CMS 3D CMS Logo

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

#include <EcalRecalibRecHitProducer.h>

Inheritance diagram for EcalRecalibRecHitProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 EcalRecalibRecHitProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::StreamID sid, edm::Event &evt, const edm::EventSetup &es) const override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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
 
 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

const bool doEnergyScale_
 
const bool doEnergyScaleInverse_
 
const bool doIntercalib_
 
const bool doIntercalibInverse_
 
const bool doLaserCorrections_
 
const bool doLaserCorrectionsInverse_
 
const std::string EBRecalibRecHitCollection_
 
const edm::InputTag EBRecHitCollection_
 
const edm::EDGetTokenT< EBRecHitCollectionEBRecHitToken_
 
const std::string EERecalibRecHitCollection_
 
const edm::InputTag EERecHitCollection_
 
const edm::EDGetTokenT< EERecHitCollectionEERecHitToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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::global::EDProducerBase
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

produce ECAL rechits from uncalibrated rechits

Author
Federico Ferri, University of Milano Bicocca and INFN

Definition at line 20 of file EcalRecalibRecHitProducer.h.

Constructor & Destructor Documentation

EcalRecalibRecHitProducer::EcalRecalibRecHitProducer ( const edm::ParameterSet ps)
explicit

Definition at line 34 of file EcalRecalibRecHitProducer.cc.

References EBRecalibRecHitCollection_, and EERecalibRecHitCollection_.

34  :
35  EBRecHitCollection_( ps.getParameter<edm::InputTag>("EBRecHitCollection") ),
36  EERecHitCollection_( ps.getParameter<edm::InputTag>("EERecHitCollection") ),
37  EBRecHitToken_( (not EBRecHitCollection_.label().empty()) ? consumes<EBRecHitCollection>(EBRecHitCollection_) : edm::EDGetTokenT<EBRecHitCollection>() ),
39  EBRecalibRecHitCollection_( ps.getParameter<std::string>("EBRecalibRecHitCollection") ),
40  EERecalibRecHitCollection_( ps.getParameter<std::string>("EERecalibRecHitCollection") ),
41  doEnergyScale_( ps.getParameter<bool>("doEnergyScale") ),
42  doIntercalib_( ps.getParameter<bool>("doIntercalib") ),
43  doLaserCorrections_( ps.getParameter<bool>("doLaserCorrections") ),
44 
45  doEnergyScaleInverse_( ps.getParameter<bool>("doEnergyScaleInverse") ),
46  doIntercalibInverse_( ps.getParameter<bool>("doIntercalibInverse") ),
47  doLaserCorrectionsInverse_( ps.getParameter<bool>("doLaserCorrectionsInverse") )
48 {
49  produces< EBRecHitCollection >(EBRecalibRecHitCollection_);
50  produces< EERecHitCollection >(EERecalibRecHitCollection_);
51 }
T getParameter(std::string const &) const
const edm::InputTag EERecHitCollection_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< EERecHitCollection > EERecHitToken_
const std::string EERecalibRecHitCollection_
std::string const & label() const
Definition: InputTag.h:36
const edm::EDGetTokenT< EBRecHitCollection > EBRecHitToken_
const edm::InputTag EBRecHitCollection_
HLT enums.
const std::string EBRecalibRecHitCollection_

Member Function Documentation

void EcalRecalibRecHitProducer::produce ( edm::StreamID  sid,
edm::Event evt,
const edm::EventSetup es 
) const
overridevirtual

Definition at line 53 of file EcalRecalibRecHitProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), DEFINE_FWK_MODULE, doEnergyScale_, doEnergyScaleInverse_, doIntercalib_, doIntercalibInverse_, doLaserCorrections_, doLaserCorrectionsInverse_, EBRecalibRecHitCollection_, EBRecHitCollection_, egHLT::errCodes::EBRecHits, EBRecHitToken_, EERecalibRecHitCollection_, EERecHitCollection_, egHLT::errCodes::EERecHits, EERecHitToken_, EcalCondObjectContainer< T >::end(), edm::SortedCollection< T, SORT >::end(), EcalCondObjectContainer< T >::find(), objects.autophobj::float, edm::EventSetup::get(), edm::Event::getByToken(), EcalADCToGeVConstant::getEBValue(), EcalADCToGeVConstant::getEEValue(), EcalLaserDbService::getLaserCorrection(), EcalCondObjectContainer< T >::getMap(), edm::InputTag::label(), eostools::move(), edm::Handle< T >::product(), edm::Event::put(), and edm::EventBase::time().

54 {
55  using namespace edm;
58 
59  const EBRecHitCollection* EBRecHits = 0;
60  const EERecHitCollection* EERecHits = 0;
61 
62  if (not EBRecHitCollection_.label().empty()) {
63  evt.getByToken( EBRecHitToken_, pEBRecHits);
64  EBRecHits = pEBRecHits.product(); // get a ptr to the product
65  }
66  if (not EERecHitCollection_.label().empty()) {
67  evt.getByToken( EERecHitToken_, pEERecHits);
68  EERecHits = pEERecHits.product(); // get a ptr to the product
69  }
70 
71  // collection of rechits to put in the event
72  auto EBRecalibRecHits = std::make_unique<EBRecHitCollection>();
73  auto EERecalibRecHits = std::make_unique<EERecHitCollection>();
74 
75  // now fetch all conditions we need to make rechits
76  // ADC to GeV constant
78  const EcalADCToGeVConstant *agc = 0;
79  float agc_eb = 1.;
80  float agc_ee = 1.;
81  if (doEnergyScale_) {
82  es.get<EcalADCToGeVConstantRcd>().get(pAgc);
83  agc = pAgc.product();
84  // use this value in the algorithm
85  agc_eb = float(agc->getEBValue());
86  agc_ee = float(agc->getEEValue());
87  }
88  // Intercalib constants
90  const EcalIntercalibConstants *ical = 0;
91  if (doIntercalib_) {
92  es.get<EcalIntercalibConstantsRcd>().get(pIcal);
93  ical = pIcal.product();
94  }
95  // Laser corrections
97  es.get<EcalLaserDbRecord>().get( pLaser );
98 
99 
101  agc_eb = 1.0/agc_eb;
102  agc_ee = 1.0/agc_ee;
103  }
104 
105 
106  if (EBRecHits) {
107  // loop over uncalibrated rechits to make calibrated ones
108  for(EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
109 
110  EcalIntercalibConstant icalconst = 1.;
111  if (doIntercalib_) {
112  // find intercalib constant for this xtal
113  const EcalIntercalibConstantMap &icalMap = ical->getMap();
114  EcalIntercalibConstantMap::const_iterator icalit = icalMap.find(it->id());
115  if( icalit!=icalMap.end() ){
116  icalconst = (*icalit);
117  } else {
118  edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EBDetId(it->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
119  ;
120  }
121  }
122  // get laser coefficient
123  float lasercalib = 1;
124  if (doLaserCorrections_) {
125  lasercalib = pLaser->getLaserCorrection( EBDetId(it->id()), evt.time() );
126  }
127 
128  // make the rechit and put in the output collection
129  // must implement op= for EcalRecHit
130 
132  icalconst = 1.0/icalconst;
133  }
135  lasercalib = 1.0/lasercalib;
136  }
137 
138  EcalRecHit aHit( (*it).id(), (*it).energy() * agc_eb * icalconst * lasercalib, (*it).time() );
139  EBRecalibRecHits->push_back( aHit );
140  }
141  }
142 
143  if (EERecHits)
144  {
145  // loop over uncalibrated rechits to make calibrated ones
146  for(EERecHitCollection::const_iterator it = EERecHits->begin();
147  it != EERecHits->end(); ++it) {
148 
149  // find intercalib constant for this xtal
150  EcalIntercalibConstant icalconst = 1.;
151  if (doIntercalib_) {
152  const EcalIntercalibConstantMap &icalMap = ical->getMap();
153  EcalIntercalibConstantMap::const_iterator icalit=icalMap.find(it->id());
154  if( icalit!=icalMap.end() ) {
155  icalconst = (*icalit);
156  } else {
157  edm::LogError("EcalRecHitError") << "No intercalib const found for xtal " << EEDetId(it->id()) << "! something wrong with EcalIntercalibConstants in your DB? ";
158  }
159  }
160  // get laser coefficient
161  float lasercalib = 1;
162  if (doLaserCorrections_) {
163  lasercalib = pLaser->getLaserCorrection( EEDetId(it->id()), evt.time() );
164  }
165 
167  icalconst = 1.0/icalconst;
168  }
170  lasercalib = 1.0/lasercalib;
171  }
172 
173  // make the rechit and put in the output collection
174  EcalRecHit aHit( (*it).id(), (*it).energy() * agc_ee * icalconst * lasercalib, (*it).time() );
175  EERecalibRecHits->push_back( aHit );
176  }
177  }
178  // put the collection of recunstructed hits in the event
179  LogInfo("EcalRecalibRecHitInfo") << "total # EB re-calibrated rechits: " << EBRecalibRecHits->size();
180  LogInfo("EcalRecalibRecHitInfo") << "total # EE re-calibrated rechits: " << EERecalibRecHits->size();
181 
182  evt.put(std::move(EBRecalibRecHits), EBRecalibRecHitCollection_);
183  evt.put(std::move(EERecalibRecHits), EERecalibRecHitCollection_);
184 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const edm::InputTag EERecHitCollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
const self & getMap() const
float getLaserCorrection(DetId const &xid, edm::Timestamp const &iTime) const
std::vector< EcalRecHit >::const_iterator const_iterator
const_iterator end() const
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
std::vector< Item >::const_iterator const_iterator
const edm::EDGetTokenT< EERecHitCollection > EERecHitToken_
const std::string EERecalibRecHitCollection_
std::string const & label() const
Definition: InputTag.h:36
const edm::EDGetTokenT< EBRecHitCollection > EBRecHitToken_
const edm::InputTag EBRecHitCollection_
HLT enums.
const_iterator find(uint32_t rawId) const
const_iterator end() const
const std::string EBRecalibRecHitCollection_
edm::Timestamp time() const
Definition: EventBase.h:61
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const
float EcalIntercalibConstant

Member Data Documentation

const bool EcalRecalibRecHitProducer::doEnergyScale_
private

Definition at line 35 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const bool EcalRecalibRecHitProducer::doEnergyScaleInverse_
private

Definition at line 38 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const bool EcalRecalibRecHitProducer::doIntercalib_
private

Definition at line 36 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const bool EcalRecalibRecHitProducer::doIntercalibInverse_
private

Definition at line 39 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const bool EcalRecalibRecHitProducer::doLaserCorrections_
private

Definition at line 37 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const bool EcalRecalibRecHitProducer::doLaserCorrectionsInverse_
private

Definition at line 40 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const std::string EcalRecalibRecHitProducer::EBRecalibRecHitCollection_
private

Definition at line 32 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

const edm::InputTag EcalRecalibRecHitProducer::EBRecHitCollection_
private

Definition at line 27 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const edm::EDGetTokenT<EBRecHitCollection> EcalRecalibRecHitProducer::EBRecHitToken_
private

Definition at line 29 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const std::string EcalRecalibRecHitProducer::EERecalibRecHitCollection_
private

Definition at line 33 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

const edm::InputTag EcalRecalibRecHitProducer::EERecHitCollection_
private

Definition at line 28 of file EcalRecalibRecHitProducer.h.

Referenced by produce().

const edm::EDGetTokenT<EERecHitCollection> EcalRecalibRecHitProducer::EERecHitToken_
private

Definition at line 30 of file EcalRecalibRecHitProducer.h.

Referenced by produce().