test
CMS 3D CMS Logo

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