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