45 std::unique_ptr<DTDigiCollection>& detectorProduct,
46 std::unique_ptr<DTLocalTriggerCollection>& triggerProduct,
52 dduID = hardcodedDDUID;
54 const int wordLength = 4;
55 int numberOfWords = datasize / wordLength;
59 controlDataFromAllROS.clear();
64 map<uint32_t, int> hitOrder;
74 while (wordCounter < numberOfWords) {
81 if (rosID <= 12 && !((rosList &
int(
pow(2., (rosID - 1)))) >> (rosID - 1)))
84 cout <<
"[DTROS25Unpacker]: ros list: " << rosList <<
" ROS ID " << rosID << endl;
91 int dum1, dum2, dum3, dum4;
93 if (
writeSC && !
mapping->readOutToGeometry(dduID, rosID, 1, 1, 1, SCwheel, dum1, SCsector, dum2, dum3, dum4)) {
95 cout <<
" found SCwheel: " << SCwheel <<
" and SCsector: " << SCsector << endl;
98 cout <<
" WARNING failed to find WHEEL and SECTOR for ROS " << rosID <<
" !" << endl;
122 cout <<
"[DTROS25Unpacker]: ROSError, Error type " << dtROSErrorWord.
errorType() <<
" robID "
123 << dtROSErrorWord.
robID() << endl;
131 cout <<
"[DTROS25Unpacker]: ROSDebug, type " << rosDebugWord.
debugType() <<
" message "
138 int eventID = robHeaderWord.
eventID();
139 int bunchID = robHeaderWord.
bunchID();
140 int robID = robHeaderWord.
robID();
146 cout <<
"[DTROS25Unpacker] ROB: ID " << robID <<
" Event ID " << eventID <<
" BXID " << bunchID << endl;
167 cout <<
"TDC Debugging" << endl;
173 DTTDCData tdcData(robID, tdcMeasurementWord);
176 int tdcID = tdcMeasurementWord.
tdcID();
177 int tdcChannel = tdcMeasurementWord.
tdcChannel();
180 cout <<
"[DTROS25Unpacker] TDC: ID " << tdcID <<
" Channel " << tdcChannel <<
" Time "
181 << tdcMeasurementWord.
tdcTime() << endl;
185 hitOrder[channelIndex.
getCode()]++;
188 cout <<
"[DTROS25Unpacker] ROAddress: DDU " << dduID <<
", ROS " << rosID <<
", ROB " << robID
189 <<
", TDC " << tdcID <<
", Channel " << tdcChannel << endl;
193 if (
writeSC && (SCsector < 1 || SCwheel < -2)) {
195 cout <<
" second try to find SCwheel and SCsector " << endl;
196 if (!
mapping->readOutToGeometry(
197 dduID, rosID, robID, tdcID, tdcChannel, SCwheel, dum1, SCsector, dum2, dum3, dum4)) {
199 cout <<
" ROS " << rosID <<
" SC wheel " << SCwheel <<
" SC sector " << SCsector << endl;
202 cout <<
" WARNING !! ROS " << rosID <<
" failed again to map for SC!! " << endl;
209 int wheelId, stationId, sectorId, slId, layerId, cellId;
210 if (!
mapping->readOutToGeometry(
211 dduID, rosID, robID, tdcID, tdcChannel, wheelId, stationId, sectorId, slId, layerId, cellId)) {
213 if (sectorId == 0 || stationId == 0)
216 detId =
DTWireId(wheelId, stationId, sectorId, slId, layerId, cellId);
219 cout <<
"[DTROS25Unpacker] " << detId << endl;
220 int wire = detId.
wire();
226 detectorProduct->insertDigi(detId.
layerId(), digi);
229 <<
"Unable to map the RO channel: DDU " << dduID <<
" ROS " << rosID <<
" ROB " << robID <<
" TDC "
230 << tdcID <<
" TDC ch. " << tdcChannel;
232 cout <<
"[DTROS25Unpacker] ***ERROR*** Missing wire: DDU " << dduID <<
" ROS " << rosID <<
" ROB "
233 << robID <<
" TDC " << tdcID <<
" TDC ch. " << tdcChannel << endl;
246 cout <<
"[DTROS25Unpacker]: ROBTrailer, robID " << robTrailerWord.
robID() <<
" eventID "
247 << robTrailerWord.
eventID() <<
" wordCount " << robTrailerWord.
wordCount() << endl;
255 cout <<
"[DTROS25Unpacker]: SC header eventID " << scHeaderWord.
eventID() << endl;
269 int leftword = numofscword;
272 cout <<
" SC PrivateHeader (number of words + subheader = "
277 if (numofscword > 0) {
278 int bx_received = (numofscword - 1) / 2;
280 cout <<
" SC number of bx read-out: " << bx_received << endl;
292 cout <<
" SC trigger delay = " << scPrivateSubHeaderWord.
TriggerDelay() << endl
293 <<
" SC bunch counter = " << scEventBX << endl;
298 int stationGroup = 0;
308 int bx_counter =
int(round((leftword + 1) / 2.));
311 if (bx_counter < 0 || leftword < 0)
312 cout <<
"[DTROS25Unpacker]: SC data more than expected; negative bx counter reached! " << endl;
325 cout <<
" at BX " << bx_counter
326 <<
" lower part has trigger! with track quality " << scDataWord.
trackQuality(0) << endl;
328 cout <<
" at BX " << bx_counter
329 <<
" upper part has trigger! with track quality " << scDataWord.
trackQuality(1) << endl;
332 if (
writeSC && SCwheel >= -2 && SCsector >= 1) {
336 if (stationGroup % 2 == 0)
344 DTChamberId chamberId(SCwheel, SCstation, SCsector);
345 triggerProduct->insertDigi(chamberId, localtrigger);
347 cout <<
"Add SC digi to the collection, for chamber: " << chamberId << endl;
348 localtrigger.
print();
352 if (stationGroup % 2 == 0)
360 DTChamberId chamberId(SCwheel, SCstation, SCsector);
361 triggerProduct->insertDigi(chamberId, localtrigger);
363 cout <<
"Add SC digi to the collection, for chamber: " << chamberId << endl;
364 localtrigger.
print();
384 cout <<
" SC Trailer, # of words: " << scTrailerWord.
wordCount() << endl;
403 controlDataFromAllROS.push_back(controlData);
408 else if (
index[
swap(wordCounter)] == 0) {
413 cout <<
"[DTROS25Unpacker]: odd number of ROS words" << endl;
418 cout <<
"[DTROS25Unpacker]: ERROR! First word is not a ROS Header" << endl;