CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HcalRecHitRecalib Class Reference

#include <CalibCalorimetry/CaloRecalibTools.src/HcalRecHitRecalib.cc>

Inheritance diagram for HcalRecHitRecalib:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 HcalRecHitRecalib (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~HcalRecHitRecalib ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

edm::InputTag hbheLabel_
 
std::string hcalfile_
 
std::string hcalfileinpath_
 
edm::InputTag hfLabel_
 
edm::InputTag hoLabel_
 
CaloMiscalibMapHcal mapHcal_
 
std::string RecalibHBHEHits_
 
std::string RecalibHFHits_
 
std::string RecalibHOHits_
 
double refactor_
 
double refactor_mean_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: Producer to miscalibrate (calibrated) Hcal RecHit

Implementation: <Notes on="" implementation>="">

Definition at line 42 of file HcalRecHitRecalib.h.

Constructor & Destructor Documentation

HcalRecHitRecalib::HcalRecHitRecalib ( const edm::ParameterSet iConfig)
explicit

Definition at line 13 of file HcalRecHitRecalib.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hbheLabel_, hcalfile_, hcalfileinpath_, hfLabel_, hoLabel_, mapHcal_, MiscalibReaderFromXML::parseXMLMiscalibFile(), CaloMiscalibMapHcal::prefillMap(), CaloMiscalibMapHcal::print(), RecalibHBHEHits_, RecalibHFHits_, RecalibHOHits_, refactor_, and refactor_mean_.

14 {
15 
16  hbheLabel_ = iConfig.getParameter<edm::InputTag>("hbheInput");
17  hoLabel_ = iConfig.getParameter<edm::InputTag>("hoInput");
18  hfLabel_ = iConfig.getParameter<edm::InputTag>("hfInput");
19 
20 
21 
22 // HBHEHitsProducer_ = iConfig.getParameter< std::string > ("HBHERecHitsProducer");
23 // HOHitsProducer_ = iConfig.getParameter< std::string > ("HERecHitsProducer");
24 // HFHitsProducer_ = iConfig.getParameter< std::string > ("HERecHitsProducer");
25 // HBHEHits_ = iConfig.getParameter< std::string > ("HBHEHitCollection");
26 // HFHits_ = iConfig.getParameter< std::string > ("HFHitCollection");
27 // HOHits_ = iConfig.getParameter< std::string > ("HOHitCollection");
28 
29  RecalibHBHEHits_ = iConfig.getParameter< std::string > ("RecalibHBHEHitCollection");
30  RecalibHFHits_ = iConfig.getParameter< std::string > ("RecalibHFHitCollection");
31  RecalibHOHits_ = iConfig.getParameter< std::string > ("RecalibHOHitCollection");
32 
33  refactor_ = iConfig.getUntrackedParameter<double> ("Refactor",(double)1);
34  refactor_mean_ = iConfig.getUntrackedParameter<double> ("Refactor_mean",(double)1);
35 
36  //register your products
37  produces< HBHERecHitCollection >(RecalibHBHEHits_);
38  produces< HFRecHitCollection >(RecalibHFHits_);
39  produces< HORecHitCollection >(RecalibHOHits_);
40 
41  // here read them from xml (particular to HCAL)
43 
44  hcalfileinpath_=iConfig.getUntrackedParameter<std::string> ("fileNameHcal","");
45  edm::FileInPath hcalfiletmp("CalibCalorimetry/CaloMiscalibTools/data/"+hcalfileinpath_);
46 
47  hcalfile_=hcalfiletmp.fullPath();
48 
49 
51  if(!hcalfile_.empty()) hcalreader_.parseXMLMiscalibFile(hcalfile_);
52  mapHcal_.print();
53 
54 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag hfLabel_
std::string RecalibHFHits_
std::string hcalfileinpath_
std::string RecalibHOHits_
edm::InputTag hbheLabel_
std::string RecalibHBHEHits_
edm::InputTag hoLabel_
CaloMiscalibMapHcal mapHcal_
HcalRecHitRecalib::~HcalRecHitRecalib ( )

Definition at line 57 of file HcalRecHitRecalib.cc.

58 {
59 
60 
61 }

Member Function Documentation

void HcalRecHitRecalib::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 66 of file HcalRecHitRecalib.cc.

References CaloMiscalibMapHcal::get(), edm::Event::getByLabel(), hbheLabel_, egHLT::errCodes::HBHERecHits, hfLabel_, egHLT::errCodes::HFRecHits, hoLabel_, LogDebug, mapHcal_, edm::Event::put(), RecalibHBHEHits_, RecalibHFHits_, RecalibHOHits_, refactor_, and refactor_mean_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

67 {
68  using namespace edm;
69  using namespace std;
70 
71  Handle<HBHERecHitCollection> HBHERecHitsHandle;
72  Handle<HFRecHitCollection> HFRecHitsHandle;
73  Handle<HORecHitCollection> HORecHitsHandle;
74 
76  const HFRecHitCollection* HFRecHits = 0;
77  const HORecHitCollection* HORecHits = 0;
78 
79  iEvent.getByLabel(hbheLabel_,HBHERecHitsHandle);
80  if (!HBHERecHitsHandle.isValid()) {
81  LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
82  } else {
83  HBHERecHits = HBHERecHitsHandle.product(); // get a ptr to the product
84  }
85 
86  iEvent.getByLabel(hoLabel_,HORecHitsHandle);
87  if (!HORecHitsHandle.isValid()) {
88  LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
89  } else {
90  HORecHits = HORecHitsHandle.product(); // get a ptr to the product
91  }
92 
93  iEvent.getByLabel(hfLabel_,HFRecHitsHandle);
94  if (!HFRecHitsHandle.isValid()) {
95  LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
96  } else {
97  HFRecHits = HFRecHitsHandle.product(); // get a ptr to the product
98  }
99 
100 
101 // iEvent.getByLabel(HBHEHitsProducer_,HBHEHits_,HBHERecHitsHandle);
102 // HBHERecHits = HBHERecHitsHandle.product(); // get a ptr to the product
103 
104 // iEvent.getByLabel(HFHitsProducer_,HFHits_,HFRecHitsHandle);
105 // HFRecHits = HFRecHitsHandle.product(); // get a ptr to the product
106 
107 // iEvent.getByLabel(HOHitsProducer_,HOHits_,HORecHitsHandle);
108 // HORecHits = HORecHitsHandle.product(); // get a ptr to the product
109 
110 
111  //Create empty output collections
112  std::auto_ptr< HBHERecHitCollection > RecalibHBHERecHitCollection( new HBHERecHitCollection );
113  std::auto_ptr< HFRecHitCollection > RecalibHFRecHitCollection( new HFRecHitCollection );
114  std::auto_ptr< HORecHitCollection > RecalibHORecHitCollection( new HORecHitCollection );
115 
116  // Intercalib constants
117  // edm::ESHandle<EcalIntercalibConstants> pIcal;
118  // iSetup.get<EcalIntercalibConstantsRcd>().get(pIcal);
119  // const EcalIntercalibConstants* ical = pIcal.product();
120 
121  if(HBHERecHits)
122  {
123 
124  //loop on all EcalRecHits (barrel)
126  for (itHBHE=HBHERecHits->begin(); itHBHE!=HBHERecHits->end(); itHBHE++) {
127 
128  // find intercalib constant for this cell
129 
130  // EcalIntercalibConstants::EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(itb->id().rawId());
131  // EcalIntercalibConstants::EcalIntercalibConstant icalconst;
132 
133  // if( icalit!=ical->getMap().end() ){
134  // icalconst = icalit->second;
135  // edm::LogDebug("EcalRecHitMiscalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;
136 
137  // } else {
138  // edm::LogError("EcalRecHitMiscalib") << "No intercalib const found for xtal " << EBDetId(itb->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
139  // ;
140  // }
141 
142  float icalconst=(mapHcal_.get().find(itHBHE->id().rawId()))->second;
143  // make the rechit with rescaled energy and put in the output collection
144 
145  icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
146  HBHERecHit aHit(itHBHE->id(),itHBHE->energy()*icalconst,itHBHE->time());
147 
148  RecalibHBHERecHitCollection->push_back( aHit);
149  }
150  }
151 
152  if(HFRecHits)
153  {
154 
155  //loop on all EcalRecHits (barrel)
157  for (itHF=HFRecHits->begin(); itHF!=HFRecHits->end(); itHF++) {
158 
159  // find intercalib constant for this cell
160 
161  // EcalIntercalibConstants::EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(itb->id().rawId());
162  // EcalIntercalibConstants::EcalIntercalibConstant icalconst;
163 
164  // if( icalit!=ical->getMap().end() ){
165  // icalconst = icalit->second;
166  // edm::LogDebug("EcalRecHitMiscalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;
167 
168  // } else {
169  // edm::LogError("EcalRecHitMiscalib") << "No intercalib const found for xtal " << EBDetId(itb->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
170  // ;
171  // }
172 
173  // make the rechit with rescaled energy and put in the output collection
174 
175  float icalconst=(mapHcal_.get().find(itHF->id().rawId()))->second;
176  icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
177  HFRecHit aHit(itHF->id(),itHF->energy()*icalconst,itHF->time());
178 
179  RecalibHFRecHitCollection->push_back( aHit);
180  }
181  }
182 
183  if(HORecHits)
184  {
185 
186  //loop on all EcalRecHits (barrel)
188  for (itHO=HORecHits->begin(); itHO!=HORecHits->end(); itHO++) {
189 
190  // find intercalib constant for this cell
191 
192  // EcalIntercalibConstants::EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(itb->id().rawId());
193  // EcalIntercalibConstants::EcalIntercalibConstant icalconst;
194 
195  // if( icalit!=ical->getMap().end() ){
196  // icalconst = icalit->second;
197  // edm::LogDebug("EcalRecHitMiscalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;
198 
199  // } else {
200  // edm::LogError("EcalRecHitMiscalib") << "No intercalib const found for xtal " << EBDetId(itb->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
201  // ;
202  // }
203 
204  // make the rechit with rescaled energy and put in the output collection
205 
206  float icalconst=(mapHcal_.get().find(itHO->id().rawId()))->second;
207  icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
208  HORecHit aHit(itHO->id(),itHO->energy()*icalconst,itHO->time());
209 
210  RecalibHORecHitCollection->push_back( aHit);
211  }
212  }
213 
214 
215  //Put Recalibrated rechit in the event
216  iEvent.put( RecalibHBHERecHitCollection, RecalibHBHEHits_);
217  iEvent.put( RecalibHFRecHitCollection, RecalibHFHits_);
218  iEvent.put( RecalibHORecHitCollection, RecalibHOHits_);
219 }
#define LogDebug(id)
const std::map< uint32_t, float > & get()
edm::InputTag hfLabel_
std::vector< T >::const_iterator const_iterator
std::string RecalibHFHits_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::string RecalibHOHits_
edm::InputTag hbheLabel_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::string RecalibHBHEHits_
edm::InputTag hoLabel_
CaloMiscalibMapHcal mapHcal_

Member Data Documentation

edm::InputTag HcalRecHitRecalib::hbheLabel_
private

Definition at line 61 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

std::string HcalRecHitRecalib::hcalfile_
private

Definition at line 66 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib().

std::string HcalRecHitRecalib::hcalfileinpath_
private

Definition at line 67 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib().

edm::InputTag HcalRecHitRecalib::hfLabel_
private

Definition at line 61 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

edm::InputTag HcalRecHitRecalib::hoLabel_
private

Definition at line 61 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

CaloMiscalibMapHcal HcalRecHitRecalib::mapHcal_
private

Definition at line 69 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

std::string HcalRecHitRecalib::RecalibHBHEHits_
private

Definition at line 62 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

std::string HcalRecHitRecalib::RecalibHFHits_
private

Definition at line 63 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

std::string HcalRecHitRecalib::RecalibHOHits_
private

Definition at line 64 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

double HcalRecHitRecalib::refactor_
private

Definition at line 70 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

double HcalRecHitRecalib::refactor_mean_
private

Definition at line 71 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().