CMS 3D CMS Logo

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 &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EcalRecHitRecalib () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 37 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.

15  {
16  ecalHitsProducer_ = iConfig.getParameter<std::string>("ecalRecHitsProducer");
17  barrelHits_ = iConfig.getParameter<std::string>("barrelHitCollection");
18  endcapHits_ = iConfig.getParameter<std::string>("endcapHitCollection");
19  RecalibBarrelHits_ = iConfig.getParameter<std::string>("RecalibBarrelHitCollection");
20  RecalibEndcapHits_ = iConfig.getParameter<std::string>("RecalibEndcapHitCollection");
21  refactor_ = iConfig.getUntrackedParameter<double>("Refactor", (double)1);
22  refactor_mean_ = iConfig.getUntrackedParameter<double>("Refactor_mean", (double)1);
23 
24  //register your products
25  produces<EBRecHitCollection>(RecalibBarrelHits_);
26  produces<EERecHitCollection>(RecalibEndcapHits_);
27 }
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 ( )
override

Definition at line 29 of file EcalRecHitRecalib.cc.

29 {}

Member Function Documentation

void EcalRecHitRecalib::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 32 of file EcalRecHitRecalib.cc.

References barrelHits_, edm::SortedCollection< T, SORT >::begin(), egHLT::errCodes::EBRecHits, ecalHitsProducer_, egHLT::errCodes::EERecHits, EcalCondObjectContainer< T >::end(), edm::SortedCollection< T, SORT >::end(), endcapHits_, EcalCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), edm::HandleBase::isValid(), LogDebug, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, and refactor_mean_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

32  {
33  using namespace edm;
34  using namespace std;
35 
36  Handle<EBRecHitCollection> barrelRecHitsHandle;
37  Handle<EERecHitCollection> endcapRecHitsHandle;
38 
39  const EBRecHitCollection* EBRecHits = nullptr;
40  const EERecHitCollection* EERecHits = nullptr;
41 
42  iEvent.getByLabel(ecalHitsProducer_, barrelHits_, barrelRecHitsHandle);
43  if (!barrelRecHitsHandle.isValid()) {
44  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
45  } else {
46  EBRecHits = barrelRecHitsHandle.product(); // get a ptr to the product
47  }
48 
49  iEvent.getByLabel(ecalHitsProducer_, endcapHits_, endcapRecHitsHandle);
50  if (!endcapRecHitsHandle.isValid()) {
51  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
52  } else {
53  EERecHits = endcapRecHitsHandle.product(); // get a ptr to the product
54  }
55 
56  //Create empty output collections
57  auto RecalibEBRecHitCollection = std::make_unique<EBRecHitCollection>();
58  auto RecalibEERecHitCollection = std::make_unique<EERecHitCollection>();
59 
60  // Intercalib constants
62  iSetup.get<EcalIntercalibConstantsRcd>().get(pIcal);
63  const EcalIntercalibConstants* ical = pIcal.product();
64 
65  if (EBRecHits) {
66  //loop on all EcalRecHits (barrel)
68  for (itb = EBRecHits->begin(); itb != EBRecHits->end(); ++itb) {
69  // find intercalib constant for this xtal
70  EcalIntercalibConstantMap::const_iterator icalit = ical->getMap().find(itb->id().rawId());
71  EcalIntercalibConstant icalconst = -1;
72 
73  if (icalit != ical->getMap().end()) {
74  icalconst = (*icalit);
75  // edm::LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;
76 
77  } else {
78  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EBDetId(itb->id())
79  << "! something wrong with EcalIntercalibConstants in your DB? ";
80  }
81 
82  // make the rechit with rescaled energy and put in the output collection
83  icalconst = refactor_mean_ +
84  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
85  EcalRecHit aHit(itb->id(), itb->energy() * icalconst, itb->time());
86 
87  RecalibEBRecHitCollection->push_back(aHit);
88  }
89  }
90 
91  if (EERecHits) {
92  //loop on all EcalRecHits (barrel)
94  for (ite = EERecHits->begin(); ite != EERecHits->end(); ++ite) {
95  // find intercalib constant for this xtal
96  EcalIntercalibConstantMap::const_iterator icalit = ical->getMap().find(ite->id().rawId());
97  EcalIntercalibConstant icalconst = -1;
98 
99  if (icalit != ical->getMap().end()) {
100  icalconst = (*icalit);
101  // edm:: LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EEDetId(ite->id()) << " " << icalconst ;
102  } else {
103  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EEDetId(ite->id())
104  << "! something wrong with EcalIntercalibConstants in your DB? ";
105  }
106 
107  // make the rechit with rescaled energy and put in the output collection
108 
109  icalconst = refactor_mean_ +
110  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
111  EcalRecHit aHit(ite->id(), ite->energy() * icalconst, ite->time());
112 
113  RecalibEERecHitCollection->push_back(aHit);
114  }
115  }
116 
117  //Put Recalibrated rechit in the event
118  iEvent.put(std::move(RecalibEBRecHitCollection), RecalibBarrelHits_);
119  iEvent.put(std::move(RecalibEERecHitCollection), RecalibEndcapHits_);
120 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
const self & getMap() const
std::vector< EcalRecHit >::const_iterator const_iterator
std::string RecalibEndcapHits_
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
const_iterator end() const
T const * product() const
Definition: Handle.h:74
std::vector< Item >::const_iterator const_iterator
std::string endcapHits_
HLT enums.
std::string RecalibBarrelHits_
std::string barrelHits_
T get() const
Definition: EventSetup.h:71
const_iterator find(uint32_t rawId) const
const_iterator end() const
std::string ecalHitsProducer_
def move(src, dest)
Definition: eostools.py:511
const_iterator begin() const
float EcalIntercalibConstant

Member Data Documentation

std::string EcalRecHitRecalib::barrelHits_
private

Definition at line 48 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::ecalHitsProducer_
private

Definition at line 47 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::endcapHits_
private

Definition at line 49 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibBarrelHits_
private

Definition at line 50 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibEndcapHits_
private

Definition at line 51 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_
private

Definition at line 52 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_mean_
private

Definition at line 53 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().