CMS 3D CMS Logo

EcalEBFenixTcpFormat.cc
Go to the documentation of this file.
7 #include <iostream>
8 
9 using namespace std;
10 
11 EcalEBFenixTcpFormat::EcalEBFenixTcpFormat(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 EcalEBFenixTcpFormat::process(std::vector<int> &Etin, std::vector<int> &Etout) {
20  // put TP-s in the output
21  // on request also in TcpFormat
22  // for famos version we have to write dummies except for the middle
23  // std::cout << " EcalEBFenixTcpFormat::process(... Etout size " << Etout.size() << " Et size " << Etin.size() << std::endl;
24 
25  int myEt;
26  int eTTotShift = 2;
27 
28  // std::cout << " FenixTcpFormatter Etin size() " << Etin.size() << std::endl;
29  for (unsigned int i = 0; i < Etin.size(); ++i) {
30  // bug fix 091009:
31  myEt = Etin[i];
32  //std::cout << " Et " << myEt << std::endl;
33  if (myEt > 0xfff)
34  myEt = 0xfff;
35 
36  myEt >>= eTTotShift;
37  //std::cout << " after myEt>>= eTTotShift " << myEt << std::endl;
38  if (myEt > 0x3ff)
39  myEt = 0x3ff;
40 
41  //myEt = lut_out & 0xff ;
42  // the lut is foreseen for 8 bits. Useless to use it here
43 
44  // stay with 10 bits
45  Etout[i] = myEt;
46  }
47 }
48 
49 void EcalEBFenixTcpFormat::process(std::vector<int> &Et,
50  std::vector<int> &fgvb,
51  std::vector<int> &sfgvb,
52  int eTTotShift,
53  std::vector<EcalEBTriggerPrimitiveSample> &out,
54  std::vector<EcalEBTriggerPrimitiveSample> &out2,
55  bool isInInnerRings) {
56  // put TP-s in the output
57  // on request also in TcpFormat
58  // for famos version we have to write dummies except for the middle
59  //std::cout << " EcalEBFenixTcpFormat::process(... out size " << out.size() << " Et size " << Et.size() << " Et[0] " << Et[0] << std::endl;
60 
61  int myEt;
62  if (famos_) {
63  for (unsigned int i = 0; i < out.size(); ++i) {
64  if (i == binOfMax_ - 1) {
65  myEt = Et[0] >> eTTotShift;
66  if (myEt > 0x3ff)
67  myEt = 0x3ff;
68  if (isInInnerRings)
69  myEt = myEt / 2;
70 
71  // badTTStatus_ ==0 if the TT works
72  // badTTStatus_ !=0 if there are some problems
73  int lut_out;
74  if (*badTTStatus_ != 0) {
75  lut_out = 0;
76  } else
77  lut_out = (lut_)[myEt];
78 
79  // int ttFlag = (lut_out & 0x700) >> 8 ;
80  myEt = lut_out & 0xff;
81  // out[i]=EcalEBTriggerPrimitiveSample( myEt,fgvb[0],sfgvb[0],ttFlag);
83  } else
85  }
86  } else {
87  //std::cout << " FenixTcpFormatter et.size() " << Et.size() << std::endl;
88  for (unsigned int i = 0; i < Et.size(); ++i) {
89  //int myFgvb=fgvb[i];
90  int mysFgvb = sfgvb[i];
91  //myEt=Et[i]>>eTTotShift;
92  //if (myEt>0x3ff) myEt=0x3ff ;
93  //if (isInInnerRings) myEt = myEt /2 ;
94 
95  // bug fix 091009:
96  myEt = Et[i];
97  //std::cout << " Et " << myEt << std::endl;
98  if (myEt > 0xfff)
99  myEt = 0xfff;
100  if (isInInnerRings)
101  myEt = myEt / 2;
102  myEt >>= eTTotShift;
103  //std::cout << " after myEt>>= eTTotShift " << myEt << std::endl;
104  if (myEt > 0x3ff)
105  myEt = 0x3ff;
106 
107  // Spike killing
108  if ((myEt > spikeZeroThresh_) && (mysFgvb == 0)) {
109  myEt = 0;
110  }
111 
112  int lut_out;
113  if (*badTTStatus_ != 0) {
114  lut_out = 0;
115  } else
116  lut_out = (lut_)[myEt];
117 
118  //int ttFlag = (lut_out & 0x700) >> 8 ;
119  if (tcpFormat_) {
120  out2[i] = EcalEBTriggerPrimitiveSample(myEt & 0x3ff);
121  //std::cout << " FenixTcpFormatter final et " << (myEt & 0x3ff) << std::endl;
122  }
123 
124  myEt = lut_out & 0xff;
125  //std::cout << " FenixTcpFormatter final lut_out " << lut_out << " 0xff " << 0xff << " et " << myEt << std::endl;
127  }
128  }
129 }
130 
132  const EcalTPGLutGroup *ecaltpgLutGroup,
133  const EcalTPGLutIdMap *ecaltpgLut,
134  const EcalTPGTowerStatus *ecaltpgbadTT,
135  const EcalTPGSpike *ecaltpgSpike) {
136  // Get TP zeroing threshold - defaut to 1023 for old data (no record found or EE)
137  spikeZeroThresh_ = 1023;
138  if (ecaltpgSpike != nullptr) {
139  const EcalTPGSpike::EcalTPGSpikeMap &spikeMap = ecaltpgSpike->getMap();
140  EcalTPGSpike::EcalTPGSpikeMapIterator sit = spikeMap.find(towid);
141  if (sit != spikeMap.end()) {
142  spikeZeroThresh_ = sit->second;
143  }
144  }
145 
146  const EcalTPGGroups::EcalTPGGroupsMap &groupmap = ecaltpgLutGroup->getMap();
147  EcalTPGGroups::EcalTPGGroupsMapItr it = groupmap.find(towid);
148  if (it != groupmap.end()) {
149  uint32_t lutid = (*it).second;
150  const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut->getMap();
151  EcalTPGLutIdMap::EcalTPGLutMapItr itl = lutmap.find(lutid);
152  if (itl != lutmap.end()) {
153  lut_ = (*itl).second.getLut();
154  //std::cout << " FenixTcpFormatter lut_ " << std::dec<<lut_ << std::endl;
155  } else
156  edm::LogWarning("EcalTPG") << " could not find EcalTPGLutMap for " << lutid;
157 
158  } else
159  edm::LogWarning("EcalTPG") << " could not find EcalTPGFineGrainTowerEEMap for " << towid;
160 
161  const EcalTPGTowerStatusMap &badTTMap = ecaltpgbadTT->getMap();
162  EcalTPGTowerStatusMapIterator itbadTT = badTTMap.find(towid);
163  if (itbadTT != badTTMap.end()) {
164  badTTStatus_ = &(*itbadTT).second;
165  }
166 }
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
const EcalTPGLutMap & getMap() const
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
const unsigned int * lut_
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
const uint16_t * badTTStatus_
std::map< uint32_t, uint16_t >::const_iterator EcalTPGSpikeMapIterator
Definition: EcalTPGSpike.h:12
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike)
#define debug
Definition: HDRShower.cc:19
const std::map< uint32_t, uint16_t > & getMap() const
Definition: EcalTPGSpike.h:18
EcalEBFenixTcpFormat(bool tccFormat, bool debug, bool famos, int binOfMax)
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
void process(std::vector< int > &, std::vector< int > &)
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