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::EDConsumerBase 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 ()
 
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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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

Description: Producer to miscalibrate (calibrated) Ecal RecHit

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

Definition at line 38 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_, refactor_mean_, and AlCaHLTBitMon_QueryRunRegistry::string.

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:113
std::string RecalibEndcapHits_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
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 49 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::ecalHitsProducer_
private

Definition at line 48 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::endcapHits_
private

Definition at line 50 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibBarrelHits_
private

Definition at line 51 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibEndcapHits_
private

Definition at line 52 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_
private

Definition at line 53 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_mean_
private

Definition at line 54 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().