CMS 3D CMS Logo

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< CastorRecHitCollectiontok_input_
 
const edm::ESGetToken< CastorChannelQuality, CastorChannelQualityRcdtokChan_
 
const edm::ESGetToken< CastorDbService, CastorDbRecordtokCond_
 

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::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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
const edm::ESGetToken< CastorChannelQuality, CastorChannelQualityRcd > tokChan_
const bool doInterCalib_
const edm::ESGetToken< CastorDbService, CastorDbRecord > tokCond_
const double factor_

◆ ~RecHitCorrector()

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

◆ produce()

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

Definition at line 93 of file RecHitCorrector.cc.

References AlignmentProducer_cff::calibrations, ewkTauDQM_cfi::channels, submitPVValidationJobs::conditions, doInterCalib_, CaloRecHit::energy(), factor_, CastorCondObjectContainer< Item >::getAllChannels(), edm::EventSetup::getData(), CastorChannelStatus::getValue(), CastorCondObjectContainer< Item >::getValues(), mps_fire::i, CastorRecHit::id(), iEvent, eostools::move(), convertSQLiteXML::ok, DetId::rawId(), HI_PhotonSkim_cff::rechits, protons_cff::time, 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 
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 }
const Item * getValues(DetId fId, bool throwOnFail=true) const
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
const edm::ESGetToken< CastorChannelQuality, CastorChannelQualityRcd > tokChan_
HcalCastorDetId id() const
get the id
Definition: CastorRecHit.h:14
const bool doInterCalib_
std::vector< DetId > getAllChannels() const
constexpr float energy() const
Definition: CaloRecHit.h:29
int iEvent
Definition: GenABIO.cc:224
const edm::ESGetToken< CastorDbService, CastorDbRecord > tokCond_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
uint32_t getValue() const
constexpr float time() const
Definition: CaloRecHit.h:31
HLT enums.
def move(src, dest)
Definition: eostools.py:511
const double factor_

Member Data Documentation

◆ doInterCalib_

const bool RecHitCorrector::doInterCalib_
private

Definition at line 57 of file RecHitCorrector.cc.

Referenced by produce().

◆ factor_

const double RecHitCorrector::factor_
private

Definition at line 56 of file RecHitCorrector.cc.

Referenced by produce().

◆ tok_input_

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

Definition at line 58 of file RecHitCorrector.cc.

Referenced by produce(), and RecHitCorrector().

◆ tokChan_

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

Definition at line 55 of file RecHitCorrector.cc.

Referenced by produce().

◆ tokCond_

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

Definition at line 54 of file RecHitCorrector.cc.

Referenced by produce().