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 // $Id: HcalCalibrator.cc,v 1.5 2010/01/11 16:40:14 kodolova Exp $
23 //
24 //
25 //_________________________________________________________________________________
26 
27 
28 
29 // system include files
30 #include <memory>
31 #include <fstream>
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();
125 }
126 
127 // ------------ method called once each job just before starting event loop ------------
128 
129 void
131 
132  // ESHandle<CaloGeometry> theGeometry;
133  // ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
134  // evtSetup.get<CaloGeometryRecord>().get( theGeometry );
135 
136 
137  // edm::ESHandle<CaloGeometry> pG;
138  // evtSetup.get<CaloGeometryRecord>().get(pG);
139  // mTheCaloGeometry = pG.product();
140 
141 }
142 
143 // ------------ method called once each job just after ending the event loop ------------
144 
145 void
147 
148 
149  if (mCalibType!="DI_JET" && mCalibType!="ISO_TRACK") {
150  cout << "\n\nUnknown calibration type " << mCalibType << endl;
151  cout << "Please select ISO_TRACK or DI_JET in the python file." << endl;
152  return;
153  }
154 
155  if (mCalibMethod != "L3" && mCalibMethod != "MATRIX_INV_OF_ETA_AVE" && mCalibMethod != "L3_AND_MTRX_INV") {
156  cout << "\n\nUnknown calibration method " << mCalibMethod << endl;
157  cout << "Supported methods for IsoTrack calibration are: L3, MATRIX_INV_OF_ETA_AVE, L3_AND_MTRX_INV" << endl;
158  cout << "For DiJets the supported method is L3" << endl;
159  return;
160  }
161 
162  if (mCalibType=="DI_JET" && mCalibMethod!="L3") {
163  cout << "\n\nDiJet calibration can use only the L3 method. Please change the python file." << endl;
164  return;
165  }
166 
167  if (mCalibAbsIEtaMin<1 || mCalibAbsIEtaMax>41 || mCalibAbsIEtaMin>mCalibAbsIEtaMax) {
168  cout << "\n\nInvalid ABS(iEta) calibration range. Check calibAbsIEtaMin and calibAbsIEtaMax in the python file." << endl;
169  return;
170  }
171 
172 
173 
174  hcalCalib* calibrator = new hcalCalib();
175 
176  // set the parameters controlling the calibratoration
177 
178  calibrator->SetCalibType(mCalibType);
179  calibrator->SetCalibMethod(mCalibMethod);
180  calibrator->SetMinTargetE(mMinTargetE);
181  calibrator->SetMaxTargetE(mMaxTargetE);
182  calibrator->SetMaxEtThirdJet(mMaxEtThirdJet);
183  calibrator->SetMinDPhiDiJets(mMinDPhiDiJets);
184  calibrator->SetSumDepthsFlag(mSumDepths);
186  calibrator->SetCombinePhiFlag(mCombinePhi);
187  calibrator->SetMinCellE(mMinCellE);
188  calibrator->SetMinEOverP(mMinEOverP);
189  calibrator->SetMaxEOverP(mMaxEOverP);
190  calibrator->SetMaxTrkEmE(mMaxTrkEmE);
191  calibrator->SetHbClusterSize(mHbClusterSize);
192  calibrator->SetHeClusterSize(mHeClusterSize);
193 
195  calibrator->SetConeMaxDist(mMaxConeDist);
196 
202 
203  calibrator->SetMinTagJetEt(mMinTagJetEt);
204 
209 
210  calibrator->SetHistoFileName(mHistoFileName);
211 
212  calibrator->SetCaloGeometry(mTheCaloGeometry);
213 
214 
215  ifstream inputFileList; // contains list of input root files
216 
217  TString files = mInputFileList;
218  inputFileList.open(files.Data());
219 
220  std::vector<TString> inputFiles;
221  while (!inputFileList.eof()) {
222  TString fileName;
223  inputFileList >> fileName;
224  if (!fileName.BeginsWith("#") && !fileName.Contains(" ") && fileName!="")
225  inputFiles.push_back(fileName);
226  }
227  inputFileList.close();
228 
229  std::cout << "\nInput files for processing:" << std::endl;
230  for (std::vector<TString>::iterator it=inputFiles.begin(); it!=inputFiles.end(); ++it) {
231  std::cout << "file: " << it->Data() << std::endl;
232  }
233  std::cout << std::endl;
234 
235 
236  TChain* fChain = new TChain("hcalCalibTree");
237 
238  for (std::vector<TString>::iterator f_it=inputFiles.begin();f_it!=inputFiles.end(); ++f_it) {
239  fChain->Add(f_it->Data());
240  }
241 
242 
243  fChain->Process(calibrator);
244 
245  if (fChain) delete fChain;
246  delete calibrator;
247 
248  return;
249 }
250 
251 
252 //define this as a plug-in
254 
255 
256 
void SetMaxTagJetAbsEta(Float_t e)
Definition: hcalCalib.h:175
void SetHbClusterSize(Int_t i)
Definition: hcalCalib.h:161
void SetMinTagJetEt(Float_t e)
Definition: hcalCalib.h:176
void SetOutputCorCoefFileName(TString filename)
Definition: hcalCalib.h:178
void SetMaxEOverP(Float_t e)
Definition: hcalCalib.h:157
double mMinProbeJetAbsEta
void SetMaxProbeJetEmFrac(Float_t f)
Definition: hcalCalib.h:173
void SetSumSmallDepthsFlag(Bool_t b)
Definition: hcalCalib.h:153
void SetConeMaxDist(Float_t d)
Definition: hcalCalib.h:165
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void SetApplyPhiSymCorFlag(Bool_t b)
Definition: hcalCalib.h:171
const CaloGeometry * mTheCaloGeometry
void SetMinDPhiDiJets(Float_t dphi)
Definition: hcalCalib.h:170
void SetSumDepthsFlag(Bool_t b)
Definition: hcalCalib.h:152
std::string mHistoFileName
void SetUseConeClustering(Bool_t b)
Definition: hcalCalib.h:164
double mMaxTagJetAbsEta
double mMaxProbeJetEmFrac
int iEvent
Definition: GenABIO.cc:243
double mMaxTagJetEmFrac
void SetHistoFileName(TString filename)
Definition: hcalCalib.h:179
void SetMinTargetE(Float_t e)
Definition: hcalCalib.h:150
void SetCaloGeometry(const CaloGeometry *g)
Definition: hcalCalib.h:182
void SetCalibAbsIEtaMax(Int_t i)
Definition: hcalCalib.h:167
void SetPhiSymCorFileName(TString filename)
Definition: hcalCalib.h:172
double mMinDPhiDiJets
std::string mInputFileList
tuple inputFileList
Definition: diJetCalib.py:17
void SetMaxTargetE(Float_t e)
Definition: hcalCalib.h:151
std::string mCalibMethod
void SetMaxTrkEmE(Float_t e)
Definition: hcalCalib.h:158
tuple conf
Definition: dbtoconf.py:185
virtual void beginJob()
HcalCalibrator(const edm::ParameterSet &)
std::string mPhiSymCorFileName
void SetMaxTagJetEmFrac(Float_t f)
Definition: hcalCalib.h:174
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:168
void SetCalibMethod(TString s)
Definition: hcalCalib.h:160
std::string mCalibType
std::string mOutputCorCoefFileName
void SetCombinePhiFlag(Bool_t b)
Definition: hcalCalib.h:154
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void SetCalibType(TString s)
Definition: hcalCalib.h:159
tuple inputFiles
Definition: merge.py:5
tuple cout
Definition: gather_cfg.py:41
void SetHeClusterSize(Int_t i)
Definition: hcalCalib.h:162
void SetMinCellE(Float_t e)
Definition: hcalCalib.h:155
void SetMaxEtThirdJet(Float_t et)
Definition: hcalCalib.h:169
void SetMinProbeJetAbsEta(Float_t e)
Definition: hcalCalib.h:177
double mMaxEtThirdJet
void SetMinEOverP(Float_t e)
Definition: hcalCalib.h:156