Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TPC: Feature/o2 monitor occupancy #11745

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions Detectors/TPC/monitor/include/TPCMonitor/SimpleEventDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class SimpleEventDisplay : public CalibRawBase

CalPad* getCalPadMax() { return &mPadMax; }

CalPad* getCalPadOccupancy() { return &mPadOccupancy; }

/// Set currently selected sector
void setSelectedSector(Int_t selectedSector) { mSelectedSector = selectedSector; }

Expand All @@ -63,6 +65,10 @@ class SimpleEventDisplay : public CalibRawBase

void setPedstals(CalPad* pedestals) { mPedestals = pedestals; }

void setSignalThreshold(UInt_t signalThreshold) { mSignalThreshold = signalThreshold; }

void setShowOccupancy(bool showOccupancy) { mShowOccupancy = showOccupancy; }

TH1D* makePadSignals(Int_t roc, Int_t row, Int_t pad);

/// set time bin range
Expand All @@ -77,23 +83,26 @@ class SimpleEventDisplay : public CalibRawBase
void endEvent() final{};

private:
CalPad mPadMax; //!< Cal Pad with max Entry per channel
TH2D* mHSigIROC; //!< iroc signals
TH2D* mHSigOROC; //!< oroc signals
CalPad* mPedestals; //!< Pedestal calibratino object

Int_t mCurrentChannel; //!< current channel processed
Int_t mCurrentROC; //!< current ROC processed
Int_t mLastSector; //!< Last sector processed
Int_t mSelectedSector; //!< Sector selected for processing
Int_t mLastSelSector; //!< Last sector selected for processing
Int_t mCurrentRow; //!< current row processed
Int_t mCurrentPad; //!< current pad processed
Float_t mMaxPadSignal; //!< maximum bin of current pad
Int_t mMaxTimeBin; //!< time bin with maximum value
Bool_t mSectorLoop; //!< only process one sector
Int_t mFirstTimeBin; //!< first time bin to accept
Int_t mLastTimeBin; //!< last time bin to accept
CalPad mPadMax; //!< Cal Pad with max Entry per channel
CalPad mPadOccupancy; //!< Cal Pad with Occupancy per channel
TH2D* mHSigIROC; //!< iroc signals
TH2D* mHSigOROC; //!< oroc signals
CalPad* mPedestals; //!< Pedestal calibratino object

Int_t mCurrentChannel; //!< current channel processed
Int_t mCurrentROC; //!< current ROC processed
Int_t mLastSector; //!< Last sector processed
Int_t mSelectedSector; //!< Sector selected for processing
Int_t mLastSelSector; //!< Last sector selected for processing
Int_t mCurrentRow; //!< current row processed
Int_t mCurrentPad; //!< current pad processed
Float_t mMaxPadSignal; //!< maximum bin of current pad
Int_t mMaxTimeBin; //!< time bin with maximum value
Bool_t mSectorLoop; //!< only process one sector
Int_t mFirstTimeBin; //!< first time bin to accept
Int_t mLastTimeBin; //!< last time bin to accept
UInt_t mSignalThreshold; //!< minimum adc value
Bool_t mShowOccupancy; //!< true iff occupancy should be calculated, false otherwise

const Mapper& mTPCmapper; //! mapper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,26 @@ class SimpleEventDisplayGUI
Online = 1, ///< run online from decoded digits
};

enum HistogramType {
MaxValues = 0,
Occupancy = 1,
};

void toggleFFT();
void toggleOccupancy();
void monitorGui();
void exitRoot();
void update(TString clist);
void resetHists(int type);
void resetHists(int type, HistogramType histogramType);
void drawPadSignal(int event, int x, int y, TObject* o);
void fillMaxHists(int type = 0);
void fillHists(int type = 0, HistogramType histogramType = MaxValues);
void selectSector(int sector);
int FindROCFromXY(const float x, const float y, const int side);
void selectSectorExec(int event, int x, int y, TObject* o);
void initGUI();
void next(int eventNumber = -1);
void callEventNumber();
void applySignalThreshold();

void runSimpleEventDisplay(std::string_view fileInfo, std::string_view pedestalFile = "", int firstTimeBin = 0, int lastTimeBin = 500, int nTimeBinsPerCall = 500, uint32_t verbosity = 0, uint32_t debugLevel = 0, int selectedSector = 0, bool showSides = 1);

Expand Down Expand Up @@ -92,12 +99,21 @@ class SimpleEventDisplayGUI
TH2F* mHMaxOROC = nullptr;
TH1* mHFFTO = nullptr;
TH1* mHFFTI = nullptr;
TH2F* mHOccupancyA = nullptr;
TH2F* mHOccupancyC = nullptr;
TH2F* mHOccupancyIROC = nullptr;
TH2F* mHOccupancyOROC = nullptr;

TGCheckButton* mCheckFFT = nullptr;
TGCheckButton* mCheckOccupancy = nullptr;
TGTextEntry* mEventNumber = nullptr;
TGTextEntry* mSignalThresholdValue = nullptr;

TH1* getBinInfoXY(int& binx, int& biny, float& bincx, float& bincy);

void initOccupancyHists(void);
void deleteOccupancyHists(void);

ClassDefNV(SimpleEventDisplayGUI, 0);
};

Expand Down
32 changes: 22 additions & 10 deletions Detectors/TPC/monitor/src/SimpleEventDisplay.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ using namespace o2::tpc;

SimpleEventDisplay::SimpleEventDisplay()
: CalibRawBase(),
mPadMax(PadSubset::ROC),
mPadMax("qMax", PadSubset::ROC),
mPadOccupancy("occupancy", PadSubset::ROC),
mHSigIROC(nullptr),
mHSigOROC(nullptr),
mPedestals(nullptr),
Expand All @@ -45,7 +46,9 @@ SimpleEventDisplay::SimpleEventDisplay()
mSectorLoop(kFALSE),
mFirstTimeBin(0),
mLastTimeBin(512),
mTPCmapper(Mapper::instance())
mTPCmapper(Mapper::instance()),
mSignalThreshold(0),
mShowOccupancy(kFALSE)
{
initHistograms();
}
Expand Down Expand Up @@ -75,7 +78,7 @@ Int_t SimpleEventDisplay::updateROC(const Int_t roc,
// no extra analysis necessary. Assumes knowledge of the signal shape!
// assumes that it is looped over consecutive time bins of one pad
//
//printf("update called: %d, %d, %d, %d, %.3f\n", roc, row, pad, timeBin, signal);
// printf("update called: %d, %d, %d, %d, %.3f\n", roc, row, pad, timeBin, signal);
if (row < 0) {
return 0;
}
Expand Down Expand Up @@ -106,15 +109,15 @@ Int_t SimpleEventDisplay::updateROC(const Int_t roc,

const int iChannel = mTPCmapper.getPadNumberInROC(PadROCPos(roc, row, pad));

//init first pad and roc in this event
// init first pad and roc in this event
if (mCurrentChannel == -1) {
mCurrentChannel = iChannel;
mCurrentROC = roc;
mCurrentRow = row;
mCurrentPad = pad;
}

//process last pad if we change to a new one
// process last pad if we change to a new one
if (iChannel != mCurrentChannel) {
mLastSector = mCurrentROC;
mCurrentChannel = iChannel;
Expand All @@ -124,26 +127,34 @@ Int_t SimpleEventDisplay::updateROC(const Int_t roc,
mMaxPadSignal = 0;
}

//fill signals for current pad
// fill signals for current pad
if (mCurrentROC % 36 == mSelectedSector % 36) {
const Int_t nbins = mLastTimeBin - mFirstTimeBin;
const Int_t offset = (nbins + 2) * (iChannel + 1) + (timeBin - mFirstTimeBin) + 1;

if ((UInt_t)roc < mTPCmapper.getNumberOfIROCs()) {
mHSigIROC->GetArray()[offset] = corrSignal;
mHSigIROC->GetArray()[offset] = corrSignal >= mSignalThreshold ? corrSignal : 0;
} else {
mHSigOROC->GetArray()[offset] = corrSignal;
mHSigOROC->GetArray()[offset] = corrSignal >= mSignalThreshold ? corrSignal : 0;
}
}

CalROC& calROC = mPadMax.getCalArray(mCurrentROC);
auto val = calROC.getValue(row, pad);

if (corrSignal > val) {
if (corrSignal > val && corrSignal >= mSignalThreshold) {
calROC.setValue(row, pad, corrSignal);
mMaxPadSignal = corrSignal;
mMaxTimeBin = timeBin;
}

CalROC& calROCOccupancy = mPadOccupancy.getCalArray(mCurrentROC);
const auto occupancy = calROCOccupancy.getValue(row, pad);

if (corrSignal >= mSignalThreshold) {
calROCOccupancy.setValue(row, pad, occupancy + 1.0f);
}

return 0;
}

Expand All @@ -165,7 +176,7 @@ TH1D* SimpleEventDisplay::makePadSignals(Int_t roc, Int_t row, Int_t pad)

mSelectedSector = roc;

//attention change for if event has changed
// attention change for if event has changed
if (mSelectedSector % 36 != mLastSelSector % 36) {
mSectorLoop = kTRUE;
processEvent(getPresentEventNumber());
Expand Down Expand Up @@ -220,6 +231,7 @@ void SimpleEventDisplay::resetEvent()
//
if (!mSectorLoop) {
mPadMax.multiply(0.);
mPadOccupancy.multiply(0.);
}
mHSigIROC->Reset();
mHSigOROC->Reset();
Expand Down
Loading