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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

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

Private Attributes

bool doInterCalib_
 
double factor_
 
edm::EDGetTokenT< CastorRecHitCollectiontok_input_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 46 of file RecHitCorrector.cc.

Constructor & Destructor Documentation

◆ RecHitCorrector()

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

Definition at line 71 of file RecHitCorrector.cc.

72  : factor_(iConfig.getParameter<double>("revertFactor")), doInterCalib_(iConfig.getParameter<bool>("doInterCalib")) {
73  tok_input_ = consumes<CastorRecHitCollection>(iConfig.getParameter<edm::InputTag>("rechitLabel"));
74  //register your products
75  produces<CastorRecHitCollection>();
76  //now do what ever other initialization is needed
77 }

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

◆ ~RecHitCorrector()

RecHitCorrector::~RecHitCorrector ( )
override

Definition at line 79 of file RecHitCorrector.cc.

79  {
80  // do anything here that needs to be done at desctruction time
81  // (e.g. close files, deallocate resources etc.)
82 }

Member Function Documentation

◆ produce()

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

Definition at line 89 of file RecHitCorrector.cc.

89  {
90  using namespace edm;
91 
92  // get original rechits
94  iEvent.getByToken(tok_input_, rechits);
95 
96  // get conditions
98  iSetup.get<CastorDbRecord>().get(conditions);
99 
101  iSetup.get<CastorChannelQualityRcd>().get(p);
102  CastorChannelQuality* myqual = new CastorChannelQuality(*p.product());
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 }

References AlignmentProducer_cff::calibrations, ewkTauDQM_cfi::channels, doInterCalib_, CaloRecHit::energy(), factor_, edm::EventSetup::get(), get, CastorCondObjectContainer< Item >::getAllChannels(), CastorDbService::getCastorCalibrations(), CastorChannelStatus::getValue(), CastorCondObjectContainer< Item >::getValues(), mps_fire::i, CastorRecHit::id(), iEvent, eostools::move(), convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, DetId::rawId(), TrackInfoProducer_cfi::rechits, CaloRecHit::time(), ntuplemaker::time, and tok_input_.

Member Data Documentation

◆ doInterCalib_

bool RecHitCorrector::doInterCalib_
private

Definition at line 57 of file RecHitCorrector.cc.

Referenced by produce().

◆ factor_

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 55 of file RecHitCorrector.cc.

Referenced by produce(), and RecHitCorrector().

RecHitCorrector::tok_input_
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
Definition: RecHitCorrector.cc:55
CastorCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: CastorCondObjectContainer.h:65
mps_fire.i
i
Definition: mps_fire.py:355
CaloRecHit::energy
constexpr float energy() const
Definition: CaloRecHit.h:29
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CastorDbService::getCastorCalibrations
const CastorCalibrations & getCastorCalibrations(const HcalGenericDetId &fId) const
Definition: CastorDbService.h:32
AlignmentProducer_cff.calibrations
calibrations
Definition: AlignmentProducer_cff.py:59
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::Handle
Definition: AssociativeIterator.h:50
CastorCondObjectContainer::getAllChannels
std::vector< DetId > getAllChannels() const
Definition: CastorCondObjectContainer.h:119
DetId
Definition: DetId.h:17
CastorCalibrations
Definition: CastorCalibrations.h:9
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
CastorRecHit
Definition: CastorRecHit.h:7
edm::ESHandle
Definition: DTSurvey.h:22
CastorRecHit::id
HcalCastorDetId id() const
get the id
Definition: CastorRecHit.h:14
CaloRecHit::time
constexpr float time() const
Definition: CaloRecHit.h:31
edm::LogWarning
Definition: MessageLogger.h:141
CastorChannelQualityRcd
Definition: CastorChannelQualityRcd.h:24
TrackInfoProducer_cfi.rechits
rechits
Definition: TrackInfoProducer_cfi.py:9
iEvent
int iEvent
Definition: GenABIO.cc:224
CastorChannelStatus::getValue
uint32_t getValue() const
Definition: CastorChannelStatus.h:68
RecHitCorrector::factor_
double factor_
Definition: RecHitCorrector.cc:56
get
#define get
CastorChannelQuality
Definition: CastorChannelQuality.h:17
CastorDbRecord
Definition: CastorDbRecord.h:29
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CastorChannelStatus
Definition: CastorChannelStatus.h:15
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
ntuplemaker.time
time
Definition: ntuplemaker.py:310
edm::InputTag
Definition: InputTag.h:15
RecHitCorrector::doInterCalib_
bool doInterCalib_
Definition: RecHitCorrector.cc:57