ATLAS Offline Software
semilCorr.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 using namespace std;
8 
9 semilCorr::semilCorr(const TString& fIn, const string& /*suffix*/, bool DebugIn){
10  m_Debug = DebugIn;
11  m_f = TFile::Open(fIn);
12  m_etas.push_back(0);
13  m_etas.push_back(0.8);
14  m_etas.push_back(1.2);
15  m_etas.push_back(1.7);
16  m_etas.push_back(2.1);
17  m_etas.push_back(2.5);
18 
19  vector<string> etastr;
20  etastr.push_back("_e0");
21  etastr.push_back("_e1");
22  etastr.push_back("_e2");
23  etastr.push_back("_e3");
24  etastr.push_back("_e4");
25 
26  vector<string> prefix;
27  prefix.push_back("corr");
28  prefix.push_back("tagSyst");
29  prefix.push_back("fragSyst");
30  prefix.push_back("decaySyst");
31  prefix.push_back("msSyst");
32  prefix.push_back("idSyst");
33  prefix.push_back("decayRewSyst");
34  prefix.push_back("muRewSyst");
35  prefix.push_back("corrIncl");
36 
37  for(unsigned int j = 0; j<prefix.size(); j++){
38  vector<TH1F*> corr;
39  for(unsigned int i = 0; i<etastr.size(); i++){
40  corr.push_back((TH1F*) m_f->Get((prefix[j]+etastr[i]).c_str()));
41  }
42  m_histos.push_back(corr);
43  }
44 }
45 
46 
48  for(unsigned int i = 0; i<m_histos.size();i++){
49  for(unsigned int j = 0; j<m_histos[i].size();j++){
50  delete m_histos[i][j]; // TH2F's that store response info
51  }
52  }
53  m_f->Close();
54  delete m_f;
55 }
56 
57 float semilCorr::getSemilCorrToIncl(const TLorentzVector& jet,
58  const TLorentzVector& mu)
59 {
60  return getSemilCorrToIncl(jet,mu,m_histos[0]);
61 }
62 
63 float semilCorr::getBjetCorrToIncl(const TLorentzVector& jet,
64  const TLorentzVector& mu)
65 {
66  return getSemilCorrToIncl(jet,mu,m_histos[8]);
67 }
68 
69 float semilCorr::getSemilCorrToIncl(const TLorentzVector& jet,
70  const TLorentzVector& mu,
71  const vector<TH1F*>& histos)
72 {
73  TLorentzVector jetmu = jet+mu;
74  //correction to get things to 1 (or to pttruth), not to reference
75  float corr = getResponse(jetmu.Pt(), jetmu.Eta(), histos);
76  return corr;
77 }
78 
80 {
81  vector<int> indices;
82  if(syst == semilCorr::ALL){
83  indices.push_back(((int)semilCorr::TAGGINGWEIGHT));
84  indices.push_back(((int)semilCorr::FRAGMENTATION));
85  indices.push_back(((int)semilCorr::DECAY));
86  indices.push_back(((int)semilCorr::MSRESO));
87  indices.push_back(((int)semilCorr::IDRESO));
88  indices.push_back(((int)semilCorr::DECAYREW));
89  indices.push_back(((int)semilCorr::MUONSPECTRUM));
90  }else
91  indices.push_back((int) syst);
92  return indices;
93 }
94 
95 float semilCorr::getSemilCorrToInclSyst(const TLorentzVector& jet,
96  const TLorentzVector& mu,
98 {
99  //vector<int> indices = getHistoIndices(up,syst);
100  vector<int> indices1 = getHistoIndices(syst);
101  float systr = 0;
102  for(unsigned int i = 0; i<indices1.size(); i++){
103  systr += pow(getSemilCorrToIncl(jet,mu,m_histos[indices1[i]]),2);
104  }
105  return sqrt(systr);
106 }
107 
108 float semilCorr::getResponse(float pt, float eta, const vector<TH1F*>& h)
109 {
110  float usePt = pt;
111  int histbin = -1;
112  for(unsigned int i = 0; i<m_etas.size()-1; i++){
113  if(fabs(eta)>=m_etas[i] && fabs(eta)<m_etas[i+1])
114  histbin = i;
115  }
116 
117  if(histbin == -1) histbin = h.size()-1;
118  float min = h[histbin]->GetBinCenter(1);
119  float max = h[histbin]->GetBinCenter(h[histbin]->GetNbinsX());
120  if(pt>max)
121  usePt = max-0.001;
122  if(pt<min) usePt = min+0.001;
123  float result = h[histbin]->Interpolate(usePt);
124  return result;
125 }
126 
semilCorr::getSemilCorrToIncl
float getSemilCorrToIncl(const TLorentzVector &jet, const TLorentzVector &mu, const std::vector< TH1F * > &histos)
Definition: semilCorr.cxx:69
semilCorr::getBjetCorrToIncl
float getBjetCorrToIncl(const TLorentzVector &jet, const TLorentzVector &mu)
Definition: semilCorr.cxx:63
get_generator_info.result
result
Definition: get_generator_info.py:21
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
test_pyathena.pt
pt
Definition: test_pyathena.py:11
semilCorr::~semilCorr
~semilCorr()
Definition: semilCorr.cxx:47
semilCorr::TAGGINGWEIGHT
@ TAGGINGWEIGHT
Definition: semilCorr.h:19
semilCorr::ALL
@ ALL
Definition: semilCorr.h:26
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
h
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
semilCorr::getSemilCorrToInclSyst
float getSemilCorrToInclSyst(const TLorentzVector &jet, const TLorentzVector &mu, semilCorr::Systematics syst=semilCorr::ALL)
Definition: semilCorr.cxx:95
semilCorr::Systematics
Systematics
Definition: semilCorr.h:18
semilCorr::semilCorr
semilCorr(const TString &fIn, const std::string &suffix="", bool DebugIn=false)
Definition: semilCorr.cxx:9
semilCorr::getResponse
float getResponse(float pt, float eta, const std::vector< TH1F * > &h)
Definition: semilCorr.cxx:108
semilCorr::IDRESO
@ IDRESO
Definition: semilCorr.h:23
semilCorr::MUONSPECTRUM
@ MUONSPECTRUM
Definition: semilCorr.h:25
semilCorr::FRAGMENTATION
@ FRAGMENTATION
Definition: semilCorr.h:20
semilCorr::getHistoIndices
std::vector< int > getHistoIndices(semilCorr::Systematics syst)
Definition: semilCorr.cxx:79
checkCorrelInHIST.histos
dictionary histos
Definition: checkCorrelInHIST.py:413
semilCorr::MSRESO
@ MSRESO
Definition: semilCorr.h:22
semilCorr::DECAY
@ DECAY
Definition: semilCorr.h:21
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
semilCorr.h
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
MooRTT_summarizeCPU.fIn
fIn
Definition: MooRTT_summarizeCPU.py:11
semilCorr::DECAYREW
@ DECAYREW
Definition: semilCorr.h:24