ATLAS Offline Software
TopEgammaCPTools.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 
7 #include <map>
8 #include <string>
9 
10 // Top includes
12 #include "TopEvent/EventTools.h"
13 
14 // PathResolver include(s):
16 
17 // Egamma include(s):
26 
27 #include "AsgTools/AnaToolHandle.h"
28 
29 namespace top {
30  EgammaCPTools::EgammaCPTools(const std::string& name) :
31  asg::AsgTool(name),
32  m_egammaCalibrationModel("es2022_R22_PRE"),
33  m_electronEffTriggerFile("SetMe"),
34  m_electronEffTriggerLooseFile("SetMe"),
35  m_electronEffSFTriggerFile("SetMe"),
36  m_electronEffSFTriggerLooseFile("SetMe"),
37  m_electronEffSFRecoFile("SetMe"),
38  m_electronEffSFIDFile("SetMe"),
39  m_electronEffSFIDLooseFile("SetMe"),
40  m_electronEffSFIsoFile("SetMe"),
41  m_electronEffSFIsoLooseFile("SetMe"),
42  m_electronEffSFChargeIDFile("SetMe"),
43  m_electronEffSFChargeIDLooseFile("SetMe"),
44  m_electronEffSFChargeMisIDFile("SetMe"),
45  m_electronEffSFChargeMisIDLooseFile("SetMe") {
46 // m_fwdElectronEffSFIDFile("SetMe"),
47 // m_fwdElectronEffSFIDLooseFile("SetMe") {
48  declareProperty("config", m_config);
49 
50  declareProperty("EgammaCalibrationAndSmearingTool", m_egammaCalibrationAndSmearingTool);
51  declareProperty("ElectronEffTrigger", m_electronEffTrigger);
52  declareProperty("ElectronEffTriggerLoose", m_electronEffTriggerLoose);
53  declareProperty("ElectronEffSFTrigger", m_electronEffSFTrigger);
54  declareProperty("ElectronEffSFTriggerLoose", m_electronEffSFTriggerLoose);
55  declareProperty("ElectronEffReco", m_electronEffSFReco);
56  declareProperty("ElectronEffID", m_electronEffSFID);
57  declareProperty("ElectronEffIDLoose", m_electronEffSFIDLoose);
58  declareProperty("ElectronEffIso", m_electronEffSFIso);
59  declareProperty("ElectronEffIsoLoose", m_electronEffSFIsoLoose);
60  declareProperty("ElectronEffChargeID", m_electronEffSFChargeID);
61  declareProperty("ElectronEffChargeIDLoose", m_electronEffSFChargeIDLoose);
62 
63  declareProperty("ElectronEffTriggerCorrModel", m_electronEffTriggerCorrModel);
64  declareProperty("ElectronEffTriggerLooseCorrModel", m_electronEffTriggerLooseCorrModel);
65  declareProperty("ElectronEffSFTriggerCorrModel", m_electronEffSFTriggerCorrModel);
66  declareProperty("ElectronEffSFTriggerLooseCorrModel", m_electronEffSFTriggerLooseCorrModel);
67  declareProperty("ElectronEffRecoCorrModel", m_electronEffSFRecoCorrModel);
68  declareProperty("ElectronEffIDCorrModel", m_electronEffSFIDCorrModel);
69  declareProperty("ElectronEffIDLooseCorrModel", m_electronEffSFIDLooseCorrModel);
70  declareProperty("ElectronEffIsoCorrModel", m_electronEffSFIsoCorrModel);
71  declareProperty("ElectronEffIsoLooseCorrModel", m_electronEffSFIsoLooseCorrModel);
72 
73  declareProperty("PhotonIsEMSelectorLoose", m_photonLooseIsEMSelector);
74  declareProperty("PhotonIsEMSelectorMedium", m_photonMediumIsEMSelector);
75  declareProperty("PhotonIsEMSelectorTight", m_photonTightIsEMSelector);
76 
77 // declareProperty("FwdElectronSelector", m_fwdElectronSelector);
78 // declareProperty("FwdElectronSelectorLoose", m_fwdElectronSelectorLoose);
79 // declareProperty("FwdElectronEffIDLoose", m_fwdElectronEffSFIDLoose);
80  }
81 
83  ATH_MSG_INFO("top::EgammaCPTools initialize...");
84 
85  if (m_config->isTruthDxAOD()) {
86  ATH_MSG_INFO("top::EgammaCPTools: no need to initialise anything on truth DxAOD");
87  return StatusCode::SUCCESS;
88  }
89 
90  if (m_config->usePhotons() || m_config->useElectrons() || m_config->useFwdElectrons()) {
91  if (m_config->makeAllCPTools()) {// skiping calibrations on mini-xAODs
92  if(m_config->egammaCalibration() != m_egammaCalibrationModel){
93  m_config->setPrintEgammaCalibModelWarning(true);
94  m_egammaCalibrationModel = m_config->egammaCalibration();
95  }
96  top::check(setupCalibration(), "Failed to setup Egamma calibration tools");
97  }
98  if (m_config->useFwdElectrons() && m_config->makeAllCPTools()) {
99  top::check(setupSelectors(), "Failed to setup Fwd electrons selectors tools");
100  }
101  if (m_config->isMC()) {// scale-factors are only for MC
102  top::check(setupScaleFactors(), "Failed to setup Egamma scale-factor tools");
103  }
104  } else {
105  ATH_MSG_INFO(
106  "top::EgammaCPTools: no need to initialise anything since using neither electrons nor fwd electrons nor photons");
107  }
108 
109  return StatusCode::SUCCESS;
110  }
111 
113  ATH_MSG_INFO("top::EgammaCPTools setupSelectors..");
114  if (m_config->useFwdElectrons()) {
115 // m_fwdElectronSelector = new AsgForwardElectronLikelihoodTool("CP::FwdElectronSelector");
116 // top::check(m_fwdElectronSelector->setProperty("ConfigFile",
117 // EgammaSelectors::ForwardLHPointToConfFile.at(
118 // m_config->fwdElectronID() + "LHForwardElectron")),
119 // "Failed to set config for AsgElectronFwdLikelihoodTool");
120 // top::check(m_fwdElectronSelector->initialize(), "Couldn't initialise Forward Electron LH ID Tool");
121 //
122 // m_fwdElectronSelectorLoose = new AsgForwardElectronLikelihoodTool("CP::FwdElectronSelectorLoose");
123 // top::check(m_fwdElectronSelectorLoose->setProperty("ConfigFile",
124 // EgammaSelectors::ForwardLHPointToConfFile.at(
125 // m_config->fwdElectronIDLoose() + "LHForwardElectron")),
126 // "Failed to set config for AsgElectronFwdLikelihoodTool");
127 // top::check(m_fwdElectronSelectorLoose->initialize(), "Couldn't initialise Forward Electron LH ID Loose Tool");
128 
129  }
130  return StatusCode::SUCCESS;
131  }
132 
134  // Setup electron and photon calibration tools
135  // List of tools include:
136  // - EgammaCalibrationAndSmearingTool
137  // - Electron Charge ID Selector tool
138  // - Photon shower shape fudge tool
139  // - Photon efficiency correction tool
140  using IEgammaCalibTool = CP::IEgammaCalibrationAndSmearingTool;
141  const std::string egamma_calib_name = "EgammaCalibrationAndSmearingTool";
142  if (asg::ToolStore::contains<IEgammaCalibTool>(egamma_calib_name)) {
143  m_egammaCalibrationAndSmearingTool = asg::ToolStore::get<IEgammaCalibTool>(egamma_calib_name);
144  } else {
145  IEgammaCalibTool* egammaCalibrationAndSmearingTool = new CP::EgammaCalibrationAndSmearingTool(egamma_calib_name);
146  top::check(asg::setProperty(egammaCalibrationAndSmearingTool,
147  "ESModel", m_egammaCalibrationModel),
148  "Failed to set ESModel for " + egamma_calib_name);
149  top::check(asg::setProperty(egammaCalibrationAndSmearingTool,
150  "decorrelationModel",
151  m_config->egammaSystematicModel()),
152  "Failed to set decorrelationModel for " + egamma_calib_name);
153 
154  if (m_config->forceRandomRunNumber() > 0) {
155  top::check(asg::setProperty(egammaCalibrationAndSmearingTool, "randomRunNumber", m_config->forceRandomRunNumber()), "Cannot set randomRunNumber for the egamma tools");
156  }
157 
158  top::check(asg::setProperty(egammaCalibrationAndSmearingTool,
159  "useFastSim", m_config->isAFII() ? 1 : 0),
160  "Failed to set useFastSim to true for" + egamma_calib_name);
161  top::check(egammaCalibrationAndSmearingTool->initialize(),
162  "Failed to initialize " + egamma_calib_name);
163  m_egammaCalibrationAndSmearingTool = egammaCalibrationAndSmearingTool;
164  }
165 
166  // The terribly named ElectronPhotonShowerShapeFudgeTool...
167  // We apply this only to photons to correct the shower shape
168  // This should only be applied on MC
169  using IFudgeTool = IElectronPhotonShowerShapeFudgeTool;
170  const std::string fudgeName = "PhotonFudgeTool";
171  m_photonFudgeTool = asg::AnaToolHandle<IElectronPhotonShowerShapeFudgeTool> ("ElectronPhotonVariableCorrectionTool/" + fudgeName);
172  if (!asg::ToolStore::contains<IFudgeTool>(fudgeName)) {
173  std::string configFilePath = "EGammaVariableCorrection/TUNE23/ElPhVariableNominalCorrection.conf";
174  ANA_CHECK(m_photonFudgeTool.setProperty("ConfigFile",configFilePath));
175  top::check(m_photonFudgeTool.initialize(), "Failed to initialize PhotonFudgeTool");
176  }
177 
178  // The photon efficiency SF tool
179  bool af2 = m_config->isAFII();
180  int data_type = 0; // Data
181  if (m_config->isMC()) {
182  if (af2) {
183  ATH_MSG_WARNING("PhotonEfficiencies - Currently there are no recommendations for FastSimulation photons");
184  ATH_MSG_WARNING("PhotonEfficiencies - Therefore we are advised to treat FastSim as FullSim for configuration");
185  //data_type = 3; // AF2
186  data_type = 1; // AF2 masquerading as full sim
187  } else {
188  data_type = 1; // Full sim
189  }
190  }
191 
192  using IPhotonEffTool = IAsgPhotonEfficiencyCorrectionTool;
193  const std::string photonSFName = "AsgPhotonEfficiencyCorrectionTool"; // to retrieve ID Eff scale factors
194  if (asg::ToolStore::contains<IPhotonEffTool>(photonSFName)) {
195  m_photonEffSF = asg::ToolStore::get<IPhotonEffTool>(photonSFName);
196  } else {
197  if (m_config->isMC()) { // Seem to only be able to setup the tool for MC
198  IPhotonEffTool* photonEffSF = new AsgPhotonEfficiencyCorrectionTool(photonSFName);
199  top::check(asg::setProperty(photonEffSF, "ForceDataType", data_type),
200  "Failed to set ForceDataType for " + photonSFName);
201  top::check(photonEffSF->initialize(),
202  "Failed to initialize " + photonSFName);
203  m_photonEffSF = photonEffSF;
204  }
205  }
206 
207  // https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/IsolationSF2016Moriond#Radiative_Z_low_ET
208  // To retrieve Isolation Eff scale factors
209  // N.B. Naming for isolation working points for AsgPhotonEfficiencyCorrectionTool isolation scale factors
210  // are different than those for the IsolationCorrectionTool (preceded by FixedCut)
211  std::set<std::string> photon_isolations = {
212  "Tight",
213  "Loose",
214  "TightCaloOnly"
215  };
216  for (const std::string& isoWP : photon_isolations) {
217  std::string photonIsoSFName = "AsgPhotonEfficiencyCorrectionTool_IsoSF" + isoWP;
218  if (!asg::ToolStore::contains<IPhotonEffTool>(photonIsoSFName)) {
219  if (m_config->isMC()) {
220  IPhotonEffTool* photonIsoSFTool = new AsgPhotonEfficiencyCorrectionTool(photonIsoSFName);
221  top::check(asg::setProperty(photonIsoSFTool, "ForceDataType", data_type),
222  "Failed to set ForceDataType for " + photonIsoSFName);
223  top::check(asg::setProperty(photonIsoSFTool, "IsoKey", isoWP),
224  "Failed to set IsoKey for " + photonIsoSFName);
225  top::check(photonIsoSFTool->initialize(),
226  "Failed to initialize " + photonIsoSFName);
227  m_photonIsoSFTools.push_back(photonIsoSFTool);
228  }
229  }
230  }
231  return StatusCode::SUCCESS;
232  }
233 
235  // Don't need for data, return SUCCESS straight away
236  if (!m_config->isMC()) return StatusCode::SUCCESS;
237 
239  std::string electron_data_dir = "ElectronEfficiencyCorrection/";
240 
241  // Define the data type variable - 0 : Data, 1 : MC FullSim, 3 : MC AFII
242  int dataType(0);
243  if (m_config->isMC()) {
244  dataType = (m_config->isAFII()) ? 3 : 1;
245  }
246 
248  std::string electronID = m_config->electronID();
249  if (electronID.find("LH") != std::string::npos) electronID.replace(electronID.find("LH"), 2, "LLH"); // that way people do not have to change their cuts file
250  std::string electronIDLoose = m_config->electronIDLoose();
251  if (electronIDLoose.find("LH") != std::string::npos) electronIDLoose.replace(electronIDLoose.find("LH"), 2, "LLH"); // that way people do not have to change their cuts file
252  std::string electronIsolation = mapWorkingPoints(m_config->electronIsolationSF()); // temporary fix: we can hopefully remove the map soon!
253  std::string electronIsolationLoose = mapWorkingPoints(m_config->electronIsolationSFLoose());
254 
255  if(electronIsolation == "PLImprovedTight" || electronIsolation == "PLImprovedVeryTight"){
256  if(!(electronID == "TightLLH" || electronID == "MediumLLH")){
257  ATH_MSG_ERROR("Combination of electron PLIV WP and ID WP not available. Try MediumLH or TightLH.");
258  return StatusCode::FAILURE;
259  }
260  }
261  if(electronIsolationLoose == "PLImprovedTight" || electronIsolationLoose == "PLImprovedVeryTight"){
262  if(!(electronIDLoose == "TightLLH" || electronIDLoose == "MediumLLH")){
263  ATH_MSG_ERROR("Combination of loose electron PLIV WP and ID WP not available. Try MediumLH or TightLH.");
264  return StatusCode::FAILURE;
265  }
266  }
267  if(electronIsolation == "PLImprovedTight" || electronIsolation == "PLImprovedVeryTight" || electronIsolationLoose == "PLImprovedTight" || electronIsolationLoose == "PLImprovedVeryTight"){
268  if(dataType == 3){
269  ATH_MSG_ERROR("electron PLIV WPs are only available for FullSim.");
270  return StatusCode::FAILURE;
271  }
272  ATH_MSG_WARNING("Trigger SFs for PLIV isolation unavailable. Proceeding without online Isolation.");
273  }
274 
275  // Retrieve full path to maps for different types of tool
277  // - Tight
279  std::vector<std::string> inExpID;
280  if(m_config->electronIDSFFilePath() !="Default"){
281  m_config->setPrintEIDFileWarning(true);
282  inExpID.push_back(electronSFFilePath("EXPID", electronID, electronIsolation));
283  }
284 
285  std::vector<std::string> inExpIDLoose;
286  if(m_config->electronIDSFFileLoosePath() !="Default"){
287  m_config->setPrintEIDFileWarning(true);
288  inExpIDLoose.push_back(electronSFFilePath("EXPID_Loose", electronID, electronIsolation));
289  }
290 
293  std::vector<std::string> inPLViso;
294  if (electronIsolation == "PLVTight" || electronIsolation == "PLVLoose") {
295  m_electronEffSFIsoFile = electronSFFilePath("PLV", electronID, electronIsolation);
296  inPLViso.push_back(m_electronEffSFIsoFile);
297  }
298  else {
300  }
301  // - Loose
305  std::vector<std::string> inPLVisoLoose;
306  if (electronIsolationLoose == "PLVTight" || electronIsolationLoose == "PLVLoose") {
307  m_electronEffSFIsoLooseFile = electronSFFilePath("PLV", electronID, electronIsolationLoose);
308  inPLVisoLoose.push_back(m_electronEffSFIsoLooseFile);
309  }
310  else {
312  }
313 
314  // Define the trigger string for scale factors
315  std::string trigger_string = "";
316 
317  if (m_config->elTrigEffConfig() != " " ) {
318  trigger_string = m_config->elTrigEffConfig();
319  }
320  else{
321  ATH_MSG_ERROR("EgammaCPTools::setupScaleFactors, ElectronTriggerEfficiencyConfig not set, unable to retrieve SFs");
322  return StatusCode::FAILURE;
323  }
324 
325  // Define the tool prefix name
326  const std::string elSFPrefix = "AsgElectronEfficiencyCorrectionTool_";
327 
328  ATH_MSG_INFO("Setting up Electrons SF tool for TOTAL correlation model");
329  // Configure the tools with the maps - Name, map, reco_key, ID_key, iso_key, trigger_key, data_type, for the TOTAL
330  // correlation model
331  // Reco SFs
332  m_electronEffSFReco = setupElectronSFToolWithMap(elSFPrefix + "Reco", m_electronEffSFRecoFile, "Reconstruction", "",
333  "", "", dataType, "TOTAL", "", "");
334  // ID SFs
335  if(m_config->electronIDSFFilePath() =="Default") m_electronEffSFID = setupElectronSFToolWithMap(elSFPrefix + "ID", m_electronEffSFIDFile, "", electronID, "", "",
336  dataType, "TOTAL", "", "");
337  else m_electronEffSFID = setupElectronSFTool(elSFPrefix + "ID", inExpID, dataType);
338  if (m_config->electronIDSFFileLoosePath() =="Default") m_electronEffSFIDLoose = setupElectronSFToolWithMap(elSFPrefix + "IDLoose", m_electronEffSFIDLooseFile, "",
339  electronIDLoose, "", "", dataType, "TOTAL", "", "");
340  else m_electronEffSFIDLoose = setupElectronSFTool(elSFPrefix + "IDLoose", inExpIDLoose, dataType);
341  // Trigger SFs
343  electronID,
344  (!(electronIsolation == "PLImprovedTight" || electronIsolation == "PLImprovedVeryTight")) ? electronIsolation : "",
345  trigger_string, dataType,
346  "TOTAL", "", "");
347  m_electronEffSFTriggerLoose = setupElectronSFToolWithMap(elSFPrefix + "TriggerSFLoose",
348  m_electronEffSFTriggerLooseFile, "", electronIDLoose,
349  (!(electronIsolationLoose == "PLImprovedTight" || electronIsolationLoose == "PLImprovedVeryTight")) ? electronIsolationLoose : "",
350  trigger_string, dataType, "TOTAL",
351  "", "");
352  // Trigger Efficiencies
353  m_electronEffTrigger = setupElectronSFToolWithMap(elSFPrefix + "Trigger", m_electronEffTriggerFile, "", electronID,
354  (!(electronIsolation == "PLImprovedTight" || electronIsolation == "PLImprovedVeryTight")) ? electronIsolation : "",
355  "Eff_" + trigger_string, dataType, "TOTAL", "",
356  "");
358  "", electronIDLoose,
359  (!(electronIsolationLoose == "PLImprovedTight" || electronIsolationLoose == "PLImprovedVeryTight")) ? electronIsolationLoose : "",
360  "Eff_" + trigger_string, dataType, "TOTAL", "", "");
361  // Isolation SFs
362  if (electronIsolation == "PLVTight" || electronIsolation == "PLVLoose") {
363  m_electronEffSFIso = setupElectronSFTool(elSFPrefix + "Iso", inPLViso, dataType);
364  }
365  else if(electronIsolation == "None" || electronIsolation == "") m_electronEffSFIso = nullptr;
366  else {
367  m_electronEffSFIso = setupElectronSFToolWithMap(elSFPrefix + "Iso", m_electronEffSFIsoFile, "", electronID,
368  electronIsolation, "", dataType, "TOTAL", "", "");
369  }
370  if (electronIsolationLoose == "PLVTight" || electronIsolationLoose == "PLVLoose") {
371  m_electronEffSFIsoLoose = setupElectronSFTool(elSFPrefix + "IsoLoose", inPLVisoLoose, dataType);
372  }
373  else if(electronIsolationLoose == "None" || electronIsolationLoose == "") m_electronEffSFIsoLoose = nullptr;
374  else {
376  electronIDLoose, electronIsolationLoose, "", dataType, "TOTAL", "",
377  "");
378  }
379 
380  ATH_MSG_INFO(
381  "Requested Electrons SF tool for " << m_config->electronEfficiencySystematicModel() << " correlation model");
382 
383  if (m_config->electronEfficiencySystematicModel() != "TOTAL") {
384  ATH_MSG_INFO(
385  "Setting up Electrons SF tool for " << m_config->electronEfficiencySystematicModel() << " correlation model");
386 
387  const std::string elSFPrefixCorrModel = elSFPrefix + "CorrModel_";
388  // Reco SFs
390  "Reconstruction", "", "", "", dataType,
391  m_config->electronEfficiencySystematicModelNToys(),
392  m_config->electronEfficiencySystematicModelToySeed(),
393  m_config->electronEfficiencySystematicModel(),
394  m_config->electronEfficiencySystematicModelEtaBinning(),
395  m_config->electronEfficiencySystematicModelEtBinning());
396  // ID SFs
397  if(m_config->electronIDSFFilePath() =="Default") m_electronEffSFIDCorrModel = setupElectronSFToolWithMap(elSFPrefixCorrModel + "ID", m_electronEffSFIDFile, "",
398  electronID, "", "", dataType,
399  m_config->electronEfficiencySystematicModelNToys(),
400  m_config->electronEfficiencySystematicModelToySeed(),
401  m_config->electronEfficiencySystematicModel(),
402  m_config->electronEfficiencySystematicModelEtaBinning(),
403  m_config->electronEfficiencySystematicModelEtBinning());
404  else m_electronEffSFIDCorrModel = setupElectronSFTool(elSFPrefixCorrModel + "ID", inExpID, dataType,
405  m_config->electronEfficiencySystematicModel(),
406  m_config->electronEfficiencySystematicModelEtaBinning(),
407  m_config->electronEfficiencySystematicModelEtBinning());
408 
409 
410  if(m_config->electronIDSFFileLoosePath() =="Default") m_electronEffSFIDLooseCorrModel = setupElectronSFToolWithMap(elSFPrefixCorrModel + "IDLoose",
411  m_electronEffSFIDLooseFile, "", electronIDLoose, "",
412  "", dataType,
413  m_config->electronEfficiencySystematicModelNToys(),
414  m_config->electronEfficiencySystematicModelToySeed(),
415  m_config->electronEfficiencySystematicModel(),
416  m_config->electronEfficiencySystematicModelEtaBinning(),
417  m_config->electronEfficiencySystematicModelEtBinning());
418 
419  else m_electronEffSFIDLooseCorrModel = setupElectronSFTool(elSFPrefixCorrModel + "IDLoose", inExpIDLoose, dataType,
420  m_config->electronEfficiencySystematicModel(),
421  m_config->electronEfficiencySystematicModelEtaBinning(),
422  m_config->electronEfficiencySystematicModelEtBinning());
423 
424  // Trigger SFs
425  m_electronEffSFTriggerCorrModel = setupElectronSFToolWithMap(elSFPrefixCorrModel + "TriggerSF",
426  m_electronEffSFTriggerFile, "", electronID,
427  (!(electronIsolation == "PLImprovedTight" || electronIsolation == "PLImprovedVeryTight")) ? electronIsolation : "",
428  trigger_string, dataType,
429  m_config->electronEfficiencySystematicModelNToys(),
430  m_config->electronEfficiencySystematicModelToySeed(),
431  m_config->electronEfficiencySystematicModel(),
432  m_config->electronEfficiencySystematicModelEtaBinning(),
433  m_config->electronEfficiencySystematicModelEtBinning());
434  m_electronEffSFTriggerLooseCorrModel = setupElectronSFToolWithMap(elSFPrefixCorrModel + "TriggerSFLoose",
436  electronIDLoose,
437  (!(electronIsolationLoose == "PLImprovedTight" || electronIsolationLoose == "PLImprovedVeryTight")) ? electronIsolationLoose : "",
438  trigger_string, dataType,
439  m_config->electronEfficiencySystematicModelNToys(),
440  m_config->electronEfficiencySystematicModelToySeed(),
441  m_config->electronEfficiencySystematicModel(),
442  m_config->electronEfficiencySystematicModelEtaBinning(),
443  m_config->electronEfficiencySystematicModelEtBinning());
444  // Trigger Efficiencies
445  m_electronEffTriggerCorrModel = setupElectronSFToolWithMap(elSFPrefixCorrModel + "Trigger",
446  m_electronEffTriggerFile, "", electronID,
447  (!(electronIsolation == "PLImprovedTight" || electronIsolation == "PLImprovedVeryTight")) ? electronIsolation : "",
448  "Eff_" + trigger_string, dataType,
449  m_config->electronEfficiencySystematicModelNToys(),
450  m_config->electronEfficiencySystematicModelToySeed(),
451  m_config->electronEfficiencySystematicModel(),
452  m_config->electronEfficiencySystematicModelEtaBinning(),
453  m_config->electronEfficiencySystematicModelEtBinning());
454  m_electronEffTriggerLooseCorrModel = setupElectronSFToolWithMap(elSFPrefixCorrModel + "TriggerLoose",
456  electronIDLoose,
457  (!(electronIsolationLoose == "PLImprovedTight" || electronIsolationLoose == "PLImprovedVeryTight")) ? electronIsolationLoose : "",
458  "Eff_" + trigger_string, dataType,
459  m_config->electronEfficiencySystematicModelNToys(),
460  m_config->electronEfficiencySystematicModelToySeed(),
461  m_config->electronEfficiencySystematicModel(),
462  m_config->electronEfficiencySystematicModelEtaBinning(),
463  m_config->electronEfficiencySystematicModelEtBinning());
464  // Isolation SFs
465  if (electronIsolation == "PLVTight" || electronIsolation == "PLVLoose") {
466  m_electronEffSFIsoCorrModel = setupElectronSFTool(elSFPrefixCorrModel + "Iso", inPLViso, dataType,
467  m_config->electronEfficiencySystematicModel(),
468  m_config->electronEfficiencySystematicModelEtaBinning(),
469  m_config->electronEfficiencySystematicModelEtBinning());
470  }
471  else if(electronIsolation == "None" || electronIsolation == "") m_electronEffSFIsoCorrModel = nullptr;
472  else {
474  electronID, electronIsolation, "", dataType,
475  m_config->electronEfficiencySystematicModelNToys(),
476  m_config->electronEfficiencySystematicModelToySeed(),
477  m_config->electronEfficiencySystematicModel(),
478  m_config->electronEfficiencySystematicModelEtaBinning(),
479  m_config->electronEfficiencySystematicModelEtBinning());
480  }
481  if (electronIsolationLoose == "PLVTight" || electronIsolationLoose == "PLVLoose") {
482  m_electronEffSFIsoLooseCorrModel = setupElectronSFTool(elSFPrefixCorrModel + "IsoLoose", inPLVisoLoose, dataType,
483  m_config->electronEfficiencySystematicModel(),
484  m_config->electronEfficiencySystematicModelEtaBinning(),
485  m_config->electronEfficiencySystematicModelEtBinning());
486 
487  }
488  else if(electronIsolationLoose == "None" || electronIsolationLoose == "") m_electronEffSFIsoLooseCorrModel = nullptr;
489  else {
490  m_electronEffSFIsoLooseCorrModel = setupElectronSFToolWithMap(elSFPrefixCorrModel + "IsoLoose",
491  m_electronEffSFIsoLooseFile, "", electronIDLoose,
492  electronIsolationLoose, "", dataType,
493  m_config->electronEfficiencySystematicModelNToys(),
494  m_config->electronEfficiencySystematicModelToySeed(),
495  m_config->electronEfficiencySystematicModel(),
496  m_config->electronEfficiencySystematicModelEtaBinning(),
497  m_config->electronEfficiencySystematicModelEtBinning());
498  }
499  }
500 
501  if (m_config->useFwdElectrons()) {
502  ATH_MSG_INFO("Setting up forward Electrons SF tool");
503 
504 // m_fwdElectronEffSFIDFile = electronSFMapFilePath("FWDID");
505 // m_fwdElectronEffSFIDLooseFile = electronSFMapFilePath("FWDID");
506 // m_fwdElectronEffSFID = setupElectronSFToolWithMap("AsgFwdElectronEfficiencyCorrectionTool_ID",
507 // m_fwdElectronEffSFIDFile, "",
508 // "Fwd" + m_config->fwdElectronID(), "", "", dataType, "TOTAL", "",
509 // "");
510 // m_fwdElectronEffSFIDLoose = setupElectronSFToolWithMap("AsgFwdElectronEfficiencyCorrectionTool_IDLoose",
511 // m_fwdElectronEffSFIDLooseFile, "",
512 // "Fwd" + m_config->fwdElectronIDLoose(), "", "", dataType, "TOTAL", "",
513 // "");
514 
515  ATH_MSG_INFO("Finished setting up forward Electrons SF tool");
516  }
517 
518 
519  // Charge ID cannot use maps at the moment so we default to the old method
520  if (m_config->useElectronChargeIDSelection()
521  && electronIsolation != "PLVTight" && electronIsolation != "PLVLoose"
522  && electronIsolationLoose != "PLVTight" && electronIsolationLoose != "PLVLoose"
523  && electronIsolation != "PLImprovedTight" && electronIsolation != "PLImprovedVeryTight"
524  && electronIsolationLoose != "PLImprovedTight" && electronIsolationLoose != "PLImprovedVeryTight") { // We need to update the implementation according to new recommendations
525 
526  ATH_MSG_INFO("Setting up Electrons ChargeID SF tool");
527  // Charge ID file (no maps)
528  m_electronEffSFChargeIDFile = electronSFFilePath("ChargeID", electronID, electronIsolation);
529  if (m_config->applyTightSFsInLooseTree()) // prevent crash on-supported loose electron WPs with ECIDS
530  m_electronEffSFChargeIDLooseFile = electronSFFilePath("ChargeID", electronID, electronIsolation);
531  else m_electronEffSFChargeIDLooseFile = electronSFFilePath("ChargeID", electronIDLoose, electronIsolationLoose);
532  // The tools want the files in vectors: remove this with function
533  std::vector<std::string> inChargeID {
535  };
536  std::vector<std::string> inChargeIDLoose {
538  };
539  // Charge Id efficiency scale factor
540  m_electronEffSFChargeID = setupElectronSFTool(elSFPrefix + "ChargeID", inChargeID, dataType);
541  m_electronEffSFChargeIDLoose = setupElectronSFTool(elSFPrefix + "ChargeIDLoose", inChargeIDLoose, dataType);
542  }
543  //if(electronIsolation != "PLVTight" && electronIsolation != "PLVLoose" &&
544  // electronIsolation != "PLImprovedTight" && electronIsolation != "PLImprovedVeryTight"){
545  // CP::ElectronChargeEfficiencyCorrectionTool* ChargeMisIDCorrections = new CP::ElectronChargeEfficiencyCorrectionTool("ElectronChargeEfficiencyCorrection");
546  // m_electronEffSFChargeMisIDFile = electronSFFilePath("ChargeMisID", electronID, electronIsolation);
547  // top::check(ChargeMisIDCorrections->setProperty("CorrectionFileName", m_electronEffSFChargeMisIDFile), "Failed to setProperty");
548  // top::check(ChargeMisIDCorrections->initialize(), "Failed to setProperty");
549  //}
550  //if(electronIsolationLoose != "PLVTight" && electronIsolationLoose != "PLVLoose" &&
551  // electronIsolationLoose != "PLImprovedTight" && electronIsolationLoose != "PLImprovedVeryTight"){
552  // CP::ElectronChargeEfficiencyCorrectionTool* ChargeMisIDCorrectionsLoose = new CP::ElectronChargeEfficiencyCorrectionTool("ElectronChargeEfficiencyCorrectionLoose");
553  // m_electronEffSFChargeMisIDLooseFile = electronSFFilePath("ChargeMisID", electronIDLoose, electronIsolationLoose);
554  // top::check(ChargeMisIDCorrectionsLoose->setProperty("CorrectionFileName", m_electronEffSFChargeMisIDLooseFile), "Failed to setProperty");
555  // top::check(ChargeMisIDCorrectionsLoose->initialize(), "Failed to setProperty");
556  //}
557  return StatusCode::SUCCESS;
558  }
559 
561  EgammaCPTools::setupElectronSFTool(const std::string& name, const std::vector<std::string>& file_list,
562  const int& data_type,
563  const std::string& correlation_model,
564  const std::string& correlationModelEtaBinning,
565  const std::string& correlationModelEtBinning) {
567 
568  if (asg::ToolStore::contains<IAsgElectronEfficiencyCorrectionTool>(name)) {
569  tool = asg::ToolStore::get<IAsgElectronEfficiencyCorrectionTool>(name);
570  } else {
571  if (!file_list.empty()) { // If the file list is empty do nothing
573  top::check(asg::setProperty(tool, "CorrectionFileNameList", file_list),
574  "Failed to set CorrectionFileNameList to " + name);
575  top::check(asg::setProperty(tool, "ForceDataType", data_type),
576  "Failed to set ForceDataType to " + name);
577  top::check(asg::setProperty(tool, "CorrelationModel", correlation_model),
578  "Failed to set CorrelationModel to " + name);
579  if (correlationModelEtaBinning != "" && correlationModelEtaBinning != "default") this->setCorrelationModelBinning(tool, "UncorrEtaBinsUser", correlationModelEtaBinning);
580  if (correlationModelEtBinning != "" && correlationModelEtBinning != "default") this->setCorrelationModelBinning(tool, "UncorrEtBinsUser", correlationModelEtBinning);
581 
582  top::check(asg::setProperty(tool, "OutputLevel", MSG::INFO), "Failed to set OutputLevel to " + name);
583  top::check(tool->initialize(), "Failed to initialize " + name);
584  }
585  }
586  return tool;
587  }
588 
590  const std::string& binningName, const std::string& binning) {
591  std::vector<std::string> tokens;
593  if (tokens.size() < 1) {
595  "EgammaCPTools::setupElectronSFToolWithMap, correlation model " << binningName <<
596  " binning must be in the form XXX:YYY:WWW:ZZZ...");
597  }
598  std::vector<float> bins;
599  for (unsigned int i = 0; i < tokens.size(); i++) {
600  std::string token = tokens[i];
601  float value = 0.;
602  try{
603  value = std::stof(token);
604  }
605  catch (...) {
606  throw std::invalid_argument {
607  "EgammaCPTools::setupElectronSFToolWithMap, correlation model " + binningName +
608  " binning must be in the for XXX:YYY:WWW:ZZZ, couldn't convert correctly to float"
609  };
610  }
611  bins.push_back(value);
612  }
613  ATH_MSG_INFO(" ---> electron SF tools will use " << binningName << " bins:");
614  for (unsigned int i = 0; i < bins.size(); i++) ATH_MSG_INFO(" " << bins[i]);
615  top::check(asg::setProperty(tool, binningName,
616  bins), "Failed to set correlation model " + binningName + " binning to " + binning);
617  }
618 
620  const std::string& ToysName, const int& number) {
621  ATH_MSG_INFO(" ---> electron SF tools will use " << ToysName << " :"<< number);
622  top::check(asg::setProperty(tool, ToysName,
623  number), "Failed to set correlation model " + ToysName );
624  }
625 
626 
628  EgammaCPTools::setupElectronSFToolWithMap(const std::string& name, const std::string& map_path,
629  const std::string& reco_key, const std::string& ID_key,
630  const std::string& ISO_key, const std::string& trigger_key,
631  const int& data_type,
632  const int& correlationModelNToys,
633  const int& correlationModelToySeed,
634  const std::string& correlation_model,
635  const std::string& correlationModelEtaBinning,
636  const std::string& correlationModelEtBinning) {
637 
638  std::string iso_key = ISO_key;
639  // https://twiki.cern.ch/twiki/bin/view/AtlasProtected/LatestRecommendationsElectronIDRun2#PLV_scale_factors_for_central_el
640  // If isolation WP is PLVTight or PLVLoose, switch to no isolation to trick this function.
641  if (iso_key == "PLVTight" || iso_key == "PLVLoose") iso_key = "";
642 
643  std::string infoStr = "Configuring : name=" + name + " map=" + map_path + " reco_key=" + reco_key + " ID_key=" +
644  ID_key + " iso_key=" + iso_key + " trigger_key=" + trigger_key + "data_type=" +
645  std::to_string(data_type) +
646  " correlation_model=" + correlation_model + " etaBinning=" + correlationModelEtaBinning +
647  " etBinning=" +
648  correlationModelEtBinning;
649  ATH_MSG_INFO(infoStr);
651  if (asg::ToolStore::contains<IAsgElectronEfficiencyCorrectionTool>(name)) {
652  tool = asg::ToolStore::get<IAsgElectronEfficiencyCorrectionTool>(name);
653  } else {
655  if (map_path != "UseEgammaRecommended") {
656  // Give the full map path if not using the default one
657  top::check(asg::setProperty(tool, "MapFilePath", map_path), "Failed to set MapFilePath to " + name);
658  }
659  // Set the data type for all tools
660  top::check(asg::setProperty(tool, "ForceDataType", data_type), "Failed to set ForceDataType to " + name);
661  // Set the correlation model for all tools
662  top::check(asg::setProperty(tool, "CorrelationModel",
663  correlation_model), "Failed to set CorrelationModel to " + name);
664 
665  if (correlationModelEtaBinning != "" && correlationModelEtaBinning != "default") this->setCorrelationModelBinning(
666  tool, "UncorrEtaBinsUser", correlationModelEtaBinning);
667  if (correlationModelEtBinning != "" && correlationModelEtBinning != "default") this->setCorrelationModelBinning(
668  tool, "UncorrEtBinsUser", correlationModelEtBinning);
669 
670  //MC Toy model variables
671  if (correlationModelNToys != 0 ) this->setCorrelationModelToys(
672  tool, "NumberOfToys", correlationModelNToys);
673 
674  if (correlationModelToySeed != 0) this->setCorrelationModelToys(
675  tool, "MCToySeed", correlationModelToySeed);
676 
677 
678  // Set the keys which configure the tool options (empty string means we do not include this key)
679  if (reco_key != "" && reco_key != "None") {
680  ATH_MSG_INFO(" Adding RecoKey : " + reco_key);
681  top::check(asg::setProperty(tool, "RecoKey", reco_key), "Failed to set RecoKey to " + name);
682  }
683  if (ID_key != "" && ID_key != "None") {
684  std::string id_key = mapWorkingPoints(ID_key);
685  ATH_MSG_INFO(" Adding IDKey : " + id_key);
686  top::check(asg::setProperty(tool, "IdKey", id_key), "Failed to set IdKey to " + name);
687  }
688  if (iso_key != "" && iso_key != "None") {
689  ATH_MSG_INFO(" Adding IsoKey : " + iso_key);
690  top::check(asg::setProperty(tool, "IsoKey", iso_key), "Failed to set IsoKey to " + name);
691  }
692  if (trigger_key != "" && trigger_key != "None") {
693  ATH_MSG_INFO(" Adding TriggerKey : " + trigger_key);
694  top::check(asg::setProperty(tool, "TriggerKey", trigger_key), "Failed to set TriggerKey to " + name);
695  }
696  // Initialise this tool
697 
698  top::check(tool->initialize(), "Failed to initialize " + name);
699  }
700  return tool;
701 }
702 
703 
705  EgammaCPTools::setupElectronSFToolWithMap(const std::string& name, const std::string& map_path,
706  const std::string& reco_key, const std::string& ID_key,
707  const std::string& ISO_key, const std::string& trigger_key,
708  const int& data_type,
709  const std::string& correlation_model,
710  const std::string& correlationModelEtaBinning,
711  const std::string& correlationModelEtBinning) {
712 
713  std::string iso_key = ISO_key;
714  // https://twiki.cern.ch/twiki/bin/view/AtlasProtected/LatestRecommendationsElectronIDRun2#PLV_scale_factors_for_central_el
715  // If isolation WP is PLVTight or PLVLoose, switch to no isolation to trick this function.
716  if (iso_key == "PLVTight" || iso_key == "PLVLoose") iso_key = "";
717 
718  // fixes needed for run 2
719  if (!m_config->isRun3() && (trigger_key != "" && trigger_key != "None")) {
720  if (iso_key == "Tight_VarRad") iso_key = "FCTight";
721  }
722 
723  if( (iso_key == "PLImprovedTight" || iso_key == "PLImprovedVeryTight") && m_config->useElectronChargeIDSelection() ){
724  ATH_MSG_INFO( "ECIDS tool and PLImproved* isolation detected, switching to combined isolation SFs.");
725  iso_key += "ECIDS";
726  }
727 
728  std::string infoStr = "Configuring : name=" + name + " map=" + map_path + " reco_key=" + reco_key + " ID_key=" +
729  ID_key + " iso_key=" + iso_key + " trigger_key=" + trigger_key + "data_type=" +
730  std::to_string(data_type) +
731  " correlation_model=" + correlation_model + " etaBinning=" + correlationModelEtaBinning +
732  " etBinning=" +
733  correlationModelEtBinning;
734  ATH_MSG_INFO(infoStr);
736  if (asg::ToolStore::contains<IAsgElectronEfficiencyCorrectionTool>(name)) {
737  tool = asg::ToolStore::get<IAsgElectronEfficiencyCorrectionTool>(name);
738  } else {
740  if (!m_config->isRun3()) {
741  top::check(asg::setProperty(tool, "MapFilePath", "ElectronEfficiencyCorrection/2015_2018/rel21.2/Precision_Summer2020_v1/map4.txt"), "Failed to set MapFilePath to " + name);
742  } else {
743  if (map_path != "UseEgammaRecommended") {
744  // Give the full map path if not using the default one
745  top::check(asg::setProperty(tool, "MapFilePath", map_path), "Failed to set MapFilePath to " + name);
746  }
747  }
748  // Set the data type for all tools
749  top::check(asg::setProperty(tool, "ForceDataType", data_type), "Failed to set ForceDataType to " + name);
750  // Set the correlation model for all tools
751  top::check(asg::setProperty(tool, "CorrelationModel",
752  correlation_model), "Failed to set CorrelationModel to " + name);
753 
754  if (correlationModelEtaBinning != "" && correlationModelEtaBinning != "default") this->setCorrelationModelBinning(
755  tool, "UncorrEtaBinsUser", correlationModelEtaBinning);
756  if (correlationModelEtBinning != "" && correlationModelEtBinning != "default") this->setCorrelationModelBinning(
757  tool, "UncorrEtBinsUser", correlationModelEtBinning);
758 
759  // Set the keys which configure the tool options (empty string means we do not include this key)
760  if (reco_key != "" && reco_key != "None") {
761  ATH_MSG_INFO(" Adding RecoKey : " + reco_key);
762  top::check(asg::setProperty(tool, "RecoKey", reco_key), "Failed to set RecoKey to " + name);
763  }
764  if (ID_key != "" && ID_key != "None") {
765  std::string id_key = mapWorkingPoints(ID_key);
766  ATH_MSG_INFO(" Adding IDKey : " + id_key);
767  top::check(asg::setProperty(tool, "IdKey", id_key), "Failed to set IdKey to " + name);
768  }
769  if (iso_key != "" && iso_key != "None") {
770  ATH_MSG_INFO(" Adding IsoKey : " + iso_key);
771  top::check(asg::setProperty(tool, "IsoKey", iso_key), "Failed to set IsoKey to " + name);
772  }
773  if (trigger_key != "" && trigger_key != "None") {
774  ATH_MSG_INFO(" Adding TriggerKey : " + trigger_key);
775  top::check(asg::setProperty(tool, "TriggerKey", trigger_key), "Failed to set TriggerKey to " + name);
776  }
777  top::check(asg::setProperty(tool, "OutputLevel", MSG::INFO), "Failed to set OutputLevel to " + name);
778  top::check(tool->initialize(), "Failed to initialize " + name);
779  }
780  return tool;
781  }
782 
783  std::string EgammaCPTools::electronSFFilePath(const std::string& type, const std::string& ID,
784  const std::string& ISO) {
785  bool isPliv = (ISO == "PLImprovedTight" || ISO == "PLImprovedVeryTight");
786  const std::string el_calib_path = "ElectronEfficiencyCorrection/2015_2025/rel22.2/2022_Summer_Prerecom_v1/";
787 
788  std::string file_path;
789 
790  if (type == "reco") {
791  ATH_MSG_ERROR("Moved to using egamma maps for configuring scale factor tools - electronSFMapFilePath");
792  } else if (type == "ID") {
793  ATH_MSG_ERROR("Moved to using egamma maps for configuring scale factor tools - electronSFMapFilePath");
794  } else if (type == "triggerSF") {
795  ATH_MSG_ERROR("Moved to using egamma maps for configuring scale factor tools - electronSFMapFilePath");
796  } else if (type == "triggerEff") {
797  ATH_MSG_ERROR("Moved to using egamma maps for configuring scale factor tools - electronSFMapFilePath");
798  } else if (type == "ChargeID") {
799  if (ID != "MediumLLH" && ID != "TightLLH") ATH_MSG_ERROR(
800  "The requested ID WP (" + ID +
801  ") is not supported for electron ChargeID SFs! Try TightLH or MediumLH instead.");
802  if (ISO != "FCTight" && ISO != "Gradient" && ISO != "PLImprovedTight" && ISO != "PLImprovedVeryTight") ATH_MSG_ERROR("The requested ISO WP (" + ISO + ") is not supported for electron ChargeID SFs! Try FCTight, Gradient, or PLImproved(Very)Tight instead.");
803  file_path += (isPliv) ? "isolation/efficiencySF.Isolation." : "additional/efficiencySF.ChargeID.";
804  file_path += ID;
805  file_path += "_d0z0_v13_";
806  if(isPliv) file_path += "isol";
807  file_path += ISO;
808  file_path += (isPliv) ? "ECIDS.root" : "_ECIDSloose.root";
809  file_path = el_calib_path + file_path;
810  } else if (type == "PLV") {
811  if (ID != "MediumLLH" && ID != "TightLLH")
813  "The requested ID WP (" + ID +
814  ") is not supported for PLV SFs! try TightLH or MediumLH instead."
815  );
816  file_path = "/ElectronEfficiencyCorrection/2015_2018/rel21.2/Precision_Summer2020_v1/isolation/";
817  file_path += "efficiencySF.Isolation.MediumLHorTightLH_d0z0_v13_isol";
818  file_path += ISO;
819  if (ISO == "PLVTight" && m_config->useElectronChargeIDSelection()) {
820  ATH_MSG_INFO(
821  "ECIDS tool and PLVTight isolation detected, switching to combined isolation SFs."
822  );
823  file_path += "ECIDS";
824  }
825  file_path += ".root";
826  } else if (type == "ChargeMisID") {
827  // Protect against "None" Iso key
828  std::string iso = ISO;
829  if (iso == "None") iso = "";
830  // Protect against Loose ID + any Iso
831  if (ID == "LooseAndBLayerLLH") iso = "";
832  file_path = "charge_misID/";
833  file_path += "chargeEfficiencySF.";
834  file_path += ID;
835  file_path += "_d0z0_v13";
836  if (iso != "" && iso != "PLVTight" && iso != "PLVLoose" && iso != "PLImprovedTight" && iso != "PLImprovedVeryTight") file_path += "_" + iso;
837  if (iso == "PLVTight" || iso == "PLVLoose" || iso == "PLImprovedTight" || iso == "PLImprovedVeryTight") {
838  // not supported for now! -> set up a dummy tool and return 1 as SF
839  ATH_MSG_WARNING("The requested ISO WP (" + iso + ") is not supported for electron ChargeMisID SFs! Will set up a dummy tool and set the SFs to one.");
840  }
841  if (m_config->useElectronChargeIDSelection()) {
842  if (ID != "MediumLLH" && ID != "TightLLH") ATH_MSG_WARNING("The requested ID WP (" + ID + ") is not supported for electron ECIDS+ChargeMisID SFs! Try TightLH or MediumLH instead. Will now switch to regular ChargeMisID SFs.");
843  else if (iso != "FCTight" && iso != "Gradient") ATH_MSG_WARNING("The requested ISO WP (" + iso + ") is not supported for electron ECIDS+ChargeMisID SFs! Try FCTight or Gradient instead. Will now switch to regular ChargeMisID SFs.");
844  else file_path += "_ECIDSloose";
845  }
846  file_path += ".root";
847  file_path = el_calib_path + file_path;
848  } else if (type == "EXPID"){
849  file_path = m_config->electronIDSFFilePath();
850  } else if (type == "EXPID_Loose"){
851  file_path = m_config->electronIDSFFileLoosePath();
852  } else {
853  ATH_MSG_ERROR("Unknown electron SF type");
854  }
856  }
857 
858  std::string EgammaCPTools::electronSFMapFilePath(const std::string& type) {
859  // Store here the paths to maps which may be updated with new recommendations
860  // Currently can use maps for reco, id, iso, trigger but not ChargeID
861  const std::string el_calib_path = "UseEgammaRecommended";
862 
863  if (type == "FWDID") {
864  return PathResolverFindCalibFile("ElectronEfficiencyCorrection/2015_2017/rel21.2/Consolidation_September2018_v1/map3.txt");
865  }
866 
867  return el_calib_path;
868  }
869 
870  std::string EgammaCPTools::mapWorkingPoints(const std::string& type) {
871  // Ian Connelly - 27 Sept 2017
872  // When moving to the maps, the working points are converted to a nicer format
873  // We will provide a mapping from the names used by analysers and the map WP names to prevent cutfiles breaking
874  // See :
875  // https://twiki.cern.ch/twiki/bin/view/AtlasProtected/XAODElectronEfficiencyCorrectionTool#Configuration_of_the_tool_using
876  std::string working_point = "";
877  // ID
878  if (type == "LooseAndBLayerLLH" || type == "LooseBLayer") {
879  working_point = "LooseBLayer";
880  }
881  if (type == "MediumLLH" || type == "Medium") {
882  working_point = "Medium";
883  }
884  if (type == "TightLLH" || type == "Tight") {
885  working_point = "Tight";
886  }
887  if (type == "FwdLoose" || type == "FwdMedium" || type == "FwdTight") working_point = type;
888 
889  if (type.find("Pflow") != std::string::npos) {
890  ATH_MSG_WARNING("You selected a Pflow isolation WP for at least one of your electron collections - BE WARNED THAT THESE ARE NOT YET READY TO BE RELEASED FOR USE IN PHYSICS ANALYSES AND OF COURSE DON'T HAVE ASSOCIATED SCALE FACTORS YET!!!");
891  if (type == "PflowLoose") working_point = "FCLoose";
892  if (type == "PflowTight") working_point = "FCTight";
893  }
894  if (type == "Tight_VarRad") working_point = "Tight_VarRad";
895  if (type == "Loose_VarRad") working_point = "Loose_VarRad";
896  if (type == "Tight") working_point = "FCTight";
897  if (type == "Loose") working_point = "FCLoose";
898  if (type == "HighPtCaloOnly") working_point = "FCHighPtCaloOnly";
899  if (type == "TightTrackOnly") {
900  ATH_MSG_WARNING("You selected the TightTrackOnly isolation WP for at least one of your electron collections - BE WARNED THAT THESE ARE NOT YET READY TO BE RELEASED FOR USE IN PHYSICS ANALYSES AND OF COURSE DON'T HAVE ASSOCIATED SCALE FACTORS YET!!! Setting to \"Gradient\" SFs to allow the code to run");
901  working_point = "Gradient";
902  }
903  if (type == "TightTrackOnly_FixedRad") {
904  ATH_MSG_WARNING("You selected the TightTrackOnly_FixedRad isolation WP for at least one of your electron collections - BE WARNED THAT THESE ARE NOT YET READY TO BE RELEASED FOR USE IN PHYSICS ANALYSES AND OF COURSE DON'T HAVE ASSOCIATED SCALE FACTORS YET!!! Setting to \"Gradient\" SFs to allow the code to run");
905  working_point = "Gradient";
906  }
907  if (type == "FCTight" || type == "FCLoose" || type == "FCHighPtCaloOnly" || type == "Gradient" || type == "PLVTight" || type == "PLVLoose" || type == "PLImprovedTight" || type == "PLImprovedVeryTight") working_point = type;
908 
909  return working_point;
910  }
911 } // namespace top
912 
top::EgammaCPTools::m_electronEffSFTrigger
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFTrigger
Definition: TopEgammaCPTools.h:60
asg::AnaToolHandle::initialize
StatusCode initialize()
initialize the tool
AsgElectronLikelihoodTool.h
AsgElectronEfficiencyCorrectionTool
Definition: AsgElectronEfficiencyCorrectionTool.h:36
asg::AnaToolHandle< IElectronPhotonShowerShapeFudgeTool >
AddEmptyComponent.binning
binning
Definition: AddEmptyComponent.py:34
top::EgammaCPTools::m_electronEffSFIDLooseFile
std::string m_electronEffSFIDLooseFile
Definition: TopEgammaCPTools.h:47
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
top::EgammaCPTools::m_electronEffSFTriggerLooseCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFTriggerLooseCorrModel
Definition: TopEgammaCPTools.h:73
top::EgammaCPTools::electronSFFilePath
std::string electronSFFilePath(const std::string &type, const std::string &ID, const std::string &ISO)
Definition: TopEgammaCPTools.cxx:783
top::EgammaCPTools::m_electronEffSFChargeIDLooseFile
std::string m_electronEffSFChargeIDLooseFile
Definition: TopEgammaCPTools.h:51
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
top::EgammaCPTools::m_photonIsoSFTools
ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > m_photonIsoSFTools
Definition: TopEgammaCPTools.h:84
python.App.bins
bins
Definition: App.py:410
top::EgammaCPTools::electronSFMapFilePath
std::string electronSFMapFilePath(const std::string &type)
Definition: TopEgammaCPTools.cxx:858
top::EgammaCPTools::setCorrelationModelToys
void setCorrelationModelToys(IAsgElectronEfficiencyCorrectionTool *tool, const std::string &ToysName, const int &number)
Definition: TopEgammaCPTools.cxx:619
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
top::EgammaCPTools::m_photonFudgeTool
asg::AnaToolHandle< IElectronPhotonShowerShapeFudgeTool > m_photonFudgeTool
Definition: TopEgammaCPTools.h:82
IAsgPhotonEfficiencyCorrectionTool
Definition: IAsgPhotonEfficiencyCorrectionTool.h:23
AsgPhotonEfficiencyCorrectionTool.h
top::tokenize
void tokenize(const std::string &input, Container &output, const std::string &delimiters=" ", bool trim_empty=false)
Tokenize an input string using a set of delimiters.
Definition: Tokenize.h:24
asg
Definition: DataHandleTestTool.h:28
downloadSingle.dataType
string dataType
Definition: downloadSingle.py:18
ElectronChargeEfficiencyCorrectionTool.h
top::EgammaCPTools::m_electronEffSFReco
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFReco
Definition: TopEgammaCPTools.h:64
athena.value
value
Definition: athena.py:122
IElectronPhotonShowerShapeFudgeTool
Definition: IElectronPhotonShowerShapeFudgeTool.h:30
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
top::EgammaCPTools::setupSelectors
StatusCode setupSelectors()
Definition: TopEgammaCPTools.cxx:112
top::EgammaCPTools::m_egammaCalibrationModel
std::string m_egammaCalibrationModel
Definition: TopEgammaCPTools.h:40
AsgElectronEfficiencyCorrectionTool.h
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
asg::AnaToolHandle::setProperty
StatusCode setProperty(const std::string &property, const T2 &value)
set the given property of the tool.
top::EgammaCPTools::m_electronEffSFIso
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFIso
Definition: TopEgammaCPTools.h:67
top::EgammaCPTools::m_electronEffSFRecoCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFRecoCorrModel
Definition: TopEgammaCPTools.h:76
top::EgammaCPTools::m_electronEffSFIsoFile
std::string m_electronEffSFIsoFile
Definition: TopEgammaCPTools.h:48
EventTools.h
A few functions for doing operations on particles / events. Currently holds code for dR,...
top::EgammaCPTools::m_electronEffSFIsoCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFIsoCorrModel
Definition: TopEgammaCPTools.h:79
TopEgammaCPTools.h
top::EgammaCPTools::m_photonEffSF
ToolHandle< IAsgPhotonEfficiencyCorrectionTool > m_photonEffSF
Definition: TopEgammaCPTools.h:83
top::EgammaCPTools::m_electronEffSFIDCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFIDCorrModel
Definition: TopEgammaCPTools.h:77
top::EgammaCPTools::setCorrelationModelBinning
void setCorrelationModelBinning(IAsgElectronEfficiencyCorrectionTool *tool, const std::string &binningName, const std::string &binning)
Definition: TopEgammaCPTools.cxx:589
IElectronPhotonShowerShapeFudgeTool.h
top::EgammaCPTools::m_electronEffSFIsoLooseCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFIsoLooseCorrModel
Definition: TopEgammaCPTools.h:80
top::EgammaCPTools::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: TopEgammaCPTools.h:38
RpcMonitorAlgorithm.file_list
list file_list
Definition: RpcMonitorAlgorithm.py:383
top::EgammaCPTools::m_electronEffSFIDFile
std::string m_electronEffSFIDFile
Definition: TopEgammaCPTools.h:46
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
top::EgammaCPTools::setupElectronSFToolWithMap
IAsgElectronEfficiencyCorrectionTool * setupElectronSFToolWithMap(const std::string &name, const std::string &map_path, const std::string &reco_key, const std::string &ID_key, const std::string &iso_key, const std::string &trigger_key, const int &data_type, const std::string &correlationModel, const std::string &correlationModelEtaBinning, const std::string &correlationModelEtBinning)
Definition: TopEgammaCPTools.cxx:705
top::EgammaCPTools::m_egammaCalibrationAndSmearingTool
ToolHandle< CP::IEgammaCalibrationAndSmearingTool > m_egammaCalibrationAndSmearingTool
Definition: TopEgammaCPTools.h:58
lumiFormat.i
int i
Definition: lumiFormat.py:92
top::EgammaCPTools::m_electronEffSFTriggerCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFTriggerCorrModel
Definition: TopEgammaCPTools.h:72
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
top::EgammaCPTools::m_photonTightIsEMSelector
ToolHandle< IAsgPhotonIsEMSelector > m_photonTightIsEMSelector
Definition: TopEgammaCPTools.h:86
athena.file_path
file_path
Definition: athena.py:92
top::EgammaCPTools::m_electronEffTriggerLooseFile
std::string m_electronEffTriggerLooseFile
Definition: TopEgammaCPTools.h:42
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
AsgPhotonEfficiencyCorrectionTool
Definition: AsgPhotonEfficiencyCorrectionTool.h:38
top::EgammaCPTools::m_electronEffTriggerCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffTriggerCorrModel
Definition: TopEgammaCPTools.h:74
top::EgammaCPTools::m_electronEffSFTriggerLoose
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFTriggerLoose
Definition: TopEgammaCPTools.h:61
top::EgammaCPTools::m_electronEffSFChargeID
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFChargeID
Definition: TopEgammaCPTools.h:69
AnaToolHandle.h
top::EgammaCPTools::m_electronEffSFIDLoose
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFIDLoose
Definition: TopEgammaCPTools.h:66
top::EgammaCPTools::m_electronEffSFIDLooseCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFIDLooseCorrModel
Definition: TopEgammaCPTools.h:78
top::EgammaCPTools::m_electronEffTrigger
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffTrigger
Definition: TopEgammaCPTools.h:62
PathResolver.h
top::EgammaCPTools::m_electronEffSFChargeIDFile
std::string m_electronEffSFChargeIDFile
Definition: TopEgammaCPTools.h:50
CP::IEgammaCalibrationAndSmearingTool
Definition: Interfaces/EgammaAnalysisInterfaces/EgammaAnalysisInterfaces/IEgammaCalibrationAndSmearingTool.h:29
python.selection.number
number
Definition: selection.py:20
top::EgammaCPTools::m_electronEffSFRecoFile
std::string m_electronEffSFRecoFile
Definition: TopEgammaCPTools.h:45
top::EgammaCPTools::m_electronEffSFTriggerFile
std::string m_electronEffSFTriggerFile
Definition: TopEgammaCPTools.h:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
top::EgammaCPTools::m_electronEffSFIsoLooseFile
std::string m_electronEffSFIsoLooseFile
Definition: TopEgammaCPTools.h:49
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
TopConfig.h
top::EgammaCPTools::m_electronEffSFIsoLoose
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFIsoLoose
Definition: TopEgammaCPTools.h:68
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
CP::EgammaCalibrationAndSmearingTool
Definition: EgammaCalibrationAndSmearingTool.h:81
top::EgammaCPTools::setupElectronSFTool
IAsgElectronEfficiencyCorrectionTool * setupElectronSFTool(const std::string &name, const std::vector< std::string > &file_list, const int &data_type, const std::string &correlation_model="TOTAL", const std::string &correlationModelEtaBinning="", const std::string &correlationModelEtBinning="")
Definition: TopEgammaCPTools.cxx:561
AsgPhotonIsEMSelector.h
top::EgammaCPTools::m_electronEffSFChargeIDLoose
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFChargeIDLoose
Definition: TopEgammaCPTools.h:70
EGSelectorConfigurationMapping.h
top::EgammaCPTools::m_electronEffSFTriggerLooseFile
std::string m_electronEffSFTriggerLooseFile
Definition: TopEgammaCPTools.h:44
top::EgammaCPTools::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: TopEgammaCPTools.cxx:82
top::EgammaCPTools::setupCalibration
StatusCode setupCalibration()
Definition: TopEgammaCPTools.cxx:133
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
top::EgammaCPTools::m_electronEffTriggerLoose
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffTriggerLoose
Definition: TopEgammaCPTools.h:63
top::EgammaCPTools::m_electronEffSFID
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffSFID
Definition: TopEgammaCPTools.h:65
top::EgammaCPTools::m_electronEffTriggerLooseCorrModel
ToolHandle< IAsgElectronEfficiencyCorrectionTool > m_electronEffTriggerLooseCorrModel
Definition: TopEgammaCPTools.h:75
top::ID
@ ID
Definition: ScaleFactorRetriever.h:213
top::EgammaCPTools::mapWorkingPoints
std::string mapWorkingPoints(const std::string &type)
Definition: TopEgammaCPTools.cxx:870
top::EgammaCPTools::setupScaleFactors
StatusCode setupScaleFactors()
Definition: TopEgammaCPTools.cxx:234
top::EgammaCPTools::m_photonLooseIsEMSelector
ToolHandle< IAsgPhotonIsEMSelector > m_photonLooseIsEMSelector
Definition: TopEgammaCPTools.h:88
IAsgElectronEfficiencyCorrectionTool
Definition: IAsgElectronEfficiencyCorrectionTool.h:18
top::EgammaCPTools::m_photonMediumIsEMSelector
ToolHandle< IAsgPhotonIsEMSelector > m_photonMediumIsEMSelector
Definition: TopEgammaCPTools.h:87
EgammaCalibrationAndSmearingTool.h
top::EgammaCPTools::m_electronEffTriggerFile
std::string m_electronEffTriggerFile
Definition: TopEgammaCPTools.h:41
top::EgammaCPTools::EgammaCPTools
EgammaCPTools(const std::string &name)
Definition: TopEgammaCPTools.cxx:30