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::ProductRegistryHelper

Public Member Functions

 RecHitCorrector (const edm::ParameterSet &)
 
 ~RecHitCorrector ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

bool doInterCalib_
 
double factor_
 
edm::InputTag inputLabel_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 48 of file RecHitCorrector.cc.

Constructor & Destructor Documentation

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

Definition at line 76 of file RecHitCorrector.cc.

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

Definition at line 87 of file RecHitCorrector.cc.

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

Member Function Documentation

void RecHitCorrector::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 176 of file RecHitCorrector.cc.

177 {
178 }
void RecHitCorrector::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 182 of file RecHitCorrector.cc.

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

Implements edm::EDProducer.

Definition at line 102 of file RecHitCorrector.cc.

References gather_cfg::cout, doInterCalib_, CaloRecHit::energy(), factor_, CastorCalibrations::gain(), edm::EventSetup::get(), edm::Event::getByLabel(), CastorChannelStatus::getValue(), i, CastorRecHit::id(), inputLabel_, HcalCastorDetId::module(), convertSQLiteXML::ok, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), DetId::rawId(), HI_PhotonSkim_cff::rechits, CaloRecHit::time(), and cond::rpcobgas::time.

103 {
104  using namespace edm;
105 
106  // get original rechits
109 
110  // get conditions
112  iSetup.get<CastorDbRecord>().get(conditions);
113 
115  iSetup.get<CastorChannelQualityRcd>().get(p);
116  CastorChannelQuality* myqual = new CastorChannelQuality(*p.product());
117 
118  if (!rechits.isValid()) std::cout << "No valid CastorRecHitCollection found, please check the InputLabel..." << std::endl;
119 
120  CastorCalibrations calibrations;
121 
122  std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection);
123 
124  for (unsigned int i=0;i<rechits->size();i++) {
125  CastorRecHit rechit = (*rechits)[i];
126  //std::cout << "rechit energy = " << rechit.energy() << std::endl;
127  double fC = factor_*rechit.energy();
128  double time = rechit.time();
129  //std::cout << "rechit energy(fC) = " << fC << " time = " << time << std::endl;
130 
131  // do proper gain calibration reading the latest entries in the condDB
132  const CastorCalibrations& calibrations=conditions->getCastorCalibrations(rechit.id());
133  int capid = 0; // take some capid, gains are the same for all capid's
134 
135  double correctedenergy = 0;
136  if (doInterCalib_) {
137  if (rechit.id().module() <= 2) {
138  correctedenergy = 0.5*fC*calibrations.gain(capid);
139  //std::cout << " correctedenergy = " << correctedenergy << " gain = " << calibrations.gain(capid) << std::endl;
140  } else {
141  correctedenergy = fC*calibrations.gain(capid);
142  }
143  } else {
144  if (rechit.id().module() <= 2) {
145  correctedenergy = 0.5*fC;
146  } else {
147  correctedenergy = fC;
148  }
149  }
150 
151  // now check the channelquality of this rechit
152  bool ok = true;
153  DetId detcell=(DetId)rechit.id();
154  std::vector<DetId> channels = myqual->getAllChannels();
155  //std::cout << "number of specified quality flags = " << channels.size() << std::endl;
156  for (std::vector<DetId>::iterator channel = channels.begin();channel != channels.end();channel++) {
157  if (channel->rawId() == detcell.rawId()) {
158  const CastorChannelStatus* mydigistatus=myqual->getValues(*channel);
159  //std::cout << "CastorChannelStatus = " << mydigistatus->getValue() << std::endl;
160  if (mydigistatus->getValue() == 2989) ok = false; // 2989 = BAD
161  }
162  }
163 
164  if (ok) {
165  CastorRecHit *correctedhit = new CastorRecHit(rechit.id(),correctedenergy,time);
166  rec->push_back(*correctedhit);
167  }
168  }
169 
170  iEvent.put(rec);
171 
172 }
int i
Definition: DBlmapReader.cc:9
int module() const
get the module (1-2 for EM, 1-12 for HAD)
float time() const
Definition: CaloRecHit.h:21
HcalCastorDetId id() const
get the id
Definition: CastorRecHit.h:15
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
uint32_t getValue() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
float energy() const
Definition: CaloRecHit.h:19
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
Definition: DetId.h:20
double gain(int fCapId) const
get gain for capid=0..3
edm::InputTag inputLabel_
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 61 of file RecHitCorrector.cc.

Referenced by produce().

double RecHitCorrector::factor_
private

Definition at line 60 of file RecHitCorrector.cc.

Referenced by produce().

edm::InputTag RecHitCorrector::inputLabel_
private

Definition at line 59 of file RecHitCorrector.cc.

Referenced by produce().