ATLAS Offline Software
FFJetSmearingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*************************************************************************************\
6  * *
7  * Name: FFJetSmearingTool *
8  * Purpose: Perform a jet mass smearing using Forward Folding. *
9  * This tool allows the user to stimate the JMS & JMR *
10  * systematics uncertainities. *
11  * *
12  * Note: normally used for JMR uncertainties since the *
13  * JMS is done using the JetUncertainties tool. *
14  * *
15 \*************************************************************************************/
16 
22 
23 // Local includes
25 
26 // Other includes
28 
29 namespace CP {
30 
31 
32  // Constructor
34  : asg::AsgTool(name)
35  , m_isInit(false)
36  , m_release("")
37  , m_truth_jetColl("")
38  , m_EtaRange(0)
39  , m_calibArea("CalibArea-08")
40  , m_histFileName("")
41  {
42  declareProperty("MassDef",m_MassDef_string = "");
43  declareProperty("MCType",m_MCType_string = "");
44  declareProperty("ConfigFile",m_configFile = ""); // Path to the config file, by default it points to XXX
45  declareProperty("Path",m_path);
46  }
47 
48 
49  // Destructor
51 
52 
53  // Initialize
55  // Ensure it hasn't been initialized already
56  if (m_isInit){
57  ATH_MSG_FATAL(Form("Blocking re-initialization of tool named %s",AsgTool::name().c_str())); //AsgTool::name() calls the name
58  return StatusCode::FAILURE;
59  }
60 
61  ATH_MSG_INFO(Form("Preparing to initialize the FFJetSmearingTool named %s",AsgTool::name().c_str()));
62 
63  if (AsgTool::name().empty()){
64  ATH_MSG_FATAL("No name specified. Aborting.");
65  return StatusCode::FAILURE;
66  }
67 
68  if (m_MassDef_string.empty()){
69  ATH_MSG_FATAL("No jet mass type specified. Aborting.");
70  return StatusCode::FAILURE;
71  }
72 
73  if (m_MCType_string.empty()){
74  ATH_MSG_FATAL("No MC campaign specified. Aborting.");
75  return StatusCode::FAILURE;
76  }
77 
78  // Make sure we have a valid mass definition
79  ATH_CHECK(JetTools::stringToEnum(m_MassDef_string, m_MassDef)); //If it fails it means that there is No Systematic Uncertainties derived for to the given mass definition.
80  //The mass definition should be 'Calo', 'TA' or 'Comb'. Show an error and exits.
81 
82  //reading the config file as in JetUncertaintiesTool
83  TEnv settings;
84 
85  const TString configFilePath = jet::utils::findFilePath(m_configFile.c_str(),m_path.c_str(),m_calibArea.c_str());
86 
87  if (settings.ReadFile( configFilePath.Data(),kEnvGlobal)){
88  ATH_MSG_ERROR("Cannot read config file: " << configFilePath.Data());
89  return StatusCode::FAILURE;
90  }
91  // We can read it - start printing
92  ATH_MSG_INFO("================================================");
93  ATH_MSG_INFO(Form(" Initializing the FFJetSmearingTool named %s",AsgTool::name().c_str()));
94  ATH_MSG_INFO(" Configuration file: " << m_configFile);
95  ATH_MSG_INFO(" Location: " << configFilePath.Data());
96 
97  m_release = settings.GetValue("UncertaintyRelease","UNKNOWN");
98  ATH_MSG_INFO(" Uncertainty release: " << m_release.c_str());
99 
100  // Check the jet definition
101  m_truth_jetColl = settings.GetValue("TruthJetColl","");
102  if (m_truth_jetColl.empty()){
103  ATH_MSG_ERROR("Cannot find the truth jet collection to use in config");
104  return StatusCode::FAILURE;
105  }
106  ATH_MSG_INFO(" Truth Jet Collection: " << m_truth_jetColl);
107 
108  // Check the name of the truth label accessor for BoostjetTaggers
109  m_truthlabelaccessor = settings.GetValue("TruthLabelAccessor","");
110  if (m_truthlabelaccessor.empty()){
111  ATH_MSG_ERROR("Cannot find the TruthLabelAccessor to use in config");
112  return StatusCode::FAILURE;
113  }
114  ATH_MSG_INFO(" Truth Label Accessor: " << m_truthlabelaccessor);
115 
116  // Check the MC campaign
117  m_supportedmctypes = settings.GetValue("SupportedMCTypes","");
118  if (m_supportedmctypes.empty()){
119  ATH_MSG_ERROR("Cannot find the SupportedMCTypes to use in config");
120  return StatusCode::FAILURE;
121  }
122  ATH_MSG_INFO(" Supported MC types: " << m_supportedmctypes);
123  // Protection for the MCType
124  if (m_supportedmctypes.find(m_MCType_string)!=std::string::npos){
125  ATH_MSG_INFO(" You are running with MC type: " << m_MCType_string);
126  }else{
127  ATH_MSG_ERROR("You are not running with a supported MC type");
128  return StatusCode::FAILURE;
129  }
130 
131  // Eta range of the tool
132  m_EtaRange = settings.GetValue("EtaRange",0);
133  if (m_EtaRange == 0){
134  ATH_MSG_ERROR("Cannot find the EtaRange parameter in the config file");
135  return StatusCode::FAILURE;
136  }
137  ATH_MSG_INFO(" EtaRange : Abs(eta) < " << m_EtaRange);
138 
139  // Mass range of the tool
140  m_MaxMass = settings.GetValue("MaxMass",0);
141  if (m_MaxMass == 0){
142  ATH_MSG_ERROR("Cannot find the MaxMass parameter in the config file");
143  return StatusCode::FAILURE;
144  }
145  ATH_MSG_INFO(" MaxMass : jet_mass < " << m_MaxMass);
146 
147  // Pt range of the tool
148  m_MaxPt = settings.GetValue("MaxPt",0);
149  if (m_MaxPt == 0){
150  ATH_MSG_ERROR("Cannot find the MaxPt parameter in the config file");
151  return StatusCode::FAILURE;
152  }
153  ATH_MSG_INFO(" MaxPt : jet_pt < " << m_MaxPt);
154 
155  // Get the file to read uncertainties in from
156  m_histFileName = settings.GetValue("UncertaintyRootFile","");
158  if (m_histFileName.empty()){
159  ATH_MSG_ERROR("Cannot find uncertainty histogram file in the config file");
160  return StatusCode::FAILURE;
161  }
162  ATH_MSG_INFO(" UncertaintyFile: " << m_histFileName);
163  ATH_MSG_INFO(" Location: " << m_HistogramsFilePath);
164 
165  // Read all the histogram files where the jms jmr variations are saved
166  // If fail, it shows an Error message and exits
168 
169  // Add the affecting systematics to the global registry
171  if (registry.registerSystematics(*this) != StatusCode::SUCCESS){
172  ATH_MSG_ERROR("Unable to register systematics!");
173  return StatusCode::FAILURE;
174  }
175 
176  m_isInit = true;
177 
178  // ANA_CHECK (applySystematicVariation (CP::SystematicSet()));
179 
180  return StatusCode::SUCCESS;
181  }
182 
183 
184  //-----------------------------------------------------------------------------
185  // Declare affecting systematics
186  //-----------------------------------------------------------------------------
187 
189  // Using 'find' is sufficient until this tool supports continuous
190  // // variations, at which point I'll need to use the 'match' method.
192  return sys.find(systematic) != sys.end();
193  }
194 
195  //-----------------------------------------------------------------------------
196 
199  result.insert(m_SysList);
200 
201  return result;
202  }
203 
204  //-----------------------------------------------------------------------------
205 
207  CP::SystematicSet filteredSysts;
208 
209  // Take only Calo-like uncertainties
211  for (auto ci = m_SysList.begin(); ci != m_SysList.end(); ci++){
212  if ((*ci).basename().find("CALO_")!=std::string::npos){
213  filteredSysts.insert(*ci);
214  }
215  }
216  return filteredSysts;
217  }
218 
219  // Take only TA-like uncertainties
221  for (auto ci = m_SysList.begin(); ci != m_SysList.end(); ci++){
222  if ((*ci).basename().find("TA_") !=std::string::npos){
223  filteredSysts.insert(*ci);
224  }
225  }
226  return filteredSysts;
227  }
228 
229  // Take only Comb-like uncertainties
231  for (auto ci = m_SysList.begin(); ci != m_SysList.end(); ci++){
232  if ((*ci).basename().find("COMB_")!=std::string::npos){
233  filteredSysts.insert(*ci);
234  }
235  }
236  return filteredSysts;
237  }
238 
239  // Take only UFO-like uncertainties
241  for (auto ci = m_SysList.begin(); ci != m_SysList.end(); ci++){
242  if ((*ci).basename().find("JET_JMRUnc_")!=std::string::npos){
243  filteredSysts.insert(*ci);
244  }
245  }
246  return filteredSysts;
247  }
248 
249  return m_SysList;
250  }
251 
252 
253  //-----------------------------------------------------------------------------
254  // Apply systematic configuration
255  //-----------------------------------------------------------------------------
256 
258  // First check if we already know this systematic configuration.
259  // Look for it in our sysData map.
260  auto iter = m_sysData.find (systematics);
261 
262  // If this is a new input set, we need to filter it.
263  if (iter == m_sysData.end()){
264  // Filter the input systematics with my affecting systematics.
265  const CP::SystematicSet affectingSysts = affectingSystematics();
266  CP::SystematicSet filteredSysts;
267  if ( CP::SystematicSet::
268  filterForAffectingSystematics(systematics, affectingSysts, filteredSysts) != StatusCode::SUCCESS ){
269  ATH_MSG_ERROR("Received unsupported systematics: " << systematics.name());
270  return StatusCode::FAILURE;
271  }
272 
273  // At this point, we can do some additional checks for consistency
274  // with the JMS/JMR functionality. For example, if the tool can only handle
275  // one type of systematic at a time, we return an error if the filtered
276  // set has more than one item:
277  if (filteredSysts.size() > 1){
278  ATH_MSG_ERROR("No support for more than one JMS/JMR sys at a time: " << filteredSysts.name());
279  return StatusCode::FAILURE;
280  }
281 
282  // Insert the new systematic data onto our map
283  SysData myData;
284 
285  const CP::SystematicVariation& sys = *filteredSysts.begin();
286 
287  myData.SysParameter = sys.parameter(); //Up (+1) and Down (-1) systematic variation
288  myData.SysBaseName = sys.basename(); //Name of the systematic variation
289 
290  iter = m_sysData.emplace (systematics, myData).first;
291  }
292 
293  // Apply the filtered systematics
294  m_currentSysData = &iter->second;
295 
296  return StatusCode::SUCCESS;
297  }
298 
299 
300  //-----------------------------------------------------------------------------
301  // Read the external file that conatins the JSS recomendations for FatJets
302  //-----------------------------------------------------------------------------
303 
305  std::unique_ptr<TFile> data_file ( TFile::Open(m_HistogramsFilePath.c_str()));
306  if (!data_file || data_file->IsZombie()){
307  ATH_MSG_FATAL( "Could not open the first input file: " << m_HistogramsFilePath );
308  return StatusCode::FAILURE;
309  }
310 
311  // Check whether we need the ResponseMap or not
312  m_doGaussianSmearing = settings.GetValue("doGaussianSmearing",true);
313  ATH_MSG_INFO(" doGaussianSmearing: " << m_doGaussianSmearing);
314 
316  TString CaloResponseMap_path = settings.GetValue("CaloResponseMap","");
317 
318  if (CaloResponseMap_path.IsNull()){
319  ATH_MSG_ERROR("Cannot find the CaloResponseMap in the config file");
320  return StatusCode::FAILURE;
321  }
322 
323  m_CALO_ResponseMap = std::unique_ptr<TH2>(dynamic_cast<TH2*>(data_file->Get( CaloResponseMap_path )));
324  m_CALO_ResponseMap->SetDirectory(nullptr);
325 
326  ATH_MSG_INFO(" ResponseMap: " << CaloResponseMap_path);
327  }
328 
330  TString TAResponseMap_path = settings.GetValue("TAResponseMap","");
331 
332  if (TAResponseMap_path.IsNull()){
333  ATH_MSG_ERROR("Cannot find the TAResponseMap in the config file");
334  return StatusCode::FAILURE;
335  }
336 
337  m_TA_ResponseMap = std::unique_ptr<TH2>(dynamic_cast<TH2*>(data_file->Get( TAResponseMap_path )));
338  m_TA_ResponseMap->SetDirectory(nullptr);//To keep it open when we close the .root file
339 
340  ATH_MSG_INFO(" ResponseMap: " << TAResponseMap_path);
341  }
342 
344  TString UFOResponseMap_path = settings.GetValue("UFOResponseMap","");
345 
346  if (UFOResponseMap_path.IsNull()){
347  ATH_MSG_ERROR("Cannot find the UFOResponseMap in the config file");
348  return StatusCode::FAILURE;
349  }
350 
351  m_UFO_ResponseMap = std::unique_ptr<TH2>(dynamic_cast<TH2*>(data_file->Get( UFOResponseMap_path )));
352  m_UFO_ResponseMap->SetDirectory(nullptr);
353 
354  ATH_MSG_INFO(" ResponseMap: " << UFOResponseMap_path);
355  }
356 
357  // JMS systematics
358  for (size_t iComp = 0; iComp < 999; ++iComp){
359 
360  const TString prefix = Form("JMSComponent.%zu.",iComp);
361  std::string Syst_Name = settings.GetValue(prefix+"Name","");
362 
363  if (!Syst_Name.empty()){
364 
365  m_SysList.insert( CP::SystematicVariation(Syst_Name, 1) );
366  m_SysList.insert( CP::SystematicVariation(Syst_Name, -1) );
367  m_Syst_MassDefAffected_map[Syst_Name] = settings.GetValue(prefix+"MassDef","");
368  m_Syst_TopologyAffected_map[Syst_Name] = settings.GetValue(prefix+"Topology","");
369  m_Syst_Affects_JMSorJMR[Syst_Name] = "JMS";
370  m_Syst_HistPath_map[Syst_Name] = settings.GetValue(prefix+"Hist","");
371 
372  // Processing the input histogram name
373  m_Syst_Hist_map[Syst_Name] = std::unique_ptr<TH2>(dynamic_cast<TH2*>(data_file->Get(m_Syst_HistPath_map[Syst_Name].c_str())));
374  m_Syst_Hist_map[Syst_Name]->SetDirectory(nullptr);
375 
376  // For Comb mass we need to read two histograms
378  m_Syst_HistTAPath_map[Syst_Name] = settings.GetValue(prefix+"HistTA","");
379  if (!m_Syst_HistTAPath_map[Syst_Name].empty()){
380  m_Syst_HistTA_map[Syst_Name] = std::unique_ptr<TH2>(dynamic_cast<TH2*>(data_file->Get(m_Syst_HistTAPath_map[Syst_Name].c_str())));
381  m_Syst_HistTA_map[Syst_Name]->SetDirectory(nullptr);
382  }
383  }
384 
385  }
386  }
387 
388  // JMR Systematics
389  for (size_t iComp = 0; iComp < 999; ++iComp){
390 
391  const TString prefix = Form("JMRComponent.%zu.",iComp);
392  std::string Syst_Name = settings.GetValue(prefix+"Name","");
393 
394  std::string to_find = "MCTYPE";
395  std::string to_replace = m_MCType_string;
396  replaceAllOccurrences(Syst_Name, to_find, to_replace);
397 
398  if (!Syst_Name.empty()){
399 
400  m_SysList.insert( CP::SystematicVariation(Syst_Name, 1) );
401  m_SysList.insert( CP::SystematicVariation(Syst_Name, -1) );
402  m_Syst_MassDefAffected_map[Syst_Name] = settings.GetValue(prefix+"MassDef","");
403  m_Syst_TopologyAffected_map[Syst_Name] = settings.GetValue(prefix+"Topology","");
404  m_Syst_Affects_JMSorJMR[Syst_Name] = "JMR";
405  m_Syst_HistPath_map[Syst_Name] = settings.GetValue(prefix+"Hist","");
406  m_Syst_uncertparam[Syst_Name] = settings.GetValue(prefix+"Param","");
407 
408  replaceAllOccurrences(m_Syst_HistPath_map[Syst_Name], to_find, to_replace);
409 
410  // Processing the input histogram name
411  if (m_Syst_uncertparam[Syst_Name] == "PtAbsMass"){
412  m_Syst_Hist_map[Syst_Name] = std::unique_ptr<TH2>(dynamic_cast<TH2*>(data_file->Get(m_Syst_HistPath_map[Syst_Name].c_str())));
413  m_Syst_Hist_map[Syst_Name]->SetDirectory(nullptr);
414  }else if (m_Syst_uncertparam[Syst_Name] == "eLOGmOeAbsEta"){
415  m_Syst_Hist_map3d[Syst_Name] = std::unique_ptr<TH3F>(dynamic_cast<TH3F*>(data_file->Get(m_Syst_HistPath_map[Syst_Name].c_str())));
416  m_Syst_Hist_map3d[Syst_Name]->SetDirectory(nullptr);
417  }
418 
419  // For Comb mass we need to read two histograms
421  m_Syst_HistTAPath_map[Syst_Name] = settings.GetValue(prefix+"HistTA","");
422  if (!m_Syst_HistTAPath_map[Syst_Name].empty()){
423  if (m_Syst_uncertparam[Syst_Name] == "PtAbsMass"){
424  m_Syst_HistTA_map[Syst_Name] = std::unique_ptr<TH2>(dynamic_cast<TH2*>(data_file->Get(m_Syst_HistTAPath_map[Syst_Name].c_str())));
425  m_Syst_HistTA_map[Syst_Name]->SetDirectory(nullptr);
426  }else if (m_Syst_uncertparam[Syst_Name] == "eLOGmOeAbsEta"){
427  m_Syst_HistTA_map3d[Syst_Name] = std::unique_ptr<TH3F>(dynamic_cast<TH3F*>(data_file->Get(m_Syst_HistTAPath_map[Syst_Name].c_str())));
428  m_Syst_HistTA_map3d[Syst_Name]->SetDirectory(nullptr);
429  }
430  }
431  }
432 
433  }
434  }
435 
436  data_file->Close();
437 
438  // Skip for UFO -> Read the Calo and TA mass weight histograms from the same file that JetUncertainties uses
440 
441  TString Calo_TA_weight_file_name = settings.GetValue("JetUncertainties_UncertaintyRootFile","");
442  const TString Calo_TA_weight_file_path = jet::utils::findFilePath(Calo_TA_weight_file_name.Data(),m_path.c_str(),m_calibArea.c_str());
443 
444  if (Calo_TA_weight_file_path.IsNull()){
445  ATH_MSG_ERROR("Cannot find the file with the Calo and TA weights");
446  return StatusCode::FAILURE;
447  }
448 
449  TString Calo_weight_hist_name = settings.GetValue("CombMassWeightCaloHist","");
450  if (Calo_weight_hist_name.IsNull()){
451  ATH_MSG_ERROR("Cannot find the histogram name that contains the Calo weights in the config file");
452  return StatusCode::FAILURE;
453  }
454 
455  TString TA_weight_hist_name = settings.GetValue("CombMassWeightTAHist","");
456  if (TA_weight_hist_name.IsNull()){
457  ATH_MSG_ERROR("Cannot find the histogram name that contains the TA weights in the config file");
458  return StatusCode::FAILURE;
459  }
460 
461  ATH_MSG_INFO(Form(" Calo weights hist: \"%s\"",Calo_weight_hist_name.Data()));
462  ATH_MSG_INFO(Form(" TA weights hist: \"%s\"",TA_weight_hist_name.Data()));
463  ATH_MSG_INFO(Form(" Location: %s",Calo_TA_weight_file_path.Data()));
464 
465 
466  std::unique_ptr<TFile> Calo_TA_weight_file ( TFile::Open(Calo_TA_weight_file_path));
467  if (!Calo_TA_weight_file || Calo_TA_weight_file->IsZombie()){
468  ATH_MSG_FATAL( "Could not open the first input file: " << Calo_TA_weight_file_path );
469  return StatusCode::FAILURE;
470  }
471 
472  m_caloMassWeight = std::unique_ptr<TH3F>(dynamic_cast<TH3F*>(Calo_TA_weight_file->Get(Calo_weight_hist_name)));
473  m_TAMassWeight = std::unique_ptr<TH3F>(dynamic_cast<TH3F*>(Calo_TA_weight_file->Get(TA_weight_hist_name)));
474 
475  m_caloMassWeight->SetDirectory(nullptr);
476  m_TAMassWeight->SetDirectory(nullptr);//To keep it open when we close the .root file
477 
478 
479  Calo_TA_weight_file->Close();
480 
481  }
482 
483  return StatusCode::SUCCESS;
484  }
485 
486 
487  //-----------------------------------------------------------------------------
488  // The function "getMatchedTruthJet" finds the truth jet that match with the given jet_reco and it save it in the given jet_truth_matched jet.
489  //-----------------------------------------------------------------------------
490 
492 
493  // Get the truth jets of the event
494  const xAOD::JetContainer* jets_truth = nullptr;
495 
496  ATH_CHECK(evtStore()->retrieve(jets_truth,m_truth_jetColl));//If fail, it means that we are "Unable to retrieve jetColl Info". It shows an Error message and exits
497 
498  double dRmax_truthJet = 0.75;// matching condition
499  double dRmin=9999; //we will take the closest jet reco-truth
500 
501  //Loop over the truth jets in the event to match
502  const xAOD::Jet* close_jet = nullptr;
503  for (const auto *const jet_truth : *jets_truth){
504  float dR_Test = jet_reco.p4().DeltaR(jet_truth->p4());
505  if (dR_Test < dRmax_truthJet){
506  if (dR_Test < dRmin){
507  close_jet = jet_truth;
508  dRmin = dR_Test;
509  }
510  }
511  }
512  if (dRmin > 999){ return StatusCode::FAILURE;}
513 
514  jet_truth_matched.setJetP4(close_jet->jetP4());
515  return StatusCode::SUCCESS;
516  }
517 
518 
519  //-----------------------------------------------------------------------------
520  // The function "getJetTopology" gets the topology of the given jet. "QCD" jets have a extra source of uncertainties called "MODELLINGUNCERTAINTIESQCDJETS".
521  //-----------------------------------------------------------------------------
522 
523  StatusCode FFJetSmearingTool::getJetTopology( xAOD::Jet& jet_reco, std::string& jetTopology) const{
525  if (!accTruthLabel.isAvailable(jet_reco) )
526  {
527  ATH_MSG_ERROR("Unable to retrieve the FatjetTruthLabel from the jet. Please call the BoostedJetTaggers decorateTruthLabel() function before calling this function.");
528  return StatusCode::FAILURE;
529  }
530 
531  LargeRJetTruthLabel::TypeEnum jetTruthLabel = LargeRJetTruthLabel::intToEnum(accTruthLabel(jet_reco));
532 
533  if (jetTruthLabel == LargeRJetTruthLabel::tqqb || jetTruthLabel == LargeRJetTruthLabel::other_From_t){
534  jetTopology="Top";
535  }else if (jetTruthLabel == LargeRJetTruthLabel::Wqq || jetTruthLabel == LargeRJetTruthLabel::Zqq || jetTruthLabel == LargeRJetTruthLabel::Wqq_From_t || jetTruthLabel == LargeRJetTruthLabel::other_From_V){
536  jetTopology="V";
537  }else if (jetTruthLabel == LargeRJetTruthLabel::qcd){
538  jetTopology="QCD";
539  }else if (jetTruthLabel == LargeRJetTruthLabel::Hbb || jetTruthLabel == LargeRJetTruthLabel::other_From_H){
540  jetTopology="H";
541  }else if (jetTruthLabel == LargeRJetTruthLabel::notruth){
542  jetTopology="no_match";
543  ATH_MSG_DEBUG("No truth jet match with this reco jet. The jet will not be smeared.");
544  }else{
545  jetTopology="QCD"; // We should never arrive here
546  }
547 
548  ATH_MSG_VERBOSE("The topology of this jet correspond to a " << jetTopology << " large-R jet");
549 
550  return StatusCode::SUCCESS;
551  }
552 
553 
554  //-----------------------------------------------------------------------------
555  // The function "getJMSJMR" read the JMS and JMR uncertainties associated with the systematic
556  //-----------------------------------------------------------------------------
557 
558  StatusCode FFJetSmearingTool::getJMSJMR( xAOD::Jet& jet_reco, double jet_mass_value, JetTools::FFJetAllowedMassDefEnum MassDef_of_syst, const std::string& jetTopology, double& JMS_err, double& JMR_err) const{
559 
560  // JMS/JMR systematic variations
561  JMS_err = 0;
562  JMR_err = 0;
563 
564  // Some variables to simplify the logic in the "if" structure found below
569 
570  auto massAffectedSys = m_Syst_MassDefAffected_map.at(m_currentSysData->SysBaseName);
571  auto topologyAffected = m_Syst_TopologyAffected_map.at(m_currentSysData->SysBaseName);
572  auto uncertparam = m_Syst_uncertparam.at(m_currentSysData->SysBaseName);
573 
574  if (massAffectedSys == JetTools::enumToString(MassDef_of_syst) || massAffectedSys == JetTools::enumToString(comb) ){
575  ATH_MSG_VERBOSE("This uncertainty affects to the " << JetTools::enumToString(MassDef_of_syst) << " mass");
576  }else{ // Only apply the systematic to the proper mass definition
577  return StatusCode::SUCCESS;
578  }
579 
580  if (topologyAffected != "All" && !TString(topologyAffected).Contains(jetTopology)){
581  ATH_MSG_VERBOSE("The systematic does not affect to this jet topology");
582  return StatusCode::SUCCESS;
583  }
584 
585  float jet_mass = jet_mass_value*m_MeVtoGeV; // jet_reco->m()*m_MeVtoGeV; The TA mass can not be extracted this way
586  float jet_pT = jet_reco.pt()*m_MeVtoGeV;
587 
589 
590  JMR_err = 0;
591 
592  const TH2* hist = nullptr; // This variable will contain the pointer to the proper histogram to use in the interpolation
593 
594  // TA and Calo mass defs take values from one hisogram only
595  if (massAffectedSys == JetTools::enumToString(calo) || massAffectedSys == JetTools::enumToString(ta) ){
597  }else if (massAffectedSys == JetTools::enumToString(comb) ){ // Comb mass defs can take values from two histograms, depending ifits Calo- or TA- part is affected
598  if (MassDef_of_syst == calo){
600  }else if (MassDef_of_syst == ta){
602  }
603  }
604  JMS_err = FFJetSmearingTool::Interpolate2D(hist, jet_pT, jet_mass) * m_currentSysData->SysParameter;
605 
606  }else if (m_Syst_Affects_JMSorJMR.at(m_currentSysData->SysBaseName) == "JMR"){
607 
608  JMS_err = 0;
609 
610  const TH2* hist = nullptr;
611  const TH3F* hist3d = nullptr;
612 
613  // TA and Calo mass defs take values from one hisogram only
614  if (massAffectedSys == JetTools::enumToString(calo) || massAffectedSys == JetTools::enumToString(ta) || massAffectedSys == JetTools::enumToString(ufo)){
615  if (uncertparam == "eLOGmOeAbsEta"){
616  hist3d = m_Syst_Hist_map3d.at(m_currentSysData->SysBaseName).get();
617  }else{ // Usually, uncertparam == "PtAbsMass"
619  }
620  }else if (massAffectedSys == JetTools::enumToString(comb) ){ // Comb mass defs can take values from two histograms, depending ifits Calo- or TA- part is affected
621  if (MassDef_of_syst == calo){
622  if (uncertparam == "eLOGmOeAbsEta"){
623  hist3d = m_Syst_Hist_map3d.at(m_currentSysData->SysBaseName).get();
624  }else{ // Usually, uncertparam == "PtAbsMass"
626  }
627  }else if (MassDef_of_syst == ta){
628  if (uncertparam == "eLOGmOeAbsEta"){
630  }else{ // Usually, uncertparam == "PtAbsMass"
632  }
633  }
634  }
635 
636  if (uncertparam == "eLOGmOeAbsEta"){
637  JMR_err = FFJetSmearingTool::Read3DHistogram(hist3d, jet_reco.e()*m_MeVtoGeV, TMath::Log(jet_reco.m()/jet_reco.e()), std::abs(jet_reco.eta())) * m_currentSysData->SysParameter;
638  }else{ // uncertparam == "PtAbsMass"
639  JMR_err = FFJetSmearingTool::Interpolate2D(hist, jet_pT, jet_mass) * m_currentSysData->SysParameter;
640  }
641 
642  }
643 
644  ATH_MSG_DEBUG("Systematic applied: " << m_currentSysData->SysBaseName);
645 
646  ATH_MSG_VERBOSE("JMS_err: " << JMS_err);
647  ATH_MSG_VERBOSE("JMR_err: " << JMR_err);
648 
649  return StatusCode::SUCCESS;
650  }
651 
652 
653  //-----------------------------------------------------------------------------
654  // Once the tool is initialized. The user can call the function "SmearJetMass" to perform the jet smearing using FF (for the current systematic in his loop)
655  //-----------------------------------------------------------------------------
656 
658 
659  ATH_MSG_VERBOSE("//---------------------------------------------------------------//");
660  ATH_MSG_VERBOSE("Reco Jet to Smear: pt = " << jet_reco.pt() << ", mass = " << jet_reco.m() << ", eta = " << jet_reco.eta());
661 
662  if (std::abs(jet_reco.eta()) > m_EtaRange){//JetCalibTools do not properly for jets with |eta|>2
663  ATH_MSG_DEBUG("This jet exceeds the eta range that the tool allows (|eta|<" << m_EtaRange << ")");
665  }
666  if (jet_reco.m() > m_MaxMass){
667  ATH_MSG_DEBUG("This jet exceeds the mass range that the tool allows jet_mass <" << m_MaxMass << " MeV)");
669  }
670  if (jet_reco.pt() > m_MaxPt){
671  ATH_MSG_DEBUG("This jet exceeds the maximum pt that the tool allows jet_pt <" << m_MaxPt << " MeV)");
673  }
674 
675  // Find matched truth jet
676  xAOD::Jet jet_truth_matched;
677  jet_truth_matched.makePrivateStore();
678 
679  if (!(getMatchedTruthJet(jet_reco, jet_truth_matched).isSuccess())){
680  ATH_MSG_VERBOSE("No truth jet match with this reco jet. The jet will not be smeared.");
682  }
683 
684  ATH_MSG_VERBOSE("Matched truth Jet: pt = " << jet_truth_matched.pt() << ", mass = " << jet_truth_matched.m() << ", eta = " << jet_truth_matched.eta());
685 
686  // Get the jet topology
687  std::string jetTopology;
688 
689  if (!(getJetTopology( jet_reco, jetTopology)).isSuccess()){
690  ATH_MSG_ERROR("Imposible to obtain the jetTopology");
692  }
693  if (jetTopology == "no_match"){
695  }
696 
697  // The TA mass is saved in an attribute so you can not access to it using ->m(). (if calibrated as Calo mass and not as Combined Mass), The Calo mass is not set as an attribute so you can not access it using ->getAttribute.
698 
699  double jet_mass_UFO = 0;
700  double jet_mass_CALO = 0;
701  double jet_mass_TA = 0;
702  double calo_mass_weight=1; // m_comb = Weight*m_Calo + (1-Weight)*m_TA
703 
704  float JetTrackAssistedMassCalibrated_from_JetCalibTools;
705 
707 
708  xAOD::JetFourMom_t jet_reco_CALO;
709  xAOD::JetFourMom_t jet_reco_TA;
710  xAOD::JetFourMom_t jet_reco_Comb;
711 
712  jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCalo",jet_reco_CALO);
713  jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumTA",jet_reco_TA);
714  jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCombQCD",jet_reco_Comb);
715 
716  ATH_MSG_VERBOSE("CALO jet mass " << jet_reco_CALO.mass());
717  ATH_MSG_VERBOSE("TA jet mass " << jet_reco_TA.mass() );
718  ATH_MSG_VERBOSE("Comb jet mass " << jet_reco_Comb.mass() );
719 
720  jet_mass_CALO = jet_reco_CALO.mass();
721  jet_mass_TA = jet_reco_TA.mass();
722  jet_reco.getAttribute<float>("JetTrackAssistedMassCalibrated", JetTrackAssistedMassCalibrated_from_JetCalibTools);
723 
725  jet_mass_CALO = jet_reco.m();
726  calo_mass_weight = 1;
728  jet_mass_TA = jet_reco.m();
729  jet_reco.getAttribute<float>("JetTrackAssistedMassCalibrated", JetTrackAssistedMassCalibrated_from_JetCalibTools);
730  calo_mass_weight = 0;
732  jet_mass_UFO = jet_reco.m();
733  calo_mass_weight = 1;
734  }
735 
736  // Obtain the average mass response of the jet. The response will depend in the chosed topology (top, W or QCD) and also in the mass definition (CALO, TA, Combined). By default the map used correspond to QCD jets
737 
738  double avg_response_UFO=1;
739  double avg_response_CALO=1;
740  double avg_response_TA=1;
741 
743  avg_response_CALO = FFJetSmearingTool::Interpolate2D(m_CALO_ResponseMap.get(), jet_reco.pt()*m_MeVtoGeV, jet_truth_matched.m()*m_MeVtoGeV);
744  if (avg_response_CALO == 0) avg_response_CALO=1; // If we look outside the Th2 histogram, we would obtain 0, so we apply the nominal response (1)
745  }
746 
748  avg_response_TA = FFJetSmearingTool::Interpolate2D(m_TA_ResponseMap.get(), jet_reco.pt()*m_MeVtoGeV, jet_truth_matched.m()*m_MeVtoGeV);
749  if (avg_response_TA == 0) avg_response_TA = 1; // If we look outside the Th2 histogram, we would obtain 0, so we apply the nominal response (1)
750  }
751 
753  avg_response_UFO = FFJetSmearingTool::Interpolate2D(m_UFO_ResponseMap.get(), jet_reco.pt()*m_MeVtoGeV, jet_truth_matched.m()*m_MeVtoGeV);
754  if (avg_response_UFO == 0) avg_response_UFO = 1; // If we look outside the Th2 histogram, we would obtain 0, so we apply the nominal response (1)
755  }
756 
757  // Obtain the jet mass scale (JMS) and the jet mass resolution (JMR) nominal values and variation that correspond to the jet_reco
758 
759  double JMS(1), JMS_err(0), JMR(1), JMR_err(0);
760  double scale;
761  double resolution;
762 
763  double smeared_UFO_mass = jet_mass_UFO;
764  double smeared_CALO_mass = jet_mass_CALO;
765  double smeared_TA_mass = jet_mass_TA;
766 
767  bool is_UFO_mass_smeared = false;
768  bool is_CALO_mass_smeared = false;
769  bool is_TA_mass_smeared = false;
770 
772 
773  if (!(getJMSJMR(jet_reco, jet_mass_CALO, JetTools::FFJetAllowedMassDefEnum::Calo, jetTopology, JMS_err, JMR_err)).isSuccess()){
774  return CP::CorrectionCode::Ok;
775  }
776 
777  scale = JMS + JMS_err;
778  resolution = JMR + JMR_err;
779 
780  if (TMath::Abs(scale-1) > 0.0001 || TMath::Abs(resolution-1) > 0.0001){
781  is_CALO_mass_smeared = true;
782 
783  ATH_MSG_VERBOSE("Forward Folding CALO procedure will use scale=" << scale << ", resolution=" << resolution << " and average respose=" << avg_response_CALO);
784 
785  //FF procedure
786  smeared_CALO_mass = jet_mass_CALO * scale + (jet_mass_CALO - avg_response_CALO*jet_truth_matched.m())*(resolution-scale); // FF formula
787  }
788 
789  }
790 
792 
793  if (!(getJMSJMR(jet_reco, jet_mass_TA, JetTools::FFJetAllowedMassDefEnum::TA, jetTopology, JMS_err, JMR_err))){
794  return CP::CorrectionCode::Ok;
795  }
796 
797  scale = JMS + JMS_err;
798  resolution = JMR + JMR_err;
799 
800  if (TMath::Abs(scale-1) > 0.0001 || TMath::Abs(resolution-1) > 0.0001){
801 
802  is_TA_mass_smeared = true;
803 
804  ATH_MSG_VERBOSE("Forward Folding TA procedure will use scale=" << scale << ", resolution=" << resolution << " and average respose=" << avg_response_TA);
805 
806  //FF procedure
807  smeared_TA_mass = jet_mass_TA * scale + (jet_mass_TA - avg_response_TA*jet_truth_matched.m())*(resolution-scale); // FF formula
808  }
809 
810  }
811 
813 
814  if (!(getJMSJMR(jet_reco, jet_mass_UFO, JetTools::FFJetAllowedMassDefEnum::UFO, jetTopology, JMS_err, JMR_err)).isSuccess()){
815  return CP::CorrectionCode::Ok;
816  }
817 
818  scale = JMS + JMS_err;
819  resolution = JMR + JMR_err;
820 
821  if (TMath::Abs(scale-1) > 0.0001 || TMath::Abs(resolution-1) > 0.0001){
822  is_UFO_mass_smeared = true;
823 
824  ATH_MSG_VERBOSE("Forward Folding UFO procedure will use scale=" << scale << ", resolution=" << resolution << " and average respose=" << avg_response_UFO);
825 
826  //FF procedure
827  smeared_UFO_mass = jet_mass_UFO * scale + (jet_mass_UFO - avg_response_UFO*jet_truth_matched.m())*(resolution-scale); // FF formula
828  }
829 
830  }
831 
832  // We only smear the jet if we have to. If not, avoid doing extra calculations
833  if (!is_CALO_mass_smeared && !is_TA_mass_smeared && !is_UFO_mass_smeared){
834  ATH_MSG_VERBOSE("This jet is not affected by the systematic. The jet won't be modified");
835  ATH_MSG_VERBOSE("//---------------------------------------------------------------//");
836 
837  return CP::CorrectionCode::Ok;
838  }
839 
840  // Recalculate the weights after the smearing
841  if (m_MassDef == JetTools::FFJetAllowedMassDefEnum::Comb && JetTrackAssistedMassCalibrated_from_JetCalibTools != 0 && jet_mass_CALO != 0){
842  //we check that JetTrackAssistedMassCalibrated_from_JetCalibTools != 0 instead of jet_mass_TA != 0 becuase
843  //there is a problem in the conversion between the mass itself and the four-vector representation (due to a
844  //limitation of floating). This makes the value of jet_mass_TA!=0 in situations where it should be 0.
845  //In order to work arround it we check JetTrackAssistedMassCalibrated_from_JetCalibTools != 0 insead.
846  double caloRes;
847  double TARes;
848 
849  xAOD::JetFourMom_t jet_reco_CALO;
850  xAOD::JetFourMom_t jet_reco_TA;
851 
852  jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumCalo",jet_reco_CALO);
853  jet_reco.getAttribute<xAOD::JetFourMom_t>("JetJMSScaleMomentumTA",jet_reco_TA);
854 
855  xAOD::JetFourMom_t p4_aux;
856 
857  //The smearing do not change the pt but it changes the mass (so the energy too) so, if we want to perform the smearing properly, we have to change
858  //the Calo and TA four momenta before looking at the weights map
859  p4_aux = xAOD::JetFourMom_t(jet_reco_CALO.pt(),jet_reco_CALO.eta(),jet_reco_CALO.phi(),smeared_CALO_mass);//The smearing do not change the pt but it changes the Energy
860  jet_reco_CALO = p4_aux;
861 
862  p4_aux = xAOD::JetFourMom_t(jet_reco_TA.pt(),jet_reco_TA.eta(),jet_reco_TA.phi(),smeared_TA_mass);
863  jet_reco_TA = p4_aux;
864 
865  caloRes=FFJetSmearingTool::Read3DHistogram(m_caloMassWeight.get() ,jet_reco_CALO.e()*m_MeVtoGeV,TMath::Log(jet_reco_CALO.M()/jet_reco_CALO.e()),std::abs(jet_reco_CALO.eta()));
866 
867  TARes=FFJetSmearingTool::Read3DHistogram(m_TAMassWeight.get() ,jet_reco_TA.e()*m_MeVtoGeV,TMath::Log(jet_reco_TA.M()/jet_reco_TA.e()),std::abs(jet_reco_TA.eta()));
868 
869  //The histograms with the weights that we are reading were defined with the code "e_LOGmOe_eta" which means that each axis correspond to:
870  //-X: Jet Energy
871  //-Y: Log(Jet_Energy/Jet_mass)
872  //-Z:Eta
873  //Domain is [200-6000],[-6,0],[0,2] but, the ReadHistogram function put the value of the extream of the histogram to the values outside the domain.
874  //We have to use a custom "My_Interpolate" because the Z axis has just one bin (and this makes the Root Interpolate function fail)
875 
876  double caloFactor;
877  double TAFactor;
878 
879  if (caloRes == 0 ){
880  caloFactor = 0; TAFactor = 1;
881  }else if (TARes == 0){
882  caloFactor = 1; TAFactor = 0;
883  }else{
884  caloFactor = 1./(caloRes*caloRes);
885  TAFactor = 1./(TARes*TARes);
886  }
887 
888  calo_mass_weight = caloFactor /(caloFactor + TAFactor);
889 
890  ATH_MSG_VERBOSE(" Map Calo weight = " << calo_mass_weight );
891  ATH_MSG_VERBOSE(" Map TA weight = " << 1 - calo_mass_weight );
892  }else if (JetTrackAssistedMassCalibrated_from_JetCalibTools == 0){
893  calo_mass_weight = 1;
894  }else if (jet_mass_CALO == 0){
895  calo_mass_weight = 0;
896  }
897 
898  // Calculate the final smeared mass
899  double smeared_mass = 0;
901  smeared_mass = smeared_UFO_mass;
902  ATH_MSG_VERBOSE("Smeared UFO mass " << smeared_UFO_mass);
903  }else{
904  smeared_mass = calo_mass_weight*smeared_CALO_mass + (1 - calo_mass_weight)*smeared_TA_mass;
905  ATH_MSG_VERBOSE("Smeared CALO mass " << smeared_CALO_mass);
906  ATH_MSG_VERBOSE("Smeared TA mass " << smeared_TA_mass);
907  }
908 
909  xAOD::JetFourMom_t p4 = jet_reco.jetP4();
910 
911  p4 = xAOD::JetFourMom_t(jet_reco.pt(),jet_reco.eta(),jet_reco.phi(),smeared_mass);
912  jet_reco.setJetP4(p4);
913 
914  ATH_MSG_VERBOSE("Smeared Reco Jet: pt = " << jet_reco.pt() << ", mass = " << jet_reco.m() << ", eta = " << jet_reco.eta());
915 
916  ATH_MSG_VERBOSE("//---------------------------------------------------------------//");
917 
918  return CP::CorrectionCode::Ok;
919  }
920 
921 
922  // To apply the correction into a copied jet
924  xAOD::Jet* copy = new xAOD::Jet(input);
925 
926  // Call the implemented function
928  delete copy;
930  }
931  output = copy;
932  return CP::CorrectionCode::Ok;
933  }
934 
935 
936  // To apply the correction into all the jets inside a jet containter
939 
940  // Loop over the container
941  for (size_t iJet = 0; iJet < inputs.size(); ++iJet)
942  {
943  result = applyCorrection(*inputs.at(iJet));
945  break;
946  }
947  }
948  return result;
949  }
950 
951 
952  // Functions from JetUncertainties. We copy them in order to read the map exactly as it is done in JetUncertainties and get EXACTLY the same result
953  double FFJetSmearingTool::Read3DHistogram(const TH3* histo, double x, double y, double z) const{
954 
955  if (not histo){
956  ATH_MSG_ERROR("Histogram pointer is null in FFJetSmearingTool::Read3DHistogram");
957  return 0.;
958  }
959 
960  double aux_x = x;
961  double aux_y = y;
962  double aux_z = z;
963 
964  // Asymptotic values
965  //If the value is outside the histogram region, we take the closest value to that one
966 
967  double xMax = histo->GetXaxis()->GetBinLowEdge(histo->GetNbinsX()+1);
968  double xMin = histo->GetXaxis()->GetBinLowEdge(1);
969  double yMax = histo->GetYaxis()->GetBinLowEdge(histo->GetNbinsY()+1);
970  double yMin = histo->GetYaxis()->GetBinLowEdge(1);
971  double zMax = histo->GetZaxis()->GetBinLowEdge(histo->GetNbinsZ()+1);
972  double zMin = histo->GetZaxis()->GetBinLowEdge(1);
973 
974  if (x >= xMax) aux_x = xMax-1e-6 ; //so it fits the up-most x-bin
975  if (x <= xMin) aux_x = xMin+1e-6 ; //so it fits the low-most x-bin
976  if (std::isnan(y)) return 0; // no weight if the input is NaN, can happen for log(X)
977  if (y >= yMax) aux_y = yMax-1e-6 ; //so it fits the up-most y-bin
978  if (y <= yMin) aux_y = yMin+1e-6 ; //so it fits the low-most y-bin
979  if (z >= zMax) aux_z = zMax-1e-6 ; //so it fits the up-most z-bin
980  if (z <= zMin) aux_z = zMin+1e-6 ; //so it fits the low-most z-bin
981 
982  //Use the interpolate function from JetHelpers.cxx
983  double weight = JetHelpers::Interpolate(histo, aux_x, aux_y, aux_z);
984 
985  return weight;
986  }
987 
988 
989  // The function in JetHelpers can not be used because it needs a TH1 and we use TH2 histograms. We define our own function.
990  double FFJetSmearingTool::Interpolate2D(const TH2* histo, double x, double y) const{
991  if (not histo){
992  ATH_MSG_ERROR("Histogram pointer is null in FFJetSmearingTool::Interpolate2D");
993  return 0.;
994  }
995  Int_t bin_x = histo->GetXaxis()->FindFixBin(x);
996  Int_t bin_y = histo->GetYaxis()->FindFixBin(y);
997  if (bin_x<1 || bin_x>histo->GetNbinsX() || bin_y<1 || bin_y>histo->GetNbinsY()){
998  ATH_MSG_VERBOSE("The point is outside the histogram domain.");
999  return 0.;
1000  }
1001 
1002  double interpolated_value = JetHelpers::Interpolate(histo, x, y);
1003  return interpolated_value;
1004  }
1005 
1006 
1007  // Function to replace all occurrences of 'to_find' with 'to_replace' in 'str'
1008  void FFJetSmearingTool::replaceAllOccurrences(std::string& str, const std::string& to_find, const std::string& to_replace){
1009  size_t pos = 0;
1010  while ((pos = str.find(to_find, pos)) != std::string::npos){
1011  str.replace(pos, to_find.length(), to_replace);
1012  pos += to_replace.length(); // Move past the last replaced position
1013  }
1014  }
1015 
1016 
1017 } // namespace CP
CP::FFJetSmearingTool::m_path
std::string m_path
Definition: FFJetSmearingTool.h:171
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CP::FFJetSmearingTool::applyContainerCorrection
virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer &inputs) const override
Definition: FFJetSmearingTool.cxx:937
python.Dso.registry
registry
Definition: Control/AthenaServices/python/Dso.py:159
LargeRJetTruthLabel::TypeEnum
TypeEnum
Definition: LargeRJetLabelEnum.h:14
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CP::FFJetSmearingTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: FFJetSmearingTool.cxx:54
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
JetTools::FFJetAllowedMassDefEnum
FFJetAllowedMassDefEnum
Definition: FFJetSmearingTool.h:60
CP::FFJetSmearingTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override
List of all systematics affecting this tool.
Definition: FFJetSmearingTool.cxx:197
CP::FFJetSmearingTool::SysData
Definition: FFJetSmearingTool.h:202
get_generator_info.result
result
Definition: get_generator_info.py:21
CP::FFJetSmearingTool::m_Syst_Hist_map
std::map< std::string, std::unique_ptr< TH2 > > m_Syst_Hist_map
Definition: FFJetSmearingTool.h:192
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CP::FFJetSmearingTool::m_SysList
CP::SystematicSet m_SysList
Definition: FFJetSmearingTool.h:186
CP::FFJetSmearingTool::SysData::SysBaseName
std::string SysBaseName
Definition: FFJetSmearingTool.h:203
CP::FFJetSmearingTool::m_Syst_HistTAPath_map
std::map< std::string, std::string > m_Syst_HistTAPath_map
Definition: FFJetSmearingTool.h:194
LargeRJetLabelEnum.h
CP::FFJetSmearingTool::m_sysData
std::unordered_map< CP::SystematicSet, SysData > m_sysData
Definition: FFJetSmearingTool.h:206
CP::SystematicSet::size
size_t size() const
returns: size of the set
Definition: SystematicSet.h:71
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
plotmaker.hist
hist
Definition: plotmaker.py:148
CP::FFJetSmearingTool::m_Syst_Hist_map3d
std::map< std::string, std::unique_ptr< TH3F > > m_Syst_Hist_map3d
Definition: FFJetSmearingTool.h:193
CP::FFJetSmearingTool::m_isInit
bool m_isInit
Definition: FFJetSmearingTool.h:157
CP::FFJetSmearingTool::m_CALO_ResponseMap
std::unique_ptr< TH2 > m_CALO_ResponseMap
Definition: FFJetSmearingTool.h:176
FFJetSmearingTool.h
asg
Definition: DataHandleTestTool.h:28
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
LargeRJetTruthLabel::other_From_t
@ other_From_t
Definition: LargeRJetLabelEnum.h:22
JetTools::enumToString
TString enumToString(const FFJetAllowedMassDefEnum type)
Definition: FFJetSmearingTool.h:86
CP::SystematicSet::name
std::string name() const
returns: the systematics joined into a single string.
Definition: SystematicSet.cxx:278
CP::FFJetSmearingTool::m_histFileName
std::string m_histFileName
Definition: FFJetSmearingTool.h:166
xAOD::Jet_v1::jetP4
JetFourMom_t jetP4() const
The full 4-momentum of the particle : internal jet type.
Definition: Jet_v1.cxx:76
xAOD::Jet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: Jet_v1.cxx:54
CP::FFJetSmearingTool::m_Syst_HistPath_map
std::map< std::string, std::string > m_Syst_HistPath_map
Definition: FFJetSmearingTool.h:191
CP::FFJetSmearingTool::applyCorrection
virtual CP::CorrectionCode applyCorrection(xAOD::Jet &jet_reco) const override
Apply a systematic variation of get a new copy.
Definition: FFJetSmearingTool.cxx:657
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
CP::FFJetSmearingTool::m_currentSysData
SysData * m_currentSysData
Points to the current systematic configuration.
Definition: FFJetSmearingTool.h:208
LargeRJetTruthLabel::Zqq
@ Zqq
Definition: LargeRJetLabelEnum.h:20
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CP::SystematicVariation
Definition: SystematicVariation.h:47
CP::FFJetSmearingTool::readFFJetSmearingToolSimplifiedData
StatusCode readFFJetSmearingToolSimplifiedData(TEnv &settings)
Definition: FFJetSmearingTool.cxx:304
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
LargeRJetTruthLabel::qcd
@ qcd
Definition: LargeRJetLabelEnum.h:25
x
#define x
Dedxcorrection::resolution
double resolution[nGasTypes][nParametersResolution]
Definition: TRT_ToT_Corrections.h:46
empty
bool empty(TH1 *h)
Definition: computils.cxx:295
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
LargeRJetTruthLabel::Hbb
@ Hbb
Definition: LargeRJetLabelEnum.h:26
CP::FFJetSmearingTool::m_truth_jetColl
std::string m_truth_jetColl
Definition: FFJetSmearingTool.h:159
xAOD::Jet_v1::getAttribute
bool getAttribute(AttributeID type, T &value) const
Retrieve attribute moment by enum.
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
CP::FFJetSmearingTool::m_Syst_HistTA_map3d
std::map< std::string, std::unique_ptr< TH3F > > m_Syst_HistTA_map3d
Definition: FFJetSmearingTool.h:196
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
LargeRJetTruthLabel::notruth
@ notruth
Definition: LargeRJetLabelEnum.h:24
xAOD::Jet_v1::setJetP4
void setJetP4(const JetFourMom_t &p4)
Definition: Jet_v1.cxx:171
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
CP::FFJetSmearingTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override
Specify whether tool is affected by provided systematic.
Definition: FFJetSmearingTool.cxx:188
JetHelpers::Interpolate
double Interpolate(const TH1 *histo, const double x)
Definition: JetHelpers.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::FFJetSmearingTool::m_MCType_string
std::string m_MCType_string
Definition: FFJetSmearingTool.h:168
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
CP::FFJetSmearingTool::m_MaxPt
float m_MaxPt
Definition: FFJetSmearingTool.h:164
LargeRJetTruthLabel::Wqq
@ Wqq
Definition: LargeRJetLabelEnum.h:17
CP::FFJetSmearingTool::~FFJetSmearingTool
virtual ~FFJetSmearingTool()
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CP::FFJetSmearingTool::m_Syst_MassDefAffected_map
std::map< std::string, std::string > m_Syst_MassDefAffected_map
Definition: FFJetSmearingTool.h:189
CP::FFJetSmearingTool::m_MeVtoGeV
static constexpr float m_MeVtoGeV
Definition: FFJetSmearingTool.h:210
z
#define z
CP::FFJetSmearingTool::m_MassDef_string
std::string m_MassDef_string
Definition: FFJetSmearingTool.h:167
CP::FFJetSmearingTool::m_HistogramsFilePath
std::string m_HistogramsFilePath
Definition: FFJetSmearingTool.h:172
CP::FFJetSmearingTool::getMatchedTruthJet
StatusCode getMatchedTruthJet(xAOD::Jet &jet_reco, xAOD::Jet &jet_truth_matched) const
Definition: FFJetSmearingTool.cxx:491
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::FFJetSmearingTool::m_Syst_uncertparam
std::map< std::string, std::string > m_Syst_uncertparam
Definition: FFJetSmearingTool.h:198
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
CP::SystematicSet::end
const_iterator end() const
description: const iterator to the end of the set
Definition: SystematicSet.h:59
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CP::FFJetSmearingTool::Interpolate2D
double Interpolate2D(const TH2 *histo, double x, double y) const
Definition: FFJetSmearingTool.cxx:990
CP::FFJetSmearingTool::m_Syst_TopologyAffected_map
std::map< std::string, std::string > m_Syst_TopologyAffected_map
Definition: FFJetSmearingTool.h:190
CP::FFJetSmearingTool::correctedCopy
virtual CP::CorrectionCode correctedCopy(const xAOD::Jet &input, xAOD::Jet *&output) const override
Definition: FFJetSmearingTool.cxx:923
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::FFJetSmearingTool::m_EtaRange
float m_EtaRange
Definition: FFJetSmearingTool.h:162
CP::FFJetSmearingTool::m_truthlabelaccessor
std::string m_truthlabelaccessor
Definition: FFJetSmearingTool.h:160
CP::FFJetSmearingTool::m_Syst_HistTA_map
std::map< std::string, std::unique_ptr< TH2 > > m_Syst_HistTA_map
Definition: FFJetSmearingTool.h:195
CP::FFJetSmearingTool::m_doGaussianSmearing
bool m_doGaussianSmearing
Definition: FFJetSmearingTool.h:175
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: Jet_v1.cxx:49
JetTools::FFJetAllowedMassDefEnum::Calo
@ Calo
merge.output
output
Definition: merge.py:17
CP::FFJetSmearingTool::m_MaxMass
float m_MaxMass
Definition: FFJetSmearingTool.h:163
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition: JetTypes.h:17
LargeRJetTruthLabel::Wqq_From_t
@ Wqq_From_t
Definition: LargeRJetLabelEnum.h:21
CheckAppliedSFs.systematics
def systematics
Definition: CheckAppliedSFs.py:231
JetTools::FFJetAllowedMassDefEnum::TA
@ TA
Calorimeter.
CP::FFJetSmearingTool::getJetTopology
StatusCode getJetTopology(xAOD::Jet &jet_reco, std::string &jetTopology) const
Definition: FFJetSmearingTool.cxx:523
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CP::FFJetSmearingTool::m_UFO_ResponseMap
std::unique_ptr< TH2 > m_UFO_ResponseMap
Definition: FFJetSmearingTool.h:178
JetTools::stringToEnum
StatusCode stringToEnum(const TString &name, FFJetAllowedMassDefEnum &result)
Definition: FFJetSmearingTool.h:66
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
CP::FFJetSmearingTool::replaceAllOccurrences
void replaceAllOccurrences(std::string &str, const std::string &to_find, const std::string &to_replace)
Definition: FFJetSmearingTool.cxx:1008
CP::FFJetSmearingTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systematics) override
Configure tool to apply systematic variation.
Definition: FFJetSmearingTool.cxx:257
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CP::FFJetSmearingTool::m_release
std::string m_release
Definition: FFJetSmearingTool.h:158
CP::FFJetSmearingTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
List of all systematics recommended for this tool.
Definition: FFJetSmearingTool.cxx:206
CP::FFJetSmearingTool::m_Syst_Affects_JMSorJMR
std::map< std::string, std::string > m_Syst_Affects_JMSorJMR
Definition: FFJetSmearingTool.h:197
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::FFJetSmearingTool::m_configFile
std::string m_configFile
Definition: FFJetSmearingTool.h:170
CP::FFJetSmearingTool::FFJetSmearingTool
FFJetSmearingTool(const std::string &name)
Proper constructor for Athena.
Definition: FFJetSmearingTool.cxx:33
jet::utils::findFilePath
TString findFilePath(const TString &fileName, const TString &path="", const TString &calibArea="")
Definition: Reconstruction/Jet/JetUncertainties/Root/Helpers.cxx:99
xAOD::Jet_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: Jet_v1.cxx:71
xAOD::Jet_v1::m
virtual double m() const
The invariant mass of the particle.
Definition: Jet_v1.cxx:59
y
#define y
LargeRJetTruthLabel::other_From_V
@ other_From_V
Definition: LargeRJetLabelEnum.h:23
xAOD::Jet_v1::e
virtual double e() const
The total energy of the particle.
Definition: Jet_v1.cxx:63
CP::SystematicRegistry
This module implements the central registry for handling systematic uncertainties with CP tools.
Definition: SystematicRegistry.h:25
CP::SystematicSet::begin
const_iterator begin() const
description: const iterator to the beginning of the set
Definition: SystematicSet.h:55
LargeRJetTruthLabel::intToEnum
TypeEnum intToEnum(const int type)
Definition: LargeRJetLabelEnum.h:57
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
LargeRJetTruthLabel::other_From_H
@ other_From_H
Definition: LargeRJetLabelEnum.h:28
CP::FFJetSmearingTool::getJMSJMR
StatusCode getJMSJMR(xAOD::Jet &jet_reco, double jet_mass, JetTools::FFJetAllowedMassDefEnum MassDef_of_syst, const std::string &jetTopology, double &JMS_err, double &JMR_err) const
Definition: FFJetSmearingTool.cxx:558
CP::FFJetSmearingTool::m_TA_ResponseMap
std::unique_ptr< TH2 > m_TA_ResponseMap
Definition: FFJetSmearingTool.h:177
CP::FFJetSmearingTool::m_caloMassWeight
std::unique_ptr< TH3F > m_caloMassWeight
Definition: FFJetSmearingTool.h:181
CP::FFJetSmearingTool::m_supportedmctypes
std::string m_supportedmctypes
Definition: FFJetSmearingTool.h:161
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
str
Definition: BTagTrackIpAccessor.cxx:11
LargeRJetTruthLabel::tqqb
@ tqqb
Definition: LargeRJetLabelEnum.h:16
calibdata.copy
bool copy
Definition: calibdata.py:27
JetTools::FFJetAllowedMassDefEnum::Comb
@ Comb
Track Assisted.
CP::FFJetSmearingTool::m_calibArea
std::string m_calibArea
Definition: FFJetSmearingTool.h:165
CP::FFJetSmearingTool::SysData::SysParameter
float SysParameter
Definition: FFJetSmearingTool.h:204
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
CP::FFJetSmearingTool::Read3DHistogram
double Read3DHistogram(const TH3 *histo, double x, double y, double z) const
Definition: FFJetSmearingTool.cxx:953
xAOD::Jet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition: Jet_v1.cxx:44
CP::FFJetSmearingTool::m_MassDef
JetTools::FFJetAllowedMassDefEnum m_MassDef
Definition: FFJetSmearingTool.h:169
JetTools::FFJetAllowedMassDefEnum::UFO
@ UFO
Combined.
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
CP::FFJetSmearingTool::m_TAMassWeight
std::unique_ptr< TH3F > m_TAMassWeight
Definition: FFJetSmearingTool.h:182
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition: SystematicRegistry.cxx:25