Skip to content

Commit

Permalink
Update event display
Browse files Browse the repository at this point in the history
- Pad vs time view for a single row
  * visualisation of hovered time bin in ADC vs. time
- cluster overlay in pad vs. time view
  * selection of cluster flags
- Pad vs. row view for a single time bin
  * visualisation of hovered time bin in ADC vs. time
  • Loading branch information
wiechula committed Sep 23, 2024
1 parent 87ec8bb commit cdc27e0
Show file tree
Hide file tree
Showing 4 changed files with 592 additions and 54 deletions.
13 changes: 12 additions & 1 deletion Detectors/TPC/monitor/include/TPCMonitor/SimpleEventDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "TPCCalibration/CalibRawBase.h"

class TH2D;
class TH2Poly;

namespace o2
{
Expand Down Expand Up @@ -50,6 +51,8 @@ class SimpleEventDisplay : public CalibRawBase
Int_t updateCRU(const CRU& cru, const Int_t row, const Int_t pad,
const Int_t timeBin, const Float_t signal) final { return 0; }

void updateSectorHists();

CalPad* getCalPadMax() { return &mPadMax; }

CalPad* getCalPadOccupancy() { return &mPadOccupancy; }
Expand All @@ -71,6 +74,11 @@ class SimpleEventDisplay : public CalibRawBase

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

TH2D* getSigIROC() const { return mHSigIROC; }
TH2D* getSigOROC() const { return mHSigOROC; }

void fillSectorHistSingleTimeBin(TH2Poly* h, Int_t timeBin);

/// set time bin range
void setTimeBinRange(int firstBin, int lastBin)
{
Expand All @@ -79,8 +87,11 @@ class SimpleEventDisplay : public CalibRawBase
initHistograms();
}

Int_t getFirstTimeBin() const { return mFirstTimeBin; }
Int_t getLastTimeBin() const { return mLastTimeBin; }

/// Dummy end event
void endEvent() final{};
void endEvent() final {};

private:
CalPad mPadMax; ///< Cal Pad with max Entry per channel
Expand Down
41 changes: 40 additions & 1 deletion Detectors/TPC/monitor/include/TPCMonitor/SimpleEventDisplayGUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@
#define TPC_SimpleEventDisplayGUI_H_

#include <memory>
#include <string>

#include "TString.h"

#include "TPCMonitor/SimpleEventDisplay.h"
#include "DataFormatsTPC/ClusterNative.h"
#include "DataFormatsTPC/ClusterNativeHelper.h"

class TH2F;
class TH1F;
class TH1;
class TGTextEntry;
class TGTextButton;
class TGCheckButton;
class TGNumberEntry;
class TGVButtonGroup;
class TH2Poly;

namespace o2::tpc
{
Expand All @@ -47,6 +53,9 @@ class SimpleEventDisplayGUI

void toggleFFT();
void toggleOccupancy();
void togglePadTime();
void toggleSingleTimeBin();
void toggleClusters();
void monitorGui();
void exitRoot();
void update(TString clist);
Expand All @@ -60,6 +69,8 @@ class SimpleEventDisplayGUI
void next(int eventNumber = -1);
void callEventNumber();
void applySignalThreshold();
void selectTimeBin();
void showClusters(int roc, int row);

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 @@ -103,17 +114,45 @@ class SimpleEventDisplayGUI
TH2F* mHOccupancyC = nullptr;
TH2F* mHOccupancyIROC = nullptr;
TH2F* mHOccupancyOROC = nullptr;

TH2F* mHPadTimeIROC = nullptr;
TH2F* mHPadTimeOROC = nullptr;
TH2Poly* mSectorPolyTimeBin = nullptr;
TPolyMarker* mClustersIROC = nullptr;
TPolyMarker* mClustersOROC = nullptr;
TPolyMarker* mClustersRowPad = nullptr;

TGCheckButton* mCheckSingleTB = nullptr;
TGCheckButton* mCheckFFT = nullptr;
TGCheckButton* mCheckOccupancy = nullptr;
TGCheckButton* mCheckPadTime = nullptr;
TGCheckButton* mCheckShowClusters = nullptr;
static constexpr int NCheckClFlags = 5;
TGCheckButton* mCheckClFlags[NCheckClFlags] = {};
TGVButtonGroup* mFlagGroup = nullptr;
TGTextEntry* mEventNumber = nullptr;
TGTextEntry* mSignalThresholdValue = nullptr;
TGNumberEntry* mSelTimeBin = nullptr;

std::string mInputFileInfo{};

o2::tpc::ClusterNativeHelper::Reader mTPCclusterReader;
o2::tpc::ClusterNativeAccess mClusterIndex;
std::unique_ptr<o2::tpc::ClusterNative[]> mClusterBuffer;
o2::tpc::ClusterNativeHelper::ConstMCLabelContainerViewWithBuffer mClusterMCBuffer;

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

void initOccupancyHists();
void deleteOccupancyHists();

void initPadTimeHists();
void deletePadTimeHists();

void initSingleTBHists();
void deleteSingleTBHists();

void fillClusters(Long64_t entry);

ClassDefNV(SimpleEventDisplayGUI, 0);
};

Expand Down
88 changes: 78 additions & 10 deletions Detectors/TPC/monitor/src/SimpleEventDisplay.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "TH2S.h"
#include "TROOT.h"
#include "TString.h"
#include "TH2Poly.h"

#include "DataFormatsTPC/Defs.h"
#include "TPCBase/CalArray.h"
Expand Down Expand Up @@ -158,6 +159,17 @@ Int_t SimpleEventDisplay::updateROC(const Int_t roc,
return 0;
}

//_____________________________________________________________________
void SimpleEventDisplay::updateSectorHists()
{
if (mSelectedSector % 36 != mLastSelSector % 36) {
mSectorLoop = kTRUE;
processEvent(getPresentEventNumber());
mLastSelSector = mSelectedSector;
mSectorLoop = kFALSE;
}
}

//_____________________________________________________________________
TH1D* SimpleEventDisplay::makePadSignals(Int_t roc, Int_t row, Int_t pad)
{
Expand All @@ -177,17 +189,47 @@ TH1D* SimpleEventDisplay::makePadSignals(Int_t roc, Int_t row, Int_t pad)
mSelectedSector = roc;

// attention change for if event has changed
if (mSelectedSector % 36 != mLastSelSector % 36) {
mSectorLoop = kTRUE;
processEvent(getPresentEventNumber());
mLastSelSector = mSelectedSector;
mSectorLoop = kFALSE;
}
TH1D* h = nullptr;
updateSectorHists();

const Int_t nbins = mLastTimeBin - mFirstTimeBin;
if (nbins <= 0) {
return nullptr;
}

TH2D* hPadSignals = nullptr;

// ===| ADC vs. Pad vs. Time for row |========================================
TH2F* hPadTime = nullptr;
if (roc < (Int_t)mTPCmapper.getNumberOfIROCs()) {
hPadTime = static_cast<TH2F*>(gROOT->FindObject("hPadTimeValsI"));
hPadSignals = mHSigIROC;
} else {
hPadTime = static_cast<TH2F*>(gROOT->FindObject("hPadTimeValsO"));
hPadSignals = mHSigOROC;
}

static Int_t lastRoc = -1;
static Int_t lastRow = -1;
if (hPadTime && ((lastRoc != roc) || (lastRow != row))) {
hPadTime->Reset();
const auto nPads = mTPCmapper.getNumberOfPadsInRowROC(roc, row);
const auto nBins = hPadTime->GetNbinsY();
const auto shift = nBins / 2 - nPads / 2;
for (int iPad = 0; iPad < nPads; ++iPad) {
const int ichannel = mTPCmapper.getPadNumberInROC(PadROCPos(roc, row, iPad));
const Int_t offset = (nbins + 2) * (ichannel + 1);
const double* arrSig = hPadSignals->GetArray() + offset;
for (int iTime = 0; iTime < nbins; ++iTime) {
hPadTime->SetBinContent(iTime + 1, iPad + shift + 1, arrSig[iTime + 1]);
}
}
hPadTime->SetEntries(nPads * nbins);
hPadTime->SetTitle(fmt::format("Pad row {}", row).data());
hPadTime->SetUniqueID(row);
}

// ===| ADC vs. time for single pad |=========================================
TH1D* h = nullptr;
const Int_t offset = (nbins + 2) * (channel + 1);
Double_t* arrP = nullptr;

Expand All @@ -196,15 +238,15 @@ TH1D* SimpleEventDisplay::makePadSignals(Int_t roc, Int_t row, Int_t pad)
if (roc < (Int_t)mTPCmapper.getNumberOfIROCs()) {
h = (TH1D*)gROOT->FindObject("PadSignals_IROC");
if (!h) {
h = new TH1D("PadSignals_IROC", "PadSignals IROC;time bins (200ns);amplitude (ADC counts)", nbins, mFirstTimeBin, mLastTimeBin);
h = new TH1D("PadSignals_IROC", "PadSignals IROC;time bin (200ns);amplitude (ADC counts)", nbins, mFirstTimeBin, mLastTimeBin);
}
h->SetFillColor(kBlue - 10);
arrP = mHSigIROC->GetArray() + offset;
// title+="IROC ";
title += "IROC ";
} else {
h = (TH1D*)gROOT->FindObject("PadSignals_OROC");
if (!h) {
h = new TH1D("PadSignals_OROC", "PadSignals OROC;time bins (200ns);amplitude (ADC counts)", nbins, mFirstTimeBin, mLastTimeBin);
h = new TH1D("PadSignals_OROC", "PadSignals OROC;time bin (200ns);amplitude (ADC counts)", nbins, mFirstTimeBin, mLastTimeBin);
}
h->SetFillColor(kBlue - 10);
arrP = mHSigOROC->GetArray() + offset;
Expand All @@ -223,6 +265,7 @@ TH1D* SimpleEventDisplay::makePadSignals(Int_t roc, Int_t row, Int_t pad)
h->SetEntries(entries);
return h;
}

//_____________________________________________________________________
void SimpleEventDisplay::resetEvent()
{
Expand All @@ -236,3 +279,28 @@ void SimpleEventDisplay::resetEvent()
mHSigIROC->Reset();
mHSigOROC->Reset();
}

//______________________________________________________________________________
void SimpleEventDisplay::fillSectorHistSingleTimeBin(TH2Poly* h, Int_t timeBin)
{
if (!h) {
return;
}
if (timeBin < mFirstTimeBin || timeBin > mLastTimeBin) {
return;
}

int ichannel = 0;
const int iTimeBin = timeBin - mFirstTimeBin + 1;
// IROC loop
for (int ipad = 0; ipad < mHSigIROC->GetNbinsY(); ++ipad, ++ichannel) {
h->SetBinContent(ichannel + 1, mHSigIROC->GetBinContent(iTimeBin, ipad + 1));
}

// OROC loop
for (int ipad = 0; ipad < mHSigOROC->GetNbinsY(); ++ipad, ++ichannel) {
h->SetBinContent(ichannel + 1, mHSigOROC->GetBinContent(iTimeBin, ipad + 1));
}

h->SetEntries(ichannel);
}
Loading

0 comments on commit cdc27e0

Please sign in to comment.