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