CMS 3D CMS Logo

EcalFenixStrip.cc
Go to the documentation of this file.
7 
9 
11 #include <string>
12 #include <bitset>
13 
14 //-------------------------------------------------------------------------------------
16  bool debug,
17  bool famos,
18  int maxNrSamples,
19  int nbMaxXtals,
20  bool tpInfoPrintout)
21  : theMapping_(theMapping), debug_(debug), famos_(famos), nbMaxXtals_(nbMaxXtals), tpInfoPrintout_(tpInfoPrintout) {
22  linearizer_.resize(nbMaxXtals_);
23  for (int i = 0; i < nbMaxXtals_; i++)
25  adder_ = new EcalFenixEtStrip();
26  amplitude_filter_ = new EcalFenixAmplitudeFilter(tpInfoPrintout);
32 
33  // prepare data storage for all events
34  std::vector<int> v;
35  v.resize(maxNrSamples);
36  lin_out_.resize(nbMaxXtals_);
37  for (int i = 0; i < 5; i++)
38  lin_out_[i] = v;
39  add_out_.resize(maxNrSamples);
40 
41  even_filt_out_.resize(maxNrSamples);
42  even_peak_out_.resize(maxNrSamples);
43  odd_filt_out_.resize(maxNrSamples);
44  odd_peak_out_.resize(maxNrSamples);
45 
46  format_out_.resize(maxNrSamples);
47  fgvb_out_.resize(maxNrSamples);
48  fgvb_out_temp_.resize(maxNrSamples);
49 }
50 
51 //-------------------------------------------------------------------------------------
53  for (int i = 0; i < nbMaxXtals_; i++)
54  delete linearizer_[i];
55  delete adder_;
56  delete amplitude_filter_;
57  delete oddAmplitude_filter_;
58  delete peak_finder_;
59  delete fenixFormatterEB_;
60  delete fenixFormatterEE_;
61  delete fgvbEE_;
62 }
63 
64 void EcalFenixStrip::process(std::vector<EBDataFrame> &samples, int nrXtals, std::vector<int> &out) {
65  // now call processing
66  if (samples.empty()) {
67  edm::LogWarning("EcalTPG") << "Warning: 0 size vector found in EcalFenixStripProcess!!!!!";
68  return;
69  }
71  uint32_t stripid = elId.rawId() & 0xfffffff8; // from Pascal
72 
74 
76  samples,
77  nrXtals,
78  stripid,
79  ecaltpPed_,
80  ecaltpLin_,
85  ecaltpgBadX_); // templated part
87  ecaltpgFgStripEE_); // part different for barrel/endcap
88  out = format_out_;
89 }
90 
91 void EcalFenixStrip::process(std::vector<EEDataFrame> &samples, int nrXtals, std::vector<int> &out) {
92  // now call processing
93  if (samples.empty()) {
94  std::cout << " Warning: 0 size vector found in EcalFenixStripProcess!!!!!" << std::endl;
95  return;
96  }
98  uint32_t stripid = elId.rawId() & 0xfffffff8; // from Pascal
99 
101 
103  samples,
104  nrXtals,
105  stripid,
106  ecaltpPed_,
107  ecaltpLin_,
112  ecaltpgBadX_); // templated part
114  out = format_out_; // FIXME: timing
115  return;
116 }
117 
118 /*
119 * strip level processing - part1.
120 * The linearizer and adder are run only once.
121 * Then the even and odd filters and peak finder are run looking at the TPmode flag
122 */
123 template <class T>
125  std::vector<T> &df,
126  int nrXtals,
127  uint32_t stripid,
128  const EcalTPGPedestals *ecaltpPed,
129  const EcalTPGLinearizationConst *ecaltpLin,
130  const EcalTPGWeightIdMap *ecaltpgWeightMap,
131  const EcalTPGWeightGroup *ecaltpgWeightGroup,
132  const EcalTPGOddWeightIdMap *ecaltpgOddWeightMap,
133  const EcalTPGOddWeightGroup *ecaltpgOddWeightGroup,
134  const EcalTPGCrystalStatus *ecaltpBadX) {
135  if (debug_) {
136  edm::LogVerbatim("EcalTPG");
137  edm::LogVerbatim("EcalTPG") << "EcalFenixStrip input is a vector of size: " << nrXtals << "\n";
138  edm::LogVerbatim("EcalTPG") << "ECAL TPG TPMode printout:";
139 
140  std::stringstream ss;
142  edm::LogVerbatim("EcalTPG") << ss.str() << "\n";
143  }
144 
145  // loop over crystals
146  for (int cryst = 0; cryst < nrXtals; cryst++) {
147  if (debug_) {
148  edm::LogVerbatim("EcalTPG") << "crystal " << cryst << " ADC counts per clock (non-linearized): ";
149  int Nsamples = df[cryst].size();
150  std::string XTAL_ADCs;
151 
152  for (int i = 0; i < Nsamples; i++) {
153  XTAL_ADCs.append(" ");
154  XTAL_ADCs.append(std::to_string(df[cryst][i].adc()));
155  }
156 
157  edm::LogVerbatim("EcalTPG") << XTAL_ADCs << "\n";
158  }
159  // call linearizer
160  this->getLinearizer(cryst)->setParameters(df[cryst].id().rawId(), ecaltpPed, ecaltpLin, ecaltpBadX);
161  this->getLinearizer(cryst)->process(df[cryst], lin_out_[cryst]);
162  }
163 
164  if (debug_) {
165  edm::LogVerbatim("EcalTPG") << "output of linearizer is a vector of size: " << lin_out_.size() << " of which "
166  << nrXtals << " are used";
167 
168  for (int ix = 0; ix < nrXtals; ix++) {
169  edm::LogVerbatim("EcalTPG") << "crystal " << std::to_string(ix) << " values per clock (linearized): ";
170  std::string Lin_Vals;
171  std::string Lin_Vals_in_time = "[";
172 
173  for (unsigned int i = 0; i < lin_out_[ix].size(); i++) {
174  Lin_Vals.append(" ");
175  if (i >= 2 && i < 7) {
176  Lin_Vals_in_time.append(
177  std::to_string((lin_out_[ix])[i])); // Save in time vals separately for nicely formatted digis
178  if (i < 6)
179  Lin_Vals_in_time.append(", ");
180  else
181  Lin_Vals_in_time.append("]");
182  }
183  Lin_Vals.append(std::to_string((lin_out_[ix])[i]));
184  }
185  Lin_Vals.append("]");
186 
187  edm::LogVerbatim("EcalTPG") << Lin_Vals << " --> In time digis: " << Lin_Vals_in_time << "\n";
188  }
189  }
190 
191  // Now call the sFGVB - this is common between EB and EE!
192  getFGVB()->setParameters(identif, stripid, ecaltpgFgStripEE_);
194 
195  if (debug_) {
196  edm::LogVerbatim("EcalTPG") << "output of strip fgvb is a vector of size: " << fgvb_out_temp_.size();
197  std::string fgvb_vals;
198  for (unsigned int i = 0; i < fgvb_out_temp_.size(); i++) {
199  fgvb_vals.append(" ");
200  fgvb_vals.append(std::to_string(fgvb_out_temp_[i]));
201  }
202  edm::LogVerbatim("EcalTPG") << fgvb_vals << "\n";
203  }
204  // call adder
205  this->getAdder()->process(lin_out_, nrXtals, add_out_); // add_out is of size SIZEMAX=maxNrSamples
206 
207  if (debug_) {
208  edm::LogVerbatim("EcalTPG") << "output of adder is a vector of size: " << add_out_.size();
209  for (unsigned int ix = 0; ix < add_out_.size(); ix++) {
210  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value: " << add_out_[ix];
211  }
212  edm::LogVerbatim("EcalTPG");
213  }
214 
215  if (famos_) {
216  even_filt_out_[0] = add_out_[0];
217  even_peak_out_[0] = add_out_[0];
218  return;
219  } else {
220  // This is where the amplitude filters are called
221  // the TPmode flag will determine which are called and if the peak finder is called.
222  // Call even amplitude filter
223  this->getEvenFilter()->setParameters(stripid, ecaltpgWeightMap, ecaltpgWeightGroup);
225 
226  // Print out even filter ET and sfgvb values
227  if (debug_) {
228  edm::LogVerbatim("EcalTPG");
229  edm::LogVerbatim("EcalTPG") << "output of EVEN filter is a vector of size: " << even_filt_out_.size();
230  for (unsigned int ix = 0; ix < even_filt_out_.size(); ix++) {
231  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value : " << even_filt_out_[ix];
232  }
233  edm::LogVerbatim("EcalTPG");
234  edm::LogVerbatim("EcalTPG") << "output of EVEN sfgvb after filter is a vector of size: " << fgvb_out_.size();
235  for (unsigned int ix = 0; ix < fgvb_out_.size(); ix++) {
236  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value : " << fgvb_out_[ix];
237  }
238  }
239 
240  // Call peak finder on even filter output
242 
243  // Print out even filter peak finder values
244  if (debug_) {
245  edm::LogVerbatim("EcalTPG");
246  edm::LogVerbatim("EcalTPG") << "output of EVEN peakfinder is a vector of size: " << even_peak_out_.size();
247  for (unsigned int ix = 0; ix < even_peak_out_.size(); ix++) {
248  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value : " << even_peak_out_[ix];
249  }
250  edm::LogVerbatim("EcalTPG");
251  }
252 
253  // Run the odd filter
254  this->getOddFilter()->setParameters(stripid, ecaltpgOddWeightMap, ecaltpgOddWeightGroup);
256 
257  // Print out odd filter ET
258  if (debug_) {
259  edm::LogVerbatim("EcalTPG");
260  edm::LogVerbatim("EcalTPG") << "output of ODD filter is a vector of size: " << odd_filt_out_.size();
261  for (unsigned int ix = 0; ix < odd_filt_out_.size(); ix++) {
262  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value : " << odd_filt_out_[ix];
263  }
264  edm::LogVerbatim("EcalTPG");
265  }
266 
267  // And run the odd peak finder always (then the formatter will use the configuration to decide to use it or not)
268  // Call peak finder on even filter output
270 
271  if (debug_) {
272  edm::LogVerbatim("EcalTPG") << "output of ODD peakfinder is a vector of size: " << odd_peak_out_.size();
273  for (unsigned int ix = 0; ix < odd_peak_out_.size(); ix++) {
274  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value : " << odd_peak_out_[ix];
275  }
276  edm::LogVerbatim("EcalTPG");
277  }
278 
279  return;
280  }
281 }
282 
283 //----------------------------------------------------------------------------------
285  const EcalTPGSlidingWindow *ecaltpgSlidW,
286  const EcalTPGFineGrainStripEE *ecaltpgFgStripEE) {
287  // call formatter
288  this->getFormatterEB()->setParameters(stripid, ecaltpgSlidW, ecaltpgTPMode_);
290 
291  if (debug_) {
292  edm::LogVerbatim("EcalTPG") << "output of strip EB formatter is a vector of size: " << format_out_.size();
293  edm::LogVerbatim("EcalTPG") << "value : ";
294  for (unsigned int ix = 0; ix < format_out_.size(); ix++) {
295  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value : " << format_out_[ix] << " 0b"
296  << std::bitset<14>(format_out_[ix]).to_string();
297  }
298  edm::LogVerbatim("EcalTPG");
299  }
300  return;
301 }
302 //-------------------------------------------------------------------------------------
304  const EcalTPGSlidingWindow *ecaltpgSlidW,
305  const EcalTPGFineGrainStripEE *ecaltpgFgStripEE,
306  const EcalTPGStripStatus *ecaltpgStripStatus) {
307  // call formatter
308  this->getFormatterEE()->setParameters(stripid, ecaltpgSlidW, ecaltpgStripStatus, ecaltpgTPMode_);
310 
311  if (debug_) {
312  edm::LogVerbatim("EcalTPG") << "\noutput of strip EE formatter is a vector of size: " << format_out_.size();
313  edm::LogVerbatim("EcalTPG") << "value : ";
314  for (unsigned int ix = 0; ix < format_out_.size(); ix++) {
315  edm::LogVerbatim("EcalTPG") << "Clock: " << ix << " value : " << format_out_[ix] << " 0b"
316  << std::bitset<14>(format_out_[ix]).to_string();
317  }
318  edm::LogVerbatim("EcalTPG");
319  }
320 
321  return;
322 }
EcalFenixStripFormatEB * getFormatterEB() const
EcalFenixOddAmplitudeFilter * getOddFilter() const
Log< level::Info, true > LogVerbatim
EcalFenixOddAmplitudeFilter * oddAmplitude_filter_
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_
EcalFenixStripFgvbEE * getFGVB() const
std::vector< int > even_peak_out_
std::vector< EcalFenixLinearizer * > linearizer_
void process(std::vector< std::vector< int >> &lin_out, std::vector< int > &output)
EcalFenixAmplitudeFilter * getEvenFilter() const
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 process(std::vector< EBDataFrame > &samples, int nrXtals, std::vector< int > &out)
const EcalTPGOddWeightGroup * ecaltpgOddWeightGroup_
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 EcalTPGOddWeightIdMap *ecaltpgOddWeightMap, const EcalTPGOddWeightGroup *ecaltpgOddWeightGroup, const EcalTPGCrystalStatus *ecaltpBadX)
void print(std::ostream &) const
Definition: EcalTPGTPMode.cc:8
std::string to_string(const V &value)
Definition: OMSAccess.h:77
const EcalElectronicsMapping * theMapping_
calculates the peak for Fenix strip, barrel input : 18 bits output: boolean
std::vector< int > odd_filt_out_
const EcalTPGSlidingWindow * ecaltpgSlidW_
calculation of Fgvb for the endcap in Fenix Strip calculates fgvb for the endcap in Fenix Strip ...
EcalTriggerElectronicsId getTriggerElectronicsId(const DetId &id) const
Get the trigger electronics id for this det id.
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...
const EcalTPGOddWeightIdMap * ecaltpgOddWeightMap_
void process(const std::vector< std::vector< int >> &linout, int nrXtals, std::vector< int > &output)
EcalFenixLinearizer * getLinearizer(int i) const
const EcalTPGLinearizationConst * ecaltpLin_
const EcalTPGStripStatus * ecaltpgStripStatus_
Linearisation for Fenix strip input: 16 bits corresponding to input EBDataFrame output: 18 bits...
virtual ~EcalFenixStrip()
EcalFenixStrip(const EcalElectronicsMapping *theMapping, bool debug, bool famos, int maxNrSamples, int nbMaxXtals, bool TPinfoPrintout)
const EcalTPGCrystalStatus * ecaltpgBadX_
std::vector< int > even_filt_out_
EcalFenixStripFormatEE * getFormatterEE() const
EcalFenixPeakFinder * peak_finder_
const EcalTPGWeightIdMap * ecaltpgWeightMap_
const EcalTPGWeightGroup * ecaltpgWeightGroup_
calculates .... for Fenix strip, barrel input: 18 bits output: 18 bits
std::vector< int > odd_peak_out_
#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_
const EcalTPGFineGrainStripEE * ecaltpgFgStripEE_
const EcalTPGTPMode * ecaltpgTPMode_
void setParameters(uint32_t raw, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup)
EcalFenixPeakFinder * getPeakFinder() const
void setParameters(uint32_t id, const EcalTPGSlidingWindow *&, const EcalTPGStripStatus *, const EcalTPGTPMode *)
std::vector< int > format_out_
EcalFenixAmplitudeFilter * amplitude_filter_
EcalFenixStripFormatEE * fenixFormatterEE_
EcalFenixEtStrip * getAdder() const
Log< level::Warning, false > LogWarning
void setParameters(uint32_t &, const EcalTPGSlidingWindow *&, const EcalTPGTPMode *)
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
EcalFenixEtStrip * adder_
std::vector< int > fgvb_out_temp_
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void setParameters(uint32_t raw, const EcalTPGOddWeightIdMap *ecaltpgOddWeightMap, const EcalTPGOddWeightGroup *ecaltpgOddWeightGroup)