CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,int binOfMax)
12  : tcpFormat_(tcpFormat),debug_(debug),famos_(famos),binOfMax_(binOfMax)
13 {
14  status_=0;
16 }
17 
19 }
20 
21 
22 void EcalFenixTcpFormat::process(std::vector<int> &Et, std::vector<int> &fgvb,
23  std::vector<int> &sfgvb,int eTTotShift,
24  std::vector<EcalTriggerPrimitiveSample> & out,
25  std::vector<EcalTriggerPrimitiveSample> & out2, bool isInInnerRings){
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;
31  if (famos_) {
32  for (unsigned int i=0; i<out.size();++i) {
33  if (i==binOfMax_-1) {
34  myEt=Et[0]>>eTTotShift;
35  if (myEt>0x3ff) myEt=0x3ff ;
36  if (isInInnerRings) myEt = myEt /2 ;
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  }
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  }
51  else out[i]=EcalTriggerPrimitiveSample( );
52  }
53  }
54  else {
55  for (unsigned int i=0; i<Et.size();++i) {
56  int myFgvb=fgvb[i];
57  int mysFgvb=sfgvb[i];
58  //myEt=Et[i]>>eTTotShift;
59  //if (myEt>0x3ff) myEt=0x3ff ;
60  //if (isInInnerRings) myEt = myEt /2 ;
61 
62  // bug fix 091009:
63  myEt=Et[i];
64  if (myEt>0xfff)
65  myEt=0xfff ;
66  if (isInInnerRings)
67  myEt = myEt /2 ;
68  myEt >>= eTTotShift ;
69  if (myEt>0x3ff) myEt=0x3ff ;
70 
71  // Spike killing
72  if((myEt > spikeZeroThresh_) && (mysFgvb == 0))
73  {
74  myEt = 0;
75  }
76 
77  int lut_out;
78  if (*badTTStatus_!=0){
79  lut_out = 0;
80  }
81  else
82  lut_out = (lut_)[myEt] ;
83 
84  int ttFlag = (lut_out & 0x700) >> 8 ;
85  if (tcpFormat_) {
86  out2[i]=EcalTriggerPrimitiveSample( ((ttFlag&0x7)<<11) | ((myFgvb & 0x1)<<10) | (myEt & 0x3ff));
87  }
88  myEt = lut_out & 0xff ;
89  out[i]=EcalTriggerPrimitiveSample( myEt,myFgvb,mysFgvb,ttFlag);
90  }
91  }
92 }
93 
94 void EcalFenixTcpFormat::setParameters(uint32_t towid,const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT,const EcalTPGSpike * ecaltpgSpike)
95 {
96  // Get TP zeroing threshold - defaut to 1023 for old data (no record found or EE)
97  spikeZeroThresh_ = 1023;
98  if(ecaltpgSpike != 0)
99  {
100  const EcalTPGSpike::EcalTPGSpikeMap &spikeMap = ecaltpgSpike->getMap();
101  EcalTPGSpike:: EcalTPGSpikeMapIterator sit = spikeMap.find(towid);
102  if(sit != spikeMap.end())
103  {
104  spikeZeroThresh_ = sit->second;
105  }
106  }
107 
108  const EcalTPGGroups::EcalTPGGroupsMap & groupmap = ecaltpgLutGroup -> getMap();
109  EcalTPGGroups::EcalTPGGroupsMapItr it=groupmap.find(towid);
110  if (it!=groupmap.end()) {
111  uint32_t lutid=(*it).second;
112  const EcalTPGLutIdMap::EcalTPGLutMap &lutmap = ecaltpgLut-> getMap();
113  EcalTPGLutIdMap::EcalTPGLutMapItr itl=lutmap.find(lutid);
114  if (itl!=lutmap.end()) {
115  lut_=(*itl).second.getLut();
116  } else edm::LogWarning("EcalTPG")<<" could not find EcalTPGLutMap for "<<lutid;
117 
118  }
119  else edm::LogWarning("EcalTPG")<<" could not find EcalTPGFineGrainTowerEEMap for "<<towid;
120 
121  const EcalTPGTowerStatusMap & badTTMap = ecaltpgbadTT -> getMap();
122  EcalTPGTowerStatusMapIterator itbadTT = badTTMap.find(towid);
123  if (itbadTT!=badTTMap.end()) {
124  badTTStatus_=&(*itbadTT).second;
125  }
126 }
127 
std::map< uint32_t, uint16_t >::const_iterator EcalTPGTowerStatusMapIterator
int i
Definition: DBlmapReader.cc:9
std::map< uint32_t, uint16_t > EcalTPGTowerStatusMap
std::map< uint32_t, uint32_t >::const_iterator EcalTPGGroupsMapItr
Definition: EcalTPGGroups.h:21
const uint16_t * badTTStatus_
std::map< uint32_t, uint16_t >::const_iterator EcalTPGSpikeMapIterator
Definition: EcalTPGSpike.h:11
const unsigned int * lut_
tuple out
Definition: dbtoconf.py:99
void setParameters(uint32_t towid, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGTowerStatus *ecaltpgbadTT, const EcalTPGSpike *ecaltpgSpike)
std::map< uint32_t, EcalTPGLut > EcalTPGLutMap
std::map< uint32_t, uint16_t > EcalTPGSpikeMap
Definition: EcalTPGSpike.h:10
EcalFenixTcpFormat(bool tccFormat, bool debug, bool famos, int binOfMax)
#define debug
Definition: MEtoEDMFormat.h:34
virtual std::vector< int > process(std::vector< int >, std::vector< int >)
std::map< uint32_t, uint32_t > EcalTPGGroupsMap
Definition: EcalTPGGroups.h:20
std::map< uint32_t, EcalTPGLut >::const_iterator EcalTPGLutMapItr
const std::map< uint32_t, uint16_t > & getMap() const
Definition: EcalTPGSpike.h:17