ATLAS Offline Software
D3PDConverter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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"
13 
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  //cout << "Entry " << i << " nCells = " << cc_sel_n << endl;
44 
45  for (int j = 0; j < cc_sel_n; j++) {
46  // skip Tile cells
47  if ((*cc_sel_DetCells)[j] & 8) continue;
48  unsigned int hash = m_id2hash[(*cc_sel_IdCells)[j]];
49  if (hash == 0) {
50  cout << "ERROR: skipping cell with offline ID = " << (*cc_sel_IdCells)[j] << endl;
51  continue;
52  }
53 
54  // find digit
55  int digitIndex = -1;
56  for (int k = 0; k < lardigit_n; k++) {
57  if ((*lardigit_offlineId)[k] == (*cc_sel_IdCells)[j]) {
58  digitIndex = k;
59  break;
60  }
61  }
62  //if (digitIndex >= 0) cout << "digitIndex = " << digitIndex << endl;
63  hash -= 1;
64  HistoryContainer* histCont = samples->hist_cont(hash);
65  CellInfo* info = nullptr;
66  if (!histCont) {
67  const CellInfo* templateInfo = m_template->cellInfo(hash);
68  info = new CellInfo(templateInfo->calo(), templateInfo->layer(),
69  templateInfo->iEta(), templateInfo->iPhi(),
70  templateInfo->feedThrough(), templateInfo->slot(), templateInfo->channel(),
71  nullptr,nullptr,nullptr, templateInfo->position(), templateInfo->onlid());
72  histCont = samples->makeNewHistory(IdentifierHash(hash), info);
73  }
74  else
75  info = histCont->cell_info();
76 
78  std::vector<short> samples;
79  if (digitIndex >= 0) {
80  gain = (CaloGain::CaloGain)(*lardigit_gain)[digitIndex];
81  std::vector<int> intSamples = (*lardigit_Samples)[digitIndex];
82  for (int s : intSamples) {
83  samples.push_back((short)s);
84  }
85  }
89  std::vector<float>(), (*cc_sel_Sigma)[j],
90  -1, -1, (*cc_sel_BadCells)[j]);
91  //cout << "Adding data to " << hash << " " << histCont->nDataContainers() << endl;
92  histCont->add(data);
93  }
94  }
95  samples->writeTrees(outputFileName);
96  return true;
97 }
98 
99 
100 bool D3PDConverter::initMapping(const TString& templateFile, const TString& translatorFile)
101 {
102  LArIdTranslatorHelper* translator = new LArIdTranslatorHelper(translatorFile);
103  m_template = Interface::open(templateFile);
104 
105  cout << "Making online->hash map" << endl;
106  std::map<unsigned long long, unsigned int> on2hash;
107  for (unsigned int i = 0; i < m_template->nChannels(); i++) {
108  const CellInfo* info = m_template->cellInfo(i);
109  if (!info) continue;
110  on2hash[info->onlid()] = i;
111  }
112 
113  cout << "Making offlineID->hash map" << endl;
114  for (unsigned int i = 0; i < translator->Tree()->GetEntries(); i++) {
115  translator->Tree()->GetEntry(i);
116  m_id2hash[translator->offlid] = on2hash[translator->onlid] + 1;
117  }
118  // delete translator; // crashes
119  return true;
120 }
121 
122 
123 
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:100
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::AbsLArCells::cellInfo
virtual const CellInfo * cellInfo(unsigned int i) const
Definition: AbsLArCells.cxx:69
LArIdTranslatorHelper::offlid
ULong64_t offlid
Definition: LArIdTranslatorHelper.h:37
CaloD3PDClass::lbn
UInt_t lbn
Definition: CaloD3PDClass.h:38
LArSamples
Definition: AbsShape.h:24
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
CaloD3PDClass::cc_sel_QCells
vector< int > * cc_sel_QCells
Definition: CaloD3PDClass.h:71
LArIdTranslatorHelper
Definition: LArIdTranslatorHelper.h:28
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:92
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
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:33
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:56
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:37
LArSamples::DataContainer
Definition: DataContainer.h:25
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
generate::GetEntries
double GetEntries(TH1D *h, int ilow, int ihi)
Definition: rmsFrac.cxx:20
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:38
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:37
fitman.k
k
Definition: fitman.py:528
EventInfoCnvParams::eventIndex
thread_local event_number_t eventIndex
Definition: IEvtIdModifierSvc.h:34