17 size_t ExpPos =
str.find(
exp);
18 if (ExpPos == std::string::npos)
return str;
38 std::map<std::string, int> weight_names{};
42 return StatusCode::SUCCESS;
48 return StatusCode::FAILURE;
58 return StatusCode::SUCCESS;
62 const EventContext& ctx = Gaudi::Hive::currentContext();
64 setFilterPassed(
true);
67 if (!evtInfo.isValid()) {
69 return StatusCode::FAILURE;
74 int mc_channel = !isData ? evtInfo->mcChannelNumber() : 0.;
75 unsigned int run_number = evtInfo->runNumber();
77 std::string trigger_stream{};
82 return meta.run_number == run_number && meta.trigger_stream == trigger_stream;
85 ATH_MSG_WARNING(
"No meta data information is available for " <<
run_number <<
". Please check on which stream you're running");
89 itr->proc_events += 1;
90 itr->processed_blocks.insert(evtInfo->lumiBlock());
91 if (!itr->has_book_keeper) {
92 itr->total_lumi_blocks.insert(evtInfo->lumiBlock());
96 const unsigned int num_lhe = !
m_storeLHE ? 1 : evtInfo->mcEventWeights().size();
97 for (
unsigned int lhe_var = 0; lhe_var < num_lhe; ++lhe_var) {
100 return meta.mc_channel == mc_channel && meta.prw_channel == run_number && meta.variation_number == lhe_var;
104 <<
" lhe weight: " << lhe_var);
107 itr->weight_name =
"IncompleteMetaData";
108 itr->variation_number = lhe_var;
110 itr->proc_events += 1;
111 if (itr->has_book_keeper)
continue;
113 ATH_MSG_WARNING(
"Cut book keeper has not been loaded for sample DSID: "
114 << itr->mc_channel <<
" period: " << itr->prw_channel <<
" lhe variation: " << lhe_var);
117 itr->tot_events += 1;
118 const double weight = evtInfo->mcEventWeight(lhe_var);
124 return StatusCode::SUCCESS;
128 if (
inputMetaStore()->contains<xAOD::CutBookkeeperContainer>(
"CutBookkeepers")) {
131 ATH_MSG_WARNING(
"Could not retrieve the CutBookKeeperContainer. Although it should be there");
136 ATH_MSG_INFO(
"Check cutbook keeper "<<cbk->inputStream()<<
" name: "<<cbk->name()<<
" cycle: "<<cbk->cycle());
137 if (cbk->inputStream() ==
Stream && cbk->name() == cbk_name && cbk->cycle() > maxCycle) {
138 maxCycle = cbk->cycle();
142 }
else ATH_MSG_WARNING(
"The CutBookkeepers are not present in the file ");
143 if (!
all)
ATH_MSG_DEBUG(
"Failed to retrieve cut book keeper for Stream: "<<
Stream<<
" cbk_name: "<<cbk_name);
155 ATH_MSG_FATAL(
"The EventTypes() container of the EventStreamInfo is empty! Something wrong with the input file?");
156 return StatusCode::FAILURE;
164 ATH_MSG_WARNING(
"FileMetaData not found in input file, setting m_isDerivedAOD=false.");
169 ATH_MSG_WARNING(
"MetaDataType::dataType not found in xAOD::FileMetaData, setting m_isDerivedAOD=false.");
175 std::string cbk_stream{};
176 using namespace std::literals;
177 for (
const std::string & trial: {
"StreamAOD"s,
"StreamESD"s,
"unknownStream"s }) {
182 const bool contains_keeper =
all !=
nullptr;
183 if (!contains_keeper) {
188 std::string trigger_stream{};
193 return meta.run_number == run_number && trigger_stream == meta.trigger_stream;
202 for (
const auto& Lumi : esi->
getLumiBlockNumbers()) { itr->total_lumi_blocks.insert(Lumi); }
203 itr->has_book_keeper = contains_keeper;
204 if (contains_keeper) itr->tot_events +=
all->nAcceptedEvents();
210 std::vector<std::string> weight_names{};
212 std::map<std::string, int> weight_map{};
214 weight_names.resize(weight_map.size());
215 for (
const auto& w_pair : weight_map) { weight_names[w_pair.second] = w_pair.first; }
216 if (weight_names.empty()) {
218 weight_names.push_back(
"");
221 weight_names.push_back(
"");
223 for (
unsigned int lhe_var = 0; lhe_var < weight_names.size(); ++lhe_var) {
224 const std::string& lhe_weight = weight_names[lhe_var];
227 return meta.mc_channel == dsid && meta.prw_channel == run && meta.variation_number == lhe_var;
232 itr->weight_name = weight_names[lhe_var];
233 itr->variation_number = lhe_var;
239 std::vector<std::string> cb_names;
240 cb_names.emplace_back(lhe_weight);
243 cb_names.emplace_back(
"AllExecutedEvents_NonNominalMCWeight_" +
std::to_string(lhe_var));
244 for (
const std::string& cb_name : cb_names) {
253 itr->has_book_keeper = mc_keeper !=
nullptr;
255 if (itr->has_book_keeper) {
266 return StatusCode::FAILURE;
269 ATH_MSG_FATAL(
"Metadata is inconsistent with the configuration");
270 return StatusCode::FAILURE;
272 return StatusCode::SUCCESS;
286 tot_ev = meta.tot_events;
287 proc_ev = meta.proc_events;
288 stream_name = meta.trigger_stream;
289 tot_lumi = meta.total_lumi_blocks;
290 proc_lumi = meta.processed_blocks;
293 return StatusCode::SUCCESS;
314 mc_dsid = meta.mc_channel;
315 lhe_var = meta.variation_number;
317 prw_lumi = meta.prw_lumi;
319 sum_w2 = meta.sum_w_squared;
320 stream_name = meta.weight_name;
322 tot_ev = meta.tot_events;
323 proc_ev = meta.proc_events;
326 return StatusCode::SUCCESS;