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 ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: Producer to miscalibrate (calibrated) Ecal RecHit

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

Definition at line 37 of file EcalRecHitRecalib.h.

Constructor & Destructor Documentation

◆ EcalRecHitRecalib()

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

Definition at line 15 of file EcalRecHitRecalib.cc.

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

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

◆ ~EcalRecHitRecalib()

EcalRecHitRecalib::~EcalRecHitRecalib ( )
override

Definition at line 29 of file EcalRecHitRecalib.cc.

29 {}

Member Function Documentation

◆ produce()

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

Implements edm::EDProducer.

Definition at line 32 of file EcalRecHitRecalib.cc.

32  {
33  using namespace edm;
34  using namespace std;
35 
36  Handle<EBRecHitCollection> barrelRecHitsHandle;
37  Handle<EERecHitCollection> endcapRecHitsHandle;
38 
39  const EBRecHitCollection* EBRecHits = nullptr;
40  const EERecHitCollection* EERecHits = nullptr;
41 
42  iEvent.getByLabel(ecalHitsProducer_, barrelHits_, barrelRecHitsHandle);
43  if (!barrelRecHitsHandle.isValid()) {
44  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
45  } else {
46  EBRecHits = barrelRecHitsHandle.product(); // get a ptr to the product
47  }
48 
49  iEvent.getByLabel(ecalHitsProducer_, endcapHits_, endcapRecHitsHandle);
50  if (!endcapRecHitsHandle.isValid()) {
51  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
52  } else {
53  EERecHits = endcapRecHitsHandle.product(); // get a ptr to the product
54  }
55 
56  //Create empty output collections
57  auto RecalibEBRecHitCollection = std::make_unique<EBRecHitCollection>();
58  auto RecalibEERecHitCollection = std::make_unique<EERecHitCollection>();
59 
60  // Intercalib constants
62  iSetup.get<EcalIntercalibConstantsRcd>().get(pIcal);
63  const EcalIntercalibConstants* ical = pIcal.product();
64 
65  if (EBRecHits) {
66  //loop on all EcalRecHits (barrel)
68  for (itb = EBRecHits->begin(); itb != EBRecHits->end(); ++itb) {
69  // find intercalib constant for this xtal
70  EcalIntercalibConstantMap::const_iterator icalit = ical->getMap().find(itb->id().rawId());
71  EcalIntercalibConstant icalconst = -1;
72 
73  if (icalit != ical->getMap().end()) {
74  icalconst = (*icalit);
75  // edm::LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;
76 
77  } else {
78  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EBDetId(itb->id())
79  << "! something wrong with EcalIntercalibConstants in your DB? ";
80  }
81 
82  // make the rechit with rescaled energy and put in the output collection
83  icalconst = refactor_mean_ +
84  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
85  EcalRecHit aHit(itb->id(), itb->energy() * icalconst, itb->time());
86 
87  RecalibEBRecHitCollection->push_back(aHit);
88  }
89  }
90 
91  if (EERecHits) {
92  //loop on all EcalRecHits (barrel)
94  for (ite = EERecHits->begin(); ite != EERecHits->end(); ++ite) {
95  // find intercalib constant for this xtal
96  EcalIntercalibConstantMap::const_iterator icalit = ical->getMap().find(ite->id().rawId());
97  EcalIntercalibConstant icalconst = -1;
98 
99  if (icalit != ical->getMap().end()) {
100  icalconst = (*icalit);
101  // edm:: LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EEDetId(ite->id()) << " " << icalconst ;
102  } else {
103  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EEDetId(ite->id())
104  << "! something wrong with EcalIntercalibConstants in your DB? ";
105  }
106 
107  // make the rechit with rescaled energy and put in the output collection
108 
109  icalconst = refactor_mean_ +
110  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
111  EcalRecHit aHit(ite->id(), ite->energy() * icalconst, ite->time());
112 
113  RecalibEERecHitCollection->push_back(aHit);
114  }
115  }
116 
117  //Put Recalibrated rechit in the event
118  iEvent.put(std::move(RecalibEBRecHitCollection), RecalibBarrelHits_);
119  iEvent.put(std::move(RecalibEERecHitCollection), RecalibEndcapHits_);
120 }

References barrelHits_, filterRecHits_cfi::EBRecHits, ecalHitsProducer_, filterRecHits_cfi::EERecHits, EcalCondObjectContainer< T >::end(), endcapHits_, EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), get, EcalCondObjectContainer< T >::getMap(), iEvent, edm::HandleBase::isValid(), LogDebug, eostools::move(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, and refactor_mean_.

Member Data Documentation

◆ barrelHits_

std::string EcalRecHitRecalib::barrelHits_
private

Definition at line 48 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

◆ ecalHitsProducer_

std::string EcalRecHitRecalib::ecalHitsProducer_
private

Definition at line 47 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

◆ endcapHits_

std::string EcalRecHitRecalib::endcapHits_
private

Definition at line 49 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

◆ RecalibBarrelHits_

std::string EcalRecHitRecalib::RecalibBarrelHits_
private

Definition at line 50 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

◆ RecalibEndcapHits_

std::string EcalRecHitRecalib::RecalibEndcapHits_
private

Definition at line 51 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

◆ refactor_

double EcalRecHitRecalib::refactor_
private

Definition at line 52 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

◆ refactor_mean_

double EcalRecHitRecalib::refactor_mean_
private

Definition at line 53 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:80
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
EcalRecHit
Definition: EcalRecHit.h:15
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
EcalRecHitRecalib::refactor_
double refactor_
Definition: EcalRecHitRecalib.h:52
edm::SortedCollection< EcalRecHit >
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EcalRecHitRecalib::refactor_mean_
double refactor_mean_
Definition: EcalRecHitRecalib.h:53
EcalCondObjectContainer< float >
edm::Handle
Definition: AssociativeIterator.h:50
filterRecHits_cfi.EERecHits
EERecHits
Definition: filterRecHits_cfi.py:9
EcalIntercalibConstant
float EcalIntercalibConstant
Definition: EcalIntercalibConstants.h:10
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
EcalRecHitRecalib::RecalibEndcapHits_
std::string RecalibEndcapHits_
Definition: EcalRecHitRecalib.h:51
edm::ESHandle
Definition: DTSurvey.h:22
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::LogError
Definition: MessageLogger.h:183
EcalRecHitRecalib::endcapHits_
std::string endcapHits_
Definition: EcalRecHitRecalib.h:49
iEvent
int iEvent
Definition: GenABIO.cc:224
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
EcalRecHitRecalib::RecalibBarrelHits_
std::string RecalibBarrelHits_
Definition: EcalRecHitRecalib.h:50
std
Definition: JetResolutionObject.h:76
EcalCondObjectContainer< float >::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
EcalIntercalibConstantsRcd
Definition: EcalIntercalibConstantsRcd.h:5
EcalRecHitRecalib::ecalHitsProducer_
std::string ecalHitsProducer_
Definition: EcalRecHitRecalib.h:47
EcalRecHitRecalib::barrelHits_
std::string barrelHits_
Definition: EcalRecHitRecalib.h:48
filterRecHits_cfi.EBRecHits
EBRecHits
Definition: filterRecHits_cfi.py:8