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::stream::EDProducer<>

Public Member Functions

 EcalRecHitRecalib (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~EcalRecHitRecalib () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

const std::string barrelHits_
 
const edm::EDPutTokenT< EBRecHitCollectionbarrelHitsToken_
 
const edm::EDGetTokenT< EBRecHitCollectionebRecHitToken_
 
const std::string ecalHitsProducer_
 
const edm::EDGetTokenT< EERecHitCollectioneeRecHitToken_
 
const std::string endcapHits_
 
const edm::EDPutTokenT< EERecHitCollectionendcapHitsToken_
 
const edm::ESGetToken< EcalIntercalibConstants, EcalIntercalibConstantsRcdintercalibConstsToken_
 
const std::string recalibBarrelHits_
 
const std::string recalibEndcapHits_
 
const double refactor_
 
const double refactor_mean_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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::EcalRecHitRecalib ( const edm::ParameterSet iConfig)
explicit

Definition at line 9 of file EcalRecHitRecalib.cc.

10  : ecalHitsProducer_(iConfig.getParameter<std::string>("ecalRecHitsProducer")),
11  barrelHits_(iConfig.getParameter<std::string>("barrelHitCollection")),
12  endcapHits_(iConfig.getParameter<std::string>("endcapHitCollection")),
13  recalibBarrelHits_(iConfig.getParameter<std::string>("RecalibBarrelHitCollection")),
14  recalibEndcapHits_(iConfig.getParameter<std::string>("RecalibEndcapHitCollection")),
15  refactor_(iConfig.getUntrackedParameter<double>("Refactor", (double)1)),
16  refactor_mean_(iConfig.getUntrackedParameter<double>("Refactor_mean", (double)1)),
17  ebRecHitToken_(consumes<EBRecHitCollection>(edm::InputTag(ecalHitsProducer_, barrelHits_))),
18  eeRecHitToken_(consumes<EERecHitCollection>(edm::InputTag(ecalHitsProducer_, endcapHits_))),
20  barrelHitsToken_(produces<EBRecHitCollection>(recalibBarrelHits_)),
21  endcapHitsToken_(produces<EERecHitCollection>(recalibEndcapHits_)) {}
const std::string recalibEndcapHits_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::string recalibBarrelHits_
const edm::EDPutTokenT< EBRecHitCollection > barrelHitsToken_
const edm::ESGetToken< EcalIntercalibConstants, EcalIntercalibConstantsRcd > intercalibConstsToken_
T getUntrackedParameter(std::string const &, T const &) const
const std::string barrelHits_
const edm::EDPutTokenT< EERecHitCollection > endcapHitsToken_
const double refactor_mean_
const edm::EDGetTokenT< EERecHitCollection > eeRecHitToken_
const double refactor_
const std::string ecalHitsProducer_
const edm::EDGetTokenT< EBRecHitCollection > ebRecHitToken_
const std::string endcapHits_

◆ ~EcalRecHitRecalib()

EcalRecHitRecalib::~EcalRecHitRecalib ( )
override

Definition at line 23 of file EcalRecHitRecalib.cc.

23 {}

Member Function Documentation

◆ produce()

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

Definition at line 26 of file EcalRecHitRecalib.cc.

References barrelHitsToken_, filterRecHits_cfi::EBRecHits, ebRecHitToken_, filterRecHits_cfi::EERecHits, eeRecHitToken_, endcapHitsToken_, edm::EventSetup::getData(), iEvent, intercalibConstsToken_, edm::HandleBase::isValid(), LogDebug, eostools::move(), edm::Handle< T >::product(), refactor_, and refactor_mean_.

26  {
27  using namespace edm;
28  using namespace std;
29 
30  Handle<EBRecHitCollection> barrelRecHitsHandle;
31  Handle<EERecHitCollection> endcapRecHitsHandle;
32 
33  const EBRecHitCollection* EBRecHits = nullptr;
34  const EERecHitCollection* EERecHits = nullptr;
35 
36  iEvent.getByToken(ebRecHitToken_, barrelRecHitsHandle);
37  if (!barrelRecHitsHandle.isValid()) {
38  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
39  } else {
40  EBRecHits = barrelRecHitsHandle.product(); // get a ptr to the product
41  }
42 
43  iEvent.getByToken(eeRecHitToken_, endcapRecHitsHandle);
44  if (!endcapRecHitsHandle.isValid()) {
45  LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
46  } else {
47  EERecHits = endcapRecHitsHandle.product(); // get a ptr to the product
48  }
49 
50  //Create empty output collections
51  auto RecalibEBRecHitCollection = std::make_unique<EBRecHitCollection>();
52  auto RecalibEERecHitCollection = std::make_unique<EERecHitCollection>();
53 
54  // Intercalib constants
56 
57  if (EBRecHits) {
58  //loop on all EcalRecHits (barrel)
60  for (itb = EBRecHits->begin(); itb != EBRecHits->end(); ++itb) {
61  // find intercalib constant for this xtal
62  EcalIntercalibConstantMap::const_iterator icalit = ical.getMap().find(itb->id().rawId());
63  EcalIntercalibConstant icalconst = -1;
64 
65  if (icalit != ical.getMap().end()) {
66  icalconst = (*icalit);
67 
68  } else {
69  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EBDetId(itb->id())
70  << "! something wrong with EcalIntercalibConstants in your DB? ";
71  }
72 
73  // make the rechit with rescaled energy and put in the output collection
74  icalconst = refactor_mean_ +
75  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
76  EcalRecHit aHit(itb->id(), itb->energy() * icalconst, itb->time());
77 
78  RecalibEBRecHitCollection->push_back(aHit);
79  }
80  }
81 
82  if (EERecHits) {
83  //loop on all EcalRecHits (barrel)
85  for (ite = EERecHits->begin(); ite != EERecHits->end(); ++ite) {
86  // find intercalib constant for this xtal
87  EcalIntercalibConstantMap::const_iterator icalit = ical.getMap().find(ite->id().rawId());
88  EcalIntercalibConstant icalconst = -1;
89 
90  if (icalit != ical.getMap().end()) {
91  icalconst = (*icalit);
92  } else {
93  edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EEDetId(ite->id())
94  << "! something wrong with EcalIntercalibConstants in your DB? ";
95  }
96 
97  // make the rechit with rescaled energy and put in the output collection
98 
99  icalconst = refactor_mean_ +
100  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
101  EcalRecHit aHit(ite->id(), ite->energy() * icalconst, ite->time());
102 
103  RecalibEERecHitCollection->push_back(aHit);
104  }
105  }
106 
107  //Put Recalibrated rechit in the event
108  iEvent.put(barrelHitsToken_, std::move(RecalibEBRecHitCollection));
109  iEvent.put(endcapHitsToken_, std::move(RecalibEERecHitCollection));
110 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::EDPutTokenT< EBRecHitCollection > barrelHitsToken_
T const * product() const
Definition: Handle.h:70
std::vector< EcalRecHit >::const_iterator const_iterator
Log< level::Error, false > LogError
const edm::ESGetToken< EcalIntercalibConstants, EcalIntercalibConstantsRcd > intercalibConstsToken_
int iEvent
Definition: GenABIO.cc:224
const edm::EDPutTokenT< EERecHitCollection > endcapHitsToken_
const double refactor_mean_
std::vector< Item >::const_iterator const_iterator
const edm::EDGetTokenT< EERecHitCollection > eeRecHitToken_
const double refactor_
bool isValid() const
Definition: HandleBase.h:70
const edm::EDGetTokenT< EBRecHitCollection > ebRecHitToken_
HLT enums.
def move(src, dest)
Definition: eostools.py:511
float EcalIntercalibConstant
#define LogDebug(id)

Member Data Documentation

◆ barrelHits_

const std::string EcalRecHitRecalib::barrelHits_
private

Definition at line 51 of file EcalRecHitRecalib.h.

◆ barrelHitsToken_

const edm::EDPutTokenT<EBRecHitCollection> EcalRecHitRecalib::barrelHitsToken_
private

Definition at line 61 of file EcalRecHitRecalib.h.

Referenced by produce().

◆ ebRecHitToken_

const edm::EDGetTokenT<EBRecHitCollection> EcalRecHitRecalib::ebRecHitToken_
private

Definition at line 58 of file EcalRecHitRecalib.h.

Referenced by produce().

◆ ecalHitsProducer_

const std::string EcalRecHitRecalib::ecalHitsProducer_
private

Definition at line 50 of file EcalRecHitRecalib.h.

◆ eeRecHitToken_

const edm::EDGetTokenT<EERecHitCollection> EcalRecHitRecalib::eeRecHitToken_
private

Definition at line 59 of file EcalRecHitRecalib.h.

Referenced by produce().

◆ endcapHits_

const std::string EcalRecHitRecalib::endcapHits_
private

Definition at line 52 of file EcalRecHitRecalib.h.

◆ endcapHitsToken_

const edm::EDPutTokenT<EERecHitCollection> EcalRecHitRecalib::endcapHitsToken_
private

Definition at line 62 of file EcalRecHitRecalib.h.

Referenced by produce().

◆ intercalibConstsToken_

const edm::ESGetToken<EcalIntercalibConstants, EcalIntercalibConstantsRcd> EcalRecHitRecalib::intercalibConstsToken_
private

Definition at line 60 of file EcalRecHitRecalib.h.

Referenced by produce().

◆ recalibBarrelHits_

const std::string EcalRecHitRecalib::recalibBarrelHits_
private

Definition at line 53 of file EcalRecHitRecalib.h.

◆ recalibEndcapHits_

const std::string EcalRecHitRecalib::recalibEndcapHits_
private

Definition at line 54 of file EcalRecHitRecalib.h.

◆ refactor_

const double EcalRecHitRecalib::refactor_
private

Definition at line 55 of file EcalRecHitRecalib.h.

Referenced by produce().

◆ refactor_mean_

const double EcalRecHitRecalib::refactor_mean_
private

Definition at line 56 of file EcalRecHitRecalib.h.

Referenced by produce().