@@ -46,22 +46,29 @@ void ITSMFTDeadMapBuilder::init(InitContext& ic)
4646
4747 LOG (info) << " ITSMFTDeadMapBuilder init... " << mSelfName ;
4848
49+ mTFSampling = ic.options ().get <int >(" tf-sampling" );
50+ mTFLength = ic.options ().get <int >(" tf-length" );
51+ mDoLocalOutput = ic.options ().get <bool >(" local-output" );
52+ mObjectName = ic.options ().get <std::string>(" outfile" );
53+ mLocalOutputDir = ic.options ().get <std::string>(" output-dir" );
54+ mSkipStaticMap = ic.options ().get <bool >(" skip-static-map" );
55+
56+ mTimeStart = o2::ccdb::getCurrentTimestamp ();
57+
4958 if (mRunMFT ) {
5059 N_CHIPS = o2::itsmft::ChipMappingMFT::getNChips ();
5160 } else {
5261 N_CHIPS = o2::itsmft::ChipMappingITS::getNChips ();
5362 }
5463
5564 mDeadMapTF .clear ();
56-
65+ mStaticChipStatus . clear ();
5766 mMapObject .clear ();
5867 mMapObject .setMapVersion (MAP_VERSION);
5968
60- mTFSampling = ic.options ().get <int >(" tf-sampling" );
61- mTFLength = ic.options ().get <int >(" tf-length" );
62- mDoLocalOutput = ic.options ().get <bool >(" local-output" );
63- mObjectName = ic.options ().get <std::string>(" outfile" );
64- mLocalOutputDir = ic.options ().get <std::string>(" output-dir" );
69+ if (!mSkipStaticMap ) {
70+ mStaticChipStatus .resize (N_CHIPS, false );
71+ }
6572
6673 LOG (info) << " Sampling one TF every " << mTFSampling ;
6774
@@ -87,6 +94,30 @@ std::vector<uint16_t> ITSMFTDeadMapBuilder::getChipIDsOnSameCable(uint16_t chip)
8794void ITSMFTDeadMapBuilder::finalizeOutput ()
8895{
8996
97+ if (!mSkipStaticMap ) {
98+ std::vector<uint16_t > staticmap{};
99+ int staticmap_chipcounter = 0 ;
100+ for (uint16_t el = 0 ; el < mStaticChipStatus .size (); el++) {
101+ if (mStaticChipStatus [el]) {
102+ continue ;
103+ }
104+ staticmap_chipcounter++;
105+ bool previous_dead = (el > 0 && !mStaticChipStatus [el - 1 ]);
106+ bool next_dead = (el < mStaticChipStatus .size () - 1 && !mStaticChipStatus [el + 1 ]);
107+ if (!previous_dead && next_dead) {
108+ staticmap.push_back (el | (uint16_t )(0x8000 ));
109+ } else if (previous_dead && next_dead) {
110+ continue ;
111+ } else {
112+ staticmap.push_back (el);
113+ }
114+ }
115+
116+ LOG (info) << " Filling static part of the map with " << staticmap_chipcounter << " dead chips, saved into " << staticmap.size () << " words" ;
117+
118+ mMapObject .fillMap (staticmap);
119+ }
120+
90121 if (mDoLocalOutput ) {
91122 std::string localoutfilename = mLocalOutputDir + " /" + mObjectName ;
92123 TFile outfile (localoutfilename.c_str (), " RECREATE" );
@@ -151,6 +182,14 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc)
151182 }
152183 }
153184
185+ // do AND operation before unmasking the full ITS lane
186+
187+ if (!mSkipStaticMap ) {
188+ for (size_t el = 0 ; el < mStaticChipStatus .size (); el++) {
189+ mStaticChipStatus [el] = mStaticChipStatus [el] || ChipStatus[el];
190+ }
191+ }
192+
154193 // for ITS, declaring dead only chips belonging to lane with no hits
155194 if (!mRunMFT ) {
156195 for (uint16_t el = N_CHIPS_ITSIB; el < ChipStatus.size (); el++) {
@@ -199,17 +238,15 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc)
199238void ITSMFTDeadMapBuilder::PrepareOutputCcdb (DataAllocator& output)
200239{
201240
202- long tstart = o2::ccdb::getCurrentTimestamp ();
203- long secinyear = 365L * 24 * 3600 ;
204- long tend = o2::ccdb::getFutureTimestamp (secinyear);
241+ long tend = o2::ccdb::getCurrentTimestamp ();
205242
206243 std::map<std::string, std::string> md = {
207244 {" map_version" , MAP_VERSION}};
208245
209246 std::string path = mRunMFT ? " MFT/Calib/" : " ITS/Calib/" ;
210247 std::string name_str = " TimeDeadMap" ;
211248
212- o2::ccdb::CcdbObjectInfo info ((path + name_str), name_str, mObjectName , md, tstart , tend);
249+ o2::ccdb::CcdbObjectInfo info ((path + name_str), name_str, mObjectName , md, mTimeStart - 120 * 1000 , tend + 60 * 1000 );
213250
214251 auto image = o2::ccdb::CcdbApi::createObjectImage (&mMapObject , &info);
215252 info.setFileName (mObjectName );
@@ -239,7 +276,11 @@ void ITSMFTDeadMapBuilder::endOfStream(EndOfStreamContext& ec)
239276 if (!isEnded && !mRunStopRequested ) {
240277 LOG (info) << " endOfStream report:" << mSelfName ;
241278 finalizeOutput ();
242- PrepareOutputCcdb (ec.outputs ());
279+ if (mMapObject .getEvolvingMapSize () > 0 ) {
280+ PrepareOutputCcdb (ec.outputs ());
281+ } else {
282+ LOG (warning) << " Time-dependent dead map is empty and will not be forwarded as output" ;
283+ }
243284 isEnded = true ;
244285 }
245286 return ;
@@ -300,6 +341,7 @@ DataProcessorSpec getITSMFTDeadMapBuilderSpec(std::string datasource, bool doMFT
300341 AlgorithmSpec{adaptFromTask<ITSMFTDeadMapBuilder>(datasource, doMFT)},
301342 Options{{" tf-sampling" , VariantType::Int, 1000 , {" Process every Nth TF. Selection according to first TF orbit." }},
302343 {" tf-length" , VariantType::Int, 32 , {" Orbits per TF." }},
344+ {" skip-static-map" , VariantType::Bool, false , {" Do not fill static part of the map." }},
303345 {" outfile" , VariantType::String, objectname_default, {" ROOT object file name." }},
304346 {" local-output" , VariantType::Bool, false , {" Save ROOT tree file locally." }},
305347 {" output-dir" , VariantType::String, " ./" , {" ROOT tree local output directory." }}}};
0 commit comments