@@ -51,7 +51,7 @@ void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/)
5151 mHistoBCMinBias2 = std::make_unique<TH1D>(" bcMinBias2" , " BC position MB2" , norbits, 0 , norbits);
5252 mHistoInputRatios = std::make_unique<TH1DRatio>(" inputRatio" , " Input Ratio to MTVX; Input; Ratio;" , ninps, 0 , ninps, true );
5353 mHistoClassRatios = std::make_unique<TH1DRatio>(" classRatio" , " Class Ratio to MB; Class; Ratio" , nclasses, 0 , nclasses, true );
54- mHistoDecodeError = std::make_unique<TH1D>(" decodeError" , " Errors from decoder" , 10 , 1 , 11 );
54+ mHistoDecodeError = std::make_unique<TH1D>(" decodeError" , " Errors from decoder" , nclasses, 0 , nclasses );
5555 getObjectsManager ()->startPublishing (mHistoInputs .get ());
5656 getObjectsManager ()->startPublishing (mHistoClasses .get ());
5757 getObjectsManager ()->startPublishing (mHistoClassRatios .get ());
@@ -61,7 +61,6 @@ void CTPRawDataReaderTask::initialize(o2::framework::InitContext& /*ctx*/)
6161 getObjectsManager ()->startPublishing (mHistoDecodeError .get ());
6262
6363 mDecoder .setDoLumi (1 );
64- mDecoder .setDecodeInps (1 );
6564 mDecoder .setDoDigits (1 );
6665 for (size_t i = 0 ; i < nclasses; i++) {
6766 classNames[i] = " " ;
@@ -84,7 +83,12 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
8483 mRunNumber = activity.mId ;
8584 mTimestamp = activity.mValidity .getMin ();
8685
87- auto MBclassName = getFromExtendedConfig<string>(activity, mCustomParameters , " MBclassName" , " CMTVX-B-NOPF" );
86+ std::string readCTPConfig = getFromExtendedConfig<string>(activity, mCustomParameters , " readCTPconfigInMonitorData" , " false" );
87+ if (readCTPConfig == " true" ) {
88+ mReadCTPconfigInMonitorData = true ;
89+ }
90+
91+ mMBclassName = getFromExtendedConfig<string>(activity, mCustomParameters , " MBclassName" , " CMTVX-B-NOPF" );
8892
8993 std::string run = std::to_string (mRunNumber );
9094 std::string ccdbName = mCustomParameters [" ccdbName" ];
@@ -93,40 +97,42 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
9397 }
9498 // / the ccdb reading to be futher discussed
9599 // o2::ctp::CTPRunManager::setCCDBHost(ccdbName);
96- bool ok;
97- // o2::ctp::CTPConfiguration CTPconfig = o2::ctp::CTPRunManager::getConfigFromCCDB(mTimestamp, run, ok) ;
98- auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
99- mgr.setURL (ccdbName);
100- map<string, string> metadata; // can be empty
101- metadata[" runNumber" ] = run;
102- auto ctpconfigdb = mgr.getSpecific <o2::ctp::CTPConfiguration>(o2::ctp::CCDBPathCTPConfig, mTimestamp , metadata);
103- if (ctpconfigdb == nullptr ) {
104- LOG (info) << " CTP config not in database, timestamp:" << mTimestamp ;
105- ok = 0 ;
106- } else {
107- // ctpconfigdb->printStream(std::cout) ;
108- LOG (info) << " CTP config found. Run: " << run ;
109- ok = 1 ;
110- }
111- if (ok) {
112- // get the index of the MB reference class
113- ILOG (Info, Support) << " CTP config found, run: " << run << ENDM ;
114- std::vector<o2::ctp::CTPClass> ctpcls = ctpconfigdb-> getCTPClasses ();
115- for ( size_t i = 0 ; i < ctpcls. size (); i++) {
116- classNames[i] = ctpcls[i].name .c_str ();
117- if ( ctpcls[i].name . find (MBclassName) != std::string::npos) {
118- mIndexMBclass = ctpcls[i]. getIndex () + 1 ;
119- break ;
100+ if (! mReadCTPconfigInMonitorData ) {
101+ bool ok ;
102+ auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
103+ mgr.setURL (ccdbName);
104+ map<string, string> metadata; // can be empty
105+ metadata[" runNumber" ] = run;
106+ auto ctpconfigdb = mgr.getSpecific <o2::ctp::CTPConfiguration>(o2::ctp::CCDBPathCTPConfig, mTimestamp , metadata);
107+ if (ctpconfigdb == nullptr ) {
108+ LOG (info) << " CTP config not in database, timestamp:" << mTimestamp ;
109+ ok = 0 ;
110+ } else {
111+ LOG (info) << " CTP config found. Run: " << run ;
112+ ok = 1 ;
113+ }
114+ if (ok) {
115+ // get the index of the MB reference class
116+ ILOG (Info, Support) << " CTP config found, run: " << run << ENDM;
117+ std::vector<o2::ctp::CTPClass> ctpcls = ctpconfigdb-> getCTPClasses () ;
118+ for ( size_t i = 0 ; i < ctpcls. size (); i++) {
119+ classNames[i] = ctpcls[i]. name . c_str ();
120+ if ( ctpcls[i].name .find ( mMBclassName ) != std::string::npos) {
121+ mIndexMBclass = ctpcls[i].getIndex () + 1 ;
122+ break ;
123+ }
120124 }
125+ mDecoder .setCTPConfig (*ctpconfigdb);
126+ } else {
127+ ILOG (Warning, Support) << " CTP config not found, run:" << run << ENDM;
121128 }
122- mDecoder .setCTPConfig (*ctpconfigdb);
123- } else {
124- ILOG (Warning, Support) << " CTP config not found, run:" << run << ENDM;
125- }
126- if (mIndexMBclass == -1 ) {
127- MBclassName = " CMBV0 (default)" ;
128- mIndexMBclass = 1 ;
129+ if (mIndexMBclass == -1 ) {
130+ mMBclassName = " CMBV0 (default)" ;
131+ mIndexMBclass = 1 ;
132+ }
133+ mHistoClassRatios ->SetTitle (Form (" Class Ratio to %s" , mMBclassName .c_str ()));
129134 }
135+
130136 std::string nameInput1 = getFromExtendedConfig<string>(activity, mCustomParameters , " MB1inputName" , " MTVX" );
131137 std::string nameInput2 = getFromExtendedConfig<string>(activity, mCustomParameters , " MB2inputName" , " MT0A" );
132138
@@ -201,12 +207,12 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
201207 titleX2 += Form (" - %d" , mShiftInput2 );
202208 }
203209 mHistoBCMinBias2 ->SetTitle (Form (" %s; %s; %s" , title2.Data (), titleX2.Data (), titley2.Data ()));
204- mHistoClassRatios ->SetTitle (Form (" Class Ratio to %s" , MBclassName.c_str ()));
205210 mHistoInputRatios ->SetTitle (Form (" Input Ratio to %s" , nameInput1.c_str ()));
206211
207212 std::string performConsistencyCheck = getFromExtendedConfig<string>(activity, mCustomParameters , " consistencyCheck" , " true" );
208213 if (performConsistencyCheck == " true" ) {
209214 mDecoder .setCheckConsistency (1 );
215+ mDecoder .setDecodeInps (1 );
210216 } else {
211217 mDecoder .setCheckConsistency (0 );
212218 }
@@ -226,10 +232,47 @@ void CTPRawDataReaderTask::monitorData(o2::framework::ProcessingContext& ctx)
226232 std::vector<o2::ctp::LumiInfo> lumiPointsHBF1;
227233 std::vector<o2::ctp::CTPDigit> outputDigits;
228234
235+ if (mReadCTPconfigInMonitorData ) {
236+ if (mCTPconfig == nullptr ) {
237+ mCTPconfig = ctx.inputs ().get <o2::ctp::CTPConfiguration*>(" ctp-config" ).get ();
238+ // mCTPconfig = ctpConfigPtr.get();
239+ if (mCTPconfig != nullptr ) {
240+ ILOG (Info, Support) << " CTP config found" << ENDM;
241+ std::vector<o2::ctp::CTPClass> ctpcls = mCTPconfig ->getCTPClasses ();
242+ for (size_t i = 0 ; i < ctpcls.size (); i++) {
243+ classNames[i] = ctpcls[i].name .c_str ();
244+ if (ctpcls[i].name .find (mMBclassName ) != std::string::npos) {
245+ mIndexMBclass = ctpcls[i].getIndex () + 1 ;
246+ break ;
247+ }
248+ }
249+ mDecoder .setCTPConfig (*mCTPconfig );
250+ }
251+ }
252+ for (int i = 0 ; i < nclasses; i++) {
253+ if (classNames[i] == " " ) {
254+ mHistoClasses .get ()->GetXaxis ()->SetBinLabel (i + 1 , Form (" %i" , i + 1 ));
255+ mHistoClassRatios .get ()->GetXaxis ()->SetBinLabel (i + 1 , Form (" %i" , i + 1 ));
256+ } else {
257+ mHistoClasses .get ()->GetXaxis ()->SetBinLabel (i + 1 , Form (" %s" , classNames[i].c_str ()));
258+ mHistoClassRatios .get ()->GetXaxis ()->SetBinLabel (i + 1 , Form (" %s" , classNames[i].c_str ()));
259+ }
260+ }
261+
262+ if (mIndexMBclass == -1 ) {
263+ mMBclassName = " CMBV0 (default)" ;
264+ mIndexMBclass = 1 ;
265+ }
266+ mHistoClassRatios ->SetTitle (Form (" Class Ratio to %s" , mMBclassName .c_str ()));
267+ }
268+
229269 o2::framework::InputRecord& inputs = ctx.inputs ();
230270 int ret = mDecoder .decodeRaw (inputs, filter, outputDigits, lumiPointsHBF1);
231- if (ret > 0 ) {
232- mHistoDecodeError ->Fill (log2 (ret) + 1.5 );
271+ mClassErrorsA = mDecoder .getClassErrorsA ();
272+ for (size_t i = 0 ; i < o2::ctp::CTP_NCLASSES; i++) {
273+ if (mClassErrorsA [i] > 0 ) {
274+ mHistoDecodeError ->Fill (i, mClassErrorsA [i]);
275+ }
233276 }
234277
235278 // reading the ctp inputs and ctp classes
0 commit comments