CMS 3D CMS Logo

EcalFixedAlphaBetaFitUncalibRecHitProducer Class Reference

#include <RecoLocalCalo/EcalRecProducers/interface/EcalFixedAlphaBetaFitUncalibRecHitProducer.h>

Inheritance diagram for EcalFixedAlphaBetaFitUncalibRecHitProducer:

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

List of all members.

Public Types

typedef std::vector< double > EcalRecoAmplitudes

Public Member Functions

 EcalFixedAlphaBetaFitUncalibRecHitProducer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &evt, const edm::EventSetup &es)
 ~EcalFixedAlphaBetaFitUncalibRecHitProducer ()

Private Member Functions

bool setAlphaBeta ()

Private Attributes

EcalUncalibRecHitFixedAlphaBetaAlgo
< EBDataFrame
algoEB_
EcalUncalibRecHitFixedAlphaBetaAlgo
< EEDataFrame
algoEE_
std::string alphabetaFilename_
std::vector< std::vector
< std::pair< double, double > > > 
alphaBetaValues_
double alphaEB_
double alphaEE_
double AmplThrEB_
double AmplThrEE_
double betaEB_
double betaEE_
edm::InputTag EBdigiCollection_
std::string EBhitCollection_
edm::InputTag EEdigiCollection_
std::string EEhitCollection_
bool useAlphaBetaArray_


Detailed Description

Definition at line 15 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.


Member Typedef Documentation

typedef std::vector<double> EcalFixedAlphaBetaFitUncalibRecHitProducer::EcalRecoAmplitudes

Definition at line 18 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.


Constructor & Destructor Documentation

EcalFixedAlphaBetaFitUncalibRecHitProducer::EcalFixedAlphaBetaFitUncalibRecHitProducer ( const edm::ParameterSet ps  )  [explicit]

Definition at line 37 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.cc.

References algoEB_, algoEE_, alphabetaFilename_, alphaEB_, alphaEE_, betaEB_, betaEE_, EBdigiCollection_, EBhitCollection_, EEdigiCollection_, EEhitCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), setAlphaBeta(), EcalUncalibRecHitFixedAlphaBetaAlgo< C >::SetDynamicPedestal(), EcalUncalibRecHitFixedAlphaBetaAlgo< C >::SetMinAmpl(), and useAlphaBetaArray_.

00037                                                                                                                 {
00038 
00039   EBdigiCollection_ = ps.getParameter<edm::InputTag>("EBdigiCollection");
00040   EEdigiCollection_ = ps.getParameter<edm::InputTag>("EEdigiCollection");
00041   EBhitCollection_  = ps.getParameter<std::string>("EBhitCollection");
00042   EEhitCollection_  = ps.getParameter<std::string>("EEhitCollection");
00043 
00044   //AmplThrEB_ =  ps.getParameter<double> ("MinAmplBarrel")
00045   //AmplThrEE_ =  ps.getParameter<double> ("MinAmplEndcap")
00046 
00047   produces< EBUncalibratedRecHitCollection >(EBhitCollection_);
00048   produces< EEUncalibratedRecHitCollection >(EEhitCollection_);
00049 
00050   
00051   alphaEB_= ps.getParameter<double>("alphaEB");
00052   betaEB_= ps.getParameter<double>("betaEB");
00053   alphaEE_= ps.getParameter<double>("alphaEE");
00054   betaEE_= ps.getParameter<double>("betaEE");
00055 
00056    alphabetaFilename_= ps.getUntrackedParameter<std::string>("AlphaBetaFilename","NOFILE");
00057    useAlphaBetaArray_=setAlphaBeta();//set crystalwise values of alpha and beta
00058    if(!useAlphaBetaArray_){edm::LogInfo("EcalUncalibRecHitError") << " No alfa-beta file found. Using the deafult values.";}
00059 
00060    algoEB_.SetMinAmpl( ps.getParameter<double> ("MinAmplBarrel") );
00061    algoEE_.SetMinAmpl(  ps.getParameter<double> ("MinAmplEndcap") );
00062 
00063    bool dyn_pede = ps.getParameter<bool>("UseDynamicPedestal");
00064    algoEB_.SetDynamicPedestal(dyn_pede);
00065    algoEE_.SetDynamicPedestal(dyn_pede);
00066 
00067 }

EcalFixedAlphaBetaFitUncalibRecHitProducer::~EcalFixedAlphaBetaFitUncalibRecHitProducer (  ) 

Definition at line 70 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.cc.

00070                                                                                         {
00071 }


Member Function Documentation

void EcalFixedAlphaBetaFitUncalibRecHitProducer::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 108 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.cc.

References a, algoEB_, algoEE_, alphaBetaValues_, alphaEB_, alphaEE_, b, edm::DataFrameContainer::begin(), betaEB_, betaEE_, EBdigiCollection_, EBhitCollection_, EEdigiCollection_, EEhitCollection_, EcalCondObjectContainer< T >::end(), edm::DataFrameContainer::end(), EcalCondObjectContainer< T >::find(), EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), edm::EventSetup::get(), edm::Event::getByLabel(), EcalCondObjectContainer< T >::getMap(), edm::InputTag::instance(), edm::InputTag::label(), LogDebug, EcalUncalibRecHitFixedAlphaBetaAlgo< C >::makeRecHit(), edm::ESHandle< T >::product(), edm::Event::put(), EcalUncalibRecHitFixedAlphaBetaAlgo< C >::SetAlphaBeta(), edm::DataFrameContainer::size(), and useAlphaBetaArray_.

00108                                                                                           {
00109    using namespace edm;
00110 
00111    Handle< EBDigiCollection > pEBDigis;
00112    Handle< EEDigiCollection > pEEDigis;
00113 
00114    const EBDigiCollection* EBdigis =0;
00115    const EEDigiCollection* EEdigis =0;
00116 
00117    //Barrel
00118    if ( EBdigiCollection_.label() != "" && EBdigiCollection_.instance() != "" ) {
00119            evt.getByLabel( EBdigiCollection_, pEBDigis);
00120            // evt.getByLabel( digiProducer_, pEBDigis);
00121            if ( pEBDigis.isValid() ) {
00122                    EBdigis = pEBDigis.product(); // get a ptr to the EB product
00123                    edm::LogInfo("EcalUncalibRecHitInfo") << "total # EBdigis: " << EBdigis->size();
00124            } else {
00125                    edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product for EB: " << EBdigiCollection_;
00126            }
00127    }
00128    //Endcap
00129    if ( EEdigiCollection_.label() != "" && EEdigiCollection_.instance() != "" ) {
00130            evt.getByLabel( EEdigiCollection_, pEEDigis);
00131            //     evt.getByLabel( digiProducer_, pEEDigis);
00132            if ( pEEDigis.isValid() ) {
00133                    EEdigis = pEEDigis.product(); // get a ptr to the EE product
00134                    edm::LogInfo("EcalUncalibRecHitInfo") << "total # EEdigis: " << EEdigis->size() ;
00135            } else {
00136                    edm::LogError("EcalUncalibRecHitError") << "Error! can't get the product for EE: " << EEdigiCollection_;
00137            }
00138    }
00139 
00140    // Gain Ratios
00141    LogDebug("EcalUncalibRecHitDebug") << "fetching gainRatios....";
00142    edm::ESHandle<EcalGainRatios> pRatio;
00143    es.get<EcalGainRatiosRcd>().get(pRatio);
00144    const EcalGainRatioMap& gainMap = pRatio.product()->getMap(); // map of gain ratios
00145 
00146 
00147    // fetch the pedestals from the cond DB via EventSetup
00148    LogDebug("EcalUncalibRecHitDebug") << "fetching pedestals....";
00149    edm::ESHandle<EcalPedestals> pedHandle;
00150    es.get<EcalPedestalsRcd>().get( pedHandle );
00151    const EcalPedestalsMap & pedMap = pedHandle.product()->getMap(); // map of pedestals
00152    LogDebug("EcalUncalibRecHitDebug") << "done." ;
00153 
00154    // EE and EB collections of reco'ed ampltudes to put in the event
00155    std::auto_ptr< EBUncalibratedRecHitCollection > EBuncalibRechits( new EBUncalibratedRecHitCollection );
00156    std::auto_ptr< EEUncalibratedRecHitCollection > EEuncalibRechits( new EEUncalibratedRecHitCollection );
00157 
00158 //    std::vector<HepMatrix> weights;
00159 //    std::vector<HepSymMatrix> chi2mat;
00160 
00161    EcalPedestalsMapIterator pedIter; // pedestal iterator
00162    EcalPedestals::Item aped; // pedestal object for a single xtal
00163 
00164    EcalGainRatioMap::const_iterator gainIter; // gain iterator
00165    EcalMGPAGainRatio aGain; // gain object for a single xtal
00166 
00167    //loop over EB digis
00168    if( EBdigis ){
00169      for(EBDigiCollection::const_iterator itdg = EBdigis->begin(); itdg != EBdigis->end(); ++itdg) {
00170 
00171        // find pedestals for this channel
00172        LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << EBDetId(itdg->id()) ;
00173        pedIter = pedMap.find(itdg->id());
00174        if( pedIter != pedMap.end() ) {
00175          aped = (*pedIter);
00176        } else {
00177          edm::LogError("EcalUncalibRecHitError") << "error!! could not find pedestals for channel: " << EBDetId(itdg->id()) 
00178                                                  << "\n  no uncalib rechit will be made for this digi!"
00179            ;
00180          continue;
00181        }
00182        double pedVec[3];
00183        pedVec[0]=aped.mean_x12;pedVec[1]=aped.mean_x6;pedVec[2]=aped.mean_x1;
00184        
00185        // find gain ratios
00186        LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << EBDetId(itdg->id()) ;
00187        gainIter = gainMap.find(itdg->id());
00188        if( gainIter != gainMap.end() ) {
00189          aGain = (*gainIter);
00190        } else {
00191          edm::LogError("EcalUncalibRecHitError") << "error!! could not find gain ratios for channel: " << EBDetId(itdg->id())
00192                                                  << "\n  no uncalib rechit will be made for this digi!"
00193            ;
00194          continue;
00195        }
00196        double gainRatios[3];
00197        gainRatios[0]=1.;gainRatios[1]=aGain.gain12Over6();gainRatios[2]=aGain.gain6Over1()*aGain.gain12Over6();
00198 
00199        double a,b;
00200 
00201        // Define Alpha and Beta either by stored values or by default universal values
00202        if (useAlphaBetaArray_){
00203          if ( alphaBetaValues_[EBDetId(itdg->id()).ism()-1].size()!=0){
00204            a=alphaBetaValues_[EBDetId(itdg->id()).ism()-1][EBDetId(itdg->id()).ic()-1].first;
00205            b=alphaBetaValues_[EBDetId(itdg->id()).ism()-1][EBDetId(itdg->id()).ic()-1].second;
00206            if ((a==-1)&&(b==-1)){
00207              a=alphaEB_;
00208              b=betaEB_;
00209            }
00210          }else{
00211            a=alphaEB_;
00212            b=betaEB_;
00213          }
00214        }else{
00215          a=alphaEB_;
00216          b=betaEB_;
00217        }
00218      
00219        algoEB_.SetAlphaBeta(a,b);
00220 
00221        EcalUncalibratedRecHit aHit =  algoEB_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
00222        EBuncalibRechits->push_back( aHit );
00223        
00224        /*
00225          if(aHit.amplitude()>0. && !counterExceeded() ) {
00226          std::cout << "EcalFixedAlphaEBBetaFitUncalibRecHitProducer: processed EBDataFrame with id: "
00227          << itdg->id() << "\n"
00228          << "uncalib rechit amplitude: " << aHit.amplitude()
00229          << std::endl;
00230          }
00231        */
00232      }
00233    }
00234    evt.put( EBuncalibRechits, EBhitCollection_ );
00235 
00236    //loop over EE digis
00237    if( EEdigis ){
00238      for(EEDigiCollection::const_iterator itdg = EEdigis->begin(); itdg != EEdigis->end(); ++itdg) {
00239        //FIX ME load in a and b from a file
00240        algoEE_.SetAlphaBeta(alphaEE_,betaEE_);
00241 
00242        // find pedestals for this channel
00243        LogDebug("EcalUncalibRecHitDebug") << "looking up pedestal for crystal: " << EEDetId(itdg->id()) ;
00244        pedIter = pedMap.find(itdg->id());
00245        if( pedIter != pedMap.end() ) {
00246          aped = (*pedIter);
00247        } else {
00248          edm::LogError("EcalUncalibRecHitError") << "error!! could not find pedestals for channel: " << EEDetId(itdg->id()) 
00249                                                  << "\n  no uncalib rechit will be made for this digi!"
00250            ;
00251          continue;
00252        }
00253        double pedVec[3];
00254        pedVec[0]=aped.mean_x12;pedVec[1]=aped.mean_x6;pedVec[2]=aped.mean_x1;
00255        
00256        // find gain ratios
00257        LogDebug("EcalUncalibRecHitDebug") << "looking up gainRatios for crystal: " << EEDetId(itdg->id()) ;
00258        gainIter = gainMap.find(itdg->id());
00259        if( gainIter != gainMap.end() ) {
00260          aGain = (*gainIter);
00261        } else {
00262          edm::LogError("EcalUncalibRecHitError") << "error!! could not find gain ratios for channel: " << EEDetId(itdg->id())
00263                                                  << "\n  no uncalib rechit will be made for this digi!"
00264            ;
00265          continue;
00266        }
00267        double gainRatios[3];
00268        gainRatios[0]=1.;gainRatios[1]=aGain.gain12Over6();gainRatios[2]=aGain.gain6Over1()*aGain.gain12Over6();
00269 
00270        EcalUncalibratedRecHit aHit =  algoEE_.makeRecHit(*itdg, pedVec, gainRatios, 0 , 0);
00271        EEuncalibRechits->push_back( aHit );
00272        
00273        /*
00274          if(aHit.amplitude()>0. && !counterExceeded() ) {
00275          std::cout << "EcalFixedAlphaBetaFitUncalibRecHitProducer: processed EBDataFrame with id: "
00276          << itdg->id() << "\n"
00277          << "uncalib rechit amplitude: " << aHit.amplitude()
00278          << std::endl;
00279          }
00280        */
00281      }
00282    }
00283 
00284    // put the collection of reconstructed hits in the event
00285    evt.put( EEuncalibRechits, EEhitCollection_ );
00286 }

bool EcalFixedAlphaBetaFitUncalibRecHitProducer::setAlphaBeta (  )  [private]

Definition at line 74 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.cc.

References a, alphabetaFilename_, alphaBetaValues_, b, file, p, and size.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer().

00074                                                              {
00075   std::ifstream file(alphabetaFilename_.c_str());
00076   if (! file.is_open())
00077     return false;
00078 
00079   alphaBetaValues_.resize(36);
00080 
00081   char buffer[100];
00082   int sm, cry,ret;
00083   float a,b;
00084   std::pair<double,double> p(-1,-1);
00085 
00086   while( ! file.getline(buffer,100).eof() ){
00087     ret=sscanf(buffer,"%d %d %f %f", &sm, &cry, &a, &b);
00088     if ((ret!=4)||
00089         (sm<=0) ||(sm>36)||
00090         (cry<=0)||(cry>1700)){
00091       // send warning
00092       continue;
00093     }
00094 
00095     if (alphaBetaValues_[sm-1].size()==0){
00096       alphaBetaValues_[sm-1].resize(1700,p);
00097     }
00098     alphaBetaValues_[sm-1][cry-1].first = a;    
00099     alphaBetaValues_[sm-1][cry-1].second = b;
00100 
00101   }
00102 
00103   file.close();
00104   return true;
00105 }


Member Data Documentation

EcalUncalibRecHitFixedAlphaBetaAlgo<EBDataFrame> EcalFixedAlphaBetaFitUncalibRecHitProducer::algoEB_ [private]

Definition at line 33 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

EcalUncalibRecHitFixedAlphaBetaAlgo<EEDataFrame> EcalFixedAlphaBetaFitUncalibRecHitProducer::algoEE_ [private]

Definition at line 34 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

std::string EcalFixedAlphaBetaFitUncalibRecHitProducer::alphabetaFilename_ [private]

Definition at line 42 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and setAlphaBeta().

std::vector<std::vector<std::pair<double,double> > > EcalFixedAlphaBetaFitUncalibRecHitProducer::alphaBetaValues_ [private]

Definition at line 40 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by produce(), and setAlphaBeta().

double EcalFixedAlphaBetaFitUncalibRecHitProducer::alphaEB_ [private]

Definition at line 36 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

double EcalFixedAlphaBetaFitUncalibRecHitProducer::alphaEE_ [private]

Definition at line 38 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

double EcalFixedAlphaBetaFitUncalibRecHitProducer::AmplThrEB_ [private]

Definition at line 30 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

double EcalFixedAlphaBetaFitUncalibRecHitProducer::AmplThrEE_ [private]

Definition at line 31 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

double EcalFixedAlphaBetaFitUncalibRecHitProducer::betaEB_ [private]

Definition at line 37 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

double EcalFixedAlphaBetaFitUncalibRecHitProducer::betaEE_ [private]

Definition at line 39 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

edm::InputTag EcalFixedAlphaBetaFitUncalibRecHitProducer::EBdigiCollection_ [private]

Definition at line 25 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

std::string EcalFixedAlphaBetaFitUncalibRecHitProducer::EBhitCollection_ [private]

Definition at line 27 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

edm::InputTag EcalFixedAlphaBetaFitUncalibRecHitProducer::EEdigiCollection_ [private]

Definition at line 26 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

std::string EcalFixedAlphaBetaFitUncalibRecHitProducer::EEhitCollection_ [private]

Definition at line 28 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().

bool EcalFixedAlphaBetaFitUncalibRecHitProducer::useAlphaBetaArray_ [private]

Definition at line 41 of file EcalFixedAlphaBetaFitUncalibRecHitProducer.h.

Referenced by EcalFixedAlphaBetaFitUncalibRecHitProducer(), and produce().


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