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;
133 return StatusCode::SUCCESS;
137 calibP4 =
jet.jetP4();
141 float correctionFactor = 1.0;
143 TH2* h_correction_2D =
nullptr;
144 float this_pt, this_eta;
146 this_pt =
jet.pt()/1000.;
148 this_eta = DetectorEtaAcc(
jet);
151 const float minY =
m_etaAxis.GetBinLowEdge(1);
153 this_eta = std::clamp(this_eta, minY, maxY);
155 int eta_bin =
m_etaAxis.FindBin(this_eta);
156 this_eta =
m_etaAxis.GetBinCenter(eta_bin);
159 this_pt =
jet.pt()/1000.;
160 this_eta = fabs(
jet.rapidity());
163 const float minY =
m_etaAxis.GetBinLowEdge(1);
165 this_eta = std::clamp(this_eta, minY, maxY);
167 int eta_bin =
m_etaAxis.FindBin(this_eta);
168 this_eta =
m_etaAxis.GetBinCenter(eta_bin);
170 this_pt =
jet.pt()/1000.;
171 this_eta = fabs(
jet.rapidity());
175 return StatusCode::SUCCESS;
176 int jet_PID = abs(PartonTruthLabelIDAcc(
jet));
181 h_correction_2D = correction_from_map->second;
185 if (h_correction_2D){
189 calibP4 *= correctionFactor;
191 jet.setJetP4(calibP4);
193 return StatusCode::SUCCESS;
264 std::string showerModel;
268 TString MC2MC_CalibFile;
274 TObjArray *CalibFile_fields = MC2MC_CalibFile.Tokenize(
"_");
275 float n_fields = CalibFile_fields->GetEntries();
276 std::string new_showerModel = ((TObjString *)(CalibFile_fields->At(n_fields-1)))->String().Data();
277 new_showerModel.resize(new_showerModel.find(
".root"));
278 showerModel = std::move(new_showerModel);
282 std::string MC2MC_CalibFileTag =
m_config->GetValue(
"JPS_MC2MC.CalibFileTag",
"");
284 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 <<
")");
285 return StatusCode::FAILURE;
290 if (showerModel.starts_with(
"Pythia") || showerModel.starts_with(
"None")){
292 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);
293 return StatusCode::SUCCESS;
297 ATH_MSG_FATAL(
"PathResolverFindCalibFile cannot find path to MC2MC CalibFile: " << MC2MC_CalibFile);
298 return StatusCode::FAILURE;
301 if (!inputFile || inputFile->IsZombie()){
302 ATH_MSG_FATAL(
"Cannot open MC2MC CalibFile, even though the m_correctionFilePath exists: " << MC2MC_CalibFile);
303 return StatusCode::FAILURE;
306 std::vector<int> considered_PIDs = {1,2,3,21};
307 bool doCjetCorrection =
m_config->GetValue(
"JPS_MC2MC.doCjetCorrection",
true);
309 considered_PIDs.push_back(4);
310 bool doBjetCorrection =
m_config->GetValue(
"JPS_MC2MC.doBjetCorrection",
true);
312 considered_PIDs.push_back(5);
315 for (
auto this_PID : considered_PIDs){
316 TString this_hist_name;
317 if(this_PID == 1 || this_PID == 2 || this_PID == 3){
318 this_hist_name =
"h_respMap_recoPt_recoY_q";
319 }
else if(this_PID == 4){
320 this_hist_name =
"h_respMap_recoPt_recoY_c";
321 }
else if(this_PID == 5){
322 this_hist_name =
"h_respMap_recoPt_recoY_b";
323 }
else if(this_PID == 21){
324 this_hist_name =
"h_respMap_recoPt_recoY_g";
326 ATH_MSG_FATAL(
"Requested PID " << this_PID <<
" is not supported for MC2MC correction, please contact JetETMiss.");
327 return StatusCode::FAILURE;
329 TH2* this_hist = (TH2*)inputFile->Get(this_hist_name);
331 ATH_MSG_FATAL(
"Failed to retrieve histogram: " << this_hist_name);
332 return StatusCode::FAILURE;
334 this_hist->SetName( (
"h_respMap_recoPt_recoY_"+std::to_string(this_PID)).c_str() );
335 this_hist->SetDirectory(0);
340 return StatusCode::SUCCESS;
348 nlohmann::json MC2MC_exceptions_DSID;
349 ATH_CHECK(
load_json(MC2MC_exceptions_DSID,
"JetCalibTools/MC2MC_exceptions_DSID.json") );
350 if( MC2MC_exceptions_DSID.contains(std::to_string(mcDSID)) ){
351 showerModel = MC2MC_exceptions_DSID[std::to_string(mcDSID)];
352 ATH_MSG_INFO(
"Sample DSID " << mcDSID <<
" is in the MC2MC_exceptions_DSID list, will be forcing the showerModel " << showerModel);
353 return StatusCode::SUCCESS;
356 if(generatorsInfo ==
""){
358 ATH_MSG_DEBUG(
"No generatorsInfo string provided, cannot parse showerModel.");
359 return StatusCode::SUCCESS;
363 TObjArray *generatorsInfo_fields = generatorsInfo.Tokenize(
"+");
364 float n_fields = generatorsInfo_fields->GetEntries();
365 std::string this_substr = ((TObjString *)(generatorsInfo_fields->At(n_fields-1)))->String().Data();
368 while( n_fields > 0 &&
369 (this_substr.starts_with(
"EvtGen") ||
370 this_substr.starts_with(
"Photos") ||
371 this_substr.starts_with(
"Tauola") ) ) {
372 generatorsInfo_fields->RemoveAt(n_fields-1);
375 if ( n_fields == 0 ){
376 ATH_MSG_FATAL(
"No valid PS/Had model found in generatorsInfo string: " << generatorsInfo);
377 return StatusCode::FAILURE;
380 this_substr = ((TObjString *)(generatorsInfo_fields->At(n_fields-1)))->String().Data();
382 std::string full_pshadInfo = this_substr;
385 std::string genType =
"";
386 std::string psType =
"";
387 std::string hadType =
"";
388 std::string version =
"";
389 if (this_substr.starts_with(
"Herwigpp")){
390 genType =
"Herwigpp";
393 }
else if (this_substr.starts_with(
"Herwig")){
397 }
else if (this_substr.starts_with(
"Sherpa")){
401 }
else if (this_substr.starts_with(
"Pythia8B")){
406 }
else if (this_substr.starts_with(
"Pythia")){
411 ATH_MSG_FATAL(
"No valid generator type found in generatorsInfo string: " << generatorsInfo);
412 return StatusCode::FAILURE;
416 this_substr = this_substr.substr(this_substr.find(
"(v.") + 3);
417 if( full_pshadInfo.starts_with(
"Pythia8") && !this_substr.starts_with(
"8")){
422 std::vector<std::string> version_exceptions = {
"alpha",
"p",
"bbb",
"atlas",
"beta",
")"};
423 for (
const auto& exception : version_exceptions) {
424 if (this_substr.find(exception) != std::string::npos) {
425 this_substr.resize(this_substr.find(exception));
430 this_substr.erase(
std::remove(this_substr.begin(), this_substr.end(),
'.'), this_substr.end());
433 version += this_substr;
436 showerModel = genType+
"-"+version+
"-"+psType+
"-"+hadType;
440 nlohmann::json MC2MC_showerRemap;
443 if( MC2MC_showerRemap.contains( genType+
"-"+version+
"-"+psType+
"-"+hadType ) ){
444 std::string replaced_showerModel = MC2MC_showerRemap[ genType+
"-"+version+
"-"+psType+
"-"+hadType ];
445 ATH_MSG_INFO(
"Sample with identified showerModel " << genType+
"-"+version+
"-"+psType+
"-"+hadType <<
" is in the MC2MC_showerRemap list, will be forcing the showerModel " << replaced_showerModel);
446 showerModel = std::move(replaced_showerModel);
447 }
else if (MC2MC_showerRemap.contains( genType+
"-"+version ) ){
448 std::string replaced_showerModel = MC2MC_showerRemap[ genType+
"-"+version ];
449 replaced_showerModel +=
"-"+psType+
"-"+hadType;
450 ATH_MSG_INFO(
"Sample with identified showerModel " << genType+
"-"+version+
"-"+psType+
"-"+hadType <<
" is in the MC2MC_showerRemap list, will be forcing the showerModel " << replaced_showerModel);
451 showerModel = std::move(replaced_showerModel);
454 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.