CMS 3D CMS Logo

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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< HBHERecHitCollectiontok_hbhe_
 
edm::EDGetTokenT< HFRecHitCollectiontok_hf_
 
edm::EDGetTokenT< HORecHitCollectiontok_ho_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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::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 12 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_.

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

48 {
49 
50 
51 }

Member Function Documentation

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

Definition at line 54 of file HcalRecHitRecalib.cc.

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

55 {
57  iSetup.get<HcalRecNumberingRecord>().get( topology );
58 
59  mapHcal_.prefillMap(*topology);
60 
62  if(!hcalfile_.empty()) hcalreader_.parseXMLMiscalibFile(hcalfile_);
63  mapHcal_.print();
64 }
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

Definition at line 68 of file HcalRecHitRecalib.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), CaloMiscalibMapHcal::get(), edm::Event::getByToken(), egHLT::errCodes::HBHERecHits, egHLT::errCodes::HFRecHits, edm::HandleBase::isValid(), LogDebug, mapHcal_, eostools::move(), edm::Handle< T >::product(), 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().

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

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().