CMS 3D CMS Logo

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 
31 // user include files
32 
35 
38 
42 
43 //--------------
45 
51 
53 
54 #include "TFile.h"
55 
57 
58 using namespace edm;
59 //using namespace reco;
60 using namespace std;
61 
62 // constructor
63 
65  :
66 
67  mInputFileList(conf.getUntrackedParameter<string>("inputFileList")),
68  // mOutputFile(conf.getUntrackedParameter<string>("outputFile")),
69 
70  mCalibType(conf.getUntrackedParameter<string>("calibType")),
71  mCalibMethod(conf.getUntrackedParameter<string>("calibMethod")),
72  mMinTargetE(conf.getUntrackedParameter<double>("minTargetE")),
73  mMaxTargetE(conf.getUntrackedParameter<double>("maxTargetE")),
74  mMinCellE(conf.getUntrackedParameter<double>("minCellE")),
75  mMinEOverP(conf.getUntrackedParameter<double>("minEOverP")),
76  mMaxEOverP(conf.getUntrackedParameter<double>("maxEOverP")),
77  mMaxTrkEmE(conf.getUntrackedParameter<double>("maxTrkEmE")),
78  mMaxEtThirdJet(conf.getUntrackedParameter<double>("maxEtThirdJet")),
79  mMinDPhiDiJets(conf.getUntrackedParameter<double>("minDPhiDiJets")),
80  mSumDepths(conf.getUntrackedParameter<bool>("sumDepths")),
81  mSumSmallDepths(conf.getUntrackedParameter<bool>("sumSmallDepths")),
82  mCombinePhi(conf.getUntrackedParameter<bool>("combinePhi")),
83  mHbClusterSize(conf.getUntrackedParameter<int>("hbClusterSize")),
84  mHeClusterSize(conf.getUntrackedParameter<int>("heClusterSize")),
85 
86  mUseConeClustering(conf.getUntrackedParameter<bool>("useConeClustering")),
87  mMaxConeDist(conf.getUntrackedParameter<double>("maxConeDist")),
88 
89  mCalibAbsIEtaMax(conf.getUntrackedParameter<int>("calibAbsIEtaMax")),
90  mCalibAbsIEtaMin(conf.getUntrackedParameter<int>("calibAbsIEtaMin")),
91  mMaxProbeJetEmFrac(conf.getUntrackedParameter<double>("maxProbeJetEmFrac")),
92  mMaxTagJetEmFrac(conf.getUntrackedParameter<double>("maxTagJetEmFrac")),
93  mMaxTagJetAbsEta(conf.getUntrackedParameter<double>("maxTagJetAbsEta")),
94  mMinTagJetEt(conf.getUntrackedParameter<double>("minTagJetEt")),
95  mMinProbeJetAbsEta(conf.getUntrackedParameter<double>("minProbeJetAbsEta")),
96  mPhiSymCorFileName(conf.getUntrackedParameter<string>("phiSymCorFileName")),
97  mApplyPhiSymCorFlag(conf.getUntrackedParameter<bool>("applyPhiSymCorFlag")),
98  mOutputCorCoefFileName(conf.getUntrackedParameter<string>("outputCorCoefFileName")),
99  mHistoFileName(conf.getUntrackedParameter<string>("histoFileName"))
100 
101 {}
102 
103 // destructor
104 
106 
107 // ------------ method called to for each event ------------
108 
111  iSetup.get<CaloGeometryRecord>().get(pG);
112  mTheCaloGeometry = pG.product();
114  iSetup.get<HcalRecNumberingRecord>().get(pT);
115  mTheHcalTopology = pT.product();
116 }
117 
118 // ------------ method called once each job just before starting event loop ------------
119 
121  // ESHandle<CaloGeometry> theGeometry;
122  // ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
123  // evtSetup.get<CaloGeometryRecord>().get( theGeometry );
124 
125  // edm::ESHandle<CaloGeometry> pG;
126  // evtSetup.get<CaloGeometryRecord>().get(pG);
127  // mTheCaloGeometry = pG.product();
128 }
129 
130 // ------------ method called once each job just after ending the event loop ------------
131 
133  if (mCalibType != "DI_JET" && mCalibType != "ISO_TRACK") {
134  std::cout << "\n\nUnknown calibration type " << mCalibType << std::endl;
135  std::cout << "Please select ISO_TRACK or DI_JET in the python file." << std::endl;
136  return;
137  }
138 
139  if (mCalibMethod != "L3" && mCalibMethod != "MATRIX_INV_OF_ETA_AVE" && mCalibMethod != "L3_AND_MTRX_INV") {
140  std::cout << "\n\nUnknown calibration method " << mCalibMethod << std::endl;
141  std::cout << "Supported methods for IsoTrack calibration are: L3, MATRIX_INV_OF_ETA_AVE, L3_AND_MTRX_INV"
142  << std::endl;
143  std::cout << "For DiJets the supported method is L3" << std::endl;
144  return;
145  }
146 
147  if (mCalibType == "DI_JET" && mCalibMethod != "L3") {
148  std::cout << "\n\nDiJet calibration can use only the L3 method. Please change the python file." << std::endl;
149  return;
150  }
151 
152  if (mCalibAbsIEtaMin < 1 || mCalibAbsIEtaMax > 41 || mCalibAbsIEtaMin > mCalibAbsIEtaMax) {
153  std::cout
154  << "\n\nInvalid ABS(iEta) calibration range. Check calibAbsIEtaMin and calibAbsIEtaMax in the python file."
155  << std::endl;
156  return;
157  }
158 
159  hcalCalib* calibrator = new hcalCalib();
160 
161  // set the parameters controlling the calibratoration
162 
163  calibrator->SetCalibType(mCalibType);
164  calibrator->SetCalibMethod(mCalibMethod);
165  calibrator->SetMinTargetE(mMinTargetE);
166  calibrator->SetMaxTargetE(mMaxTargetE);
167  calibrator->SetMaxEtThirdJet(mMaxEtThirdJet);
168  calibrator->SetMinDPhiDiJets(mMinDPhiDiJets);
169  calibrator->SetSumDepthsFlag(mSumDepths);
171  calibrator->SetCombinePhiFlag(mCombinePhi);
172  calibrator->SetMinCellE(mMinCellE);
173  calibrator->SetMinEOverP(mMinEOverP);
174  calibrator->SetMaxEOverP(mMaxEOverP);
175  calibrator->SetMaxTrkEmE(mMaxTrkEmE);
176  calibrator->SetHbClusterSize(mHbClusterSize);
177  calibrator->SetHeClusterSize(mHeClusterSize);
178 
180  calibrator->SetConeMaxDist(mMaxConeDist);
181 
187 
188  calibrator->SetMinTagJetEt(mMinTagJetEt);
189 
194 
195  calibrator->SetHistoFileName(mHistoFileName);
196 
198 
199  std::ifstream inputFileList; // contains list of input root files
200 
201  TString files = mInputFileList;
202  inputFileList.open(files.Data());
203 
204  std::vector<TString> inputFiles;
205  while (!inputFileList.eof()) {
206  TString fileName;
207  inputFileList >> fileName;
208  if (!fileName.BeginsWith("#") && !fileName.Contains(" ") && fileName != "")
209  inputFiles.push_back(fileName);
210  }
211  inputFileList.close();
212 
213  std::cout << "\nInput files for processing:" << std::endl;
214  for (std::vector<TString>::iterator it = inputFiles.begin(); it != inputFiles.end(); ++it) {
215  std::cout << "file: " << it->Data() << std::endl;
216  }
217  std::cout << std::endl;
218 
219  TChain* fChain = new TChain("hcalCalibTree");
220 
221  for (std::vector<TString>::iterator f_it = inputFiles.begin(); f_it != inputFiles.end(); ++f_it) {
222  fChain->Add(f_it->Data());
223  }
224 
225  fChain->Process(calibrator);
226 
227  if (fChain)
228  delete fChain;
229  delete calibrator;
230 
231  return;
232 }
233 
234 //define this as a plug-in
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
hcalCalib::SetMaxProbeJetEmFrac
void SetMaxProbeJetEmFrac(Float_t f)
Definition: hcalCalib.h:172
HcalCalibrator::beginJob
void beginJob() override
Definition: HcalCalibrator.cc:120
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
HcalCalibrator::~HcalCalibrator
~HcalCalibrator() override
Definition: HcalCalibrator.cc:105
hcalCalib::SetCombinePhiFlag
void SetCombinePhiFlag(Bool_t b)
Definition: hcalCalib.h:153
MessageLogger.h
ESHandle.h
hcalCalib::SetMaxTargetE
void SetMaxTargetE(Float_t e)
Definition: hcalCalib.h:150
hcalCalib::SetPhiSymCorFileName
void SetPhiSymCorFileName(const TString &filename)
Definition: hcalCalib.h:171
hcalCalib::SetMinDPhiDiJets
void SetMinDPhiDiJets(Float_t dphi)
Definition: hcalCalib.h:169
hcalCalib::SetMinTargetE
void SetMinTargetE(Float_t e)
Definition: hcalCalib.h:149
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalCalibrator::mMaxTagJetEmFrac
double mMaxTagJetEmFrac
Definition: HcalCalibrator.h:61
hcalCalib::SetUseConeClustering
void SetUseConeClustering(Bool_t b)
Definition: hcalCalib.h:163
HcalCalibrator::HcalCalibrator
HcalCalibrator(const edm::ParameterSet &)
Definition: HcalCalibrator.cc:64
hcalCalib::SetHeClusterSize
void SetHeClusterSize(Int_t i)
Definition: hcalCalib.h:161
hcalCalib::SetCaloGeometry
void SetCaloGeometry(const CaloGeometry *g, const HcalTopology *topo)
Definition: hcalCalib.h:180
hcalCalib::SetMinCellE
void SetMinCellE(Float_t e)
Definition: hcalCalib.h:154
hcalCalib::SetMaxEtThirdJet
void SetMaxEtThirdJet(Float_t et)
Definition: hcalCalib.h:168
HcalCalibrator
Definition: HcalCalibrator.h:22
hcalCalib.h
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
HcalCalibrator::mMaxEOverP
double mMaxEOverP
Definition: HcalCalibrator.h:43
hcalCalib::SetHistoFileName
void SetHistoFileName(const TString &filename)
Definition: hcalCalib.h:178
HcalCalibrator::mMinProbeJetAbsEta
double mMinProbeJetAbsEta
Definition: HcalCalibrator.h:64
hcalCalib::SetMinEOverP
void SetMinEOverP(Float_t e)
Definition: hcalCalib.h:155
hcalCalib::SetOutputCorCoefFileName
void SetOutputCorCoefFileName(const TString &filename)
Definition: hcalCalib.h:177
HcalCalibrator::mMaxEtThirdJet
double mMaxEtThirdJet
Definition: HcalCalibrator.h:46
hcalCalib
Definition: hcalCalib.h:38
hcalCalib::SetMaxTagJetAbsEta
void SetMaxTagJetAbsEta(Float_t e)
Definition: hcalCalib.h:174
MakerMacros.h
hcalCalib::SetHbClusterSize
void SetHbClusterSize(Int_t i)
Definition: hcalCalib.h:160
HcalCalibrator::mHbClusterSize
int mHbClusterSize
Definition: HcalCalibrator.h:51
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MainPageGenerator.files
files
Definition: MainPageGenerator.py:256
hcalCalib::SetSumDepthsFlag
void SetSumDepthsFlag(Bool_t b)
Definition: hcalCalib.h:151
Service.h
PVValHelper::pT
Definition: PVValidationHelpers.h:70
HcalCalibrator.h
edm::ESHandle< CaloGeometry >
HcalCalibrator::mMinTagJetEt
double mMinTagJetEt
Definition: HcalCalibrator.h:63
hcalCalib::SetApplyPhiSymCorFlag
void SetApplyPhiSymCorFlag(Bool_t b)
Definition: hcalCalib.h:170
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
HcalCalibrator::mTheCaloGeometry
const CaloGeometry * mTheCaloGeometry
Definition: HcalCalibrator.h:72
CaloGeometryRecord.h
HcalCalibrator::mInputFileList
std::string mInputFileList
Definition: HcalCalibrator.h:35
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalCalibrator::endJob
void endJob() override
Definition: HcalCalibrator.cc:132
HcalCalibrator::mHistoFileName
std::string mHistoFileName
Definition: HcalCalibrator.h:70
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
HcalCalibrator::mCalibType
std::string mCalibType
Definition: HcalCalibrator.h:37
get
#define get
HcalCalibrator::mMaxProbeJetEmFrac
double mMaxProbeJetEmFrac
Definition: HcalCalibrator.h:60
hcalCalib::SetMinProbeJetAbsEta
void SetMinProbeJetAbsEta(Float_t e)
Definition: hcalCalib.h:176
hcalCalib::SetSumSmallDepthsFlag
void SetSumSmallDepthsFlag(Bool_t b)
Definition: hcalCalib.h:152
HcalCalibrator::mTheHcalTopology
const HcalTopology * mTheHcalTopology
Definition: HcalCalibrator.h:73
hcalCalib::SetMaxTrkEmE
void SetMaxTrkEmE(Float_t e)
Definition: hcalCalib.h:157
hcalCalib::SetCalibMethod
void SetCalibMethod(const TString &s)
Definition: hcalCalib.h:159
HcalCalibrator::mPhiSymCorFileName
std::string mPhiSymCorFileName
Definition: HcalCalibrator.h:66
std
Definition: JetResolutionObject.h:76
HcalCalibrator::mCalibAbsIEtaMax
int mCalibAbsIEtaMax
Definition: HcalCalibrator.h:57
varParsingExample.inputFiles
inputFiles
Definition: varParsingExample.py:6
Frameworkfwd.h
hcalCalib::SetCalibType
void SetCalibType(const TString &s)
Definition: hcalCalib.h:158
hcalCalib::SetMaxEOverP
void SetMaxEOverP(Float_t e)
Definition: hcalCalib.h:156
HcalCalibrator::mMinDPhiDiJets
double mMinDPhiDiJets
Definition: HcalCalibrator.h:47
HcalCalibrator::mMinTargetE
double mMinTargetE
Definition: HcalCalibrator.h:39
HcalCalibrator::mMaxTrkEmE
double mMaxTrkEmE
Definition: HcalCalibrator.h:44
EventSetup.h
HcalCalibrator::mSumSmallDepths
bool mSumSmallDepths
Definition: HcalCalibrator.h:49
hcalCalib::SetConeMaxDist
void SetConeMaxDist(Float_t d)
Definition: hcalCalib.h:164
HcalCalibrator::mCalibAbsIEtaMin
int mCalibAbsIEtaMin
Definition: HcalCalibrator.h:58
HcalCalibrator::mMinCellE
double mMinCellE
Definition: HcalCalibrator.h:41
HcalCalibrator::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: HcalCalibrator.cc:109
HcalCalibrator::mUseConeClustering
bool mUseConeClustering
Definition: HcalCalibrator.h:54
ParameterSet.h
HcalCalibrator::mOutputCorCoefFileName
std::string mOutputCorCoefFileName
Definition: HcalCalibrator.h:69
HcalCalibrator::mHeClusterSize
int mHeClusterSize
Definition: HcalCalibrator.h:52
HcalCalibrator::mApplyPhiSymCorFlag
bool mApplyPhiSymCorFlag
Definition: HcalCalibrator.h:67
HcalCalibrator::mMaxTargetE
double mMaxTargetE
Definition: HcalCalibrator.h:40
HcalCalibrator::mCombinePhi
bool mCombinePhi
Definition: HcalCalibrator.h:50
edm::Event
Definition: Event.h:73
HcalCalibrator::mMaxConeDist
double mMaxConeDist
Definition: HcalCalibrator.h:55
HcalCalibrator::mMinEOverP
double mMinEOverP
Definition: HcalCalibrator.h:42
HcalCalibrator::mSumDepths
bool mSumDepths
Definition: HcalCalibrator.h:48
hcalCalib::SetMinTagJetEt
void SetMinTagJetEt(Float_t e)
Definition: hcalCalib.h:175
HcalCalibrator::mMaxTagJetAbsEta
double mMaxTagJetAbsEta
Definition: HcalCalibrator.h:62
hcalCalib::SetMaxTagJetEmFrac
void SetMaxTagJetEmFrac(Float_t f)
Definition: hcalCalib.h:173
hcalCalib::SetCalibAbsIEtaMax
void SetCalibAbsIEtaMax(Int_t i)
Definition: hcalCalib.h:166
HcalCalibrator::mCalibMethod
std::string mCalibMethod
Definition: HcalCalibrator.h:38
hcalCalib::SetCalibAbsIEtaMin
void SetCalibAbsIEtaMin(Int_t i)
Definition: hcalCalib.h:167