CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalCalibrator.cc
Go to the documentation of this file.
1 // -*- C++ -*-F
2 //---------------------------------------------------------------------------------
3 // Package: HcalCalibrator
4 // Class: HcalCalibrator
5 //
19 //
20 // Original Author: "Anton Anastassov"
21 // Created: Tue Sept 24 09:13:48 CDT 2008
22 //
23 //
24 //_________________________________________________________________________________
25 
26 
27 
28 // system include files
29 #include <memory>
30 #include <fstream>
31 #include <iostream>
32 
33 // user include files
34 
37 
40 
41 
45 
46 //--------------
48 
54 
56 
57 #include "TFile.h"
58 
59 
60 
62 
63 
64 
65 
66 using namespace edm;
67 //using namespace reco;
68 using namespace std;
69 
70 
71 // constructor
72 
74 
75  mInputFileList(conf.getUntrackedParameter<string>("inputFileList")),
76  // mOutputFile(conf.getUntrackedParameter<string>("outputFile")),
77 
78  mCalibType(conf.getUntrackedParameter<string>("calibType")),
79  mCalibMethod(conf.getUntrackedParameter<string>("calibMethod")),
80  mMinTargetE(conf.getUntrackedParameter<double>("minTargetE")),
81  mMaxTargetE(conf.getUntrackedParameter<double>("maxTargetE")),
82  mMinCellE(conf.getUntrackedParameter<double>("minCellE")),
83  mMinEOverP(conf.getUntrackedParameter<double>("minEOverP")),
84  mMaxEOverP(conf.getUntrackedParameter<double>("maxEOverP")),
85  mMaxTrkEmE(conf.getUntrackedParameter<double>("maxTrkEmE")),
86  mMaxEtThirdJet(conf.getUntrackedParameter<double>("maxEtThirdJet")),
87  mMinDPhiDiJets(conf.getUntrackedParameter<double>("minDPhiDiJets")),
88  mSumDepths(conf.getUntrackedParameter<bool>("sumDepths")),
89  mSumSmallDepths(conf.getUntrackedParameter<bool>("sumSmallDepths")),
90  mCombinePhi (conf.getUntrackedParameter<bool>("combinePhi")),
91  mHbClusterSize(conf.getUntrackedParameter<int>("hbClusterSize")),
92  mHeClusterSize(conf.getUntrackedParameter<int>("heClusterSize")),
93 
94  mUseConeClustering(conf.getUntrackedParameter<bool>("useConeClustering")),
95  mMaxConeDist(conf.getUntrackedParameter<double>("maxConeDist")),
96 
97  mCalibAbsIEtaMax(conf.getUntrackedParameter<int>("calibAbsIEtaMax")),
98  mCalibAbsIEtaMin(conf.getUntrackedParameter<int>("calibAbsIEtaMin")),
99  mMaxProbeJetEmFrac(conf.getUntrackedParameter<double>("maxProbeJetEmFrac")),
100  mMaxTagJetEmFrac(conf.getUntrackedParameter<double>("maxTagJetEmFrac")),
101  mMaxTagJetAbsEta(conf.getUntrackedParameter<double>("maxTagJetAbsEta")),
102  mMinTagJetEt(conf.getUntrackedParameter<double>("minTagJetEt")),
103  mMinProbeJetAbsEta(conf.getUntrackedParameter<double>("minProbeJetAbsEta")),
104  mPhiSymCorFileName(conf.getUntrackedParameter<string>("phiSymCorFileName")),
105  mApplyPhiSymCorFlag(conf.getUntrackedParameter<bool>("applyPhiSymCorFlag")),
106  mOutputCorCoefFileName(conf.getUntrackedParameter<string>("outputCorCoefFileName")),
107  mHistoFileName(conf.getUntrackedParameter<string>("histoFileName"))
108 
109 {
110 }
111 
112 
113 // destructor
114 
116 }
117 
118 // ------------ method called to for each event ------------
119 
120 void
123  iSetup.get<CaloGeometryRecord>().get(pG);
124  mTheCaloGeometry = pG.product();
126  iSetup.get<IdealGeometryRecord>().get(pT);
127  mTheHcalTopology = pT.product();
128 }
129 
130 // ------------ method called once each job just before starting event loop ------------
131 
132 void
134 
135  // ESHandle<CaloGeometry> theGeometry;
136  // ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
137  // evtSetup.get<CaloGeometryRecord>().get( theGeometry );
138 
139 
140  // edm::ESHandle<CaloGeometry> pG;
141  // evtSetup.get<CaloGeometryRecord>().get(pG);
142  // mTheCaloGeometry = pG.product();
143 
144 }
145 
146 // ------------ method called once each job just after ending the event loop ------------
147 
148 void
150 
151 
152  if (mCalibType!="DI_JET" && mCalibType!="ISO_TRACK") {
153  std::cout << "\n\nUnknown calibration type " << mCalibType << std::endl;
154  std::cout << "Please select ISO_TRACK or DI_JET in the python file." << std::endl;
155  return;
156  }
157 
158  if (mCalibMethod != "L3" && mCalibMethod != "MATRIX_INV_OF_ETA_AVE" && mCalibMethod != "L3_AND_MTRX_INV") {
159  std::cout << "\n\nUnknown calibration method " << mCalibMethod << std::endl;
160  std::cout << "Supported methods for IsoTrack calibration are: L3, MATRIX_INV_OF_ETA_AVE, L3_AND_MTRX_INV" << std::endl;
161  std::cout << "For DiJets the supported method is L3" << std::endl;
162  return;
163  }
164 
165  if (mCalibType=="DI_JET" && mCalibMethod!="L3") {
166  std::cout << "\n\nDiJet calibration can use only the L3 method. Please change the python file." << std::endl;
167  return;
168  }
169 
170  if (mCalibAbsIEtaMin<1 || mCalibAbsIEtaMax>41 || mCalibAbsIEtaMin>mCalibAbsIEtaMax) {
171  std::cout << "\n\nInvalid ABS(iEta) calibration range. Check calibAbsIEtaMin and calibAbsIEtaMax in the python file." << std::endl;
172  return;
173  }
174 
175 
176 
177  hcalCalib* calibrator = new hcalCalib();
178 
179  // set the parameters controlling the calibratoration
180 
181  calibrator->SetCalibType(mCalibType);
182  calibrator->SetCalibMethod(mCalibMethod);
183  calibrator->SetMinTargetE(mMinTargetE);
184  calibrator->SetMaxTargetE(mMaxTargetE);
185  calibrator->SetMaxEtThirdJet(mMaxEtThirdJet);
186  calibrator->SetMinDPhiDiJets(mMinDPhiDiJets);
187  calibrator->SetSumDepthsFlag(mSumDepths);
189  calibrator->SetCombinePhiFlag(mCombinePhi);
190  calibrator->SetMinCellE(mMinCellE);
191  calibrator->SetMinEOverP(mMinEOverP);
192  calibrator->SetMaxEOverP(mMaxEOverP);
193  calibrator->SetMaxTrkEmE(mMaxTrkEmE);
194  calibrator->SetHbClusterSize(mHbClusterSize);
195  calibrator->SetHeClusterSize(mHeClusterSize);
196 
198  calibrator->SetConeMaxDist(mMaxConeDist);
199 
205 
206  calibrator->SetMinTagJetEt(mMinTagJetEt);
207 
212 
213  calibrator->SetHistoFileName(mHistoFileName);
214 
216 
217 
218  std::ifstream inputFileList; // contains list of input root files
219 
220  TString files = mInputFileList;
221  inputFileList.open(files.Data());
222 
223  std::vector<TString> inputFiles;
224  while (!inputFileList.eof()) {
225  TString fileName;
226  inputFileList >> fileName;
227  if (!fileName.BeginsWith("#") && !fileName.Contains(" ") && fileName!="")
228  inputFiles.push_back(fileName);
229  }
230  inputFileList.close();
231 
232  std::cout << "\nInput files for processing:" << std::endl;
233  for (std::vector<TString>::iterator it=inputFiles.begin(); it!=inputFiles.end(); ++it) {
234  std::cout << "file: " << it->Data() << std::endl;
235  }
236  std::cout << std::endl;
237 
238 
239  TChain* fChain = new TChain("hcalCalibTree");
240 
241  for (std::vector<TString>::iterator f_it=inputFiles.begin();f_it!=inputFiles.end(); ++f_it) {
242  fChain->Add(f_it->Data());
243  }
244 
245 
246  fChain->Process(calibrator);
247 
248  if (fChain) delete fChain;
249  delete calibrator;
250 
251  return;
252 }
253 
254 
255 //define this as a plug-in
257 
258 
259 
void SetMaxTagJetAbsEta(Float_t e)
Definition: hcalCalib.h:176
void SetPhiSymCorFileName(const TString &filename)
Definition: hcalCalib.h:173
void SetHbClusterSize(Int_t i)
Definition: hcalCalib.h:162
void SetOutputCorCoefFileName(const TString &filename)
Definition: hcalCalib.h:179
void SetMinTagJetEt(Float_t e)
Definition: hcalCalib.h:177
void SetMaxEOverP(Float_t e)
Definition: hcalCalib.h:158
double mMinProbeJetAbsEta
void SetMaxProbeJetEmFrac(Float_t f)
Definition: hcalCalib.h:174
void SetSumSmallDepthsFlag(Bool_t b)
Definition: hcalCalib.h:154
void SetConeMaxDist(Float_t d)
Definition: hcalCalib.h:166
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void SetApplyPhiSymCorFlag(Bool_t b)
Definition: hcalCalib.h:172
const CaloGeometry * mTheCaloGeometry
void SetCalibType(const TString &s)
Definition: hcalCalib.h:160
void SetMinDPhiDiJets(Float_t dphi)
Definition: hcalCalib.h:171
void SetSumDepthsFlag(Bool_t b)
Definition: hcalCalib.h:153
std::string mHistoFileName
void SetUseConeClustering(Bool_t b)
Definition: hcalCalib.h:165
double mMaxTagJetAbsEta
double mMaxProbeJetEmFrac
const HcalTopology * mTheHcalTopology
int iEvent
Definition: GenABIO.cc:243
double mMaxTagJetEmFrac
void SetMinTargetE(Float_t e)
Definition: hcalCalib.h:151
void SetCalibMethod(const TString &s)
Definition: hcalCalib.h:161
void SetCalibAbsIEtaMax(Int_t i)
Definition: hcalCalib.h:168
double mMinDPhiDiJets
std::string mInputFileList
tuple inputFileList
Definition: diJetCalib.py:17
void SetMaxTargetE(Float_t e)
Definition: hcalCalib.h:152
std::string mCalibMethod
void SetMaxTrkEmE(Float_t e)
Definition: hcalCalib.h:159
tuple conf
Definition: dbtoconf.py:185
virtual void beginJob()
HcalCalibrator(const edm::ParameterSet &)
std::string mPhiSymCorFileName
void SetCaloGeometry(const CaloGeometry *g, const HcalTopology *topo)
Definition: hcalCalib.h:183
void SetMaxTagJetEmFrac(Float_t f)
Definition: hcalCalib.h:175
const T & get() const
Definition: EventSetup.h:55
virtual void endJob()
T const * product() const
Definition: ESHandle.h:62
bool mApplyPhiSymCorFlag
void SetCalibAbsIEtaMin(Int_t i)
Definition: hcalCalib.h:169
std::string mCalibType
std::string mOutputCorCoefFileName
void SetCombinePhiFlag(Bool_t b)
Definition: hcalCalib.h:155
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void SetHistoFileName(const TString &filename)
Definition: hcalCalib.h:180
tuple inputFiles
Definition: merge.py:5
tuple cout
Definition: gather_cfg.py:121
void SetHeClusterSize(Int_t i)
Definition: hcalCalib.h:163
void SetMinCellE(Float_t e)
Definition: hcalCalib.h:156
void SetMaxEtThirdJet(Float_t et)
Definition: hcalCalib.h:170
void SetMinProbeJetAbsEta(Float_t e)
Definition: hcalCalib.h:178
double mMaxEtThirdJet
void SetMinEOverP(Float_t e)
Definition: hcalCalib.h:157