CMS 3D CMS Logo

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