CMS 3D CMS Logo

EcalFenixTcp.cc
Go to the documentation of this file.
2 
9 
11 
13 
14 #include <vector>
15 //----------------------------------------------------------------------------------------
17  bool tcpFormat, bool debug, bool famos, int binOfMax, int maxNrSamples, int nbMaxStrips, bool tpInfoPrintout)
18  : debug_(debug), nbMaxStrips_(nbMaxStrips), tpInfoPrintout_(tpInfoPrintout) {
19  bypasslin_.resize(nbMaxStrips_);
20  for (int i = 0; i < nbMaxStrips_; i++)
22  adder_ = new EcalFenixEtTot();
23  maxOf2_ = new EcalFenixMaxof2(maxNrSamples, nbMaxStrips_);
24  formatter_EB_ = new EcalFenixTcpFormatEB(tcpFormat, debug_, famos, binOfMax);
25  formatter_EE_ = new EcalFenixTcpFormatEE(tcpFormat, debug_, famos, binOfMax);
26  fgvbEB_ = new EcalFenixFgvbEB(maxNrSamples);
27  fgvbEE_ = new EcalFenixTcpFgvbEE(maxNrSamples);
29 
30  // permanent data structures
32  std::vector<int> vec(maxNrSamples, 0);
33  for (int i = 0; i < nbMaxStrips_; i++)
34  bypasslin_out_[i] = vec;
35 
36  adder_even_out_.resize(maxNrSamples);
37  adder_odd_out_.resize(maxNrSamples);
38  maxOf2_out_.resize(maxNrSamples);
39  fgvb_out_.resize(maxNrSamples);
40  strip_fgvb_out_.resize(maxNrSamples);
41 }
42 //-----------------------------------------------------------------------------------------
44  for (int i = 0; i < nbMaxStrips_; i++)
45  delete bypasslin_[i];
46  delete adder_;
47  delete maxOf2_;
48  delete formatter_EB_;
49  delete formatter_EE_;
50  delete fgvbEB_;
51  delete fgvbEE_;
52 }
53 //-----------------------------------------------------------------------------------------
54 
55 void EcalFenixTcp::process(std::vector<EBDataFrame> &bid, // dummy argument for template call
56  std::vector<std::vector<int>> &tpframetow,
57  int nStr,
58  std::vector<EcalTriggerPrimitiveSample> &tptow,
59  std::vector<EcalTriggerPrimitiveSample> &tptow2,
60  bool isInInnerRing,
61  EcalTrigTowerDetId towid) {
62  int bitMask = 12;
63  // The 14th bit is always used for the odd>even flag. If the flagging is off in the Strip fenix the feature will be not used.
64  int bitOddEven = 13;
65  process_part1(tpframetow, nStr, bitMask, bitOddEven);
66 
67  process_part2_barrel(tpframetow,
68  nStr,
69  bitMask,
70  bitOddEven,
77  tptow,
78  tptow2,
79  towid);
80 }
81 
82 //-----------------------------------------------------------------------------------------
83 void EcalFenixTcp::process(std::vector<EEDataFrame> &bid, // dummy argument for template call
84  std::vector<std::vector<int>> &tpframetow,
85  int nStr,
86  std::vector<EcalTriggerPrimitiveSample> &tptow,
87  std::vector<EcalTriggerPrimitiveSample> &tptow2,
88  bool isInInnerRing,
89  EcalTrigTowerDetId towid) {
90  int bitMask = 12; // Pascal: endcap has 12 bits as in EB (bug in FENIX!!!!)
91  // The 14th bit is always used for the odd>even flag. If the flagging is off in the Strip fenix the feature will be not used.
92  int bitOddEven = 13;
93 
94  process_part1(tpframetow, nStr, bitMask, bitOddEven);
95 
96  process_part2_endcap(tpframetow,
97  nStr,
98  bitMask,
99  bitOddEven,
101  ecaltpgLut_,
104  tptow,
105  tptow2,
106  isInInnerRing,
107  towid);
108 }
109 //-----------------------------------------------------------------------------------------
110 void EcalFenixTcp::process_part1(std::vector<std::vector<int>> &tpframetow, int nStr, int bitMask, int bitOddEven) {
111  // call adder
112  this->getAdder()->process(tpframetow, nStr, bitMask, bitOddEven, adder_even_out_, adder_odd_out_);
113  if (debug_) {
114  edm::LogVerbatim("EcalTPG") << "output of TCP adder is a vector of size: " << adder_even_out_.size();
115  edm::LogVerbatim("EcalTPG") << "EVEN sum : ";
116  std::string even_adder_outputs;
117  for (unsigned int i = 0; i < adder_even_out_.size(); i++) {
118  even_adder_outputs.append(" ");
119  even_adder_outputs.append(std::to_string(adder_even_out_[i]));
120  }
121  edm::LogVerbatim("EcalTPG") << even_adder_outputs << "\n";
122 
123  edm::LogVerbatim("EcalTPG") << "ODD sum : ";
124  std::string odd_adder_outputs;
125  for (unsigned int i = 0; i < adder_odd_out_.size(); i++) {
126  odd_adder_outputs.append(" ");
127  odd_adder_outputs.append(std::to_string(adder_odd_out_[i]));
128  }
129  edm::LogVerbatim("EcalTPG") << odd_adder_outputs << "\n";
130  }
131  return;
132 }
133 //-----------------------------------------------------------------------------------------
134 void EcalFenixTcp::process_part2_barrel(std::vector<std::vector<int>> &bypasslinout,
135  int nStr,
136  int bitMask,
137  int bitOddEven,
138  const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup,
139  const EcalTPGLutGroup *ecaltpgLutGroup,
140  const EcalTPGLutIdMap *ecaltpgLut,
141  const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB,
142  const EcalTPGTowerStatus *ecaltpgBadTT,
143  const EcalTPGSpike *ecaltpgSpike,
144  std::vector<EcalTriggerPrimitiveSample> &tcp_out,
145  std::vector<EcalTriggerPrimitiveSample> &tcp_outTcc,
146  EcalTrigTowerDetId towid) {
147  // call maxof2
148  // the oddEven flag is used to exclude "odd" strip from the computation of the maxof2 as in the fenix firmware
149  this->getMaxOf2()->process(bypasslinout, nStr, bitMask, bitOddEven, maxOf2_out_);
150 
151  if (debug_) {
152  edm::LogVerbatim("EcalTPG") << "output of maxof2 is a vector of size: " << maxOf2_out_.size();
153  edm::LogVerbatim("EcalTPG") << "value : ";
154  std::string maxOf2_outputs;
155  for (unsigned int i = 0; i < maxOf2_out_.size(); i++) {
156  maxOf2_outputs.append(" ");
157  maxOf2_outputs.append(std::to_string(maxOf2_out_[i]));
158  }
159  edm::LogVerbatim("EcalTPG") << maxOf2_outputs << "\n";
160  }
161 
162  // call fgvb
163  this->getFGVBEB()->setParameters(towid.rawId(), ecaltpgFgEBGroup, ecaltpgFineGrainEB);
164  // The FGVB is computed only on the even sum, as in the firmware
166 
167  // Call sFGVB
168  this->getsFGVBEB()->process(bypasslinout, nStr, bitMask, strip_fgvb_out_);
169 
170  if (debug_) {
171  edm::LogVerbatim("EcalTPG") << "output of fgvb is a vector of size: " << fgvb_out_.size();
172  edm::LogVerbatim("EcalTPG") << "value : ";
173  std::string fgvb_output;
174  for (unsigned int i = 0; i < fgvb_out_.size(); i++) {
175  fgvb_output.append(" ");
176  fgvb_output.append(std::to_string(fgvb_out_[i]));
177  }
178  edm::LogVerbatim("EcalTPG") << fgvb_output;
179  }
180 
181  // call formatter
182  int eTTotShift = 2;
183 
184  this->getFormatterEB()->setParameters(
185  towid.rawId(), ecaltpgLutGroup, ecaltpgLut, ecaltpgBadTT, ecaltpgSpike, ecaltpgTPMode_);
186  this->getFormatterEB()->process(
187  adder_even_out_, adder_odd_out_, fgvb_out_, strip_fgvb_out_, eTTotShift, tcp_out, tcp_outTcc);
188 
189  if (tpInfoPrintout_) {
190  for (unsigned int i = 3; i < tcp_out.size(); i++) {
191  edm::LogVerbatim("EcalTPG") << " " << i << " " << tcp_out[i];
192  }
193  }
194 
195  if (debug_) {
196  edm::LogVerbatim("EcalTPG") << "\noutput of TCP formatter Barrel is a vector of size: " << tcp_out.size();
197  edm::LogVerbatim("EcalTPG") << "value : ";
198  for (unsigned int i = 0; i < tcp_out.size(); i++) {
199  edm::LogVerbatim("EcalTPG") << " " << i << " " << tcp_out[i];
200  }
201  edm::LogVerbatim("EcalTPG");
202  }
203 
204  return;
205 }
206 //-----------------------------------------------------------------------------------------
207 void EcalFenixTcp::process_part2_endcap(std::vector<std::vector<int>> &bypasslinout,
208  int nStr,
209  int bitMask,
210  int bitOddEven,
211  const EcalTPGLutGroup *ecaltpgLutGroup,
212  const EcalTPGLutIdMap *ecaltpgLut,
213  const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE,
214  const EcalTPGTowerStatus *ecaltpgbadTT,
215  std::vector<EcalTriggerPrimitiveSample> &tcp_out,
216  std::vector<EcalTriggerPrimitiveSample> &tcp_outTcc,
217  bool isInInnerRings,
218  EcalTrigTowerDetId towid)
219 
220 {
221  // Zero EB strip records
222  for (unsigned int i = 0; i < strip_fgvb_out_.size(); ++i) {
223  strip_fgvb_out_[i] = 0;
224  }
225 
226  // call fgvb
227  this->getFGVBEE()->setParameters(towid.rawId(), ecaltpgFineGrainTowerEE);
228  // fgvbEE_->process(bypasslin_out_,nStr,bitMask,fgvb_out_);
229  fgvbEE_->process(bypasslinout, nStr, bitMask, fgvb_out_);
230 
231  // call formatter
232  int eTTotShift = 2; // Pascal: endcap has 12 bits as in EB (bug in FENIX!!!!)
233  // so shift must be applied to just keep [11:2]
234 
235  this->getFormatterEE()->setParameters(
236  towid.rawId(), ecaltpgLutGroup, ecaltpgLut, ecaltpgbadTT, nullptr, ecaltpgTPMode_);
237 
238  // Pass both the even and the odd Et sums to the EE formatter also if there is not TCP in the electronics.
239  // The feature can be implemented in the TCC in the future: the emulator is kept generic.
240  this->getFormatterEE()->process(
241  adder_even_out_, adder_odd_out_, fgvb_out_, strip_fgvb_out_, eTTotShift, tcp_out, tcp_outTcc, isInInnerRings);
242  if (debug_) {
243  edm::LogVerbatim("EcalTPG") << "\noutput of TCP formatter(endcap) is a vector of size: " << tcp_out.size();
244  edm::LogVerbatim("EcalTPG") << "value : ";
245  for (unsigned int i = 0; i < tcp_out.size(); i++) {
246  edm::LogVerbatim("EcalTPG") << " " << i << " " << tcp_out[i];
247  }
248  edm::LogVerbatim("EcalTPG");
249  }
250  return;
251 }
Log< level::Info, true > LogVerbatim
void process_part2_endcap(std::vector< std::vector< int >> &, int nStr, int bitMask, int bitOddEven, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE, const EcalTPGTowerStatus *ecaltpgBadTT, std::vector< EcalTriggerPrimitiveSample > &tptow, std::vector< EcalTriggerPrimitiveSample > &tptow2, bool isInInnerRings, EcalTrigTowerDetId towid)
const EcalTPGFineGrainEBIdMap * ecaltpgFineGrainEB_
Definition: EcalFenixTcp.h:138
void setParameters(uint32_t towid, const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup, const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB)
EcalFenixTcpFormatEB * getFormatterEB() const
Definition: EcalFenixTcp.h:129
class for calculation of Et for Fenix tcp calculates the sum. As in the firmware the Et sum is splitt...
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike, const EcalTPGTPMode *ecaltpgTPMode)
EcalFenixTcpsFgvbEB * sfgvbEB_
Definition: EcalFenixTcp.h:44
EcalFenixMaxof2 * maxOf2_
Definition: EcalFenixTcp.h:39
const EcalTPGTPMode * ecaltpgTPMode_
Definition: EcalFenixTcp.h:142
calculation of Fgvb for Fenix Tcp, format barrel calculates fgvb for the barrel
void process(std::vector< int > &add_out, std::vector< int > &maxof2_out, std::vector< int > &output)
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void process(std::vector< EBDataFrame > &bid, std::vector< std::vector< int >> &tpframetow, int nStr, std::vector< EcalTriggerPrimitiveSample > &tptow, std::vector< EcalTriggerPrimitiveSample > &tptow2, bool isInInnerRings, EcalTrigTowerDetId thisTower)
Definition: EcalFenixTcp.cc:55
EcalFenixTcp(bool tcpFormat, bool debug, bool famos, int binOfMax, int maxNrSamples, int nbMaxStrips, bool TPinfoPrintout)
Definition: EcalFenixTcp.cc:16
void process_part1(std::vector< std::vector< int >> &tpframetow, int nStr, int bitMask, int bitOddEven)
virtual ~EcalFenixTcp()
Definition: EcalFenixTcp.cc:43
const EcalTPGSpike * ecaltpgSpike_
Definition: EcalFenixTcp.h:141
void process(std::vector< std::vector< int >> &, int nStr, int bitMask, int bitOddEven, std::vector< int > &out)
std::vector< int > fgvb_out_
Definition: EcalFenixTcp.h:54
virtual std::vector< int > process(const std::vector< EBDataFrame *> &)
const EcalTPGTowerStatus * ecaltpgBadTT_
Definition: EcalFenixTcp.h:140
EcalFenixTcpFgvbEE * fgvbEE_
Definition: EcalFenixTcp.h:43
std::vector< EcalFenixBypassLin * > bypasslin_
Definition: EcalFenixTcp.h:40
const EcalTPGFineGrainEBGroup * ecaltpgFgEBGroup_
Definition: EcalFenixTcp.h:135
EcalFenixTcpFormatEE * getFormatterEE() const
Definition: EcalFenixTcp.h:130
const EcalTPGLutIdMap * ecaltpgLut_
Definition: EcalFenixTcp.h:137
void process(std::vector< std::vector< int >> &bypasslin_out, int nStr, int bitMask, std::vector< int > &output)
EcalFenixTcpFgvbEE * getFGVBEE() const
Definition: EcalFenixTcp.h:132
void setParameters(uint32_t towid, const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE)
const EcalTPGFineGrainTowerEE * ecaltpgFineGrainTowerEE_
Definition: EcalFenixTcp.h:139
EcalFenixMaxof2 * getMaxOf2() const
Definition: EcalFenixTcp.h:128
virtual std::vector< int > process(const std::vector< int > &, const std::vector< int > &)
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike, const EcalTPGTPMode *ecaltpgTPMode)
EcalFenixTcpFormatEE * formatter_EE_
Definition: EcalFenixTcp.h:47
std::vector< int > adder_odd_out_
Definition: EcalFenixTcp.h:52
EcalFenixFgvbEB * fgvbEB_
Definition: EcalFenixTcp.h:42
#define debug
Definition: HDRShower.cc:19
EcalFenixTcpsFgvbEB * getsFGVBEB() const
Definition: EcalFenixTcp.h:133
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
calculation of Fgvb for Fenix Tcp, format endcap calculates fgvb for the endcap
std::vector< int > adder_even_out_
Definition: EcalFenixTcp.h:51
std::vector< int > maxOf2_out_
Definition: EcalFenixTcp.h:53
std::vector< int > strip_fgvb_out_
Definition: EcalFenixTcp.h:55
void process_part2_barrel(std::vector< std::vector< int >> &, int nStr, int bitMask, int bitOddEven, const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB, const EcalTPGTowerStatus *ecaltpgBadTT, const EcalTPGSpike *ecaltpgSpike, std::vector< EcalTriggerPrimitiveSample > &tptow, std::vector< EcalTriggerPrimitiveSample > &tptow2, EcalTrigTowerDetId towid)
EcalFenixFgvbEB * getFGVBEB() const
Definition: EcalFenixTcp.h:131
void process(std::vector< std::vector< int >> &bypasslin_out, int nStr, int bitMask, std::vector< int > &output)
EcalFenixTcpFormatEB * formatter_EB_
Definition: EcalFenixTcp.h:46
virtual std::vector< int > process(const std::vector< int > &, const std::vector< int > &)
const EcalTPGLutGroup * ecaltpgLutGroup_
Definition: EcalFenixTcp.h:136
EcalFenixEtTot * getAdder() const
Definition: EcalFenixTcp.h:127
bool tpInfoPrintout_
Definition: EcalFenixTcp.h:37
std::vector< std::vector< int > > bypasslin_out_
Definition: EcalFenixTcp.h:50
EcalFenixEtTot * adder_
Definition: EcalFenixTcp.h:41
Linearisation for Tcp input: 16 bits output: 12 bits +1 going to fgvb (???)
calculation of strip Fgvb for Fenix Tcp, format barrel calculates fgvb for the barrel ...