CMS 3D CMS Logo

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