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

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

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

Public Member Functions

 EcalRecHitRecalib (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~EcalRecHitRecalib ()
 
- 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

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
 
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)
 
static void prevalidate (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

Description: Producer to miscalibrate (calibrated) Ecal RecHit

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

Definition at line 40 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_, and refactor_mean_.

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 ( )

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 
)
virtual

Implements edm::EDProducer.

Definition at line 40 of file EcalRecHitRecalib.cc.

References barrelHits_, egHLT::errCodes::EBRecHits, ecalHitsProducer_, egHLT::errCodes::EERecHits, endcapHits_, EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), LogDebug, 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 = 0;
49  const EERecHitCollection* EERecHits = 0;
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  std::auto_ptr< EBRecHitCollection > RecalibEBRecHitCollection( new EBRecHitCollection );
67  std::auto_ptr< EERecHitCollection > RecalibEERecHitCollection( new 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( RecalibEBRecHitCollection, RecalibBarrelHits_);
134  iEvent.put( RecalibEERecHitCollection, RecalibEndcapHits_);
135 
136 }
#define LogDebug(id)
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:85
std::string RecalibEndcapHits_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
std::string endcapHits_
std::string RecalibBarrelHits_
std::string barrelHits_
const_iterator find(uint32_t rawId) const
std::string ecalHitsProducer_
float EcalIntercalibConstant

Member Data Documentation

std::string EcalRecHitRecalib::barrelHits_
private

Definition at line 51 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::ecalHitsProducer_
private

Definition at line 50 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::endcapHits_
private

Definition at line 52 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibBarrelHits_
private

Definition at line 53 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibEndcapHits_
private

Definition at line 54 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_
private

Definition at line 55 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_mean_
private

Definition at line 56 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().