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 Member Functions | Private Attributes
RecHitCorrector Class Reference

#include <RecoLocalCalo/Castor/src/RecHitCorrector.cc>

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

Public Member Functions

 RecHitCorrector (const edm::ParameterSet &)
 
 ~RecHitCorrector () 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 Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const bool doInterCalib_
 
const double factor_
 
edm::EDGetTokenT
< CastorRecHitCollection
tok_input_
 
const edm::ESGetToken
< CastorChannelQuality,
CastorChannelQualityRcd
tokChan_
 
const edm::ESGetToken
< CastorDbService,
CastorDbRecord
tokCond_
 

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: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 45 of file RecHitCorrector.cc.

Constructor & Destructor Documentation

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

Definition at line 72 of file RecHitCorrector.cc.

References edm::ParameterSet::getParameter(), and tok_input_.

73  : tokCond_(esConsumes<CastorDbService, CastorDbRecord>()),
74  tokChan_(esConsumes<CastorChannelQuality, CastorChannelQualityRcd>()),
75  factor_(iConfig.getParameter<double>("revertFactor")),
76  doInterCalib_(iConfig.getParameter<bool>("doInterCalib")) {
77  tok_input_ = consumes<CastorRecHitCollection>(iConfig.getParameter<edm::InputTag>("rechitLabel"));
78  //register your products
79  produces<CastorRecHitCollection>();
80  //now do what ever other initialization is needed
81 }
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
const edm::ESGetToken< CastorChannelQuality, CastorChannelQualityRcd > tokChan_
const bool doInterCalib_
const edm::ESGetToken< CastorDbService, CastorDbRecord > tokCond_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const double factor_
RecHitCorrector::~RecHitCorrector ( )
override

Definition at line 83 of file RecHitCorrector.cc.

83  {
84  // do anything here that needs to be done at desctruction time
85  // (e.g. close files, deallocate resources etc.)
86 }

Member Function Documentation

void RecHitCorrector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 93 of file RecHitCorrector.cc.

References submitPVValidationJobs::conditions, doInterCalib_, CaloRecHit::energy(), factor_, CastorCalibrations::gain(), edm::Event::getByToken(), edm::EventSetup::getData(), CastorChannelStatus::getValue(), mps_fire::i, CastorRecHit::id(), eostools::move(), convertSQLiteXML::ok, edm::Event::put(), DetId::rawId(), HI_PhotonSkim_cff::rechits, CaloRecHit::time(), tok_input_, tokChan_, and tokCond_.

93  {
94  using namespace edm;
95 
96  // get original rechits
98  iEvent.getByToken(tok_input_, rechits);
99 
100  // get conditions
101  const CastorDbService* conditions = &iSetup.getData(tokCond_);
102  const CastorChannelQuality* myqual = &iSetup.getData(tokChan_);
103 
104  if (!rechits.isValid())
105  edm::LogWarning("CastorRecHitCorrector") << "No valid CastorRecHitCollection found, please check the InputLabel...";
106 
107  CastorCalibrations calibrations;
108 
109  auto rec = std::make_unique<CastorRecHitCollection>();
110 
111  for (unsigned int i = 0; i < rechits->size(); i++) {
112  CastorRecHit rechit = (*rechits)[i];
113  double time = rechit.time();
114  double correctedenergy = factor_ * rechit.energy();
115 
116  if (doInterCalib_) {
117  // do proper gain calibration reading the latest entries in the condDB
118  const CastorCalibrations& calibrations = conditions->getCastorCalibrations(rechit.id());
119  int capid = 0; // take some capid, gains are the same for all capid's
120  correctedenergy *= calibrations.gain(capid);
121  }
122 
123  // now check the channelquality of this rechit
124  bool ok = true;
125  DetId detcell = (DetId)rechit.id();
126  std::vector<DetId> channels = myqual->getAllChannels();
127  for (auto channel : channels) {
128  if (channel.rawId() == detcell.rawId()) {
129  const CastorChannelStatus* mydigistatus = myqual->getValues(channel);
130  if (mydigistatus->getValue() == 2989) {
131  ok = false; // 2989 = BAD
132  break;
133  }
134  }
135  }
136 
137  if (ok) {
138  rec->emplace_back(rechit.id(), correctedenergy, time);
139  }
140  }
141 
142  iEvent.put(std::move(rec));
143 
144  delete myqual;
145 }
constexpr float energy() const
Definition: CaloRecHit.h:29
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
const edm::ESGetToken< CastorChannelQuality, CastorChannelQualityRcd > tokChan_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
const bool doInterCalib_
HcalCastorDetId id() const
get the id
Definition: CastorRecHit.h:14
bool getData(T &iHolder) const
Definition: EventSetup.h:122
const edm::ESGetToken< CastorDbService, CastorDbRecord > tokCond_
uint32_t getValue() const
def move
Definition: eostools.py:511
constexpr float time() const
Definition: CaloRecHit.h:31
Definition: DetId.h:17
double gain(int fCapId) const
get gain for capid=0..3
const double factor_

Member Data Documentation

const bool RecHitCorrector::doInterCalib_
private

Definition at line 57 of file RecHitCorrector.cc.

Referenced by produce().

const double RecHitCorrector::factor_
private

Definition at line 56 of file RecHitCorrector.cc.

Referenced by produce().

edm::EDGetTokenT<CastorRecHitCollection> RecHitCorrector::tok_input_
private

Definition at line 58 of file RecHitCorrector.cc.

Referenced by produce(), and RecHitCorrector().

const edm::ESGetToken<CastorChannelQuality, CastorChannelQualityRcd> RecHitCorrector::tokChan_
private

Definition at line 55 of file RecHitCorrector.cc.

Referenced by produce().

const edm::ESGetToken<CastorDbService, CastorDbRecord> RecHitCorrector::tokCond_
private

Definition at line 54 of file RecHitCorrector.cc.

Referenced by produce().