Skip to content

Commit fc78c97

Browse files
nicolovallenoferini
authored andcommitted
ITS MFT Time-evolving dead maps (#12644)
* ITS - Adding static part to time dead maps * do not forward empty objects * object validity * cleaning --------- Co-authored-by: Nicolo Valle <nicolo.valle@cern.ch>
1 parent 7057c18 commit fc78c97

3 files changed

Lines changed: 60 additions & 13 deletions

File tree

DataFormats/Detectors/ITSMFT/common/include/DataFormatsITSMFT/TimeDeadMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class TimeDeadMap
5858

5959
void decodeMap(o2::itsmft::NoiseMap& noisemap)
6060
{ // for static part only
61-
if (mMAP_VERSION != "3") {
61+
if (mMAP_VERSION == "3") {
6262
LOG(error) << "Trying to decode static part of deadmap version " << mMAP_VERSION << ". Not implemented, doing nothing.";
6363
return;
6464
}

Detectors/ITSMFT/common/workflow/include/ITSMFTWorkflow/DeadMapBuilderSpec.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,22 @@ class ITSMFTDeadMapBuilder : public Task
8282

8383
bool mRunMFT = false;
8484
bool mDoLocalOutput = false;
85+
bool mSkipStaticMap = false;
8586
uint16_t N_CHIPS;
8687
uint16_t N_CHIPS_ITSIB = o2::itsmft::ChipMappingITS::getNChips(0);
8788
int mTFLength = 32; // TODO find utility for proper value -- o2::base::GRPGeomHelper::getNHBFPerTF() returns 128 see https://github.com/AliceO2Group/AliceO2/blob/051b56f9f136e7977e83f5d26d922db9bd6ecef5/Detectors/Base/src/GRPGeomHelper.cxx#L233 and correct also default option is getSpec
8889

8990
uint mStepCounter = 0;
9091
uint mTFCounter = 0;
9192

93+
long mTimeStart = -1; // TODO: better to use RCT info?
94+
9295
std::string mObjectName;
9396
std::string mLocalOutputDir;
9497

95-
std::string MAP_VERSION = "3"; // to change in case the encoding or the format change
98+
std::string MAP_VERSION = "4"; // to change in case the encoding or the format change
99+
100+
std::vector<bool> mStaticChipStatus{};
96101

97102
std::vector<uint16_t> mDeadMapTF{};
98103

Detectors/ITSMFT/common/workflow/src/DeadMapBuilderSpec.cxx

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
8794
void 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)
199238
void 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

Comments
 (0)