CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 RecHitCorrector (const edm::ParameterSet &)
 
 ~RecHitCorrector () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

bool doInterCalib_
 
double factor_
 
edm::EDGetTokenT
< CastorRecHitCollection
tok_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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 
)
overrideprivatevirtual

Implements edm::stream::EDProducerBase.

Definition at line 99 of file RecHitCorrector.cc.

References doInterCalib_, CaloRecHit::energy(), factor_, CastorCalibrations::gain(), edm::EventSetup::get(), edm::Event::getByToken(), CastorChannelStatus::getValue(), i, CastorRecHit::id(), eostools::move(), convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), DetId::rawId(), HI_PhotonSkim_cff::rechits, CaloRecHit::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);
113  CastorChannelQuality* myqual = new CastorChannelQuality(*p.product());
114 
115  if (!rechits.isValid()) edm::LogWarning("CastorRecHitCorrector") << "No valid CastorRecHitCollection found, please check the InputLabel...";
116 
117  CastorCalibrations calibrations;
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 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
float time() const
Definition: CaloRecHit.h:19
HcalCastorDetId id() const
get the id
Definition: CastorRecHit.h:15
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
uint32_t getValue() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
float energy() const
Definition: CaloRecHit.h:17
def move
Definition: eostools.py:510
Definition: DetId.h:18
double gain(int fCapId) const
get gain for capid=0..3
const T & get() const
Definition: EventSetup.h:56

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().