Skip to content

Commit f642cda

Browse files
authored
ITS MFT deadmaps using std::map objects instrad of TTree (#12471)
* ITS and MFT dead damp builder workflow * removing trailing spaces * removing unused struct * fixing format * optimization * ITSMFT dead maps using map objects * Update DeadMapBuilderSpec.h --------- Co-authored-by: Nicolo Valle <nicolo.valle@cern.ch>
1 parent 169a0ab commit f642cda

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

DataFormats/Detectors/ITSMFT/common/src/ITSMFTDataFormatsLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#pragma link C++ class o2::itsmft::CTF + ;
5050
#pragma link C++ class o2::ctf::EncodedBlocks < o2::itsmft::CTFHeader, 10, uint32_t> + ;
5151

52+
#pragma link C++ class std::map < unsigned long, std::vector < uint16_t>> + ;
53+
5254
#pragma link C++ function o2::itsmft::getROFData(const gsl::span <const o2::itsmft::Digit> tfdata) const;
5355
#pragma link C++ function o2::itsmft::getROFData(const gsl::span <const o2::itsmft::Cluster> tfdata) const;
5456
#pragma link C++ function o2::itsmft::getROFData(const gsl::span <const o2::itsmft::CompCluster> tfdata) const;

Detectors/ITSMFT/common/reconstruction/src/ITSMFTReconstructionLinkDef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#pragma link C++ class o2::itsmft::ChipStat + ;
4949
#pragma link C++ class std::map < unsigned long, std::pair < o2::itsmft::ClusterTopology, unsigned long>> + ;
5050

51+
#pragma link C++ class std::map < unsigned long, std::vector < uint16_t>> + ;
52+
5153
#pragma link C++ class o2::itsmft::ClustererParam < o2::detectors::DetID::ITS> + ;
5254
#pragma link C++ class o2::itsmft::ClustererParam < o2::detectors::DetID::MFT> + ;
5355
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::itsmft::ClustererParam < o2::detectors::DetID::ITS>> + ;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include <ITSMFTReconstruction/RawPixelDecoder.h> //o2::itsmft::RawPixelDecoder
4545
#include "DetectorsCalibration/Utils.h"
4646
#include "DetectorsCommonDataFormats/FileMetaData.h"
47-
#include "DetectorsBase/GRPGeomHelper.h" //nicolo
47+
#include "DetectorsBase/GRPGeomHelper.h"
4848
#include "CCDB/CcdbApi.h"
4949
#include "CommonUtils/MemFileHelper.h"
5050

@@ -91,17 +91,17 @@ class ITSMFTDeadMapBuilder : public Task
9191
std::string mObjectName;
9292
std::string mLocalOutputDir;
9393

94-
std::string MAP_VERSION = "1"; // to change in case the encoding or the format change
94+
std::string MAP_VERSION = "2"; // to change in case the encoding or the format change
9595

96-
std::vector<uint16_t>* mDeadMapTF = nullptr;
96+
std::vector<uint16_t> mDeadMapTF{};
9797

98-
Long64_t mFirstOrbitTF = 0x0;
98+
unsigned long mFirstOrbitTF = 0x0;
9999

100100
std::string mDataSource = "chipsstatus";
101101

102102
int mTFSampling = 1000;
103103

104-
TTree* mTreeObject = nullptr;
104+
std::map<unsigned long, std::vector<uint16_t>> mMapObject{};
105105

106106
void finalizeOutput();
107107
void PrepareOutputCcdb(DataAllocator& output);

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

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ ITSMFTDeadMapBuilder::ITSMFTDeadMapBuilder(std::string datasource, bool doMFT)
3636
ITSMFTDeadMapBuilder::~ITSMFTDeadMapBuilder()
3737
{
3838
// Clear dynamic memory
39-
delete mDeadMapTF;
40-
delete mTreeObject;
39+
return;
4140
}
4241

4342
//////////////////////////////////////////////////////////////////////////////
@@ -52,11 +51,9 @@ void ITSMFTDeadMapBuilder::init(InitContext& ic)
5251
N_CHIPS = o2::itsmft::ChipMappingITS::getNChips();
5352
}
5453

55-
mDeadMapTF = new std::vector<uint16_t>{};
54+
mDeadMapTF.clear();
5655

57-
mTreeObject = new TTree("ccdb_object", "ccdb_object");
58-
mTreeObject->Branch("orbit", &mFirstOrbitTF);
59-
mTreeObject->Branch("deadmap", &mDeadMapTF);
56+
mMapObject.clear();
6057

6158
mTFSampling = ic.options().get<int>("tf-sampling");
6259
mTFLength = ic.options().get<int>("tf-length");
@@ -95,13 +92,11 @@ void ITSMFTDeadMapBuilder::finalizeOutput()
9592
if (mDoLocalOutput) {
9693
std::string localoutfilename = mLocalOutputDir + "/" + mObjectName;
9794
TFile outfile(localoutfilename.c_str(), "RECREATE");
98-
outfile.cd();
99-
mTreeObject->Write();
95+
outfile.WriteObjectAny(&mMapObject, "std::map<unsigned long, std::vector<uint16_t>>", "ccdb_object");
10096
outfile.Close();
10197
}
10298
return;
103-
104-
} // finalizeOutput
99+
}
105100

106101
//////////////////////////////////////////////////////////////////////////////
107102
// Main running function
@@ -120,14 +115,14 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc)
120115

121116
mFirstOrbitTF = pc.services().get<o2::framework::TimingInfo>().firstTForbit;
122117

123-
if ((Long64_t)(mFirstOrbitTF / mTFLength) % mTFSampling != 0) {
118+
if ((unsigned long)(mFirstOrbitTF / mTFLength) % mTFSampling != 0) {
124119
return;
125120
}
126121

127122
mStepCounter++;
128123
LOG(info) << "Processing step #" << mStepCounter << " out of " << mTFCounter << " TF received. First orbit " << mFirstOrbitTF;
129124

130-
mDeadMapTF->clear();
125+
mDeadMapTF.clear();
131126

132127
std::vector<bool> ElementsStatus(getElementIDFromChip(N_CHIPS), false);
133128

@@ -170,18 +165,18 @@ void ITSMFTDeadMapBuilder::run(ProcessingContext& pc)
170165
bool previous_dead = (el > 0 && !ElementsStatus.at(el - 1));
171166
bool next_dead = (el < ElementsStatus.size() - 1 && !ElementsStatus.at(el + 1));
172167
if (!previous_dead && next_dead) {
173-
mDeadMapTF->push_back(el | (uint16_t)(0x8000));
168+
mDeadMapTF.push_back(el | (uint16_t)(0x8000));
174169
} else if (previous_dead && next_dead) {
175170
continue;
176171
} else {
177-
mDeadMapTF->push_back(el);
172+
mDeadMapTF.push_back(el);
178173
}
179174
}
180175

181-
LOG(info) << "TF contains " << CountDead << " dead elements, saved into " << mDeadMapTF->size() << " words.";
176+
LOG(info) << "TF contains " << CountDead << " dead elements, saved into " << mDeadMapTF.size() << " words.";
182177

183-
// filling the tree
184-
mTreeObject->Fill();
178+
// filling the map
179+
mMapObject[mFirstOrbitTF] = mDeadMapTF;
185180

186181
end = std::chrono::high_resolution_clock::now();
187182
int difference = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
@@ -207,7 +202,8 @@ void ITSMFTDeadMapBuilder::PrepareOutputCcdb(DataAllocator& output)
207202

208203
o2::ccdb::CcdbObjectInfo info((path + name_str), "time_dead_map", mObjectName, md, tstart, tend);
209204

210-
auto image = o2::ccdb::CcdbApi::createObjectImage(mTreeObject, &info);
205+
auto image = o2::ccdb::CcdbApi::createObjectImage(&mMapObject, &info);
206+
info.setFileName(mObjectName);
211207

212208
info.setAdjustableEOV();
213209

@@ -241,7 +237,7 @@ void ITSMFTDeadMapBuilder::endOfStream(EndOfStreamContext& ec)
241237
}
242238

243239
//////////////////////////////////////////////////////////////////////////////
244-
// DDS stop method: simply close the latest tree
240+
// DDS stop method: create local output if endOfStream not processed
245241
void ITSMFTDeadMapBuilder::stop()
246242
{
247243
if (!isEnded) {

0 commit comments

Comments
 (0)