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
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
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
00075 public:
00076
00077 void setPointers( const EcalTPGPedestals * ecaltpPed,
00078 const EcalTPGLinearizationConst *ecaltpLin,
00079 const EcalTPGWeightIdMap *ecaltpgWeightMap,
00080 const EcalTPGWeightGroup *ecaltpgWeightGroup,
00081 const EcalTPGSlidingWindow *ecaltpgSlidW,
00082 const EcalTPGFineGrainStripEE *ecaltpgFgStripEE)
00083 {
00084 ecaltpPed_=ecaltpPed;
00085 ecaltpLin_=ecaltpLin;
00086 ecaltpgWeightMap_=ecaltpgWeightMap;
00087 ecaltpgWeightGroup_= ecaltpgWeightGroup;
00088 ecaltpgSlidW_=ecaltpgSlidW;
00089 ecaltpgFgStripEE_=ecaltpgFgStripEE;
00090 }
00091
00092
00093
00094
00095
00096 template <class T>
00097 void process(const edm::EventSetup&, std::vector<const T> &, int nrxtals, std::vector<int> & out);
00098 void process_part2_barrel(uint32_t stripid,const EcalTPGSlidingWindow * ecaltpgSlidW);
00099
00100 void process_part2_endcap(uint32_t stripid, const EcalTPGSlidingWindow * ecaltpgSlidW,const EcalTPGFineGrainStripEE * ecaltpgFgStripEE);
00101
00102
00103
00104
00105 EcalFenixLinearizer *getLinearizer (int i) const { return linearizer_[i];}
00106 EcalFenixEtStrip *getAdder() const { return adder_;}
00107 EcalFenixAmplitudeFilter *getFilter() const { return amplitude_filter_;}
00108 EcalFenixPeakFinder *getPeakFinder() const { return peak_finder_;}
00109
00110 EcalFenixStripFormatEB *getFormatterEB() const { return fenixFormatterEB_;}
00111 EcalFenixStripFormatEE *getFormatterEE() const { return fenixFormatterEE_;}
00112
00113 EcalFenixStripFgvbEE *getFGVB() const { return fgvbEE_;}
00114
00115
00116 void process(const edm::EventSetup &setup, std::vector<EBDataFrame> &samples, int nrXtals,std::vector<int> &out){
00117
00118
00119 if (samples.size()==0) {
00120 std::cout<<" Warning: 0 size vector found in EcalFenixStripProcess!!!!!"<<std::endl;
00121 return;
00122
00123 }
00124 const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
00125 uint32_t stripid=elId.rawId() & 0xfffffff8;
00126 process_part1(samples,nrXtals,stripid,ecaltpPed_,ecaltpLin_,ecaltpgWeightMap_,ecaltpgWeightGroup_);
00127 process_part2_barrel(stripid,ecaltpgSlidW_);
00128 out=format_out_;
00129 }
00130
00131 void process(const edm::EventSetup &setup, std::vector<EEDataFrame> &samples, int nrXtals, std::vector<int> & out){
00132
00133
00134 if (samples.size()==0) {
00135 std::cout<<" Warning: 0 size vector found in EcalFenixStripProcess!!!!!"<<std::endl;
00136 return;
00137 }
00138 const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
00139 uint32_t stripid=elId.rawId() & 0xfffffff8;
00140 process_part1(samples,nrXtals,stripid,ecaltpPed_,ecaltpLin_,ecaltpgWeightMap_,ecaltpgWeightGroup_);
00141 process_part2_endcap(stripid,ecaltpgSlidW_,ecaltpgFgStripEE_);
00142 out=format_out_;
00143 return;
00144 }
00145
00146 template <class T>
00147 void process_part1(std::vector<T> & df,int nrXtals, uint32_t stripid, const EcalTPGPedestals * ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin,const EcalTPGWeightIdMap * ecaltpgWeightMap,const EcalTPGWeightGroup * ecaltpgWeightGroup)
00148 {
00149
00150 if(debug_) std::cout<<"\n\nEcalFenixStrip input is a vector of size: "<<nrXtals<< std::endl;
00151
00152
00153 for (int cryst=0;cryst<nrXtals;cryst++) {
00154 if(debug_){
00155 std::cout<<std::endl;
00156 std::cout <<"cryst= "<<cryst<<" EBDataFrame/EEDataFrame is: "<<std::endl;
00157 for ( int i = 0; i<df[cryst].size();i++){
00158 std::cout <<" "<<std::dec<<df[cryst][i].adc();
00159 }
00160 std::cout<<std::endl;
00161 }
00162
00163 this->getLinearizer(cryst)->setParameters(df[cryst].id().rawId(),ecaltpPed,ecaltpLin) ;
00164 this->getLinearizer(cryst)->process(df[cryst],lin_out_[cryst]);
00165 }
00166
00167 if(debug_){
00168 std::cout<< "output of linearizer is a vector of size: "
00169 <<std::dec<<lin_out_.size()<<" of which used "<<nrXtals<<std::endl;
00170 for (int ix=0;ix<nrXtals;ix++){
00171 std::cout<< "cryst: "<<ix<<" value : "<<std::dec<<std::endl;
00172 std::cout<<" lin_out[ix].size()= "<<std::dec<<lin_out_[ix].size()<<std::endl;
00173 for (unsigned int i =0; i<lin_out_[ix].size();i++){
00174 std::cout <<" "<<std::dec<<(lin_out_[ix])[i];
00175 }
00176 std::cout<<std::endl;
00177 }
00178
00179 std::cout<<std::endl;
00180 }
00181
00182
00183 this->getAdder()->process(lin_out_,nrXtals,add_out_);
00184
00185 if(debug_){
00186 std::cout<< "output of adder is a vector of size: "<<std::dec<<add_out_.size()<<std::endl;
00187 for (unsigned int ix=0;ix<add_out_.size();ix++){
00188 std::cout<< "cryst: "<<ix<<" value : "<<std::dec<<add_out_[ix]<<std::endl;
00189 }
00190 std::cout<<std::endl;
00191 }
00192
00193
00194 if (famos_) {
00195 filt_out_[0]= add_out_[0];
00196 peak_out_[0]= add_out_[0];
00197 return;
00198 }else {
00199
00200 this->getFilter()->setParameters(stripid,ecaltpgWeightMap,ecaltpgWeightGroup);
00201 this->getFilter()->process(add_out_,filt_out_);
00202
00203 if(debug_){
00204 std::cout<< "output of filter is a vector of size: "<<std::dec<<filt_out_.size()<<std::endl;
00205 for (unsigned int ix=0;ix<filt_out_.size();ix++){
00206 std::cout<< "cryst: "<<ix<<" value : "<<std::dec<<filt_out_[ix]<<std::endl;
00207 }
00208 std::cout<<std::endl;
00209 }
00210
00211
00212 this->getPeakFinder()->process(filt_out_,peak_out_);
00213 if(debug_){
00214 std::cout<< "output of peakfinder is a vector of size: "<<peak_out_.size()<<std::endl;
00215 for (unsigned int ix=0;ix<peak_out_.size();ix++){
00216 std::cout<< "cryst: "<<ix<<" value : "<<peak_out_[ix]<<std::endl;
00217 }
00218 std::cout<<std::endl;
00219 }
00220 return;
00221 }
00222 }
00223
00224 };
00225 #endif
00226