ATLAS Offline Software
EventBookkeeperCollection.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Implementation file for class EventBookkeeperCollection
7 // Author: David Cote, September 2008. <david.cote@cern.ch>
10 
14 
16 
18  DataVector<EventBookkeeper> (rhs) {}
19 
21  {
22  if ( this != &rhs ) {
24  }
25  return *this;
26  }
27 
30 {}
31 
33  for(unsigned int i=0; i<this->size(); i++){
34  if( this->at(i)->isEqualTo( book ) ){ return this->at(i); }
35  }
36  //if book not found, return null pointer (0x0)
37  EventBookkeeper* nullElement=0;
38  return nullElement;
39 }
40 
42  //Loop through coll, if element already in self update event count, otherwise create new element
43  for(unsigned int i=0; i<coll->size(); i++){
44  const EventBookkeeper* book_i=coll->at(i);
45  EventBookkeeper* tmpBook = this->GetElement( book_i );
46  if( tmpBook ){
47  tmpBook->updateAcceptedEventsIncludingFamily(book_i);
48  }
49  else{
50  EventBookkeeper* newBook = new EventBookkeeper( *book_i );
51  this->push_back( newBook );
52  }
53  }
54  return;
55 }
56 
58  //Just a simple vector of pointers, nothing new is constructed, but now with a flat structure
60  for(unsigned int i=0; i<this->size(); i++){
61  PtrFLAT->push_back(this->at(i));
62  this->at(i)->fillWithWholeFamily( PtrFLAT ); //family does not include topParent
63  }
64 
65  //Now a make a flat-structure collection with new objects
67  for(unsigned int i=0; i<PtrFLAT->size(); i++){
68  EventBookkeeper* tmp = PtrFLAT->at(i)->DeepCopyForFlatStructure( PtrFLAT );
69  CopyFLAT->push_back( tmp );
70  }
71 
72  //Set parentIndex of the CopyFLAT elements
73  for(unsigned int i=0; i<CopyFLAT->size(); i++){
74  if(CopyFLAT->at(i)->m_childrenIndices->size()>0){
75  //parentIndex=i for children of element i
76  std::vector<unsigned int>* childrenIndices=CopyFLAT->at(i)->m_childrenIndices;
77  for(unsigned int j=0; j<childrenIndices->size(); j++){
78  CopyFLAT->at(childrenIndices->at(j))->m_parentIndex=i;
79  }
80  }
81  }
82  //finally, delete the temporary collection (but not its content)
83  //PROBLEM! destructor of EventBookkeeperCollection deletes all its elements... which are double-deleted.
84  //But not deleting PtrFLAT should result in a (small) memory leak
85  //Maybe use an std::vector for PtrFLAT instead?
86  //delete PtrFLAT;
87 
88  //The caller now owns CopyFLAT and its content
89  return CopyFLAT;
90 }
91 
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
EventBookkeeperCollection::GetElement
EventBookkeeper * GetElement(const EventBookkeeper *book)
Definition: EventBookkeeperCollection.cxx:32
EventBookkeeperCollection.h
EventBookkeeperCollection
Definition: EventBookkeeperCollection.h:21
EventBookkeeperCollection::operator=
EventBookkeeperCollection & operator=(const EventBookkeeperCollection &rhs)
Definition: EventBookkeeperCollection.cxx:20
DataVector::operator=
DataVector & operator=(const DataVector &rhs)
Assignment operator.
EventBookkeeperCollection::UpdateFromColl
void UpdateFromColl(const EventBookkeeperCollection *coll)
Definition: EventBookkeeperCollection.cxx:41
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
EventBookkeeper::DeepCopyForFlatStructure
EventBookkeeper * DeepCopyForFlatStructure(EventBookkeeperCollection *collFLAT)
Definition: EventBookkeeper.cxx:115
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
EventBookkeeperCollection::EventBookkeeperCollection
EventBookkeeperCollection()
Constructors.
Definition: EventBookkeeperCollection.cxx:15
EventBookkeeperCollection::GetCopyWithFlatStructure
EventBookkeeperCollection * GetCopyWithFlatStructure()
Definition: EventBookkeeperCollection.cxx:57
EventBookkeeper
Definition: EventBookkeeper.h:24
EventBookkeeper::m_parentIndex
int m_parentIndex
Definition: EventBookkeeper.h:102
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
EventBookkeeper::updateAcceptedEventsIncludingFamily
void updateAcceptedEventsIncludingFamily(const EventBookkeeper *eb)
Definition: EventBookkeeper.cxx:223
DataVector< EventBookkeeper >::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
EventBookkeeper::m_childrenIndices
std::vector< unsigned int > * m_childrenIndices
Definition: EventBookkeeper.h:103
DataVector< EventBookkeeper >::at
const EventBookkeeper * at(size_type n) const
Access an element, as an rvalue.
DataVector< EventBookkeeper >::size
size_type size() const noexcept
Returns the number of elements in the collection.
EventBookkeeper::fillWithWholeFamily
void fillWithWholeFamily(EventBookkeeperCollection *family)
Definition: EventBookkeeper.cxx:317