2626#include < Framework/InputRecord.h>
2727#include < vector>
2828
29+ #include " FITCommon/HelperHist.h"
30+ #include " FITCommon/HelperCommon.h"
31+ #include " FITCommon/HelperFIT.h"
2932namespace o2 ::quality_control_modules::ft0
3033{
3134
35+ using namespace o2 ::quality_control_modules::fit;
36+
3237RecPointsQcTask::~RecPointsQcTask ()
3338{
3439 delete mListHistGarbage ;
3540}
3641
37- void RecPointsQcTask::rebinFromConfig ()
38- {
39- /* Examples:
40- "binning_SumAmpC": "100, 0, 100"
41- "binning_BcOrbitMap_TrgOrA": "25, 0, 256, 10, 0, 3564"
42- hashtag = all channel IDs (mSetAllowedChIDs), e.g.
43- "binning_Amp_channel#": "5,-10,90"
44- is equivalent to:
45- "binning_Amp_channel0": "5,-10,90"
46- "binning_Amp_channel1": "5,-10,90"
47- "binning_Amp_channel2": "5,-10,90" ...
48- */
49- auto rebinHisto = [](std::string hName, std::string binning) {
50- std::vector<std::string> tokenizedBinning;
51- boost::split (tokenizedBinning, binning, boost::is_any_of (" ," ));
52- if (tokenizedBinning.size () == 3 ) { // TH1
53- ILOG (Debug) << " config: rebinning TH1 " << hName << " -> " << binning << ENDM ;
54- auto htmp = (TH1F *)gROOT ->FindObject (hName.data ());
55- htmp->SetBins (std::atof (tokenizedBinning[0 ].c_str ()), std::atof (tokenizedBinning[1 ].c_str ()), std::atof (tokenizedBinning[2 ].c_str ()));
56- } else if (tokenizedBinning.size () == 6 ) { // TH2
57- auto htmp = (TH2F *)gROOT ->FindObject (hName.data ());
58- ILOG (Debug) << " config: rebinning TH2 " << hName << " -> " << binning << ENDM ;
59- htmp->SetBins (std::atof (tokenizedBinning[0 ].c_str ()), std::atof (tokenizedBinning[1 ].c_str ()), std::atof (tokenizedBinning[2 ].c_str ()),
60- std::atof (tokenizedBinning[3 ].c_str ()), std::atof (tokenizedBinning[4 ].c_str ()), std::atof (tokenizedBinning[5 ].c_str ()));
61- } else {
62- ILOG (Warning) << " config: invalid binning parameter: " << hName << " -> " << binning << ENDM ;
63- }
64- };
65-
66- const std::string rebinKeyword = " binning" ;
67- const char * channelIdPlaceholder = " #" ;
68- try {
69- for (auto & param : mCustomParameters .getAllDefaults ()) {
70- if (param.first .rfind (rebinKeyword, 0 ) != 0 )
71- continue ;
72- std::string hName = param.first .substr (rebinKeyword.length () + 1 );
73- std::string binning = param.second .c_str ();
74- if (hName.find (channelIdPlaceholder) != std::string::npos) {
75- for (const auto & chID : mSetAllowedChIDs ) {
76- std::string hNameCur = hName.substr (0 , hName.find (channelIdPlaceholder)) + std::to_string (chID) + hName.substr (hName.find (channelIdPlaceholder) + 1 );
77- rebinHisto (hNameCur, binning);
78- }
79- } else if (!gROOT ->FindObject (hName.data ())) {
80- ILOG (Warning) << " config: histogram named \" " << hName << " \" not found" << ENDM ;
81- continue ;
82- } else {
83- rebinHisto (hName, binning);
84- }
85- }
86- } catch (std::out_of_range& oor) {
87- ILOG (Error) << " Cannot access the default custom parameters : " << oor.what () << ENDM ;
88- }
89- }
90-
9142void RecPointsQcTask::initialize (o2::framework::InitContext& /* ctx*/ )
9243{
9344 ILOG (Info, Support) << " @@@@initialize RecoQcTask" << ENDM ; // QcInfoLogger is used. FairMQ logs will go to there as well.
94- mStateLastIR2Ch = {};
9545
9646 mHistTime2Ch = std::make_unique<TH2F >(" TimePerChannel" , " Time vs Channel;Channel;Time [ps]" , NCHANNELS , 0 , NCHANNELS , 500 , -2050 , 2050 );
9747 mHistTime2Ch ->SetOption (" colz" );
@@ -109,7 +59,7 @@ void RecPointsQcTask::initialize(o2::framework::InitContext& /*ctx*/)
10959 if (auto param = mCustomParameters .find (" ChannelIDs" ); param != mCustomParameters .end ()) {
11060 const auto chIDs = param->second ;
11161 const std::string del = " ," ;
112- vecChannelIDs = parseParameters<unsigned int >(chIDs, del);
62+ vecChannelIDs = helper:: parseParameters<unsigned int >(chIDs, del);
11363 } else {
11464 for (unsigned int iCh = 0 ; iCh < o2::ft0::Constants::sNCHANNELS_PM ; iCh++)
11565 vecChannelIDs.push_back (iCh);
@@ -126,16 +76,28 @@ void RecPointsQcTask::initialize(o2::framework::InitContext& /*ctx*/)
12676 getObjectsManager ()->startPublishing (mHistResCollTimeA .get ());
12777 getObjectsManager ()->startPublishing (mHistResCollTimeC .get ());
12878
79+ const std::tuple<int , float , float > binsTime{ 500 , -2500 , 2500 };
80+ const std::tuple<int , float , float > binsBC{ 3564 , 0 , 3564 };
81+ mMapTrgBits = HelperTrgFIT::sMapBasicTrgBitsFT0 ;
82+ mTrgPos_minBias = mMapTrgBits .size ();
83+ mMapTrgBits .insert ({ mTrgPos_minBias , " MinBias" });
84+ mTrgPos_allEvents = mMapTrgBits .size ();
85+ mMapTrgBits .insert ({ mTrgPos_allEvents , " AllEvents" });
86+ mHistSumTimeAC_perTrg = helper::registerHist<TH2F >(getObjectsManager (), " COLZ" , " SumTimeAC_perTrg" , " (T0A+T0C)/2 per Trigger;Time [ps]; Trigger" , binsTime, mMapTrgBits );
87+ mHistDiffTimeAC_perTrg = helper::registerHist<TH2F >(getObjectsManager (), " COLZ" , " DiffTimeAC_perTrg" , " (T0C-T0C)/2 per Trigger;Time [ps]; Trigger" , binsTime, mMapTrgBits );
88+ mHistTimeA_perTrg = helper::registerHist<TH2F >(getObjectsManager (), " COLZ" , " TimeA_perTrg" , " T0A per Trigger;Time [ps]; Trigger" , binsTime, mMapTrgBits );
89+ mHistTimeC_perTrg = helper::registerHist<TH2F >(getObjectsManager (), " COLZ" , " TimeC_perTrg" , " T0C per Trigger;Time [ps]; Trigger" , binsTime, mMapTrgBits );
90+ mHistBC_perTriggers = helper::registerHist<TH2F >(getObjectsManager (), " COLZ" , " BC_perTriggers" , " BC per Triggers;BC; Trigger" , binsBC, mMapTrgBits );
91+
12992 for (const auto & chID : mSetAllowedChIDs ) {
130- auto pairHistAmpVsTime = mMapHistAmpVsTime .insert ({ chID, new TH2F (Form (" Amp_vs_time_channel%i" , chID), Form (" Amplitude vs time, channel %i;Amp;Time" , chID), 420 , - 100 , 500 , 410 , -2050 , 2050 ) });
93+ auto pairHistAmpVsTime = mMapHistAmpVsTime .insert ({ chID, new TH2F (Form (" Amp_vs_time_channel%i" , chID), Form (" Amplitude vs time, channel %i;Amp;Time" , chID), 1000 , 0 , 4000 , 100 , -1000 , 1000 ) });
13194 if (pairHistAmpVsTime.second ) {
13295 mListHistGarbage ->Add (pairHistAmpVsTime.first ->second );
13396 getObjectsManager ()->startPublishing (pairHistAmpVsTime.first ->second );
13497 }
13598 }
13699
137100 ILOG (Info, Support) << " @@@ histos created" << ENDM ;
138- rebinFromConfig (); // after all histos are created
139101}
140102
141103void RecPointsQcTask::startOfActivity (const Activity& activity)
@@ -148,31 +110,28 @@ void RecPointsQcTask::startOfActivity(const Activity& activity)
148110 mHistCollTimeC ->Reset ();
149111 mHistResCollTimeA ->Reset ();
150112 mHistResCollTimeC ->Reset ();
113+ mHistSumTimeAC_perTrg ->Reset ();
114+ mHistDiffTimeAC_perTrg ->Reset ();
115+ mHistTimeA_perTrg ->Reset ();
116+ mHistTimeC_perTrg ->Reset ();
117+ mHistBC_perTriggers ->Reset ();
118+
151119 for (auto & entry : mMapHistAmpVsTime ) {
152120 entry.second ->Reset ();
153121 }
154122}
155123
156124void RecPointsQcTask::startOfCycle ()
157125{
158- mTimeMinNS = -1 ;
159- mTimeMaxNS = 0 .;
160- mTimeCurNS = 0 .;
161- mTfCounter = 0 ;
162- mTimeSum = 0 .;
163126}
164127
165128void RecPointsQcTask::monitorData (o2::framework::ProcessingContext& ctx)
166129{
167- double curTfTimeMin = -1 ;
168- double curTfTimeMax = 0 ;
169- mTfCounter ++;
170130 auto chan = ctx.inputs ().get <gsl::span<o2::ft0::ChannelDataFloat>>(" channels" );
171131 auto recpoints = ctx.inputs ().get <gsl::span<o2::ft0::RecPoints>>(" recpoints" );
172- bool isFirst = true ;
173- uint32_t firstOrbit;
174132
175- for (auto & recpoint : recpoints) {
133+ for (const auto & recpoint : recpoints) {
134+ const auto bc = recpoint.getInteractionRecord ().bc ;
176135 int time[o2::ft0::Constants::sNCHANNELS_PM ] = { 0 };
177136 int amp[o2::ft0::Constants::sNCHANNELS_PM ] = { 0 };
178137 o2::ft0::Triggers triggersignals = recpoint.getTrigger ();
@@ -181,12 +140,31 @@ void RecPointsQcTask::monitorData(o2::framework::ProcessingContext& ctx)
181140 mHistCollTimeAC ->Fill (static_cast <Float_t>(recpoint.getCollisionTimeMean ()));
182141 mHistCollTimeA ->Fill (static_cast <Float_t>(recpoint.getCollisionTimeA ()));
183142 mHistCollTimeC ->Fill (static_cast <Float_t>(recpoint.getCollisionTimeC ()));
143+ const bool minBias = triggersignals.getVertex () && (triggersignals.getCen () || triggersignals.getSCen ());
144+ // Preparing trigger word
145+ uint64_t trgWord = triggersignals.getTriggersignals () & 0b11111 ;
146+ trgWord |= (static_cast <int >(minBias) << mTrgPos_minBias );
147+ trgWord |= (1ull << mTrgPos_allEvents );
148+ // Filling hists with trg bits
149+ for (const auto & entry : mMapTrgBits ) {
150+ if ((trgWord & (1ull << entry.first )) > 0 ) {
151+ mHistBC_perTriggers ->Fill (static_cast <double >(bc), static_cast <double >(entry.first ));
152+ const auto timeA = static_cast <double >(recpoint.getCollisionTimeA ());
153+ const auto timeC = static_cast <double >(recpoint.getCollisionTimeC ());
154+ mHistTimeA_perTrg ->Fill (timeA, static_cast <double >(entry.first ));
155+ mHistTimeC_perTrg ->Fill (timeC, static_cast <double >(entry.first ));
156+ mHistDiffTimeAC_perTrg ->Fill (static_cast <double >(recpoint.getVertex ()), static_cast <double >(entry.first ));
157+ if (timeA < o2::ft0::RecPoints::sDummyCollissionTime && timeC < o2::ft0::RecPoints::sDummyCollissionTime ) {
158+ mHistSumTimeAC_perTrg ->Fill (static_cast <double >(recpoint.getCollisionTimeMean ()), static_cast <double >(entry.first ));
159+ }
160+ }
161+ }
184162 for (const auto & chData : channels) {
185163 time[chData.ChId ] = chData.CFDTime ;
186164 amp[chData.ChId ] = chData.QTCAmpl ;
187165 mHistTime2Ch ->Fill (static_cast <Double_t>(chData.ChId ), static_cast <Double_t>(chData.CFDTime ));
188166 mHistAmp2Ch ->Fill (static_cast <Double_t>(chData.ChId ), static_cast <Double_t>(chData.QTCAmpl ));
189- if (mSetAllowedChIDs .find (static_cast <unsigned int >(chData.ChId )) != mSetAllowedChIDs .end ()) {
167+ if (mSetAllowedChIDs .find (static_cast <unsigned int >(chData.ChId )) != mSetAllowedChIDs .end () && minBias ) { // ampt-time dependency is needed only for PbPb runs
190168 mMapHistAmpVsTime [chData.ChId ]->Fill (chData.QTCAmpl , chData.CFDTime );
191169 }
192170 }
@@ -233,7 +211,6 @@ void RecPointsQcTask::monitorData(o2::framework::ProcessingContext& ctx)
233211 }
234212 }
235213 }
236- mTimeSum += curTfTimeMax - curTfTimeMin;
237214}
238215
239216void RecPointsQcTask::endOfCycle ()
@@ -258,6 +235,12 @@ void RecPointsQcTask::reset()
258235 mHistCollTimeC ->Reset ();
259236 mHistResCollTimeA ->Reset ();
260237 mHistResCollTimeC ->Reset ();
238+ mHistSumTimeAC_perTrg ->Reset ();
239+ mHistDiffTimeAC_perTrg ->Reset ();
240+ mHistTimeA_perTrg ->Reset ();
241+ mHistTimeC_perTrg ->Reset ();
242+ mHistBC_perTriggers ->Reset ();
243+
261244 for (auto & entry : mMapHistAmpVsTime ) {
262245 entry.second ->Reset ();
263246 }
0 commit comments