CMS 3D CMS Logo

EcalFenixStrip.h
Go to the documentation of this file.
1 #ifndef ECAL_FENIXSTRIP_H
2 #define ECAL_FENIXSTRIP_H
3 
11 
18 
19 class EBDataFrame;
26 class EcalTPGStripStatus;
27 
33  public:
34 
35  // constructor, destructor
36  EcalFenixStrip(const edm::EventSetup& setup, const EcalElectronicsMapping* theMapping,bool debug,bool famos,int maxNrSamples, int nbMaxXtals);
37  virtual ~EcalFenixStrip() ;
38 
39  private:
41 
42  bool debug_;
43  bool famos_;
45 
46  std::vector <EcalFenixLinearizer *> linearizer_;
47 
49 
51 
53 
55 
56 
58 
60 
61  // data formats for each event
62  std::vector<std::vector<int> > lin_out_;
63  std::vector<int> add_out_;
64  std::vector<int> filt_out_;
65  std::vector<int> peak_out_;
66  std::vector<int> format_out_;
67  std::vector<int> fgvb_out_;
68  std::vector<int> fgvb_out_temp_;
69 
78 
79  bool identif_;
80 
81  public:
82 
83  void setPointers( const EcalTPGPedestals * ecaltpPed,
84  const EcalTPGLinearizationConst *ecaltpLin,
85  const EcalTPGWeightIdMap *ecaltpgWeightMap,
86  const EcalTPGWeightGroup *ecaltpgWeightGroup,
87  const EcalTPGSlidingWindow *ecaltpgSlidW,
88  const EcalTPGFineGrainStripEE *ecaltpgFgStripEE,
89  const EcalTPGCrystalStatus *ecaltpgBadX,
90  const EcalTPGStripStatus *ecaltpgStripStatus)
91  {
92  ecaltpPed_=ecaltpPed;
93  ecaltpLin_=ecaltpLin;
94  ecaltpgWeightMap_=ecaltpgWeightMap;
95  ecaltpgWeightGroup_= ecaltpgWeightGroup;
96  ecaltpgSlidW_=ecaltpgSlidW;
97  ecaltpgFgStripEE_=ecaltpgFgStripEE;
98  ecaltpgBadX_=ecaltpgBadX;
99  ecaltpgStripStatus_=ecaltpgStripStatus;
100  }
101 
102  // main methods
103  // process method is splitted in 2 parts:
104  // the first one is templated, the same except input
105  // the second part is slightly different for barrel/endcap
106  template <class T>
107  void process(const edm::EventSetup&, std::vector<const T> &, int nrxtals, std::vector<int> & out);
108  void process_part2_barrel(uint32_t stripid,const EcalTPGSlidingWindow * ecaltpgSlidW,const EcalTPGFineGrainStripEE * ecaltpgFgStripEE);
109 
110  void process_part2_endcap(uint32_t stripid, const EcalTPGSlidingWindow * ecaltpgSlidW,const EcalTPGFineGrainStripEE * ecaltpgFgStripEE,const EcalTPGStripStatus * ecaltpgStripStatus);
111 
112 
113  // getters for the algorithms ;
114 
115  EcalFenixLinearizer *getLinearizer (int i) const { return linearizer_[i];}
116  EcalFenixEtStrip *getAdder() const { return adder_;}
119 
122 
124 
125  void setbadStripMissing(bool flag) { identif_ = flag; }
126  bool getbadStripMissing() const {return identif_;}
127 
128  // ========================= implementations ==============================================================
129  void process(const edm::EventSetup &setup, std::vector<EBDataFrame> &samples, int nrXtals,std::vector<int> &out){
130 
131  // now call processing
132  if (samples.empty()) {
133  std::cout<<" Warning: 0 size vector found in EcalFenixStripProcess!!!!!"<<std::endl;
134  return;
135 
136  }
137  const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
138  uint32_t stripid=elId.rawId() & 0xfffffff8; //from Pascal
139 
140  identif_ = getFGVB()->getMissedStripFlag();
141 
142  process_part1(identif_,samples,nrXtals,stripid,ecaltpPed_,ecaltpLin_,ecaltpgWeightMap_,ecaltpgWeightGroup_,ecaltpgBadX_);//templated part
143  process_part2_barrel(stripid,ecaltpgSlidW_,ecaltpgFgStripEE_);//part different for barrel/endcap
144  out=format_out_;
145  }
146 
147  void process(const edm::EventSetup &setup, std::vector<EEDataFrame> &samples, int nrXtals, std::vector<int> & out){
148 
149 // now call processing
150  if (samples.empty()) {
151  std::cout<<" Warning: 0 size vector found in EcalFenixStripProcess!!!!!"<<std::endl;
152  return;
153  }
154  const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
155  uint32_t stripid=elId.rawId() & 0xfffffff8; //from Pascal
156 
157  identif_ = getFGVB()->getMissedStripFlag();
158 
159  process_part1(identif_,samples,nrXtals,stripid,ecaltpPed_,ecaltpLin_,ecaltpgWeightMap_,ecaltpgWeightGroup_,ecaltpgBadX_); //templated part
160  process_part2_endcap(stripid,ecaltpgSlidW_,ecaltpgFgStripEE_,ecaltpgStripStatus_);
161  out=format_out_; //FIXME: timing
162  return;
163  }
164 
165  template <class T>
166  void process_part1(int identif, std::vector<T> & df,int nrXtals, uint32_t stripid, const EcalTPGPedestals * ecaltpPed, const
167  EcalTPGLinearizationConst *ecaltpLin,const EcalTPGWeightIdMap * ecaltpgWeightMap,const EcalTPGWeightGroup * ecaltpgWeightGroup, const EcalTPGCrystalStatus * ecaltpBadX)
168  {
169 
170  if(debug_) std::cout<<"\n\nEcalFenixStrip input is a vector of size: "<<nrXtals<< std::endl;
171 
172  //loop over crystals
173  for (int cryst=0;cryst<nrXtals;cryst++) {
174  if(debug_){
175  std::cout<<std::endl;
176  std::cout <<"cryst= "<<cryst<<" EBDataFrame/EEDataFrame is: "<<std::endl;
177  for ( int i = 0; i<df[cryst].size();i++){
178  std::cout <<" "<<std::dec<<df[cryst][i].adc();
179  }
180  std::cout<<std::endl;
181  }
182  // call linearizer
183  this->getLinearizer(cryst)->setParameters(df[cryst].id().rawId(),ecaltpPed,ecaltpLin,ecaltpBadX) ;
184  this->getLinearizer(cryst)->process(df[cryst],lin_out_[cryst]);
185  }
186 
187  if(debug_){
188  std::cout<< "output of linearizer is a vector of size: "
189  <<std::dec<<lin_out_.size()<<" of which used "<<nrXtals<<std::endl;
190  for (int ix=0;ix<nrXtals;ix++){
191  std::cout<< "cryst: "<<ix<<" value : "<<std::dec<<std::endl;
192  std::cout<<" lin_out[ix].size()= "<<std::dec<<lin_out_[ix].size()<<std::endl;
193  for (unsigned int i =0; i<lin_out_[ix].size();i++){
194  std::cout <<" "<<std::dec<<(lin_out_[ix])[i];
195  }
196  std::cout<<std::endl;
197  }
198 
199  std::cout<<std::endl;
200  }
201 
202  // Now call the sFGVB - this is common between EB and EE!
203  getFGVB()->setParameters(identif, stripid,ecaltpgFgStripEE_);
204  getFGVB()->process(lin_out_,fgvb_out_temp_);
205 
206  if(debug_)
207  {
208  std::cout << "output of strip fgvb is a vector of size: " <<std::dec<<fgvb_out_temp_.size()<<std::endl;
209  for (unsigned int i =0; i<fgvb_out_temp_.size();i++){
210  std::cout << " " << std::dec << (fgvb_out_temp_[i]);
211  }
212  std::cout<<std::endl;
213  }
214 
215  // call adder
216  this->getAdder()->process(lin_out_,nrXtals,add_out_); //add_out is of size SIZEMAX=maxNrSamples
217 
218  if(debug_){
219  std::cout<< "output of adder is a vector of size: "<<std::dec<<add_out_.size()<<std::endl;
220  for (unsigned int ix=0;ix<add_out_.size();ix++){
221  std::cout<< "cryst: "<<ix<<" value : "<<std::dec<<add_out_[ix]<<std::endl;
222  }
223  std::cout<<std::endl;
224  }
225 
226 
227  if (famos_) {
228  filt_out_[0]= add_out_[0];
229  peak_out_[0]= add_out_[0];
230  return;
231  }else {
232  // call amplitudefilter
233  this->getFilter()->setParameters(stripid,ecaltpgWeightMap,ecaltpgWeightGroup);
234  this->getFilter()->process(add_out_,filt_out_,fgvb_out_temp_,fgvb_out_);
235 
236  if(debug_){
237  std::cout<< "output of filter is a vector of size: "<<std::dec<<filt_out_.size()<<std::endl;
238  for (unsigned int ix=0;ix<filt_out_.size();ix++){
239  std::cout<< "cryst: "<<ix<<" value : "<<std::dec<<filt_out_[ix]<<std::endl;
240  }
241  std::cout<<std::endl;
242 
243  std::cout<< "output of sfgvb after filter is a vector of size: "<<std::dec<<fgvb_out_.size()<<std::endl;
244  for (unsigned int ix=0;ix<fgvb_out_.size();ix++){
245  std::cout<< "cryst: "<<ix<<" value : "<<std::dec<<fgvb_out_[ix]<<std::endl;
246  }
247  std::cout<<std::endl;
248  }
249 
250  // call peakfinder
251  this->getPeakFinder()->process(filt_out_,peak_out_);
252  if(debug_){
253  std::cout<< "output of peakfinder is a vector of size: "<<peak_out_.size()<<std::endl;
254  for (unsigned int ix=0;ix<peak_out_.size();ix++){
255  std::cout<< "cryst: "<<ix<<" value : "<<peak_out_[ix]<<std::endl;
256  }
257  std::cout<<std::endl;
258  }
259  return;
260  }
261  }
262 
263 };
264 #endif
265 
EcalFenixStripFgvbEE * fgvbEE_
void setParameters(uint32_t raw, const EcalTPGPedestals *ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGCrystalStatus *ecaltpBadX)
std::vector< std::vector< int > > lin_out_
std::vector< int > add_out_
void process(const edm::EventSetup &setup, std::vector< EBDataFrame > &samples, int nrXtals, std::vector< int > &out)
std::vector< EcalFenixLinearizer * > linearizer_
void setParameters(int identif, uint32_t id, const EcalTPGFineGrainStripEE *)
EcalFenixStripFormatEB * fenixFormatterEB_
void process_part2_barrel(uint32_t stripid, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE)
void setPointers(const EcalTPGPedestals *ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE, const EcalTPGCrystalStatus *ecaltpgBadX, const EcalTPGStripStatus *ecaltpgStripStatus)
EcalFenixAmplitudeFilter * getFilter() const
class representing the Fenix chip, format strip
EcalFenixPeakFinder * getPeakFinder() const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
const EcalElectronicsMapping * theMapping_
calculates the peak for Fenix strip, barrel input : 18 bits output: boolean
const EcalTPGSlidingWindow * ecaltpgSlidW_
calculation of Fgvb for the endcap in Fenix Strip calculates fgvb for the endcap in Fenix Strip ...
void process_part2_endcap(uint32_t stripid, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE, const EcalTPGStripStatus *ecaltpgStripStatus)
Formatting for Fenix strip input: 18 bits + 3x 1bit (fgvb, gapflagbit, output from peakfinder) output...
std::vector< int > filt_out_
void process(const edm::EventSetup &, std::vector< const T > &, int nrxtals, std::vector< int > &out)
bool getMissedStripFlag() const
void process_part1(int identif, std::vector< T > &df, int nrXtals, uint32_t stripid, const EcalTPGPedestals *ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGCrystalStatus *ecaltpBadX)
bool getbadStripMissing() const
const EcalTPGLinearizationConst * ecaltpLin_
const EcalTPGStripStatus * ecaltpgStripStatus_
Linearisation for Fenix strip input: 16 bits corresponding to input EBDataFrame output: 18 bits...
virtual ~EcalFenixStrip()
const EcalTPGCrystalStatus * ecaltpgBadX_
EcalTriggerElectronicsId getTriggerElectronicsId(const DetId &id) const
Get the trigger electronics id for this det id.
EcalFenixStripFgvbEE * getFGVB() const
EcalFenixPeakFinder * peak_finder_
const EcalTPGWeightIdMap * ecaltpgWeightMap_
const EcalTPGWeightGroup * ecaltpgWeightGroup_
calculates .... for Fenix strip, barrel input: 18 bits output: 18 bits
#define debug
Definition: HDRShower.cc:19
Formatting for Fenix strip input: 18 bits + 3x 1bit (fgvb, gapflagbit, output from peakfinder) output...
const EcalTPGPedestals * ecaltpPed_
std::vector< int > fgvb_out_
EcalFenixEtStrip * getAdder() const
void setbadStripMissing(bool flag)
const EcalTPGFineGrainStripEE * ecaltpgFgStripEE_
EcalFenixStripFormatEB * getFormatterEB() const
void process(const edm::EventSetup &setup, std::vector< EEDataFrame > &samples, int nrXtals, std::vector< int > &out)
void setParameters(uint32_t raw, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup)
void process(std::vector< std::vector< int > > &lin_out, std::vector< int > &output)
std::vector< int > format_out_
EcalFenixStripFormatEE * getFormatterEE() const
EcalFenixAmplitudeFilter * amplitude_filter_
EcalFenixStripFormatEE * fenixFormatterEE_
EcalFenixLinearizer * getLinearizer(int i) const
std::vector< int > peak_out_
void process(const std::vector< std::vector< int > > &linout, int nrXtals, std::vector< int > &output)
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
EcalFenixEtStrip * adder_
EcalFenixStrip(const edm::EventSetup &setup, const EcalElectronicsMapping *theMapping, bool debug, bool famos, int maxNrSamples, int nbMaxXtals)
std::vector< int > fgvb_out_temp_