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
00024
00025 bypasslin_out_.resize(nbMaxStrips_);
00026 std::vector<int> vec(maxNrSamples,0);
00027 for (int i=0;i<nbMaxStrips_;i++) bypasslin_out_[i]=vec;
00028 adder_out_.resize(maxNrSamples);
00029 maxOf2_out_.resize(maxNrSamples);
00030 fgvb_out_.resize(maxNrSamples);
00031
00032 }
00033
00034 EcalFenixTcp::~EcalFenixTcp() {
00035 for (int i=0;i<nbMaxStrips_;i++) delete bypasslin_[i];
00036 delete adder_;
00037 delete maxOf2_;
00038 delete formatter_;
00039 delete fgvbEB_;
00040 delete fgvbEE_;
00041 }
00042
00043
00044 void EcalFenixTcp::process(const edm::EventSetup& setup,
00045 std::vector <EBDataFrame> &bid,
00046 std::vector<std::vector<int> > & tpframetow, int nStr,
00047 std::vector< EcalTriggerPrimitiveSample> & tptow,
00048 std::vector< EcalTriggerPrimitiveSample> & tptow2,
00049 bool isInInnerRing, EcalTrigTowerDetId towid)
00050 {
00051
00052 int bitMask=12;
00053 process_part1(tpframetow,nStr,bitMask);
00054
00055
00056 process_part2_barrel(tpframetow,nStr,ecaltpgFgEBGroup_,ecaltpgLutGroup_,ecaltpgLut_,ecaltpgFineGrainEB_,ecaltpgBadTT_,tptow,tptow2,towid);
00057 }
00058
00059
00060 void EcalFenixTcp::process(const edm::EventSetup& setup,
00061 std::vector <EEDataFrame> &bid,
00062 std::vector<std::vector<int> > & tpframetow, int nStr,
00063 std::vector< EcalTriggerPrimitiveSample> & tptow,
00064 std::vector< EcalTriggerPrimitiveSample> & tptow2,
00065 bool isInInnerRing, EcalTrigTowerDetId towid)
00066 {
00067 int bitMask=12;
00068 process_part1(tpframetow,nStr,bitMask);
00069
00070 process_part2_endcap(tpframetow,nStr,bitMask,ecaltpgLutGroup_,ecaltpgLut_,ecaltpgFineGrainTowerEE_,ecaltpgBadTT_,tptow,tptow2,isInInnerRing, towid);
00071 }
00072
00073 void EcalFenixTcp::process_part1(std::vector<std::vector<int> > &tpframetow, int nStr, int bitMask)
00074 {
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 this->getAdder()->process(tpframetow, nStr, bitMask,adder_out_);
00094
00095 if (debug_) {
00096 std::cout<< "output of adder is a vector of size: "<<adder_out_.size()<<std::endl;
00097 std::cout<< "value : "<<std::endl;
00098 for (unsigned int i =0; i<adder_out_.size();i++){
00099 std::cout <<" "<<adder_out_[i];
00100 }
00101 std::cout<<std::endl;
00102 }
00103
00104 return;
00105
00106 }
00107
00108 void EcalFenixTcp::process_part2_barrel(std::vector<std::vector<int> > & bypasslinout, int nStr,
00109 const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup,
00110 const EcalTPGLutGroup *ecaltpgLutGroup,
00111 const EcalTPGLutIdMap *ecaltpgLut,
00112 const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB,
00113 const EcalTPGTowerStatus *ecaltpgBadTT,
00114 std::vector< EcalTriggerPrimitiveSample> & tcp_out,
00115 std::vector< EcalTriggerPrimitiveSample> & tcp_outTcc,
00116 EcalTrigTowerDetId towid)
00117 {
00118
00119
00120 this->getMaxOf2()->process(bypasslinout,nStr,maxOf2_out_);
00121
00122 if (debug_) {
00123 std::cout<< "output of maxof2 is a vector of size: "<<maxOf2_out_.size()<<std::endl;
00124 std::cout<< "value : "<<std::endl;
00125 for (unsigned int i =0; i<maxOf2_out_.size();i++){
00126 std::cout <<" "<<std::dec<<maxOf2_out_[i];
00127 }
00128 std::cout<<std::endl;
00129 }
00130
00131
00132
00133 this->getFGVBEB()->setParameters(towid.rawId(),ecaltpgFgEBGroup,ecaltpgFineGrainEB);
00134 this->getFGVBEB()->process(adder_out_,maxOf2_out_,fgvb_out_);
00135
00136 if (debug_) {
00137 std::cout<< "output of fgvb is a vector of size: "<<fgvb_out_.size()<<std::endl;
00138 std::cout<< "value : "<<std::endl;
00139 for (unsigned int i =0; i<fgvb_out_.size();i++){
00140 std::cout <<" "<<std::dec<<fgvb_out_[i];
00141 }
00142 std::cout<<std::endl;
00143 }
00144
00145
00146 int eTTotShift=2;
00147
00148 this->getFormatter()->setParameters(towid.rawId(),ecaltpgLutGroup,ecaltpgLut,ecaltpgBadTT);
00149 this->getFormatter()->process(adder_out_,fgvb_out_,eTTotShift,tcp_out,tcp_outTcc,false);
00150
00151 if (debug_) {
00152 std::cout<< "output of TCP formatter Barrel is a vector of size: "<<std::dec<<tcp_out.size()<<std::endl;
00153 std::cout<< "value : "<<std::endl;
00154 for (unsigned int i =0; i<tcp_out.size();i++){
00155 std::cout <<" "<<i<<" "<<std::dec<<tcp_out[i];
00156 }
00157 std::cout<<std::endl;
00158 }
00159
00160 return;
00161 }
00162
00163 void EcalFenixTcp::process_part2_endcap(std::vector<std::vector<int> > & bypasslinout, int nStr, int bitMask,
00164 const EcalTPGLutGroup *ecaltpgLutGroup,
00165 const EcalTPGLutIdMap *ecaltpgLut,
00166 const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE,
00167 const EcalTPGTowerStatus *ecaltpgbadTT,
00168 std::vector< EcalTriggerPrimitiveSample> & tcp_out,
00169 std::vector< EcalTriggerPrimitiveSample> & tcp_outTcc,bool isInInnerRings,
00170 EcalTrigTowerDetId towid)
00171
00172 {
00173
00174 this->getFGVBEE()->setParameters(towid.rawId(),ecaltpgFineGrainTowerEE);
00175
00176 fgvbEE_->process(bypasslinout,nStr,bitMask,fgvb_out_);
00177
00178
00179 int eTTotShift=2;
00180
00181 this->getFormatter()->setParameters(towid.rawId(),ecaltpgLutGroup,ecaltpgLut,ecaltpgbadTT);
00182
00183 this->getFormatter()->process(adder_out_,fgvb_out_,eTTotShift,tcp_out,tcp_outTcc,isInInnerRings);
00184
00185 if (debug_) {
00186 std::cout<< "output of TCP formatter(endcap) is a vector of size: "<<std::dec<<tcp_out.size()<<std::endl;
00187 std::cout<< "value : "<<std::endl;
00188 for (unsigned int i =0; i<tcp_out.size();i++){
00189 std::cout <<" "<<i<<" "<<std::dec<<tcp_out[i]<<std::endl;
00190 }
00191 std::cout<<std::endl;
00192 }
00193 return;
00194 }