45 if(performDataIntegrityMonitor) {
50 "[DTROS25Unpacker] WARNING! Data Integrity Monitoring requested but no DTDataMonitorInterface Service available" << endl;
51 performDataIntegrityMonitor =
false;
64 std::auto_ptr<DTDigiCollection>& detectorProduct,
65 std::auto_ptr<DTLocalTriggerCollection>& triggerProduct,
70 if (readDDUIDfromDDU) dduID = dduIDfromDDU;
71 else dduID = hardcodedDDUID;
73 const int wordLength = 4;
74 int numberOfWords = datasize / wordLength;
78 controlDataFromAllROS.clear();
81 uint32_t word = index[
swap(wordCounter)];
83 map<uint32_t,int> hitOrder;
94 while (wordCounter < numberOfWords) {
102 if ( rosID <= 12 && !((rosList &
int(
pow(2., (rosID-1) )) ) >> (rosID-1) ) )
continue;
103 if (
debug)
cout<<
"[DTROS25Unpacker]: ros list: "<<rosList <<
" ROS ID "<<rosID<<endl;
110 int dum1, dum2, dum3, dum4;
112 if (writeSC && ! mapping->readOutToGeometry(dduID, rosID, 1, 1, 1,
113 SCwheel, dum1, SCsector, dum2, dum3, dum4) ) {
114 if (
debug)
cout <<
" found SCwheel: "<<SCwheel<<
" and SCsector: "<<SCsector<<endl;
117 if (writeSC &&
debug)
cout <<
" WARNING failed to find WHEEL and SECTOR for ROS "<<rosID<<
" !"<<endl;
134 wordCounter++; word = index[
swap(wordCounter)];
140 if (
debug)
cout<<
"[DTROS25Unpacker]: ROSError, Error type "<<dtROSErrorWord.
errorType()
141 <<
" robID "<<dtROSErrorWord.
robID()<<endl;
156 int eventID = robHeaderWord.
eventID();
157 int bunchID = robHeaderWord.
bunchID();
158 int robID = robHeaderWord.
robID();
163 if (
debug)
cout<<
"[DTROS25Unpacker] ROB: ID "<<robID
164 <<
" Event ID "<<eventID
165 <<
" BXID "<<bunchID<<endl;
169 wordCounter++; word = index[
swap(wordCounter)];
190 DTTDCData tdcData(robID,tdcMeasurementWord);
193 int tdcID = tdcMeasurementWord.
tdcID();
194 int tdcChannel = tdcMeasurementWord.
tdcChannel();
196 if (
debug)
cout<<
"[DTROS25Unpacker] TDC: ID "<<tdcID
197 <<
" Channel "<< tdcChannel
198 <<
" Time "<<tdcMeasurementWord.
tdcTime()<<endl;
202 hitOrder[channelIndex.
getCode()]++;
205 cout<<
"[DTROS25Unpacker] ROAddress: DDU "<< dduID
209 <<
", Channel "<< tdcChannel<<endl;
213 if (writeSC && (SCsector < 1 || SCwheel < -2) ) {
215 if (
debug)
cout <<
" second try to find SCwheel and SCsector "<<endl;
216 if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,
217 SCwheel, dum1, SCsector, dum2, dum3, dum4) ) {
218 if (
debug)
cout<<
" ROS "<<rosID<<
" SC wheel "<<SCwheel<<
" SC sector "<<SCsector<<endl;
221 if (
debug)
cout<<
" WARNING !! ROS "<<rosID<<
" failed again to map for SC!! "<<endl;
229 int wheelId, stationId, sectorId, slId,layerId, cellId;
230 if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,
231 wheelId, stationId, sectorId, slId, layerId, cellId)) {
234 if (sectorId==0 || stationId == 0)
continue;
235 else detId =
DTWireId(wheelId, stationId, sectorId, slId, layerId, cellId);
237 if (
debug)
cout<<
"[DTROS25Unpacker] "<<detId<<endl;
238 int wire = detId.
wire();
244 detectorProduct->insertDigi(detId.
layerId(),digi);
247 LogWarning (
"DTRawToDigi|DTROS25Unpacker") <<
"Unable to map the RO channel: DDU "<<dduID
248 <<
" ROS "<<rosID<<
" ROB "<<robID<<
" TDC "<<tdcID<<
" TDC ch. "<<tdcChannel;
249 if (
debug)
cout<<
"[DTROS25Unpacker] ***ERROR*** Missing wire: DDU "<<dduID
250 <<
" ROS "<<rosID<<
" ROB "<<robID<<
" TDC "<<tdcID<<
" TDC ch. "<<tdcChannel<<endl;
262 if (
debug)
cout<<
"[DTROS25Unpacker]: ROBTrailer, robID "<<robTrailerWord.
robID()
263 <<
" eventID "<<robTrailerWord.
eventID()
264 <<
" wordCount "<<robTrailerWord.
wordCount()<<endl;
271 if (
debug)
cout<<
"[DTROS25Unpacker]: SC header eventID " << scHeaderWord.
eventID()<<endl;
274 wordCounter++; word = index[
swap(wordCounter)];
279 if(performDataIntegrityMonitor) {
284 int leftword = numofscword;
286 if(
debug)
cout<<
" SC PrivateHeader (number of words + subheader = "
293 int bx_received = (numofscword - 1) / 2;
294 if(
debug)
cout<<
" SC number of bx read-out: " << bx_received << endl;
296 wordCounter++; word = index[
swap(wordCounter)];
306 <<
" SC bunch counter = "
307 << scEventBX << endl;
314 wordCounter++; word = index[
swap(wordCounter)];
321 int bx_counter = int(round( (leftword + 1)/ 2.));
324 if(bx_counter < 0 || leftword < 0)
325 cout<<
"[DTROS25Unpacker]: SC data more than expected; negative bx counter reached! "<<endl;
338 cout<<
" at BX "<< bx_counter
339 <<
" lower part has trigger! with track quality "
342 cout<<
" at BX "<< bx_counter
343 <<
" upper part has trigger! with track quality "
347 if (writeSC && SCwheel >= -2 && SCsector >=1 ) {
352 if ( stationGroup%2 == 0) SCstation = 1;
358 DTChamberId chamberId (SCwheel,SCstation,SCsector);
359 triggerProduct->insertDigi(chamberId,localtrigger);
361 cout<<
"Add SC digi to the collection, for chamber: " << chamberId
363 localtrigger.
print(); }
366 if ( stationGroup%2 == 0) SCstation = 2;
372 DTChamberId chamberId (SCwheel,SCstation,SCsector);
373 triggerProduct->insertDigi(chamberId,localtrigger);
375 cout<<
"Add SC digi to the collection, for chamber: " << chamberId
377 localtrigger.
print();
396 if (
debug)
cout<<
" SC Trailer, # of words: "
412 if (performDataIntegrityMonitor) {
413 dataMonitor->processROS25(controlData, dduID, rosID);
415 controlDataFromAllROS.push_back(controlData);
420 else if (index[
swap(wordCounter)] == 0) {
424 if (
debug)
cout<<
"[DTROS25Unpacker]: odd number of ROS words"<<endl;
429 cout<<
"[DTROS25Unpacker]: ERROR! First word is not a ROS Header"<<endl;
433 wordCounter++; word = index[
swap(wordCounter)];
445 if (n%2==0) result = (n+1);
446 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)
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)
virtual void interpretRawData(const unsigned int *index, int datasize, int dduID, edm::ESHandle< DTReadOutMapping > &mapping, std::auto_ptr< DTDigiCollection > &product, std::auto_ptr< DTLocalTriggerCollection > &product2, uint16_t rosList=0)
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)
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)