CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStrip.h

Go to the documentation of this file.
00001 #ifndef ECAL_FENIXSTRIP_H
00002 #define ECAL_FENIXSTRIP_H
00003 
00004 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixLinearizer.h>
00005 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixAmplitudeFilter.h>
00006 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixPeakFinder.h>
00007 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixEtStrip.h>
00008 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixLinearizer.h>
00009 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixEtStrip.h>
00010 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStripFgvbEE.h>
00011 
00012 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
00013 #include <DataFormats/EcalDigi/interface/EBDataFrame.h>
00014 #include <DataFormats/EcalDigi/interface/EEDataFrame.h>
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
00018 
00019 class EBDataFrame;
00020 class EcalTriggerPrimitiveSample;
00021 class EcalTPGSlidingWindow;
00022 class EcalTPGFineGrainStripEE;
00023 class EcalFenixStripFgvbEE;
00024 class EcalFenixStripFormatEB;
00025 class EcalFenixStripFormatEE;
00026 class EcalTPGStripStatus;
00027 
00032 class EcalFenixStrip {
00033  public:
00034 
00035   // constructor, destructor
00036   EcalFenixStrip(const edm::EventSetup& setup, const EcalElectronicsMapping* theMapping,bool debug,bool famos,int maxNrSamples, int nbMaxXtals);
00037   virtual ~EcalFenixStrip() ;
00038 
00039  private:
00040  const EcalElectronicsMapping* theMapping_;
00041 
00042   bool debug_;
00043   bool famos_;
00044   int nbMaxXtals_;
00045     
00046   std::vector <EcalFenixLinearizer *> linearizer_; 
00047 
00048   EcalFenixAmplitudeFilter *amplitude_filter_; 
00049 
00050   EcalFenixPeakFinder *peak_finder_; 
00051     
00052   EcalFenixStripFormatEB *fenixFormatterEB_;   
00053     
00054   EcalFenixStripFormatEE *fenixFormatterEE_;
00055     
00056 
00057   EcalFenixEtStrip *adder_;
00058     
00059   EcalFenixStripFgvbEE *fgvbEE_;
00060 
00061   // data formats for each event
00062   std::vector<std::vector<int> > lin_out_;
00063   std::vector<int> add_out_;
00064   std::vector<int> filt_out_;
00065   std::vector<int> peak_out_;
00066   std::vector<int> format_out_;
00067   std::vector<int> fgvb_out_;
00068   std::vector<int> fgvb_out_temp_;
00069 
00070   const EcalTPGPedestals * ecaltpPed_;
00071   const EcalTPGLinearizationConst *ecaltpLin_;
00072   const EcalTPGWeightIdMap *ecaltpgWeightMap_;
00073   const EcalTPGWeightGroup *ecaltpgWeightGroup_;
00074   const EcalTPGSlidingWindow *ecaltpgSlidW_;
00075   const EcalTPGFineGrainStripEE *ecaltpgFgStripEE_;
00076   const EcalTPGCrystalStatus *ecaltpgBadX_;
00077   const EcalTPGStripStatus *ecaltpgStripStatus_;
00078 
00079  public:
00080 
00081   void setPointers(  const EcalTPGPedestals * ecaltpPed,
00082                      const EcalTPGLinearizationConst *ecaltpLin,
00083                      const EcalTPGWeightIdMap *ecaltpgWeightMap,
00084                      const EcalTPGWeightGroup *ecaltpgWeightGroup,
00085                      const EcalTPGSlidingWindow *ecaltpgSlidW,
00086                      const EcalTPGFineGrainStripEE *ecaltpgFgStripEE,
00087                      const EcalTPGCrystalStatus *ecaltpgBadX,
00088                      const EcalTPGStripStatus *ecaltpgStripStatus)
00089     {
00090       ecaltpPed_=ecaltpPed;
00091       ecaltpLin_=ecaltpLin;
00092       ecaltpgWeightMap_=ecaltpgWeightMap;
00093       ecaltpgWeightGroup_= ecaltpgWeightGroup;
00094       ecaltpgSlidW_=ecaltpgSlidW;
00095       ecaltpgFgStripEE_=ecaltpgFgStripEE;
00096       ecaltpgBadX_=ecaltpgBadX;
00097       ecaltpgStripStatus_=ecaltpgStripStatus;
00098     }
00099 
00100   // main methods
00101   // process method is splitted in 2 parts:
00102   //   the first one is templated, the same except input
00103   //   the second part is slightly different for barrel/endcap
00104   template <class T> 
00105   void process(const edm::EventSetup&, std::vector<const T> &, int nrxtals, std::vector<int> & out);
00106   void process_part2_barrel(uint32_t stripid,const EcalTPGSlidingWindow * ecaltpgSlidW,const EcalTPGFineGrainStripEE * ecaltpgFgStripEE);
00107 
00108   void process_part2_endcap(uint32_t stripid, const EcalTPGSlidingWindow * ecaltpgSlidW,const EcalTPGFineGrainStripEE * ecaltpgFgStripEE,const EcalTPGStripStatus * ecaltpgStripStatus);
00109 
00110 
00111   // getters for the algorithms  ;
00112 
00113   EcalFenixLinearizer *getLinearizer (int i) const { return linearizer_[i];}
00114   EcalFenixEtStrip *getAdder() const { return  adder_;}
00115   EcalFenixAmplitudeFilter *getFilter() const { return amplitude_filter_;}
00116   EcalFenixPeakFinder *getPeakFinder() const { return peak_finder_;}
00117     
00118   EcalFenixStripFormatEB *getFormatterEB() const { return fenixFormatterEB_;}
00119   EcalFenixStripFormatEE *getFormatterEE() const { return fenixFormatterEE_;}
00120     
00121   EcalFenixStripFgvbEE *getFGVB()      const { return fgvbEE_;}
00122 
00123   // ========================= implementations ==============================================================
00124   void process(const edm::EventSetup &setup, std::vector<EBDataFrame> &samples, int nrXtals,std::vector<int> &out){
00125 
00126     // now call processing
00127     if (samples.size()==0) {
00128       std::cout<<" Warning: 0 size vector found in EcalFenixStripProcess!!!!!"<<std::endl;
00129       return;
00130 
00131     }
00132     const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
00133     uint32_t stripid=elId.rawId() & 0xfffffff8;   //from Pascal
00134     process_part1(samples,nrXtals,stripid,ecaltpPed_,ecaltpLin_,ecaltpgWeightMap_,ecaltpgWeightGroup_,ecaltpgBadX_);//templated part
00135     process_part2_barrel(stripid,ecaltpgSlidW_,ecaltpgFgStripEE_);//part different for barrel/endcap
00136     out=format_out_;
00137   }
00138 
00139  void  process(const edm::EventSetup &setup, std::vector<EEDataFrame> &samples, int nrXtals, std::vector<int> & out){
00140 
00141 // now call processing
00142    if (samples.size()==0) {
00143      std::cout<<" Warning: 0 size vector found in EcalFenixStripProcess!!!!!"<<std::endl;
00144      return;
00145    }
00146    const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
00147    uint32_t stripid=elId.rawId() & 0xfffffff8;   //from Pascal
00148    process_part1(samples,nrXtals,stripid,ecaltpPed_,ecaltpLin_,ecaltpgWeightMap_,ecaltpgWeightGroup_,ecaltpgBadX_); //templated part
00149    process_part2_endcap(stripid,ecaltpgSlidW_,ecaltpgFgStripEE_,ecaltpgStripStatus_);
00150    out=format_out_; //FIXME: timing
00151    return;
00152  }
00153 
00154  template <class T> 
00155  void  process_part1(std::vector<T> & df,int nrXtals, uint32_t stripid, const EcalTPGPedestals * ecaltpPed, const
00156  EcalTPGLinearizationConst *ecaltpLin,const EcalTPGWeightIdMap * ecaltpgWeightMap,const EcalTPGWeightGroup * ecaltpgWeightGroup, const EcalTPGCrystalStatus * ecaltpBadX)
00157    {
00158   
00159       if(debug_)  std::cout<<"\n\nEcalFenixStrip input is a vector of size: "<<nrXtals<< std::endl;
00160 
00161       //loop over crystals
00162       for (int cryst=0;cryst<nrXtals;cryst++) {
00163         if(debug_){
00164           std::cout<<std::endl;
00165           std::cout <<"cryst= "<<cryst<<" EBDataFrame/EEDataFrame is: "<<std::endl; 
00166           for ( int i = 0; i<df[cryst].size();i++){
00167             std::cout <<" "<<std::dec<<df[cryst][i].adc();
00168           }
00169           std::cout<<std::endl;
00170         }
00171         // call linearizer
00172         this->getLinearizer(cryst)->setParameters(df[cryst].id().rawId(),ecaltpPed,ecaltpLin,ecaltpBadX) ; 
00173         this->getLinearizer(cryst)->process(df[cryst],lin_out_[cryst]);
00174       }
00175 
00176       if(debug_){
00177         std::cout<< "output of linearizer is a vector of size: "
00178               <<std::dec<<lin_out_.size()<<" of which used "<<nrXtals<<std::endl; 
00179         for (int ix=0;ix<nrXtals;ix++){
00180           std::cout<< "cryst: "<<ix<<"  value : "<<std::dec<<std::endl;
00181           std::cout<<" lin_out[ix].size()= "<<std::dec<<lin_out_[ix].size()<<std::endl;
00182           for (unsigned int i =0; i<lin_out_[ix].size();i++){
00183             std::cout <<" "<<std::dec<<(lin_out_[ix])[i];
00184           }
00185           std::cout<<std::endl;
00186         }
00187     
00188         std::cout<<std::endl;
00189       }
00190  
00191       // Now call the sFGVB - this is common between EB and EE!
00192       getFGVB()->setParameters(stripid,ecaltpgFgStripEE_);
00193       getFGVB()->process(lin_out_,fgvb_out_temp_);
00194 
00195       if(debug_)
00196       {
00197         std::cout << "output of strip fgvb is a vector of size: " <<std::dec<<fgvb_out_temp_.size()<<std::endl;
00198         for (unsigned int i =0; i<fgvb_out_temp_.size();i++){
00199           std::cout << " " << std::dec << (fgvb_out_temp_[i]);
00200         }
00201         std::cout<<std::endl;
00202       }
00203  
00204       // call adder
00205       this->getAdder()->process(lin_out_,nrXtals,add_out_);  //add_out is of size SIZEMAX=maxNrSamples
00206  
00207       if(debug_){
00208         std::cout<< "output of adder is a vector of size: "<<std::dec<<add_out_.size()<<std::endl; 
00209         for (unsigned int ix=0;ix<add_out_.size();ix++){
00210           std::cout<< "cryst: "<<ix<<"  value : "<<std::dec<<add_out_[ix]<<std::endl;
00211         }
00212         std::cout<<std::endl;
00213       }
00214  
00215 
00216       if (famos_) {
00217         filt_out_[0]= add_out_[0];
00218         peak_out_[0]= add_out_[0];
00219         return;
00220       }else {
00221         // call amplitudefilter
00222         this->getFilter()->setParameters(stripid,ecaltpgWeightMap,ecaltpgWeightGroup); 
00223         this->getFilter()->process(add_out_,filt_out_,fgvb_out_temp_,fgvb_out_); 
00224 
00225         if(debug_){
00226           std::cout<< "output of filter is a vector of size: "<<std::dec<<filt_out_.size()<<std::endl; 
00227           for (unsigned int ix=0;ix<filt_out_.size();ix++){
00228             std::cout<< "cryst: "<<ix<<"  value : "<<std::dec<<filt_out_[ix]<<std::endl;
00229           }
00230           std::cout<<std::endl;
00231 
00232           std::cout<< "output of sfgvb after filter is a vector of size: "<<std::dec<<fgvb_out_.size()<<std::endl;
00233           for (unsigned int ix=0;ix<fgvb_out_.size();ix++){
00234             std::cout<< "cryst: "<<ix<<"  value : "<<std::dec<<fgvb_out_[ix]<<std::endl;
00235           }
00236           std::cout<<std::endl;
00237         }
00238 
00239         // call peakfinder
00240         this->getPeakFinder()->process(filt_out_,peak_out_);
00241         if(debug_){
00242           std::cout<< "output of peakfinder is a vector of size: "<<peak_out_.size()<<std::endl; 
00243           for (unsigned int ix=0;ix<peak_out_.size();ix++){
00244             std::cout<< "cryst: "<<ix<<"  value : "<<peak_out_[ix]<<std::endl;
00245           }
00246           std::cout<<std::endl;
00247         }
00248         return;
00249       }
00250    }
00251 
00252 };
00253 #endif
00254