CMS 3D CMS Logo

EcalFenixTcpFormatEB.cc
Go to the documentation of this file.
8 #include <iostream>
9 using namespace std;
10 
11 EcalFenixTcpFormatEB::EcalFenixTcpFormatEB(bool tcpFormat, bool debug, bool famos, int binOfMax)
12  : tcpFormat_(tcpFormat), debug_(debug), famos_(famos), binOfMax_(binOfMax) {
13  status_ = 0;
15 }
16 
18 
19 void EcalFenixTcpFormatEB::process(std::vector<int> &Et_even_sum,
20  std::vector<int> &Et_odd_sum,
21  std::vector<int> &fgvb,
22  std::vector<int> &sfgvb,
23  int eTTotShift,
24  std::vector<EcalTriggerPrimitiveSample> &out,
25  std::vector<EcalTriggerPrimitiveSample> &out2) {
26  // put TP-s in the output
27  // on request also in TcpFormat
28  // for famos version we have to write dummies except for the middle
29 
30  int myEt = 0;
31  if (famos_) {
32  for (unsigned int i = 0; i < out.size(); ++i) {
33  if (i == binOfMax_ - 1) {
34  myEt = Et_even_sum[i] >> eTTotShift;
35  if (myEt > 0x3ff)
36  myEt = 0x3ff;
37 
38  // badTTStatus_ ==0 if the TT works
39  // badTTStatus_ !=0 if there are some problems
40  int lut_out;
41  if (*badTTStatus_ != 0) {
42  lut_out = 0;
43  } else
44  lut_out = (lut_)[myEt];
45 
46  int ttFlag = (lut_out & 0x700) >> 8;
47  myEt = lut_out & 0xff;
48  out[i] = EcalTriggerPrimitiveSample(myEt, fgvb[0], sfgvb[0], ttFlag);
49  } else
51  }
52  } else {
53  for (unsigned int i = 0; i < Et_even_sum.size(); ++i) {
54  int myFgvb = fgvb[i];
55  int mysFgvb = sfgvb[i];
56  bool is_odd_larger = false;
57 
58  // Check if odd sum is larger than even sum, in case flag_EB_odd_even_tcp is used
59  if (Et_odd_sum[i] > Et_even_sum[i]) {
60  is_odd_larger = true;
61  }
62 
64  case 0: //output even sum
65  myEt = Et_even_sum[i];
66  break;
67  case 1: // output larger of odd and even
68  if (Et_odd_sum[i] > Et_even_sum[i]) {
69  myEt = Et_odd_sum[i];
70  } else {
71  myEt = Et_even_sum[i];
72  }
73  break;
74  case 2: // output even+odd
75  myEt = Et_even_sum[i] + Et_odd_sum[i];
76  break;
77  default:
78  // In case of unknown configuration switch to default
79  myEt = Et_even_sum[i];
80  break;
81  }
82 
83  // check TPmode config to decide to output the FGVB or the odd>even flag
84  int infobit1 = myFgvb;
86  infobit1 = is_odd_larger;
87 
88  if (myEt > 0xfff)
89  myEt = 0xfff;
90  myEt >>= eTTotShift;
91  if (myEt > 0x3ff)
92  myEt = 0x3ff;
93 
94  // Spike killer
95  if ((myEt > spikeZeroThresh_) && (mysFgvb == 0)) {
96  myEt = 0;
97  }
98 
99  int lut_out;
100  if (*badTTStatus_ != 0) {
101  lut_out = 0;
102  } else
103  lut_out = (lut_)[myEt];
104 
105  int ttFlag = (lut_out & 0x700) >> 8;
106  if (tcpFormat_) {
107  out2[i] = EcalTriggerPrimitiveSample(((ttFlag & 0x7) << 11) | ((infobit1 & 0x1) << 10) | (myEt & 0x3ff));
108  }
109  myEt = lut_out & 0xff;
110  out[i] = EcalTriggerPrimitiveSample(myEt, infobit1, mysFgvb, ttFlag);
111  }
112  }
113 }
114 
116  const EcalTPGLutGroup *ecaltpgLutGroup,
117  const EcalTPGLutIdMap *ecaltpgLut,
118  const EcalTPGTowerStatus *ecaltpgbadTT,
119  const EcalTPGSpike *ecaltpgSpike,
120  const EcalTPGTPMode *ecaltpgTPMode) {
121  // Get TP zeroing threshold - defaut to 1023 for old data (no record found or
122  // EE)
123  spikeZeroThresh_ = 1023;
124  if (ecaltpgSpike != nullptr) {
125  const EcalTPGSpike::EcalTPGSpikeMap &spikeMap = ecaltpgSpike->getMap();
126  EcalTPGSpike::EcalTPGSpikeMapIterator sit = spikeMap.find(towid);
127  if (sit != spikeMap.end()) {
128  spikeZeroThresh_ = sit->second;
129  }
130  }
131 
132  const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgLutGroup->getMap();
133  EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(towid);
134  if (it != groupmap.end()) {
135  uint32_t lutid = (*it).second;
136  const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut->getMap();
137  EcalTPGLutIdMap::EcalTPGLutMapItr itl = lutmap.find(lutid);
138  if (itl != lutmap.end()) {
139  lut_ = (*itl).second.getLut();
140  } else
141  edm::LogWarning("EcalTPG") << " could not find EcalTPGLutMap for " << lutid;
142 
143  } else
144  edm::LogWarning("EcalTPG") << " could not find EcalTPGFineGrainTowerEEMap for " << towid;
145 
146  const EcalTPGTowerStatusMap &badTTMap = ecaltpgbadTT->getMap();
147  EcalTPGTowerStatusMapIterator itbadTT = badTTMap.find(towid);
148  if (itbadTT != badTTMap.end()) {
149  badTTStatus_ = &(*itbadTT).second;
150  }
151 
152  ecaltpgTPMode_ = ecaltpgTPMode;
153 }
const uint16_t * badTTStatus_
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
uint16_t EBFenixTcpInfobit1
Definition: EcalTPGTPMode.h:28
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
const EcalTPGLutMap & getMap() const
const unsigned int * lut_
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike, const EcalTPGTPMode *ecaltpgTPMode)
uint16_t EBFenixTcpOutput
Definition: EcalTPGTPMode.h:27
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
std::map< uint32_t, uint16_t >::const_iterator EcalTPGSpikeMapIterator
Definition: EcalTPGSpike.h:12
const EcalTPGTPMode * ecaltpgTPMode_
virtual std::vector< int > process(const std::vector< int > &, const std::vector< int > &)
#define debug
Definition: HDRShower.cc:19
const std::map< uint32_t, uint16_t > & getMap() const
Definition: EcalTPGSpike.h:18
EcalFenixTcpFormatEB(bool tccFormat, bool debug, bool famos, int binOfMax)
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
std::map< uint32_t, uint16_t > EcalTPGSpikeMap
Definition: EcalTPGSpike.h:11
const std::map< uint32_t, uint16_t > & getMap() const
Log< level::Warning, false > LogWarning
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr