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 }
EcalTPGTowerStatus::getMap
const std::map< uint32_t, uint16_t > & getMap() const
Definition: EcalTPGTowerStatus.h:15
mps_fire.i
i
Definition: mps_fire.py:428
EcalTPGTPMode
Definition: EcalTPGTPMode.h:12
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
EcalFenixTcpFormatEB::ecaltpgTPMode_
const EcalTPGTPMode * ecaltpgTPMode_
Definition: EcalFenixTcpFormatEB.h:55
EcalFenixTcpFormatEB::setParameters
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike, const EcalTPGTPMode *ecaltpgTPMode)
Definition: EcalFenixTcpFormatEB.cc:115
EcalTPGSpike
Definition: EcalTPGSpike.h:9
EcalTPGTowerStatusMapIterator
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
Definition: EcalTPGTowerStatus.h:25
EcalFenixTcpFormatEB::spikeZeroThresh_
uint16_t spikeZeroThresh_
Definition: EcalFenixTcpFormatEB.h:54
EcalTPGTPMode::EBFenixTcpOutput
uint16_t EBFenixTcpOutput
Definition: EcalTPGTPMode.h:27
EcalTPGTPMode::EBFenixTcpInfobit1
uint16_t EBFenixTcpInfobit1
Definition: EcalTPGTPMode.h:28
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalTPGLutGroup
Definition: EcalTPGLutGroup.h:13
EcalFenixTcpFormatEB::~EcalFenixTcpFormatEB
virtual ~EcalFenixTcpFormatEB()
Definition: EcalFenixTcpFormatEB.cc:17
EcalFenixTcpFormatEB.h
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
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
EcalFenixTcpFormatEB::badTTStatus_
const uint16_t * badTTStatus_
Definition: EcalFenixTcpFormatEB.h:48
EcalTPGTowerStatusMap
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
Definition: EcalTPGTowerStatus.h:24
EcalTPGTPMode.h
EcalFenixTcpFormatEB::status_
uint16_t status_
Definition: EcalFenixTcpFormatEB.h:49
EcalTPGLutIdMap
Definition: EcalTPGLutIdMap.h:10
EcalTPGLutGroup.h
EcalFenixTcpFormatEB::lut_
const unsigned int * lut_
Definition: EcalFenixTcpFormatEB.h:47
EcalFenixTcpFormatEB::famos_
bool famos_
Definition: EcalFenixTcpFormatEB.h:52
EcalFenixTcpFormatEB::process
virtual std::vector< int > process(const std::vector< int > &, const std::vector< int > &)
Definition: EcalFenixTcpFormatEB.h:28
EcalTPGGroups::getMap
const EcalTPGGroupsMap & getMap() const
Definition: EcalTPGGroups.h:25
EcalTPGTowerStatus.h
EcalFenixTcpFormatEB::EcalFenixTcpFormatEB
EcalFenixTcpFormatEB(bool tccFormat, bool debug, bool famos, int binOfMax)
Definition: EcalFenixTcpFormatEB.cc:11
EcalTPGTowerStatus
Definition: EcalTPGTowerStatus.h:9
std
Definition: JetResolutionObject.h:76
PointingDoubleMultiSkim_cfg.out2
out2
Definition: PointingDoubleMultiSkim_cfg.py:85
EcalTPGLutIdMap::EcalTPGLutMapItr
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
Definition: EcalTPGLutIdMap.h:13
EcalFenixTcpFormatEB::tcpFormat_
bool tcpFormat_
Definition: EcalFenixTcpFormatEB.h:50
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
EcalFenixTcpFormatEB::binOfMax_
unsigned int binOfMax_
Definition: EcalFenixTcpFormatEB.h:53
EcalTriggerPrimitiveSample
Definition: EcalTriggerPrimitiveSample.h:12
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