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

Public Member Functions

 RecHitCorrector (const edm::ParameterSet &)
 
 ~RecHitCorrector ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 (const std::string &iProcessName, std::vector< const char * > &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

virtual void beginJob () override
 
virtual void endJob () override
 
virtual 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::EDProducer
typedef EDProducer 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::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 ( )

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.

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

Implements edm::EDProducer.

Definition at line 101 of file RecHitCorrector.cc.

References gather_cfg::cout, doInterCalib_, CaloRecHit::energy(), factor_, CastorCalibrations::gain(), edm::EventSetup::get(), edm::Event::getByToken(), CastorChannelStatus::getValue(), i, CastorRecHit::id(), HcalCastorDetId::module(), convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), DetId::rawId(), HI_PhotonSkim_cff::rechits, CaloRecHit::time(), cond::rpcobgas::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);
115  CastorChannelQuality* myqual = new CastorChannelQuality(*p.product());
116 
117  if (!rechits.isValid()) std::cout << "No valid CastorRecHitCollection found, please check the InputLabel..." << std::endl;
118 
119  CastorCalibrations calibrations;
120 
121  std::auto_ptr<CastorRecHitCollection> rec(new 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(rec);
170 
171 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< CastorRecHitCollection > tok_input_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
int module() const
get the module (1-2 for EM, 1-12 for HAD)
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:115
float energy() const
Definition: CaloRecHit.h:17
Definition: DetId.h:18
double gain(int fCapId) const
get gain for capid=0..3
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:121

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