CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
EcalRecHitRecalib Class Reference

#include <CalibCalorimetry/CaloMiscalibTools.src/EcalRecHitRecalib.cc>

Inheritance diagram for EcalRecHitRecalib:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalRecHitRecalib (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EcalRecHitRecalib () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies 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 barrelHits_
 
std::string ecalHitsProducer_
 
std::string endcapHits_
 
std::string RecalibBarrelHits_
 
std::string RecalibEndcapHits_
 
double refactor_
 
double refactor_mean_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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) Ecal RecHit

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

Definition at line 38 of file EcalRecHitRecalib.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file EcalRecHitRecalib.cc.

References barrelHits_, ecalHitsProducer_, endcapHits_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, refactor_mean_, and AlCaHLTBitMon_QueryRunRegistry::string.

16 {
17  ecalHitsProducer_ = iConfig.getParameter< std::string > ("ecalRecHitsProducer");
18  barrelHits_ = iConfig.getParameter< std::string > ("barrelHitCollection");
19  endcapHits_ = iConfig.getParameter< std::string > ("endcapHitCollection");
20  RecalibBarrelHits_ = iConfig.getParameter< std::string > ("RecalibBarrelHitCollection");
21  RecalibEndcapHits_ = iConfig.getParameter< std::string > ("RecalibEndcapHitCollection");
22  refactor_ = iConfig.getUntrackedParameter<double> ("Refactor",(double)1);
23  refactor_mean_ = iConfig.getUntrackedParameter<double> ("Refactor_mean",(double)1);
24 
25  //register your products
26  produces< EBRecHitCollection >(RecalibBarrelHits_);
27  produces< EERecHitCollection >(RecalibEndcapHits_);
28 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string RecalibEndcapHits_
std::string endcapHits_
std::string RecalibBarrelHits_
std::string barrelHits_
std::string ecalHitsProducer_
EcalRecHitRecalib::~EcalRecHitRecalib ( )
override

Definition at line 31 of file EcalRecHitRecalib.cc.

32 {
33 
34 
35 }

Member Function Documentation

void EcalRecHitRecalib::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 40 of file EcalRecHitRecalib.cc.

References barrelHits_, edm::SortedCollection< T, SORT >::begin(), egHLT::errCodes::EBRecHits, ecalHitsProducer_, egHLT::errCodes::EERecHits, EcalCondObjectContainer< T >::end(), edm::SortedCollection< T, SORT >::end(), endcapHits_, EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), edm::HandleBase::isValid(), LogDebug, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, and refactor_mean_.

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

41 {
42  using namespace edm;
43  using namespace std;
44 
45  Handle<EBRecHitCollection> barrelRecHitsHandle;
46  Handle<EERecHitCollection> endcapRecHitsHandle;
47 
48  const EBRecHitCollection* EBRecHits = nullptr;
49  const EERecHitCollection* EERecHits = nullptr;
50 
51  iEvent.getByLabel(ecalHitsProducer_,barrelHits_,barrelRecHitsHandle);
52  if (!barrelRecHitsHandle.isValid()) {
53  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
54  } else {
55  EBRecHits = barrelRecHitsHandle.product(); // get a ptr to the product
56  }
57 
58  iEvent.getByLabel(ecalHitsProducer_,endcapHits_,endcapRecHitsHandle);
59  if (!endcapRecHitsHandle.isValid()) {
60  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
61  } else {
62  EERecHits = endcapRecHitsHandle.product(); // get a ptr to the product
63  }
64 
65  //Create empty output collections
66  auto RecalibEBRecHitCollection = std::make_unique<EBRecHitCollection>();
67  auto RecalibEERecHitCollection = std::make_unique<EERecHitCollection>();
68 
69 
70  // Intercalib constants
72  iSetup.get<EcalIntercalibConstantsRcd>().get(pIcal);
73  const EcalIntercalibConstants* ical = pIcal.product();
74 
75  if(EBRecHits)
76  {
77 
78  //loop on all EcalRecHits (barrel)
80  for (itb=EBRecHits->begin(); itb!=EBRecHits->end(); ++itb) {
81 
82  // find intercalib constant for this xtal
83  EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(itb->id().rawId());
84  EcalIntercalibConstant icalconst = -1;
85 
86  if( icalit!=ical->getMap().end() ){
87  icalconst = (*icalit);
88  // edm::LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;
89 
90  } else {
91  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EBDetId(itb->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
92  ;
93  }
94 
95  // make the rechit with rescaled energy and put in the output collection
96  icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
97  EcalRecHit aHit(itb->id(),itb->energy()*icalconst,itb->time());
98 
99  RecalibEBRecHitCollection->push_back( aHit);
100  }
101  }
102 
103  if(EERecHits)
104  {
105 
106  //loop on all EcalRecHits (barrel)
108  for (ite=EERecHits->begin(); ite!=EERecHits->end(); ++ite) {
109 
110  // find intercalib constant for this xtal
111  EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(ite->id().rawId());
112  EcalIntercalibConstant icalconst = -1;
113 
114  if( icalit!=ical->getMap().end() ){
115  icalconst = (*icalit);
116  // edm:: LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EEDetId(ite->id()) << " " << icalconst ;
117  } else {
118  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EEDetId(ite->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
119  ;
120  }
121 
122  // make the rechit with rescaled energy and put in the output collection
123 
124  icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
125  EcalRecHit aHit(ite->id(),ite->energy()*icalconst,ite->time());
126 
127  RecalibEERecHitCollection->push_back( aHit);
128  }
129  }
130 
131 
132  //Put Recalibrated rechit in the event
133  iEvent.put(std::move(RecalibEBRecHitCollection), RecalibBarrelHits_);
134  iEvent.put(std::move(RecalibEERecHitCollection), RecalibEndcapHits_);
135 
136 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
const self & getMap() const
std::vector< EcalRecHit >::const_iterator const_iterator
std::string RecalibEndcapHits_
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:464
const_iterator end() const
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
std::string endcapHits_
HLT enums.
std::string RecalibBarrelHits_
std::string barrelHits_
const_iterator find(uint32_t rawId) const
const_iterator end() const
std::string ecalHitsProducer_
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const
float EcalIntercalibConstant

Member Data Documentation

std::string EcalRecHitRecalib::barrelHits_
private

Definition at line 49 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::ecalHitsProducer_
private

Definition at line 48 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::endcapHits_
private

Definition at line 50 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibBarrelHits_
private

Definition at line 51 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibEndcapHits_
private

Definition at line 52 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_
private

Definition at line 53 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_mean_
private

Definition at line 54 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().