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::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 HcalRecHitRecalib (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 ~HcalRecHitRecalib ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::string hcalfile_
 
std::string hcalfileinpath_
 
CaloMiscalibMapHcal mapHcal_
 
std::string RecalibHBHEHits_
 
std::string RecalibHFHits_
 
std::string RecalibHOHits_
 
double refactor_
 
double refactor_mean_
 
edm::EDGetTokenT
< HBHERecHitCollection
tok_hbhe_
 
edm::EDGetTokenT
< HFRecHitCollection
tok_hf_
 
edm::EDGetTokenT
< HORecHitCollection
tok_ho_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: Producer to miscalibrate (calibrated) Hcal RecHit

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

Definition at line 37 of file HcalRecHitRecalib.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file HcalRecHitRecalib.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hcalfile_, hcalfileinpath_, RecalibHBHEHits_, RecalibHFHits_, RecalibHOHits_, refactor_, refactor_mean_, AlCaHLTBitMon_QueryRunRegistry::string, tok_hbhe_, tok_hf_, and tok_ho_.

12 {
13 
14  tok_hbhe_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"));
15  tok_ho_ = consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"));
16  tok_hf_ = consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInput"));
17 
18 // HBHEHitsProducer_ = iConfig.getParameter< std::string > ("HBHERecHitsProducer");
19 // HOHitsProducer_ = iConfig.getParameter< std::string > ("HERecHitsProducer");
20 // HFHitsProducer_ = iConfig.getParameter< std::string > ("HERecHitsProducer");
21 // HBHEHits_ = iConfig.getParameter< std::string > ("HBHEHitCollection");
22 // HFHits_ = iConfig.getParameter< std::string > ("HFHitCollection");
23 // HOHits_ = iConfig.getParameter< std::string > ("HOHitCollection");
24 
25  RecalibHBHEHits_ = iConfig.getParameter< std::string > ("RecalibHBHEHitCollection");
26  RecalibHFHits_ = iConfig.getParameter< std::string > ("RecalibHFHitCollection");
27  RecalibHOHits_ = iConfig.getParameter< std::string > ("RecalibHOHitCollection");
28 
29  refactor_ = iConfig.getUntrackedParameter<double> ("Refactor",(double)1);
30  refactor_mean_ = iConfig.getUntrackedParameter<double> ("Refactor_mean",(double)1);
31 
32  //register your products
33  produces< HBHERecHitCollection >(RecalibHBHEHits_);
34  produces< HFRecHitCollection >(RecalibHFHits_);
35  produces< HORecHitCollection >(RecalibHOHits_);
36 
37  // here read them from xml (particular to HCAL)
38 
39  hcalfileinpath_=iConfig.getUntrackedParameter<std::string> ("fileNameHcal","");
40  edm::FileInPath hcalfiletmp("CalibCalorimetry/CaloMiscalibTools/data/"+hcalfileinpath_);
41 
42  hcalfile_=hcalfiletmp.fullPath();
43 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
std::string RecalibHFHits_
std::string hcalfileinpath_
std::string RecalibHOHits_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
std::string RecalibHBHEHits_
edm::EDGetTokenT< HORecHitCollection > tok_ho_
HcalRecHitRecalib::~HcalRecHitRecalib ( )

Definition at line 46 of file HcalRecHitRecalib.cc.

47 {
48 
49 
50 }

Member Function Documentation

void HcalRecHitRecalib::beginRun ( const edm::Run ,
const edm::EventSetup iSetup 
)
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 53 of file HcalRecHitRecalib.cc.

References edm::EventSetup::get(), hcalfile_, mapHcal_, MiscalibReaderFromXML::parseXMLMiscalibFile(), CaloMiscalibMapHcal::prefillMap(), CaloMiscalibMapHcal::print(), and ecaldqm::topology().

54 {
56  iSetup.get<IdealGeometryRecord>().get( topology );
57 
58  mapHcal_.prefillMap(*topology);
59 
61  if(!hcalfile_.empty()) hcalreader_.parseXMLMiscalibFile(hcalfile_);
62  mapHcal_.print();
63 }
CaloTopology const * topology(0)
const T & get() const
Definition: EventSetup.h:55
CaloMiscalibMapHcal mapHcal_
void prefillMap(const HcalTopology &topology)
void HcalRecHitRecalib::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 67 of file HcalRecHitRecalib.cc.

References CaloMiscalibMapHcal::get(), edm::Event::getByToken(), egHLT::errCodes::HBHERecHits, egHLT::errCodes::HFRecHits, LogDebug, mapHcal_, edm::Event::put(), RecalibHBHEHits_, RecalibHFHits_, RecalibHOHits_, refactor_, refactor_mean_, tok_hbhe_, tok_hf_, and tok_ho_.

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

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

Member Data Documentation

std::string HcalRecHitRecalib::hcalfile_
private

Definition at line 54 of file HcalRecHitRecalib.h.

Referenced by beginRun(), and HcalRecHitRecalib().

std::string HcalRecHitRecalib::hcalfileinpath_
private

Definition at line 55 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib().

CaloMiscalibMapHcal HcalRecHitRecalib::mapHcal_
private

Definition at line 57 of file HcalRecHitRecalib.h.

Referenced by beginRun(), and produce().

std::string HcalRecHitRecalib::RecalibHBHEHits_
private

Definition at line 50 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

std::string HcalRecHitRecalib::RecalibHFHits_
private

Definition at line 51 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

std::string HcalRecHitRecalib::RecalibHOHits_
private

Definition at line 52 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

double HcalRecHitRecalib::refactor_
private

Definition at line 58 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

double HcalRecHitRecalib::refactor_mean_
private

Definition at line 59 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

edm::EDGetTokenT<HBHERecHitCollection> HcalRecHitRecalib::tok_hbhe_
private

Definition at line 47 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

edm::EDGetTokenT<HFRecHitCollection> HcalRecHitRecalib::tok_hf_
private

Definition at line 49 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

edm::EDGetTokenT<HORecHitCollection> HcalRecHitRecalib::tok_ho_
private

Definition at line 48 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().