CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 // system include files
27 #include <memory>
28 #include <fstream>
29 #include <iostream>
30 #include <string>
31 
32 // user include files
33 
36 
45 
50 
52 public:
53  explicit HcalCalibrator(const edm::ParameterSet&);
54  ~HcalCalibrator() override;
55 
56  // Added for running the CaloTower creation algorithm
57 
58 private:
59  void beginJob() override;
60  void analyze(const edm::Event&, const edm::EventSetup&) override;
61  void endJob() override;
62 
65 
68  double mMinTargetE;
69  double mMaxTargetE;
70  double mMinCellE;
71  double mMinEOverP;
72  double mMaxEOverP;
73  double mMaxTrkEmE;
74 
77  bool mSumDepths;
82 
84  double mMaxConeDist;
85 
88 
92  double mMinTagJetEt;
94 
97 
100 
103 
106 
108 };
109 
110 // constructor
111 
113  : mInputFileList(conf.getUntrackedParameter<std::string>("inputFileList")),
114  // mOutputFile(conf.getUntrackedParameter<std::string>("outputFile")),
115  mCalibType(conf.getUntrackedParameter<std::string>("calibType")),
116  mCalibMethod(conf.getUntrackedParameter<std::string>("calibMethod")),
117  mMinTargetE(conf.getUntrackedParameter<double>("minTargetE")),
118  mMaxTargetE(conf.getUntrackedParameter<double>("maxTargetE")),
119  mMinCellE(conf.getUntrackedParameter<double>("minCellE")),
120  mMinEOverP(conf.getUntrackedParameter<double>("minEOverP")),
121  mMaxEOverP(conf.getUntrackedParameter<double>("maxEOverP")),
122  mMaxTrkEmE(conf.getUntrackedParameter<double>("maxTrkEmE")),
123  mMaxEtThirdJet(conf.getUntrackedParameter<double>("maxEtThirdJet")),
124  mMinDPhiDiJets(conf.getUntrackedParameter<double>("minDPhiDiJets")),
125  mSumDepths(conf.getUntrackedParameter<bool>("sumDepths")),
126  mSumSmallDepths(conf.getUntrackedParameter<bool>("sumSmallDepths")),
127  mCombinePhi(conf.getUntrackedParameter<bool>("combinePhi")),
128  mHbClusterSize(conf.getUntrackedParameter<int>("hbClusterSize")),
129  mHeClusterSize(conf.getUntrackedParameter<int>("heClusterSize")),
130 
131  mUseConeClustering(conf.getUntrackedParameter<bool>("useConeClustering")),
132  mMaxConeDist(conf.getUntrackedParameter<double>("maxConeDist")),
133 
134  mCalibAbsIEtaMax(conf.getUntrackedParameter<int>("calibAbsIEtaMax")),
135  mCalibAbsIEtaMin(conf.getUntrackedParameter<int>("calibAbsIEtaMin")),
136  mMaxProbeJetEmFrac(conf.getUntrackedParameter<double>("maxProbeJetEmFrac")),
137  mMaxTagJetEmFrac(conf.getUntrackedParameter<double>("maxTagJetEmFrac")),
138  mMaxTagJetAbsEta(conf.getUntrackedParameter<double>("maxTagJetAbsEta")),
139  mMinTagJetEt(conf.getUntrackedParameter<double>("minTagJetEt")),
140  mMinProbeJetAbsEta(conf.getUntrackedParameter<double>("minProbeJetAbsEta")),
141  mPhiSymCorFileName(conf.getUntrackedParameter<std::string>("phiSymCorFileName")),
142  mApplyPhiSymCorFlag(conf.getUntrackedParameter<bool>("applyPhiSymCorFlag")),
143  mOutputCorCoefFileName(conf.getUntrackedParameter<std::string>("outputCorCoefFileName")),
144  mHistoFileName(conf.getUntrackedParameter<std::string>("histoFileName")) {
145  tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
146  tok_htopo_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
147 }
148 
149 // destructor
150 
152 
153 // ------------ method called to for each event ------------
154 
158 }
159 
160 // ------------ method called once each job just before starting event loop ------------
161 
163 
164 // ------------ method called once each job just after ending the event loop ------------
165 
167  if (mCalibType != "DI_JET" && mCalibType != "ISO_TRACK") {
168  edm::LogVerbatim("HcalCalib") << "\n\nUnknown calibration type " << mCalibType;
169  edm::LogVerbatim("HcalCalib") << "Please select ISO_TRACK or DI_JET in the python file.";
170  return;
171  }
172 
173  if (mCalibMethod != "L3" && mCalibMethod != "MATRIX_INV_OF_ETA_AVE" && mCalibMethod != "L3_AND_MTRX_INV") {
174  edm::LogVerbatim("HcalCalib") << "\n\nUnknown calibration method " << mCalibMethod;
175  edm::LogVerbatim("HcalCalib")
176  << "Supported methods for IsoTrack calibration are: L3, MATRIX_INV_OF_ETA_AVE, L3_AND_MTRX_INV";
177  edm::LogVerbatim("HcalCalib") << "For DiJets the supported method is L3";
178  return;
179  }
180 
181  if (mCalibType == "DI_JET" && mCalibMethod != "L3") {
182  edm::LogVerbatim("HcalCalib") << "\n\nDiJet calibration can use only the L3 method. Please change the python file.";
183  return;
184  }
185 
186  if (mCalibAbsIEtaMin < 1 || mCalibAbsIEtaMax > 41 || mCalibAbsIEtaMin > mCalibAbsIEtaMax) {
187  edm::LogVerbatim("HcalCalib")
188  << "\n\nInvalid ABS(iEta) calibration range. Check calibAbsIEtaMin and calibAbsIEtaMax in the python file.";
189  return;
190  }
191 
192  hcalCalib* calibrator = new hcalCalib();
193 
194  // set the parameters controlling the calibratoration
195 
196  calibrator->SetCalibType(mCalibType);
197  calibrator->SetCalibMethod(mCalibMethod);
198  calibrator->SetMinTargetE(mMinTargetE);
199  calibrator->SetMaxTargetE(mMaxTargetE);
200  calibrator->SetMaxEtThirdJet(mMaxEtThirdJet);
201  calibrator->SetMinDPhiDiJets(mMinDPhiDiJets);
202  calibrator->SetSumDepthsFlag(mSumDepths);
204  calibrator->SetCombinePhiFlag(mCombinePhi);
205  calibrator->SetMinCellE(mMinCellE);
206  calibrator->SetMinEOverP(mMinEOverP);
207  calibrator->SetMaxEOverP(mMaxEOverP);
208  calibrator->SetMaxTrkEmE(mMaxTrkEmE);
209  calibrator->SetHbClusterSize(mHbClusterSize);
210  calibrator->SetHeClusterSize(mHeClusterSize);
211 
213  calibrator->SetConeMaxDist(mMaxConeDist);
214 
220 
221  calibrator->SetMinTagJetEt(mMinTagJetEt);
222 
227 
228  calibrator->SetHistoFileName(mHistoFileName);
229 
231 
232  std::ifstream inputFileList; // contains list of input root files
233 
234  TString files = mInputFileList;
235  inputFileList.open(files.Data());
236 
237  std::vector<TString> inputFiles;
238  while (!inputFileList.eof()) {
239  TString fileName;
240  inputFileList >> fileName;
241  if (!fileName.BeginsWith("#") && !fileName.Contains(" ") && fileName != "")
242  inputFiles.push_back(fileName);
243  }
244  inputFileList.close();
245 
246  edm::LogVerbatim("HcalCalib") << "\nInput files for processing:";
247  for (std::vector<TString>::iterator it = inputFiles.begin(); it != inputFiles.end(); ++it) {
248  edm::LogVerbatim("HcalCalib") << "file: " << it->Data();
249  }
250 
251  TChain* fChain = new TChain("hcalCalibTree");
252 
253  for (std::vector<TString>::iterator f_it = inputFiles.begin(); f_it != inputFiles.end(); ++f_it) {
254  fChain->Add(f_it->Data());
255  }
256 
257  fChain->Process(calibrator);
258 
259  if (fChain)
260  delete fChain;
261  delete calibrator;
262 
263  return;
264 }
265 
266 //define this as a plug-in
void SetMaxTagJetAbsEta(Float_t e)
Definition: hcalCalib.h:208
void SetPhiSymCorFileName(const TString &filename)
Definition: hcalCalib.h:205
Log< level::Info, true > LogVerbatim
void SetHbClusterSize(Int_t i)
Definition: hcalCalib.h:194
void SetOutputCorCoefFileName(const TString &filename)
Definition: hcalCalib.h:211
void SetMinTagJetEt(Float_t e)
Definition: hcalCalib.h:209
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
void beginJob() override
void SetMaxEOverP(Float_t e)
Definition: hcalCalib.h:190
double mMinProbeJetAbsEta
void SetMaxProbeJetEmFrac(Float_t f)
Definition: hcalCalib.h:206
void SetSumSmallDepthsFlag(Bool_t b)
Definition: hcalCalib.h:186
void SetConeMaxDist(Float_t d)
Definition: hcalCalib.h:198
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void SetApplyPhiSymCorFlag(Bool_t b)
Definition: hcalCalib.h:204
std::string mOutputFile
const CaloGeometry * mTheCaloGeometry
void SetCalibType(const TString &s)
Definition: hcalCalib.h:192
void SetMinDPhiDiJets(Float_t dphi)
Definition: hcalCalib.h:203
void SetSumDepthsFlag(Bool_t b)
Definition: hcalCalib.h:185
std::string mHistoFileName
void analyze(const edm::Event &, const edm::EventSetup &) override
void SetUseConeClustering(Bool_t b)
Definition: hcalCalib.h:197
double mMaxTagJetAbsEta
double mMaxProbeJetEmFrac
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const HcalTopology * mTheHcalTopology
int iEvent
Definition: GenABIO.cc:224
double mMaxTagJetEmFrac
void SetMinTargetE(Float_t e)
Definition: hcalCalib.h:183
void SetCalibMethod(const TString &s)
Definition: hcalCalib.h:193
void SetCalibAbsIEtaMax(Int_t i)
Definition: hcalCalib.h:200
std::string mInputFileList
~HcalCalibrator() override
tuple inputFileList
Definition: diJetCalib.py:17
void SetMaxTargetE(Float_t e)
Definition: hcalCalib.h:184
std::string mCalibMethod
void SetMaxTrkEmE(Float_t e)
Definition: hcalCalib.h:191
HcalCalibrator(const edm::ParameterSet &)
std::string mPhiSymCorFileName
void SetCaloGeometry(const CaloGeometry *g, const HcalTopology *topo)
Definition: hcalCalib.h:214
void SetMaxTagJetEmFrac(Float_t f)
Definition: hcalCalib.h:207
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo_
void SetCalibAbsIEtaMin(Int_t i)
Definition: hcalCalib.h:201
std::string mCalibType
std::string mOutputCorCoefFileName
void SetCombinePhiFlag(Bool_t b)
Definition: hcalCalib.h:187
void SetHistoFileName(const TString &filename)
Definition: hcalCalib.h:212
void SetHeClusterSize(Int_t i)
Definition: hcalCalib.h:195
void SetMinCellE(Float_t e)
Definition: hcalCalib.h:188
void SetMaxEtThirdJet(Float_t et)
Definition: hcalCalib.h:202
void endJob() override
void SetMinProbeJetAbsEta(Float_t e)
Definition: hcalCalib.h:210
void SetMinEOverP(Float_t e)
Definition: hcalCalib.h:189