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
EcalRecalibRecHitProducer Class Reference

#include <EcalRecalibRecHitProducer.h>

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

Public Member Functions

 EcalRecalibRecHitProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 
 ~EcalRecalibRecHitProducer ()
 
- 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool doEnergyScale_
 
bool doEnergyScaleInverse_
 
bool doIntercalib_
 
bool doIntercalibInverse_
 
bool doLaserCorrections_
 
bool doLaserCorrectionsInverse_
 
EcalRecHitAbsAlgoEBalgo_
 
std::string EBRecalibRecHitCollection_
 
edm::InputTag EBRecHitCollection_
 
edm::EDGetTokenT
< EBRecHitCollection
EBRecHitToken_
 
EcalRecHitAbsAlgoEEalgo_
 
std::string EERecalibRecHitCollection_
 
edm::InputTag EERecHitCollection_
 
edm::EDGetTokenT
< EERecHitCollection
EERecHitToken_
 

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

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 doEnergyScale_, doEnergyScaleInverse_, doIntercalib_, doIntercalibInverse_, doLaserCorrections_, doLaserCorrectionsInverse_, EBalgo_, EBRecalibRecHitCollection_, EBRecHitCollection_, EBRecHitToken_, EEalgo_, EERecalibRecHitCollection_, EERecHitCollection_, EERecHitToken_, edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

34  {
35 
36  EBRecHitCollection_ = ps.getParameter<edm::InputTag>("EBRecHitCollection");
37  EERecHitCollection_ = ps.getParameter<edm::InputTag>("EERecHitCollection");
38  EBRecHitToken_ = consumes<EBRecHitCollection>(EBRecHitCollection_);
39  EERecHitToken_ = consumes<EBRecHitCollection>(EERecHitCollection_);
40  EBRecalibRecHitCollection_ = ps.getParameter<std::string>("EBRecalibRecHitCollection");
41  EERecalibRecHitCollection_ = ps.getParameter<std::string>("EERecalibRecHitCollection");
42  doEnergyScale_ = ps.getParameter<bool>("doEnergyScale");
43  doIntercalib_ = ps.getParameter<bool>("doIntercalib");
44  doLaserCorrections_ = ps.getParameter<bool>("doLaserCorrections");
45 
46  doEnergyScaleInverse_ = ps.getParameter<bool>("doEnergyScaleInverse");
47  doIntercalibInverse_ = ps.getParameter<bool>("doIntercalibInverse");
48  doLaserCorrectionsInverse_ = ps.getParameter<bool>("doLaserCorrectionsInverse");
49 
52 
53  produces< EBRecHitCollection >(EBRecalibRecHitCollection_);
54  produces< EERecHitCollection >(EERecalibRecHitCollection_);
55 }
edm::EDGetTokenT< EERecHitCollection > EERecHitToken_
T getParameter(std::string const &) const
edm::EDGetTokenT< EBRecHitCollection > EBRecHitToken_
EcalRecalibRecHitProducer::~EcalRecalibRecHitProducer ( )

Definition at line 57 of file EcalRecalibRecHitProducer.cc.

References EBalgo_, and EEalgo_.

57  {
58 
59  if (EBalgo_) delete EBalgo_;
60  if (EEalgo_) delete EEalgo_;
61 
62 }

Member Function Documentation

void EcalRecalibRecHitProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 64 of file EcalRecalibRecHitProducer.cc.

References doEnergyScale_, doEnergyScaleInverse_, doIntercalib_, doIntercalibInverse_, doLaserCorrections_, doLaserCorrectionsInverse_, EBRecalibRecHitCollection_, EBRecHitCollection_, egHLT::errCodes::EBRecHits, EBRecHitToken_, EERecalibRecHitCollection_, EERecHitCollection_, egHLT::errCodes::EERecHits, EERecHitToken_, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByToken(), EcalCondObjectContainer< T >::getMap(), edm::InputTag::label(), edm::Event::put(), and edm::EventBase::time().

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

Member Data Documentation

bool EcalRecalibRecHitProducer::doEnergyScale_
private

Definition at line 37 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

bool EcalRecalibRecHitProducer::doEnergyScaleInverse_
private

Definition at line 40 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

bool EcalRecalibRecHitProducer::doIntercalib_
private

Definition at line 38 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

bool EcalRecalibRecHitProducer::doIntercalibInverse_
private

Definition at line 41 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

bool EcalRecalibRecHitProducer::doLaserCorrections_
private

Definition at line 39 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

bool EcalRecalibRecHitProducer::doLaserCorrectionsInverse_
private

Definition at line 42 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

EcalRecHitAbsAlgo* EcalRecalibRecHitProducer::EBalgo_
private
std::string EcalRecalibRecHitProducer::EBRecalibRecHitCollection_
private

Definition at line 34 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

edm::InputTag EcalRecalibRecHitProducer::EBRecHitCollection_
private

Definition at line 29 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

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

Definition at line 31 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

EcalRecHitAbsAlgo* EcalRecalibRecHitProducer::EEalgo_
private
std::string EcalRecalibRecHitProducer::EERecalibRecHitCollection_
private

Definition at line 35 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

edm::InputTag EcalRecalibRecHitProducer::EERecHitCollection_
private

Definition at line 30 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

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

Definition at line 32 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().