CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixTcp.cc

Go to the documentation of this file.
00001 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcp.h>
00002 #include <SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcpFormat.h>
00003 
00004 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBGroup.h"
00005 #include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h"
00006 #include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h"
00007 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBIdMap.h"
00008 #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainTowerEE.h"
00009 
00010 #include "FWCore/Framework/interface/ESHandle.h"
00011 
00012 #include <vector>
00013 //----------------------------------------------------------------------------------------
00014 EcalFenixTcp::EcalFenixTcp(const edm::EventSetup& setup,bool tcpFormat, bool debug,bool famos, int binOfMax, int maxNrSamples, int nbMaxStrips): debug_(debug),nbMaxStrips_(nbMaxStrips)
00015  { 
00016     bypasslin_.resize(nbMaxStrips_);
00017     for (int i=0;i<nbMaxStrips_;i++) bypasslin_[i] = new EcalFenixBypassLin();
00018     adder_= new EcalFenixEtTot();
00019     maxOf2_=new EcalFenixMaxof2(maxNrSamples,nbMaxStrips_);
00020     formatter_= new EcalFenixTcpFormat(tcpFormat, debug_, famos, binOfMax);
00021     fgvbEB_= new EcalFenixFgvbEB(maxNrSamples);
00022     fgvbEE_= new EcalFenixTcpFgvbEE(maxNrSamples);
00023     sfgvbEB_ = new EcalFenixTcpsFgvbEB();
00024 
00025     // permanent data structures
00026     bypasslin_out_.resize(nbMaxStrips_);
00027     std::vector<int> vec(maxNrSamples,0);
00028     for (int i=0;i<nbMaxStrips_;i++) bypasslin_out_[i]=vec;
00029     adder_out_.resize(maxNrSamples);
00030     maxOf2_out_.resize(maxNrSamples);
00031     fgvb_out_.resize(maxNrSamples);
00032     strip_fgvb_out_.resize(maxNrSamples);
00033 
00034   }
00035 //-----------------------------------------------------------------------------------------  
00036   EcalFenixTcp::~EcalFenixTcp() {
00037     for (int i=0;i<nbMaxStrips_;i++) delete bypasslin_[i];
00038     delete adder_; 
00039     delete maxOf2_;
00040     delete formatter_;
00041     delete fgvbEB_;
00042     delete fgvbEE_;
00043   }
00044 //-----------------------------------------------------------------------------------------  
00045 
00046 void EcalFenixTcp::process(const edm::EventSetup& setup,
00047                            std::vector <EBDataFrame> &bid,             //dummy argument for template call 
00048                            std::vector<std::vector<int> > & tpframetow, int nStr,
00049                            std::vector< EcalTriggerPrimitiveSample> & tptow,
00050                            std::vector< EcalTriggerPrimitiveSample> & tptow2,
00051                            bool isInInnerRing, EcalTrigTowerDetId towid) 
00052 {
00053 
00054   int bitMask=12; 
00055   process_part1(tpframetow,nStr,bitMask);
00056 
00057  
00058 process_part2_barrel(tpframetow,nStr,bitMask,ecaltpgFgEBGroup_,ecaltpgLutGroup_,ecaltpgLut_,ecaltpgFineGrainEB_,ecaltpgBadTT_,ecaltpgSpike_,tptow,tptow2,towid);
00059 }
00060  
00061 //-----------------------------------------------------------------------------------------  
00062 void EcalFenixTcp::process(const edm::EventSetup& setup,
00063                            std::vector <EEDataFrame> &bid,  //dummy argument for template call 
00064                            std::vector<std::vector<int> > & tpframetow, int nStr,
00065                            std::vector< EcalTriggerPrimitiveSample> & tptow,
00066                            std::vector< EcalTriggerPrimitiveSample> & tptow2,
00067                            bool isInInnerRing, EcalTrigTowerDetId towid) 
00068 {
00069   int bitMask=12; // Pascal: endcap has 12 bits as in EB (bug in FENIX!!!!) {was 10 before]
00070   process_part1(tpframetow,nStr,bitMask);
00071  
00072   process_part2_endcap(tpframetow,nStr,bitMask,ecaltpgLutGroup_,ecaltpgLut_,ecaltpgFineGrainTowerEE_,ecaltpgBadTT_,tptow,tptow2,isInInnerRing, towid);
00073 }
00074 //----------------------------------------------------------------------------------------- 
00075 void EcalFenixTcp::process_part1(std::vector<std::vector<int> > &tpframetow, int nStr, int bitMask)
00076 {
00077 //  //call bypasslin
00078 //     for (int istrip=0;istrip<nStr;istrip ++){
00079 //       this->getBypasslin(istrip)->process(tpframetow[istrip],bypasslin_out_[istrip]);
00080 //     }
00081 //     //this is a test
00082 //     if (debug_) {
00083 //       std::cout<<"bypasslinout = "<<std::endl;
00084 //       for (int istrip=0;istrip<nStr;istrip ++){
00085 //      std::vector<int> stripin= bypasslin_out_[istrip];
00086 //      for (unsigned int is=0;is<stripin.size();is++){
00087 //        std::cout<<stripin[is]<<" ";
00088 //      }
00089 //      std::cout<<std::endl;
00090 //       }
00091 //     }
00092 
00093 //     //call adder
00094 //     this->getAdder()->process(bypasslin_out_, nStr, bitMask,adder_out_);
00095      this->getAdder()->process(tpframetow, nStr, bitMask,adder_out_);
00096     //this is a test:
00097     if (debug_) {
00098       std::cout<< "output of adder is a vector of size: "<<adder_out_.size()<<std::endl; 
00099       std::cout<< "value : "<<std::endl;
00100       for (unsigned int i =0; i<adder_out_.size();i++){
00101         std::cout <<" "<<adder_out_[i];
00102       }    
00103       std::cout<<std::endl;
00104     }
00105     //    return adder_out;
00106     return;
00107     
00108 }
00109 //-----------------------------------------------------------------------------------------
00110 void EcalFenixTcp::process_part2_barrel(std::vector<std::vector<int> > & bypasslinout,
00111                                         int nStr, int bitMask,
00112                                         const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup,
00113                                         const EcalTPGLutGroup *ecaltpgLutGroup,
00114                                         const EcalTPGLutIdMap *ecaltpgLut,
00115                                         const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB,
00116                                         const EcalTPGTowerStatus *ecaltpgBadTT,
00117                                         const EcalTPGSpike * ecaltpgSpike,
00118                                         std::vector< EcalTriggerPrimitiveSample> & tcp_out,
00119                                         std::vector< EcalTriggerPrimitiveSample> & tcp_outTcc,
00120                                         EcalTrigTowerDetId towid)
00121 {
00122   //call maxof2
00123   //  this->getMaxOf2()->process(bypasslin_out_,nStr,maxOf2_out_);
00124   this->getMaxOf2()->process(bypasslinout,nStr,bitMask,maxOf2_out_);
00125   // this is a test:
00126   if (debug_) {
00127     std::cout<< "output of maxof2 is a vector of size: "<<maxOf2_out_.size()<<std::endl; 
00128     std::cout<< "value : "<<std::endl;
00129     for (unsigned int i =0; i<maxOf2_out_.size();i++){
00130       std::cout <<" "<<std::dec<<maxOf2_out_[i];
00131     }    
00132     std::cout<<std::endl;
00133   }
00134    
00135   //call fgvb
00136 
00137   this->getFGVBEB()->setParameters(towid.rawId(),ecaltpgFgEBGroup,ecaltpgFineGrainEB);
00138   this->getFGVBEB()->process(adder_out_,maxOf2_out_,fgvb_out_);
00139 
00140   // Call sFGVB
00141   this->getsFGVBEB()->process(bypasslinout,nStr,bitMask,strip_fgvb_out_);
00142 
00143   //this is a test:
00144   if (debug_) {
00145     std::cout<< "output of fgvb is a vector of size: "<<fgvb_out_.size()<<std::endl; 
00146     std::cout<< "value : "<<std::endl;
00147     for (unsigned int i =0; i<fgvb_out_.size();i++){
00148       std::cout <<" "<<std::dec<<fgvb_out_[i];
00149     }    
00150     std::cout<<std::endl;
00151   }
00152 
00153   // call formatter
00154   int eTTotShift=2;
00155  
00156   this->getFormatter()->setParameters(towid.rawId(),ecaltpgLutGroup,ecaltpgLut,ecaltpgBadTT,ecaltpgSpike);
00157   this->getFormatter()->process(adder_out_,fgvb_out_,strip_fgvb_out_,eTTotShift,tcp_out,tcp_outTcc,false);
00158   //this is a test:
00159   if (debug_) {
00160     std::cout<< "output of TCP formatter Barrel is a vector of size: "<<std::dec<<tcp_out.size()<<std::endl; 
00161     std::cout<< "value : "<<std::endl;
00162     for (unsigned int i =0; i<tcp_out.size();i++){
00163       std::cout <<" "<<i<<" "<<std::dec<<tcp_out[i];
00164     }    
00165     std::cout<<std::endl;
00166   }
00167     
00168   return;
00169 }
00170 //-----------------------------------------------------------------------------------------
00171 void EcalFenixTcp::process_part2_endcap(std::vector<std::vector<int> > & bypasslinout, int nStr, int bitMask,
00172                                         const EcalTPGLutGroup *ecaltpgLutGroup,
00173                                         const EcalTPGLutIdMap *ecaltpgLut,
00174                                         const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE,
00175                                         const EcalTPGTowerStatus *ecaltpgbadTT,
00176                                         std::vector< EcalTriggerPrimitiveSample> & tcp_out,
00177                                         std::vector< EcalTriggerPrimitiveSample> & tcp_outTcc,bool isInInnerRings,                                      
00178                                         EcalTrigTowerDetId towid)
00179 
00180 {
00181   // Zero EB strip records
00182   for(unsigned int i = 0; i < strip_fgvb_out_.size(); ++i)
00183   {
00184     strip_fgvb_out_[i] = 0;
00185   }
00186 
00187   //call fgvb
00188   this->getFGVBEE()->setParameters(towid.rawId(),ecaltpgFineGrainTowerEE);
00189   //  fgvbEE_->process(bypasslin_out_,nStr,bitMask,fgvb_out_);
00190   fgvbEE_->process(bypasslinout,nStr,bitMask,fgvb_out_);
00191 
00192   //call formatter
00193   int eTTotShift=2; // Pascal: endcap has 12 bits as in EB (bug in FENIX!!!!) so shift must be applied to just keep [11:2]
00194 
00195   this->getFormatter()->setParameters(towid.rawId(),ecaltpgLutGroup,ecaltpgLut,ecaltpgbadTT,0);
00196 
00197   this->getFormatter()->process(adder_out_,fgvb_out_,strip_fgvb_out_,eTTotShift,tcp_out,tcp_outTcc,isInInnerRings);
00198   //this is a test:
00199   if (debug_) {
00200     std::cout<< "output of TCP formatter(endcap) is a vector of size: "<<std::dec<<tcp_out.size()<<std::endl; 
00201     std::cout<< "value : "<<std::endl;
00202     for (unsigned int i =0; i<tcp_out.size();i++){
00203       std::cout <<" "<<i<<" "<<std::dec<<tcp_out[i]<<std::endl;
00204     }    
00205     std::cout<<std::endl;
00206   }
00207   return;
00208 }