17 size_t ExpPos =
str.find(
exp);
18 if (ExpPos == std::string::npos)
return str;
40 std::map<std::string, int> weight_names{};
44 return StatusCode::SUCCESS;
50 return StatusCode::FAILURE;
60 return StatusCode::SUCCESS;
64 const EventContext& ctx = Gaudi::Hive::currentContext();
66 setFilterPassed(
true);
69 if (!evtInfo.isValid()) {
71 return StatusCode::FAILURE;
76 int mc_channel = !
isData ? evtInfo->mcChannelNumber() : 0.;
77 unsigned int run_number = evtInfo->runNumber();
79 std::string trigger_stream{};
84 return meta.run_number == run_number && meta.trigger_stream == trigger_stream;
87 ATH_MSG_WARNING(
"No meta data information is available for " <<
run_number <<
". Please check on which stream you're running");
91 itr->proc_events += 1;
92 itr->processed_blocks.insert(evtInfo->lumiBlock());
93 if (!itr->has_book_keeper) {
94 itr->total_lumi_blocks.insert(evtInfo->lumiBlock());
98 const unsigned int num_lhe = !
m_storeLHE ? 1 : evtInfo->mcEventWeights().size();
99 for (
unsigned int lhe_var = 0; lhe_var < num_lhe; ++lhe_var) {
102 return meta.mc_channel == mc_channel && meta.prw_channel == run_number && meta.variation_number == lhe_var;
106 <<
" lhe weight: " << lhe_var);
109 itr->weight_name =
"IncompleteMetaData";
110 itr->variation_number = lhe_var;
112 itr->proc_events += 1;
113 if (itr->has_book_keeper)
continue;
115 ATH_MSG_WARNING(
"Cut book keeper has not been loaded for sample DSID: "
116 << itr->mc_channel <<
" period: " << itr->prw_channel <<
" lhe variation: " << lhe_var);
119 itr->tot_events += 1;
120 const double weight = evtInfo->mcEventWeight(lhe_var);
126 return StatusCode::SUCCESS;
130 if (
inputMetaStore()->contains<xAOD::CutBookkeeperContainer>(
"CutBookkeepers")) {
133 ATH_MSG_WARNING(
"Could not retrieve the CutBookKeeperContainer. Although it should be there");
138 ATH_MSG_INFO(
"Check cutbook keeper "<<cbk->inputStream()<<
" name: "<<cbk->name()<<
" cycle: "<<cbk->cycle());
139 if (cbk->inputStream() ==
Stream && cbk->name() == cbk_name && cbk->cycle() > maxCycle) {
140 maxCycle = cbk->cycle();
144 }
else ATH_MSG_WARNING(
"The CutBookkeepers are not present in the file ");
145 if (!
all)
ATH_MSG_DEBUG(
"Failed to retrieve cut book keeper for Stream: "<<
Stream<<
" cbk_name: "<<cbk_name);
157 ATH_MSG_FATAL(
"The EventTypes() container of the EventStreamInfo is empty! Something wrong with the input file?");
158 return StatusCode::FAILURE;
166 ATH_MSG_WARNING(
"FileMetaData not found in input file, setting m_isDerivedAOD=false.");
171 ATH_MSG_WARNING(
"MetaDataType::dataType not found in xAOD::FileMetaData, setting m_isDerivedAOD=false.");
177 std::string cbk_stream{};
178 for (std::string trial: {
"StreamAOD",
"StreamESD",
"unknownStream" }) {
183 const bool contains_keeper =
all !=
nullptr;
184 if (!contains_keeper) {
189 std::string trigger_stream{};
194 return meta.run_number == run_number && trigger_stream == meta.trigger_stream;
203 for (
const auto& Lumi : esi->
getLumiBlockNumbers()) { itr->total_lumi_blocks.insert(Lumi); }
204 itr->has_book_keeper = contains_keeper;
205 if (contains_keeper) itr->tot_events +=
all->nAcceptedEvents();
211 std::vector<std::string> weight_names{};
213 std::map<std::string, int> weight_map{};
215 weight_names.resize(weight_map.size());
216 for (
const auto& w_pair : weight_map) { weight_names[w_pair.second] = w_pair.first; }
217 if (weight_names.empty()) {
219 weight_names.push_back(
"");
222 weight_names.push_back(
"");
224 for (
unsigned int lhe_var = 0; lhe_var < weight_names.size(); ++lhe_var) {
225 const std::string& lhe_weight = weight_names[lhe_var];
228 return meta.mc_channel == dsid && meta.prw_channel == run && meta.variation_number == lhe_var;
233 itr->weight_name = weight_names[lhe_var];
234 itr->variation_number = lhe_var;
240 std::vector<std::string> cb_names;
241 cb_names.emplace_back(lhe_weight);
244 cb_names.emplace_back(
"AllExecutedEvents_NonNominalMCWeight_" +
std::to_string(lhe_var));
245 for (
const std::string& cb_name : cb_names) {
254 itr->has_book_keeper = mc_keeper !=
nullptr;
256 if (itr->has_book_keeper) {
267 return StatusCode::FAILURE;
270 ATH_MSG_FATAL(
"Metadata is inconsistent with the configuration");
271 return StatusCode::FAILURE;
273 return StatusCode::SUCCESS;
287 tot_ev = meta.tot_events;
288 proc_ev = meta.proc_events;
289 stream_name = meta.trigger_stream;
290 tot_lumi = meta.total_lumi_blocks;
291 proc_lumi = meta.processed_blocks;
294 return StatusCode::SUCCESS;
315 mc_dsid = meta.mc_channel;
316 lhe_var = meta.variation_number;
318 prw_lumi = meta.prw_lumi;
320 sum_w2 = meta.sum_w_squared;
321 stream_name = meta.weight_name;
323 tot_ev = meta.tot_events;
324 proc_ev = meta.proc_events;
327 return StatusCode::SUCCESS;