Go to the documentation of this file.00001
00002 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00003 #include "CalibCalorimetry/CaloMiscalibTools/interface/HcalRecHitRecalib.h"
00004
00005
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/ParameterSet/interface/FileInPath.h"
00008
00009 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00011 #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLHcal.h"
00012
00013 HcalRecHitRecalib::HcalRecHitRecalib(const edm::ParameterSet& iConfig)
00014 {
00015
00016 hbheLabel_ = iConfig.getParameter<edm::InputTag>("hbheInput");
00017 hoLabel_ = iConfig.getParameter<edm::InputTag>("hoInput");
00018 hfLabel_ = iConfig.getParameter<edm::InputTag>("hfInput");
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 RecalibHBHEHits_ = iConfig.getParameter< std::string > ("RecalibHBHEHitCollection");
00030 RecalibHFHits_ = iConfig.getParameter< std::string > ("RecalibHFHitCollection");
00031 RecalibHOHits_ = iConfig.getParameter< std::string > ("RecalibHOHitCollection");
00032
00033 refactor_ = iConfig.getUntrackedParameter<double> ("Refactor",(double)1);
00034 refactor_mean_ = iConfig.getUntrackedParameter<double> ("Refactor_mean",(double)1);
00035
00036
00037 produces< HBHERecHitCollection >(RecalibHBHEHits_);
00038 produces< HFRecHitCollection >(RecalibHFHits_);
00039 produces< HORecHitCollection >(RecalibHOHits_);
00040
00041
00042 mapHcal_.prefillMap();
00043
00044 hcalfileinpath_=iConfig.getUntrackedParameter<std::string> ("fileNameHcal","");
00045 edm::FileInPath hcalfiletmp("CalibCalorimetry/CaloMiscalibTools/data/"+hcalfileinpath_);
00046
00047 hcalfile_=hcalfiletmp.fullPath();
00048
00049
00050 MiscalibReaderFromXMLHcal hcalreader_(mapHcal_);
00051 if(!hcalfile_.empty()) hcalreader_.parseXMLMiscalibFile(hcalfile_);
00052 mapHcal_.print();
00053
00054 }
00055
00056
00057 HcalRecHitRecalib::~HcalRecHitRecalib()
00058 {
00059
00060
00061 }
00062
00063
00064
00065 void
00066 HcalRecHitRecalib::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00067 {
00068 using namespace edm;
00069 using namespace std;
00070
00071 Handle<HBHERecHitCollection> HBHERecHitsHandle;
00072 Handle<HFRecHitCollection> HFRecHitsHandle;
00073 Handle<HORecHitCollection> HORecHitsHandle;
00074
00075 const HBHERecHitCollection* HBHERecHits = 0;
00076 const HFRecHitCollection* HFRecHits = 0;
00077 const HORecHitCollection* HORecHits = 0;
00078
00079 iEvent.getByLabel(hbheLabel_,HBHERecHitsHandle);
00080 if (!HBHERecHitsHandle.isValid()) {
00081 LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
00082 } else {
00083 HBHERecHits = HBHERecHitsHandle.product();
00084 }
00085
00086 iEvent.getByLabel(hoLabel_,HORecHitsHandle);
00087 if (!HORecHitsHandle.isValid()) {
00088 LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
00089 } else {
00090 HORecHits = HORecHitsHandle.product();
00091 }
00092
00093 iEvent.getByLabel(hfLabel_,HFRecHitsHandle);
00094 if (!HFRecHitsHandle.isValid()) {
00095 LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
00096 } else {
00097 HFRecHits = HFRecHitsHandle.product();
00098 }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 std::auto_ptr< HBHERecHitCollection > RecalibHBHERecHitCollection( new HBHERecHitCollection );
00113 std::auto_ptr< HFRecHitCollection > RecalibHFRecHitCollection( new HFRecHitCollection );
00114 std::auto_ptr< HORecHitCollection > RecalibHORecHitCollection( new HORecHitCollection );
00115
00116
00117
00118
00119
00120
00121 if(HBHERecHits)
00122 {
00123
00124
00125 HBHERecHitCollection::const_iterator itHBHE;
00126 for (itHBHE=HBHERecHits->begin(); itHBHE!=HBHERecHits->end(); itHBHE++) {
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 float icalconst=(mapHcal_.get().find(itHBHE->id().rawId()))->second;
00143
00144
00145 icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_;
00146 HBHERecHit aHit(itHBHE->id(),itHBHE->energy()*icalconst,itHBHE->time());
00147
00148 RecalibHBHERecHitCollection->push_back( aHit);
00149 }
00150 }
00151
00152 if(HFRecHits)
00153 {
00154
00155
00156 HFRecHitCollection::const_iterator itHF;
00157 for (itHF=HFRecHits->begin(); itHF!=HFRecHits->end(); itHF++) {
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 float icalconst=(mapHcal_.get().find(itHF->id().rawId()))->second;
00176 icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_;
00177 HFRecHit aHit(itHF->id(),itHF->energy()*icalconst,itHF->time());
00178
00179 RecalibHFRecHitCollection->push_back( aHit);
00180 }
00181 }
00182
00183 if(HORecHits)
00184 {
00185
00186
00187 HORecHitCollection::const_iterator itHO;
00188 for (itHO=HORecHits->begin(); itHO!=HORecHits->end(); itHO++) {
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 float icalconst=(mapHcal_.get().find(itHO->id().rawId()))->second;
00207 icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_;
00208 HORecHit aHit(itHO->id(),itHO->energy()*icalconst,itHO->time());
00209
00210 RecalibHORecHitCollection->push_back( aHit);
00211 }
00212 }
00213
00214
00215
00216 iEvent.put( RecalibHBHERecHitCollection, RecalibHBHEHits_);
00217 iEvent.put( RecalibHFRecHitCollection, RecalibHFHits_);
00218 iEvent.put( RecalibHORecHitCollection, RecalibHOHits_);
00219 }
00220