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