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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 47 of file RecHitCorrector.cc.

Constructor & Destructor Documentation

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

Definition at line 73 of file RecHitCorrector.cc.

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

73  :
74 factor_(iConfig.getParameter<double>("revertFactor")),
75 doInterCalib_(iConfig.getParameter<bool>("doInterCalib"))
76 {
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
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
RecHitCorrector::~RecHitCorrector ( )
override

Definition at line 84 of file RecHitCorrector.cc.

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

Member Function Documentation

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

Definition at line 99 of file RecHitCorrector.cc.

References AlignmentProducer_cff::calibrations, DEFINE_FWK_MODULE, doInterCalib_, CaloRecHit::energy(), factor_, CastorCalibrations::gain(), edm::EventSetup::get(), CastorCondObjectContainer< Item >::getAllChannels(), edm::Event::getByToken(), CastorDbService::getCastorCalibrations(), CastorChannelStatus::getValue(), CastorCondObjectContainer< Item >::getValues(), mps_fire::i, CastorRecHit::id(), edm::HandleBase::isValid(), eostools::move(), convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, edm::ESHandle< T >::product(), edm::Event::put(), DetId::rawId(), TrackInfoProducer_cfi::rechits, edm::SortedCollection< T, SORT >::size(), CaloRecHit::time(), ntuplemaker::time, and tok_input_.

100 {
101  using namespace edm;
102 
103  // get original rechits
105  iEvent.getByToken(tok_input_,rechits);
106 
107  // get conditions
109  iSetup.get<CastorDbRecord>().get(conditions);
110 
112  iSetup.get<CastorChannelQualityRcd>().get(p);
114 
115  if (!rechits.isValid()) edm::LogWarning("CastorRecHitCorrector") << "No valid CastorRecHitCollection found, please check the InputLabel...";
116 
118 
119  auto rec = std::make_unique<CastorRecHitCollection>();
120 
121  for (unsigned int i=0;i<rechits->size();i++) {
122  CastorRecHit rechit = (*rechits)[i];
123  double time = rechit.time();
124  double correctedenergy = factor_*rechit.energy();
125 
126  if (doInterCalib_) {
127  // do proper gain calibration reading the latest entries in the condDB
128  const CastorCalibrations& calibrations=conditions->getCastorCalibrations(rechit.id());
129  int capid = 0; // take some capid, gains are the same for all capid's
130  correctedenergy *= calibrations.gain(capid);
131  }
132 
133  // now check the channelquality of this rechit
134  bool ok = true;
135  DetId detcell=(DetId)rechit.id();
136  std::vector<DetId> channels = myqual->getAllChannels();
137  for (auto channel : channels) {
138  if (channel.rawId() == detcell.rawId()) {
139  const CastorChannelStatus* mydigistatus=myqual->getValues(channel);
140  if (mydigistatus->getValue() == 2989) {
141  ok = false; // 2989 = BAD
142  break;
143  }
144  }
145  }
146 
147  if (ok) {
148  rec->emplace_back(rechit.id(),correctedenergy,time);
149  }
150  }
151 
152  iEvent.put(std::move(rec));
153 
154  delete myqual;
155 
156 }
constexpr float energy() const
Definition: CaloRecHit.h:31
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::vector< DetId > getAllChannels() const
const CastorCalibrations & getCastorCalibrations(const HcalGenericDetId &fId) const
const Item * getValues(DetId fId, bool throwOnFail=true) const
HcalCastorDetId id() const
get the id
Definition: CastorRecHit.h:15
uint32_t getValue() const
constexpr float time() const
Definition: CaloRecHit.h:33
bool isValid() const
Definition: HandleBase.h:74
Definition: DetId.h:18
double gain(int fCapId) const
get gain for capid=0..3
HLT enums.
size_type size() const
T get() const
Definition: EventSetup.h:71
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool RecHitCorrector::doInterCalib_
private

Definition at line 58 of file RecHitCorrector.cc.

Referenced by produce().

double RecHitCorrector::factor_
private

Definition at line 57 of file RecHitCorrector.cc.

Referenced by produce().

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

Definition at line 56 of file RecHitCorrector.cc.

Referenced by produce(), and RecHitCorrector().