ATLAS Offline Software
CutBookkeeperContainer_v1.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 CutBookkeeperContainer_v1
7 // Author: Karsten Koeneke, May 2014 <karsten.koeneke@cern.ch>
9 
11 
12 namespace xAOD {
13 
14 
16  // Constructors
18 
19  // CutBookkeeperContainer_v1::CutBookkeeperContainer_v1()
20  // : DataVector<CutBookkeeper_v1> (SG::OWN_ELEMENTS)
21  // { }
22 
23 
26  SG::IndexTrackingPolicy trackIndices )
27  : DataVector<xAOD::CutBookkeeper_v1>(ownPolicy,trackIndices)
28  { }
29 
33  SG::OwnershipPolicy ownPolicy,
34  SG::IndexTrackingPolicy trackIndices )
35  : DataVector<xAOD::CutBookkeeper_v1>(first,last,ownPolicy,trackIndices)
36  { }
37 
38 
41  { }
42 
43 
44 
45  // CutBookkeeperContainer_v1::CutBookkeeperContainer_v1( const CutBookkeeperContainer_v1& rhs ) :
46  // DataVector<CutBookkeeper_v1> (rhs)
47  // { }
48  //
49  //
50  // CutBookkeeperContainer_v1&
51  // CutBookkeeperContainer_v1::operator=( const CutBookkeeperContainer_v1& rhs ) {
52  // if ( this != &rhs ) {
53  // DataVector<CutBookkeeper_v1>::operator=(rhs);
54  // }
55  // return *this;
56  // }
57  //
58  //
59  // CutBookkeeperContainer_v1::CutBookkeeperContainer_v1( const SG::OwnershipPolicy own ) :
60  // DataVector<CutBookkeeper_v1>(own)
61  // { }
62 
63  // Merge the content of another xAOD::CutBookkeeperContainer into this one
65  {
66  // Create an vector of indices of all the newly transferred CutBookkeepers
67  std::vector< std::size_t > newEBKIndices;
68  // Loop through otherCont.
69  // If element already in this container, update event counts, otherwise create new element
70  for ( std::size_t i=0; i<otherCont->size(); ++i ){
71  const xAOD::CutBookkeeper_v1* otherEBK = otherCont->at(i);
72 
73  // Loop through this container and see if we find a match
74  bool foundEBKToUpdate(false);
75  for ( std::size_t j=0; j<this->size(); ++j ) {
76  xAOD::CutBookkeeper_v1* ebkToUpdate = this->at(j);
77  // Check if they are identical, if so, update; else add otherEBK
78  if ( otherEBK->isEqualTo(ebkToUpdate) ) {
79  ebkToUpdate->setPayload( ebkToUpdate->payload() + otherEBK->payload() );
80  foundEBKToUpdate = true;
81  break;
82  }
83  } // End: Inner loop over contToUpdate
84  if (!foundEBKToUpdate) {
86  if ( newEBK->usingPrivateStore() ) { newEBK->releasePrivateStore(); }
87  newEBK->makePrivateStore(otherEBK);
88  this->push_back( newEBK );
89  std::size_t ebIdx = newEBK->index();
90  newEBKIndices.push_back(ebIdx);
91  }
92  } // End: Outer loop over contToUpdate
93 
94  // Now, we still need to fix the cross-referencing of the newly added CutBookkkeepers
95  for ( std::size_t i=0; i<newEBKIndices.size(); ++i ) {
96  std::size_t otherIndex = newEBKIndices.at(i);
97  xAOD::CutBookkeeper_v1* ebkToModify = this->at(otherIndex);
98 
99  // Parent check
100  if ( ebkToModify->hasParent() ) {
101  const xAOD::CutBookkeeper_v1* oldParent = ebkToModify->parent();
103  this->end(),
104  oldParent );
105  // If we found it, we can modify
106  if ( matchIter != this->end() ) {
107  ebkToModify->setParent( *matchIter );
108  }
109  // If we didn't find it, we need to add it
110  else {
112  if ( newEBK->usingPrivateStore() ) { newEBK->releasePrivateStore(); }
113  newEBK->makePrivateStore(oldParent);
114  this->push_back( newEBK );
115  ebkToModify->setParent( newEBK );
116  }
117  } // Done fixing parent
118 
119  // Children check
120  for ( std::size_t oldIdx=0; oldIdx<ebkToModify->nChildren(); ++oldIdx ) {
121  const xAOD::CutBookkeeper_v1* oldEBK = ebkToModify->child(oldIdx);
123  this->end(),
124  oldEBK );
125  // If we found it, we can modify
126  if ( matchIter != this->end() ) {
127  ebkToModify->addChild( *matchIter );
128  }
129  // If we didn't find it, we need to add it
130  else {
132  if ( newEBK->usingPrivateStore() ) { newEBK->releasePrivateStore(); }
133  newEBK->makePrivateStore(oldEBK);
134  this->push_back( newEBK );
135  ebkToModify->addChild( newEBK );
136  }
137  } // Done fixing children
138 
139  // Used others check
140  for ( std::size_t oldIdx=0; oldIdx<ebkToModify->nUsedOthers(); ++oldIdx ) {
141  const xAOD::CutBookkeeper_v1* oldEBK = ebkToModify->usedOther(oldIdx);
143  this->end(),
144  oldEBK );
145  // If we found it, we can modify
146  if ( matchIter != this->end() ) {
147  ebkToModify->addUsedOther( *matchIter );
148  }
149  // If we didn't find it, we need to add it
150  else {
152  if ( newEBK->usingPrivateStore() ) { newEBK->releasePrivateStore(); }
153  newEBK->makePrivateStore(oldEBK);
154  this->push_back( newEBK );
155  ebkToModify->addUsedOther( newEBK );
156  }
157  } // Done fixing used others
158 
159  // Siblings check
160  for ( std::size_t oldIdx=0; oldIdx<ebkToModify->nSiblings(); ++oldIdx ) {
161  const xAOD::CutBookkeeper_v1* oldEBK = ebkToModify->sibling(oldIdx);
163  this->end(),
164  oldEBK );
165  // If we found it, we can modify
166  if ( matchIter != this->end() ) {
167  ebkToModify->addSibling( *matchIter );
168  }
169  // If we didn't find it, we need to add it
170  else {
172  if ( newEBK->usingPrivateStore() ) { newEBK->releasePrivateStore(); }
173  newEBK->makePrivateStore(oldEBK);
174  this->push_back( newEBK );
175  ebkToModify->addSibling( newEBK );
176  }
177  } // Done fixing siblings
178  } // Done fixing all cross references
179  return;
180  }
181 
182 
183  // Get the minimum cycle number of any xAOD::CutBookkeepers in the container
185  {
186  // Now, iterate over all CutBookkeepers and search for the lowest cycle number
187  int minCycle=9999999;
188  for ( std::size_t i=0; i<this->size(); ++i ) {
189  // Get the current old EBK
190  const xAOD::CutBookkeeper_v1* cbk = this->at(i);
191  int inCycle = cbk->cycle();
192  if (inCycle < minCycle) minCycle = inCycle;
193  }
194  if (minCycle==9999999){ minCycle = 0; }
195  return minCycle;
196  }
197 
198 
199  // Get the maximum cycle number of any xAOD::CutBookkeepers in the container
201  {
202  // Now, iterate over all CutBookkeepers and search for the highest cycle number
203  int maxCycle=0;
204  for ( std::size_t i=0; i<this->size(); ++i ) {
205  // Get the current old EBK
206  const xAOD::CutBookkeeper_v1* cbk = this->at(i);
207  int inCycle = cbk->cycle();
208  if (inCycle > maxCycle) maxCycle = inCycle;
209  }
210  return maxCycle;
211  }
212 
213 } // namespace xAOD
xAOD::CutBookkeeper_v1::cycle
int cycle() const
Get the skimming cycle that this CutBookkeeper was running in.
Definition: CutBookkeeper_v1.cxx:205
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CutBookkeeperContainer_v1.h
xAOD::CutBookkeeper_v1::sibling
const xAOD::CutBookkeeper_v1 * sibling(std::size_t i) const
Get the sibling number i.
Definition: CutBookkeeper_v1.cxx:608
xAOD::CutBookkeeper_v1::addSibling
void addSibling(CutBookkeeper_v1 *siblingsEB)
Add one sibling CutBookkeeper to this one.
Definition: CutBookkeeper_v1.cxx:642
xAOD::CutBookkeeper_v1
Description of the class that is used to keep track of event counts.
Definition: CutBookkeeper_v1.h:29
xAOD::CutBookkeeper_v1::nUsedOthers
std::size_t nUsedOthers() const
Check if this CutBookkeeper has used others.
Definition: CutBookkeeper_v1.cxx:500
xAOD::CutBookkeeper_v1::addChild
void addChild(CutBookkeeper_v1 *childEB)
Add one child to this CutBookkeeper.
Definition: CutBookkeeper_v1.cxx:442
xAOD::CutBookkeeperContainer_v1::merge
void merge(const CutBookkeeperContainer_v1 *otherCont)
Merge the content of another xAOD::CutBookkeeperContainer into this one.
Definition: CutBookkeeperContainer_v1.cxx:64
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::CutBookkeeper_v1::addUsedOther
void addUsedOther(CutBookkeeper_v1 *usedOtherEB)
Add one other CutBookkeeper that is used by this one.
Definition: CutBookkeeper_v1.cxx:555
xAOD::CutBookkeeper_v1::payload
Payload payload() const
Get the whole payload object (which contains all counters) in one go.
Definition: CutBookkeeper_v1.cxx:112
xAOD::CutBookkeeper_v1::nSiblings
std::size_t nSiblings() const
Check if this CutBookkeeper has siblings.
Definition: CutBookkeeper_v1.cxx:587
xAOD::CutBookkeeper_v1::hasParent
bool hasParent() const
Check if there is a parent CutBookkeeper of this CutBookkeeper.
Definition: CutBookkeeper_v1.cxx:359
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
DataModel_detail::iterator
(Non-const) Iterator class for DataVector/DataList.
Definition: DVLIterator.h:184
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::AuxElement::usingPrivateStore
bool usingPrivateStore() const
Test to see if this object is currently using a private store.
Definition: AuxElement.cxx:260
xAOD::CutBookkeeperContainer_v1::minCycle
int minCycle() const
Get the minimum cycle number of any xAOD::CutBookkeepers in the container.
Definition: CutBookkeeperContainer_v1.cxx:184
xAOD::CutBookkeeperContainer_v1::maxCycle
int maxCycle() const
Get the maximum cycle number of any xAOD::CutBookkeepers in the container.
Definition: CutBookkeeperContainer_v1.cxx:200
SG::AuxElement::releasePrivateStore
void releasePrivateStore()
Release and free any private store associated with this object.
Definition: AuxElement.cxx:190
xAOD::CutBookkeeper_v1::setParent
void setParent(const CutBookkeeper_v1 *parentEB)
Set the parent CutBookkeeper of this CutBookkeeper.
Definition: CutBookkeeper_v1.cxx:372
xAOD::CutBookkeeperContainer_v1
Container that holds the Container of all CutBookkeepers.
Definition: CutBookkeeperContainer_v1.h:27
xAOD::CutBookkeeper_v1::isEqualTo
bool isEqualTo(const CutBookkeeper_v1 *eb) const
Test for the equality of this CutBookkeeper with another one.
Definition: CutBookkeeper_v1.cxx:348
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::CutBookkeeper_v1::child
const xAOD::CutBookkeeper_v1 * child(std::size_t i) const
Get the child at position i.
Definition: CutBookkeeper_v1.cxx:408
xAOD::CutBookkeeperContainer_v1::CutBookkeeperContainer_v1
CutBookkeeperContainer_v1(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS, SG::IndexTrackingPolicy trackIndices=SG::DEFAULT_TRACK_INDICES)
Default Constructor.
Definition: CutBookkeeperContainer_v1.cxx:25
DataVector< CutBookkeeper_v1 >::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
DataVector< CutBookkeeper_v1 >::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::CutBookkeeper_v1::usedOther
const xAOD::CutBookkeeper_v1 * usedOther(std::size_t i) const
Get the usedOther at position i.
Definition: CutBookkeeper_v1.cxx:521
DeMoScan.first
bool first
Definition: DeMoScan.py:536
xAOD::CutBookkeeper_v1::setPayload
void setPayload(const Payload &payload)
Set the whole payload object (which contains all counters) in one go.
Definition: CutBookkeeper_v1.cxx:121
xAOD::CutBookkeeper_v1::nChildren
std::size_t nChildren() const
Get the number of children CutBookkeepers of this CutBookkeeper.
Definition: CutBookkeeper_v1.cxx:387
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::CutBookkeeperContainer_v1::~CutBookkeeperContainer_v1
virtual ~CutBookkeeperContainer_v1()
Destructor.
Definition: CutBookkeeperContainer_v1.cxx:40
SG::IndexTrackingPolicy
IndexTrackingPolicy
Definition: IndexTrackingPolicy.h:37
DataVector< CutBookkeeper_v1 >::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
xAOD::CutBookkeeper_v1::parent
const xAOD::CutBookkeeper_v1 * parent() const
Get the parent CutBookkeeper.
Definition: CutBookkeeper_v1.cxx:364