ATLAS Offline Software
LArCalorimeter/LArCafJobs/src/DataStore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "LArCafJobs/DataStore.h"
6 
7 #include "LArCafJobs/ShapeInfo.h"
10 #include "LArCafJobs/EventData.h"
11 #include "LArCafJobs/RunData.h"
14 #include "TRandom.h"
15 #include "TMath.h"
16 #include "TFile.h"
17 #include "TTree.h"
18 #include <iostream>
19 
20 using std::cout;
21 using std::endl;
22 
23 using namespace LArSamples;
24 
25 
26 DataStore::DataStore() : m_cellHistories(nChannels(), nullptr)
27 {
28 }
29 
30 
32 {
34  delete h;
35 }
36 
37 
39 {
40  HistoryContainer*& histCont = hist_cont(hash);
41  if (histCont) return histCont;
42  histCont = new HistoryContainer(info);
43  return histCont;
44 }
45 
46 
47 bool DataStore::addData(const IdentifierHash& hash, DataContainer* data)
48 {
49  HistoryContainer*& histCont = hist_cont(hash);
50  histCont->add(data);
51  return true;
52 }
53 
54 
55 unsigned int DataStore::addEvent(EventData* eventData)
56 {
57  m_events.push_back(eventData);
58  return nEvents() - 1;
59 }
60 
61 
62 unsigned int DataStore::addRun(RunData* runData)
63 {
64  m_runs.push_back(runData);
65  return nRuns() - 1;
66 }
67 
68 
69 unsigned int DataStore::size() const
70 {
71  unsigned int size = 0;
72 
73  for (unsigned int i = 0; i < nChannels(); i++) {
75  if (!hist) continue;
76  size += hist->nDataContainers();
77  }
78 
79  return size;
80 }
81 
82 
83 unsigned int DataStore::nFilledChannels() const
84 {
85  unsigned int n = 0;
86 
87  for (unsigned int i = 0; i < nChannels(); i++) {
89  if (!hist) continue;
90  n++;
91  }
92 
93  return n;
94 }
95 
96 
97 double DataStore::footprint() const
98 {
99  double fp = sizeof(*this);
100  for (unsigned int i = 0; i < nChannels(); i++) {
102  if (!hist) continue;
103  fp += hist->footprint();
104  }
105 
106  return fp;
107 }
108 
109 
111 {
113 
114  for (unsigned int i = 0; i < nRuns(); i++) {
115  RunData*& r = runData(i);
116  acc->addRun(r);
117  delete r; r = nullptr;
118  }
119 
120  for (unsigned int i = 0; i < nEvents(); i++) {
121  EventData*& ev = eventData(i);
122  acc->addEvent(ev);
123  delete ev; ev = nullptr;
124  }
125 
126  for (unsigned int i = 0; i < nChannels(); i++) {
127  HistoryContainer*& hc = hist_cont(i);
128  acc->add(hc);
129  delete hc; hc = nullptr;
130  }
131 
132  bool result = acc->save();
133  delete acc;
134  return result;
135 }
grepfile.info
info
Definition: grepfile.py:38
LArSamples::DataStore::DataStore
DataStore()
Constructor
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:26
RunData.h
beamspotman.r
def r
Definition: beamspotman.py:676
LArSamples::DataStore::addData
bool addData(const IdentifierHash &hash, DataContainer *data)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:47
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
get_generator_info.result
result
Definition: get_generator_info.py:21
LArSamples::DataStore::~DataStore
virtual ~DataStore()
Destructor.
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:31
LArSamples::DataStore::historyContainer
const HistoryContainer * historyContainer(unsigned int i) const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:42
DataStore.h
plotmaker.hist
hist
Definition: plotmaker.py:148
LArSamples::DataStore::runData
const RunData * runData(unsigned int i) const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:44
LArSamples::DataStore::addEvent
unsigned int addEvent(EventData *eventData)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:55
LArSamples::PersistentAccessor
Definition: PersistentAccessor.h:24
LArSamples
Definition: AbsShape.h:24
ShapeInfo.h
PersistentAccessor.h
LArSamples::RunData
Definition: RunData.h:21
LArSamples::DataStore::footprint
double footprint() const
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:97
DataContainer.h
LArSamples::DataStore::hist_cont
HistoryContainer *& hist_cont(unsigned int i)
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:67
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ev
int ev
Definition: globals.cxx:25
LArSamples::DataStore::m_runs
std::vector< RunData * > m_runs
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:73
lumiFormat.i
int i
Definition: lumiFormat.py:92
trigmenu_modify_prescale_json.fp
fp
Definition: trigmenu_modify_prescale_json.py:53
h
beamspotman.n
n
Definition: beamspotman.py:731
extractSporadic.h
list h
Definition: extractSporadic.py:97
LArSamples::DataStore::nChannels
unsigned int nChannels() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:53
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
LArSamples::DataStore::eventData
const EventData * eventData(unsigned int i) const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:43
EventData.h
LArSamples::DataStore::m_events
std::vector< EventData * > m_events
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:72
HistoryContainer.h
LArSamples::DataStore::size
unsigned int size() const
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:69
LArSamples::DataStore::nEvents
unsigned int nEvents() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:56
LArSamples::DataStore::nFilledChannels
unsigned int nFilledChannels() const
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:83
IdentifierHash.h
LArSamples::CellInfo
Definition: CellInfo.h:31
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
LArSamples::DataStore::m_cellHistories
std::vector< HistoryContainer * > m_cellHistories
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:71
LArSamples::EventData
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/EventData.h:29
LArSamples::DataStore::writeTrees
bool writeTrees(const char *fileName)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:110
LArSamples::DataStore::nRuns
unsigned int nRuns() const
Definition: LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:57
LArSamples::DataStore::makeNewHistory
HistoryContainer * makeNewHistory(const IdentifierHash &hash, CellInfo *info)
append data (takes ownership of everything)
Definition: LArCalorimeter/LArCafJobs/src/DataStore.cxx:38