ATLAS Offline Software
Loading...
Searching...
No Matches
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
20
21EventBookkeeper::EventBookkeeper(const std::string &name)
22{
24 m_name=name;
25}
26
27EventBookkeeper::EventBookkeeper(const std::string& name,
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),
42 m_logic (rhs.m_logic),
45 m_cycle (rhs.m_cycle),
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
95void
97{
98 m_name="";
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>;
111 return;
112}
113
116{
117 EventBookkeeper* book = new EventBookkeeper();
118 book->m_name = m_name;
122 book->m_logic = m_logic;
125 book->m_cycle = m_cycle;
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
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
158void
159EventBookkeeper::setName(const std::string& name)
160{
161 m_name=name;
162}
163
164void
169
170void
171EventBookkeeper::setInputStream(const std::string& inputstream)
172{
173 m_inputstream=inputstream;
174}
175
176void
177EventBookkeeper::setOutputStream(const std::string& outputstream)
178{
179 m_outputstream=outputstream;
180}
181
182void
183EventBookkeeper::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
192void
193EventBookkeeper::setLogic(const std::string& logic)
194{
195 m_logic=logic;
196}
197
198void
203
204void
209
210void
212{
213 m_nWeightedAcceptedEvents=nWeightedEvents;
214}
215
216void
218{
219 m_nWeightedAcceptedEvents+=nWeightedEvents;
220}
221
222void
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
235void
240
241void
242EventBookkeeper::setChildrenEventBookkeepers(std::vector<EventBookkeeper*>* childrenEB)
243{
244 m_childrenEB=childrenEB;
245}
246
247void
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}
264void 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
285void
286EventBookkeeper::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
298void
299EventBookkeeper::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
305void
306EventBookkeeper::PrintFamily(const std::string& indent)
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
316void
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}
#define endmsg
double cycle(double a, double b)
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
uint64_t getNAcceptedEvents() const
EventBookkeeper * AddNewChild(const std::string &name, const std::string &description)
void setOutputStreamOfFamily(const std::string &outputstream)
void setNAcceptedEvents(uint64_t nEvents)
double getNWeightedAcceptedEvents() const
std::vector< unsigned int > * m_childrenIndices
void setDescription(const std::string &description)
void fillWithWholeFamily(EventBookkeeperCollection *family)
EventBookkeeper * DeepCopyForFlatStructure(EventBookkeeperCollection *collFLAT)
uint64_t m_nAcceptedEvents
const std::vector< EventBookkeeper * > * getChildrenEventBookkeepers() const
bool isEqualTo(const EventBookkeeper *eb)
void setCycle(int cycle)
const std::string & getName() const
void addNAcceptedEvents(uint64_t nEvents)
void SetDefaultDataMemberValues()
EventBookkeeper()
Constructors.
friend class EventBookkeeperCollection
void setOutputStream(const std::string &outputstream)
void PrintToMsg(MsgStream &, const std::string &indent="")
void PrintFamily(const std::string &indent="")
std::string m_logic
void setNWeightedAcceptedEvents(double nWeightedEvents)
void AddChildren(std::vector< EventBookkeeper * > *children)
void Print(const std::string &indent="", std::ostream &out=std::cout)
void updateAcceptedEventsIncludingFamily(const EventBookkeeper *eb)
std::string m_outputstream
std::string m_inputstream
std::string m_description
void setName(const std::string &name)
double m_nWeightedAcceptedEvents
void AddChild(EventBookkeeper *eb)
int getCycle() const
EventBookkeeper & operator=(const EventBookkeeper &rhs)
std::vector< EventBookkeeper * > * m_childrenEB
void addNWeightedAcceptedEvents(double nWeightedEvents)
void setLogic(const std::string &logic)
void setChildrenEventBookkeepers(std::vector< EventBookkeeper * > *childrenEB)
void setInputStream(const std::string &inputstream)
std::string m_name
const int nEvents
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91