ATLAS Offline Software
Loading...
Searching...
No Matches
HIEfficiencyResponseHistos.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
10
11#include "TH1.h"
12#include "TH2.h"
13#include "TProfile.h"
14
15
16#define toGeV 1/1000.
17#define toTeV 1/1000000.
18
20 , m_histoDef(this)
21{
22 declareProperty("HistoDef", m_histoDef, "The list of HistoDefinitionTool defining the histos to be used in this tool");
23 declareProperty("RefContainer", m_refContainerName);
24 declareProperty("HIEventShapeContainerName", m_container_key="CaloSums");
25}
26
27
28
30 CHECK( m_histoDef.retrieve() );
31 return StatusCode::SUCCESS;
32}
33
35 ATH_MSG_INFO(" buildHistos num of histos : "<< m_histoDef.size() );
36
38
39 // Histos are defined in jobOptions !
40 // For each histo, ask hbuilder if a corresponding definition exists in the jobOption list.
41 // -> if so a valid histo is returned (and booked)
42 // -> else NULL is returned
43 m_eff1 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR1") );
44 m_eff2 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR2") );
45 m_eff3 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR3") );
46
47 m_etres = bookHisto( hbuilder.build<TH1F>("erhResponse") );
48 m_etres_eta =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta") );
49 m_etres_eta_hpt =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_highpT") );
50 m_etres_pt =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt") );
51
52 m_deltaRclosest = bookHisto( hbuilder.build<TH1F>("erhDeltaR") );
54
55 m_eff1_0_10 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR1_0_10") );
56 m_eff2_0_10 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR2_0_10") );
57 m_eff3_0_10 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR3_0_10") );
58
59 m_eff1_10_20 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR1_10_20") );
60 m_eff2_10_20 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR2_10_20") );
61 m_eff3_10_20 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR3_10_20") );
62
63 m_eff1_20_40 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR1_20_40") );
64 m_eff2_20_40 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR2_20_40") );
65 m_eff3_20_40 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR3_20_40") );
66
67 m_eff1_60_100 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR1_60_100") );
68 m_eff2_60_100 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR2_60_100") );
69 m_eff3_60_100 = bookHisto( hbuilder.build<TProfile>("erhEfficiencyR3_60_100") );
70
71 m_etres_0_10 = bookHisto( hbuilder.build<TH1F>("erhResponse_0_10") );
72 m_etres_eta_0_10 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_0_10") );
73 m_etres_eta_hpt_0_10 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_highpT_0_10") );
74 m_etres_pt_0_10 =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt_0_10") );
75
76 m_etres_10_20 = bookHisto( hbuilder.build<TH1F>("erhResponse_10_20") );
77 m_etres_eta_10_20 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_10_20") );
78 m_etres_eta_hpt_10_20 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_highpT_10_20") );
79 m_etres_pt_10_20 =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt_10_20") );
80
81 m_etres_20_40 = bookHisto( hbuilder.build<TH1F>("erhResponse_20_40") );
82 m_etres_eta_20_40 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_20_40") );
83 m_etres_eta_hpt_20_40 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_highpT_20_40") );
84 m_etres_pt_20_40 =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt_20_40") );
85
86 m_etres_60_100 = bookHisto( hbuilder.build<TH1F>("erhResponse_60_100") );
87 m_etres_eta_60_100 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_60_100") );
88 m_etres_eta_hpt_60_100 =bookHisto( hbuilder.build<TProfile>("erhResponseVsEta_highpT_60_100") );
89 m_etres_pt_60_100 =bookHisto( hbuilder.build<TProfile>("erhResponseVsPt_60_100") );
90
91 m_etres_pt_RP = bookHisto( hbuilder.build<TProfile>("erhResponse_RP") );
92 m_etres_pt_2Dphi = bookHisto( hbuilder.build<TProfile>("erhResponse_2Dphi") );
93
94 m_etres_pt_hpt_RP = bookHisto( hbuilder.build<TProfile>("erhResponse_highpT_RP") );
95 m_etres_pt_hpt_2Dphi = bookHisto( hbuilder.build<TProfile>("erhResponse_highpT_2Dphi") );
96 return 0;
97}
98
99
101 m_n=2;
102 m_harmonic=m_n-1;
103 m_eventShape=nullptr;
104 CHECK( evtStore()->retrieve(m_eventShape,m_container_key), 1 );
105 m_FCalET=0;
106 m_psiN_FCal=0;
107 // m_vN_fcal=0;
108 for(const xAOD::HIEventShape* sh : *m_eventShape){
109 static const SG::ConstAccessor<std::string> SummaryAcc("Summary");
110 std::string summary = SummaryAcc.withDefault(*sh, "");
111 if(summary.compare("FCal")==0){
112 m_FCalET=sh->et()*toTeV;
113 float qx=sh->etCos().at(m_harmonic);
114 float qy=sh->etSin().at(m_harmonic);
115 m_psiN_FCal=std::atan2(qy,qx)/float(m_n); // Psi2 (m_n=2)
116 // vN_fcal=std::sqrt(qx+qx+qy*qy)/m_FCalET;
117 break;
118 }
119 }
120
121 const xAOD::JetContainer* refContainer = nullptr;
122 CHECK( evtStore()->retrieve( refContainer, m_refContainerName), 1 );
124 std::list<const xAOD::Jet*> listJets(cont.begin(), cont.end());
125
126 for ( const xAOD::Jet* refjet : *refContainer ){
127 double dr2min = 500000;
128
129 if (listJets.empty() ) break;
130 // find the min match
131 std::list<const xAOD::Jet*>::iterator it=listJets.begin();
132 std::list<const xAOD::Jet*>::iterator itmin=listJets.end();
133 for( ; it != listJets.end(); ++it) {
134 double dr2 = xAOD::P4Helpers::deltaR2(*(*it),*refjet);
135 if(dr2 < dr2min) { dr2min = dr2; itmin = it ;}
136 }
137 if (itmin == listJets.end()) break;
138 const xAOD::Jet* matched = *itmin;
139 //cppcheck-suppress eraseIteratorOutOfBoundsCond
140 listJets.erase(itmin);
141
142 double dr = sqrt(dr2min);
143 double refPt = refjet->pt() * toGeV;
144
145 if (fabs(refjet->eta()) > 2.1 ) continue;
146 // if (refPt<100 ) continue;
147 m_eff1->Fill(refPt, dr<0.1 ? weight : 0 ); // 0 weight if not matching close enough
148 m_eff2->Fill(refPt, dr<0.2 ? weight : 0 ); // 0 weight if not matching close enough
149 m_eff3->Fill(refPt, dr<0.3 ? weight : 0 ); // 0 weight if not matching close enough
150
151 if (m_FCalET > 2.7){
152 m_eff1_0_10->Fill(refPt, dr<0.1 ? weight : 0 ); // 0 weight if not matching close enough
153 m_eff2_0_10->Fill(refPt, dr<0.2 ? weight : 0 ); // 0 weight if not matching close enough
154 m_eff3_0_10->Fill(refPt, dr<0.3 ? weight : 0 ); // 0 weight if not matching close enough
155 }
156 if (m_FCalET < 2.7 && m_FCalET > 1.75 ){//10-20%
157 m_eff1_10_20->Fill(refPt, dr<0.1 ? weight : 0 ); // 0 weight if not matching close enough
158 m_eff2_10_20->Fill(refPt, dr<0.2 ? weight : 0 ); // 0 weight if not matching close enough
159 m_eff3_10_20->Fill(refPt, dr<0.3 ? weight : 0 ); // 0 weight if not matching close enough
160 }
161 if (m_FCalET < 1.75 && m_FCalET > 0.65 ){//20-40%
162 m_eff1_20_40->Fill(refPt, dr<0.1 ? weight : 0 ); // 0 weight if not matching close enough
163 m_eff2_20_40->Fill(refPt, dr<0.2 ? weight : 0 ); // 0 weight if not matching close enough
164 m_eff3_20_40->Fill(refPt, dr<0.3 ? weight : 0 ); // 0 weight if not matching close enough
165 }
166 if (m_FCalET < 0.20 ){//60-100%
167 m_eff1_60_100->Fill(refPt, dr<0.1 ? weight : 0 ); // 0 weight if not matching close enough
168 m_eff2_60_100->Fill(refPt, dr<0.2 ? weight : 0 ); // 0 weight if not matching close enough
169 m_eff3_60_100->Fill(refPt, dr<0.3 ? weight : 0 ); // 0 weight if not matching close enough
170 }
171 m_deltaRclosest->Fill( dr );
172 float Acos = std::acos(std::cos(2*(matched->getAttribute<float>("JetEtaJESScaleMomentum_phi") - m_psiN_FCal)));
173 // float diff = fabs(matched->phi() - m_psiN_FCal);
174 // while (diff > TMath::Pi()/2. ) diff = TMath::Pi() - diff;
175
176 if( dr < 0.2) {
177 double relDiff = -999.;
178 if (refPt > 0.) relDiff = ( matched->pt()* toGeV - refPt )/refPt;
179 m_etres->Fill( relDiff, weight );
180 m_etres_eta->Fill( refjet->eta(), relDiff);
181 if (matched->pt()* toGeV > 100) {
182 m_etres_eta_hpt->Fill( refjet->eta(), relDiff, weight);
183 m_etres_pt_hpt_RP->Fill( m_psiN_FCal, relDiff, weight );
184 m_etres_pt_hpt_2Dphi->Fill( Acos, relDiff, weight );
185 }
186 m_etres_pt->Fill( refPt, relDiff, weight);
187 m_etres_pt_2Dphi->Fill( Acos, relDiff, weight );
188 m_etres_pt_RP->Fill( m_psiN_FCal, relDiff, weight );
189 if (m_FCalET > 2.7){
190 m_etres_0_10->Fill( relDiff, weight );
191 m_etres_eta_0_10->Fill( refjet->eta(), relDiff, weight);
192 if (matched->pt()* toGeV > 100) m_etres_eta_hpt_0_10->Fill( refjet->eta(), relDiff, weight);
193 m_etres_pt_0_10->Fill( refPt, relDiff, weight);
194 }
195 if (m_FCalET < 2.7 && m_FCalET > 1.75 ){//10-20%
196 m_etres_10_20->Fill( relDiff, weight );
197 m_etres_eta_10_20->Fill( refjet->eta(), relDiff, weight);
198 if (matched->pt()* toGeV > 100) m_etres_eta_hpt_10_20->Fill( refjet->eta(), relDiff, weight);
199 m_etres_pt_10_20->Fill( refPt, relDiff, weight);
200 }
201 if (m_FCalET < 1.75 && m_FCalET > 0.65 ){//20-40%
202 m_etres_20_40->Fill( relDiff, weight );
203 m_etres_eta_20_40->Fill( refjet->eta(), relDiff, weight);
204 if (matched->pt()* toGeV > 100) m_etres_eta_hpt_20_40->Fill( refjet->eta(), relDiff, weight);
205 m_etres_pt_20_40->Fill( refPt, relDiff, weight);
206 }
207 if (m_FCalET < 0.20 ){//60-100%
208 m_etres_60_100->Fill( relDiff, weight );
209 m_etres_eta_60_100->Fill( refjet->eta(), relDiff, weight);
210 if (matched->pt()* toGeV > 100) m_etres_eta_hpt_60_100->Fill( refjet->eta(), relDiff, weight);
211 m_etres_pt_60_100->Fill( refPt, relDiff, weight);
212 }
213
214 }
215
216 }
217
218
219 return 0;
220}
#define ATH_MSG_INFO(x)
Helper class to provide constant type-safe access to aux data.
#define CHECK(...)
Evaluate an expression and check for errors.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
ToolHandleArray< HistoDefinitionTool > m_histoDef
const xAOD::HIEventShapeContainer * m_eventShape
HIEfficiencyResponseHistos(const std::string &t)
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
virtual int fillHistosFromContainer(const xAOD::JetContainer &cont, float weight)
T * bookHisto(T *h, Interval_t ityp=useToolInterval)
register the histo h in this group (if h!=NULL). The histo name is changed if m_prefixedHistoName==tr...
JetHistoBase(const std::string &t)
Helper class to provide constant type-safe access to aux data.
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
bool getAttribute(AttributeID type, T &value) const
Retrieve attribute moment by enum.
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
HIEventShape_v2 HIEventShape
Definition of the latest event info version.