@@ -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 ());
@@ -84,7 +84,12 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
8484 mRunNumber = activity.mId ;
8585 mTimestamp = activity.mValidity .getMin ();
8686
87- auto MBclassName = getFromExtendedConfig<string>(activity, mCustomParameters , " MBclassName" , " CMTVX-B-NOPF" );
87+ std::string readCTPConfig = getFromExtendedConfig<string>(activity, mCustomParameters , " readCTPconfigInMonitorData" , " false" );
88+ if (readCTPConfig == " true" ) {
89+ mReadCTPconfigInMonitorData = true ;
90+ }
91+
92+ mMBclassName = getFromExtendedConfig<string>(activity, mCustomParameters , " MBclassName" , " CMTVX-B-NOPF" );
8893
8994 std::string run = std::to_string (mRunNumber );
9095 std::string ccdbName = mCustomParameters [" ccdbName" ];
@@ -93,40 +98,42 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
9398 }
9499 // / the ccdb reading to be futher discussed
95100 // 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 ;
101+ if (! mReadCTPconfigInMonitorData ) {
102+ bool ok ;
103+ auto & mgr = o2::ccdb::BasicCCDBManager::instance ();
104+ mgr.setURL (ccdbName);
105+ map<string, string> metadata; // can be empty
106+ metadata[" runNumber" ] = run;
107+ auto ctpconfigdb = mgr.getSpecific <o2::ctp::CTPConfiguration>(o2::ctp::CCDBPathCTPConfig, mTimestamp , metadata);
108+ if (ctpconfigdb == nullptr ) {
109+ LOG (info) << " CTP config not in database, timestamp:" << mTimestamp ;
110+ ok = 0 ;
111+ } else {
112+ LOG (info) << " CTP config found. Run: " << run ;
113+ ok = 1 ;
114+ }
115+ if (ok) {
116+ // get the index of the MB reference class
117+ ILOG (Info, Support) << " CTP config found, run: " << run << ENDM;
118+ std::vector<o2::ctp::CTPClass> ctpcls = ctpconfigdb-> getCTPClasses () ;
119+ for ( size_t i = 0 ; i < ctpcls. size (); i++) {
120+ classNames[i] = ctpcls[i]. name . c_str ();
121+ if ( ctpcls[i].name .find ( mMBclassName ) != std::string::npos) {
122+ mIndexMBclass = ctpcls[i].getIndex () + 1 ;
123+ break ;
124+ }
120125 }
126+ mDecoder .setCTPConfig (*ctpconfigdb);
127+ } else {
128+ ILOG (Warning, Support) << " CTP config not found, run:" << run << ENDM;
121129 }
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 ;
130+ if (mIndexMBclass == -1 ) {
131+ mMBclassName = " CMBV0 (default)" ;
132+ mIndexMBclass = 1 ;
133+ }
134+ mHistoClassRatios ->SetTitle (Form (" Class Ratio to %s" , mMBclassName .c_str ()));
129135 }
136+
130137 std::string nameInput1 = getFromExtendedConfig<string>(activity, mCustomParameters , " MB1inputName" , " MTVX" );
131138 std::string nameInput2 = getFromExtendedConfig<string>(activity, mCustomParameters , " MB2inputName" , " MT0A" );
132139
@@ -201,7 +208,6 @@ void CTPRawDataReaderTask::startOfActivity(const Activity& activity)
201208 titleX2 += Form (" - %d" , mShiftInput2 );
202209 }
203210 mHistoBCMinBias2 ->SetTitle (Form (" %s; %s; %s" , title2.Data (), titleX2.Data (), titley2.Data ()));
204- mHistoClassRatios ->SetTitle (Form (" Class Ratio to %s" , MBclassName.c_str ()));
205211 mHistoInputRatios ->SetTitle (Form (" Input Ratio to %s" , nameInput1.c_str ()));
206212
207213 std::string performConsistencyCheck = getFromExtendedConfig<string>(activity, mCustomParameters , " consistencyCheck" , " true" );
@@ -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