CMS 3D CMS Logo

DCCFEBlock.cc
Go to the documentation of this file.
4 #include <cstdio>
6 
8  DCCDataUnpacker* u, EcalElectronicsMapper* m, DCCEventBlock* e, bool unpack, bool forceToKeepFRdata)
9  : DCCDataBlockPrototype(u, m, e, unpack), checkFeId_(false), forceToKeepFRdata_(forceToKeepFRdata) {
11  numbDWInXtalBlock_ = (expXtalTSamples_ - 2) / 4 + 1;
13  xtalGains_ = new short[expXtalTSamples_];
14 }
15 
20 }
21 
22 int DCCFEBlock::unpack(const uint64_t** data, unsigned int* dwToEnd, bool zs, unsigned int expectedTowerID) {
23  zs_ = zs;
24  datap_ = data;
25  data_ = *data;
26  dwToEnd_ = dwToEnd;
27 
28  const unsigned int activeDCC = mapper_->getActiveSM();
29 
30  if ((*dwToEnd_) < 1) {
32  edm::LogWarning("IncorrectEvent") << "\n Unable to unpack Tower block for event " << event_->l1A() << " in fed "
33  << activeDCC << "\n The end of event was reached "
34  << "\n(or, previously, pointers intended to navigate outside of FedBlock "
35  "(based on block sizes), and were stopped by setting dwToEnd_ to zero)";
36  //TODO : add this to a dcc event size collection error?
37  }
38  return STOP_EVENT_UNPACKING;
39  }
40 
41  lastStripId_ = 0;
42  lastXtalId_ = 0;
43  expTowerID_ = expectedTowerID;
44 
45  //Point to begin of block
46  data_++;
47 
48  towerId_ = (*data_) & TOWER_ID_MASK;
53 
54  event_->setFESyncNumbers(l1_, bx_, (short)(expTowerID_ - 1));
55 
56  //debugging
57  //display(cout);
58 
60  // check that expected fe_id==fe_expected is on
61  if (checkFeId_ && expTowerID_ != towerId_ &&
62  expTowerID_ <= mapper_->getNumChannelsInDcc(activeDCC)) { // fe_id must be within range foreseen in the FED
64  edm::LogWarning("IncorrectBlock") << "Expected tower ID is " << expTowerID_ << " while " << towerId_
65  << " was found"
66  << " (L1A " << event_->l1A() << " fed " << mapper_->getActiveDCC() << ")\n"
67  << " => Skipping to next FE block...";
68  }
69 
71 
73  return SKIP_BLOCK_UNPACKING;
74  }
75 
77  // check that expected fe_id==fe_expected is off
79  activeDCC)) { // fe_id must still be within range foreseen in the FED
81  edm::LogWarning("IncorrectBlock") << "For event " << event_->l1A() << " and fed " << mapper_->getActiveDCC()
82  << " (there's no check fe_id==dcc_channel)"
83  << "\n the FE_id found: " << towerId_
84  << " exceeds max number of FE foreseen in fed"
85  << "\n => Skipping to next FE block...";
86  }
87 
89  return SKIP_BLOCK_UNPACKING;
90  }
91 
92  // Check synchronization
93  if (sync_) {
94  const unsigned int dccBx = (event_->bx()) & TCC_BX_MASK;
95  const unsigned int dccL1 = (event_->l1A()) & TCC_L1_MASK;
96  const unsigned int fov = (event_->fov()) & H_FOV_MASK;
97 
98  if (!isSynced(dccBx, bx_, dccL1, l1_, FE_MEM, fov)) {
100  // TODO: add check for status from Channel Status DB
101 
102  edm::LogWarning("IncorrectBlock")
103  << "Synchronization error for Tower Block"
104  << " (L1A " << event_->l1A() << " bx " << event_->bx() << " fed " << mapper_->getActiveDCC() << " tower "
105  << towerId_ << ")\n"
106  << " dccBx = " << dccBx << " bx_ = " << bx_ << " dccL1 = " << dccL1 << " l1_ = " << l1_ << "\n"
107  << " => Skipping to next tower block";
108  }
109 
110  //Note : add to error collection ?
112  return SKIP_BLOCK_UNPACKING;
113  }
114  }
115 
116  // check number of samples
117  if (nTSamples_ != expXtalTSamples_) {
119  edm::LogWarning("IncorrectBlock") << "Unable to unpack Tower Block " << towerId_ << " for event L1A "
120  << event_->l1A() << " in fed " << mapper_->getActiveDCC()
121  << "\n Number of time samples " << nTSamples_
122  << " is not the same as expected (" << expXtalTSamples_ << ")"
123  << "\n => Skipping to next tower block...";
124  }
125  //Note : add to error collection ?
127  return SKIP_BLOCK_UNPACKING;
128  }
129 
131  blockSize_ = blockLength_ * 8;
132 
133  if ((*dwToEnd_) < blockLength_) {
135  edm::LogWarning("IncorrectEvent") << "\n Unable to unpack Tower Block " << towerId_ << " for event L1A "
136  << event_->l1A() << " in fed " << mapper_->getActiveDCC() << "\n Only "
137  << ((*dwToEnd_) * 8) << " bytes are available while " << blockSize_
138  << " are needed!"
139  << "\n => Skipping to next fed block...";
140  }
141  //TODO : add to error collections
142  return STOP_EVENT_UNPACKING;
143  }
144 
145  if (!zs_ && !forceToKeepFRdata_) {
148  edm::LogWarning("IncorrectEvent")
149  << "\n For event L1A " << event_->l1A() << ", fed " << mapper_->getActiveDCC() << " and tower " << towerId_
150  << "\n Expected block size is " << (unfilteredDataBlockLength_ * 8) << " bytes while " << (blockLength_ * 8)
151  << " was found"
152  << "\n => Skipping to next fed block...";
153  }
154 
156 
157  //Safer approach... - why pointers do not navigate in this case?
158  return STOP_EVENT_UNPACKING;
159  }
160 
161  } else if (!zs && forceToKeepFRdata_) {
164  edm::LogWarning("IncorrectBlock")
165  << "For event L1A " << event_->l1A() << ", fed " << mapper_->getActiveDCC() << " and tower " << towerId_
166  << "\n Expected block size is " << (unfilteredDataBlockLength_ * 8) << " bytes while " << (blockLength_ * 8)
167  << " was found"
168  << "\n => Keeps unpacking as the unpacker was forced to keep FR data (by configuration) ...";
169  }
170 
172  }
173 
176  edm::LogWarning("IncorrectEvent") << "\n For event L1A " << event_->l1A() << " and fed "
177  << mapper_->getActiveDCC() << "\n The tower " << towerId_
178  << " has a wrong number of bytes : " << (blockLength_ * 8)
179  << "\n => Skipping to next fed block...";
180  }
181 
183 
184  //Safer approach... - why pointers do not navigate in this case?
185  return STOP_EVENT_UNPACKING;
186  }
187 
188  // If the HLT says to skip this tower we skip it...
189  if (!event_->getHLTChannel(towerId_)) {
191  return SKIP_BLOCK_UNPACKING;
192  }
194 
195  unsigned int numbOfXtalBlocks = (blockLength_ - 1) / numbDWInXtalBlock_;
196 
197  // get XTAL Data
198  unsigned int expStripID(0), expXtalID(0);
199  //point to xtal data
200  data_++;
201 
202  int statusUnpackXtal = 0;
203 
204  for (unsigned int numbXtal = 1; numbXtal <= numbOfXtalBlocks && statusUnpackXtal != SKIP_BLOCK_UNPACKING;
205  numbXtal++) {
206  if (!zs_ && !forceToKeepFRdata_) {
207  expStripID = (numbXtal - 1) / 5 + 1;
208  expXtalID = numbXtal - (expStripID - 1) * 5;
209  }
210 
211  statusUnpackXtal = unpackXtalData(expStripID, expXtalID);
212  if (statusUnpackXtal == SKIP_BLOCK_UNPACKING) {
214  edm::LogWarning("IncorrectBlock") << "For event L1A " << event_->l1A() << " and fed " << mapper_->getActiveDCC()
215  << "\n The tower " << towerId_ << " won't be unpacked further";
216  }
217  }
218 
219  } // end loop over xtals of given FE
220 
222  return BLOCK_UNPACKED;
223 }
224 
225 void DCCFEBlock::display(std::ostream& o) {
226  o << "\n Unpacked Info for DCC Tower Block"
227  << "\n DW1 ============================="
228  << "\n Tower Id " << towerId_ << "\n Numb Samp " << nTSamples_ << "\n Bx " << bx_ << "\n L1 " << l1_
229  << "\n blockLength " << blockLength_;
230 }
unsigned int towerId_
Definition: DCCFEBlock.h:53
std::unique_ptr< EcalElectronicsIdCollection > * invalidTTIds_
Definition: DCCFEBlock.h:63
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)
unsigned int blockSize_
Definition: DCCFEBlock.h:58
std::unique_ptr< EcalElectronicsIdCollection > * invalidBlockLengths_
Definition: DCCFEBlock.h:65
unsigned int expTowerID_
Definition: DCCFEBlock.h:46
bool zs_
Definition: DCCFEBlock.h:44
unsigned int xtalBlockSize_
Definition: DCCFEBlock.h:55
unsigned int getNumChannelsInDcc(unsigned int aDCCId)
int unpack(const uint64_t **data, unsigned int *dwToEnd, bool zs, unsigned int expectedTowerID)
Definition: DCCFEBlock.cc:22
virtual void fillEcalElectronicsError(std::unique_ptr< EcalElectronicsIdCollection > *)
Definition: DCCFEBlock.h:42
unsigned int nTSamples_
Definition: DCCFEBlock.h:56
DCCFEBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
Definition: DCCFEBlock.cc:7
std::unique_ptr< EcalElectronicsIdCollection > * invalidTTIdsCollection()
void updateCollectors() override
Definition: DCCFEBlock.cc:16
static std::atomic< bool > silentMode_
unsigned int lastXtalId_
Definition: DCCFEBlock.h:51
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
unsigned int bx()
Definition: DCCEventBlock.h:58
unsigned int fov()
Definition: DCCEventBlock.h:55
void setFESyncNumbers(short l1, short bx, short id)
Definition: DCCEventBlock.h:65
unsigned int l1_
Definition: DCCFEBlock.h:60
bool forceToKeepFRdata_
Definition: DCCFEBlock.h:47
std::unique_ptr< EcalElectronicsIdCollection > * invalidBlockLengthsCollection()
unsigned long long uint64_t
Definition: Time.h:13
unsigned int bx_
Definition: DCCFEBlock.h:59
unsigned int expXtalTSamples_
Definition: DCCFEBlock.h:48
std::unique_ptr< EcalElectronicsIdCollection > * invalidZSXtalIdsCollection()
unsigned int lastStripId_
Definition: DCCFEBlock.h:50
DCCDataUnpacker * unpacker_
unsigned int getUnfilteredTowerBlockLength()
virtual int unpackXtalData(unsigned int stripID, unsigned int xtalID)
Definition: DCCFEBlock.h:41
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
short getHLTChannel(int channel)
Definition: DCCEventBlock.h:74
virtual void updateEventPointers()
unsigned int numbDWInXtalBlock_
Definition: DCCFEBlock.h:54
unsigned int unfilteredDataBlockLength_
Definition: DCCFEBlock.h:49
EcalElectronicsMapper * mapper_
std::unique_ptr< EcalElectronicsIdCollection > * invalidZSXtalIds_
Definition: DCCFEBlock.h:64
Log< level::Warning, false > LogWarning
void display(std::ostream &o) override
Definition: DCCFEBlock.cc:225
short * xtalGains_
Definition: DCCFEBlock.h:62
bool checkFeId_
Definition: DCCFEBlock.h:45
unsigned int l1A()
Definition: DCCEventBlock.h:57