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::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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Attributes

bool doEnergyScale_
 
bool doIntercalib_
 
bool doLaserCorrections_
 
EcalRecHitAbsAlgoEBalgo_
 
std::string EBRecalibRecHitCollection_
 
edm::InputTag EBRecHitCollection_
 
EcalRecHitAbsAlgoEEalgo_
 
std::string EERecalibRecHitCollection_
 
edm::InputTag EERecHitCollection_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

produce ECAL rechits from uncalibrated rechits

Id:
EcalRecalibRecHitProducer.cc,v 1.3 2008/12/16 23:33:11 elmer Exp
Date:
2008/12/16 23:33:11
Revision:
1.3
Author
Federico Ferri, University of Milano Bicocca and INFN

produce ECAL rechits from uncalibrated rechits

Id:
EcalRecalibRecHitProducer.h,v 1.1 2008/12/10 01:52:41 ferriff Exp
Date:
2008/12/10 01:52:41
Revision:
1.1
Author
Federico Ferri, University of Milano Bicocca and INFN

Definition at line 21 of file EcalRecalibRecHitProducer.h.

Constructor & Destructor Documentation

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

Definition at line 39 of file EcalRecalibRecHitProducer.cc.

References doEnergyScale_, doIntercalib_, doLaserCorrections_, EBalgo_, EBRecalibRecHitCollection_, EBRecHitCollection_, EEalgo_, EERecalibRecHitCollection_, EERecHitCollection_, and edm::ParameterSet::getParameter().

39  {
40 
41  EBRecHitCollection_ = ps.getParameter<edm::InputTag>("EBRecHitCollection");
42  EERecHitCollection_ = ps.getParameter<edm::InputTag>("EERecHitCollection");
43  EBRecalibRecHitCollection_ = ps.getParameter<std::string>("EBRecalibRecHitCollection");
44  EERecalibRecHitCollection_ = ps.getParameter<std::string>("EERecalibRecHitCollection");
45  doEnergyScale_ = ps.getParameter<bool>("doEnergyScale");
46  doIntercalib_ = ps.getParameter<bool>("doIntercalib");
47  doLaserCorrections_ = ps.getParameter<bool>("doLaserCorrections");
48 
51 
52  produces< EBRecHitCollection >(EBRecalibRecHitCollection_);
53  produces< EERecHitCollection >(EERecalibRecHitCollection_);
54 }
T getParameter(std::string const &) const
EcalRecalibRecHitProducer::~EcalRecalibRecHitProducer ( )

Definition at line 56 of file EcalRecalibRecHitProducer.cc.

References EBalgo_, and EEalgo_.

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

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 63 of file EcalRecalibRecHitProducer.cc.

References doEnergyScale_, doIntercalib_, doLaserCorrections_, EBRecalibRecHitCollection_, EBRecHitCollection_, egHLT::errCodes::EBRecHits, EERecalibRecHitCollection_, EERecHitCollection_, egHLT::errCodes::EERecHits, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), edm::InputTag::instance(), edm::InputTag::label(), LogDebug, edm::Event::put(), and edm::EventBase::time().

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

Member Data Documentation

bool EcalRecalibRecHitProducer::doEnergyScale_
private

Definition at line 35 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

bool EcalRecalibRecHitProducer::doIntercalib_
private

Definition at line 36 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

bool EcalRecalibRecHitProducer::doLaserCorrections_
private

Definition at line 37 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

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

Definition at line 32 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

edm::InputTag EcalRecalibRecHitProducer::EBRecHitCollection_
private

Definition at line 30 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

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

Definition at line 33 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().

edm::InputTag EcalRecalibRecHitProducer::EERecHitCollection_
private

Definition at line 31 of file EcalRecalibRecHitProducer.h.

Referenced by EcalRecalibRecHitProducer(), and produce().