CMS 3D CMS Logo

EcalFenixStrip.h
Go to the documentation of this file.
1 #ifndef ECAL_FENIXSTRIP_H
2 #define ECAL_FENIXSTRIP_H
3 
9 
16 
17 class EBDataFrame;
24 class EcalTPGStripStatus;
25 
31 public:
32  // constructor, destructor
34  const EcalElectronicsMapping *theMapping,
35  bool debug,
36  bool famos,
37  int maxNrSamples,
38  int nbMaxXtals);
39  virtual ~EcalFenixStrip();
40 
41 private:
43 
44  bool debug_;
45  bool famos_;
47 
48  std::vector<EcalFenixLinearizer *> linearizer_;
49 
51 
53 
55 
57 
59 
61 
62  // data formats for each event
63  std::vector<std::vector<int>> lin_out_;
64  std::vector<int> add_out_;
65  std::vector<int> filt_out_;
66  std::vector<int> peak_out_;
67  std::vector<int> format_out_;
68  std::vector<int> fgvb_out_;
69  std::vector<int> fgvb_out_temp_;
70 
79 
80  bool identif_;
81 
82 public:
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  ecaltpPed_ = ecaltpPed;
92  ecaltpLin_ = ecaltpLin;
93  ecaltpgWeightMap_ = ecaltpgWeightMap;
94  ecaltpgWeightGroup_ = ecaltpgWeightGroup;
95  ecaltpgSlidW_ = ecaltpgSlidW;
96  ecaltpgFgStripEE_ = ecaltpgFgStripEE;
97  ecaltpgBadX_ = ecaltpgBadX;
98  ecaltpgStripStatus_ = ecaltpgStripStatus;
99  }
100 
101  // main methods
102  // process method is splitted in 2 parts:
103  // the first one is templated, the same except input
104  // the second part is slightly different for barrel/endcap
105  template <class T>
106  void process(const edm::EventSetup &, std::vector<const T> &, int nrxtals, std::vector<int> &out);
107  void process_part2_barrel(uint32_t stripid,
108  const EcalTPGSlidingWindow *ecaltpgSlidW,
109  const EcalTPGFineGrainStripEE *ecaltpgFgStripEE);
110 
111  void process_part2_endcap(uint32_t stripid,
112  const EcalTPGSlidingWindow *ecaltpgSlidW,
113  const EcalTPGFineGrainStripEE *ecaltpgFgStripEE,
114  const EcalTPGStripStatus *ecaltpgStripStatus);
115 
116  // getters for the algorithms ;
117 
118  EcalFenixLinearizer *getLinearizer(int i) const { return linearizer_[i]; }
119  EcalFenixEtStrip *getAdder() const { return adder_; }
122 
125 
126  EcalFenixStripFgvbEE *getFGVB() const { return fgvbEE_; }
127 
128  void setbadStripMissing(bool flag) { identif_ = flag; }
129  bool getbadStripMissing() const { return identif_; }
130 
131  // ========================= implementations
132  // ==============================================================
133  void process(const edm::EventSetup &setup, std::vector<EBDataFrame> &samples, int nrXtals, std::vector<int> &out) {
134  // now call processing
135  if (samples.empty()) {
136  std::cout << " Warning: 0 size vector found in EcalFenixStripProcess!!!!!" << std::endl;
137  return;
138  }
139  const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
140  uint32_t stripid = elId.rawId() & 0xfffffff8; // from Pascal
141 
142  identif_ = getFGVB()->getMissedStripFlag();
143 
144  process_part1(identif_,
145  samples,
146  nrXtals,
147  stripid,
148  ecaltpPed_,
149  ecaltpLin_,
150  ecaltpgWeightMap_,
151  ecaltpgWeightGroup_,
152  ecaltpgBadX_); // templated part
153  process_part2_barrel(stripid, ecaltpgSlidW_,
154  ecaltpgFgStripEE_); // part different for barrel/endcap
155  out = format_out_;
156  }
157 
158  void process(const edm::EventSetup &setup, std::vector<EEDataFrame> &samples, int nrXtals, std::vector<int> &out) {
159  // now call processing
160  if (samples.empty()) {
161  std::cout << " Warning: 0 size vector found in EcalFenixStripProcess!!!!!" << std::endl;
162  return;
163  }
164  const EcalTriggerElectronicsId elId = theMapping_->getTriggerElectronicsId(samples[0].id());
165  uint32_t stripid = elId.rawId() & 0xfffffff8; // from Pascal
166 
167  identif_ = getFGVB()->getMissedStripFlag();
168 
169  process_part1(identif_,
170  samples,
171  nrXtals,
172  stripid,
173  ecaltpPed_,
174  ecaltpLin_,
175  ecaltpgWeightMap_,
176  ecaltpgWeightGroup_,
177  ecaltpgBadX_); // templated part
178  process_part2_endcap(stripid, ecaltpgSlidW_, ecaltpgFgStripEE_, ecaltpgStripStatus_);
179  out = format_out_; // FIXME: timing
180  return;
181  }
182 
183  template <class T>
184  void process_part1(int identif,
185  std::vector<T> &df,
186  int nrXtals,
187  uint32_t stripid,
188  const EcalTPGPedestals *ecaltpPed,
189  const EcalTPGLinearizationConst *ecaltpLin,
190  const EcalTPGWeightIdMap *ecaltpgWeightMap,
191  const EcalTPGWeightGroup *ecaltpgWeightGroup,
192  const EcalTPGCrystalStatus *ecaltpBadX) {
193  if (debug_)
194  std::cout << "\n\nEcalFenixStrip input is a vector of size: " << nrXtals << std::endl;
195 
196  // loop over crystals
197  for (int cryst = 0; cryst < nrXtals; cryst++) {
198  if (debug_) {
199  std::cout << std::endl;
200  std::cout << "cryst= " << cryst << " EBDataFrame/EEDataFrame is: " << std::endl;
201  for (int i = 0; i < df[cryst].size(); i++) {
202  std::cout << " " << std::dec << df[cryst][i].adc();
203  }
204  std::cout << std::endl;
205  }
206  // call linearizer
207  this->getLinearizer(cryst)->setParameters(df[cryst].id().rawId(), ecaltpPed, ecaltpLin, ecaltpBadX);
208  this->getLinearizer(cryst)->process(df[cryst], lin_out_[cryst]);
209  }
210 
211  if (debug_) {
212  std::cout << "output of linearizer is a vector of size: " << std::dec << lin_out_.size() << " of which used "
213  << nrXtals << std::endl;
214  for (int ix = 0; ix < nrXtals; ix++) {
215  std::cout << "cryst: " << ix << " value : " << std::dec << std::endl;
216  std::cout << " lin_out[ix].size()= " << std::dec << lin_out_[ix].size() << std::endl;
217  for (unsigned int i = 0; i < lin_out_[ix].size(); i++) {
218  std::cout << " " << std::dec << (lin_out_[ix])[i];
219  }
220  std::cout << std::endl;
221  }
222 
223  std::cout << std::endl;
224  }
225 
226  // Now call the sFGVB - this is common between EB and EE!
227  getFGVB()->setParameters(identif, stripid, ecaltpgFgStripEE_);
228  getFGVB()->process(lin_out_, fgvb_out_temp_);
229 
230  if (debug_) {
231  std::cout << "output of strip fgvb is a vector of size: " << std::dec << fgvb_out_temp_.size() << std::endl;
232  for (unsigned int i = 0; i < fgvb_out_temp_.size(); i++) {
233  std::cout << " " << std::dec << (fgvb_out_temp_[i]);
234  }
235  std::cout << std::endl;
236  }
237 
238  // call adder
239  this->getAdder()->process(lin_out_, nrXtals, add_out_); // add_out is of size SIZEMAX=maxNrSamples
240 
241  if (debug_) {
242  std::cout << "output of adder is a vector of size: " << std::dec << add_out_.size() << std::endl;
243  for (unsigned int ix = 0; ix < add_out_.size(); ix++) {
244  std::cout << "cryst: " << ix << " value : " << std::dec << add_out_[ix] << std::endl;
245  }
246  std::cout << std::endl;
247  }
248 
249  if (famos_) {
250  filt_out_[0] = add_out_[0];
251  peak_out_[0] = add_out_[0];
252  return;
253  } else {
254  // call amplitudefilter
255  this->getFilter()->setParameters(stripid, ecaltpgWeightMap, ecaltpgWeightGroup);
256  this->getFilter()->process(add_out_, filt_out_, fgvb_out_temp_, fgvb_out_);
257 
258  if (debug_) {
259  std::cout << "output of filter is a vector of size: " << std::dec << filt_out_.size() << std::endl;
260  for (unsigned int ix = 0; ix < filt_out_.size(); ix++) {
261  std::cout << "cryst: " << ix << " value : " << std::dec << filt_out_[ix] << std::endl;
262  }
263  std::cout << std::endl;
264 
265  std::cout << "output of sfgvb after filter is a vector of size: " << std::dec << fgvb_out_.size() << std::endl;
266  for (unsigned int ix = 0; ix < fgvb_out_.size(); ix++) {
267  std::cout << "cryst: " << ix << " value : " << std::dec << fgvb_out_[ix] << std::endl;
268  }
269  std::cout << std::endl;
270  }
271 
272  // call peakfinder
273  this->getPeakFinder()->process(filt_out_, peak_out_);
274  if (debug_) {
275  std::cout << "output of peakfinder is a vector of size: " << peak_out_.size() << std::endl;
276  for (unsigned int ix = 0; ix < peak_out_.size(); ix++) {
277  std::cout << "cryst: " << ix << " value : " << peak_out_[ix] << std::endl;
278  }
279  std::cout << std::endl;
280  }
281  return;
282  }
283  }
284 };
285 #endif
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 process(std::vector< std::vector< int >> &lin_out, std::vector< int > &output)
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
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
void process(const std::vector< std::vector< int >> &linout, int nrXtals, std::vector< int > &output)
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)
std::vector< int > format_out_
EcalFenixStripFormatEE * getFormatterEE() const
EcalFenixAmplitudeFilter * amplitude_filter_
EcalFenixStripFormatEE * fenixFormatterEE_
EcalFenixLinearizer * getLinearizer(int i) const
std::vector< int > peak_out_
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_