CMS 3D CMS Logo

EcalFenixStripFormatEE.cc
Go to the documentation of this file.
5 
7 #include <iostream>
8 
9 //-----------------------------------------------------------------------------------------
11 //------------------------------------------------------------------------------------------
12 
14 
15 //-----------------------------------------------------------------------------------------
16 
17 int EcalFenixStripFormatEE::setInput(int input_even, int inputEvenPeak, int input_odd, int inputOddPeak, int fgvb) {
18  inputEvenPeak_ = inputEvenPeak;
19  input_even_ = input_even;
20  inputOddPeak_ = inputOddPeak;
21  input_odd_ = input_odd;
22  fgvb_ = fgvb;
23  return 0;
24 }
25 //-----------------------------------------------------------------------------------------
26 
28  // Bad strip - zero everything
29  if (stripStatus_ != 0)
30  return 0;
31 
32  int even_output = 0;
33  int odd_output = 0;
34 
35  // Applying sliding window on the strip output after the peak finder
37  even_output = input_even_ >> shift_;
38  } else {
39  if (inputEvenPeak_ == 1)
40  even_output = input_even_ >> shift_;
41  }
42 
44  if (inputOddPeak_ == 1)
45  odd_output = input_odd_ >> shift_;
46  } else {
47  odd_output = input_odd_ >> shift_;
48  }
49 
50  // Truncating the signals to to 12 bit after peak finder sliding window
51  if (odd_output > 0XFFF)
52  odd_output = 0XFFF;
53  if (even_output > 0XFFF)
54  even_output = 0XFFF;
55 
56  // Prepare the amplitude output for the strip looking at the TPmode options
57  int output = 0;
58  bool is_odd_larger = false;
59 
60  if (ecaltpgTPMode_->EnableEEOddFilter && (odd_output > even_output))
61  is_odd_larger =
62  true; // If running with odd filter enabled, check if odd output is larger regardless of strip formatter output mode
64  case 0: // even filter out
65  output = even_output;
66  break;
67  case 1: // odd filter out
69  output = odd_output;
70  else
71  output = even_output;
72  break;
73  case 2: // larger between odd and even
74  if (ecaltpgTPMode_->EnableEEOddFilter && (odd_output > even_output)) {
75  output = odd_output;
76  } else
77  output = even_output;
78  break;
79  case 3: // even + odd
81  output = even_output + odd_output;
82  else
83  output = even_output;
84  break;
85  }
86 
87  // barrel saturates at 12 bits, endcap at 10!
88  // Pascal: finally no,endcap has 12 bits as in EB (bug in FENIX!!!!)
89  if (output > 0XFFF)
90  output = 0XFFF;
91 
92  // Info bits
93  // bit12 is sFGVB, bit13 is for odd>even flagging
94  output |= ((fgvb_ & 0x1) << 12);
95 
97  output |= ((is_odd_larger & 0x1) << 13);
98  }
99 
100  return output;
101 }
102 //------------------------------------------------------------------------------------------
103 
104 void EcalFenixStripFormatEE::process(std::vector<int> &fgvbout,
105  std::vector<int> &peakout_even,
106  std::vector<int> &filtout_even,
107  std::vector<int> &peakout_odd,
108  std::vector<int> &filtout_odd,
109  std::vector<int> &output) {
110  if (peakout_even.size() != filtout_even.size() || fgvbout.size() != filtout_even.size() ||
111  peakout_odd.size() != filtout_odd.size() || filtout_odd.size() != filtout_even.size()) {
112  edm::LogWarning("EcalTPG") << " problem in EcalFenixStripFormatEE: peak_out and filt_out don't "
113  "have the same size";
114  std::cout << " Size peak_out" << peakout_even.size() << ", size filt_out:" << filtout_even.size() << std::flush
115  << std::endl;
116  }
117 
118  for (unsigned int i = 0; i < filtout_even.size(); i++) {
119  setInput(filtout_even[i], peakout_even[i], filtout_odd[i], peakout_odd[i], fgvbout[i]);
120  output[i] = process();
121  }
122  return;
123 }
124 //-----------------------------------------------------------------------------------------
125 
127  const EcalTPGSlidingWindow *&slWin,
128  const EcalTPGStripStatus *stripStatus,
129  const EcalTPGTPMode *ecaltpgTPMode) {
130  // TP mode contains options for the formatter (odd/even filters config)
131  ecaltpgTPMode_ = ecaltpgTPMode;
132  const EcalTPGSlidingWindowMap &slwinmap = slWin->getMap();
133  EcalTPGSlidingWindowMapIterator it = slwinmap.find(id);
134  if (it != slwinmap.end())
135  shift_ = (*it).second;
136  else
137  edm::LogWarning("EcalTPG") << " could not find EcalTPGSlidingWindowMap entry for " << id;
138 
139  const EcalTPGStripStatusMap &statusMap = stripStatus->getMap();
140  EcalTPGStripStatusMapIterator sit = statusMap.find(id);
141  if (sit != statusMap.end()) {
142  stripStatus_ = (*sit).second;
143  } else {
144  stripStatus_ = 0; // Assume strip OK
145  }
146 }
147 //-----------------------------------------------------------------------------------------
const std::map< uint32_t, uint32_t > & getMap() const
int setInput(int input_even, int inputEvenPeak, int input_odd, int inputOddPeak, int fgvb)
uint16_t FenixEEStripInfobit2
Definition: EcalTPGTPMode.h:26
bool EnableEEOddFilter
Definition: EcalTPGTPMode.h:18
std::map< uint32_t, uint32_t > EcalTPGSlidingWindowMap
uint16_t FenixEEStripOutput
Definition: EcalTPGTPMode.h:24
bool EnableEEOddPeakFinder
Definition: EcalTPGTPMode.h:20
bool DisableEEEvenPeakFinder
Definition: EcalTPGTPMode.h:22
void setParameters(uint32_t id, const EcalTPGSlidingWindow *&, const EcalTPGStripStatus *, const EcalTPGTPMode *)
const std::map< uint32_t, uint16_t > & getMap() const
const EcalTPGTPMode * ecaltpgTPMode_
Log< level::Warning, false > LogWarning
std::map< uint32_t, uint16_t > EcalTPGStripStatusMap
std::map< uint32_t, uint32_t >::const_iterator EcalTPGSlidingWindowMapIterator
std::map< uint32_t, uint16_t >::const_iterator EcalTPGStripStatusMapIterator