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 }
DCCFEBlock::invalidBlockLengths_
std::unique_ptr< EcalElectronicsIdCollection > * invalidBlockLengths_
Definition: DCCFEBlock.h:65
DCCDataBlockPrototype::dwToEnd_
unsigned int * dwToEnd_
Definition: DCCDataBlockPrototype.h:74
DCCDataUnpacker.h
DCCEventBlock
Definition: DCCEventBlock.h:29
funct::false
false
Definition: Factorize.h:29
DCCFEBlock::unpack
int unpack(const uint64_t **data, unsigned int *dwToEnd, bool zs, unsigned int expectedTowerID)
Definition: DCCFEBlock.cc:22
SKIP_BLOCK_UNPACKING
Definition: DCCRawDataDefinitions.h:7
DCCEventBlock::getHLTChannel
short getHLTChannel(int channel)
Definition: DCCEventBlock.h:74
DCCFEBlock::xtalGains_
short * xtalGains_
Definition: DCCFEBlock.h:62
DCCDataBlockPrototype::data_
const uint64_t * data_
Definition: DCCDataBlockPrototype.h:73
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
TOWER_ID_MASK
Definition: DCCRawDataDefinitions.h:149
DCCFEBlock::invalidZSXtalIds_
std::unique_ptr< EcalElectronicsIdCollection > * invalidZSXtalIds_
Definition: DCCFEBlock.h:64
H_FOV_MASK
Definition: DCCRawDataDefinitions.h:102
DCCFEBlock::expTowerID_
unsigned int expTowerID_
Definition: DCCFEBlock.h:46
DCCDataUnpacker::invalidBlockLengthsCollection
std::unique_ptr< EcalElectronicsIdCollection > * invalidBlockLengthsCollection()
Definition: DCCDataUnpacker.h:150
EcalElectronicsMapper::getActiveSM
unsigned int getActiveSM()
Definition: EcalElectronicsMapper.h:128
DCCEventBlock::setFESyncNumbers
void setFESyncNumbers(short l1, short bx, short id)
Definition: DCCEventBlock.h:65
DCCDataUnpacker
Definition: DCCDataUnpacker.h:49
DCCDataBlockPrototype::updateEventPointers
virtual void updateEventPointers()
Definition: DCCDataBlockPrototype.h:51
DCCDataUnpacker::silentMode_
static std::atomic< bool > silentMode_
Definition: DCCDataUnpacker.h:185
DCCFEBlock::DCCFEBlock
DCCFEBlock(DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpack, bool forceToKeepFRdata)
Definition: DCCFEBlock.cc:7
EcalElectronicsMapper::numbXtalTSamples
unsigned int numbXtalTSamples()
Definition: EcalElectronicsMapper.h:130
DCCFEBlock::l1_
unsigned int l1_
Definition: DCCFEBlock.h:60
DCCDataBlockPrototype
Definition: DCCDataBlockPrototype.h:28
TOWER_L1_MASK
Definition: DCCRawDataDefinitions.h:157
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalElectronicsMapper.h
DCCEventBlock::fov
unsigned int fov()
Definition: DCCEventBlock.h:55
DCCFEBlock::nTSamples_
unsigned int nTSamples_
Definition: DCCFEBlock.h:56
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
DCCFEBlock::zs_
bool zs_
Definition: DCCFEBlock.h:42
DCCFEBlock::towerId_
unsigned int towerId_
Definition: DCCFEBlock.h:53
DCCFEBlock::fillEcalElectronicsError
virtual void fillEcalElectronicsError(std::unique_ptr< EcalElectronicsIdCollection > *)
Definition: DCCFEBlock.h:42
DCCFEBlock::updateCollectors
void updateCollectors() override
Definition: DCCFEBlock.cc:16
DCCFEBlock::display
void display(std::ostream &o) override
Definition: DCCFEBlock.cc:225
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DCCFEBlock.h
DCCDataBlockPrototype::unpacker_
DCCDataUnpacker * unpacker_
Definition: DCCDataBlockPrototype.h:67
DCCEventBlock::bx
unsigned int bx()
Definition: DCCEventBlock.h:58
DCCFEBlock::checkFeId_
bool checkFeId_
Definition: DCCFEBlock.h:45
FE_MEM
Definition: DCCEventBlock.h:138
DCCDataUnpacker::invalidTTIdsCollection
std::unique_ptr< EcalElectronicsIdCollection > * invalidTTIdsCollection()
Definition: DCCDataUnpacker.h:146
EcalElectronicsMapper::getActiveDCC
unsigned int getActiveDCC()
Definition: EcalElectronicsMapper.h:126
DCCFEBlock::forceToKeepFRdata_
bool forceToKeepFRdata_
Definition: DCCFEBlock.h:47
EcalElectronicsMapper::getNumChannelsInDcc
unsigned int getNumChannelsInDcc(unsigned int aDCCId)
Definition: EcalElectronicsMapper.h:146
TOWER_NSAMP_MASK
Definition: DCCRawDataDefinitions.h:151
STOP_EVENT_UNPACKING
Definition: DCCRawDataDefinitions.h:8
DCCEventBlock.h
DCCDataBlockPrototype::sync_
bool sync_
Definition: DCCDataBlockPrototype.h:78
DCCFEBlock::expXtalTSamples_
unsigned int expXtalTSamples_
Definition: DCCFEBlock.h:48
TOWER_BX_MASK
Definition: DCCRawDataDefinitions.h:154
DCCDataBlockPrototype::event_
DCCEventBlock * event_
Definition: DCCDataBlockPrototype.h:70
DCCFEBlock::lastXtalId_
unsigned int lastXtalId_
Definition: DCCFEBlock.h:51
TCC_BX_MASK
Definition: DCCRawDataDefinitions.h:179
DCCFEBlock::unfilteredDataBlockLength_
unsigned int unfilteredDataBlockLength_
Definition: DCCFEBlock.h:49
DCCEventBlock::l1A
unsigned int l1A()
Definition: DCCEventBlock.h:57
DCCFEBlock::blockSize_
unsigned int blockSize_
Definition: DCCFEBlock.h:58
EcalElectronicsMapper
Definition: EcalElectronicsMapper.h:36
DCCDataUnpacker::invalidZSXtalIdsCollection
std::unique_ptr< EcalElectronicsIdCollection > * invalidZSXtalIdsCollection()
Definition: DCCDataUnpacker.h:148
DCCDataBlockPrototype::mapper_
EcalElectronicsMapper * mapper_
Definition: DCCDataBlockPrototype.h:69
DCCFEBlock::invalidTTIds_
std::unique_ptr< EcalElectronicsIdCollection > * invalidTTIds_
Definition: DCCFEBlock.h:63
DCCFEBlock::numbDWInXtalBlock_
unsigned int numbDWInXtalBlock_
Definition: DCCFEBlock.h:54
DCCDataBlockPrototype::datap_
const uint64_t ** datap_
Definition: DCCDataBlockPrototype.h:72
BeamSpotPI::unpack
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
Definition: BeamSpotPayloadInspectorHelper.h:23
TOWER_BX_B
Definition: DCCRawDataDefinitions.h:155
TOWER_LENGTH_MASK
Definition: DCCRawDataDefinitions.h:168
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
EcalElectronicsMapper::getUnfilteredTowerBlockLength
unsigned int getUnfilteredTowerBlockLength()
Definition: EcalElectronicsMapper.h:134
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
DCCFEBlock::unpackXtalData
virtual int unpackXtalData(unsigned int stripID, unsigned int xtalID)
Definition: DCCFEBlock.h:41
DCCDataBlockPrototype::blockLength_
unsigned int blockLength_
Definition: DCCDataBlockPrototype.h:76
TOWER_LENGTH_B
Definition: DCCRawDataDefinitions.h:169
TOWER_NSAMP_B
Definition: DCCRawDataDefinitions.h:152
DCCFEBlock::lastStripId_
unsigned int lastStripId_
Definition: DCCFEBlock.h:50
BLOCK_UNPACKED
Definition: DCCRawDataDefinitions.h:6
DCCFEBlock::bx_
unsigned int bx_
Definition: DCCFEBlock.h:59
DCCFEBlock::xtalBlockSize_
unsigned int xtalBlockSize_
Definition: DCCFEBlock.h:55
TOWER_L1_B
Definition: DCCRawDataDefinitions.h:158
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TCC_L1_MASK
Definition: DCCRawDataDefinitions.h:182