47 if(performDataIntegrityMonitor) {
52 "[DTROS25Unpacker] WARNING! Data Integrity Monitoring requested but no DTDataMonitorInterface Service available" << endl;
53 performDataIntegrityMonitor =
false;
66 std::auto_ptr<DTDigiCollection>& detectorProduct,
67 std::auto_ptr<DTLocalTriggerCollection>& triggerProduct,
72 if (readDDUIDfromDDU) dduID = dduIDfromDDU;
73 else dduID = hardcodedDDUID;
75 const int wordLength = 4;
76 int numberOfWords = datasize / wordLength;
80 controlDataFromAllROS.clear();
83 uint32_t word = index[
swap(wordCounter)];
85 map<uint32_t,int> hitOrder;
96 while (wordCounter < numberOfWords) {
104 if ( rosID <= 12 && !((rosList &
int(
pow(2., (rosID-1) )) ) >> (rosID-1) ) )
continue;
105 if (
debug)
cout<<
"[DTROS25Unpacker]: ros list: "<<rosList <<
" ROS ID "<<rosID<<endl;
112 int dum1, dum2, dum3, dum4;
114 if (writeSC && ! mapping->readOutToGeometry(dduID, rosID, 1, 1, 1,
115 SCwheel, dum1, SCsector, dum2, dum3, dum4) ) {
116 if (
debug)
cout <<
" found SCwheel: "<<SCwheel<<
" and SCsector: "<<SCsector<<endl;
119 if (writeSC &&
debug)
cout <<
" WARNING failed to find WHEEL and SECTOR for ROS "<<rosID<<
" !"<<endl;
136 wordCounter++; word = index[
swap(wordCounter)];
142 if (
debug)
cout<<
"[DTROS25Unpacker]: ROSError, Error type "<<dtROSErrorWord.
errorType()
143 <<
" robID "<<dtROSErrorWord.
robID()<<endl;
158 int eventID = robHeaderWord.
eventID();
159 int bunchID = robHeaderWord.
bunchID();
160 int robID = robHeaderWord.
robID();
165 if (
debug)
cout<<
"[DTROS25Unpacker] ROB: ID "<<robID
166 <<
" Event ID "<<eventID
167 <<
" BXID "<<bunchID<<endl;
171 wordCounter++; word = index[
swap(wordCounter)];
192 DTTDCData tdcData(robID,tdcMeasurementWord);
195 int tdcID = tdcMeasurementWord.
tdcID();
196 int tdcChannel = tdcMeasurementWord.
tdcChannel();
198 if (
debug)
cout<<
"[DTROS25Unpacker] TDC: ID "<<tdcID
199 <<
" Channel "<< tdcChannel
200 <<
" Time "<<tdcMeasurementWord.
tdcTime()<<endl;
204 hitOrder[channelIndex.
getCode()]++;
207 cout<<
"[DTROS25Unpacker] ROAddress: DDU "<< dduID
211 <<
", Channel "<< tdcChannel<<endl;
215 if (writeSC && (SCsector < 1 || SCwheel < -2) ) {
217 if (
debug)
cout <<
" second try to find SCwheel and SCsector "<<endl;
218 if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,
219 SCwheel, dum1, SCsector, dum2, dum3, dum4) ) {
220 if (
debug)
cout<<
" ROS "<<rosID<<
" SC wheel "<<SCwheel<<
" SC sector "<<SCsector<<endl;
223 if (
debug)
cout<<
" WARNING !! ROS "<<rosID<<
" failed again to map for SC!! "<<endl;
231 int wheelId, stationId, sectorId, slId,layerId, cellId;
232 if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,
233 wheelId, stationId, sectorId, slId, layerId, cellId)) {
236 if (sectorId==0 || stationId == 0)
continue;
237 else detId =
DTWireId(wheelId, stationId, sectorId, slId, layerId, cellId);
239 if (
debug)
cout<<
"[DTROS25Unpacker] "<<detId<<endl;
240 int wire = detId.
wire();
246 detectorProduct->insertDigi(detId.
layerId(),digi);
249 LogWarning (
"DTRawToDigi|DTROS25Unpacker") <<
"Unable to map the RO channel: DDU "<<dduID
250 <<
" ROS "<<rosID<<
" ROB "<<robID<<
" TDC "<<tdcID<<
" TDC ch. "<<tdcChannel;
251 if (
debug)
cout<<
"[DTROS25Unpacker] ***ERROR*** Missing wire: DDU "<<dduID
252 <<
" ROS "<<rosID<<
" ROB "<<robID<<
" TDC "<<tdcID<<
" TDC ch. "<<tdcChannel<<endl;
264 if (
debug)
cout<<
"[DTROS25Unpacker]: ROBTrailer, robID "<<robTrailerWord.
robID()
265 <<
" eventID "<<robTrailerWord.
eventID()
266 <<
" wordCount "<<robTrailerWord.
wordCount()<<endl;
273 if (
debug)
cout<<
"[DTROS25Unpacker]: SC header eventID " << scHeaderWord.
eventID()<<endl;
276 wordCounter++; word = index[
swap(wordCounter)];
281 if(performDataIntegrityMonitor) {
286 int leftword = numofscword;
288 if(
debug)
cout<<
" SC PrivateHeader (number of words + subheader = "
295 int bx_received = (numofscword - 1) / 2;
296 if(
debug)
cout<<
" SC number of bx read-out: " << bx_received << endl;
298 wordCounter++; word = index[
swap(wordCounter)];
308 <<
" SC bunch counter = "
309 << scEventBX << endl;
316 wordCounter++; word = index[
swap(wordCounter)];
323 int bx_counter = int(round( (leftword + 1)/ 2.));
326 if(bx_counter < 0 || leftword < 0)
327 cout<<
"[DTROS25Unpacker]: SC data more than expected; negative bx counter reached! "<<endl;
340 cout<<
" at BX "<< bx_counter
341 <<
" lower part has trigger! with track quality "
344 cout<<
" at BX "<< bx_counter
345 <<
" upper part has trigger! with track quality "
349 if (writeSC && SCwheel >= -2 && SCsector >=1 ) {
354 if ( stationGroup%2 == 0) SCstation = 1;
360 DTChamberId chamberId (SCwheel,SCstation,SCsector);
361 triggerProduct->insertDigi(chamberId,localtrigger);
363 cout<<
"Add SC digi to the collection, for chamber: " << chamberId
365 localtrigger.
print(); }
368 if ( stationGroup%2 == 0) SCstation = 2;
374 DTChamberId chamberId (SCwheel,SCstation,SCsector);
375 triggerProduct->insertDigi(chamberId,localtrigger);
377 cout<<
"Add SC digi to the collection, for chamber: " << chamberId
379 localtrigger.
print();
398 if (
debug)
cout<<
" SC Trailer, # of words: "
414 if (performDataIntegrityMonitor) {
415 dataMonitor->processROS25(controlData, dduID, rosID);
417 controlDataFromAllROS.push_back(controlData);
422 else if (index[
swap(wordCounter)] == 0) {
426 if (
debug)
cout<<
"[DTROS25Unpacker]: odd number of ROS words"<<endl;
431 cout<<
"[DTROS25Unpacker]: ERROR! First word is not a ROS Header"<<endl;
435 wordCounter++; word = index[
swap(wordCounter)];
447 if (n%2==0) result = (n+1);
448 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)