Skip to content

Commit

Permalink
TRD use new raw data stat format and Trklt Task cleanup (#1925)
Browse files Browse the repository at this point in the history
  • Loading branch information
martenole authored and Barthelemy committed Aug 22, 2023
1 parent 8728fbe commit 2794846
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Modules/TRD/include/TRD/RawData.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ class RawData final : public TaskInterface
TH1F* mTimeFrameTime = nullptr;
TH1F* mTrackletParsingTime = nullptr;
TH1F* mDigitParsingTime = nullptr;
TH1F* mDataVersions = nullptr;
TH1F* mDataVersionsMajor = nullptr;
TH1F* mParsingErrors = nullptr;
std::array<TH2F*, 10> mLinkErrors;
std::array<TH2F*, o2::trd::ParsingErrors::TRDLastParsingError> mParsingErrors2d;
bool mCheckDigitHCHeaderVersion = false;
};

} // namespace o2::quality_control_modules::trd
Expand Down
1 change: 0 additions & 1 deletion Modules/TRD/include/TRD/TrackletsTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class TrackletsTask final : public TaskInterface
TH1F* mTrackletHCIDn = nullptr;
TH1F* mTrackletPositionn = nullptr;
TH1F* mTrackletPositionRawn = nullptr;
TH1F* mTrackletsPerEventn = nullptr;
TH1F* mTrackletsPerTimeFrame = nullptr;
TH1F* mTriggersPerTimeFrame = nullptr;
TH1F* mTrackletsPerTimeFrameCycled = nullptr;
Expand Down
58 changes: 38 additions & 20 deletions Modules/TRD/src/RawData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "TCanvas.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TMath.h"

#include "QualityControl/QcInfoLogger.h"
#include "TRD/RawData.h"
Expand Down Expand Up @@ -54,7 +55,7 @@ void RawData::buildHistograms()

mStats = new TH1F("stats", "Data reader statistics;;counts", 5, 0, 5);
getObjectsManager()->startPublishing(mStats);
getObjectsManager()->setDisplayHint("stats", "logz");
getObjectsManager()->setDefaultDrawOptions(mStats->GetName(), "logy");
mStats->GetXaxis()->SetBinLabel(1, "nTF");
mStats->GetXaxis()->SetBinLabel(2, "nTrig");
mStats->GetXaxis()->SetBinLabel(3, "nCalTrig");
Expand All @@ -65,21 +66,30 @@ void RawData::buildHistograms()
getObjectsManager()->startPublishing(mDataAcceptance);
mDataAcceptance->GetXaxis()->SetBinLabel(1, "Accepted");
mDataAcceptance->GetXaxis()->SetBinLabel(2, "Rejected");
mTimeFrameTime = new TH1F("timeframetime", "Time taken per time frame;Time taken [ms];Counts", 10000, 0, 10000);
constexpr int nLogBins = 100;
float xBins[nLogBins + 1];
float xBinLogMin = 1.f;
float xBinLogMax = 6.f;
float logBinWidth = (xBinLogMax - xBinLogMin) / nLogBins;
for (int iBin = 0; iBin <= nLogBins; ++iBin) {
xBins[iBin] = TMath::Power(10, xBinLogMin + iBin * logBinWidth);
}
mTimeFrameTime = new TH1F("timeframetime", "Time taken per time frame;Time taken [us];Counts", nLogBins, xBins);
getObjectsManager()->startPublishing(mTimeFrameTime);
mTrackletParsingTime = new TH1F("tracklettime", "Time taken per tracklet block;Time taken [ms];Counts", 1000, 0, 1000);
getObjectsManager()->setDefaultDrawOptions(mTimeFrameTime->GetName(), "logx");
mTrackletParsingTime = new TH1F("tracklettime", "Time taken per tracklet block;Time taken [us];Counts", nLogBins, xBins);
getObjectsManager()->startPublishing(mTrackletParsingTime);
mDigitParsingTime = new TH1F("digittime", "Time taken per digit block;Time taken [ms];Counts", 1000, 0, 1000);
getObjectsManager()->setDefaultDrawOptions(mTrackletParsingTime->GetName(), "logx");
mDigitParsingTime = new TH1F("digittime", "Time taken per digit block;Time taken [us];Counts", nLogBins, xBins);
getObjectsManager()->startPublishing(mDigitParsingTime);
mDataVersions = new TH1F("dataversions", "Data versions major.minor seen in data (half chamber header required);Version major.minor;Counts", 65000, 0, 65000);
getObjectsManager()->startPublishing(mDataVersions);
mDataVersionsMajor = new TH1F("dataversionsmajor", "Data versions major seen in the data (half chamber header required);Version;Counts", 256, 0, 256);
getObjectsManager()->setDefaultDrawOptions(mDigitParsingTime->GetName(), "logx");
mDataVersionsMajor = new TH1F("dataversionsmajor", "Data versions major seen in the data (half chamber header required);Version;Counts", 256, -0.5, 255.5);
getObjectsManager()->startPublishing(mDataVersionsMajor);
mParsingErrors = new TH1F("parseerrors", "Parsing Errors seen in data;;Counts", TRDLastParsingError, 0, TRDLastParsingError);
getObjectsManager()->startPublishing(mParsingErrors);
getObjectsManager()->setDisplayHint(mParsingErrors->GetName(), "logz");
getObjectsManager()->setDefaultDrawOptions(mParsingErrors->GetName(), "logy");

mDataVolumePerHalfChamber = new TH2F("datavolumeperhalfchamber", "Data sizes from HalfCRU header;Data Volume [kB/TF]", 1080, -0.5, 1079.5, 1000, 0, 100);
mDataVolumePerHalfChamber = new TH2F("datavolumeperhalfchamber", "Data sizes from HalfCRU header;Half Chamber ID;Data Volume [kB/TF]", 1080, -0.5, 1079.5, 1000, 0, 100);
getObjectsManager()->startPublishing(mDataVolumePerHalfChamber);
getObjectsManager()->setDefaultDrawOptions("datavolumeperhalfchamber", "COLZ");
getObjectsManager()->setDisplayHint(mDataVolumePerHalfChamber->GetName(), "logz");
Expand Down Expand Up @@ -163,7 +173,10 @@ void RawData::buildHistograms()
void RawData::initialize(o2::framework::InitContext& /*ctx*/)
{

ILOG(Debug, Devel) << "initialize TRD RawData QC " << ENDM;
ILOG(Debug, Devel) << "initialize TRD RawData QC" << ENDM;
if (auto param = mCustomParameters.find("fillHeaderVersionHist"); param != mCustomParameters.end()) {
mCheckDigitHCHeaderVersion = std::stoi(param->second);
}

buildHistograms();
ILOG(Info, Support) << "TRD RawData QC histograms built" << ENDM;
Expand All @@ -186,17 +199,16 @@ void RawData::monitorData(o2::framework::ProcessingContext& ctx)
{

auto rawdatastats = ctx.inputs().get<o2::trd::TRDDataCountersPerTimeFrame*>("rawstats");
/*
mStats->AddBinContent(1, 1); // count number of TFs seen
mStats->AddBinContent(2, rawdatastats->mNTriggersTotal); // count total number of triggers seen
mStats->AddBinContent(3, rawdatastats->mNTriggersCalib); // count total number of calibration triggers seen
mStats->AddBinContent(4, rawdatastats->mTrackletsFound); // count total number of tracklets seen
mStats->AddBinContent(5, rawdatastats->mDigitsFound); // count total number of digits seen
*/

// data per TF per link.
for (int hcid = 0; hcid < 1080; ++hcid) {
for (int hcid = 0; hcid < MAXHALFCHAMBER; ++hcid) {
if (rawdatastats->mLinkWords[hcid] > 0) {
int sec = hcid / 60;
int sec = hcid / NHCPERSEC;
mDataVolumePerHalfChamber->Fill(hcid, rawdatastats->mLinkWords[hcid] / 32.f); // one link word is 32 bytes, we want to display in units of kB per TF
mDataVolumePerSector->Fill(sec, rawdatastats->mLinkWords[hcid] / 32.f);
}
Expand All @@ -206,15 +218,20 @@ void RawData::monitorData(o2::framework::ProcessingContext& ctx)
for (int error = 0; error < TRDLastParsingError; ++error) {
mParsingErrors->AddBinContent(error + 1, rawdatastats->mParsingErrors[error]);
}
/* TODO uncomment when changes available in O2 and add plot for links without any errors
for (auto e : rawdatastats->mParsingErrorsLink) {
for (auto e : rawdatastats->mParsingErrorsByLink) {
int hcid = e / TRDLastParsingError;
int errorIdx = e % TRDLastParsingError;
int stackLayer = HelperMethods::getStack(hcid / 2) * NLAYER + HelperMethods::getLayer(hcid / 2);
int sectorSide = (hcid / NHCPERSEC) * 2 + (hcid % 2);
mParsingErrors2d[errorIdx]->Fill(sectorSide, stackLayer);
}
*/
for (int hcid = 0; hcid < MAXHALFCHAMBER; ++hcid) {
if (rawdatastats->mParsingOK[hcid] > 0) {
int stackLayer = HelperMethods::getStack(hcid / 2) * NLAYER + HelperMethods::getLayer(hcid / 2);
int sectorSide = (hcid / NHCPERSEC) * 2 + (hcid % 2);
mParsingErrors2d[0]->SetBinContent(sectorSide + 1, stackLayer + 1, mParsingErrors2d[0]->GetBinContent(sectorSide + 1, stackLayer + 1) + rawdatastats->mParsingOK[hcid]);
}
}

// link statistics
for (int hcid = 0; hcid < MAXHALFCHAMBER; ++hcid) {
Expand Down Expand Up @@ -260,8 +277,10 @@ void RawData::monitorData(o2::framework::ProcessingContext& ctx)
mDigitParsingTime->Fill(rawdatastats->mTimeTakenForDigits);
mTrackletParsingTime->Fill(rawdatastats->mTimeTakenForTracklets);

for (int i = 0; i < rawdatastats->mDataFormatRead.size(); ++i) {
mDataVersionsMajor->Fill(i, rawdatastats->mDataFormatRead[i]);
if (mCheckDigitHCHeaderVersion) {
for (int i = 0; i < rawdatastats->mDataFormatRead.size(); ++i) {
mDataVersionsMajor->Fill(i, rawdatastats->mDataFormatRead[i]);
}
}
}

Expand Down Expand Up @@ -296,7 +315,6 @@ void RawData::resetHistograms()
mTimeFrameTime->Reset();
mTrackletParsingTime->Reset();
mDigitParsingTime->Reset();
mDataVersions->Reset();
mDataVersionsMajor->Reset();
mParsingErrors->Reset();
mDataVolumePerHalfChamber->Reset();
Expand Down
27 changes: 15 additions & 12 deletions Modules/TRD/src/TrackletsTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <TH2.h>
#include <THashList.h>
#include <TLine.h>
#include <TMath.h>
#include <sstream>
#include <string>

Expand Down Expand Up @@ -136,6 +137,14 @@ void TrackletsTask::buildHistograms()
getObjectsManager()->setDefaultDrawOptions(moHCMCM[sm]->GetName(), "COLZ");
drawLinesMCM(moHCMCM[sm]);
}
constexpr int nLogBins = 100;
float xBins[nLogBins + 1];
float xBinLogMin = 0.f;
float xBinLogMax = 8.f;
float logBinWidth = (xBinLogMax - xBinLogMin) / nLogBins;
for (int iBin = 0; iBin <= nLogBins; ++iBin) {
xBins[iBin] = TMath::Power(10, xBinLogMin + iBin * logBinWidth);
}
mTrackletSlope = new TH1F("trackletslope", "uncalibrated Slope of tracklets;Slope;Counts", 1024, -6.0, 6.0); // slope is 8 bits in the tracklet
getObjectsManager()->startPublishing(mTrackletSlope);
mTrackletSlopeRaw = new TH1F("trackletsloperaw", "Raw Slope of tracklets;Slope;Counts", 256, 0, 256); // slope is 8 bits in the tracklet
Expand All @@ -146,8 +155,9 @@ void TrackletsTask::buildHistograms()
getObjectsManager()->startPublishing(mTrackletPosition);
mTrackletPositionRaw = new TH1F("trackletposraw", "Raw Position of Tracklets;Position;Counts", 2048, 0, 2048);
getObjectsManager()->startPublishing(mTrackletPositionRaw);
mTrackletsPerEvent = new TH1F("trackletsperevent", "Number of Tracklets per event;Tracklets in Event;Counts", 25000, 0, 25000);
mTrackletsPerEvent = new TH1F("trackletsperevent", "Number of Tracklets per event;Tracklets in Event;Counts", nLogBins, xBins);
getObjectsManager()->startPublishing(mTrackletsPerEvent);
getObjectsManager()->setDefaultDrawOptions(mTrackletsPerEvent->GetName(), "logx");
mTrackletsPerHC2D = 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");
Expand Down Expand Up @@ -242,13 +252,11 @@ void TrackletsTask::buildHistograms()
getObjectsManager()->startPublishing(mTrackletPositionn);
mTrackletPositionRawn = new TH1F("trackletposrawnoise", "Raw Position of Tracklets noise in;Position;Counts", 2048, 0, 2048);
getObjectsManager()->startPublishing(mTrackletPositionRawn);
mTrackletsPerEventn = new TH1F("trackletspereventn", "Number of Tracklets per event noise in;Tracklets in Events;Counts", 25000, 0, 25000);
getObjectsManager()->startPublishing(mTrackletsPerEventn);
mTrackletsPerTimeFrame = new TH1F("trackletspertimeframe", "Number of Tracklets per timeframe;Tracklets in TimeFrame;Counts", 25000, 0, 500000);
mTrackletsPerTimeFrame = new TH1F("trackletspertimeframe", "Number of Tracklets per timeframe;Tracklets in TimeFrame;Counts", nLogBins, xBins);
getObjectsManager()->startPublishing(mTrackletsPerTimeFrame);
mTrackletsPerTimeFrameCycled = new TH1F("trackletspertimeframecycled", "Number of Tracklets per timeframe, this cycle;Tracklets in TimeFrame;Counts", 25000, 0, 500000);
getObjectsManager()->startPublishing(mTrackletsPerTimeFrameCycled);
mTriggersPerTimeFrame = new TH1F("triggerspertimeframe", "Number of Triggers per timeframe;Triggers in TimeFrame;Counts", 10000, 0, 10000);
getObjectsManager()->setDefaultDrawOptions(mTrackletsPerTimeFrame->GetName(), "logx");
// getObjectsManager()->setDisplayHint(mTrackletsPerTimeFrame->GetName(), "gStyle->SetOptStat(11111)"); // FIXME: how to show number of underflow bin entries by default?
mTriggersPerTimeFrame = new TH1F("triggerspertimeframe", "Number of Triggers per timeframe;Triggers in TimeFrame;Counts", 1000, 0, 1000);
getObjectsManager()->startPublishing(mTriggersPerTimeFrame);

buildTrackletLayers();
Expand Down Expand Up @@ -417,7 +425,6 @@ void TrackletsTask::monitorData(o2::framework::ProcessingContext& ctx)
auto tracklets = ctx.inputs().get<gsl::span<o2::trd::Tracklet64>>("tracklets");
auto triggerrecords = ctx.inputs().get<gsl::span<o2::trd::TriggerRecord>>("triggers");
mTrackletsPerTimeFrame->Fill(tracklets.size());
mTrackletsPerTimeFrameCycled->Fill(tracklets.size());
mTriggersPerTimeFrame->Fill(triggerrecords.size());
for (auto& trigger : triggerrecords) {
mTrackletsPerEvent->Fill(trigger.getNumberOfTracklets());
Expand Down Expand Up @@ -487,8 +494,6 @@ void TrackletsTask::endOfCycle()
for (auto& hist : moHCMCM) {
hist->SetMaximum(max);
}
// reset the TrackletPerTimeCycled
mTrackletsPerTimeFrameCycled->Reset();
}

void TrackletsTask::endOfActivity(const Activity& /*activity*/)
Expand Down Expand Up @@ -519,9 +524,7 @@ void TrackletsTask::reset()
mTrackletHCIDn->Reset();
mTrackletPositionn->Reset();
mTrackletPositionRawn->Reset();
mTrackletsPerEventn->Reset();
mTrackletsPerTimeFrame->Reset();
mTrackletsPerTimeFrameCycled->Reset();
for (auto h : mLayers) {
h->Reset();
}
Expand Down

0 comments on commit 2794846

Please sign in to comment.