24 const std::string& histName,
25 int minCycle,
int maxCycle ) {
27 if (!cbkCont)
return nullptr;
30 const int cbkMaxCycle = cbkCont->
maxCycle();
31 if (maxCycle<0) maxCycle = cbkMaxCycle;
34 std::vector<const xAOD::CutBookkeeper*> cbks;
35 cbks.reserve(cbkCont->
size());
37 const int cycle = cbk->cycle();
38 if (
cycle >= minCycle &&
cycle <= maxCycle ){ cbks.push_back(cbk); }
40 const std::size_t nCBK = cbks.size();
43 const std::string histTitle = histName +
", minCycle=" + std::to_string(minCycle)
44 +
", maxCycle=" + std::to_string(maxCycle);
45 ::TH1* resultHist = new ::TH1D( histName.c_str(), histTitle.c_str(),
48 resultHist->GetXaxis()->SetTitle(
"CutBookkeeper Name");
49 resultHist->GetYaxis()->SetTitle(
"nAcceptedEvents");
52 for (std::size_t i=0; i<nCBK; ++i){
56 const std::string&
name = cbk->
name();
57 const int binIdx =
static_cast<int>(i+1);
58 resultHist->SetBinContent(binIdx,
nEvents);
59 resultHist->SetBinError(binIdx,
error);
60 resultHist->GetXaxis()->SetBinLabel(binIdx,
name.c_str());
75 const std::vector<size_t> &otherIndexMap )
79 std::find(contToUpdate.
begin(), contToUpdate.
end(), old);
80 if (matchIter != contToUpdate.
end()) {
87 std::find(otherCont.
begin(), otherCont.
end(), old);
88 if (matchIter != contToUpdate.
end()) {
89 std::size_t
pos = matchIter - otherCont.
begin();
90 return contToUpdate[otherIndexMap[
pos]];
109 std::size_t origSize = contToUpdate->
size();
112 std::vector<std::size_t> otherIndexMap(otherCont->
size());
115 for (std::size_t i = 0; i < otherCont->
size(); ++i) {
119 bool foundEBKToUpdate{
false};
120 for (std::size_t j = 0; j < contToUpdate->
size(); ++j) {
125 otherIndexMap[i] = j;
126 foundEBKToUpdate =
true;
130 if (!foundEBKToUpdate) {
135 std::size_t ebIdx = newEBK->
index();
136 otherIndexMap[i] = ebIdx;
141 for (std::size_t i = origSize; i < contToUpdate->
size(); ++i) {
155 std::vector<xAOD::CutBookkeeper *> newChildren;
156 for ( std::size_t oldIdx = 0; oldIdx < ebkToModify->
nChildren(); ++oldIdx) {
158 newChildren.push_back(resolveLink(oldEBK,
166 std::vector<xAOD::CutBookkeeper *> newOthers;
167 for (std::size_t oldIdx = 0; oldIdx < ebkToModify->
nUsedOthers(); ++oldIdx) {
169 newOthers.push_back(resolveLink(oldEBK,
177 std::vector<xAOD::CutBookkeeper*> newSiblings;
178 for (std::size_t oldIdx = 0; oldIdx < ebkToModify->
nSiblings(); ++oldIdx) {
180 newSiblings.push_back(resolveLink(oldEBK,
double cycle(double a, double b)
DataModel_detail::const_iterator< DataVector > const_iterator
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.
DataModel_detail::iterator< DataVector > iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void makePrivateStore()
Create a new (empty) private store for this object.
bool usingPrivateStore() const
Test to see if this object is currently using a private store.
void releasePrivateStore()
Release and free any private store associated with this object.
size_t index() const
Return the index of this element within its container.
int maxCycle() const
Get the maximum cycle number of any xAOD::CutBookkeepers in the container.
std::size_t nSiblings() const
Check if this CutBookkeeper has siblings.
void setPayload(const Payload &payload)
Set the whole payload object (which contains all counters) in one go.
const xAOD::CutBookkeeper_v1 * usedOther(std::size_t i) const
Get the usedOther at position i.
bool isEqualTo(const CutBookkeeper_v1 *eb) const
Test for the equality of this CutBookkeeper with another one.
std::size_t nChildren() const
Get the number of children CutBookkeepers of this CutBookkeeper.
const xAOD::CutBookkeeper_v1 * parent() const
Get the parent CutBookkeeper.
void setUsedOthers(const std::vector< CutBookkeeper_v1 * > &usedOthers)
Set all CutBookkeeper that are used by this one in one go.
const xAOD::CutBookkeeper_v1 * child(std::size_t i) const
Get the child at position i.
void setParent(const CutBookkeeper_v1 *parentEB)
Set the parent CutBookkeeper of this CutBookkeeper.
Payload payload() const
Get the whole payload object (which contains all counters) in one go.
const std::string & name() const
Get the name of this CutBookkeeper.
const xAOD::CutBookkeeper_v1 * sibling(std::size_t i) const
Get the sibling number i.
uint64_t nAcceptedEvents() const
Get the number of accepted events that this CutBookkeeper has seen.
void setChildren(const std::vector< CutBookkeeper_v1 * > &childrenEB)
Set all children of this CutBookkeeper in one go.
void setSiblings(const std::vector< CutBookkeeper_v1 * > &siblings)
Set all CutBookkeeper that are siblings to this one in one go.
std::size_t nUsedOthers() const
Check if this CutBookkeeper has used others.
bool hasParent() const
Check if there is a parent CutBookkeeper of this CutBookkeeper.
::TH1 * nAcceptedEvents(const xAOD::CutBookkeeperContainer *cbkCont, const std::string &histName, int minCycle=0, int maxCycle=-1)
Make a histogram of the number of accepted events from a container.
void updateContainer(xAOD::CutBookkeeperContainer *contToUpdate, const xAOD::CutBookkeeperContainer *otherCont)
Helper function to update a container with information from another one.
CutBookkeeper_v1 CutBookkeeper
Define the latest version of the CutBookkeeper class.
CutBookkeeperContainer_v1 CutBookkeeperContainer
Define the latest version of the CutBookkeeperContainer class.