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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 RecHitCorrector (const edm::ParameterSet &)
 
 ~RecHitCorrector () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
void endJob () override
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
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 75 of file RecHitCorrector.cc.

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

75  :
76 factor_(iConfig.getParameter<double>("revertFactor")),
77 doInterCalib_(iConfig.getParameter<bool>("doInterCalib"))
78 {
79  tok_input_ = consumes<CastorRecHitCollection>(iConfig.getParameter<edm::InputTag>("rechitLabel"));
80  //register your products
81  produces<CastorRecHitCollection>();
82  //now do what ever other initialization is needed
83 }
T getParameter(std::string const &) const
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
RecHitCorrector::~RecHitCorrector ( )
override

Definition at line 86 of file RecHitCorrector.cc.

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

Member Function Documentation

void RecHitCorrector::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 175 of file RecHitCorrector.cc.

176 {
177 }
void RecHitCorrector::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 181 of file RecHitCorrector.cc.

References DEFINE_FWK_MODULE.

181  {
182 }
void RecHitCorrector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 101 of file RecHitCorrector.cc.

References AlignmentProducer_cff::calibrations, gather_cfg::cout, 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(), HcalCastorDetId::module(), 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_.

102 {
103  using namespace edm;
104 
105  // get original rechits
107  iEvent.getByToken(tok_input_,rechits);
108 
109  // get conditions
111  iSetup.get<CastorDbRecord>().get(conditions);
112 
114  iSetup.get<CastorChannelQualityRcd>().get(p);
116 
117  if (!rechits.isValid()) std::cout << "No valid CastorRecHitCollection found, please check the InputLabel..." << std::endl;
118 
120 
121  auto rec = std::make_unique<CastorRecHitCollection>();
122 
123  for (unsigned int i=0;i<rechits->size();i++) {
124  CastorRecHit rechit = (*rechits)[i];
125  //std::cout << "rechit energy = " << rechit.energy() << std::endl;
126  double fC = factor_*rechit.energy();
127  double time = rechit.time();
128  //std::cout << "rechit energy(fC) = " << fC << " time = " << time << std::endl;
129 
130  // do proper gain calibration reading the latest entries in the condDB
131  const CastorCalibrations& calibrations=conditions->getCastorCalibrations(rechit.id());
132  int capid = 0; // take some capid, gains are the same for all capid's
133 
134  double correctedenergy = 0;
135  if (doInterCalib_) {
136  if (rechit.id().module() <= 2) {
137  correctedenergy = 0.5*fC*calibrations.gain(capid);
138  //std::cout << " correctedenergy = " << correctedenergy << " gain = " << calibrations.gain(capid) << std::endl;
139  } else {
140  correctedenergy = fC*calibrations.gain(capid);
141  }
142  } else {
143  if (rechit.id().module() <= 2) {
144  correctedenergy = 0.5*fC;
145  } else {
146  correctedenergy = fC;
147  }
148  }
149 
150  // now check the channelquality of this rechit
151  bool ok = true;
152  DetId detcell=(DetId)rechit.id();
153  std::vector<DetId> channels = myqual->getAllChannels();
154  //std::cout << "number of specified quality flags = " << channels.size() << std::endl;
155  for (std::vector<DetId>::iterator channel = channels.begin();channel != channels.end();channel++) {
156  if (channel->rawId() == detcell.rawId()) {
157  const CastorChannelStatus* mydigistatus=myqual->getValues(*channel);
158  //std::cout << "CastorChannelStatus = " << mydigistatus->getValue() << std::endl;
159  if (mydigistatus->getValue() == 2989) ok = false; // 2989 = BAD
160  }
161  }
162 
163  if (ok) {
164  CastorRecHit *correctedhit = new CastorRecHit(rechit.id(),correctedenergy,time);
165  rec->push_back(*correctedhit);
166  }
167  }
168 
169  iEvent.put(std::move(rec));
170 
171 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
std::vector< DetId > getAllChannels() const
const CastorCalibrations & getCastorCalibrations(const HcalGenericDetId &fId) const
int module() const
get the module (1-2 for EM, 1-12 for HAD)
float time() const
Definition: CaloRecHit.h:19
const Item * getValues(DetId fId, bool throwOnFail=true) const
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
float energy() const
Definition: CaloRecHit.h:17
bool isValid() const
Definition: HandleBase.h:74
Definition: DetId.h:18
double gain(int fCapId) const
get gain for capid=0..3
const T & get() const
Definition: EventSetup.h:55
HLT enums.
size_type size() const
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

bool RecHitCorrector::doInterCalib_
private

Definition at line 60 of file RecHitCorrector.cc.

Referenced by produce().

double RecHitCorrector::factor_
private

Definition at line 59 of file RecHitCorrector.cc.

Referenced by produce().

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

Definition at line 58 of file RecHitCorrector.cc.

Referenced by produce(), and RecHitCorrector().