ATLAS Offline Software
EventBookkeeper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Implementation file for class Eventbookkeeper
7 // Author: DavidCote, September 2008 <david.cote@cern.ch>
9 
11 
15 
17 {
19 }
20 
22 {
24  m_name=name;
25 }
26 
28  const std::string& description,
29  const std::string& logic)
30 {
32  m_name=name;
34  m_logic=logic;
35 }
36 
38  : m_name (rhs.m_name),
39  m_description (rhs.m_description),
40  m_inputstream (rhs.m_inputstream),
41  m_outputstream (rhs.m_outputstream),
42  m_logic (rhs.m_logic),
43  m_nAcceptedEvents (rhs.m_nAcceptedEvents),
44  m_nWeightedAcceptedEvents (rhs.m_nWeightedAcceptedEvents),
45  m_cycle (rhs.m_cycle),
46  m_parentIndex (rhs.m_parentIndex),
47  m_declaredChildFilter (rhs.m_declaredChildFilter),
48  m_declaredTopFilter (rhs.m_declaredTopFilter)
49 {
50  //Make a new deep copy of the children, as these will be owned by this
51  m_childrenEB = new std::vector<EventBookkeeper*>;
52  m_childrenEB->reserve(rhs.m_childrenEB->size());
53  for(unsigned int i=0; i<rhs.m_childrenEB->size(); i++){
54  EventBookkeeper* child=new EventBookkeeper(*rhs.m_childrenEB->at(i));
55  m_childrenEB->push_back(child);
56  }
57  m_childrenIndices = new std::vector<unsigned int>;
58  m_childrenIndices->reserve(rhs.m_childrenIndices->size());
59  for(unsigned int i=0; i<rhs.m_childrenIndices->size(); i++){
60  m_childrenIndices->push_back(rhs.m_childrenIndices->at(i));
61  }
62 }
63 
66 {
67  if (this != &rhs) {
68  m_name=rhs.m_name;
72  m_logic = rhs.m_logic;
75  m_cycle=rhs.m_cycle;
77  //Make a new deep copy of the children, as these will be owned by this
78  m_childrenEB = new std::vector<EventBookkeeper*>;
79  m_childrenEB->reserve(rhs.m_childrenEB->size());
80  for(unsigned int i=0; i<rhs.m_childrenEB->size(); i++){
81  EventBookkeeper* child=new EventBookkeeper(*rhs.m_childrenEB->at(i));
82  m_childrenEB->push_back(child);
83  }
84  m_childrenIndices = new std::vector<unsigned int>;
85  m_childrenIndices->reserve(rhs.m_childrenIndices->size());
86  for(unsigned int i=0; i<rhs.m_childrenIndices->size(); i++){
87  m_childrenIndices->push_back(rhs.m_childrenIndices->at(i));
88  }
91  }
92  return *this;
93 }
94 
95 void
97 {
98  m_name="";
99  m_description="";
100  m_inputstream="unkwn";
101  m_outputstream="unkwn";
102  m_logic="unkwn";
105  m_cycle=-1;
106  m_childrenEB = new std::vector<EventBookkeeper*>;
107  m_parentIndex=-1;
108  m_childrenIndices = new std::vector<unsigned int>;
109  m_declaredChildFilter=false;
110  m_declaredTopFilter=false;
111  return;
112 }
113 
116 {
118  book->m_name = m_name;
119  book->m_description = m_description;
120  book->m_inputstream = m_inputstream;
121  book->m_outputstream = m_outputstream;
122  book->m_logic = m_logic;
123  book->m_nAcceptedEvents = m_nAcceptedEvents;
124  book->m_nWeightedAcceptedEvents = m_nWeightedAcceptedEvents;
125  book->m_cycle = m_cycle;
126  book->m_declaredChildFilter = m_declaredChildFilter;
127  book->m_declaredTopFilter = m_declaredTopFilter;
128 
129  //now deal here with the flat indices from collFLAT. Only the direct children are filled, NOT the whole family.
130  for(unsigned int i=0; i<m_childrenEB->size(); i++){
131  bool notFound=true;
132  for(unsigned int j=0; (j<collFLAT->size() && notFound); j++){
133  if(m_childrenEB->at(i)==collFLAT->at(j)){
134  book->m_childrenIndices->push_back(j);
135  notFound=false;
136  }
137  }
138  }
139  //parentIndex is dealt in a separate function of EventBookkeeperCollection
140  book->m_parentIndex=m_parentIndex;
141 
142  //the caller now owns book
143  return book;
144 }
145 
147 {
148  //std::cout<<"Destructing "<<m_name<<std::endl;
149  for(unsigned int i=0; i<m_childrenEB->size(); i++){ delete m_childrenEB->at(i); }
150  m_childrenEB->clear();
151  delete m_childrenEB;
152 
153  m_childrenIndices->clear();
154  delete m_childrenIndices;
155 }
156 
157 
158 void
159 EventBookkeeper::setName(const std::string& name)
160 {
161  m_name=name;
162 }
163 
164 void
166 {
168 }
169 
170 void
171 EventBookkeeper::setInputStream(const std::string& inputstream)
172 {
173  m_inputstream=inputstream;
174 }
175 
176 void
177 EventBookkeeper::setOutputStream(const std::string& outputstream)
178 {
179  m_outputstream=outputstream;
180 }
181 
182 void
183 EventBookkeeper::setOutputStreamOfFamily(const std::string &outputstream)
184 {
185  setOutputStream(outputstream);
186  for(unsigned int i=0; i<m_childrenEB->size(); i++){
187  m_childrenEB->at(i)->setOutputStreamOfFamily(outputstream);
188  }
189  return;
190 }
191 
192 void
193 EventBookkeeper::setLogic(const std::string& logic)
194 {
195  m_logic=logic;
196 }
197 
198 void
200 {
202 }
203 
204 void
206 {
208 }
209 
210 void
212 {
213  m_nWeightedAcceptedEvents=nWeightedEvents;
214 }
215 
216 void
218 {
219  m_nWeightedAcceptedEvents+=nWeightedEvents;
220 }
221 
222 void
224 {
227 
228  const std::vector<EventBookkeeper*>* eb_children = eb->getChildrenEventBookkeepers();
229  for(unsigned int i=0; i<m_childrenEB->size(); i++){
230  m_childrenEB->at(i)->updateAcceptedEventsIncludingFamily(eb_children->at(i));
231  }
232  return;
233 }
234 
235 void
237 {
238  m_cycle=cycle;
239 }
240 
241 void
242 EventBookkeeper::setChildrenEventBookkeepers(std::vector<EventBookkeeper*>* childrenEB)
243 {
244  m_childrenEB=childrenEB;
245 }
246 
247 void
249 {
250  //synchronize contextual info with the parent
252  eb->setCycle( m_cycle );
254  bool notFound=true;
255  for(unsigned int i=0; (i<m_childrenEB->size()) && notFound; i++){
256  if(m_childrenEB->at(i)==eb){
257  notFound=false;
258  }
259  }
260  if(notFound){ m_childrenEB->push_back(eb); }
261  //else{ ATH_MSG_WARNING("Two requests for the same child. Second one ignored."); }
262  return;
263 }
264 void EventBookkeeper::AddChildren( std::vector<EventBookkeeper*>* children ){
265  for(unsigned int i=0; i<children->size(); i++){
266  AddChild( children->at(i) );
267  }
268  return;
269 }
270 
272  const std::string& description)
273 {
274  EventBookkeeper* eb = new EventBookkeeper(name,description,"Child");
275  AddChild(eb);
276  return eb;
277 }
278 
279 
281  //This function is mostly a placeholder in case we decide to complexify later.
282  return (m_name==eb->getName() && m_cycle==eb->getCycle());
283 }
284 
285 void
286 EventBookkeeper::PrintToMsg(MsgStream &log, const std::string& indent)
287 {
288  if(log.level()==MSG::DEBUG){
289  log<<MSG::DEBUG<<indent<<m_name<<" "<<m_inputstream<<" "<<m_outputstream<<" "<<m_logic<<" "<<m_cycle<<" ("<<m_childrenEB->size()<<" children) "<<": "<<m_description<<" ==> "<<m_nAcceptedEvents<<" "<<m_nWeightedAcceptedEvents<<endmsg;
290  }
291  else{
292  log<<MSG::INFO<<indent<<m_name<<": "<<m_description<<" ==> "<<m_nAcceptedEvents<<endmsg;
293  }
294 
295  return;
296 }
297 
298 void
299 EventBookkeeper::Print(const std::string& indent, std::ostream &out)
300 {
301  out<<indent<<m_name<<" "<<m_inputstream<<" "<<m_outputstream<<" "<<m_logic<<" "<<m_cycle<<" ("<<m_childrenEB->size()<<" children) "<<": "<<m_description<<" ==> "<<m_nAcceptedEvents<<" "<<m_nWeightedAcceptedEvents<<std::endl;
302  return;
303 }
304 
305 void
307 {
308  Print(indent);
309  std::string indent_ = indent + " ";
310  for(unsigned int i=0; i<m_childrenEB->size(); i++){
311  m_childrenEB->at(i)->PrintFamily(indent_);
312  }
313  return;
314 }
315 
316 void
318 {
319 
320  //family does not include self
321  for(unsigned int i=0; i<m_childrenEB->size(); i++){
322  family->push_back(m_childrenEB->at(i));
323  m_childrenEB->at(i)->fillWithWholeFamily(family);
324  }
325 
326  return;
327 }
EventBookkeeper::PrintFamily
void PrintFamily(const std::string &indent="")
Definition: EventBookkeeper.cxx:306
EventBookkeeper::m_nWeightedAcceptedEvents
double m_nWeightedAcceptedEvents
Definition: EventBookkeeper.h:92
EventBookkeeper::m_declaredChildFilter
bool m_declaredChildFilter
Definition: EventBookkeeper.h:106
EventBookkeeper::addNWeightedAcceptedEvents
void addNWeightedAcceptedEvents(double nWeightedEvents)
Definition: EventBookkeeper.cxx:217
EventBookkeeper::setLogic
void setLogic(const std::string &logic)
Definition: EventBookkeeper.cxx:193
EventBookkeeper::m_cycle
int m_cycle
Definition: EventBookkeeper.h:93
EventBookkeeperCollection.h
EventBookkeeper::setNAcceptedEvents
void setNAcceptedEvents(uint64_t nEvents)
Definition: EventBookkeeper.cxx:199
cycle
double cycle(double a, double b)
Definition: SiHitCollectionCnv_p2.cxx:37
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
EventBookkeeperCollection
Definition: EventBookkeeperCollection.h:21
EventBookkeeper::setCycle
void setCycle(int cycle)
Definition: EventBookkeeper.cxx:236
EventBookkeeper::m_outputstream
std::string m_outputstream
Definition: EventBookkeeper.h:89
EventBookkeeper::AddNewChild
EventBookkeeper * AddNewChild(const std::string &name, const std::string &description)
Definition: EventBookkeeper.cxx:271
EventBookkeeper::DeepCopyForFlatStructure
EventBookkeeper * DeepCopyForFlatStructure(EventBookkeeperCollection *collFLAT)
Definition: EventBookkeeper.cxx:115
EventBookkeeper::m_description
std::string m_description
Definition: EventBookkeeper.h:87
EventBookkeeper::setOutputStream
void setOutputStream(const std::string &outputstream)
Definition: EventBookkeeper.cxx:177
EventBookkeeper::AddChildren
void AddChildren(std::vector< EventBookkeeper * > *children)
Definition: EventBookkeeper.cxx:264
EventBookkeeper::EventBookkeeper
EventBookkeeper()
Constructors.
Definition: EventBookkeeper.cxx:16
EventBookkeeper::m_name
std::string m_name
Definition: EventBookkeeper.h:86
EventBookkeeper::setNWeightedAcceptedEvents
void setNWeightedAcceptedEvents(double nWeightedEvents)
Definition: EventBookkeeper.cxx:211
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:18
book
T * book(const std::string &n, const std::string &t, unsigned nbins)
Definition: main_benchmark.cxx:138
lumiFormat.i
int i
Definition: lumiFormat.py:92
EventBookkeeper::addNAcceptedEvents
void addNAcceptedEvents(uint64_t nEvents)
Definition: EventBookkeeper.cxx:205
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EventBookkeeper::m_nAcceptedEvents
uint64_t m_nAcceptedEvents
Definition: EventBookkeeper.h:91
EventBookkeeper::setChildrenEventBookkeepers
void setChildrenEventBookkeepers(std::vector< EventBookkeeper * > *childrenEB)
Definition: EventBookkeeper.cxx:242
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
EventBookkeeper
Definition: EventBookkeeper.h:24
nEvents
int nEvents
Definition: fbtTestBasics.cxx:77
EventBookkeeper::m_parentIndex
int m_parentIndex
Definition: EventBookkeeper.h:102
EventBookkeeper::getNAcceptedEvents
uint64_t getNAcceptedEvents() const
Definition: EventBookkeeper.h:60
EventBookkeeper::updateAcceptedEventsIncludingFamily
void updateAcceptedEventsIncludingFamily(const EventBookkeeper *eb)
Definition: EventBookkeeper.cxx:223
EventBookkeeper::getNWeightedAcceptedEvents
double getNWeightedAcceptedEvents() const
Definition: EventBookkeeper.h:64
EventBookkeeper::setName
void setName(const std::string &name)
Definition: EventBookkeeper.cxx:159
EventBookkeeper::m_declaredTopFilter
bool m_declaredTopFilter
Definition: EventBookkeeper.h:107
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventBookkeeper::~EventBookkeeper
~EventBookkeeper()
Definition: EventBookkeeper.cxx:146
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
EventBookkeeper::isEqualTo
bool isEqualTo(const EventBookkeeper *eb)
Definition: EventBookkeeper.cxx:280
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
EventBookkeeper::Print
void Print(const std::string &indent="", std::ostream &out=std::cout)
Definition: EventBookkeeper.cxx:299
python.DecayParser.children
children
Definition: DecayParser.py:32
EventBookkeeper::m_childrenEB
std::vector< EventBookkeeper * > * m_childrenEB
Definition: EventBookkeeper.h:94
EventBookkeeper::m_childrenIndices
std::vector< unsigned int > * m_childrenIndices
Definition: EventBookkeeper.h:103
EventBookkeeper::AddChild
void AddChild(EventBookkeeper *eb)
Definition: EventBookkeeper.cxx:248
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
EventBookkeeper::setOutputStreamOfFamily
void setOutputStreamOfFamily(const std::string &outputstream)
Definition: EventBookkeeper.cxx:183
EventBookkeeper::getChildrenEventBookkeepers
const std::vector< EventBookkeeper * > * getChildrenEventBookkeepers() const
Definition: EventBookkeeper.h:73
EventBookkeeper::setDescription
void setDescription(const std::string &description)
Definition: EventBookkeeper.cxx:165
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
EventBookkeeper::SetDefaultDataMemberValues
void SetDefaultDataMemberValues()
Definition: EventBookkeeper.cxx:96
EventBookkeeper::PrintToMsg
void PrintToMsg(MsgStream &, const std::string &indent="")
Definition: EventBookkeeper.cxx:286
EventBookkeeper::m_inputstream
std::string m_inputstream
Definition: EventBookkeeper.h:88
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
EventBookkeeper::m_logic
std::string m_logic
Definition: EventBookkeeper.h:90
EventBookkeeper::setInputStream
void setInputStream(const std::string &inputstream)
Definition: EventBookkeeper.cxx:171
EventBookkeeper::operator=
EventBookkeeper & operator=(const EventBookkeeper &rhs)
Definition: EventBookkeeper.cxx:65
EventBookkeeper::getCycle
int getCycle() const
Definition: EventBookkeeper.h:70
EventBookkeeper::fillWithWholeFamily
void fillWithWholeFamily(EventBookkeeperCollection *family)
Definition: EventBookkeeper.cxx:317
EventBookkeeper::getName
const std::string & getName() const
Definition: EventBookkeeper.h:44