CMS 3D CMS Logo

DCCEventBlock.cc
Go to the documentation of this file.
9 #include <sys/time.h>
10 
11 #include <iomanip>
12 #include <sstream>
13 
16  bool hU,
17  bool srpU,
18  bool tccU,
19  bool feU,
20  bool memU,
21  bool forceToKeepFRdata)
22  : unpacker_(u),
23  mapper_(m),
24  headerUnpacking_(hU),
25  srpUnpacking_(srpU),
26  tccUnpacking_(tccU),
27  feUnpacking_(feU),
28  memUnpacking_(memU),
29  forceToKeepFRdata_(forceToKeepFRdata) {
30  // Build a Mem Unpacker Block
31  memBlock_ = new DCCMemBlock(u, m, this);
32 
33  // setup and initialize ch status vectors
34  for (int feChannel = 1; feChannel <= 70; feChannel++) {
35  feChStatus_.push_back(0);
36  hlt_.push_back(1);
37  }
38  for (int tccChannel = 1; tccChannel <= 4; tccChannel++) {
39  tccChStatus_.push_back(0);
40  }
41 
42  // setup and initialize sync vectors
43  for (int feChannel = 1; feChannel <= 70; feChannel++) {
44  feBx_.push_back(-1);
45  feLv1_.push_back(-1);
46  }
47  for (int tccChannel = 1; tccChannel <= 4; tccChannel++) {
48  tccBx_.push_back(-1);
49  tccLv1_.push_back(-1);
50  }
51  srpBx_ = -1;
52  srpLv1_ = -1;
53 }
54 
56  // reset sync vectors
57  for (int feChannel = 1; feChannel <= 70; feChannel++) {
58  feBx_[feChannel - 1] = -1;
59  feLv1_[feChannel - 1] = -1;
60  }
61  for (int tccChannel = 1; tccChannel <= 4; tccChannel++) {
62  tccBx_[tccChannel - 1] = -1;
63  tccLv1_[tccChannel - 1] = -1;
64  }
65  srpBx_ = -1;
66  srpLv1_ = -1;
67 }
68 
74 }
75 
77 
78 unsigned int DCCEventBlock::next_tower_search(const unsigned int current_tower_id) {
79  const uint64_t* const prev_data = data_;
80  const unsigned int prev_dwToEnd = dwToEnd_;
81 
82  // expected LV1, BX, #TS
83  const uint32_t lv1 = ((l1_ - 1) & 0xFFF);
84  const uint32_t bx = (bx_ != 3564) ? bx_ : 0;
85  const uint32_t ts = mapper_->numbXtalTSamples();
86 
87  // construct tower header and mask
88  const uint64_t s_hi = 0xC0000000 + lv1;
89  const uint64_t s_lo = 0xC0000000 + (bx << 16) + (ts << 8);
90 
91  const uint64_t sign = (s_hi << 32) + s_lo;
92  const uint64_t mask = 0xC0001FFFDFFF7F00;
93 
94  // step forward to skip header word of problematic tower
95  data_++;
96  dwToEnd_--;
97 
98  //std::cerr << "header of bad tower = " << current_tower_id << " #" << dwToEnd_ << " 0x" << std::hex << *data_ << std::dec << std::endl;
99  //std::cerr << "mask and sign = 0x" << std::hex << mask << " 0x" << sign << std::dec << std::endl;
100 
101  // navigate through tower data blocks to find tower block header
102  while (dwToEnd_ > 0) {
103  data_++;
104  dwToEnd_--;
105 
106  //std::cerr << current_tower_id << " #" << dwToEnd_ << " 0x" << std::hex << *data_ << " 0x" << (*data_ & mask) << std::dec << std::endl;
107 
108  if ((*data_ & mask) == sign) {
109  const unsigned int next_tower_id = (*data_) & 0xFF;
110 
111  if (next_tower_id <= current_tower_id)
112  continue;
113 
114  //std::cerr << "next tower = " << next_tower_id << std::endl;
115 
116  // step back one word of the next tower header
117  data_--;
118  dwToEnd_++;
119 
120  return next_tower_id;
121  }
122  }
123 
124  // can't find next tower header
125  // restore data pointer
126  data_ = prev_data;
127  dwToEnd_ = prev_dwToEnd;
128  return 1000;
129 }
130 
133 
138 }
139 
141  EcalDCCHeaderBlock theDCCheader;
142 
143  // container for fed_id (601-654 for ECAL)
144  theDCCheader.setFedId(fedId_);
145 
146  // this needs to be migrated to the ECAL mapping package
147 
148  // dccId is number internal to ECAL running 1.. 54.
149  // convention is that dccId = (fed_id - 600)
150  int dccId = mapper_->getActiveSM();
151  // DCCHeaders follow the same convenction
152  theDCCheader.setId(dccId);
153 
154  theDCCheader.setRunNumber(runNumber_);
155  theDCCheader.setBasicTriggerType(triggerType_);
156  theDCCheader.setLV1(l1_);
157  theDCCheader.setBX(bx_);
158  theDCCheader.setOrbit(orbitCounter_);
159  theDCCheader.setErrors(dccErrors_);
160  theDCCheader.setSelectiveReadout(sr_);
161  theDCCheader.setZeroSuppression(zs_);
162  theDCCheader.setTestZeroSuppression(tzs_);
163  theDCCheader.setSrpStatus(srChStatus_);
164  theDCCheader.setTccStatus(tccChStatus_);
165  theDCCheader.setFEStatus(feChStatus_);
166 
167  theDCCheader.setSRPLv1(srpLv1_);
168  theDCCheader.setSRPBx(srpBx_);
169  theDCCheader.setFELv1(feLv1_);
170  theDCCheader.setFEBx(feBx_);
171  theDCCheader.setTCCLv1(tccLv1_);
172  theDCCheader.setTCCBx(tccBx_);
173 
174  EcalDCCHeaderRuntypeDecoder theRuntypeDecoder;
175  unsigned int DCCruntype = runType_;
176  unsigned int DCCdetTriggerType = detailedTriggerType_;
177  theRuntypeDecoder.Decode(triggerType_, DCCdetTriggerType, DCCruntype, &theDCCheader);
178 
179  // Add Header to collection
180  (*dccHeaders_)->push_back(theDCCheader);
181 }
182 
183 void DCCEventBlock::display(std::ostream& o) {
184  o << "\n Unpacked Info for DCC Event Class"
185  << "\n DW1 ============================="
186  << "\n Fed Id " << fedId_ << "\n Bx " << bx_ << "\n L1 " << l1_ << "\n Trigger Type " << triggerType_
187  << "\n DW2 ============================="
188  << "\n Length " << blockLength_ << "\n Dcc errors " << dccErrors_ << "\n Run number " << runNumber_
189  << "\n DW3 ============================="
190  << "\n SR " << sr_ << "\n ZS " << zs_ << "\n TZS " << tzs_ << "\n SRStatus " << srChStatus_;
191 
192  std::vector<short>::iterator it;
193  int i(0), k(0);
194  for (it = tccChStatus_.begin(); it != tccChStatus_.end(); it++, i++) {
195  o << "\n TCCStatus#" << i << " " << (*it);
196  }
197 
198  i = 0;
199  for (it = feChStatus_.begin(); it != feChStatus_.end(); it++, i++) {
200  if (!(i % 14)) {
201  o << "\n DW" << (k + 3) << " =============================";
202  k++;
203  }
204  o << "\n FEStatus#" << i << " " << (*it);
205  }
206 
207  o << "\n";
208 }
209 
211  if (towerBlock_) {
212  delete towerBlock_;
213  }
214  if (tccBlock_) {
215  delete tccBlock_;
216  }
217  if (memBlock_) {
218  delete memBlock_;
219  }
220  if (srpBlock_) {
221  delete srpBlock_;
222  }
223 }
224 
225 // -----------------------------------------------------------------------
226 // sync checking
227 
228 bool isSynced(const unsigned int dccBx,
229  const unsigned int bx,
230  const unsigned int dccL1,
231  const unsigned int l1,
232  const BlockType type,
233  const unsigned int fov) {
234  // avoid checking for MC until EcalDigiToRaw bugfixed
235  // and to guarantee backward compatibility on RAW data
236  if (fov < 1)
237  return true;
238  // check the BX sync according the following rule:
239  //
240  // FE Block MEM Block TCC Block SRP Block DCC
241  // ------------------------------------------------------------------
242  // fe_bx == mem_bx == 0 tcc_bx == srp_bx == DCC_bx == 3564
243  // fe_bx == mem_bx == tcc_bx == srp_bx == DCC_bx != 3564
244 
245  const bool bxSynced = ((type == FE_MEM) && (bx == 0) && (dccBx == 3564)) ||
246  ((type == FE_MEM) && (bx == dccBx) && (dccBx != 3564)) || ((type == TCC_SRP) && (bx == dccBx));
247 
248  // check the L1A sync:
249  //
250  // L1A counter relation is valid modulo 0xFFF:
251  // fe_l1 == mem_l1 == (DCC_l1-1) & 0xFFF
252  // tcc_l1 == srp_l1 == DCC_l1 & 0xFFF
253 
254  const bool l1Synced =
255  ((type == FE_MEM) && (l1 == ((dccL1 - 1) & 0xFFF))) || ((type == TCC_SRP) && (l1 == (dccL1 & 0xFFF)));
256 
257  return (bxSynced && l1Synced);
258 }
DCCEventBlock::fedId_
unsigned int fedId_
Definition: DCCEventBlock.h:102
DCCEventBlock::display
void display(std::ostream &o)
Definition: DCCEventBlock.cc:183
EcalDCCHeaderBlock::setTCCBx
void setTCCBx(const std::vector< short > &tccBx)
Definition: EcalDCCHeaderBlock.h:112
DCCDataUnpacker.h
mps_fire.i
i
Definition: mps_fire.py:428
EcalDCCHeaderBlock::setSRPBx
void setSRPBx(const short &srpBx)
Definition: EcalDCCHeaderBlock.h:113
DCCEventBlock::triggerType_
unsigned int triggerType_
Definition: DCCEventBlock.h:105
DCCEventBlock::tccBlock_
DCCTCCBlock * tccBlock_
Definition: DCCEventBlock.h:120
EcalDCCHeaderBlock::setBX
void setBX(const int &BX)
Definition: EcalDCCHeaderBlock.h:93
DCCEventBlock::srpLv1_
short srpLv1_
Definition: DCCEventBlock.h:96
BlockType
BlockType
Definition: DCCEventBlock.h:138
EcalDCCHeaderBlock::setRunNumber
void setRunNumber(const int &run)
Definition: EcalDCCHeaderBlock.h:91
DCCEventBlock::hlt_
std::vector< short > hlt_
Definition: DCCEventBlock.h:90
EcalDCCHeaderBlock::setFEStatus
void setFEStatus(const std::vector< short > &feStatus)
Definition: EcalDCCHeaderBlock.h:109
DCCEventBlock::enableSyncChecks
void enableSyncChecks()
Definition: DCCEventBlock.cc:69
DCCEventBlock::addHeaderToCollection
void addHeaderToCollection()
Definition: DCCEventBlock.cc:140
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
EcalElectronicsMapper::getActiveSM
unsigned int getActiveSM()
Definition: EcalElectronicsMapper.h:128
EcalDCCHeaderBlock::setZeroSuppression
void setZeroSuppression(const bool &zeroSuppression)
Definition: EcalDCCHeaderBlock.h:104
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
DCCDataUnpacker
Definition: DCCDataUnpacker.h:49
EcalElectronicsMapper::numbXtalTSamples
unsigned int numbXtalTSamples()
Definition: EcalElectronicsMapper.h:130
EcalDCCHeaderBlock::setSRPLv1
void setSRPLv1(const short &srpLv1)
Definition: EcalDCCHeaderBlock.h:117
DCCEventBlock::unpacker_
DCCDataUnpacker * unpacker_
Definition: DCCEventBlock.h:81
DCCSRPBlock.h
DCCEventBlock::towerBlock_
DCCFEBlock * towerBlock_
Definition: DCCEventBlock.h:119
DCCTCCBlock.h
isSynced
bool isSynced(const unsigned int dccBx, const unsigned int bx, const unsigned int dccL1, const unsigned int l1, const BlockType type, const unsigned int fov)
Definition: DCCEventBlock.cc:228
EcalElectronicsMapper.h
DCCEventBlock::bx_
unsigned int bx_
Definition: DCCEventBlock.h:103
DCCEventBlock::detailedTriggerType_
unsigned int detailedTriggerType_
Definition: DCCEventBlock.h:111
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
EcalDCCHeaderBlock::setBasicTriggerType
void setBasicTriggerType(const short &triggerType)
Definition: EcalDCCHeaderBlock.h:98
EcalDCCHeaderBlock::setLV1
void setLV1(const int &LV1)
Definition: EcalDCCHeaderBlock.h:92
EcalDCCHeaderBlock::setOrbit
void setOrbit(const int &orbit)
Definition: EcalDCCHeaderBlock.h:94
DCCEventBlock::runNumber_
unsigned int runNumber_
Definition: DCCEventBlock.h:109
DCCFEBlock::updateCollectors
void updateCollectors() override
Definition: DCCFEBlock.cc:16
DCCEventBlock::tccBx_
std::vector< short > tccBx_
Definition: DCCEventBlock.h:95
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
EcalDCCHeaderBlock::setTccStatus
void setTccStatus(const std::vector< short > &tccStatus)
Definition: EcalDCCHeaderBlock.h:107
DCCFEBlock.h
DCCEventBlock::bx
unsigned int bx()
Definition: DCCEventBlock.h:58
DCCEventBlock::feLv1_
std::vector< short > feLv1_
Definition: DCCEventBlock.h:92
DCCEventBlock::feBx_
std::vector< short > feBx_
Definition: DCCEventBlock.h:93
FE_MEM
Definition: DCCEventBlock.h:138
DCCEventBlock::updateCollectors
void updateCollectors()
Definition: DCCEventBlock.cc:131
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DCCEventBlock::srpBlock_
DCCSRPBlock * srpBlock_
Definition: DCCEventBlock.h:122
DCCMemBlock
Definition: DCCMemBlock.h:34
DCCEventBlock::dwToEnd_
unsigned int dwToEnd_
Definition: DCCEventBlock.h:84
DCCEventBlock::memBlock_
DCCMemBlock * memBlock_
Definition: DCCEventBlock.h:121
DCCDataUnpacker::dccHeadersCollection
std::unique_ptr< EcalRawDataCollection > * dccHeadersCollection()
Definition: DCCDataUnpacker.h:130
DCCEventBlock::dccErrors_
unsigned int dccErrors_
Definition: DCCEventBlock.h:108
DCCEventBlock.h
EcalDCCHeaderRuntypeDecoder.h
DCCEventBlock::data_
const uint64_t * data_
Definition: DCCEventBlock.h:82
EcalDCCHeaderBlock::setSelectiveReadout
void setSelectiveReadout(const bool &selectiveReadout)
Definition: EcalDCCHeaderBlock.h:103
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
DCCEventBlock::dccHeaders_
std::unique_ptr< EcalRawDataCollection > * dccHeaders_
Definition: DCCEventBlock.h:132
DCCEventBlock::DCCEventBlock
DCCEventBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, bool hU, bool srpU, bool tccU, bool feU, bool memU, bool forceToKeepFRdata)
Definition: DCCEventBlock.cc:14
EcalDCCHeaderBlock::setFedId
void setFedId(const int &fedId)
Definition: EcalDCCHeaderBlock.h:87
TCC_SRP
Definition: DCCEventBlock.h:138
DCCEventBlock::feChStatus_
std::vector< short > feChStatus_
Definition: DCCEventBlock.h:88
DCCEventBlock::tzs_
unsigned int tzs_
Definition: DCCEventBlock.h:117
DCCEventBlock::tccLv1_
std::vector< short > tccLv1_
Definition: DCCEventBlock.h:94
DCCEventBlock::blockLength_
unsigned int blockLength_
Definition: DCCEventBlock.h:107
EcalDCCHeaderBlock
Definition: EcalDCCHeaderBlock.h:15
EcalDCCHeaderBlock::setTestZeroSuppression
void setTestZeroSuppression(const bool &testZeroSuppression)
Definition: EcalDCCHeaderBlock.h:105
EcalDCCHeaderBlock::setId
void setId(const int &dccId)
Definition: EcalDCCHeaderBlock.h:86
EcalElectronicsMapper
Definition: EcalElectronicsMapper.h:36
EcalDCCHeaderBlock::setTCCLv1
void setTCCLv1(const std::vector< short > &tccLv1)
Definition: EcalDCCHeaderBlock.h:116
DCCEventBlock::sr_
unsigned int sr_
Definition: DCCEventBlock.h:115
DCCEventBlock::srpBx_
short srpBx_
Definition: DCCEventBlock.h:97
DCCMemBlock::updateCollectors
void updateCollectors() override
Definition: DCCMemBlock.cc:26
EcalDCCHeaderRuntypeDecoder::Decode
bool Decode(unsigned long TrTy, unsigned long detTrTy, unsigned long runType, EcalDCCHeaderBlock *theHeader)
Definition: EcalDCCHeaderRuntypeDecoder.cc:11
DCCMemBlock.h
DCCEventBlock::runType_
unsigned int runType_
Definition: DCCEventBlock.h:110
DCCEventBlock::reset
void reset()
Definition: DCCEventBlock.cc:55
DCCEventBlock::orbitCounter_
unsigned int orbitCounter_
Definition: DCCEventBlock.h:113
DCCDataBlockPrototype::updateCollectors
virtual void updateCollectors()
Definition: DCCDataBlockPrototype.h:42
EcalDCCHeaderBlock::setFEBx
void setFEBx(const std::vector< short > &feBx)
Definition: EcalDCCHeaderBlock.h:111
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
DCCDataBlockPrototype::enableSyncChecks
void enableSyncChecks()
Definition: DCCDataBlockPrototype.h:46
DCCEventBlock::~DCCEventBlock
virtual ~DCCEventBlock()
Definition: DCCEventBlock.cc:210
EcalDCCHeaderBlock::setErrors
void setErrors(const int &dccErrors)
Definition: EcalDCCHeaderBlock.h:89
EcalDCCHeaderBlock::setSrpStatus
void setSrpStatus(const short &srpStatus)
Definition: EcalDCCHeaderBlock.h:106
DCCEventBlock::tccChStatus_
std::vector< short > tccChStatus_
Definition: DCCEventBlock.h:89
EcalDCCHeaderBlock::setFELv1
void setFELv1(const std::vector< short > &feLv1)
Definition: EcalDCCHeaderBlock.h:115
DCCEventBlock::zs_
unsigned int zs_
Definition: DCCEventBlock.h:116
DCCEventBlock::next_tower_search
unsigned int next_tower_search(const unsigned int current_tower_id)
Definition: DCCEventBlock.cc:78
EcalDCCHeaderRuntypeDecoder
Definition: EcalDCCHeaderRuntypeDecoder.h:8
DCCEventBlock::l1_
unsigned int l1_
Definition: DCCEventBlock.h:104
DCCFEBlock::enableFeIdChecks
void enableFeIdChecks()
Definition: DCCFEBlock.h:30
DCCEventBlock::enableFeIdChecks
void enableFeIdChecks()
Definition: DCCEventBlock.cc:76
DCCEventBlock::srChStatus_
unsigned int srChStatus_
Definition: DCCEventBlock.h:99
DCCEventBlock::mapper_
EcalElectronicsMapper * mapper_
Definition: DCCEventBlock.h:123
ecaldqm::dccId
unsigned dccId(DetId const &)
Definition: EcalDQMCommonUtils.cc:16