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 ( const edm::ParameterSet iConfig)
explicit

Definition at line 71 of file RecHitCorrector.cc.

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

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 }
T getParameter(std::string const &) const
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
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

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

Definition at line 89 of file RecHitCorrector.cc.

References AlignmentProducer_cff::calibrations, ewkTauDQM_cfi::channels, 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_.

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);
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 }
constexpr float energy() const
Definition: CaloRecHit.h:29
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
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:14
uint32_t getValue() const
constexpr float time() const
Definition: CaloRecHit.h:31
bool isValid() const
Definition: HandleBase.h:70
Definition: DetId.h:17
double gain(int fCapId) const
get gain for capid=0..3
HLT enums.
size_type size() const
T get() const
Definition: EventSetup.h:73
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 57 of file RecHitCorrector.cc.

Referenced by produce().

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

Referenced by produce(), and RecHitCorrector().