31 StatusCode AsgCutBookkeeperAlg ::
37 return StatusCode::FAILURE;
46 float flt_channel_number{};
53 ANA_MSG_WARNING (
"MC channel number could not be read from the FileMetaData.");
63 if (tmd->
size() == 1) {
75 return StatusCode::SUCCESS;
80 StatusCode AsgCutBookkeeperAlg ::
91 float flt_channel_number{};
106 ANA_MSG_DEBUG (
"Complete cbk name: " << cbk->name() <<
" - stream: " << cbk->inputStream());
108 if (cbk->cycle() > maxCycle && cbk->name() ==
"AllExecutedEvents"
112 maxCycle = cbk->cycle();
116 if (allEvents ==
nullptr)
118 ANA_MSG_ERROR (
"Could not find AllExecutedEvents CutBookkeeper information.");
119 return StatusCode::FAILURE;
125 if (cbk->cycle() == maxCycle && cbk->name().find(
"AllExecutedEvents") == 0
128 static const std::regex
re (
"AllExecutedEvents.*_([0-9]+)");
132 if (std::regex_match(cbk->name(),
match,
re))
146 std::string cbkName =
"CutBookkeepers_weight_" + std::to_string(
index);
156 if (cbk->cycle() == maxCycle && cbk->name().find(
"AllExecutedEvents") == 0
167 ANA_MSG_WARNING (
"This sample does not support CutBookkeeper systematics. Disabling...");
173 return StatusCode::SUCCESS;
178 void AsgCutBookkeeperAlg ::
190 ANA_MSG_VERBOSE (
"Initial sum of weights squared = " << sumOfWeightsSquared);
193 it->second.nEventsProcessed += nEventsProcessed;
194 it->second.sumOfWeights += sumOfWeights;
195 it->second.sumOfWeightsSquared += sumOfWeightsSquared;
200 StatusCode AsgCutBookkeeperAlg ::
222 assert(
h !=
nullptr);
224 h->GetXaxis()->SetBinLabel (1,
"Initial events");
225 h->GetXaxis()->SetBinLabel (2,
"Initial sum of weights");
226 h->GetXaxis()->SetBinLabel (3,
"Initial sum of weights squared");
235 ANA_MSG_ERROR (
"No weight is available for CutBookkeeper histogram. \nDid you set skip-n-events > 0? This is a known issue in EventLoop.");
240 h->SetBinContent (1,
weights.nEventsProcessed);
241 h->SetBinContent (2,
weights.sumOfWeights);
242 h->SetBinContent (3,
weights.sumOfWeightsSquared);
245 return StatusCode::SUCCESS;
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
static const std::vector< std::string > systematics
Header file for AthHistogramAlgorithm.
StatusCode book(const TH1 &hist, const std::string &tDir="", const std::string &stream="")
Simplify the booking and registering (into THistSvc) of histograms.
TH1 * hist(const std::string &histName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered histograms of any type.
ServiceHandle< ISystematicsSvc > m_systematics
the systematics service
Gaudi::Property< uint32_t > m_runNumber
run number we are processing
uint32_t m_mcChannelNumber
MC channel number we are processing.
Gaudi::Property< bool > m_enableSystematics
flag to enable systematics
Gaudi::Property< std::string > m_histPattern
the pattern for histogram names
ToolHandle< PMGTools::IPMGTruthWeightTool > m_truthWeightTool
the truth weight tool
std::vector< std::string > m_allowed_streams
input streams that we can run the CutBookkeepers against
void processCutBookkeeper(const xAOD::CutBookkeeper *cbk, size_t index)
process a CutBookkeeper
std::unordered_map< size_t, WeightsGroup > m_weights
weights map
Class to wrap a set of SystematicVariations.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
ConstMetaStorePtr_t inputMetaStore() const
::StatusCode requestFileExecute()
register this algorithm to have an implementation of fileexecute
double sumOfEventWeightsSquared() const
Get the sum-of-(event-weights-squared) that this CutBookkeeper has seen.
double sumOfEventWeights() const
Get the sum-of-event-weights that this CutBookkeeper has seen.
uint64_t nAcceptedEvents() const
Get the number of accepted events that this CutBookkeeper has seen.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Select isolated Photons, Electrons and Muons.
std::string substitute(const std::string &str, const std::string &pattern, const std::string &with)
effects: substitute all occurences of "pattern" with "with" in the string "str" returns: the substitu...
TruthMetaDataContainer_v1 TruthMetaDataContainer
Declare the latest version of the truth vertex container.
CutBookkeeper_v1 CutBookkeeper
Define the latest version of the CutBookkeeper class.
FileMetaData_v1 FileMetaData
Declare the latest version of the class.
CutBookkeeperContainer_v1 CutBookkeeperContainer
Define the latest version of the CutBookkeeperContainer class.