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 }
EcalEBFenixTcpFormat::famos_
bool famos_
Definition: EcalEBFenixTcpFormat.h:47
EcalTPGTowerStatus::getMap
const std::map< uint32_t, uint16_t > & getMap() const
Definition: EcalTPGTowerStatus.h:15
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
EcalTPGLutIdMap::EcalTPGLutMap
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
Definition: EcalTPGLutIdMap.h:12
EcalTPGGroups::EcalTPGGroupsMapItr
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:20
EcalEBFenixTcpFormat::binOfMax_
unsigned int binOfMax_
Definition: EcalEBFenixTcpFormat.h:48
EcalTPGSpike
Definition: EcalTPGSpike.h:9
EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
Definition: EcalTPGTowerStatus.h:25
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
EcalEBTriggerPrimitiveSample
Definition: EcalEBTriggerPrimitiveSample.h:12
EcalTPGSpike.h
EcalTPGSpike::getMap
const std::map< uint32_t, uint16_t > & getMap() const
Definition: EcalTPGSpike.h:18
EcalTPGLutIdMap.h
debug
#define debug
Definition: HDRShower.cc:19
EcalEBFenixTcpFormat.h
EcalTPGTowerStatusMap
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
Definition: EcalTPGTowerStatus.h:24
EcalEBFenixTcpFormat::EcalEBFenixTcpFormat
EcalEBFenixTcpFormat(bool tccFormat, bool debug, bool famos, int binOfMax)
Definition: EcalEBFenixTcpFormat.cc:11
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
EcalTPGLutGroup.h
EcalTPGGroups::getMap
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
EcalEBFenixTcpFormat::badTTStatus_
const uint16_t * badTTStatus_
Definition: EcalEBFenixTcpFormat.h:43
EcalEBFenixTcpFormat::setParameters
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike)
Definition: EcalEBFenixTcpFormat.cc:131
EcalTPGTowerStatus.h
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
std
Definition: JetResolutionObject.h:76
EcalEBFenixTcpFormat::tcpFormat_
bool tcpFormat_
Definition: EcalEBFenixTcpFormat.h:45
EcalEBFenixTcpFormat::~EcalEBFenixTcpFormat
virtual ~EcalEBFenixTcpFormat()
Definition: EcalEBFenixTcpFormat.cc:17
PointingDoubleMultiSkim_cfg.out2
out2
Definition: PointingDoubleMultiSkim_cfg.py:85
EcalEBFenixTcpFormat::process
void process(std::vector< int > &, std::vector< int > &)
Definition: EcalEBFenixTcpFormat.cc:19
EcalTPGLutIdMap::EcalTPGLutMapItr
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
Definition: EcalTPGLutIdMap.h:13
EcalEBFenixTcpFormat::spikeZeroThresh_
uint16_t spikeZeroThresh_
Definition: EcalEBFenixTcpFormat.h:49
EcalEBFenixTcpFormat::lut_
const unsigned int * lut_
Definition: EcalEBFenixTcpFormat.h:42
EcalEBFenixTcpFormat::status_
uint16_t status_
Definition: EcalEBFenixTcpFormat.h:44
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
EcalTPGSpike::EcalTPGSpikeMapIterator
std::map< uint32_t, uint16_t >::const_iterator EcalTPGSpikeMapIterator
Definition: EcalTPGSpike.h:12
EcalTPGLutIdMap::getMap
const EcalTPGLutMap & getMap() const
Definition: EcalTPGLutIdMap.h:18
EcalTPGSpike::EcalTPGSpikeMap
std::map< uint32_t, uint16_t > EcalTPGSpikeMap
Definition: EcalTPGSpike.h:11
EcalTPGGroups::EcalTPGGroupsMap
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:19