CMS 3D CMS Logo

EcalFenixTcpFormat.cc
Go to the documentation of this file.
7 #include <iostream>
8 
9 using namespace std;
10 
11 EcalFenixTcpFormat::EcalFenixTcpFormat(bool tcpFormat, bool debug, bool famos,
12  int binOfMax)
13  : tcpFormat_(tcpFormat), debug_(debug), famos_(famos), binOfMax_(binOfMax) {
14  status_ = 0;
16 }
17 
19 
20 void EcalFenixTcpFormat::process(std::vector<int> &Et, std::vector<int> &fgvb,
21  std::vector<int> &sfgvb, int eTTotShift,
22  std::vector<EcalTriggerPrimitiveSample> &out,
23  std::vector<EcalTriggerPrimitiveSample> &out2,
24  bool isInInnerRings) {
25  // put TP-s in the output
26  // on request also in TcpFormat
27  // for famos version we have to write dummies except for the middle
28 
29  int myEt;
30  if (famos_) {
31  for (unsigned int i = 0; i < out.size(); ++i) {
32  if (i == binOfMax_ - 1) {
33  myEt = Et[0] >> eTTotShift;
34  if (myEt > 0x3ff)
35  myEt = 0x3ff;
36  if (isInInnerRings)
37  myEt = myEt / 2;
38 
39  // badTTStatus_ ==0 if the TT works
40  // badTTStatus_ !=0 if there are some problems
41  int lut_out;
42  if (*badTTStatus_ != 0) {
43  lut_out = 0;
44  } else
45  lut_out = (lut_)[myEt];
46 
47  int ttFlag = (lut_out & 0x700) >> 8;
48  myEt = lut_out & 0xff;
49  out[i] = EcalTriggerPrimitiveSample(myEt, fgvb[0], sfgvb[0], ttFlag);
50  } else
52  }
53  } else {
54  for (unsigned int i = 0; i < Et.size(); ++i) {
55  int myFgvb = fgvb[i];
56  int mysFgvb = sfgvb[i];
57  // myEt=Et[i]>>eTTotShift;
58  // if (myEt>0x3ff) myEt=0x3ff ;
59  // if (isInInnerRings) myEt = myEt /2 ;
60 
61  // bug fix 091009:
62  myEt = Et[i];
63  if (myEt > 0xfff)
64  myEt = 0xfff;
65  if (isInInnerRings)
66  myEt = myEt / 2;
67  myEt >>= eTTotShift;
68  if (myEt > 0x3ff)
69  myEt = 0x3ff;
70 
71  // Spike killing
72  if ((myEt > spikeZeroThresh_) && (mysFgvb == 0)) {
73  myEt = 0;
74  }
75 
76  int lut_out;
77  if (*badTTStatus_ != 0) {
78  lut_out = 0;
79  } else
80  lut_out = (lut_)[myEt];
81 
82  int ttFlag = (lut_out & 0x700) >> 8;
83  if (tcpFormat_) {
85  ((ttFlag & 0x7) << 11) | ((myFgvb & 0x1) << 10) | (myEt & 0x3ff));
86  }
87  myEt = lut_out & 0xff;
88  out[i] = EcalTriggerPrimitiveSample(myEt, myFgvb, mysFgvb, ttFlag);
89  }
90  }
91 }
92 
93 void EcalFenixTcpFormat::setParameters(uint32_t towid,
94  const EcalTPGLutGroup *ecaltpgLutGroup,
95  const EcalTPGLutIdMap *ecaltpgLut,
96  const EcalTPGTowerStatus *ecaltpgbadTT,
97  const EcalTPGSpike *ecaltpgSpike) {
98  // Get TP zeroing threshold - defaut to 1023 for old data (no record found or
99  // EE)
100  spikeZeroThresh_ = 1023;
101  if (ecaltpgSpike != nullptr) {
102  const EcalTPGSpike::EcalTPGSpikeMap &spikeMap = ecaltpgSpike->getMap();
103  EcalTPGSpike::EcalTPGSpikeMapIterator sit = spikeMap.find(towid);
104  if (sit != spikeMap.end()) {
105  spikeZeroThresh_ = sit->second;
106  }
107  }
108 
109  const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgLutGroup->getMap();
110  EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(towid);
111  if (it != groupmap.end()) {
112  uint32_t lutid = (*it).second;
113  const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut->getMap();
114  EcalTPGLutIdMap::EcalTPGLutMapItr itl = lutmap.find(lutid);
115  if (itl != lutmap.end()) {
116  lut_ = (*itl).second.getLut();
117  } else
118  edm::LogWarning("EcalTPG")
119  << " could not find EcalTPGLutMap for " << lutid;
120 
121  } else
122  edm::LogWarning("EcalTPG")
123  << " could not find EcalTPGFineGrainTowerEEMap for " << towid;
124 
125  const EcalTPGTowerStatusMap &badTTMap = ecaltpgbadTT->getMap();
126  EcalTPGTowerStatusMapIterator itbadTT = badTTMap.find(towid);
127  if (itbadTT != badTTMap.end()) {
128  badTTStatus_ = &(*itbadTT).second;
129  }
130 }
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
void process(std::vector< int > &, std::vector< int > &)
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:28
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:23
std::map< uint32_t, uint16_t >::const_iterator EcalTPGSpikeMapIterator
Definition: EcalTPGSpike.h:13
const EcalTPGLutMap & getMap() const
const uint16_t * badTTStatus_
#define debug
Definition: HDRShower.cc:19
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike)
const std::map< uint32_t, uint16_t > & getMap() const
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
std::map< uint32_t, uint16_t > EcalTPGSpikeMap
Definition: EcalTPGSpike.h:12
EcalFenixTcpFormat(bool tccFormat, bool debug, bool famos, int binOfMax)
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:22
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
const std::map< uint32_t, uint16_t > & getMap() const
Definition: EcalTPGSpike.h:19
const unsigned int * lut_