From 655fc5c59af7b36aee7687791e6819b6d3d7bcfd Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Wed, 13 Dec 2023 18:27:31 +0100 Subject: [PATCH 01/15] TRD: change type of mChamberStatus to array* --- Modules/TRD/include/TRD/TrackletsTask.h | 10 +++++++++- Modules/TRD/src/TrackletsTask.cxx | 18 ++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 0be9c81acf..2f9a1174ff 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -51,6 +51,14 @@ class TrackletsTask final : public TaskInterface void drawHashedOnHistsPerLayer(int layer); //, int hcid, int rowstart, int rowend); void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); + // Auxiliary functions + bool isChamberMasked(int chamberId, const std::array* ptrChamber) { + // List here the chamber status to be masked + int BadStatus[] = {1}; + int ChamberStatus = (*ptrChamber)[chamberId]; + return (std::find(std::begin(BadStatus), std::end(BadStatus), ChamberStatus) != std::end(BadStatus)); + } + private: // settings bool mRemoveNoise{ false }; @@ -69,7 +77,7 @@ class TrackletsTask final : public TaskInterface // data to pull from CCDB const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; - const o2::trd::HalfChamberStatusQC* mChamberStatus = nullptr; + const std::array* mChamberStatus = nullptr; }; } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index fa4b49b9bf..6ad8199ab2 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -155,7 +155,8 @@ void TrackletsTask::buildHistograms() std::pair x, y; for (int iHC = 0; iHC < NCHAMBER * 2; ++iHC) { if (mChamberStatus != nullptr) { - if (mChamberStatus->isMasked(iHC)) { + // if (mChamberStatus->isMasked(iHC)) { + if (isChamberMasked(iHC, mChamberStatus)) { int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); x.first = sectorSide; @@ -193,7 +194,7 @@ void TrackletsTask::buildHistograms() mTriggersPerTimeFrame = new TH1F("triggerspertimeframe", "Number of Triggers per timeframe;Triggers in TimeFrame;Counts", 1000, 0, 1000); getObjectsManager()->startPublishing(mTriggersPerTimeFrame); - buildTrackletLayers(); + //buildTrackletLayers(); } void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) @@ -252,7 +253,8 @@ void TrackletsTask::drawHashedOnHistsPerLayer(int iLayer) int hcid = (side == 0) ? det * 2 : det * 2 + 1; int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector - if (mChamberStatus->isMasked(hcid) && (!hciddone.test(hcid))) { + // if (mChamberStatus->isMasked(hcid) && (!hciddone.test(hcid))) { + if (isChamberMasked(hcid, mChamberStatus) && (!hciddone.test(hcid))) { drawHashOnLayers(iLayer, hcid, rowstart, rowend); hciddone.set(hcid); } @@ -283,14 +285,22 @@ void TrackletsTask::startOfCycle() void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) { + buildTrackletLayers(); + // Load CCDB objects (needs to be done only once) if (!mNoiseMap) { auto ptr = ctx.inputs().get("noiseMap"); mNoiseMap = ptr.get(); } + if (!mChamberStatus) { - auto ptr = ctx.inputs().get("chamberStatus"); + auto ptr = ctx.inputs().get*>("chamberStatus"); mChamberStatus = ptr.get(); + auto ChamberStatusArray = *mChamberStatus; + for (int i = 0; i < o2::trd::constants::MAXCHAMBER; i++) { + std::cout << "Chamber ID = " << i << ",\tstatus = " << ChamberStatusArray[i] << std::endl; + } + } auto tracklets = ctx.inputs().get>("tracklets"); From 6ce5adefd4211c3d992c88471f32cd4cc18656b5 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Wed, 13 Dec 2023 21:40:50 +0100 Subject: [PATCH 02/15] TRD: create separate function to plot chamber status --- Modules/TRD/include/TRD/TrackletsTask.h | 9 +- Modules/TRD/src/TrackletsTask.cxx | 139 ++++++++++++------------ 2 files changed, 73 insertions(+), 75 deletions(-) diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 2f9a1174ff..9b8d60d11b 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -48,15 +48,16 @@ class TrackletsTask final : public TaskInterface void drawLinesMCM(TH2F* histo); void drawTrdLayersGrid(TH2F* hist); void buildTrackletLayers(); - void drawHashedOnHistsPerLayer(int layer); //, int hcid, int rowstart, int rowend); + //void drawHashedOnHistsPerLayer(int layer); //, int hcid, int rowstart, int rowend); void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); + void drawChamberStatus(); // Auxiliary functions - bool isChamberMasked(int chamberId, const std::array* ptrChamber) { + bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) { // List here the chamber status to be masked int BadStatus[] = {1}; - int ChamberStatus = (*ptrChamber)[chamberId]; - return (std::find(std::begin(BadStatus), std::end(BadStatus), ChamberStatus) != std::end(BadStatus)); + int hcStatus = (*ptrChamber)[hcId / 2]; + return (std::find(std::begin(BadStatus), std::end(BadStatus), hcStatus) != std::end(BadStatus)); } private: diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index 6ad8199ab2..d681c5c857 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -91,6 +91,7 @@ void TrackletsTask::drawTrdLayersGrid(TH2F* hist) break; } } + for (int iSec = 1; iSec < 18; ++iSec) { float yPos = iSec * 8 - 0.5; line = new TLine(-0.5, yPos, 75.5, yPos); @@ -142,6 +143,7 @@ void TrackletsTask::buildHistograms() mTrackletsPerHC2D->GetYaxis()->SetBinLabel(pos, label.c_str()); } } + for (int sm = 0; sm < NSECTOR; ++sm) { for (int side = 0; side < 2; ++side) { std::string label = fmt::format("{0}_{1}", sm, side == 0 ? "A" : "B"); @@ -150,33 +152,6 @@ void TrackletsTask::buildHistograms() } } - // Mask known inactive halfchambers in the active chamber map - TLine* line[6]; - std::pair x, y; - for (int iHC = 0; iHC < NCHAMBER * 2; ++iHC) { - if (mChamberStatus != nullptr) { - // if (mChamberStatus->isMasked(iHC)) { - if (isChamberMasked(iHC, mChamberStatus)) { - int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); - int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); - x.first = sectorSide; - x.second = sectorSide + 1; - y.first = stackLayer; - y.second = stackLayer + 1; - - line[0] = new TLine(x.first, y.first, x.second, y.second); - line[1] = new TLine(x.second, y.first, x.first, y.second); - line[2] = new TLine(x.first, y.first, x.second, y.first); - line[3] = new TLine(x.first, y.second, x.second, y.second); - line[4] = new TLine(x.first, y.first, x.first, y.second); - line[5] = new TLine(x.second, y.first, x.second, y.second); - for (int i = 0; i < 6; ++i) { - line[i]->SetLineColor(kBlack); - mTrackletsPerHC2D->GetListOfFunctions()->Add(line[i]); - } - } - } - } getObjectsManager()->startPublishing(mTrackletsPerHC2D); getObjectsManager()->setDefaultDrawOptions("trackletsperHC2D", "COLZ"); getObjectsManager()->setDisplayHint(mTrackletsPerHC2D->GetName(), "logz"); @@ -194,7 +169,7 @@ void TrackletsTask::buildHistograms() mTriggersPerTimeFrame = new TH1F("triggerspertimeframe", "Number of Triggers per timeframe;Triggers in TimeFrame;Counts", 1000, 0, 1000); getObjectsManager()->startPublishing(mTriggersPerTimeFrame); - //buildTrackletLayers(); + buildTrackletLayers(); } void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) @@ -202,7 +177,7 @@ void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowe // instead of using overlays, draw a simple box in red with a cross on it. std::pair topright, bottomleft; // coordinates of box - TLine* boxlines[9]; + TLine* boxlines[6]; int det = hcid / 2; int side = hcid % 2; int sec = hcid / 60; @@ -211,18 +186,15 @@ void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowe topright.first = rowend - 0.5; topright.second = (sec * 2 + side) * 4 + 4 - 0.5; - // LOG(info) << "Box for layer : " << layer << " hcid : " << hcid << ": " << bottomleft.first << ":" << bottomleft.second << " -- " << topright.first << ":" << topright.second; - boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom - boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top - boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left - boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right - boxlines[4] = new TLine(bottomleft.first, topright.second - (topright.second - bottomleft.second) / 2, topright.first, topright.second - (topright.second - bottomleft.second) / 2); // horizontal middle - boxlines[5] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash - boxlines[6] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - boxlines[7] = new TLine(bottomleft.first + (topright.first - bottomleft.first) / 2, bottomleft.second, bottomleft.first + (topright.first - bottomleft.first) / 2, topright.second); // vertical middle - boxlines[8] = new TLine(bottomleft.first, bottomleft.second + (topright.second - bottomleft.second) / 2, topright.first, bottomleft.second + (topright.second - bottomleft.second) / 2); // bottom - for (int line = 0; line < 9; ++line) { - boxlines[line]->SetLineColor(kBlack); + boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom + boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top + boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left + boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right + boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash + boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash + for (int line = 0; line < 6; ++line) { + boxlines[line]->SetLineColor(kRed); + boxlines[line]->SetLineWidth(4); mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); } } @@ -233,39 +205,12 @@ void TrackletsTask::buildTrackletLayers() mLayers[iLayer] = new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), 76, -0.5, 75.5, 144, -0.5, 143.5); mLayers[iLayer]->SetStats(0); drawTrdLayersGrid(mLayers[iLayer]); - drawHashedOnHistsPerLayer(iLayer); getObjectsManager()->startPublishing(mLayers[iLayer]); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer], "logz"); } } -void TrackletsTask::drawHashedOnHistsPerLayer(int iLayer) -{ - std::bitset<1080> hciddone; - hciddone.reset(); - if (mChamberStatus != nullptr) { - for (int iSec = 0; iSec < 18; ++iSec) { - for (int iStack = 0; iStack < 5; ++iStack) { - int rowMax = (iStack == 2) ? 12 : 16; - for (int side = 0; side < 2; ++side) { - int det = iSec * 30 + iStack * 6 + iLayer; - int hcid = (side == 0) ? det * 2 : det * 2 + 1; - int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector - int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector - // if (mChamberStatus->isMasked(hcid) && (!hciddone.test(hcid))) { - if (isChamberMasked(hcid, mChamberStatus) && (!hciddone.test(hcid))) { - drawHashOnLayers(iLayer, hcid, rowstart, rowend); - hciddone.set(hcid); - } - } - } - } - } else { - ILOG(Info, Support) << " Failed to retrieve ChamberStatus, so it will be blank" << ENDM; - } -} - void TrackletsTask::initialize(o2::framework::InitContext& /*ctx*/) { ILOG(Debug, Devel) << "initialize TrackletsTask" << ENDM; @@ -285,8 +230,6 @@ void TrackletsTask::startOfCycle() void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) { - buildTrackletLayers(); - // Load CCDB objects (needs to be done only once) if (!mNoiseMap) { auto ptr = ctx.inputs().get("noiseMap"); @@ -302,7 +245,6 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) } } - auto tracklets = ctx.inputs().get>("tracklets"); auto triggerrecords = ctx.inputs().get>("triggers"); mTrackletsPerTimeFrame->Fill(tracklets.size()); @@ -335,6 +277,61 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) mLayers[layer]->Fill(rowGlb, colGlb); } } + drawChamberStatus(); +} + +void TrackletsTask::drawChamberStatus() +{ + // LB: draw Xs on plots given the Chamber status after histograms are built + // Mask known inactive halfchambers in the active chamber map + if (mChamberStatus != nullptr) { + // LB: draw in mTrackletsPerHC2D + TLine* line[6]; + std::pair x, y; + for (int iHC = 0; iHC < NCHAMBER * 2; ++iHC) { + if (isHalfChamberMasked(iHC, mChamberStatus)) { + int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); + int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); + x.first = sectorSide; + x.second = sectorSide + 1; + y.first = stackLayer; + y.second = stackLayer + 1; + + line[0] = new TLine(x.first, y.first, x.second, y.second); + line[1] = new TLine(x.second, y.first, x.first, y.second); + line[2] = new TLine(x.first, y.first, x.second, y.first); + line[3] = new TLine(x.first, y.second, x.second, y.second); + line[4] = new TLine(x.first, y.first, x.first, y.second); + line[5] = new TLine(x.second, y.first, x.second, y.second); + for (int i = 0; i < 6; ++i) { + //line[i]->SetLineColor(kBlack); + line[i]->SetLineColor(kRed); + line[i]->SetLineWidth(4); + mTrackletsPerHC2D->GetListOfFunctions()->Add(line[i]); + } + } + } + + // LB: draw in mLayers elements + for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { + for (int iSec = 0; iSec < 18; ++iSec) { + for (int iStack = 0; iStack < 5; ++iStack) { + int rowMax = (iStack == 2) ? 12 : 16; + for (int side = 0; side < 2; ++side) { + int det = iSec * 30 + iStack * 6 + iLayer; + int hcid = (side == 0) ? det * 2 : det * 2 + 1; + int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector + int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector + if (isHalfChamberMasked(hcid, mChamberStatus)) { + drawHashOnLayers(iLayer, hcid, rowstart, rowend); + } + } + } + } + } + } else { + ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; + } } void TrackletsTask::endOfCycle() From 9a8cebd36aae506a0e824340893095efda306558 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Thu, 14 Dec 2023 16:53:59 +0100 Subject: [PATCH 03/15] TRD: functions clean up --- Modules/TRD/include/TRD/TrackletsTask.h | 9 +- Modules/TRD/src/TrackletsTask.cxx | 291 +++++++++++------------- 2 files changed, 136 insertions(+), 164 deletions(-) diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 9b8d60d11b..8069f35252 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -45,19 +45,16 @@ class TrackletsTask final : public TaskInterface void endOfActivity(const Activity& activity) override; void reset() override; void buildHistograms(); - void drawLinesMCM(TH2F* histo); void drawTrdLayersGrid(TH2F* hist); - void buildTrackletLayers(); - //void drawHashedOnHistsPerLayer(int layer); //, int hcid, int rowstart, int rowend); void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); void drawChamberStatus(); // Auxiliary functions bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) { - // List here the chamber status to be masked - int BadStatus[] = {1}; + // List here the chamber status to not be masked, anything different returns true + int GoodStatus[] = {0, 3}; int hcStatus = (*ptrChamber)[hcId / 2]; - return (std::find(std::begin(BadStatus), std::end(BadStatus), hcStatus) != std::end(BadStatus)); + return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); } private: diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index d681c5c857..969950fb0c 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -41,64 +41,11 @@ using Helper = o2::trd::HelperMethods; namespace o2::quality_control_modules::trd { -void TrackletsTask::drawLinesMCM(TH2F* histo) -{ - TLine* l; - Int_t nPos[NSTACK - 1] = { 16, 32, 44, 60 }; - - for (Int_t iStack = 0; iStack < NSTACK - 1; ++iStack) { - l = new TLine(nPos[iStack] - 0.5, -0.5, nPos[iStack] - 0.5, 47.5); - l->SetLineStyle(2); - histo->GetListOfFunctions()->Add(l); - } - - for (Int_t iLayer = 0; iLayer < NLAYER; ++iLayer) { - l = new TLine(-0.5, iLayer * 8 - 0.5, 75.5, iLayer * 8 - 0.5); - l = new TLine(0.5, iLayer * 8 - 0.5, 75.5, iLayer * 8 - 0.5); - l->SetLineStyle(2); - histo->GetListOfFunctions()->Add(l); - } -} - -void TrackletsTask::drawTrdLayersGrid(TH2F* hist) +void TrackletsTask::initialize(o2::framework::InitContext& /*ctx*/) { - TLine* line; - for (int i = 0; i < 5; ++i) { - switch (i) { - case 0: - line = new TLine(15.5, 0, 15.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 1: - line = new TLine(31.5, 0, 31.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 2: - line = new TLine(43.5, 0, 43.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 3: - line = new TLine(59.5, 0, 59.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - } - } - - for (int iSec = 1; iSec < 18; ++iSec) { - float yPos = iSec * 8 - 0.5; - line = new TLine(-0.5, yPos, 75.5, yPos); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - hist->GetListOfFunctions()->Add(line); - } + ILOG(Debug, Devel) << "initialize TrackletsTask" << ENDM; + mRemoveNoise = getFromConfig(mCustomParameters, "removeNoise", false); + buildHistograms(); } void TrackletsTask::buildHistograms() @@ -169,40 +116,10 @@ void TrackletsTask::buildHistograms() mTriggersPerTimeFrame = new TH1F("triggerspertimeframe", "Number of Triggers per timeframe;Triggers in TimeFrame;Counts", 1000, 0, 1000); getObjectsManager()->startPublishing(mTriggersPerTimeFrame); - buildTrackletLayers(); -} - -void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) -{ - // instead of using overlays, draw a simple box in red with a cross on it. - - std::pair topright, bottomleft; // coordinates of box - TLine* boxlines[6]; - int det = hcid / 2; - int side = hcid % 2; - int sec = hcid / 60; - bottomleft.first = rowstart - 0.5; - bottomleft.second = (sec * 2 + side) * 4 - 0.5; - topright.first = rowend - 0.5; - topright.second = (sec * 2 + side) * 4 + 4 - 0.5; - - boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom - boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top - boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left - boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right - boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash - boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - for (int line = 0; line < 6; ++line) { - boxlines[line]->SetLineColor(kRed); - boxlines[line]->SetLineWidth(4); - mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); - } -} - -void TrackletsTask::buildTrackletLayers() -{ + // Build tracklet layers for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { - mLayers[iLayer] = new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), 76, -0.5, 75.5, 144, -0.5, 143.5); + mLayers[iLayer] = new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), + 76, -0.5, 75.5, 144, -0.5, 143.5); mLayers[iLayer]->SetStats(0); drawTrdLayersGrid(mLayers[iLayer]); getObjectsManager()->startPublishing(mLayers[iLayer]); @@ -211,23 +128,6 @@ void TrackletsTask::buildTrackletLayers() } } -void TrackletsTask::initialize(o2::framework::InitContext& /*ctx*/) -{ - ILOG(Debug, Devel) << "initialize TrackletsTask" << ENDM; - mRemoveNoise = getFromConfig(mCustomParameters, "removeNoise", false); - buildHistograms(); -} - -void TrackletsTask::startOfActivity(const Activity& activity) -{ - ILOG(Debug, Devel) << "startOfActivity " << activity.mId << ENDM; -} - -void TrackletsTask::startOfCycle() -{ - ILOG(Debug, Devel) << "startOfCycle" << ENDM; -} - void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) { // Load CCDB objects (needs to be done only once) @@ -237,14 +137,17 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) } if (!mChamberStatus) { - auto ptr = ctx.inputs().get*>("chamberStatus"); + auto ptr = ctx.inputs().get*>("chamberStatus"); mChamberStatus = ptr.get(); - auto ChamberStatusArray = *mChamberStatus; - for (int i = 0; i < o2::trd::constants::MAXCHAMBER; i++) { - std::cout << "Chamber ID = " << i << ",\tstatus = " << ChamberStatusArray[i] << std::endl; - } - } + + if (mChamberStatus != nullptr) { + drawChamberStatus(); + } else { + ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; + } + + // Fill histograms auto tracklets = ctx.inputs().get>("tracklets"); auto triggerrecords = ctx.inputs().get>("triggers"); mTrackletsPerTimeFrame->Fill(tracklets.size()); @@ -277,61 +180,134 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) mLayers[layer]->Fill(rowGlb, colGlb); } } - drawChamberStatus(); } void TrackletsTask::drawChamberStatus() { - // LB: draw Xs on plots given the Chamber status after histograms are built - // Mask known inactive halfchambers in the active chamber map - if (mChamberStatus != nullptr) { - // LB: draw in mTrackletsPerHC2D - TLine* line[6]; - std::pair x, y; - for (int iHC = 0; iHC < NCHAMBER * 2; ++iHC) { - if (isHalfChamberMasked(iHC, mChamberStatus)) { - int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); - int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); - x.first = sectorSide; - x.second = sectorSide + 1; - y.first = stackLayer; - y.second = stackLayer + 1; - - line[0] = new TLine(x.first, y.first, x.second, y.second); - line[1] = new TLine(x.second, y.first, x.first, y.second); - line[2] = new TLine(x.first, y.first, x.second, y.first); - line[3] = new TLine(x.first, y.second, x.second, y.second); - line[4] = new TLine(x.first, y.first, x.first, y.second); - line[5] = new TLine(x.second, y.first, x.second, y.second); - for (int i = 0; i < 6; ++i) { - //line[i]->SetLineColor(kBlack); - line[i]->SetLineColor(kRed); - line[i]->SetLineWidth(4); - mTrackletsPerHC2D->GetListOfFunctions()->Add(line[i]); - } + // Mask known inactive halfchambers in the active chamber map with a X + // LB: draw in mTrackletsPerHC2D + TLine* line[6]; + std::pair x, y; + for (int iHC = 0; iHC < MAXCHAMBER * 2; ++iHC) { + if (isHalfChamberMasked(iHC, mChamberStatus)) { + int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); + int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); + x.first = sectorSide; + x.second = sectorSide + 1; + y.first = stackLayer; + y.second = stackLayer + 1; + + line[0] = new TLine(x.first, y.first, x.second, y.second); + line[1] = new TLine(x.second, y.first, x.first, y.second); + line[2] = new TLine(x.first, y.first, x.second, y.first); + line[3] = new TLine(x.first, y.second, x.second, y.second); + line[4] = new TLine(x.first, y.first, x.first, y.second); + line[5] = new TLine(x.second, y.first, x.second, y.second); + for (int i = 0; i < 6; ++i) { + line[i]->SetLineColor(kBlack); + line[i]->SetLineWidth(3); + mTrackletsPerHC2D->GetListOfFunctions()->Add(line[i]); } } + } - // LB: draw in mLayers elements - for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { - for (int iSec = 0; iSec < 18; ++iSec) { - for (int iStack = 0; iStack < 5; ++iStack) { - int rowMax = (iStack == 2) ? 12 : 16; - for (int side = 0; side < 2; ++side) { - int det = iSec * 30 + iStack * 6 + iLayer; - int hcid = (side == 0) ? det * 2 : det * 2 + 1; - int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector - int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector - if (isHalfChamberMasked(hcid, mChamberStatus)) { - drawHashOnLayers(iLayer, hcid, rowstart, rowend); - } + // LB: draw in mLayers elements + for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { + for (int iSec = 0; iSec < 18; ++iSec) { + for (int iStack = 0; iStack < 5; ++iStack) { + int rowMax = (iStack == 2) ? 12 : 16; + for (int side = 0; side < 2; ++side) { + int det = iSec * 30 + iStack * 6 + iLayer; + int hcid = (side == 0) ? det * 2 : det * 2 + 1; + int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector + int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector + if (isHalfChamberMasked(hcid, mChamberStatus)) { + drawHashOnLayers(iLayer, hcid, rowstart, rowend); } } } } - } else { - ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; - } + } +} + +void TrackletsTask::drawTrdLayersGrid(TH2F* hist) +{ + TLine* line; + for (int i = 0; i < 5; ++i) { + switch (i) { + case 0: + line = new TLine(15.5, 0, 15.5, 143.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 1: + line = new TLine(31.5, 0, 31.5, 143.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 2: + line = new TLine(43.5, 0, 43.5, 143.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 3: + line = new TLine(59.5, 0, 59.5, 143.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + } + } + + for (int iSec = 1; iSec < 18; ++iSec) { + float yPos = iSec * 8 - 0.5; + line = new TLine(-0.5, yPos, 75.5, yPos); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + hist->GetListOfFunctions()->Add(line); + } +} + +void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) +{ + // instead of using overlays, draw a simple box in red with a cross on it. + + std::pair topright, bottomleft; // coordinates of box + TLine* boxlines[6]; + int det = hcid / 2; + int side = hcid % 2; + int sec = hcid / 60; + + bottomleft.first = rowstart - 0.5; + bottomleft.second = (sec * 2 + side) * 4 - 0.5; + topright.first = rowend - 0.5; + topright.second = (sec * 2 + side) * 4 + 4 - 0.5; + + boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom + boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top + boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left + boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right + boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash + boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash + + for (int line = 0; line < 6; ++line) { + boxlines[line]->SetLineColor(kRed); + boxlines[line]->SetLineWidth(4); + mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); + } +} + +void TrackletsTask::startOfActivity(const Activity& activity) +{ + ILOG(Debug, Devel) << "startOfActivity " << activity.mId << ENDM; +} + +void TrackletsTask::startOfCycle() +{ + ILOG(Debug, Devel) << "startOfCycle" << ENDM; } void TrackletsTask::endOfCycle() @@ -347,7 +323,6 @@ void TrackletsTask::endOfActivity(const Activity& /*activity*/) void TrackletsTask::reset() { // clean all the monitor objects here - ILOG(Debug, Devel) << "Resetting the histograms" << ENDM; mTrackletSlope->Reset(); mTrackletHCID->Reset(); From 90beb83c28bd3f56fcd1a33dce2e428a41777dbd Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Fri, 15 Dec 2023 14:44:05 +0100 Subject: [PATCH 04/15] TRD: apply chamber status changes to digits task --- Modules/TRD/include/TRD/DigitsTask.h | 17 +- Modules/TRD/src/DigitsTask.cxx | 334 ++++++++++++++------------- 2 files changed, 183 insertions(+), 168 deletions(-) diff --git a/Modules/TRD/include/TRD/DigitsTask.h b/Modules/TRD/include/TRD/DigitsTask.h index bcfa961fb2..4d2670c450 100644 --- a/Modules/TRD/include/TRD/DigitsTask.h +++ b/Modules/TRD/include/TRD/DigitsTask.h @@ -47,11 +47,20 @@ class DigitsTask final : public TaskInterface void endOfActivity(const Activity& activity) override; void reset() override; void buildHistograms(); - void drawTrdLayersGrid(TH2F* hist); void drawLinesOnPulseHeight(TH1F* h); - void fillLinesOnHistsPerLayer(int iLayer); - void drawHashOnLayers(int layer, int hcid, int col, int rowstart, int rowend); + void drawTrdLayersGrid(TH2F* hist); + void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); + void drawChamberStatus(); void buildChamberIgnoreBP(); + + // Auxiliary functions + // Duplicated from TrackletsTask.h + bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) { + // List here the chamber status to not be masked, anything different returns true + int GoodStatus[] = {0, 3}; // Make sure to match the same array in TrackletsTask.h + int hcStatus = (*ptrChamber)[hcId / 2]; + return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); + } private: // user settings @@ -87,7 +96,7 @@ class DigitsTask final : public TaskInterface // CCDB objects const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; - const o2::trd::HalfChamberStatusQC* mChamberStatus = nullptr; + const std::array* mChamberStatus = nullptr; }; } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index 2d1e9542c2..fdbc5bc4eb 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -41,143 +41,21 @@ using Helper = o2::trd::HelperMethods; namespace o2::quality_control_modules::trd { -void DigitsTask::buildChamberIgnoreBP() -{ - mChambersToIgnoreBP.reset(); - // Vector of string to save tokens - std::vector tokens; - // stringstream class check1 - std::stringstream check1(mChambersToIgnore); - std::string intermediate; - // Tokenizing w.r.t. space ',' - while (getline(check1, intermediate, ',')) { - tokens.push_back(intermediate); - } - // Printing the token vector - for (auto& token : tokens) { - // token now holds something like 16_3_0 - std::vector parts; - std::stringstream indexcheck(token); - std::string tokenpart; - // Tokenizing w.r.t. space ',' - while (getline(indexcheck, tokenpart, '_')) { - parts.push_back(tokenpart); - } - // now flip the bit related to the sector:stack:layer stored in parts. - int sector = std::stoi(parts[0]); - int stack = std::stoi(parts[1]); - int layer = std::stoi(parts[2]); - mChambersToIgnoreBP.set(Helper::getDetector(sector, stack, layer)); - } -} - -void DigitsTask::drawTrdLayersGrid(TH2F* hist) -{ - TLine* line; - for (int i = 0; i < 5; ++i) { - switch (i) { - case 0: - line = new TLine(15.5, 0, 15.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 1: - line = new TLine(31.5, 0, 31.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 2: - line = new TLine(43.5, 0, 43.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 3: - line = new TLine(59.5, 0, 59.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - } - } - for (int iSec = 1; iSec < 18; ++iSec) { - float yPos = iSec * 144 - 0.5; - line = new TLine(0, yPos, 76, yPos); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - hist->GetListOfFunctions()->Add(line); - } - - ILOG(Info, Support) << "Layer Grid redrawn in check for : " << hist->GetName() << ENDM; - ILOG(Info, Support) << "Layer Grid redrawn in hist has function count of : " << hist->GetListOfFunctions()->GetSize() << ENDM; -} - -void DigitsTask::drawLinesOnPulseHeight(TH1F* h) +void DigitsTask::initialize(o2::framework::InitContext& /*ctx*/) { - TLine* lmin = new TLine(mPulseHeightPeakRegion.first, 0, mPulseHeightPeakRegion.first, 1e9); - TLine* lmax = new TLine(mPulseHeightPeakRegion.second, 0, mPulseHeightPeakRegion.second, 1e9); - lmin->SetLineStyle(2); - lmax->SetLineStyle(2); - lmin->SetLineColor(kRed); - lmax->SetLineColor(kRed); - h->GetListOfFunctions()->Add(lmin); - h->GetListOfFunctions()->Add(lmax); -} + ILOG(Debug, Devel) << "initialize TRDDigitQcTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well. -void DigitsTask::drawHashOnLayers(int layer, int hcid, int col, int rowstart, int rowend) -{ - // instead of using overlays, draw a simple box in red with a cross on it. - std::pair topright, bottomleft; // coordinates of box - TLine* boxlines[8]; - int det = hcid / 2; - int side = hcid % 2; - int sec = hcid / 60; - bottomleft.first = rowstart - 0.5; - bottomleft.second = (sec * 2 + side) * 72; - topright.first = rowend - 0.5; - topright.second = (sec * 2 + side) * 72 + 72; - - // LOG(info) << "Box for layer : " << layer << " hcid : " << hcid << ": " << bottomleft.first << ":" << bottomleft.second << "(" << bottomleft.second/144 << ") -- " << topright.first << ":" << topright.second << "(" << topright.second/144 << ")"; - boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom - boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top - boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left - boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right - boxlines[4] = new TLine(bottomleft.first, topright.second - (topright.second - bottomleft.second) / 2, topright.first, topright.second - (topright.second - bottomleft.second) / 2); // horizontal middle - boxlines[5] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash - boxlines[6] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - boxlines[7] = new TLine(bottomleft.first + (topright.first - bottomleft.first) / 2, bottomleft.second, bottomleft.first + (topright.first - bottomleft.first) / 2, topright.second); // vertical middle - for (int line = 0; line < 8; ++line) { - boxlines[line]->SetLineColor(kBlack); - mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); - } -} + // this is how to get access to custom parameters defined in the config file at qc.tasks..taskParameters + mDoClusterize = getFromConfig(mCustomParameters, "doClusterize", false); + mPulseHeightPeakRegion.first = getFromConfig(mCustomParameters, "peakRegionStart", 0.f); + mPulseHeightPeakRegion.second = getFromConfig(mCustomParameters, "peakRegionEnd", 5.f); + mPulseHeightThreshold = getFromConfig(mCustomParameters, "phThreshold", 400u); + mChambersToIgnore = getFromConfig(mCustomParameters, "ignoreChambers", "16_3_0"); + mClsCutoff = getFromConfig(mCustomParameters, "clsCutoff", 1000); + mAdcBaseline = getFromConfig(mCustomParameters, "adcBaseline", 10); -void DigitsTask::fillLinesOnHistsPerLayer(int iLayer) -{ - std::bitset hciddone; - hciddone.reset(); - if (mChamberStatus == nullptr) { - // protect for if the chamber status is not pulled from the ccdb for what ever reason. - ILOG(Info, Support) << "No half chamber status object to be able to fill the mask" << ENDM; - } else { - for (int iSec = 0; iSec < 18; ++iSec) { - for (int iStack = 0; iStack < 5; ++iStack) { - int rowMax = (iStack == 2) ? 12 : 16; - for (int side = 0; side < 2; ++side) { - int det = iSec * 30 + iStack * 6 + iLayer; - int hcid = (side == 0) ? det * 2 : det * 2 + 1; - int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector - int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector - if (mChamberStatus->isMasked(hcid) && (!hciddone.test(hcid))) { - drawHashOnLayers(iLayer, hcid, 0, rowstart, rowend); - hciddone.set(hcid); // to avoid mutliple instances of adding lines - } - } - } - } - } + buildChamberIgnoreBP(); + buildHistograms(); } void DigitsTask::buildHistograms() @@ -247,43 +125,16 @@ void DigitsTask::buildHistograms() } for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { - mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), 76, -0.5, 75.5, 2592, -0.5, 2591.5)); + mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), + 76, -0.5, 75.5, 2592, -0.5, 2591.5)); mLayers[iLayer]->SetStats(0); drawTrdLayersGrid(mLayers[iLayer].get()); - fillLinesOnHistsPerLayer(iLayer); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); } } -void DigitsTask::initialize(o2::framework::InitContext& /*ctx*/) -{ - ILOG(Debug, Devel) << "initialize TRDDigitQcTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well. - - // this is how to get access to custom parameters defined in the config file at qc.tasks..taskParameters - mDoClusterize = getFromConfig(mCustomParameters, "doClusterize", false); - mPulseHeightPeakRegion.first = getFromConfig(mCustomParameters, "peakRegionStart", 0.f); - mPulseHeightPeakRegion.second = getFromConfig(mCustomParameters, "peakRegionEnd", 5.f); - mPulseHeightThreshold = getFromConfig(mCustomParameters, "phThreshold", 400u); - mChambersToIgnore = getFromConfig(mCustomParameters, "ignoreChambers", "16_3_0"); - mClsCutoff = getFromConfig(mCustomParameters, "clsCutoff", 1000); - mAdcBaseline = getFromConfig(mCustomParameters, "adcBaseline", 10); - - buildChamberIgnoreBP(); - buildHistograms(); -} - -void DigitsTask::startOfActivity(const Activity& /*activity*/) -{ - ILOG(Debug, Devel) << "startOfActivity" << ENDM; -} // set stats/stacs - -void DigitsTask::startOfCycle() -{ - ILOG(Debug, Devel) << "startOfCycle" << ENDM; -} - void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) { // Load CCDB objects (needs to be done only once) @@ -292,10 +143,17 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) mNoiseMap = ptr.get(); } if (!mChamberStatus) { - auto ptr = ctx.inputs().get("chamberStatus"); + auto ptr = ctx.inputs().get*>("chamberStatus"); mChamberStatus = ptr.get(); } + if (mChamberStatus != nullptr) { + drawChamberStatus(); + } else { + ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; + } + + // fill histograms auto digits = ctx.inputs().get>("digits"); auto triggerrecords = ctx.inputs().get>("triggers"); for (auto& trigger : triggerrecords) { @@ -418,6 +276,154 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) } // loop over triggers } +void DigitsTask::drawChamberStatus() +{ + // Mask known inactive halfchambers in the active chamber map with a X + // LB: draw in mLayers elements + for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { + for (int iSec = 0; iSec < 18; ++iSec) { + for (int iStack = 0; iStack < 5; ++iStack) { + int rowMax = (iStack == 2) ? 12 : 16; + for (int side = 0; side < 2; ++side) { + int det = iSec * 30 + iStack * 6 + iLayer; + int hcid = (side == 0) ? det * 2 : det * 2 + 1; + int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector + int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector + if (isHalfChamberMasked(hcid, mChamberStatus)) { + drawHashOnLayers(iLayer, hcid, rowstart, rowend); + } + } + } + } + } +} + +void DigitsTask::drawTrdLayersGrid(TH2F* hist) +{ + TLine* line; + for (int i = 0; i < 5; ++i) { + switch (i) { + case 0: + line = new TLine(15.5, 0, 15.5, 2592); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 1: + line = new TLine(31.5, 0, 31.5, 2592); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 2: + line = new TLine(43.5, 0, 43.5, 2592); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 3: + line = new TLine(59.5, 0, 59.5, 2592); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + } + } + for (int iSec = 1; iSec < 18; ++iSec) { + float yPos = iSec * 144 - 0.5; + line = new TLine(0, yPos, 76, yPos); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + hist->GetListOfFunctions()->Add(line); + } + + ILOG(Info, Support) << "Layer Grid redrawn in check for : " << hist->GetName() << ENDM; + ILOG(Info, Support) << "Layer Grid redrawn in hist has function count of : " << hist->GetListOfFunctions()->GetSize() << ENDM; +} + +void DigitsTask::drawLinesOnPulseHeight(TH1F* h) +{ + TLine* lmin = new TLine(mPulseHeightPeakRegion.first, 0, mPulseHeightPeakRegion.first, 1e9); + TLine* lmax = new TLine(mPulseHeightPeakRegion.second, 0, mPulseHeightPeakRegion.second, 1e9); + lmin->SetLineStyle(2); + lmax->SetLineStyle(2); + lmin->SetLineColor(kRed); + lmax->SetLineColor(kRed); + h->GetListOfFunctions()->Add(lmin); + h->GetListOfFunctions()->Add(lmax); +} + +void DigitsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) +{ + // instead of using overlays, draw a simple box in red with a cross on it. + + std::pair topright, bottomleft; // coordinates of box + TLine* boxlines[6]; + int det = hcid / 2; + int side = hcid % 2; + int sec = hcid / 60; + + bottomleft.first = rowstart - 0.5; + bottomleft.second = (sec * 2 + side) * 72; + topright.first = rowend - 0.5; + topright.second = (sec * 2 + side) * 72 + 72; + + boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom + boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top + boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left + boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right + boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash + boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash + + for (int line = 0; line < 6; ++line) { + boxlines[line]->SetLineColor(kBlack); + boxlines[line]->SetLineWidth(3); + mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); + } +} + +void DigitsTask::buildChamberIgnoreBP() +{ + mChambersToIgnoreBP.reset(); + // Vector of string to save tokens + std::vector tokens; + // stringstream class check1 + std::stringstream check1(mChambersToIgnore); + std::string intermediate; + // Tokenizing w.r.t. space ',' + while (getline(check1, intermediate, ',')) { + tokens.push_back(intermediate); + } + // Printing the token vector + for (auto& token : tokens) { + // token now holds something like 16_3_0 + std::vector parts; + std::stringstream indexcheck(token); + std::string tokenpart; + // Tokenizing w.r.t. space ',' + while (getline(indexcheck, tokenpart, '_')) { + parts.push_back(tokenpart); + } + // now flip the bit related to the sector:stack:layer stored in parts. + int sector = std::stoi(parts[0]); + int stack = std::stoi(parts[1]); + int layer = std::stoi(parts[2]); + mChambersToIgnoreBP.set(Helper::getDetector(sector, stack, layer)); + } +} + + +void DigitsTask::startOfActivity(const Activity& /*activity*/) +{ + ILOG(Debug, Devel) << "startOfActivity" << ENDM; +} // set stats/stacs + +void DigitsTask::startOfCycle() +{ + ILOG(Debug, Devel) << "startOfCycle" << ENDM; +} + + void DigitsTask::endOfCycle() { ILOG(Debug, Devel) << "endOfCycle" << ENDM; From dca81bb297c781fe2793b698160f384ebd6eee11 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Fri, 15 Dec 2023 15:01:25 +0100 Subject: [PATCH 05/15] TRD: clean up --- Modules/TRD/include/TRD/DigitsTask.h | 7 ++++--- Modules/TRD/include/TRD/TrackletsTask.h | 5 +++-- Modules/TRD/src/DigitsTask.cxx | 10 +++------- Modules/TRD/src/TrackletsTask.cxx | 14 ++++++-------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Modules/TRD/include/TRD/DigitsTask.h b/Modules/TRD/include/TRD/DigitsTask.h index 4d2670c450..b293d1452d 100644 --- a/Modules/TRD/include/TRD/DigitsTask.h +++ b/Modules/TRD/include/TRD/DigitsTask.h @@ -52,12 +52,13 @@ class DigitsTask final : public TaskInterface void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); void drawChamberStatus(); void buildChamberIgnoreBP(); - + // Auxiliary functions // Duplicated from TrackletsTask.h - bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) { + bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) + { // List here the chamber status to not be masked, anything different returns true - int GoodStatus[] = {0, 3}; // Make sure to match the same array in TrackletsTask.h + int GoodStatus[] = { 0, 3 }; // Make sure to match the same array in TrackletsTask.h int hcStatus = (*ptrChamber)[hcId / 2]; return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); } diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 8069f35252..78257b8288 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -50,9 +50,10 @@ class TrackletsTask final : public TaskInterface void drawChamberStatus(); // Auxiliary functions - bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) { + bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) + { // List here the chamber status to not be masked, anything different returns true - int GoodStatus[] = {0, 3}; + int GoodStatus[] = { 0, 3 }; // Make sure to match the same array in DigitsTask.h int hcStatus = (*ptrChamber)[hcId / 2]; return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); } diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index fdbc5bc4eb..8bf6d6e041 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -126,7 +126,7 @@ void DigitsTask::buildHistograms() for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), - 76, -0.5, 75.5, 2592, -0.5, 2591.5)); + 76, -0.5, 75.5, 2592, -0.5, 2591.5)); mLayers[iLayer]->SetStats(0); drawTrdLayersGrid(mLayers[iLayer].get()); getObjectsManager()->startPublishing(mLayers[iLayer].get()); @@ -278,7 +278,6 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) void DigitsTask::drawChamberStatus() { - // Mask known inactive halfchambers in the active chamber map with a X // LB: draw in mLayers elements for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { for (int iSec = 0; iSec < 18; ++iSec) { @@ -355,8 +354,7 @@ void DigitsTask::drawLinesOnPulseHeight(TH1F* h) void DigitsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) { - // instead of using overlays, draw a simple box in red with a cross on it. - + // Draw a simple box in with a X on it std::pair topright, bottomleft; // coordinates of box TLine* boxlines[6]; int det = hcid / 2; @@ -366,7 +364,7 @@ void DigitsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) bottomleft.first = rowstart - 0.5; bottomleft.second = (sec * 2 + side) * 72; topright.first = rowend - 0.5; - topright.second = (sec * 2 + side) * 72 + 72; + topright.second = (sec * 2 + side) * 72 + 72; boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top @@ -412,7 +410,6 @@ void DigitsTask::buildChamberIgnoreBP() } } - void DigitsTask::startOfActivity(const Activity& /*activity*/) { ILOG(Debug, Devel) << "startOfActivity" << ENDM; @@ -423,7 +420,6 @@ void DigitsTask::startOfCycle() ILOG(Debug, Devel) << "startOfCycle" << ENDM; } - void DigitsTask::endOfCycle() { ILOG(Debug, Devel) << "endOfCycle" << ENDM; diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index 969950fb0c..eb6dfb6578 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -119,7 +119,7 @@ void TrackletsTask::buildHistograms() // Build tracklet layers for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer] = new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), - 76, -0.5, 75.5, 144, -0.5, 143.5); + 76, -0.5, 75.5, 144, -0.5, 143.5); mLayers[iLayer]->SetStats(0); drawTrdLayersGrid(mLayers[iLayer]); getObjectsManager()->startPublishing(mLayers[iLayer]); @@ -140,7 +140,7 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) auto ptr = ctx.inputs().get*>("chamberStatus"); mChamberStatus = ptr.get(); } - + if (mChamberStatus != nullptr) { drawChamberStatus(); } else { @@ -184,7 +184,6 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) void TrackletsTask::drawChamberStatus() { - // Mask known inactive halfchambers in the active chamber map with a X // LB: draw in mTrackletsPerHC2D TLine* line[6]; std::pair x, y; @@ -273,8 +272,7 @@ void TrackletsTask::drawTrdLayersGrid(TH2F* hist) void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) { - // instead of using overlays, draw a simple box in red with a cross on it. - + // Draw a simple box in with a X on it std::pair topright, bottomleft; // coordinates of box TLine* boxlines[6]; int det = hcid / 2; @@ -292,10 +290,10 @@ void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowe boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - + for (int line = 0; line < 6; ++line) { - boxlines[line]->SetLineColor(kRed); - boxlines[line]->SetLineWidth(4); + boxlines[line]->SetLineColor(kBlack); + boxlines[line]->SetLineWidth(3); mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); } } From 066bdd86b8fc977a899dc5dcb296b6af444eff9c Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Wed, 20 Dec 2023 12:13:31 -0500 Subject: [PATCH 06/15] TRD: create TRDHelpers class --- Modules/TRD/CMakeLists.txt | 3 +- Modules/TRD/include/TRD/DigitsTask.h | 18 +-- Modules/TRD/include/TRD/LinkDef.h | 1 + Modules/TRD/include/TRD/TRDHelpers.h | 46 +++++++ Modules/TRD/include/TRD/TrackletsTask.h | 20 ++- Modules/TRD/src/DigitsTask.cxx | 111 ++--------------- Modules/TRD/src/TRDHelpers.cxx | 154 ++++++++++++++++++++++++ Modules/TRD/src/TrackletsTask.cxx | 140 ++------------------- 8 files changed, 239 insertions(+), 254 deletions(-) create mode 100644 Modules/TRD/include/TRD/TRDHelpers.h create mode 100644 Modules/TRD/src/TRDHelpers.cxx diff --git a/Modules/TRD/CMakeLists.txt b/Modules/TRD/CMakeLists.txt index c69a17b03f..a4b4634a55 100644 --- a/Modules/TRD/CMakeLists.txt +++ b/Modules/TRD/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(O2QcTRD) -target_sources(O2QcTRD PRIVATE src/TrackletCountCheck.cxx src/TRDReductor.cxx src/PulsePositionCheck.cxx src/TrackingTask.cxx src/PulseHeightTrackMatch.cxx src/TrackletsCheck.cxx src/TrackletsTask.cxx src/PulseHeightCheck.cxx src/PulseHeight.cxx src/RawData.cxx src/DigitsTask.cxx +target_sources(O2QcTRD PRIVATE src/TrackletCountCheck.cxx src/TRDReductor.cxx src/PulsePositionCheck.cxx src/TrackingTask.cxx src/PulseHeightTrackMatch.cxx src/TrackletsCheck.cxx src/TrackletsTask.cxx src/TRDHelpers.cxx src/PulseHeightCheck.cxx src/PulseHeight.cxx src/RawData.cxx src/DigitsTask.cxx src/DigitsCheck.cxx src/TRDTrending.cxx src/TrendingTaskConfigTRD.cxx src/PulseHeightPostProcessing.cxx) target_include_directories( @@ -27,6 +27,7 @@ add_root_dictionary(O2QcTRD include/TRD/PulseHeightTrackMatch.h include/TRD/TrackletsCheck.h include/TRD/TrackletsTask.h + include/TRD/TRDHelpers.h include/TRD/PulseHeightCheck.h include/TRD/PulseHeight.h include/TRD/RawData.h diff --git a/Modules/TRD/include/TRD/DigitsTask.h b/Modules/TRD/include/TRD/DigitsTask.h index b293d1452d..8a18945aec 100644 --- a/Modules/TRD/include/TRD/DigitsTask.h +++ b/Modules/TRD/include/TRD/DigitsTask.h @@ -20,6 +20,7 @@ #include #include "DataFormatsTRD/NoiseCalibration.h" #include "TRDQC/StatusHelper.h" +#include "TRD/TRDHelpers.h" class TH1F; class TH2F; @@ -48,21 +49,8 @@ class DigitsTask final : public TaskInterface void reset() override; void buildHistograms(); void drawLinesOnPulseHeight(TH1F* h); - void drawTrdLayersGrid(TH2F* hist); - void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); - void drawChamberStatus(); void buildChamberIgnoreBP(); - // Auxiliary functions - // Duplicated from TrackletsTask.h - bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) - { - // List here the chamber status to not be masked, anything different returns true - int GoodStatus[] = { 0, 3 }; // Make sure to match the same array in TrackletsTask.h - int hcStatus = (*ptrChamber)[hcId / 2]; - return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); - } - private: // user settings unsigned int mPulseHeightThreshold; @@ -95,6 +83,10 @@ class DigitsTask final : public TaskInterface std::shared_ptr mPulseHeightperchamber = nullptr; std::array, o2::trd::constants::NLAYER> mLayers; + // Plotting variables + TRDHelpers mTRDHelpers; // Auxiliary functions for TRD + int mUnitsPerSection; // Units for each section in layers plots + // CCDB objects const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; const std::array* mChamberStatus = nullptr; diff --git a/Modules/TRD/include/TRD/LinkDef.h b/Modules/TRD/include/TRD/LinkDef.h index 85e47d2f54..1960ec82b2 100644 --- a/Modules/TRD/include/TRD/LinkDef.h +++ b/Modules/TRD/include/TRD/LinkDef.h @@ -10,6 +10,7 @@ #pragma link C++ class o2::quality_control_modules::trd::PulseHeight + ; #pragma link C++ class o2::quality_control_modules::trd::PulseHeightCheck + ; #pragma link C++ class o2::quality_control_modules::trd::TrackletsTask + ; +#pragma link C++ class o2::quality_control_modules::trd::TRDHelpers + ; #pragma link C++ class o2::quality_control_modules::trd::TrackletsCheck + ; #pragma link C++ class o2::quality_control::postprocessing::TRDTrending + ; #pragma link C++ class o2::quality_control::postprocessing::PulseHeightPostProcessing + ; diff --git a/Modules/TRD/include/TRD/TRDHelpers.h b/Modules/TRD/include/TRD/TRDHelpers.h new file mode 100644 index 0000000000..5bc30f5834 --- /dev/null +++ b/Modules/TRD/include/TRD/TRDHelpers.h @@ -0,0 +1,46 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// +/// \file TRDHelpers.h +/// + +#ifndef QC_MODULE_TRD_TRDHELPER_H +#define QC_MODULE_TRD_TRDHELPER_H + +#include "QualityControl/TaskInterface.h" +#include "TRDQC/StatusHelper.h" + +class TH2F; + +using namespace o2::quality_control::core; + +namespace o2::quality_control_modules::trd +{ + +class TRDHelpers +{ + public: + TRDHelpers() = default; + ~TRDHelpers() = default; + + void drawTrdLayersGrid(TH2F* hist, int unitspersection); + void drawChamberStatusOn2D(TH2F* hist, const std::array* ptrChamber); + void drawChamberStatusOnLayers(std::array, o2::trd::constants::NLAYER> mLayers, const std::array* ptrChamber, int unitspersection); + + private: + void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend, int unitspersection, std::array, o2::trd::constants::NLAYER> mLayers); + bool isHalfChamberMasked(int hcId, const std::array* ptrChamber); +}; + +} // namespace o2::quality_control_modules::trd + +#endif diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 78257b8288..7a593a3a9b 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -20,6 +20,7 @@ #include "QualityControl/DatabaseInterface.h" #include "DataFormatsTRD/NoiseCalibration.h" #include "TRDQC/StatusHelper.h" +#include "TRD/TRDHelpers.h" class TH1F; class TH2F; @@ -45,18 +46,6 @@ class TrackletsTask final : public TaskInterface void endOfActivity(const Activity& activity) override; void reset() override; void buildHistograms(); - void drawTrdLayersGrid(TH2F* hist); - void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend); - void drawChamberStatus(); - - // Auxiliary functions - bool isHalfChamberMasked(int hcId, const std::array* ptrChamber) - { - // List here the chamber status to not be masked, anything different returns true - int GoodStatus[] = { 0, 3 }; // Make sure to match the same array in DigitsTask.h - int hcStatus = (*ptrChamber)[hcId / 2]; - return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); - } private: // settings @@ -72,7 +61,12 @@ class TrackletsTask final : public TaskInterface TH2F* mTrackletsPerHC2D = nullptr; TH1F* mTrackletsPerTimeFrame = nullptr; TH1F* mTriggersPerTimeFrame = nullptr; - std::array mLayers; + // std::array, o2::trd::constants::NLAYER> mLayersTracklets; + std::array, o2::trd::constants::NLAYER> mLayers; + + // Plotting variables + TRDHelpers mTRDHelpers; // Auxiliary functions for TRD + int mUnitsPerSection; // Units for each section in layers plots // data to pull from CCDB const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index 8bf6d6e041..1e65f5c2a9 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -124,11 +124,13 @@ void DigitsTask::buildHistograms() getObjectsManager()->startPublishing(mPulseHeight2DperSM[iSec].get()); } + // Build digits layers + mUnitsPerSection = 144; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), - 76, -0.5, 75.5, 2592, -0.5, 2591.5)); + 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - drawTrdLayersGrid(mLayers[iLayer].get()); + mTRDHelpers.drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); @@ -142,15 +144,16 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) auto ptr = ctx.inputs().get("noiseMap"); mNoiseMap = ptr.get(); } + if (!mChamberStatus) { auto ptr = ctx.inputs().get*>("chamberStatus"); mChamberStatus = ptr.get(); - } - - if (mChamberStatus != nullptr) { - drawChamberStatus(); - } else { - ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; + // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr + if (mChamberStatus) { + mTRDHelpers.drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); + } else { + ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; + } } // fill histograms @@ -276,70 +279,6 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) } // loop over triggers } -void DigitsTask::drawChamberStatus() -{ - // LB: draw in mLayers elements - for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { - for (int iSec = 0; iSec < 18; ++iSec) { - for (int iStack = 0; iStack < 5; ++iStack) { - int rowMax = (iStack == 2) ? 12 : 16; - for (int side = 0; side < 2; ++side) { - int det = iSec * 30 + iStack * 6 + iLayer; - int hcid = (side == 0) ? det * 2 : det * 2 + 1; - int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector - int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector - if (isHalfChamberMasked(hcid, mChamberStatus)) { - drawHashOnLayers(iLayer, hcid, rowstart, rowend); - } - } - } - } - } -} - -void DigitsTask::drawTrdLayersGrid(TH2F* hist) -{ - TLine* line; - for (int i = 0; i < 5; ++i) { - switch (i) { - case 0: - line = new TLine(15.5, 0, 15.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 1: - line = new TLine(31.5, 0, 31.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 2: - line = new TLine(43.5, 0, 43.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 3: - line = new TLine(59.5, 0, 59.5, 2592); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - } - } - for (int iSec = 1; iSec < 18; ++iSec) { - float yPos = iSec * 144 - 0.5; - line = new TLine(0, yPos, 76, yPos); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - hist->GetListOfFunctions()->Add(line); - } - - ILOG(Info, Support) << "Layer Grid redrawn in check for : " << hist->GetName() << ENDM; - ILOG(Info, Support) << "Layer Grid redrawn in hist has function count of : " << hist->GetListOfFunctions()->GetSize() << ENDM; -} - void DigitsTask::drawLinesOnPulseHeight(TH1F* h) { TLine* lmin = new TLine(mPulseHeightPeakRegion.first, 0, mPulseHeightPeakRegion.first, 1e9); @@ -352,34 +291,6 @@ void DigitsTask::drawLinesOnPulseHeight(TH1F* h) h->GetListOfFunctions()->Add(lmax); } -void DigitsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) -{ - // Draw a simple box in with a X on it - std::pair topright, bottomleft; // coordinates of box - TLine* boxlines[6]; - int det = hcid / 2; - int side = hcid % 2; - int sec = hcid / 60; - - bottomleft.first = rowstart - 0.5; - bottomleft.second = (sec * 2 + side) * 72; - topright.first = rowend - 0.5; - topright.second = (sec * 2 + side) * 72 + 72; - - boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom - boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top - boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left - boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right - boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash - boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - - for (int line = 0; line < 6; ++line) { - boxlines[line]->SetLineColor(kBlack); - boxlines[line]->SetLineWidth(3); - mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); - } -} - void DigitsTask::buildChamberIgnoreBP() { mChambersToIgnoreBP.reset(); diff --git a/Modules/TRD/src/TRDHelpers.cxx b/Modules/TRD/src/TRDHelpers.cxx new file mode 100644 index 0000000000..006fa03565 --- /dev/null +++ b/Modules/TRD/src/TRDHelpers.cxx @@ -0,0 +1,154 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// +/// \file TRDHelpers.cxx +/// + +#include +#include +#include + +#include "TRD/TRDHelpers.h" +#include "DataFormatsTRD/HelperMethods.h" + +using namespace o2::trd::constants; +using Helper = o2::trd::HelperMethods; + +namespace o2::quality_control_modules::trd +{ +bool TRDHelpers::isHalfChamberMasked(int hcId, const std::array* ptrChamber) +{ + // List here the chamber status to not be masked, anything different returns true + int GoodStatus[] = { 0, 2, 3, 4, 5 }; + int hcStatus = (*ptrChamber)[hcId / 2]; + return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); +} + +void TRDHelpers::drawChamberStatusOn2D(TH2F* hist, const std::array* ptrChamber) +{ + TLine* line[6]; + std::pair x, y; + for (int iHC = 0; iHC < MAXCHAMBER * 2; ++iHC) { + if (isHalfChamberMasked(iHC, ptrChamber)) { + int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); + int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); + x.first = sectorSide; + x.second = sectorSide + 1; + y.first = stackLayer; + y.second = stackLayer + 1; + + line[0] = new TLine(x.first, y.first, x.second, y.second); + line[1] = new TLine(x.second, y.first, x.first, y.second); + line[2] = new TLine(x.first, y.first, x.second, y.first); + line[3] = new TLine(x.first, y.second, x.second, y.second); + line[4] = new TLine(x.first, y.first, x.first, y.second); + line[5] = new TLine(x.second, y.first, x.second, y.second); + + for (int i = 0; i < 6; ++i) { + line[i]->SetLineColor(kBlack); + line[i]->SetLineWidth(3); + hist->GetListOfFunctions()->Add(line[i]); + } + } + } +} + +void TRDHelpers::drawChamberStatusOnLayers(std::array, NLAYER> mLayers, const std::array* ptrChamber, int unitspersection) +{ + for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { + for (int iSec = 0; iSec < 18; ++iSec) { + for (int iStack = 0; iStack < 5; ++iStack) { + int rowMax = (iStack == 2) ? 12 : 16; + for (int side = 0; side < 2; ++side) { + int det = iSec * 30 + iStack * 6 + iLayer; + int hcid = (side == 0) ? det * 2 : det * 2 + 1; + int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector + int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector + if (isHalfChamberMasked(hcid, ptrChamber)) { + drawHashOnLayers(iLayer, hcid, rowstart, rowend, unitspersection, mLayers); + } + } + } + } + } +} + +void TRDHelpers::drawTrdLayersGrid(TH2F* hist, int unitspersection) +{ + TLine* line; + for (int i = 0; i < 5; ++i) { + switch (i) { + case 0: + line = new TLine(15.5, 0, 15.5, 18 * unitspersection - 0.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 1: + line = new TLine(31.5, 0, 31.5, 18 * unitspersection - 0.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 2: + line = new TLine(43.5, 0, 43.5, 18 * unitspersection - 0.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + case 3: + line = new TLine(59.5, 0, 59.5, 18 * unitspersection - 0.5); + hist->GetListOfFunctions()->Add(line); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + break; + } + } + + for (int iSec = 1; iSec < 18; ++iSec) { + float yPos = iSec * unitspersection - 0.5; + line = new TLine(-0.5, yPos, 75.5, yPos); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + hist->GetListOfFunctions()->Add(line); + } +} + +void TRDHelpers::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend, int unitspersection, std::array, NLAYER> mLayers) +{ + // Draw a simple box in with a X on it + std::pair topright, bottomleft; // coordinates of box + TLine* boxlines[6]; + int det = hcid / 2; + int side = hcid % 2; + int sec = hcid / 60; + + bottomleft.first = rowstart - 0.5; + bottomleft.second = (sec * 2 + side) * (unitspersection / 2) - 0.5; + topright.first = rowend - 0.5; + topright.second = (sec * 2 + side + 1) * (unitspersection / 2) - 0.5; + + boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom + boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top + boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left + boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right + boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash + boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash + + for (int line = 0; line < 6; ++line) { + boxlines[line]->SetLineColor(kBlack); + boxlines[line]->SetLineWidth(3); + mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); + } +} + +} // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index eb6dfb6578..8c743142cc 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -117,14 +117,15 @@ void TrackletsTask::buildHistograms() getObjectsManager()->startPublishing(mTriggersPerTimeFrame); // Build tracklet layers + mUnitsPerSection = 8; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { - mLayers[iLayer] = new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), - 76, -0.5, 75.5, 144, -0.5, 143.5); + mLayers[iLayer].reset(new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), + 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - drawTrdLayersGrid(mLayers[iLayer]); - getObjectsManager()->startPublishing(mLayers[iLayer]); + mTRDHelpers.drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); + getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); - getObjectsManager()->setDisplayHint(mLayers[iLayer], "logz"); + getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); } } @@ -139,12 +140,13 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) if (!mChamberStatus) { auto ptr = ctx.inputs().get*>("chamberStatus"); mChamberStatus = ptr.get(); - } - - if (mChamberStatus != nullptr) { - drawChamberStatus(); - } else { - ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; + // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr + if (mChamberStatus) { + mTRDHelpers.drawChamberStatusOn2D(mTrackletsPerHC2D, mChamberStatus); + mTRDHelpers.drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); + } else { + ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; + } } // Fill histograms @@ -182,122 +184,6 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) } } -void TrackletsTask::drawChamberStatus() -{ - // LB: draw in mTrackletsPerHC2D - TLine* line[6]; - std::pair x, y; - for (int iHC = 0; iHC < MAXCHAMBER * 2; ++iHC) { - if (isHalfChamberMasked(iHC, mChamberStatus)) { - int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); - int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); - x.first = sectorSide; - x.second = sectorSide + 1; - y.first = stackLayer; - y.second = stackLayer + 1; - - line[0] = new TLine(x.first, y.first, x.second, y.second); - line[1] = new TLine(x.second, y.first, x.first, y.second); - line[2] = new TLine(x.first, y.first, x.second, y.first); - line[3] = new TLine(x.first, y.second, x.second, y.second); - line[4] = new TLine(x.first, y.first, x.first, y.second); - line[5] = new TLine(x.second, y.first, x.second, y.second); - for (int i = 0; i < 6; ++i) { - line[i]->SetLineColor(kBlack); - line[i]->SetLineWidth(3); - mTrackletsPerHC2D->GetListOfFunctions()->Add(line[i]); - } - } - } - - // LB: draw in mLayers elements - for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { - for (int iSec = 0; iSec < 18; ++iSec) { - for (int iStack = 0; iStack < 5; ++iStack) { - int rowMax = (iStack == 2) ? 12 : 16; - for (int side = 0; side < 2; ++side) { - int det = iSec * 30 + iStack * 6 + iLayer; - int hcid = (side == 0) ? det * 2 : det * 2 + 1; - int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector - int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector - if (isHalfChamberMasked(hcid, mChamberStatus)) { - drawHashOnLayers(iLayer, hcid, rowstart, rowend); - } - } - } - } - } -} - -void TrackletsTask::drawTrdLayersGrid(TH2F* hist) -{ - TLine* line; - for (int i = 0; i < 5; ++i) { - switch (i) { - case 0: - line = new TLine(15.5, 0, 15.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 1: - line = new TLine(31.5, 0, 31.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 2: - line = new TLine(43.5, 0, 43.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 3: - line = new TLine(59.5, 0, 59.5, 143.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - } - } - - for (int iSec = 1; iSec < 18; ++iSec) { - float yPos = iSec * 8 - 0.5; - line = new TLine(-0.5, yPos, 75.5, yPos); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - hist->GetListOfFunctions()->Add(line); - } -} - -void TrackletsTask::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend) -{ - // Draw a simple box in with a X on it - std::pair topright, bottomleft; // coordinates of box - TLine* boxlines[6]; - int det = hcid / 2; - int side = hcid % 2; - int sec = hcid / 60; - - bottomleft.first = rowstart - 0.5; - bottomleft.second = (sec * 2 + side) * 4 - 0.5; - topright.first = rowend - 0.5; - topright.second = (sec * 2 + side) * 4 + 4 - 0.5; - - boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom - boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top - boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left - boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right - boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash - boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - - for (int line = 0; line < 6; ++line) { - boxlines[line]->SetLineColor(kBlack); - boxlines[line]->SetLineWidth(3); - mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); - } -} - void TrackletsTask::startOfActivity(const Activity& activity) { ILOG(Debug, Devel) << "startOfActivity " << activity.mId << ENDM; From d80757f7c710a2c4b2ae2cc7575cd336e3ea2d36 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Wed, 20 Dec 2023 22:55:58 -0500 Subject: [PATCH 07/15] TRD: color options for drawing chamber status --- Modules/TRD/include/TRD/TRDHelpers.h | 12 ++- Modules/TRD/src/TRDHelpers.cxx | 114 ++++++++++++++------------- 2 files changed, 70 insertions(+), 56 deletions(-) diff --git a/Modules/TRD/include/TRD/TRDHelpers.h b/Modules/TRD/include/TRD/TRDHelpers.h index 5bc30f5834..4223857b17 100644 --- a/Modules/TRD/include/TRD/TRDHelpers.h +++ b/Modules/TRD/include/TRD/TRDHelpers.h @@ -33,12 +33,18 @@ class TRDHelpers ~TRDHelpers() = default; void drawTrdLayersGrid(TH2F* hist, int unitspersection); - void drawChamberStatusOn2D(TH2F* hist, const std::array* ptrChamber); + void drawChamberStatusOn2D(std::shared_ptr hist, const std::array* ptrChamber); void drawChamberStatusOnLayers(std::array, o2::trd::constants::NLAYER> mLayers, const std::array* ptrChamber, int unitspersection); private: - void drawHashOnLayers(int layer, int hcid, int rowstart, int rowend, int unitspersection, std::array, o2::trd::constants::NLAYER> mLayers); - bool isHalfChamberMasked(int hcId, const std::array* ptrChamber); + void drawHashOnLayers(int layer, int hcid, int hcstat, int rowstart, int rowend, int unitspersection, std::array, o2::trd::constants::NLAYER> mLayers); + bool isHalfChamberMasked(int hcid, const std::array* ptrChamber); + void setBoxChamberStatus(int hcstat, TLine* box[], std::shared_ptr hist); + + // Chamber status values definitions, used for masking + int mConfiguredChamberStatus = 3; + int mEmptyChamberStatus = 0; + int mErrorChamberStatus = 99; }; } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/src/TRDHelpers.cxx b/Modules/TRD/src/TRDHelpers.cxx index 006fa03565..cec0f2fbdc 100644 --- a/Modules/TRD/src/TRDHelpers.cxx +++ b/Modules/TRD/src/TRDHelpers.cxx @@ -16,7 +16,6 @@ #include #include #include - #include "TRD/TRDHelpers.h" #include "DataFormatsTRD/HelperMethods.h" @@ -25,39 +24,35 @@ using Helper = o2::trd::HelperMethods; namespace o2::quality_control_modules::trd { -bool TRDHelpers::isHalfChamberMasked(int hcId, const std::array* ptrChamber) +bool TRDHelpers::isHalfChamberMasked(int hcid, const std::array* ptrChamber) { - // List here the chamber status to not be masked, anything different returns true - int GoodStatus[] = { 0, 2, 3, 4, 5 }; - int hcStatus = (*ptrChamber)[hcId / 2]; - return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcStatus) == std::end(GoodStatus)); + // LB: defined as array in case other chamber status values are set as not masked + int GoodStatus[] = { mConfiguredChamberStatus }; + int hcstat = (*ptrChamber)[hcid / 2]; + return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcstat) == std::end(GoodStatus)); } -void TRDHelpers::drawChamberStatusOn2D(TH2F* hist, const std::array* ptrChamber) +void TRDHelpers::drawChamberStatusOn2D(std::shared_ptr hist, const std::array* ptrChamber) { - TLine* line[6]; + TLine* boxlines[6]; std::pair x, y; - for (int iHC = 0; iHC < MAXCHAMBER * 2; ++iHC) { - if (isHalfChamberMasked(iHC, ptrChamber)) { - int stackLayer = Helper::getStack(iHC / 2) * NLAYER + Helper::getLayer(iHC / 2); - int sectorSide = (iHC / NHCPERSEC) * 2 + (iHC % 2); + for (int hcid = 0; hcid < MAXCHAMBER * 2; ++hcid) { + if (isHalfChamberMasked(hcid, ptrChamber)) { + int stackLayer = Helper::getStack(hcid / 2) * NLAYER + Helper::getLayer(hcid / 2); + int sectorSide = (hcid / NHCPERSEC) * 2 + (hcid % 2); x.first = sectorSide; x.second = sectorSide + 1; y.first = stackLayer; y.second = stackLayer + 1; - line[0] = new TLine(x.first, y.first, x.second, y.second); - line[1] = new TLine(x.second, y.first, x.first, y.second); - line[2] = new TLine(x.first, y.first, x.second, y.first); - line[3] = new TLine(x.first, y.second, x.second, y.second); - line[4] = new TLine(x.first, y.first, x.first, y.second); - line[5] = new TLine(x.second, y.first, x.second, y.second); + boxlines[0] = new TLine(x.first, y.first, x.second, y.second); + boxlines[1] = new TLine(x.second, y.first, x.first, y.second); + boxlines[2] = new TLine(x.first, y.first, x.second, y.first); + boxlines[3] = new TLine(x.first, y.second, x.second, y.second); + boxlines[4] = new TLine(x.first, y.first, x.first, y.second); + boxlines[5] = new TLine(x.second, y.first, x.second, y.second); - for (int i = 0; i < 6; ++i) { - line[i]->SetLineColor(kBlack); - line[i]->SetLineWidth(3); - hist->GetListOfFunctions()->Add(line[i]); - } + setBoxChamberStatus((*ptrChamber)[hcid / 2], boxlines, hist); } } } @@ -74,7 +69,10 @@ void TRDHelpers::drawChamberStatusOnLayers(std::array, NLA int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector if (isHalfChamberMasked(hcid, ptrChamber)) { - drawHashOnLayers(iLayer, hcid, rowstart, rowend, unitspersection, mLayers); + int hcstat = (*ptrChamber)[hcid / 2]; + std::cout << "Leonardo hcid / 2 " << hcid / 2 << std::endl; + std::cout << "Leonardo hcstat " << hcstat << std::endl; + drawHashOnLayers(iLayer, hcid, hcstat, rowstart, rowend, unitspersection, mLayers); } } } @@ -82,6 +80,45 @@ void TRDHelpers::drawChamberStatusOnLayers(std::array, NLA } } +void TRDHelpers::drawHashOnLayers(int layer, int hcid, int hcstat, int rowstart, int rowend, int unitspersection, std::array, NLAYER> mLayers) +{ + // Draw a simple box in with a X on it + std::pair topright, bottomleft; // coordinates of box + TLine* boxlines[6]; + int det = hcid / 2; + int side = hcid % 2; + int sec = hcid / 60; + + bottomleft.first = rowstart - 0.5; + bottomleft.second = (sec * 2 + side) * (unitspersection / 2) - 0.5; + topright.first = rowend - 0.5; + topright.second = (sec * 2 + side + 1) * (unitspersection / 2) - 0.5; + + boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom + boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top + boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left + boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right + boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash + boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash + + setBoxChamberStatus(hcstat, boxlines, mLayers[layer]); +} + +void TRDHelpers::setBoxChamberStatus(int hcstat, TLine* box[], std::shared_ptr hist) +{ + for (int line = 0; line < 6; ++line) { + if (hcstat == mEmptyChamberStatus) { + box[line]->SetLineColor(kGray + 1); + } else if (hcstat == mErrorChamberStatus) { + box[line]->SetLineColor(kRed); + } else { + box[line]->SetLineColor(kBlack); + } + box[line]->SetLineWidth(2); + hist->GetListOfFunctions()->Add(box[line]); + } +} + void TRDHelpers::drawTrdLayersGrid(TH2F* hist, int unitspersection) { TLine* line; @@ -122,33 +159,4 @@ void TRDHelpers::drawTrdLayersGrid(TH2F* hist, int unitspersection) hist->GetListOfFunctions()->Add(line); } } - -void TRDHelpers::drawHashOnLayers(int layer, int hcid, int rowstart, int rowend, int unitspersection, std::array, NLAYER> mLayers) -{ - // Draw a simple box in with a X on it - std::pair topright, bottomleft; // coordinates of box - TLine* boxlines[6]; - int det = hcid / 2; - int side = hcid % 2; - int sec = hcid / 60; - - bottomleft.first = rowstart - 0.5; - bottomleft.second = (sec * 2 + side) * (unitspersection / 2) - 0.5; - topright.first = rowend - 0.5; - topright.second = (sec * 2 + side + 1) * (unitspersection / 2) - 0.5; - - boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom - boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top - boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left - boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right - boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash - boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - - for (int line = 0; line < 6; ++line) { - boxlines[line]->SetLineColor(kBlack); - boxlines[line]->SetLineWidth(3); - mLayers[layer]->GetListOfFunctions()->Add(boxlines[line]); - } -} - } // namespace o2::quality_control_modules::trd From 4bcae9c56cca5ab2abcce91a04e61fe9c06fe5ce Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Wed, 20 Dec 2023 23:16:47 -0500 Subject: [PATCH 08/15] TRD: change tracklets task histogram to shared pointers --- Modules/TRD/include/TRD/TrackletsTask.h | 21 ++++++------- Modules/TRD/src/TrackletsTask.cxx | 42 ++++++++++++------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 7a593a3a9b..4f8da532fb 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -51,17 +51,16 @@ class TrackletsTask final : public TaskInterface // settings bool mRemoveNoise{ false }; // histograms - std::array mTrackletQ; - TH1F* mTrackletSlope = nullptr; - TH1F* mTrackletHCID = nullptr; - TH1F* mTrackletPosition = nullptr; - TH1F* mTrackletsPerEvent = nullptr; - TH1F* mTrackletsPerEventPP = nullptr; - TH1F* mTrackletsPerEventPbPb = nullptr; - TH2F* mTrackletsPerHC2D = nullptr; - TH1F* mTrackletsPerTimeFrame = nullptr; - TH1F* mTriggersPerTimeFrame = nullptr; - // std::array, o2::trd::constants::NLAYER> mLayersTracklets; + std::array, 3> mTrackletQ; + std::shared_ptr mTrackletSlope = nullptr; + std::shared_ptr mTrackletHCID = nullptr; + std::shared_ptr mTrackletPosition = nullptr; + std::shared_ptr mTrackletsPerEvent = nullptr; + std::shared_ptr mTrackletsPerEventPP = nullptr; + std::shared_ptr mTrackletsPerEventPbPb = nullptr; + std::shared_ptr mTrackletsPerHC2D = nullptr; + std::shared_ptr mTrackletsPerTimeFrame = nullptr; + std::shared_ptr mTriggersPerTimeFrame = nullptr; std::array, o2::trd::constants::NLAYER> mLayers; // Plotting variables diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index 8c743142cc..8ca3b7375c 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -58,26 +58,26 @@ void TrackletsTask::buildHistograms() for (int iBin = 0; iBin <= nLogBins; ++iBin) { xBins[iBin] = TMath::Power(10, xBinLogMin + iBin * logBinWidth); } - mTrackletSlope = new TH1F("trackletslope", "Tracklet inclination in natural units;pads per time bin;counts", 100, -0.15, 0.15); - getObjectsManager()->startPublishing(mTrackletSlope); + mTrackletSlope.reset(new TH1F("trackletslope", "Tracklet inclination in natural units;pads per time bin;counts", 100, -0.15, 0.15)); + getObjectsManager()->startPublishing(mTrackletSlope.get()); - mTrackletHCID = new TH1F("tracklethcid", "Tracklet distribution over Halfchambers;HalfChamber ID;counts", 1080, -0.5, 1079.5); - getObjectsManager()->startPublishing(mTrackletHCID); + mTrackletHCID.reset(new TH1F("tracklethcid", "Tracklet distribution over Halfchambers;HalfChamber ID;counts", 1080, -0.5, 1079.5)); + getObjectsManager()->startPublishing(mTrackletHCID.get()); - mTrackletPosition = new TH1F("trackletpos", "Tracklet position relative to MCM center;number of pads;counts", 200, -30, 30); - getObjectsManager()->startPublishing(mTrackletPosition); + mTrackletPosition.reset(new TH1F("trackletpos", "Tracklet position relative to MCM center;number of pads;counts", 200, -30, 30)); + getObjectsManager()->startPublishing(mTrackletPosition.get()); - mTrackletsPerEvent = new TH1F("trackletsperevent", "Number of Tracklets per event;Tracklets in Event;Counts", nLogBins, xBins); - getObjectsManager()->startPublishing(mTrackletsPerEvent); + mTrackletsPerEvent.reset(new TH1F("trackletsperevent", "Number of Tracklets per event;Tracklets in Event;Counts", nLogBins, xBins)); + getObjectsManager()->startPublishing(mTrackletsPerEvent.get()); getObjectsManager()->setDefaultDrawOptions(mTrackletsPerEvent->GetName(), "logx"); - mTrackletsPerEventPP = new TH1F("trackletspereventPP", "Number of Tracklets per event;Tracklets in Event;Counts", 1000, 0, 5000); - getObjectsManager()->startPublishing(mTrackletsPerEventPP); + mTrackletsPerEventPP.reset(new TH1F("trackletspereventPP", "Number of Tracklets per event;Tracklets in Event;Counts", 1000, 0, 5000)); + getObjectsManager()->startPublishing(mTrackletsPerEventPP.get()); - mTrackletsPerEventPbPb = new TH1F("trackletspereventPbPb", "Number of Tracklets per event;Tracklets in Event;Counts", 1000, 0, 100000); - getObjectsManager()->startPublishing(mTrackletsPerEventPbPb); + mTrackletsPerEventPbPb.reset(new TH1F("trackletspereventPbPb", "Number of Tracklets per event;Tracklets in Event;Counts", 1000, 0, 100000)); + getObjectsManager()->startPublishing(mTrackletsPerEventPbPb.get()); - mTrackletsPerHC2D = new TH2F("trackletsperHC2D", "Tracklets distribution in half-chambers;Sector_Side;Stack_Side", 36, 0, 36, 30, 0, 30); + mTrackletsPerHC2D.reset(new TH2F("trackletsperHC2D", "Tracklets distribution in half-chambers;Sector_Side;Stack_Side", 36, 0, 36, 30, 0, 30)); mTrackletsPerHC2D->SetStats(0); mTrackletsPerHC2D->GetXaxis()->SetTitle("Sector_Side"); mTrackletsPerHC2D->GetXaxis()->CenterTitle(kTRUE); @@ -99,22 +99,22 @@ void TrackletsTask::buildHistograms() } } - getObjectsManager()->startPublishing(mTrackletsPerHC2D); - getObjectsManager()->setDefaultDrawOptions("trackletsperHC2D", "COLZ"); + getObjectsManager()->startPublishing(mTrackletsPerHC2D.get()); + getObjectsManager()->setDefaultDrawOptions(mTrackletsPerHC2D->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mTrackletsPerHC2D->GetName(), "logz"); for (int chargeWindow = 0; chargeWindow < 3; ++chargeWindow) { - mTrackletQ[chargeWindow] = new TH1F(Form("TrackletQ%i", chargeWindow), Form("Tracklet Q%i;charge (a.u.);counts", chargeWindow), 256, -0.5, 255.5); - getObjectsManager()->startPublishing(mTrackletQ[chargeWindow]); + mTrackletQ[chargeWindow].reset(new TH1F(Form("TrackletQ%i", chargeWindow), Form("Tracklet Q%i;charge (a.u.);counts", chargeWindow), 256, -0.5, 255.5)); + getObjectsManager()->startPublishing(mTrackletQ[chargeWindow].get()); getObjectsManager()->setDefaultDrawOptions(mTrackletQ[chargeWindow]->GetName(), "logy"); } - mTrackletsPerTimeFrame = new TH1F("trackletspertimeframe", "Number of Tracklets per timeframe;Tracklets in TimeFrame;Counts", nLogBins, xBins); - getObjectsManager()->startPublishing(mTrackletsPerTimeFrame); + mTrackletsPerTimeFrame.reset(new TH1F("trackletspertimeframe", "Number of Tracklets per timeframe;Tracklets in TimeFrame;Counts", nLogBins, xBins)); + getObjectsManager()->startPublishing(mTrackletsPerTimeFrame.get()); getObjectsManager()->setDefaultDrawOptions(mTrackletsPerTimeFrame->GetName(), "logx"); - mTriggersPerTimeFrame = new TH1F("triggerspertimeframe", "Number of Triggers per timeframe;Triggers in TimeFrame;Counts", 1000, 0, 1000); - getObjectsManager()->startPublishing(mTriggersPerTimeFrame); + mTriggersPerTimeFrame.reset(new TH1F("triggerspertimeframe", "Number of Triggers per timeframe;Triggers in TimeFrame;Counts", 1000, 0, 1000)); + getObjectsManager()->startPublishing(mTriggersPerTimeFrame.get()); // Build tracklet layers mUnitsPerSection = 8; From f07ed5a2fda9d26d364177aae25f55a726351b23 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Thu, 21 Dec 2023 11:05:46 -0500 Subject: [PATCH 09/15] TRD: set TRDHelpers class as pure static --- Modules/TRD/include/TRD/DigitsTask.h | 3 +-- Modules/TRD/include/TRD/TRDHelpers.h | 22 +++++++++++----------- Modules/TRD/include/TRD/TrackletsTask.h | 3 +-- Modules/TRD/src/DigitsTask.cxx | 7 ++++--- Modules/TRD/src/TrackletsTask.cxx | 7 ++++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Modules/TRD/include/TRD/DigitsTask.h b/Modules/TRD/include/TRD/DigitsTask.h index 8a18945aec..470e0fc011 100644 --- a/Modules/TRD/include/TRD/DigitsTask.h +++ b/Modules/TRD/include/TRD/DigitsTask.h @@ -20,7 +20,6 @@ #include #include "DataFormatsTRD/NoiseCalibration.h" #include "TRDQC/StatusHelper.h" -#include "TRD/TRDHelpers.h" class TH1F; class TH2F; @@ -84,7 +83,7 @@ class DigitsTask final : public TaskInterface std::array, o2::trd::constants::NLAYER> mLayers; // Plotting variables - TRDHelpers mTRDHelpers; // Auxiliary functions for TRD + //TRDHelpers mTRDHelpers; // Auxiliary functions for TRD int mUnitsPerSection; // Units for each section in layers plots // CCDB objects diff --git a/Modules/TRD/include/TRD/TRDHelpers.h b/Modules/TRD/include/TRD/TRDHelpers.h index 4223857b17..17795d961a 100644 --- a/Modules/TRD/include/TRD/TRDHelpers.h +++ b/Modules/TRD/include/TRD/TRDHelpers.h @@ -32,19 +32,19 @@ class TRDHelpers TRDHelpers() = default; ~TRDHelpers() = default; - void drawTrdLayersGrid(TH2F* hist, int unitspersection); - void drawChamberStatusOn2D(std::shared_ptr hist, const std::array* ptrChamber); - void drawChamberStatusOnLayers(std::array, o2::trd::constants::NLAYER> mLayers, const std::array* ptrChamber, int unitspersection); - + static void drawTrdLayersGrid(TH2F* hist, int unitspersection); + static void drawChamberStatusOn2D(std::shared_ptr hist, const std::array* ptrChamber); + static void drawChamberStatusOnLayers(std::array, o2::trd::constants::NLAYER> mLayers, const std::array* ptrChamber, int unitspersection); + + static void drawHashOnLayers(int layer, int hcid, int hcstat, int rowstart, int rowend, int unitspersection, std::array, o2::trd::constants::NLAYER> mLayers); + static bool isHalfChamberMasked(int hcid, const std::array* ptrChamber); + static void setBoxChamberStatus(int hcstat, TLine* box[], std::shared_ptr hist); + private: - void drawHashOnLayers(int layer, int hcid, int hcstat, int rowstart, int rowend, int unitspersection, std::array, o2::trd::constants::NLAYER> mLayers); - bool isHalfChamberMasked(int hcid, const std::array* ptrChamber); - void setBoxChamberStatus(int hcstat, TLine* box[], std::shared_ptr hist); - // Chamber status values definitions, used for masking - int mConfiguredChamberStatus = 3; - int mEmptyChamberStatus = 0; - int mErrorChamberStatus = 99; + static const int mConfiguredChamberStatus = 3; + static const int mEmptyChamberStatus = 0; + static const int mErrorChamberStatus = 99; }; } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index 4f8da532fb..e786ddabc3 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -20,7 +20,6 @@ #include "QualityControl/DatabaseInterface.h" #include "DataFormatsTRD/NoiseCalibration.h" #include "TRDQC/StatusHelper.h" -#include "TRD/TRDHelpers.h" class TH1F; class TH2F; @@ -64,7 +63,7 @@ class TrackletsTask final : public TaskInterface std::array, o2::trd::constants::NLAYER> mLayers; // Plotting variables - TRDHelpers mTRDHelpers; // Auxiliary functions for TRD + //TRDHelpers mTRDHelpers; // Auxiliary functions for TRD int mUnitsPerSection; // Units for each section in layers plots // data to pull from CCDB diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index 1e65f5c2a9..ed99601679 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -19,6 +19,8 @@ #include #include +#include "TRD/DigitsTask.h" +#include "TRD/TRDHelpers.h" #include "DataFormatsTRD/Constants.h" #include "DataFormatsTRD/Digit.h" #include "DataFormatsTRD/HelperMethods.h" @@ -27,7 +29,6 @@ #include "QualityControl/TaskInterface.h" #include "QualityControl/QcInfoLogger.h" #include "Common/Utils.h" -#include "TRD/DigitsTask.h" #include #include #include @@ -130,7 +131,7 @@ void DigitsTask::buildHistograms() mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - mTRDHelpers.drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); + TRDHelpers::drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); @@ -150,7 +151,7 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { - mTRDHelpers.drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); + TRDHelpers::drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index 8ca3b7375c..a1ab247cf2 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -25,6 +25,7 @@ #include "QualityControl/QcInfoLogger.h" #include "Common/Utils.h" #include "TRD/TrackletsTask.h" +#include "TRD/TRDHelpers.h" #include "TRDQC/StatusHelper.h" #include #include @@ -122,7 +123,7 @@ void TrackletsTask::buildHistograms() mLayers[iLayer].reset(new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - mTRDHelpers.drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); + TRDHelpers::drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); @@ -142,8 +143,8 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { - mTRDHelpers.drawChamberStatusOn2D(mTrackletsPerHC2D, mChamberStatus); - mTRDHelpers.drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); + TRDHelpers::drawChamberStatusOn2D(mTrackletsPerHC2D, mChamberStatus); + TRDHelpers::drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } From be025482e9f040331e3bf75637fd51d7715e55cf Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Thu, 21 Dec 2023 16:46:32 -0500 Subject: [PATCH 10/15] TRD: merge drawing functions into one --- Modules/TRD/include/TRD/TRDHelpers.h | 7 +- Modules/TRD/src/DigitsTask.cxx | 3 +- Modules/TRD/src/TRDHelpers.cxx | 107 +++++++++++---------------- Modules/TRD/src/TrackletsTask.cxx | 3 +- 4 files changed, 47 insertions(+), 73 deletions(-) diff --git a/Modules/TRD/include/TRD/TRDHelpers.h b/Modules/TRD/include/TRD/TRDHelpers.h index 17795d961a..8756c2d501 100644 --- a/Modules/TRD/include/TRD/TRDHelpers.h +++ b/Modules/TRD/include/TRD/TRDHelpers.h @@ -33,12 +33,9 @@ class TRDHelpers ~TRDHelpers() = default; static void drawTrdLayersGrid(TH2F* hist, int unitspersection); - static void drawChamberStatusOn2D(std::shared_ptr hist, const std::array* ptrChamber); - static void drawChamberStatusOnLayers(std::array, o2::trd::constants::NLAYER> mLayers, const std::array* ptrChamber, int unitspersection); - - static void drawHashOnLayers(int layer, int hcid, int hcstat, int rowstart, int rowend, int unitspersection, std::array, o2::trd::constants::NLAYER> mLayers); + static void drawChamberStatusOnMapAndLayers(const std::array* ptrChamber, std::shared_ptr hcdist, std::array, o2::trd::constants::NLAYER> mLayers, int unitspersection); + static void drawChamberStatusMask(int hcstat, std::pair x, std::pair y, std::shared_ptr hist); static bool isHalfChamberMasked(int hcid, const std::array* ptrChamber); - static void setBoxChamberStatus(int hcstat, TLine* box[], std::shared_ptr hist); private: // Chamber status values definitions, used for masking diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index ed99601679..0571eaa010 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -151,7 +151,8 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { - TRDHelpers::drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); + // LB: no half chamber distribution map for Digits, pass it as null pointer + TRDHelpers::drawChamberStatusOnMapAndLayers(mChamberStatus, nullptr, mLayers, mUnitsPerSection); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } diff --git a/Modules/TRD/src/TRDHelpers.cxx b/Modules/TRD/src/TRDHelpers.cxx index cec0f2fbdc..c3ea9e906a 100644 --- a/Modules/TRD/src/TRDHelpers.cxx +++ b/Modules/TRD/src/TRDHelpers.cxx @@ -26,86 +26,63 @@ namespace o2::quality_control_modules::trd { bool TRDHelpers::isHalfChamberMasked(int hcid, const std::array* ptrChamber) { - // LB: defined as array in case other chamber status values are set as not masked + // LB: defined as array in case other chamber status values should be set as not masked int GoodStatus[] = { mConfiguredChamberStatus }; int hcstat = (*ptrChamber)[hcid / 2]; return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcstat) == std::end(GoodStatus)); } -void TRDHelpers::drawChamberStatusOn2D(std::shared_ptr hist, const std::array* ptrChamber) +void TRDHelpers::drawChamberStatusOnMapAndLayers(const std::array* ptrChamber, std::shared_ptr hcdist, std::array, NLAYER> mLayers, int unitspersection) { - TLine* boxlines[6]; - std::pair x, y; + std::pair x, y; for (int hcid = 0; hcid < MAXCHAMBER * 2; ++hcid) { if (isHalfChamberMasked(hcid, ptrChamber)) { - int stackLayer = Helper::getStack(hcid / 2) * NLAYER + Helper::getLayer(hcid / 2); - int sectorSide = (hcid / NHCPERSEC) * 2 + (hcid % 2); - x.first = sectorSide; - x.second = sectorSide + 1; - y.first = stackLayer; - y.second = stackLayer + 1; + // Chamber properties + int hcstat = (*ptrChamber)[hcid / 2]; + int side = hcid % 2; + int sec = hcid / NHCPERSEC; + int stack = Helper::getStack(hcid / 2); + int layer = Helper::getLayer(hcid / 2); + + if (hcdist) { + // Coordinates for half chamber distribution + int stackLayer = stack * NLAYER + layer; + int sectorSide = sec * 2 + side; + x.first = sectorSide; + x.second = sectorSide + 1; + y.first = stackLayer; + y.second = stackLayer + 1; - boxlines[0] = new TLine(x.first, y.first, x.second, y.second); - boxlines[1] = new TLine(x.second, y.first, x.first, y.second); - boxlines[2] = new TLine(x.first, y.first, x.second, y.first); - boxlines[3] = new TLine(x.first, y.second, x.second, y.second); - boxlines[4] = new TLine(x.first, y.first, x.first, y.second); - boxlines[5] = new TLine(x.second, y.first, x.second, y.second); - - setBoxChamberStatus((*ptrChamber)[hcid / 2], boxlines, hist); - } - } -} - -void TRDHelpers::drawChamberStatusOnLayers(std::array, NLAYER> mLayers, const std::array* ptrChamber, int unitspersection) -{ - for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { - for (int iSec = 0; iSec < 18; ++iSec) { - for (int iStack = 0; iStack < 5; ++iStack) { - int rowMax = (iStack == 2) ? 12 : 16; - for (int side = 0; side < 2; ++side) { - int det = iSec * 30 + iStack * 6 + iLayer; - int hcid = (side == 0) ? det * 2 : det * 2 + 1; - int rowstart = iStack < 3 ? iStack * 16 : 44 + (iStack - 3) * 16; // pad row within whole sector - int rowend = iStack < 3 ? rowMax + iStack * 16 : rowMax + 44 + (iStack - 3) * 16; // pad row within whole sector - if (isHalfChamberMasked(hcid, ptrChamber)) { - int hcstat = (*ptrChamber)[hcid / 2]; - std::cout << "Leonardo hcid / 2 " << hcid / 2 << std::endl; - std::cout << "Leonardo hcstat " << hcstat << std::endl; - drawHashOnLayers(iLayer, hcid, hcstat, rowstart, rowend, unitspersection, mLayers); - } - } + drawChamberStatusMask(hcstat, x, y, hcdist); + } + + if (mLayers[layer]) { + // Chamber stack of type C0 or C1 condition + int rowstart = FIRSTROW[stack]; + int rowend = stack == 2 ? rowstart + NROWC0 : rowstart + NROWC1; + + // Coordinates for layer map + x.first = rowstart - 0.5; + x.second = rowend - 0.5; + y.first = (sec * 2 + side) * (unitspersection / 2) - 0.5; + y.second = y.first + (unitspersection / 2); + + drawChamberStatusMask(hcstat, x, y, mLayers[layer]); } } } } -void TRDHelpers::drawHashOnLayers(int layer, int hcid, int hcstat, int rowstart, int rowend, int unitspersection, std::array, NLAYER> mLayers) -{ - // Draw a simple box in with a X on it - std::pair topright, bottomleft; // coordinates of box - TLine* boxlines[6]; - int det = hcid / 2; - int side = hcid % 2; - int sec = hcid / 60; - - bottomleft.first = rowstart - 0.5; - bottomleft.second = (sec * 2 + side) * (unitspersection / 2) - 0.5; - topright.first = rowend - 0.5; - topright.second = (sec * 2 + side + 1) * (unitspersection / 2) - 0.5; - - boxlines[0] = new TLine(bottomleft.first, bottomleft.second, topright.first, bottomleft.second); // bottom - boxlines[1] = new TLine(bottomleft.first, topright.second, topright.first, topright.second); // top - boxlines[2] = new TLine(bottomleft.first, bottomleft.second, bottomleft.first, topright.second); // left - boxlines[3] = new TLine(topright.first, bottomleft.second, topright.first, topright.second); // right - boxlines[4] = new TLine(topright.first, bottomleft.second, bottomleft.first, topright.second); // backslash - boxlines[5] = new TLine(bottomleft.first, bottomleft.second, topright.first, topright.second); // forwardslash - - setBoxChamberStatus(hcstat, boxlines, mLayers[layer]); -} - -void TRDHelpers::setBoxChamberStatus(int hcstat, TLine* box[], std::shared_ptr hist) +void TRDHelpers::drawChamberStatusMask(int hcstat, std::pair x, std::pair y, std::shared_ptr hist) { + TLine* box[6]; + box[0] = new TLine(x.first, y.first, x.second, y.first); // bottom + box[1] = new TLine(x.first, y.second, x.second, y.second); // top + box[2] = new TLine(x.first, y.first, x.first, y.second); // left + box[3] = new TLine(x.second, y.first, x.second, y.second); // right + box[4] = new TLine(x.first, y.second, x.second, y.first); // backslash + box[5] = new TLine(x.first, y.first, x.second, y.second); // forwardslash + for (int line = 0; line < 6; ++line) { if (hcstat == mEmptyChamberStatus) { box[line]->SetLineColor(kGray + 1); diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index a1ab247cf2..1cd3ec4624 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -143,8 +143,7 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { - TRDHelpers::drawChamberStatusOn2D(mTrackletsPerHC2D, mChamberStatus); - TRDHelpers::drawChamberStatusOnLayers(mLayers, mChamberStatus, mUnitsPerSection); + TRDHelpers::drawChamberStatusOnMapAndLayers(mChamberStatus, mTrackletsPerHC2D, mLayers, mUnitsPerSection); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } From 43a46f5422d1e99c42ac6310ee5825b8f598c205 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Thu, 21 Dec 2023 20:37:35 -0500 Subject: [PATCH 11/15] TRD: change definitions for better readibility --- Modules/TRD/include/TRD/DigitsTask.h | 4 -- Modules/TRD/include/TRD/TRDHelpers.h | 10 +-- Modules/TRD/include/TRD/TrackletsTask.h | 4 -- Modules/TRD/src/DigitsTask.cxx | 8 +-- Modules/TRD/src/TRDHelpers.cxx | 84 +++++++++---------------- Modules/TRD/src/TrackletsTask.cxx | 8 +-- 6 files changed, 44 insertions(+), 74 deletions(-) diff --git a/Modules/TRD/include/TRD/DigitsTask.h b/Modules/TRD/include/TRD/DigitsTask.h index 470e0fc011..82c3d19c80 100644 --- a/Modules/TRD/include/TRD/DigitsTask.h +++ b/Modules/TRD/include/TRD/DigitsTask.h @@ -82,10 +82,6 @@ class DigitsTask final : public TaskInterface std::shared_ptr mPulseHeightperchamber = nullptr; std::array, o2::trd::constants::NLAYER> mLayers; - // Plotting variables - //TRDHelpers mTRDHelpers; // Auxiliary functions for TRD - int mUnitsPerSection; // Units for each section in layers plots - // CCDB objects const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; const std::array* mChamberStatus = nullptr; diff --git a/Modules/TRD/include/TRD/TRDHelpers.h b/Modules/TRD/include/TRD/TRDHelpers.h index 8756c2d501..dfce01aef7 100644 --- a/Modules/TRD/include/TRD/TRDHelpers.h +++ b/Modules/TRD/include/TRD/TRDHelpers.h @@ -32,11 +32,11 @@ class TRDHelpers TRDHelpers() = default; ~TRDHelpers() = default; - static void drawTrdLayersGrid(TH2F* hist, int unitspersection); - static void drawChamberStatusOnMapAndLayers(const std::array* ptrChamber, std::shared_ptr hcdist, std::array, o2::trd::constants::NLAYER> mLayers, int unitspersection); - static void drawChamberStatusMask(int hcstat, std::pair x, std::pair y, std::shared_ptr hist); - static bool isHalfChamberMasked(int hcid, const std::array* ptrChamber); - + static void addChamberGridToHistogram(TH2F* histogram, int unitsPerSection); + static void drawChamberStatusOnHistograms(const std::array* ptrChamber, std::shared_ptr chamberMap, std::array, o2::trd::constants::NLAYER> ptrLayersArray, int unitsPerSection); + static void drawHalfChamberMask(int halfChamberStatus, std::pair xCoords, std::pair yCoords, std::shared_ptr histogram); + static bool isHalfChamberMasked(int halfChamberId, const std::array* ptrChamber); + private: // Chamber status values definitions, used for masking static const int mConfiguredChamberStatus = 3; diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index e786ddabc3..eb8c65db46 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -62,10 +62,6 @@ class TrackletsTask final : public TaskInterface std::shared_ptr mTriggersPerTimeFrame = nullptr; std::array, o2::trd::constants::NLAYER> mLayers; - // Plotting variables - //TRDHelpers mTRDHelpers; // Auxiliary functions for TRD - int mUnitsPerSection; // Units for each section in layers plots - // data to pull from CCDB const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; const std::array* mChamberStatus = nullptr; diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index 0571eaa010..0373ef293c 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -126,12 +126,12 @@ void DigitsTask::buildHistograms() } // Build digits layers - mUnitsPerSection = 144; + int unitsPerSection = NCOLUMN; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), - 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); + 76, -0.5, 75.5, unitsPerSection * 18, -0.5, unitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - TRDHelpers::drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); + TRDHelpers::addChamberGridToHistogram(mLayers[iLayer].get(), unitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); @@ -152,7 +152,7 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { // LB: no half chamber distribution map for Digits, pass it as null pointer - TRDHelpers::drawChamberStatusOnMapAndLayers(mChamberStatus, nullptr, mLayers, mUnitsPerSection); + TRDHelpers::drawChamberStatusOnHistograms(mChamberStatus, nullptr, mLayers, NCOLUMN); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } diff --git a/Modules/TRD/src/TRDHelpers.cxx b/Modules/TRD/src/TRDHelpers.cxx index c3ea9e906a..f3854ed01e 100644 --- a/Modules/TRD/src/TRDHelpers.cxx +++ b/Modules/TRD/src/TRDHelpers.cxx @@ -32,7 +32,7 @@ bool TRDHelpers::isHalfChamberMasked(int hcid, const std::array return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcstat) == std::end(GoodStatus)); } -void TRDHelpers::drawChamberStatusOnMapAndLayers(const std::array* ptrChamber, std::shared_ptr hcdist, std::array, NLAYER> mLayers, int unitspersection) +void TRDHelpers::drawChamberStatusOnHistograms(const std::array* ptrChamber, std::shared_ptr chamberMap, std::array, NLAYER> ptrLayersArray, int unitsPerSection) { std::pair x, y; for (int hcid = 0; hcid < MAXCHAMBER * 2; ++hcid) { @@ -43,8 +43,8 @@ void TRDHelpers::drawChamberStatusOnMapAndLayers(const std::array x, std::pair y, std::shared_ptr hist) +void TRDHelpers::drawHalfChamberMask(int hcstat, std::pair xCoord, std::pair yCoord, std::shared_ptr histogram) { TLine* box[6]; - box[0] = new TLine(x.first, y.first, x.second, y.first); // bottom - box[1] = new TLine(x.first, y.second, x.second, y.second); // top - box[2] = new TLine(x.first, y.first, x.first, y.second); // left - box[3] = new TLine(x.second, y.first, x.second, y.second); // right - box[4] = new TLine(x.first, y.second, x.second, y.first); // backslash - box[5] = new TLine(x.first, y.first, x.second, y.second); // forwardslash - + box[0] = new TLine(xCoord.first, yCoord.first, xCoord.second, yCoord.first); // bottom + box[1] = new TLine(xCoord.first, yCoord.second, xCoord.second, yCoord.second); // top + box[2] = new TLine(xCoord.first, yCoord.first, xCoord.first, yCoord.second); // left + box[3] = new TLine(xCoord.second, yCoord.first, xCoord.second, yCoord.second); // right + box[4] = new TLine(xCoord.first, yCoord.second, xCoord.second, yCoord.first); // backslash + box[5] = new TLine(xCoord.first, yCoord.first, xCoord.second, yCoord.second); // forwardslash + for (int line = 0; line < 6; ++line) { if (hcstat == mEmptyChamberStatus) { box[line]->SetLineColor(kGray + 1); @@ -92,48 +92,26 @@ void TRDHelpers::drawChamberStatusMask(int hcstat, std::pair x, st box[line]->SetLineColor(kBlack); } box[line]->SetLineWidth(2); - hist->GetListOfFunctions()->Add(box[line]); + histogram->GetListOfFunctions()->Add(box[line]); } } -void TRDHelpers::drawTrdLayersGrid(TH2F* hist, int unitspersection) +void TRDHelpers::addChamberGridToHistogram(TH2F* histogram, int unitsPerSection) { TLine* line; - for (int i = 0; i < 5; ++i) { - switch (i) { - case 0: - line = new TLine(15.5, 0, 15.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 1: - line = new TLine(31.5, 0, 31.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 2: - line = new TLine(43.5, 0, 43.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 3: - line = new TLine(59.5, 0, 59.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - } + for (int iStack = 0; iStack < NSTACK; ++iStack) { + line = new TLine(FIRSTROW[iStack] - 0.5, 0, FIRSTROW[iStack] - 0.5, NSECTOR * unitsPerSection - 0.5); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + histogram->GetListOfFunctions()->Add(line); } - for (int iSec = 1; iSec < 18; ++iSec) { - float yPos = iSec * unitspersection - 0.5; - line = new TLine(-0.5, yPos, 75.5, yPos); + for (int iSec = 1; iSec < NSECTOR; ++iSec) { + float yPos = iSec * unitsPerSection - 0.5; + line = new TLine(-0.5, yPos, FIRSTROW[NSTACK - 1] + NROWC1 - 0.5, yPos); line->SetLineStyle(kDashed); line->SetLineColor(kBlack); - hist->GetListOfFunctions()->Add(line); + histogram->GetListOfFunctions()->Add(line); } } } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index 1cd3ec4624..d72f4e2983 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -118,12 +118,12 @@ void TrackletsTask::buildHistograms() getObjectsManager()->startPublishing(mTriggersPerTimeFrame.get()); // Build tracklet layers - mUnitsPerSection = 8; + int unitsPerSection = NCOLUMN / NSECTOR; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), - 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); + 76, -0.5, 75.5, unitsPerSection * 18, -0.5, unitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - TRDHelpers::drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); + TRDHelpers::addChamberGridToHistogram(mLayers[iLayer].get(), unitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); @@ -143,7 +143,7 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { - TRDHelpers::drawChamberStatusOnMapAndLayers(mChamberStatus, mTrackletsPerHC2D, mLayers, mUnitsPerSection); + TRDHelpers::drawChamberStatusOnHistograms(mChamberStatus, mTrackletsPerHC2D, mLayers, NCOLUMN / NSECTOR); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } From 436c602006746f2e35e1b51636827d7da67f8742 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Thu, 21 Dec 2023 20:37:35 -0500 Subject: [PATCH 12/15] better definitions for readibility --- Modules/TRD/include/TRD/DigitsTask.h | 4 -- Modules/TRD/include/TRD/TRDHelpers.h | 10 +-- Modules/TRD/include/TRD/TrackletsTask.h | 4 -- Modules/TRD/src/DigitsTask.cxx | 8 +-- Modules/TRD/src/TRDHelpers.cxx | 84 +++++++++---------------- Modules/TRD/src/TrackletsTask.cxx | 8 +-- 6 files changed, 44 insertions(+), 74 deletions(-) diff --git a/Modules/TRD/include/TRD/DigitsTask.h b/Modules/TRD/include/TRD/DigitsTask.h index 470e0fc011..82c3d19c80 100644 --- a/Modules/TRD/include/TRD/DigitsTask.h +++ b/Modules/TRD/include/TRD/DigitsTask.h @@ -82,10 +82,6 @@ class DigitsTask final : public TaskInterface std::shared_ptr mPulseHeightperchamber = nullptr; std::array, o2::trd::constants::NLAYER> mLayers; - // Plotting variables - //TRDHelpers mTRDHelpers; // Auxiliary functions for TRD - int mUnitsPerSection; // Units for each section in layers plots - // CCDB objects const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; const std::array* mChamberStatus = nullptr; diff --git a/Modules/TRD/include/TRD/TRDHelpers.h b/Modules/TRD/include/TRD/TRDHelpers.h index 8756c2d501..dfce01aef7 100644 --- a/Modules/TRD/include/TRD/TRDHelpers.h +++ b/Modules/TRD/include/TRD/TRDHelpers.h @@ -32,11 +32,11 @@ class TRDHelpers TRDHelpers() = default; ~TRDHelpers() = default; - static void drawTrdLayersGrid(TH2F* hist, int unitspersection); - static void drawChamberStatusOnMapAndLayers(const std::array* ptrChamber, std::shared_ptr hcdist, std::array, o2::trd::constants::NLAYER> mLayers, int unitspersection); - static void drawChamberStatusMask(int hcstat, std::pair x, std::pair y, std::shared_ptr hist); - static bool isHalfChamberMasked(int hcid, const std::array* ptrChamber); - + static void addChamberGridToHistogram(TH2F* histogram, int unitsPerSection); + static void drawChamberStatusOnHistograms(const std::array* ptrChamber, std::shared_ptr chamberMap, std::array, o2::trd::constants::NLAYER> ptrLayersArray, int unitsPerSection); + static void drawHalfChamberMask(int halfChamberStatus, std::pair xCoords, std::pair yCoords, std::shared_ptr histogram); + static bool isHalfChamberMasked(int halfChamberId, const std::array* ptrChamber); + private: // Chamber status values definitions, used for masking static const int mConfiguredChamberStatus = 3; diff --git a/Modules/TRD/include/TRD/TrackletsTask.h b/Modules/TRD/include/TRD/TrackletsTask.h index e786ddabc3..eb8c65db46 100644 --- a/Modules/TRD/include/TRD/TrackletsTask.h +++ b/Modules/TRD/include/TRD/TrackletsTask.h @@ -62,10 +62,6 @@ class TrackletsTask final : public TaskInterface std::shared_ptr mTriggersPerTimeFrame = nullptr; std::array, o2::trd::constants::NLAYER> mLayers; - // Plotting variables - //TRDHelpers mTRDHelpers; // Auxiliary functions for TRD - int mUnitsPerSection; // Units for each section in layers plots - // data to pull from CCDB const o2::trd::NoiseStatusMCM* mNoiseMap = nullptr; const std::array* mChamberStatus = nullptr; diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index 0571eaa010..0373ef293c 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -126,12 +126,12 @@ void DigitsTask::buildHistograms() } // Build digits layers - mUnitsPerSection = 144; + int unitsPerSection = NCOLUMN; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), - 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); + 76, -0.5, 75.5, unitsPerSection * 18, -0.5, unitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - TRDHelpers::drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); + TRDHelpers::addChamberGridToHistogram(mLayers[iLayer].get(), unitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); @@ -152,7 +152,7 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { // LB: no half chamber distribution map for Digits, pass it as null pointer - TRDHelpers::drawChamberStatusOnMapAndLayers(mChamberStatus, nullptr, mLayers, mUnitsPerSection); + TRDHelpers::drawChamberStatusOnHistograms(mChamberStatus, nullptr, mLayers, NCOLUMN); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } diff --git a/Modules/TRD/src/TRDHelpers.cxx b/Modules/TRD/src/TRDHelpers.cxx index c3ea9e906a..f3854ed01e 100644 --- a/Modules/TRD/src/TRDHelpers.cxx +++ b/Modules/TRD/src/TRDHelpers.cxx @@ -32,7 +32,7 @@ bool TRDHelpers::isHalfChamberMasked(int hcid, const std::array return (std::find(std::begin(GoodStatus), std::end(GoodStatus), hcstat) == std::end(GoodStatus)); } -void TRDHelpers::drawChamberStatusOnMapAndLayers(const std::array* ptrChamber, std::shared_ptr hcdist, std::array, NLAYER> mLayers, int unitspersection) +void TRDHelpers::drawChamberStatusOnHistograms(const std::array* ptrChamber, std::shared_ptr chamberMap, std::array, NLAYER> ptrLayersArray, int unitsPerSection) { std::pair x, y; for (int hcid = 0; hcid < MAXCHAMBER * 2; ++hcid) { @@ -43,8 +43,8 @@ void TRDHelpers::drawChamberStatusOnMapAndLayers(const std::array x, std::pair y, std::shared_ptr hist) +void TRDHelpers::drawHalfChamberMask(int hcstat, std::pair xCoord, std::pair yCoord, std::shared_ptr histogram) { TLine* box[6]; - box[0] = new TLine(x.first, y.first, x.second, y.first); // bottom - box[1] = new TLine(x.first, y.second, x.second, y.second); // top - box[2] = new TLine(x.first, y.first, x.first, y.second); // left - box[3] = new TLine(x.second, y.first, x.second, y.second); // right - box[4] = new TLine(x.first, y.second, x.second, y.first); // backslash - box[5] = new TLine(x.first, y.first, x.second, y.second); // forwardslash - + box[0] = new TLine(xCoord.first, yCoord.first, xCoord.second, yCoord.first); // bottom + box[1] = new TLine(xCoord.first, yCoord.second, xCoord.second, yCoord.second); // top + box[2] = new TLine(xCoord.first, yCoord.first, xCoord.first, yCoord.second); // left + box[3] = new TLine(xCoord.second, yCoord.first, xCoord.second, yCoord.second); // right + box[4] = new TLine(xCoord.first, yCoord.second, xCoord.second, yCoord.first); // backslash + box[5] = new TLine(xCoord.first, yCoord.first, xCoord.second, yCoord.second); // forwardslash + for (int line = 0; line < 6; ++line) { if (hcstat == mEmptyChamberStatus) { box[line]->SetLineColor(kGray + 1); @@ -92,48 +92,26 @@ void TRDHelpers::drawChamberStatusMask(int hcstat, std::pair x, st box[line]->SetLineColor(kBlack); } box[line]->SetLineWidth(2); - hist->GetListOfFunctions()->Add(box[line]); + histogram->GetListOfFunctions()->Add(box[line]); } } -void TRDHelpers::drawTrdLayersGrid(TH2F* hist, int unitspersection) +void TRDHelpers::addChamberGridToHistogram(TH2F* histogram, int unitsPerSection) { TLine* line; - for (int i = 0; i < 5; ++i) { - switch (i) { - case 0: - line = new TLine(15.5, 0, 15.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 1: - line = new TLine(31.5, 0, 31.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 2: - line = new TLine(43.5, 0, 43.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - case 3: - line = new TLine(59.5, 0, 59.5, 18 * unitspersection - 0.5); - hist->GetListOfFunctions()->Add(line); - line->SetLineStyle(kDashed); - line->SetLineColor(kBlack); - break; - } + for (int iStack = 0; iStack < NSTACK; ++iStack) { + line = new TLine(FIRSTROW[iStack] - 0.5, 0, FIRSTROW[iStack] - 0.5, NSECTOR * unitsPerSection - 0.5); + line->SetLineStyle(kDashed); + line->SetLineColor(kBlack); + histogram->GetListOfFunctions()->Add(line); } - for (int iSec = 1; iSec < 18; ++iSec) { - float yPos = iSec * unitspersection - 0.5; - line = new TLine(-0.5, yPos, 75.5, yPos); + for (int iSec = 1; iSec < NSECTOR; ++iSec) { + float yPos = iSec * unitsPerSection - 0.5; + line = new TLine(-0.5, yPos, FIRSTROW[NSTACK - 1] + NROWC1 - 0.5, yPos); line->SetLineStyle(kDashed); line->SetLineColor(kBlack); - hist->GetListOfFunctions()->Add(line); + histogram->GetListOfFunctions()->Add(line); } } } // namespace o2::quality_control_modules::trd diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index 1cd3ec4624..d72f4e2983 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -118,12 +118,12 @@ void TrackletsTask::buildHistograms() getObjectsManager()->startPublishing(mTriggersPerTimeFrame.get()); // Build tracklet layers - mUnitsPerSection = 8; + int unitsPerSection = NCOLUMN / NSECTOR; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), - 76, -0.5, 75.5, mUnitsPerSection * 18, -0.5, mUnitsPerSection * 18 - 0.5)); + 76, -0.5, 75.5, unitsPerSection * 18, -0.5, unitsPerSection * 18 - 0.5)); mLayers[iLayer]->SetStats(0); - TRDHelpers::drawTrdLayersGrid(mLayers[iLayer].get(), mUnitsPerSection); + TRDHelpers::addChamberGridToHistogram(mLayers[iLayer].get(), unitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); @@ -143,7 +143,7 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { - TRDHelpers::drawChamberStatusOnMapAndLayers(mChamberStatus, mTrackletsPerHC2D, mLayers, mUnitsPerSection); + TRDHelpers::drawChamberStatusOnHistograms(mChamberStatus, mTrackletsPerHC2D, mLayers, NCOLUMN / NSECTOR); } else { ILOG(Info, Support) << "Failed to retrieve ChamberStatus, so it will not show on plots" << ENDM; } From 52c4654a015caffb5c3c4fbfb45c9b7bece031e7 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Thu, 21 Dec 2023 20:55:42 -0500 Subject: [PATCH 13/15] TRD: add grid helper function to receive shared pointers --- Modules/TRD/include/TRD/TRDHelpers.h | 2 +- Modules/TRD/src/DigitsTask.cxx | 4 ++-- Modules/TRD/src/TRDHelpers.cxx | 2 +- Modules/TRD/src/TrackletsTask.cxx | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/TRD/include/TRD/TRDHelpers.h b/Modules/TRD/include/TRD/TRDHelpers.h index dfce01aef7..1ae8af7861 100644 --- a/Modules/TRD/include/TRD/TRDHelpers.h +++ b/Modules/TRD/include/TRD/TRDHelpers.h @@ -32,7 +32,7 @@ class TRDHelpers TRDHelpers() = default; ~TRDHelpers() = default; - static void addChamberGridToHistogram(TH2F* histogram, int unitsPerSection); + static void addChamberGridToHistogram(std::shared_ptr histogram, int unitsPerSection); static void drawChamberStatusOnHistograms(const std::array* ptrChamber, std::shared_ptr chamberMap, std::array, o2::trd::constants::NLAYER> ptrLayersArray, int unitsPerSection); static void drawHalfChamberMask(int halfChamberStatus, std::pair xCoords, std::pair yCoords, std::shared_ptr histogram); static bool isHalfChamberMasked(int halfChamberId, const std::array* ptrChamber); diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index 0373ef293c..5ce90db685 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -129,9 +129,9 @@ void DigitsTask::buildHistograms() int unitsPerSection = NCOLUMN; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("DigitsPerLayer_%i", iLayer), Form("Digit count per pad in layer %i;glb pad row;glb pad col", iLayer), - 76, -0.5, 75.5, unitsPerSection * 18, -0.5, unitsPerSection * 18 - 0.5)); + 76, -0.5, 75.5, unitsPerSection * NSECTOR, -0.5, unitsPerSection * NSECTOR - 0.5)); mLayers[iLayer]->SetStats(0); - TRDHelpers::addChamberGridToHistogram(mLayers[iLayer].get(), unitsPerSection); + TRDHelpers::addChamberGridToHistogram(mLayers[iLayer], unitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); diff --git a/Modules/TRD/src/TRDHelpers.cxx b/Modules/TRD/src/TRDHelpers.cxx index f3854ed01e..565c2371e2 100644 --- a/Modules/TRD/src/TRDHelpers.cxx +++ b/Modules/TRD/src/TRDHelpers.cxx @@ -96,7 +96,7 @@ void TRDHelpers::drawHalfChamberMask(int hcstat, std::pair xCoord, } } -void TRDHelpers::addChamberGridToHistogram(TH2F* histogram, int unitsPerSection) +void TRDHelpers::addChamberGridToHistogram(std::shared_ptr histogram, int unitsPerSection) { TLine* line; for (int iStack = 0; iStack < NSTACK; ++iStack) { diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index d72f4e2983..4222896a72 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -121,9 +121,9 @@ void TrackletsTask::buildHistograms() int unitsPerSection = NCOLUMN / NSECTOR; for (int iLayer = 0; iLayer < NLAYER; ++iLayer) { mLayers[iLayer].reset(new TH2F(Form("TrackletsPerMCM_Layer%i", iLayer), Form("Tracklet count per MCM in layer %i;glb pad row;glb MCM col", iLayer), - 76, -0.5, 75.5, unitsPerSection * 18, -0.5, unitsPerSection * 18 - 0.5)); + 76, -0.5, 75.5, NCOLUMN, -0.5, NCOLUMN - 0.5)); mLayers[iLayer]->SetStats(0); - TRDHelpers::addChamberGridToHistogram(mLayers[iLayer].get(), unitsPerSection); + TRDHelpers::addChamberGridToHistogram(mLayers[iLayer], unitsPerSection); getObjectsManager()->startPublishing(mLayers[iLayer].get()); getObjectsManager()->setDefaultDrawOptions(mLayers[iLayer]->GetName(), "COLZ"); getObjectsManager()->setDisplayHint(mLayers[iLayer].get(), "logz"); From fbdaaaa93546bc604cb8f544fce62cb19a9100c4 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Thu, 11 Jan 2024 12:49:25 -0500 Subject: [PATCH 14/15] TRD: new variable for chamber status --- Modules/TRD/src/DigitsTask.cxx | 2 +- Modules/TRD/src/TrackletsTask.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/TRD/src/DigitsTask.cxx b/Modules/TRD/src/DigitsTask.cxx index 5ce90db685..16ac5e2208 100644 --- a/Modules/TRD/src/DigitsTask.cxx +++ b/Modules/TRD/src/DigitsTask.cxx @@ -147,7 +147,7 @@ void DigitsTask::monitorData(o2::framework::ProcessingContext& ctx) } if (!mChamberStatus) { - auto ptr = ctx.inputs().get*>("chamberStatus"); + auto ptr = ctx.inputs().get*>("fedChamberStatus"); mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { diff --git a/Modules/TRD/src/TrackletsTask.cxx b/Modules/TRD/src/TrackletsTask.cxx index 4222896a72..018ad7f0d3 100644 --- a/Modules/TRD/src/TrackletsTask.cxx +++ b/Modules/TRD/src/TrackletsTask.cxx @@ -139,7 +139,7 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx) } if (!mChamberStatus) { - auto ptr = ctx.inputs().get*>("chamberStatus"); + auto ptr = ctx.inputs().get*>("fedChamberStatus"); mChamberStatus = ptr.get(); // LB: only draw in plots if it is first instance, e.g. null ptr to non null ptr if (mChamberStatus) { From 24466273255758c52a2189ca1aea1d854a45a2e1 Mon Sep 17 00:00:00 2001 From: leo-barreto Date: Mon, 15 Jan 2024 10:22:37 +0100 Subject: [PATCH 15/15] TRD: Empty, trigger CI