ATLAS Offline Software
Loading...
Searching...
No Matches
EventBookkeeperCollection.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
19
21 {
22 if ( this != &rhs ) {
24 }
25 return *this;
26 }
27
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 ){
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 (EventBookkeeper* bk : *this) {
61 PtrFLAT.push_back(bk);
62 bk->fillWithWholeFamily( &PtrFLAT ); //family does not include topParent
63 }
64
65 //Now a make a flat-structure collection with new objects
66 auto CopyFLAT = std::make_unique<EventBookkeeperCollection>();
67 for (EventBookkeeper* bk : PtrFLAT) {
68 EventBookkeeper* tmp = bk->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 //The caller now owns CopyFLAT and its content
83 return CopyFLAT.release();
84}
85
const EventBookkeeper * at(size_type n) const
value_type push_back(value_type pElem)
DataVector(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
size_type size() const noexcept
DataVector & operator=(const DataVector &rhs)
Assignment operator.
void UpdateFromColl(const EventBookkeeperCollection *coll)
EventBookkeeper * GetElement(const EventBookkeeper *book)
EventBookkeeperCollection & operator=(const EventBookkeeperCollection &rhs)
EventBookkeeperCollection * GetCopyWithFlatStructure()
void fillWithWholeFamily(EventBookkeeperCollection *family)
EventBookkeeper * DeepCopyForFlatStructure(EventBookkeeperCollection *collFLAT)
void updateAcceptedEventsIncludingFamily(const EventBookkeeper *eb)
Forward declaration.
OwnershipPolicy
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts