CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
< EBRecHitCollection
barrelHitsToken_
 
const edm::EDGetTokenT
< EBRecHitCollection
ebRecHitToken_
 
const std::string ecalHitsProducer_
 
const edm::EDGetTokenT
< EERecHitCollection
eeRecHitToken_
 
const std::string endcapHits_
 
const edm::EDPutTokenT
< EERecHitCollection
endcapHitsToken_
 
const edm::ESGetToken
< EcalIntercalibConstants,
EcalIntercalibConstantsRcd
intercalibConstsToken_
 
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 ( 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_
T getUntrackedParameter(std::string const &, T const &) const
const std::string recalibBarrelHits_
const edm::EDPutTokenT< EBRecHitCollection > barrelHitsToken_
const edm::ESGetToken< EcalIntercalibConstants, EcalIntercalibConstantsRcd > intercalibConstsToken_
const std::string barrelHits_
const edm::EDPutTokenT< EERecHitCollection > endcapHitsToken_
const double refactor_mean_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::EDGetTokenT< EERecHitCollection > eeRecHitToken_
const double refactor_
const std::string ecalHitsProducer_
const edm::EDGetTokenT< EBRecHitCollection > ebRecHitToken_
const std::string endcapHits_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
EcalRecHitRecalib::~EcalRecHitRecalib ( )
override

Definition at line 23 of file EcalRecHitRecalib.cc.

23 {}

Member Function Documentation

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

Definition at line 26 of file EcalRecHitRecalib.cc.

References barrelHitsToken_, egHLT::errCodes::EBRecHits, ebRecHitToken_, egHLT::errCodes::EERecHits, eeRecHitToken_, endcapHitsToken_, edm::Event::getByToken(), edm::EventSetup::getData(), intercalibConstsToken_, LogDebug, eostools::move(), edm::Event::put(), 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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EDPutTokenT< EBRecHitCollection > barrelHitsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< EcalRecHit >::const_iterator const_iterator
Log< level::Error, false > LogError
const edm::ESGetToken< EcalIntercalibConstants, EcalIntercalibConstantsRcd > intercalibConstsToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
def move
Definition: eostools.py:511
const edm::EDPutTokenT< EERecHitCollection > endcapHitsToken_
const double refactor_mean_
std::vector< Item >::const_iterator const_iterator
const edm::EDGetTokenT< EERecHitCollection > eeRecHitToken_
const double refactor_
const edm::EDGetTokenT< EBRecHitCollection > ebRecHitToken_
float EcalIntercalibConstant
#define LogDebug(id)

Member Data Documentation

const std::string EcalRecHitRecalib::barrelHits_
private

Definition at line 51 of file EcalRecHitRecalib.h.

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

Definition at line 61 of file EcalRecHitRecalib.h.

Referenced by produce().

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

Definition at line 58 of file EcalRecHitRecalib.h.

Referenced by produce().

const std::string EcalRecHitRecalib::ecalHitsProducer_
private

Definition at line 50 of file EcalRecHitRecalib.h.

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

Definition at line 59 of file EcalRecHitRecalib.h.

Referenced by produce().

const std::string EcalRecHitRecalib::endcapHits_
private

Definition at line 52 of file EcalRecHitRecalib.h.

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

Definition at line 62 of file EcalRecHitRecalib.h.

Referenced by produce().

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

Definition at line 60 of file EcalRecHitRecalib.h.

Referenced by produce().

const std::string EcalRecHitRecalib::recalibBarrelHits_
private

Definition at line 53 of file EcalRecHitRecalib.h.

const std::string EcalRecHitRecalib::recalibEndcapHits_
private

Definition at line 54 of file EcalRecHitRecalib.h.

const double EcalRecHitRecalib::refactor_
private

Definition at line 55 of file EcalRecHitRecalib.h.

Referenced by produce().

const double EcalRecHitRecalib::refactor_mean_
private

Definition at line 56 of file EcalRecHitRecalib.h.

Referenced by produce().