ATLAS Offline Software
D3PDConverter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "LArCafJobs/DataStore.h"
8 #include "LArCafJobs/RunData.h"
9 #include "LArCafJobs/EventData.h"
12 #include "LArCafJobs/CellInfo.h"
15 
17 
18 #include <iostream>
19 using std::cout;
20 using std::endl;
21 
22 using namespace LArSamples;
23 
25 {
26  DataStore* samples = new DataStore();
27  RunData* runData = nullptr;
28 
29  cout << "Processing " << fChain->GetEntries() << " entries" << endl;
30  for (long long i = 0; i < fChain->GetEntries(); i++) {
31  if (i % 500 == 0) cout << "Processing Entry " << i << endl;
32  fChain->GetEntry(i);
33  if (!runData || runData->run() != (int)RunNumber) {
34  // new run
35  runData = new RunData(RunNumber);
36  samples->addRun(runData);
37  }
38 
39  EventData* eventData = new EventData(EventNumber, 0, lbn, bcid);
40  eventData->setRunData(runData);
41  unsigned int eventIndex = samples->addEvent(eventData);
42 
43 
44  for (int j = 0; j < cc_sel_n; j++) {
45  // skip Tile cells
46  if ((*cc_sel_DetCells)[j] & 8) continue;
47  unsigned int hash = m_id2hash[(*cc_sel_IdCells)[j]];
48  if (hash == 0) {
49  cout << "ERROR: skipping cell with offline ID = " << (*cc_sel_IdCells)[j] << endl;
50  continue;
51  }
52 
53  // find digit
54  int digitIndex = -1;
55  for (int k = 0; k < lardigit_n; k++) {
56  if ((*lardigit_offlineId)[k] == (*cc_sel_IdCells)[j]) {
57  digitIndex = k;
58  break;
59  }
60  }
61  //if (digitIndex >= 0) cout << "digitIndex = " << digitIndex << endl;
62  hash -= 1;
63  HistoryContainer* histCont = samples->hist_cont(hash);
64  CellInfo* info = nullptr;
65  if (!histCont) {
66  const CellInfo* templateInfo = m_template->cellInfo(hash);
67  info = new CellInfo(templateInfo->calo(), templateInfo->layer(),
68  templateInfo->iEta(), templateInfo->iPhi(),
69  templateInfo->feedThrough(), templateInfo->slot(), templateInfo->channel(),
70  nullptr,nullptr,nullptr, templateInfo->position(), templateInfo->onlid());
71  histCont = samples->makeNewHistory(IdentifierHash(hash), info);
72  }
73  else
74  info = histCont->cell_info();
75 
77  std::vector<short> samples;
78  if (digitIndex >= 0) {
79  gain = (CaloGain::CaloGain)(*lardigit_gain)[digitIndex];
80  std::vector<int> intSamples = (*lardigit_Samples)[digitIndex];
81  for (int s : intSamples) {
82  samples.push_back((short)s);
83  }
84  }
86  new DataContainer(gain, samples, (*cc_sel_E)[j], (*cc_sel_TimeCells)[j],
88  std::vector<float>(), (*cc_sel_Sigma)[j],
89  -1, -1, (*cc_sel_BadCells)[j]);
90  histCont->add(data);
91  }
92  }
93  samples->writeTrees(outputFileName);
94  delete samples;
95  return true;
96 }
97 
98 
99 bool D3PDConverter::initMapping(const TString& templateFile, const TString& translatorFile)
100 {
101  LArIdTranslatorHelper* translator = new LArIdTranslatorHelper(translatorFile);
102  m_template = Interface::open(templateFile);
103 
104  cout << "Making online->hash map" << endl;
105  std::map<unsigned long long, unsigned int> on2hash;
106  for (unsigned int i = 0; i < m_template->nChannels(); i++) {
107  const CellInfo* info = m_template->cellInfo(i);
108  if (!info) continue;
109  on2hash[info->onlid()] = i;
110  }
111 
112  cout << "Making offlineID->hash map" << endl;
113  for (unsigned int i = 0; i < translator->Tree()->GetEntries(); i++) {
114  translator->Tree()->GetEntry(i);
115  m_id2hash[translator->offlid] = on2hash[translator->onlid] + 1;
116  }
117  // delete translator; // crashes
118  return true;
119 }
120 
121 
122 
grepfile.info
info
Definition: grepfile.py:38
RunData.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
LArSamples::CellInfo::slot
short slot() const
Definition: CellInfo.h:68
LArSamples::CellInfo::calo
CaloId calo() const
Definition: CellInfo.h:50
LArSamples::EventData::setRunData
void setRunData(const RunData *runData)
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:75
LArSamples::D3PDConverter::initMapping
bool initMapping(const TString &templateFile, const TString &translatorFile)
Definition: D3PDConverter.cxx:99
CaloD3PDClass::EventNumber
UInt_t EventNumber
Definition: CaloD3PDClass.h:35
CaloD3PDClass::RunNumber
UInt_t RunNumber
current Tree number in a TChain
Definition: CaloD3PDClass.h:34
CaloGain::UNKNOWNGAIN
@ UNKNOWNGAIN
Definition: CaloGain.h:20
DataStore.h
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
CaloD3PDClass::fChain
TTree * fChain
Definition: CaloD3PDClass.h:30
LArSamples::CellInfo::feedThrough
short feedThrough() const
Definition: CellInfo.h:65
CaloD3PDClass::lardigit_offlineId
vector< unsigned int > * lardigit_offlineId
Definition: CaloD3PDClass.h:220
LArSamples::DataStore::addEvent
unsigned int addEvent(EventData *eventData)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:55
LArSamples::AbsLArCells::cellInfo
virtual const CellInfo * cellInfo(unsigned int i) const
Definition: AbsLArCells.cxx:71
LArIdTranslatorHelper::offlid
ULong64_t offlid
Definition: LArIdTranslatorHelper.h:39
CaloD3PDClass::lbn
UInt_t lbn
Definition: CaloD3PDClass.h:38
LArSamples
Definition: AbsShape.h:24
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition: TRTCalib_makeplots.cxx:4019
CaloD3PDClass::cc_sel_Sigma
vector< float > * cc_sel_Sigma
Definition: CaloD3PDClass.h:80
CaloD3PDClass::lardigit_gain
vector< int > * lardigit_gain
Definition: CaloD3PDClass.h:218
LArSamples::CellInfo::iEta
short iEta() const
Definition: CellInfo.h:56
LArSamples::D3PDConverter::makeSamplesTuple
bool makeSamplesTuple(const TString &outputFileName)
Definition: D3PDConverter.cxx:24
LArSamples::RunData
Definition: RunData.h:21
DataContainer.h
LArSamples::DataStore::hist_cont
HistoryContainer *& hist_cont(unsigned int i)
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:67
CaloD3PDClass::cc_sel_QCells
vector< int > * cc_sel_QCells
Definition: CaloD3PDClass.h:71
LArIdTranslatorHelper
Definition: LArIdTranslatorHelper.h:30
CaloD3PDClass::bcid
UInt_t bcid
Definition: CaloD3PDClass.h:39
LArSamples::CellInfo::onlid
ULong64_t onlid() const
Definition: CellInfo.h:90
LArSamples::CellInfo::position
TVector3 position() const
Definition: CellInfo.cxx:204
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloD3PDClass::cc_sel_n
Int_t cc_sel_n
Definition: CaloD3PDClass.h:66
LArIdTranslatorHelper.h
ITk::EventData
InDet::SiSpacePointsSeedMakerEventData EventData
Definition: ITkSiSpacePointsSeedMaker.h:63
LArSamples::HistoryContainer::cell_info
CellInfo * cell_info() const
Definition: HistoryContainer.h:57
EventData.h
CaloD3PDClass::cc_sel_DetCells
vector< int > * cc_sel_DetCells
Definition: CaloD3PDClass.h:73
HistoryContainer.h
CaloD3PDClass::cc_sel_E
vector< float > * cc_sel_E
Definition: CaloD3PDClass.h:67
CaloD3PDClass::cc_sel_TimeCells
vector< float > * cc_sel_TimeCells
Definition: CaloD3PDClass.h:74
LArSamples::Interface::open
static Interface * open(const TString &fileName)
Definition: Interface.cxx:35
D3PDConverter.h
IdentifierHash.h
CaloD3PDClass::cc_sel_IdCells
vector< unsigned int > * cc_sel_IdCells
Definition: CaloD3PDClass.h:79
LArSamples::DataStore
storage of the time histories of all the cells
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:32
LArSamples::CellInfo
Definition: CellInfo.h:31
LArIdTranslatorHelper::Tree
TTree * Tree()
Definition: LArIdTranslatorHelper.h:58
LArSamples::CellInfo::iPhi
short iPhi() const
Definition: CellInfo.h:62
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArSamples::RunData::run
int run() const
Definition: RunData.h:36
LArSamples::CellInfo::channel
short channel() const
Definition: CellInfo.h:76
LArIdTranslatorHelper::onlid
ULong64_t onlid
Definition: LArIdTranslatorHelper.h:39
LArSamples::DataContainer
Definition: DataContainer.h:25
LArSamples::DataStore::addRun
unsigned int addRun(RunData *eventData)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:62
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
LArSamples::HistoryContainer
Definition: HistoryContainer.h:29
LArSamples::HistoryContainer::add
void add(const DataContainer *data)
append data (takes ownership)
Definition: HistoryContainer.h:46
CaloD3PDClass::cc_sel_BadCells
vector< int > * cc_sel_BadCells
Definition: CaloD3PDClass.h:78
CaloD3PDClass::lardigit_n
Int_t lardigit_n
Definition: CaloD3PDClass.h:208
LArSamples::D3PDConverter::m_template
Interface * m_template
Definition: D3PDConverter.h:41
Interface.h
LArSamples::EventData
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:29
CellInfo.h
AthenaPoolExample_Copy.outputFileName
string outputFileName
Definition: AthenaPoolExample_Copy.py:40
LArSamples::CellInfo::layer
short layer() const
Definition: CellInfo.h:53
LArSamples::AbsLArCells::nChannels
virtual unsigned int nChannels() const
Definition: AbsLArCells.h:34
LArSamples::D3PDConverter::m_id2hash
std::map< unsigned int, unsigned int > m_id2hash
Definition: D3PDConverter.h:40
LArSamples::DataStore::writeTrees
bool writeTrees(const char *fileName)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:110
fitman.k
k
Definition: fitman.py:528
LArSamples::DataStore::makeNewHistory
HistoryContainer * makeNewHistory(const IdentifierHash &hash, CellInfo *info)
append data (takes ownership of everything)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:38
EventInfoCnvParams::eventIndex
thread_local event_number_t eventIndex
Definition: IEvtIdModifierSvc.h:34