@@ -64,6 +64,7 @@ void ITSMFTDeadMapBuilder::init(InitContext& ic)
6464 mLocalOutputDir = ic.options ().get <std::string>(" output-dir" );
6565 mSkipStaticMap = ic.options ().get <bool >(" skip-static-map" );
6666
67+ isEnded = false ;
6768 mTimeStart = o2::ccdb::getCurrentTimestamp ();
6869
6970 if (mRunMFT ) {
@@ -89,7 +90,7 @@ void ITSMFTDeadMapBuilder::init(InitContext& ic)
8990}
9091
9192// /////////////////////////////////////////////////////////////////
92- // TODO: can ChipMappingITS help here?
93+ // TODO: can ChipMappingITS help here?
9394std::vector<uint16_t > ITSMFTDeadMapBuilder::getChipIDsOnSameCable (uint16_t chip)
9495{
9596 if (mRunMFT || chip < N_CHIPS_ITSIB) {
@@ -178,27 +179,40 @@ void ITSMFTDeadMapBuilder::finalizeOutput()
178179void ITSMFTDeadMapBuilder::run (ProcessingContext& pc)
179180{
180181
182+ // Skip everything in case of garbage (potentially at EoS)
183+ if (pc.services ().get <o2::framework::TimingInfo>().firstTForbit == -1U ) {
184+ LOG (info) << " Skipping the processing of inputs for timeslice " << pc.services ().get <o2::framework::TimingInfo>().timeslice << " (firstTForbit is " << pc.services ().get <o2::framework::TimingInfo>().firstTForbit << " )" ;
185+ return ;
186+ }
187+
181188 std::chrono::time_point<std::chrono::high_resolution_clock> start;
182189 std::chrono::time_point<std::chrono::high_resolution_clock> end;
183190
184191 start = std::chrono::high_resolution_clock::now ();
185192
186- mTFCounter ++;
187-
188- mFirstOrbitTF = pc.services ().get <o2::framework::TimingInfo>().firstTForbit ;
193+ const auto & tinfo = pc.services ().get <o2::framework::TimingInfo>();
189194
190- if (mFirstOrbitRun == 0x0 ) {
195+ if (tinfo.globalRunNumberChanged || mFirstOrbitRun == 0x0 ) { // new run is starting
196+ mRunNumber = tinfo.runNumber ;
191197 mFirstOrbitRun = mFirstOrbitTF ;
198+ mTFCounter = 0 ;
199+ isEnded = false ;
192200 }
193201
202+ if (isEnded) {
203+ return ;
204+ }
205+ mFirstOrbitTF = tinfo.firstTForbit ;
206+ mTFCounter ++;
207+
194208 long sampled_orbit = mFirstOrbitTF - mFirstOrbitRun ;
195209
196210 if (!acceptTF (sampled_orbit)) {
197211 return ;
198212 }
199213
200214 mStepCounter ++;
201- LOG (info) << " Processing step #" << mStepCounter << " out of " << mTFCounter << " TF received. First orbit " << mFirstOrbitTF ;
215+ LOG (info) << " Processing step #" << mStepCounter << " out of " << mTFCounter << " good TF received. First orbit " << mFirstOrbitTF ;
202216
203217 mDeadMapTF .clear ();
204218
@@ -280,6 +294,12 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc)
280294
281295 LOG (info) << " Elapsed time in TF processing: " << difference / 1000 . << " ms" ;
282296
297+ if (pc.transitionState () == TransitionHandlingState::Requested && !isEnded) {
298+ std::string detname = mRunMFT ? " MFT" : " ITS" ;
299+ LOG (warning) << " Transition state requested for " << detname << " process, calling stop() and stopping the process of new data." ;
300+ stop ();
301+ }
302+
283303 return ;
284304}
285305
@@ -291,8 +311,7 @@ void ITSMFTDeadMapBuilder::PrepareOutputCcdb(EndOfStreamContext* ec, std::string
291311
292312 long tend = o2::ccdb::getCurrentTimestamp ();
293313
294- std::map<std::string, std::string> md = {
295- {" map_version" , MAP_VERSION}};
314+ std::map<std::string, std::string> md = {{" map_version" , MAP_VERSION}, {" runNumber" , std::to_string (mRunNumber )}};
296315
297316 std::string path = mRunMFT ? " MFT/Calib/" : " ITS/Calib/" ;
298317 std::string name_str = " TimeDeadMap" ;
@@ -355,6 +374,7 @@ void ITSMFTDeadMapBuilder::endOfStream(EndOfStreamContext& ec)
355374 } else {
356375 LOG (warning) << " Time-dependent dead map is empty and will not be forwarded as output" ;
357376 }
377+ LOG (info) << " Stop process of new data because of endOfStream" ;
358378 isEnded = true ;
359379 }
360380 return ;
@@ -374,6 +394,7 @@ void ITSMFTDeadMapBuilder::stop()
374394 } else {
375395 LOG (alarm) << " endOfStream not processed. Nothing forwarded as output." ;
376396 }
397+ LOG (info) << " Stop process of new data because of stop() call." ;
377398 isEnded = true ;
378399 }
379400 return ;
0 commit comments