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

#include <CalibCalorimetry/CaloRecalibTools.src/HcalRecHitRecalib.cc>

Inheritance diagram for HcalRecHitRecalib:
edm::stream::EDProducer<>

Public Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 HcalRecHitRecalib (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~HcalRecHitRecalib () 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

std::string hcalfile_
 
const std::string hcalfileinpath_
 
CaloMiscalibMapHcal mapHcal_
 
const std::string recalibHBHEHits_
 
const std::string recalibHFHits_
 
const std::string recalibHOHits_
 
const double refactor_
 
const double refactor_mean_
 
const edm::EDGetTokenT
< HBHERecHitCollection
tok_hbhe_
 
const edm::EDGetTokenT
< HFRecHitCollection
tok_hf_
 
const edm::EDGetTokenT
< HORecHitCollection
tok_ho_
 
const edm::ESGetToken
< HcalTopology,
HcalRecNumberingRecord
topologyToken_
 

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) Hcal RecHit

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

Definition at line 37 of file HcalRecHitRecalib.h.

Constructor & Destructor Documentation

HcalRecHitRecalib::HcalRecHitRecalib ( const edm::ParameterSet iConfig)
explicit

Definition at line 10 of file HcalRecHitRecalib.cc.

References hcalfile_, hcalfileinpath_, recalibHBHEHits_, recalibHFHits_, and recalibHOHits_.

11  : tok_hbhe_(consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"))),
12  tok_ho_(consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"))),
13  tok_hf_(consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInput"))),
14  topologyToken_(esConsumes<edm::Transition::BeginRun>()),
15  recalibHBHEHits_(iConfig.getParameter<std::string>("RecalibHBHEHitCollection")),
16  recalibHFHits_(iConfig.getParameter<std::string>("RecalibHFHitCollection")),
17  recalibHOHits_(iConfig.getParameter<std::string>("RecalibHOHitCollection")),
18  hcalfileinpath_(iConfig.getUntrackedParameter<std::string>("fileNameHcal", "")),
19  refactor_(iConfig.getUntrackedParameter<double>("Refactor", (double)1)),
20  refactor_mean_(iConfig.getUntrackedParameter<double>("Refactor_mean", (double)1)) {
21  //register your products
22  produces<HBHERecHitCollection>(recalibHBHEHits_);
23  produces<HFRecHitCollection>(recalibHFHits_);
24  produces<HORecHitCollection>(recalibHOHits_);
25 
26  // here read them from xml (particular to HCAL)
27  edm::FileInPath hcalfiletmp("CalibCalorimetry/CaloMiscalibTools/data/" + hcalfileinpath_);
28  hcalfile_ = hcalfiletmp.fullPath();
29 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string recalibHOHits_
const edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const std::string hcalfileinpath_
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topologyToken_
const std::string recalibHFHits_
const edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
const std::string recalibHBHEHits_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const double refactor_
const edm::EDGetTokenT< HORecHitCollection > tok_ho_
const double refactor_mean_
HcalRecHitRecalib::~HcalRecHitRecalib ( )
override

Definition at line 31 of file HcalRecHitRecalib.cc.

31 {}

Member Function Documentation

void HcalRecHitRecalib::beginRun ( const edm::Run ,
const edm::EventSetup iSetup 
)
override

Definition at line 33 of file HcalRecHitRecalib.cc.

References edm::EventSetup::getData(), hcalfile_, mapHcal_, MiscalibReaderFromXML::parseXMLMiscalibFile(), CaloMiscalibMapHcal::prefillMap(), CaloMiscalibMapHcal::print(), and topologyToken_.

33  {
34  const HcalTopology& topology = iSetup.getData(topologyToken_);
35 
36  mapHcal_.prefillMap(topology);
37 
39  if (!hcalfile_.empty())
40  hcalreader_.parseXMLMiscalibFile(hcalfile_);
41  mapHcal_.print();
42 }
const edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topologyToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
CaloMiscalibMapHcal mapHcal_
void prefillMap(const HcalTopology &topology)
void HcalRecHitRecalib::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 45 of file HcalRecHitRecalib.cc.

References CaloMiscalibMapHcal::get(), edm::Event::getByToken(), egHLT::errCodes::HBHERecHits, egHLT::errCodes::HFRecHits, LogDebug, mapHcal_, eostools::move(), edm::Event::put(), recalibHBHEHits_, recalibHFHits_, recalibHOHits_, refactor_, refactor_mean_, tok_hbhe_, tok_hf_, and tok_ho_.

45  {
46  using namespace edm;
47  using namespace std;
48 
49  Handle<HBHERecHitCollection> HBHERecHitsHandle;
50  Handle<HFRecHitCollection> HFRecHitsHandle;
51  Handle<HORecHitCollection> HORecHitsHandle;
52 
53  const HBHERecHitCollection* HBHERecHits = nullptr;
54  const HFRecHitCollection* HFRecHits = nullptr;
55  const HORecHitCollection* HORecHits = nullptr;
56 
57  iEvent.getByToken(tok_hbhe_, HBHERecHitsHandle);
58  if (!HBHERecHitsHandle.isValid()) {
59  LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
60  } else {
61  HBHERecHits = HBHERecHitsHandle.product(); // get a ptr to the product
62  }
63 
64  iEvent.getByToken(tok_ho_, HORecHitsHandle);
65  if (!HORecHitsHandle.isValid()) {
66  LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
67  } else {
68  HORecHits = HORecHitsHandle.product(); // get a ptr to the product
69  }
70 
71  iEvent.getByToken(tok_hf_, HFRecHitsHandle);
72  if (!HFRecHitsHandle.isValid()) {
73  LogDebug("") << "HcalREcHitRecalib: Error! can't get product!" << std::endl;
74  } else {
75  HFRecHits = HFRecHitsHandle.product(); // get a ptr to the product
76  }
77 
78  //Create empty output collections
79  auto RecalibHBHERecHitCollection = std::make_unique<HBHERecHitCollection>();
80  auto RecalibHFRecHitCollection = std::make_unique<HFRecHitCollection>();
81  auto RecalibHORecHitCollection = std::make_unique<HORecHitCollection>();
82 
83  if (HBHERecHits) {
85  for (itHBHE = HBHERecHits->begin(); itHBHE != HBHERecHits->end(); ++itHBHE) {
86  // make the rechit with rescaled energy and put in the output collection
87  float icalconst = (mapHcal_.get().find(itHBHE->id().rawId()))->second;
88  icalconst = refactor_mean_ +
89  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
90  HBHERecHit aHit(itHBHE->id(), itHBHE->energy() * icalconst, itHBHE->time());
91 
92  RecalibHBHERecHitCollection->push_back(aHit);
93  }
94  }
95 
96  if (HFRecHits) {
98  for (itHF = HFRecHits->begin(); itHF != HFRecHits->end(); ++itHF) {
99  // make the rechit with rescaled energy and put in the output collection
100  float icalconst = (mapHcal_.get().find(itHF->id().rawId()))->second;
101  icalconst = refactor_mean_ +
102  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
103  HFRecHit aHit(itHF->id(), itHF->energy() * icalconst, itHF->time());
104 
105  RecalibHFRecHitCollection->push_back(aHit);
106  }
107  }
108 
109  if (HORecHits) {
111  for (itHO = HORecHits->begin(); itHO != HORecHits->end(); ++itHO) {
112  // make the rechit with rescaled energy and put in the output collection
113  float icalconst = (mapHcal_.get().find(itHO->id().rawId()))->second;
114  icalconst = refactor_mean_ +
115  (icalconst - refactor_mean_) * refactor_; //apply additional scaling factor (works if gaussian)
116  HORecHit aHit(itHO->id(), itHO->energy() * icalconst, itHO->time());
117 
118  RecalibHORecHitCollection->push_back(aHit);
119  }
120  }
121 
122  //Put Recalibrated rechit in the event
123  iEvent.put(std::move(RecalibHBHERecHitCollection), recalibHBHEHits_);
124  iEvent.put(std::move(RecalibHFRecHitCollection), recalibHFHits_);
125  iEvent.put(std::move(RecalibHORecHitCollection), recalibHOHits_);
126 }
const std::map< uint32_t, float > & get()
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< T >::const_iterator const_iterator
const std::string recalibHOHits_
const edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const std::string recalibHFHits_
const edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
def move
Definition: eostools.py:511
const std::string recalibHBHEHits_
const double refactor_
CaloMiscalibMapHcal mapHcal_
const edm::EDGetTokenT< HORecHitCollection > tok_ho_
const double refactor_mean_
#define LogDebug(id)

Member Data Documentation

std::string HcalRecHitRecalib::hcalfile_
private

Definition at line 54 of file HcalRecHitRecalib.h.

Referenced by beginRun(), and HcalRecHitRecalib().

const std::string HcalRecHitRecalib::hcalfileinpath_
private

Definition at line 55 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib().

CaloMiscalibMapHcal HcalRecHitRecalib::mapHcal_
private

Definition at line 57 of file HcalRecHitRecalib.h.

Referenced by beginRun(), and produce().

const std::string HcalRecHitRecalib::recalibHBHEHits_
private

Definition at line 50 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

const std::string HcalRecHitRecalib::recalibHFHits_
private

Definition at line 51 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

const std::string HcalRecHitRecalib::recalibHOHits_
private

Definition at line 52 of file HcalRecHitRecalib.h.

Referenced by HcalRecHitRecalib(), and produce().

const double HcalRecHitRecalib::refactor_
private

Definition at line 58 of file HcalRecHitRecalib.h.

Referenced by produce().

const double HcalRecHitRecalib::refactor_mean_
private

Definition at line 59 of file HcalRecHitRecalib.h.

Referenced by produce().

const edm::EDGetTokenT<HBHERecHitCollection> HcalRecHitRecalib::tok_hbhe_
private

Definition at line 46 of file HcalRecHitRecalib.h.

Referenced by produce().

const edm::EDGetTokenT<HFRecHitCollection> HcalRecHitRecalib::tok_hf_
private

Definition at line 48 of file HcalRecHitRecalib.h.

Referenced by produce().

const edm::EDGetTokenT<HORecHitCollection> HcalRecHitRecalib::tok_ho_
private

Definition at line 47 of file HcalRecHitRecalib.h.

Referenced by produce().

const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> HcalRecHitRecalib::topologyToken_
private

Definition at line 49 of file HcalRecHitRecalib.h.

Referenced by beginRun().