107 const float minX = h_correction_2D->GetXaxis()->GetBinLowEdge(1);
108 const float maxX = h_correction_2D->GetXaxis()->GetBinLowEdge(h_correction_2D->GetNbinsX()+1);
109 const float minY = h_correction_2D->GetYaxis()->GetBinLowEdge(1);
110 const float maxY = h_correction_2D->GetYaxis()->GetBinLowEdge(h_correction_2D->GetNbinsY()+1);
113 else if (
x <= minX )
117 else if (
y <= minY )
121 correctionFactor = h_correction_2D->Interpolate(
x,
y);
123 return StatusCode::SUCCESS;
254 std::string showerModel;
258 TString MC2MC_CalibFile;
264 TObjArray *CalibFile_fields = MC2MC_CalibFile.Tokenize(
"_");
265 float n_fields = CalibFile_fields->GetEntries();
266 std::string new_showerModel = ((TObjString *)(CalibFile_fields->At(n_fields-1)))->String().Data();
267 new_showerModel.resize(new_showerModel.find(
".root"));
268 showerModel = std::move(new_showerModel);
272 std::string MC2MC_CalibFileTag =
m_config->GetValue(
"JPS_MC2MC.CalibFileTag",
"");
274 ATH_MSG_FATAL(
"At least one of the required parameters is not set, please check m_mcCampaign (" <<
m_mcCampaign <<
"), m_jetAlgo (" <<
m_jetAlgo <<
"), JPS_MC2MC.CalibFileTag (" << MC2MC_CalibFileTag <<
"), and showerModel (" << showerModel <<
")");
275 return StatusCode::FAILURE;
280 if (showerModel.starts_with(
"Pythia") || showerModel.starts_with(
"None")){
282 ATH_MSG_INFO(
"Will not perform MC2MC correction for this sample (Pythia or forced to None), but will write out the redundant jet scale " <<
m_outJetScale);
283 return StatusCode::SUCCESS;
287 ATH_MSG_FATAL(
"PathResolverFindCalibFile cannot find path to MC2MC CalibFile: " << MC2MC_CalibFile);
288 return StatusCode::FAILURE;
291 if (!inputFile || inputFile->IsZombie()){
292 ATH_MSG_FATAL(
"Cannot open MC2MC CalibFile, even though the m_correctionFilePath exists: " << MC2MC_CalibFile);
293 return StatusCode::FAILURE;
296 std::vector<int> considered_PIDs = {1,2,3,21};
297 bool doCjetCorrection =
m_config->GetValue(
"JPS_MC2MC.doCjetCorrection",
true);
299 considered_PIDs.push_back(4);
300 bool doBjetCorrection =
m_config->GetValue(
"JPS_MC2MC.doBjetCorrection",
true);
302 considered_PIDs.push_back(5);
305 for (
auto this_PID : considered_PIDs){
306 TString this_hist_name;
307 if(this_PID == 1 || this_PID == 2 || this_PID == 3){
308 this_hist_name =
"h_respMap_recoPt_recoY_q";
309 }
else if(this_PID == 4){
310 this_hist_name =
"h_respMap_recoPt_recoY_c";
311 }
else if(this_PID == 5){
312 this_hist_name =
"h_respMap_recoPt_recoY_b";
313 }
else if(this_PID == 21){
314 this_hist_name =
"h_respMap_recoPt_recoY_g";
316 ATH_MSG_FATAL(
"Requested PID " << this_PID <<
" is not supported for MC2MC correction, please contact JetETMiss.");
317 return StatusCode::FAILURE;
319 TH2* this_hist = (TH2*)inputFile->Get(this_hist_name);
321 ATH_MSG_FATAL(
"Failed to retrieve histogram: " << this_hist_name);
322 return StatusCode::FAILURE;
324 this_hist->SetName( (
"h_respMap_recoPt_recoY_"+std::to_string(this_PID)).c_str() );
325 this_hist->SetDirectory(0);
330 return StatusCode::SUCCESS;
338 nlohmann::json MC2MC_exceptions_DSID;
339 ATH_CHECK(
load_json(MC2MC_exceptions_DSID,
"JetCalibTools/MC2MC_exceptions_DSID.json") );
340 if( MC2MC_exceptions_DSID.contains(std::to_string(mcDSID)) ){
341 showerModel = MC2MC_exceptions_DSID[std::to_string(mcDSID)];
342 ATH_MSG_INFO(
"Sample DSID " << mcDSID <<
" is in the MC2MC_exceptions_DSID list, will be forcing the showerModel " << showerModel);
343 return StatusCode::SUCCESS;
346 if(generatorsInfo ==
""){
348 ATH_MSG_DEBUG(
"No generatorsInfo string provided, cannot parse showerModel.");
349 return StatusCode::SUCCESS;
353 TObjArray *generatorsInfo_fields = generatorsInfo.Tokenize(
"+");
354 float n_fields = generatorsInfo_fields->GetEntries();
355 std::string this_substr = ((TObjString *)(generatorsInfo_fields->At(n_fields-1)))->String().Data();
358 while( n_fields > 0 &&
359 (this_substr.starts_with(
"EvtGen") ||
360 this_substr.starts_with(
"Photos") ||
361 this_substr.starts_with(
"Tauola") ) ) {
362 generatorsInfo_fields->RemoveAt(n_fields-1);
365 if ( n_fields == 0 ){
366 ATH_MSG_FATAL(
"No valid PS/Had model found in generatorsInfo string: " << generatorsInfo);
367 return StatusCode::FAILURE;
370 this_substr = ((TObjString *)(generatorsInfo_fields->At(n_fields-1)))->String().Data();
372 std::string full_pshadInfo = this_substr;
375 std::string genType =
"";
376 std::string psType =
"";
377 std::string hadType =
"";
378 std::string version =
"";
379 if (this_substr.starts_with(
"Herwigpp")){
380 genType =
"Herwigpp";
383 }
else if (this_substr.starts_with(
"Herwig")){
387 }
else if (this_substr.starts_with(
"Sherpa")){
391 }
else if (this_substr.starts_with(
"Pythia8B")){
396 }
else if (this_substr.starts_with(
"Pythia")){
401 ATH_MSG_FATAL(
"No valid generator type found in generatorsInfo string: " << generatorsInfo);
402 return StatusCode::FAILURE;
406 this_substr = this_substr.substr(this_substr.find(
"(v.") + 3);
407 if( full_pshadInfo.starts_with(
"Pythia8") && !this_substr.starts_with(
"8")){
412 std::vector<std::string> version_exceptions = {
"alpha",
"p",
"bbb",
"atlas",
"beta",
")"};
413 for (
const auto& exception : version_exceptions) {
414 if (this_substr.find(exception) != std::string::npos) {
415 this_substr.resize(this_substr.find(exception));
420 this_substr.erase(
std::remove(this_substr.begin(), this_substr.end(),
'.'), this_substr.end());
423 version += this_substr;
426 showerModel = genType+
"-"+version+
"-"+psType+
"-"+hadType;
430 nlohmann::json MC2MC_showerRemap;
433 if( MC2MC_showerRemap.contains( genType+
"-"+version+
"-"+psType+
"-"+hadType ) ){
434 std::string replaced_showerModel = MC2MC_showerRemap[ genType+
"-"+version+
"-"+psType+
"-"+hadType ];
435 ATH_MSG_INFO(
"Sample with identified showerModel " << genType+
"-"+version+
"-"+psType+
"-"+hadType <<
" is in the MC2MC_showerRemap list, will be forcing the showerModel " << replaced_showerModel);
436 showerModel = std::move(replaced_showerModel);
437 }
else if (MC2MC_showerRemap.contains( genType+
"-"+version ) ){
438 std::string replaced_showerModel = MC2MC_showerRemap[ genType+
"-"+version ];
439 replaced_showerModel +=
"-"+psType+
"-"+hadType;
440 ATH_MSG_INFO(
"Sample with identified showerModel " << genType+
"-"+version+
"-"+psType+
"-"+hadType <<
" is in the MC2MC_showerRemap list, will be forcing the showerModel " << replaced_showerModel);
441 showerModel = std::move(replaced_showerModel);
444 return StatusCode::SUCCESS;
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.