CMS 3D CMS Logo

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

List of all members.

Public Member Functions

 RecHitCorrector (const edm::ParameterSet &)
 ~RecHitCorrector ()

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_

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.

                                                              :
inputLabel_(iConfig.getParameter<edm::InputTag>("rechitLabel")),
factor_(iConfig.getParameter<double>("revertFactor")),
doInterCalib_(iConfig.getParameter<bool>("doInterCalib"))
{
   //register your products
   produces<CastorRecHitCollection>();
   //now do what ever other initialization is needed
}
RecHitCorrector::~RecHitCorrector ( )

Definition at line 87 of file RecHitCorrector.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void RecHitCorrector::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 176 of file RecHitCorrector.cc.

{
}
void RecHitCorrector::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 182 of file RecHitCorrector.cc.

                        {
}
void RecHitCorrector::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

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, cond::rpcobgas::time, and CaloRecHit::time().

{
   using namespace edm;
   
   // get original rechits
   edm::Handle<CastorRecHitCollection> rechits;
   iEvent.getByLabel(inputLabel_,rechits);
   
   // get conditions
   edm::ESHandle<CastorDbService> conditions;
   iSetup.get<CastorDbRecord>().get(conditions);
   
   edm::ESHandle<CastorChannelQuality> p;
   iSetup.get<CastorChannelQualityRcd>().get(p);
   CastorChannelQuality* myqual = new CastorChannelQuality(*p.product());
   
   if (!rechits.isValid()) std::cout << "No valid CastorRecHitCollection found, please check the InputLabel..." << std::endl;
   
   CastorCalibrations calibrations;
   
   std::auto_ptr<CastorRecHitCollection> rec(new CastorRecHitCollection);
   
   for (unsigned int i=0;i<rechits->size();i++) {
        CastorRecHit rechit = (*rechits)[i];
        //std::cout << "rechit energy = " << rechit.energy() << std::endl;
        double fC = factor_*rechit.energy();
        double time = rechit.time();
        //std::cout << "rechit energy(fC) = " << fC << " time = " << time << std::endl;
        
        // do proper gain calibration reading the latest entries in the condDB
        const CastorCalibrations& calibrations=conditions->getCastorCalibrations(rechit.id());
        int capid = 0; // take some capid, gains are the same for all capid's
        
        double correctedenergy = 0;
        if (doInterCalib_) {
                if (rechit.id().module() <= 2) {
                        correctedenergy = 0.5*fC*calibrations.gain(capid);
                        //std::cout << " correctedenergy = " << correctedenergy << " gain = " << calibrations.gain(capid) << std::endl;
                } else {
                        correctedenergy = fC*calibrations.gain(capid);
                }
        } else {
                if (rechit.id().module() <= 2) {
                        correctedenergy = 0.5*fC;
                } else {
                        correctedenergy = fC;
                }
        }
        
        // now check the channelquality of this rechit
        bool ok = true;
        DetId detcell=(DetId)rechit.id();
        std::vector<DetId> channels = myqual->getAllChannels();
        //std::cout << "number of specified quality flags = " << channels.size() << std::endl;
        for (std::vector<DetId>::iterator channel = channels.begin();channel !=  channels.end();channel++) {    
                if (channel->rawId() == detcell.rawId()) {
                        const CastorChannelStatus* mydigistatus=myqual->getValues(*channel);
                        //std::cout << "CastorChannelStatus = " << mydigistatus->getValue() << std::endl;
                        if (mydigistatus->getValue() == 2989) ok = false; // 2989 = BAD
                }
        }
        
        if (ok) {
            CastorRecHit *correctedhit = new CastorRecHit(rechit.id(),correctedenergy,time);
            rec->push_back(*correctedhit);
        }
   }
   
   iEvent.put(rec);
 
}

Member Data Documentation

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

Definition at line 59 of file RecHitCorrector.cc.

Referenced by produce().