CMS 3D CMS Logo

EcalRecHitRecalib Class Reference

Description: Producer to miscalibrate (calibrated) Ecal RecHit. More...

#include <CalibCalorimetry/CaloMiscalibTools.src/EcalRecHitRecalib.cc>

Inheritance diagram for EcalRecHitRecalib:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EcalRecHitRecalib (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~EcalRecHitRecalib ()

Private Attributes

std::string barrelHits_
std::string ecalHitsProducer_
std::string endcapHits_
std::string RecalibBarrelHits_
std::string RecalibEndcapHits_
double refactor_
double refactor_mean_


Detailed Description

Description: Producer to miscalibrate (calibrated) Ecal RecHit.

Implementation: <Notes on="" implementation>="">

Definition at line 40 of file EcalRecHitRecalib.h.


Constructor & Destructor Documentation

EcalRecHitRecalib::EcalRecHitRecalib ( const edm::ParameterSet iConfig  )  [explicit]

Definition at line 15 of file EcalRecHitRecalib.cc.

References barrelHits_, ecalHitsProducer_, endcapHits_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, and refactor_mean_.

00016 {
00017   ecalHitsProducer_ = iConfig.getParameter< std::string > ("ecalRecHitsProducer");
00018   barrelHits_ = iConfig.getParameter< std::string > ("barrelHitCollection");
00019   endcapHits_ = iConfig.getParameter< std::string > ("endcapHitCollection");
00020   RecalibBarrelHits_ = iConfig.getParameter< std::string > ("RecalibBarrelHitCollection");
00021   RecalibEndcapHits_ = iConfig.getParameter< std::string > ("RecalibEndcapHitCollection");
00022   refactor_ = iConfig.getUntrackedParameter<double> ("Refactor",(double)1);
00023   refactor_mean_ = iConfig.getUntrackedParameter<double> ("Refactor_mean",(double)1);
00024 
00025   //register your products
00026   produces< EBRecHitCollection >(RecalibBarrelHits_);
00027   produces< EERecHitCollection >(RecalibEndcapHits_);
00028 }

EcalRecHitRecalib::~EcalRecHitRecalib (  ) 

Definition at line 31 of file EcalRecHitRecalib.cc.

00032 {
00033  
00034 
00035 }


Member Function Documentation

void EcalRecHitRecalib::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 40 of file EcalRecHitRecalib.cc.

References barrelHits_, edm::SortedCollection< T, SORT >::begin(), ecalHitsProducer_, edm::SortedCollection< T, SORT >::end(), endcapHits_, lat::endl(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), LogDebug, edm::ESHandle< T >::product(), edm::Event::put(), RecalibBarrelHits_, RecalibEndcapHits_, refactor_, refactor_mean_, and std.

00041 {
00042   using namespace edm;
00043   using namespace std;
00044 
00045   Handle<EBRecHitCollection> barrelRecHitsHandle;
00046   Handle<EERecHitCollection> endcapRecHitsHandle;
00047 
00048   const EBRecHitCollection*  EBRecHits = 0;
00049   const EERecHitCollection*  EERecHits = 0; 
00050  
00051   iEvent.getByLabel(ecalHitsProducer_,barrelHits_,barrelRecHitsHandle);
00052   if (!barrelRecHitsHandle.isValid()) {
00053     LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
00054   } else {
00055     EBRecHits = barrelRecHitsHandle.product(); // get a ptr to the product
00056   }
00057 
00058   iEvent.getByLabel(ecalHitsProducer_,endcapHits_,endcapRecHitsHandle);
00059   if (!endcapRecHitsHandle.isValid()) {
00060     LogDebug("") << "EcalREcHitMiscalib: Error! can't get product!" << std::endl;
00061   } else {
00062     EERecHits = endcapRecHitsHandle.product(); // get a ptr to the product
00063   }
00064 
00065   //Create empty output collections
00066   std::auto_ptr< EBRecHitCollection > RecalibEBRecHitCollection( new EBRecHitCollection );
00067   std::auto_ptr< EERecHitCollection > RecalibEERecHitCollection( new EERecHitCollection );
00068 
00069 
00070   // Intercalib constants
00071   edm::ESHandle<EcalIntercalibConstants> pIcal;
00072   iSetup.get<EcalIntercalibConstantsRcd>().get(pIcal);
00073   const EcalIntercalibConstants* ical = pIcal.product();
00074 
00075   if(EBRecHits)
00076     {
00077 
00078        //loop on all EcalRecHits (barrel)
00079       EBRecHitCollection::const_iterator itb;
00080       for (itb=EBRecHits->begin(); itb!=EBRecHits->end(); itb++) {
00081         
00082         // find intercalib constant for this xtal
00083         EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(itb->id().rawId());
00084         EcalIntercalibConstant icalconst = -1;
00085 
00086         if( icalit!=ical->getMap().end() ){
00087           icalconst = (*icalit);
00088           // edm::LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EBDetId(itb->id()) << " " << icalconst ;
00089 
00090         } else {
00091           edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EBDetId(itb->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
00092               ;
00093           }
00094           
00095           // make the rechit with rescaled energy and put in the output collection
00096         icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
00097         EcalRecHit aHit(itb->id(),itb->energy()*icalconst,itb->time());
00098           
00099         RecalibEBRecHitCollection->push_back( aHit);
00100       }
00101     }
00102 
00103   if(EERecHits)
00104     {
00105 
00106        //loop on all EcalRecHits (barrel)
00107       EERecHitCollection::const_iterator ite;
00108       for (ite=EERecHits->begin(); ite!=EERecHits->end(); ite++) {
00109         
00110         // find intercalib constant for this xtal
00111         EcalIntercalibConstantMap::const_iterator icalit=ical->getMap().find(ite->id().rawId());
00112         EcalIntercalibConstant icalconst = -1;
00113 
00114         if( icalit!=ical->getMap().end() ){
00115           icalconst = (*icalit);
00116           // edm:: LogDebug("EcalRecHitRecalib") << "Found intercalib for xtal " << EEDetId(ite->id()) << " " << icalconst ;
00117           } else {
00118             edm::LogError("EcalRecHitRecalib") << "No intercalib const found for xtal " << EEDetId(ite->id()) << "! something wrong with EcalIntercalibConstants in your DB? "
00119               ;
00120           }
00121           
00122           // make the rechit with rescaled energy and put in the output collection
00123         
00124         icalconst=refactor_mean_+(icalconst-refactor_mean_)*refactor_; //apply additional scaling factor (works if gaussian)
00125         EcalRecHit aHit(ite->id(),ite->energy()*icalconst,ite->time());
00126         
00127         RecalibEERecHitCollection->push_back( aHit);
00128       }
00129     }
00130 
00131 
00132   //Put Recalibrated rechit in the event
00133   iEvent.put( RecalibEBRecHitCollection, RecalibBarrelHits_);
00134   iEvent.put( RecalibEERecHitCollection, RecalibEndcapHits_);
00135   
00136 }


Member Data Documentation

std::string EcalRecHitRecalib::barrelHits_ [private]

Definition at line 51 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::ecalHitsProducer_ [private]

Definition at line 50 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::endcapHits_ [private]

Definition at line 52 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibBarrelHits_ [private]

Definition at line 53 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

std::string EcalRecHitRecalib::RecalibEndcapHits_ [private]

Definition at line 54 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_ [private]

Definition at line 55 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().

double EcalRecHitRecalib::refactor_mean_ [private]

Definition at line 56 of file EcalRecHitRecalib.h.

Referenced by EcalRecHitRecalib(), and produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:19:51 2009 for CMSSW by  doxygen 1.5.4