52 std::unique_ptr<DTDigiCollection>& detectorProduct,
53 std::unique_ptr<DTLocalTriggerCollection>& triggerProduct,
57 if (readDDUIDfromDDU) dduID = dduIDfromDDU;
58 else dduID = hardcodedDDUID;
60 const int wordLength = 4;
61 int numberOfWords = datasize / wordLength;
65 controlDataFromAllROS.clear();
68 uint32_t word = index[
swap(wordCounter)];
70 map<uint32_t,int> hitOrder;
81 while (wordCounter < numberOfWords) {
89 if ( rosID <= 12 && !((rosList &
int(
pow(2., (rosID-1) )) ) >> (rosID-1) ) )
continue;
90 if (
debug)
cout<<
"[DTROS25Unpacker]: ros list: "<<rosList <<
" ROS ID "<<rosID<<endl;
97 int dum1, dum2, dum3, dum4;
99 if (writeSC && ! mapping->readOutToGeometry(dduID, rosID, 1, 1, 1,
100 SCwheel, dum1, SCsector, dum2, dum3, dum4) ) {
101 if (
debug)
cout <<
" found SCwheel: "<<SCwheel<<
" and SCsector: "<<SCsector<<endl;
104 if (writeSC &&
debug)
cout <<
" WARNING failed to find WHEEL and SECTOR for ROS "<<rosID<<
" !"<<endl;
121 wordCounter++; word = index[
swap(wordCounter)];
127 if (
debug)
cout<<
"[DTROS25Unpacker]: ROSError, Error type "<<dtROSErrorWord.
errorType()
128 <<
" robID "<<dtROSErrorWord.
robID()<<endl;
143 int eventID = robHeaderWord.
eventID();
144 int bunchID = robHeaderWord.
bunchID();
145 int robID = robHeaderWord.
robID();
150 if (
debug)
cout<<
"[DTROS25Unpacker] ROB: ID "<<robID
151 <<
" Event ID "<<eventID
152 <<
" BXID "<<bunchID<<endl;
156 wordCounter++; word = index[
swap(wordCounter)];
177 DTTDCData tdcData(robID,tdcMeasurementWord);
180 int tdcID = tdcMeasurementWord.
tdcID();
181 int tdcChannel = tdcMeasurementWord.
tdcChannel();
183 if (
debug)
cout<<
"[DTROS25Unpacker] TDC: ID "<<tdcID
184 <<
" Channel "<< tdcChannel
185 <<
" Time "<<tdcMeasurementWord.
tdcTime()<<endl;
189 hitOrder[channelIndex.
getCode()]++;
192 cout<<
"[DTROS25Unpacker] ROAddress: DDU "<< dduID
196 <<
", Channel "<< tdcChannel<<endl;
200 if (writeSC && (SCsector < 1 || SCwheel < -2) ) {
202 if (
debug)
cout <<
" second try to find SCwheel and SCsector "<<endl;
203 if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,
204 SCwheel, dum1, SCsector, dum2, dum3, dum4) ) {
205 if (
debug)
cout<<
" ROS "<<rosID<<
" SC wheel "<<SCwheel<<
" SC sector "<<SCsector<<endl;
208 if (
debug)
cout<<
" WARNING !! ROS "<<rosID<<
" failed again to map for SC!! "<<endl;
216 int wheelId, stationId, sectorId, slId,layerId, cellId;
217 if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,
218 wheelId, stationId, sectorId, slId, layerId, cellId)) {
221 if (sectorId==0 || stationId == 0)
continue;
222 else detId =
DTWireId(wheelId, stationId, sectorId, slId, layerId, cellId);
224 if (
debug)
cout<<
"[DTROS25Unpacker] "<<detId<<endl;
225 int wire = detId.
wire();
231 detectorProduct->insertDigi(detId.
layerId(),digi);
234 LogWarning (
"DTRawToDigi|DTROS25Unpacker") <<
"Unable to map the RO channel: DDU "<<dduID
235 <<
" ROS "<<rosID<<
" ROB "<<robID<<
" TDC "<<tdcID<<
" TDC ch. "<<tdcChannel;
236 if (
debug)
cout<<
"[DTROS25Unpacker] ***ERROR*** Missing wire: DDU "<<dduID
237 <<
" ROS "<<rosID<<
" ROB "<<robID<<
" TDC "<<tdcID<<
" TDC ch. "<<tdcChannel<<endl;
249 if (
debug)
cout<<
"[DTROS25Unpacker]: ROBTrailer, robID "<<robTrailerWord.
robID()
250 <<
" eventID "<<robTrailerWord.
eventID()
251 <<
" wordCount "<<robTrailerWord.
wordCount()<<endl;
258 if (
debug)
cout<<
"[DTROS25Unpacker]: SC header eventID " << scHeaderWord.
eventID()<<endl;
261 wordCounter++; word = index[
swap(wordCounter)];
271 int leftword = numofscword;
273 if(
debug)
cout<<
" SC PrivateHeader (number of words + subheader = "
280 int bx_received = (numofscword - 1) / 2;
281 if(
debug)
cout<<
" SC number of bx read-out: " << bx_received << endl;
283 wordCounter++; word = index[
swap(wordCounter)];
293 <<
" SC bunch counter = "
294 << scEventBX << endl;
301 wordCounter++; word = index[
swap(wordCounter)];
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 "
329 cout<<
" at BX "<< bx_counter
330 <<
" upper part has trigger! with track quality "
334 if (writeSC && SCwheel >= -2 && SCsector >=1 ) {
339 if ( stationGroup%2 == 0) SCstation = 1;
345 DTChamberId chamberId (SCwheel,SCstation,SCsector);
346 triggerProduct->insertDigi(chamberId,localtrigger);
348 cout<<
"Add SC digi to the collection, for chamber: " << chamberId
350 localtrigger.
print(); }
353 if ( stationGroup%2 == 0) SCstation = 2;
359 DTChamberId chamberId (SCwheel,SCstation,SCsector);
360 triggerProduct->insertDigi(chamberId,localtrigger);
362 cout<<
"Add SC digi to the collection, for chamber: " << chamberId
364 localtrigger.
print();
383 if (
debug)
cout<<
" SC Trailer, # of words: "
402 controlDataFromAllROS.push_back(controlData);
407 else if (index[
swap(wordCounter)] == 0) {
411 if (
debug)
cout<<
"[DTROS25Unpacker]: odd number of ROS words"<<endl;
416 cout<<
"[DTROS25Unpacker]: ERROR! First word is not a ROS Header"<<endl;
420 wordCounter++; word = index[
swap(wordCounter)];
432 if (n%2==0) result = (n+1);
433 if (n%2==1) result = (n-1);
int trackQuality(int first) const
int EventWordCount() const
T getUntrackedParameter(std::string const &, T const &) const
void addSCData(const DTSectorCollectorData &scData)
virtual void interpretRawData(const unsigned int *index, int datasize, int dduID, edm::ESHandle< DTReadOutMapping > &mapping, std::unique_ptr< DTDigiCollection > &product, std::unique_ptr< DTLocalTriggerCollection > &product2, uint16_t rosList=0)
int hasTrigger(int first) const
std::pair< int, DTROBHeaderWord > DTROBHeader
void addROBHeader(const DTROBHeader &robHeader)
int getBits(int first) const
void addSCPrivHeader(const DTLocalTriggerSectorCollectorHeaderWord &scPrivHeader)
void addSCTrailer(const DTLocalTriggerTrailerWord &scTrailer)
DTROS25Unpacker(const edm::ParameterSet &ps)
Constructor.
std::pair< int, DTTDCErrorWord > DTTDCError
uint32_t getCode() const
Getters ///////////////////////.
void print()
Print out the error information >>> FIXME: to be implemented.
void addTDCError(const DTTDCError &tdcError)
void addSCPrivSubHeader(const DTLocalTriggerSectorCollectorSubHeaderWord &scPrivSubHeader)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
tuple performDataIntegrityMonitor
std::pair< DTLocalTriggerDataWord, int > DTSectorCollectorData
void setROSId(const int &ID)
Setters ///////////////////////.
virtual ~DTROS25Unpacker()
Destructor.
int tdcID() const
<== OBSOLETE!!
int wire() const
Return the wire number.
enum wordTypes type()
DDU word type getter.
void print() const
Print content of trigger.
void addROBTrailer(const DTROBTrailerWord &word)
void addROSHeader(const DTROSHeaderWord &word)
void addROSError(const DTROSErrorWord &word)
DTLayerId layerId() const
Return the corresponding LayerId.
void addROSTrailer(const DTROSTrailerWord &word)
std::pair< int, DTTDCMeasurementWord > DTTDCData
void addSCHeader(const DTLocalTriggerHeaderWord &scHeader)
void addROSDebug(const DTROSDebugWord &word)
Power< A, B >::type pow(const A &a, const B &b)
void addTDCData(const DTTDCData &tdcData)