CMS 3D CMS Logo

hcalCalib.h
Go to the documentation of this file.
1 // This class skeleton has been automatically generated on
3 // from TTree hcalCalibTree/Tree for IsoTrack Calibration
4 // with ROOT version 5.17/02
5 //
6 // TSelector-based code for getting the HCAL resp. correction
7 // from physics events. Works for DiJet and IsoTrack calibration.
8 //
9 // Anton Anastassov (Northwestern)
10 // Email: aa@fnal.gov
11 //
12 //
14 
15 #ifndef hcalCalib_h
16 #define hcalCalib_h
17 
18 #include <vector>
19 #include <map>
20 
21 #include <TROOT.h>
22 #include <TChain.h>
23 #include <TFile.h>
24 #include <TSelector.h>
25 #include <TROOT.h>
26 #include <TChain.h>
27 #include <TFile.h>
28 #include <TSelector.h>
29 
30 #include "TLorentzVector.h"
31 #include "TClonesArray.h"
32 #include "TRefArray.h"
33 
34 // needed to get cell coordinates
37 
38 class hcalCalib : public TSelector {
39 public:
40  TTree *fChain;
41 
42  UInt_t eventNumber;
43  UInt_t runNumber;
44  Int_t iEtaHit;
45  UInt_t iPhiHit;
46  TClonesArray *cells;
47  Float_t emEnergy;
48  Float_t targetE;
49  Float_t etVetoJet;
50 
51  Float_t xTrkHcal;
52  Float_t yTrkHcal;
53  Float_t zTrkHcal;
54  Float_t xTrkEcal;
55  Float_t yTrkEcal;
56  Float_t zTrkEcal;
57 
58  TLorentzVector *tagJetP4;
59  TLorentzVector *probeJetP4;
60 
61  Float_t tagJetEmFrac;
62  Float_t probeJetEmFrac;
63 
64  // List of branches
65  TBranch *b_eventNumber;
66  TBranch *b_runNumber;
67  TBranch *b_iEtaHit;
68  TBranch *b_iPhiHit;
69  TBranch *b_cells;
70  TBranch *b_emEnergy;
71  TBranch *b_targetE;
72  TBranch *b_etVetoJet;
73 
74  TBranch *b_xTrkHcal;
75  TBranch *b_yTrkHcal;
76  TBranch *b_zTrkHcal;
77  TBranch *b_xTrkEcal;
78  TBranch *b_yTrkEcal;
79  TBranch *b_zTrkEcal;
80 
81  TBranch *b_tagJetEmFrac;
82  TBranch *b_probeJetEmFrac;
83 
84  TBranch *b_tagJetP4;
85  TBranch *b_probeJetP4;
86 
87  hcalCalib(TTree * /*tree*/ = nullptr) {}
88  ~hcalCalib() override {}
89  Int_t Version() const override { return 2; }
90  void Begin(TTree *tree) override;
91  // virtual void SlaveBegin(TTree *tree);
92  void Init(TTree *tree) override;
93  Bool_t Notify() override;
94  Bool_t Process(Long64_t entry) override;
95  Int_t GetEntry(Long64_t entry, Int_t getall = 0) override {
96  return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0;
97  }
98  void SetOption(const char *option) override { fOption = option; }
99  void SetObject(TObject *obj) override { fObject = obj; }
100  void SetInputList(TList *input) override { fInput = input; }
101  TList *GetOutputList() const override { return fOutput; }
102  // virtual void SlaveTerminate();
103  void Terminate() override;
104 
105  //------------ CUTS ---------------
106  Float_t MIN_TARGET_E;
107  Float_t MAX_TARGET_E;
108 
109  Float_t MIN_CELL_E;
110  Float_t MIN_EOVERP;
111  Float_t MAX_EOVERP;
112  Float_t MAX_TRK_EME;
113 
116 
117  Bool_t SUM_DEPTHS;
119  Bool_t COMBINE_PHI;
120 
123 
125  Float_t MAX_CONE_DIST;
126 
129 
133  Float_t MIN_TAGJET_ET;
134 
136 
137  TString CALIB_TYPE; // "ISO_TRACK" or "DI_JET"
138  TString CALIB_METHOD; // L3, matrix inversion, everage then matrix inversion,...
139 
142 
144  TString HISTO_FILENAME;
145 
148 
149  void SetMinTargetE(Float_t e) { MIN_TARGET_E = e; }
150  void SetMaxTargetE(Float_t e) { MAX_TARGET_E = e; }
151  void SetSumDepthsFlag(Bool_t b) { SUM_DEPTHS = b; }
152  void SetSumSmallDepthsFlag(Bool_t b) { SUM_SMALL_DEPTHS = b; }
153  void SetCombinePhiFlag(Bool_t b) { COMBINE_PHI = b; }
154  void SetMinCellE(Float_t e) { MIN_CELL_E = e; }
155  void SetMinEOverP(Float_t e) { MIN_EOVERP = e; }
156  void SetMaxEOverP(Float_t e) { MAX_EOVERP = e; }
157  void SetMaxTrkEmE(Float_t e) { MAX_TRK_EME = e; }
158  void SetCalibType(const TString &s) { CALIB_TYPE = s; }
159  void SetCalibMethod(const TString &s) { CALIB_METHOD = s; }
160  void SetHbClusterSize(Int_t i) { HB_CLUSTER_SIZE = i; }
161  void SetHeClusterSize(Int_t i) { HE_CLUSTER_SIZE = i; }
162 
163  void SetUseConeClustering(Bool_t b) { USE_CONE_CLUSTERING = b; }
164  void SetConeMaxDist(Float_t d) { MAX_CONE_DIST = d; }
165 
166  void SetCalibAbsIEtaMax(Int_t i) { CALIB_ABS_IETA_MAX = i; }
167  void SetCalibAbsIEtaMin(Int_t i) { CALIB_ABS_IETA_MIN = i; }
168  void SetMaxEtThirdJet(Float_t et) { MAX_ET_THIRD_JET = et; }
169  void SetMinDPhiDiJets(Float_t dphi) { MIN_DPHI_DIJETS = dphi; }
170  void SetApplyPhiSymCorFlag(Bool_t b) { APPLY_PHI_SYM_COR_FLAG = b; }
171  void SetPhiSymCorFileName(const TString &filename) { PHI_SYM_COR_FILENAME = filename; }
172  void SetMaxProbeJetEmFrac(Float_t f) { MAX_PROBEJET_EMFRAC = f; }
173  void SetMaxTagJetEmFrac(Float_t f) { MAX_TAGJET_EMFRAC = f; }
174  void SetMaxTagJetAbsEta(Float_t e) { MAX_TAGJET_ABSETA = e; }
175  void SetMinTagJetEt(Float_t e) { MIN_TAGJET_ET = e; }
176  void SetMinProbeJetAbsEta(Float_t e) { MIN_PROBEJET_ABSETA = e; }
177  void SetOutputCorCoefFileName(const TString &filename) { OUTPUT_COR_COEF_FILENAME = filename; }
178  void SetHistoFileName(const TString &filename) { HISTO_FILENAME = filename; }
179 
180  void SetCaloGeometry(const CaloGeometry *g, const HcalTopology *topo) {
181  theCaloGeometry = g;
182  topo_ = topo;
183  }
184 
186 
187  Bool_t ReadPhiSymCor();
188 
189  void makeTextFile();
190 
191  // --------- containers passed to minimizers ----------------
192  std::vector<std::vector<Float_t> > cellEnergies;
193  std::vector<std::vector<UInt_t> > cellIds;
194  std::vector<std::pair<Int_t, UInt_t> > refIEtaIPhi; // centroid of jet or hottest tower iEta, iPhi
195  std::vector<Float_t> targetEnergies;
196 
197  std::map<UInt_t, Float_t> phiSymCor; // holds the phi symmetry corrections read from the file
198 
199  std::map<UInt_t, Float_t> solution; // correction coef: solution from L3, holds final coef for hybrid methods as well
200  std::map<Int_t, Float_t>
201  iEtaCoefMap; // correction coef: from matrix inversion AFTER averaging, also intermediate results for hybrid methods
202 
203  // ClassDef(hcalCalib,0);
204 };
205 
206 #endif
207 
208 #ifdef hcalCalib_cxx
209 void hcalCalib::Init(TTree *tree) {
210  // The Init() function is called when the selector needs to initialize
211  // a new tree or chain. Typically here the branch addresses and branch
212  // pointers of the tree will be set.
213  // It is normaly not necessary to make changes to the generated
214  // code, but the routine can be extended by the user if needed.
215  // Init() will be called many times when running on PROOF
216  // (once per file to be processed).
217 
218  // Set object pointer
219  cells = nullptr;
220  tagJetP4 = nullptr;
221  probeJetP4 = nullptr;
222 
223  // Set branch addresses and branch pointers
224  if (!tree)
225  return;
226  fChain = tree;
227 
228  // fChain->SetMakeClass(1);
229 
230  fChain->SetBranchAddress("eventNumber", &eventNumber, &b_eventNumber);
231  fChain->SetBranchAddress("runNumber", &runNumber, &b_runNumber);
232  fChain->SetBranchAddress("iEtaHit", &iEtaHit, &b_iEtaHit);
233  fChain->SetBranchAddress("iPhiHit", &iPhiHit, &b_iPhiHit);
234  fChain->SetBranchAddress("cells", &cells, &b_cells);
235  fChain->SetBranchAddress("emEnergy", &emEnergy, &b_emEnergy);
236  fChain->SetBranchAddress("targetE", &targetE, &b_targetE);
237  fChain->SetBranchAddress("etVetoJet", &etVetoJet, &b_etVetoJet);
238 
239  fChain->SetBranchAddress("xTrkHcal", &xTrkHcal, &b_xTrkHcal);
240  fChain->SetBranchAddress("yTrkHcal", &yTrkHcal, &b_yTrkHcal);
241  fChain->SetBranchAddress("zTrkHcal", &zTrkHcal, &b_zTrkHcal);
242  fChain->SetBranchAddress("xTrkEcal", &xTrkEcal, &b_xTrkEcal);
243  fChain->SetBranchAddress("yTrkEcal", &yTrkEcal, &b_yTrkEcal);
244  fChain->SetBranchAddress("zTrkEcal", &zTrkEcal, &b_zTrkEcal);
245 
246  fChain->SetBranchAddress("tagJetEmFrac", &tagJetEmFrac, &b_tagJetEmFrac);
247  fChain->SetBranchAddress("probeJetEmFrac", &probeJetEmFrac, &b_probeJetEmFrac);
248 
249  fChain->SetBranchAddress("tagJetP4", &tagJetP4, &b_tagJetP4);
250  fChain->SetBranchAddress("probeJetP4", &probeJetP4, &b_probeJetP4);
251 }
252 
253 Bool_t hcalCalib::Notify() {
254  // The Notify() function is called when a new file is opened. This
255  // can be either for a new TTree in a TChain or when when a new TTree
256  // is started when using PROOF. It is normaly not necessary to make changes
257  // to the generated code, but the routine can be extended by the
258  // user if needed. The return value is currently not used.
259 
260  return kTRUE;
261 }
262 
263 #endif // #ifdef hcalCalib_cxx
std::vector< std::pair< Int_t, UInt_t > > refIEtaIPhi
Definition: hcalCalib.h:194
void SetMaxTagJetAbsEta(Float_t e)
Definition: hcalCalib.h:174
void SetPhiSymCorFileName(const TString &filename)
Definition: hcalCalib.h:171
std::vector< Float_t > targetEnergies
Definition: hcalCalib.h:195
void SetHbClusterSize(Int_t i)
Definition: hcalCalib.h:160
std::map< Int_t, Float_t > iEtaCoefMap
Definition: hcalCalib.h:201
void SetOutputCorCoefFileName(const TString &filename)
Definition: hcalCalib.h:177
void SetMinTagJetEt(Float_t e)
Definition: hcalCalib.h:175
TBranch * b_iEtaHit
Definition: hcalCalib.h:67
TTree * fChain
Definition: hcalCalib.h:40
UInt_t eventNumber
pointer to the analyzed TTree or TChain
Definition: hcalCalib.h:42
Float_t MAX_TARGET_E
Definition: hcalCalib.h:107
TBranch * b_etVetoJet
Definition: hcalCalib.h:72
std::vector< std::vector< UInt_t > > cellIds
Definition: hcalCalib.h:193
TString PHI_SYM_COR_FILENAME
Definition: hcalCalib.h:140
void SetMaxEOverP(Float_t e)
Definition: hcalCalib.h:156
TBranch * b_yTrkEcal
Definition: hcalCalib.h:78
void SetMaxProbeJetEmFrac(Float_t f)
Definition: hcalCalib.h:172
void SetSumSmallDepthsFlag(Bool_t b)
Definition: hcalCalib.h:152
void GetCoefFromMtrxInvOfAve()
Definition: hcalCalib.cc:511
void Begin(TTree *tree) override
Definition: hcalCalib.cc:67
TBranch * b_probeJetEmFrac
Definition: hcalCalib.h:82
void SetConeMaxDist(Float_t d)
Definition: hcalCalib.h:164
void SetApplyPhiSymCorFlag(Bool_t b)
Definition: hcalCalib.h:170
TBranch * b_iPhiHit
Definition: hcalCalib.h:68
~hcalCalib() override
Definition: hcalCalib.h:88
Float_t xTrkHcal
Definition: hcalCalib.h:51
TString CALIB_TYPE
Definition: hcalCalib.h:137
TLorentzVector * tagJetP4
Definition: hcalCalib.h:58
Float_t tagJetEmFrac
Definition: hcalCalib.h:61
void SetOption(const char *option) override
Definition: hcalCalib.h:98
Float_t zTrkHcal
Definition: hcalCalib.h:53
std::map< UInt_t, Float_t > phiSymCor
Definition: hcalCalib.h:197
void SetCalibType(const TString &s)
Definition: hcalCalib.h:158
Float_t xTrkEcal
Definition: hcalCalib.h:54
void SetMinDPhiDiJets(Float_t dphi)
Definition: hcalCalib.h:169
Float_t MAX_EOVERP
Definition: hcalCalib.h:111
Float_t targetE
Definition: hcalCalib.h:48
Bool_t SUM_DEPTHS
Definition: hcalCalib.h:117
Float_t MIN_CELL_E
Definition: hcalCalib.h:109
void SetSumDepthsFlag(Bool_t b)
Definition: hcalCalib.h:151
TLorentzVector * probeJetP4
Definition: hcalCalib.h:59
void SetUseConeClustering(Bool_t b)
Definition: hcalCalib.h:163
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
static std::string const input
Definition: EdmProvDump.cc:48
Float_t yTrkEcal
Definition: hcalCalib.h:55
Int_t CALIB_ABS_IETA_MIN
Definition: hcalCalib.h:128
void SetObject(TObject *obj) override
Definition: hcalCalib.h:99
TBranch * b_zTrkHcal
Definition: hcalCalib.h:76
TBranch * b_tagJetP4
Definition: hcalCalib.h:84
Int_t HE_CLUSTER_SIZE
Definition: hcalCalib.h:122
TBranch * b_runNumber
Definition: hcalCalib.h:66
void SetMinTargetE(Float_t e)
Definition: hcalCalib.h:149
Int_t iEtaHit
Definition: hcalCalib.h:44
Float_t MAX_TRK_EME
Definition: hcalCalib.h:112
TBranch * b_zTrkEcal
Definition: hcalCalib.h:79
Float_t MIN_DPHI_DIJETS
Definition: hcalCalib.h:115
Int_t HB_CLUSTER_SIZE
Definition: hcalCalib.h:121
void SetCalibMethod(const TString &s)
Definition: hcalCalib.h:159
Float_t MIN_TAGJET_ET
Definition: hcalCalib.h:133
void Terminate() override
Definition: hcalCalib.cc:357
void SetCalibAbsIEtaMax(Int_t i)
Definition: hcalCalib.h:166
TBranch * b_eventNumber
Definition: hcalCalib.h:65
Bool_t APPLY_PHI_SYM_COR_FLAG
Definition: hcalCalib.h:141
Float_t zTrkEcal
Definition: hcalCalib.h:56
double f[11][100]
TBranch * b_tagJetEmFrac
Definition: hcalCalib.h:81
const HcalTopology * topo_
Definition: hcalCalib.h:147
std::map< UInt_t, Float_t > solution
Definition: hcalCalib.h:199
Float_t emEnergy
Definition: hcalCalib.h:47
void SetMaxTargetE(Float_t e)
Definition: hcalCalib.h:150
std::vector< std::vector< Float_t > > cellEnergies
Definition: hcalCalib.h:192
Float_t MIN_EOVERP
Definition: hcalCalib.h:110
TBranch * b_cells
Definition: hcalCalib.h:69
void SetMaxTrkEmE(Float_t e)
Definition: hcalCalib.h:157
Float_t MIN_PROBEJET_ABSETA
Definition: hcalCalib.h:135
Bool_t COMBINE_PHI
Definition: hcalCalib.h:119
Float_t MAX_ET_THIRD_JET
Definition: hcalCalib.h:114
UInt_t iPhiHit
Definition: hcalCalib.h:45
Bool_t USE_CONE_CLUSTERING
Definition: hcalCalib.h:124
TString CALIB_METHOD
Definition: hcalCalib.h:138
TString OUTPUT_COR_COEF_FILENAME
Definition: hcalCalib.h:143
void SetCaloGeometry(const CaloGeometry *g, const HcalTopology *topo)
Definition: hcalCalib.h:180
Int_t Version() const override
Definition: hcalCalib.h:89
void SetMaxTagJetEmFrac(Float_t f)
Definition: hcalCalib.h:173
void SetCalibAbsIEtaMin(Int_t i)
Definition: hcalCalib.h:167
double b
Definition: hdecay.h:120
Int_t CALIB_ABS_IETA_MAX
Definition: hcalCalib.h:127
TList * GetOutputList() const override
Definition: hcalCalib.h:101
void Init(TTree *tree) override
TBranch * b_yTrkHcal
Definition: hcalCalib.h:75
Float_t etVetoJet
Definition: hcalCalib.h:49
et
define resolution functions of each parameter
TBranch * b_emEnergy
Definition: hcalCalib.h:70
void SetInputList(TList *input) override
Definition: hcalCalib.h:100
void makeTextFile()
Definition: hcalCalib.cc:661
TBranch * b_xTrkEcal
Definition: hcalCalib.h:77
Bool_t Process(Long64_t entry) override
Definition: hcalCalib.cc:152
Bool_t ReadPhiSymCor()
Definition: hcalCalib.cc:599
void SetCombinePhiFlag(Bool_t b)
Definition: hcalCalib.h:153
TClonesArray * cells
Definition: hcalCalib.h:46
Bool_t SUM_SMALL_DEPTHS
Definition: hcalCalib.h:118
void SetHistoFileName(const TString &filename)
Definition: hcalCalib.h:178
Int_t GetEntry(Long64_t entry, Int_t getall=0) override
Definition: hcalCalib.h:95
Float_t MIN_TARGET_E
Definition: hcalCalib.h:106
TString HISTO_FILENAME
Definition: hcalCalib.h:144
Float_t MAX_TAGJET_EMFRAC
Definition: hcalCalib.h:131
Float_t MAX_TAGJET_ABSETA
Definition: hcalCalib.h:132
Definition: tree.py:1
Float_t MAX_PROBEJET_EMFRAC
Definition: hcalCalib.h:130
const CaloGeometry * theCaloGeometry
Definition: hcalCalib.h:146
void SetHeClusterSize(Int_t i)
Definition: hcalCalib.h:161
void SetMinCellE(Float_t e)
Definition: hcalCalib.h:154
void SetMaxEtThirdJet(Float_t et)
Definition: hcalCalib.h:168
hcalCalib(TTree *=0)
Definition: hcalCalib.h:87
UInt_t runNumber
Definition: hcalCalib.h:43
TBranch * b_xTrkHcal
Definition: hcalCalib.h:74
TBranch * b_targetE
Definition: hcalCalib.h:71
Float_t MAX_CONE_DIST
Definition: hcalCalib.h:125
Float_t yTrkHcal
Definition: hcalCalib.h:52
void SetMinProbeJetAbsEta(Float_t e)
Definition: hcalCalib.h:176
Bool_t Notify() override
Float_t probeJetEmFrac
Definition: hcalCalib.h:62
void SetMinEOverP(Float_t e)
Definition: hcalCalib.h:155
TBranch * b_probeJetP4
Definition: hcalCalib.h:85