CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/EventFilter/DTRawToDigi/plugins/DTROS8Unpacker.cc

Go to the documentation of this file.
00001 
00009 #include <EventFilter/DTRawToDigi/plugins/DTROS8Unpacker.h>
00010 #include <CondFormats/DTObjects/interface/DTReadOutMapping.h>
00011 #include <FWCore/Utilities/interface/Exception.h>
00012 #include <DataFormats/MuonDetId/interface/DTWireId.h> 
00013 
00014 #include <iostream>
00015 #include <map>
00016 
00017 
00018 using namespace std;
00019 using namespace edm;
00020 using namespace cms;
00021 
00022 void DTROS8Unpacker::interpretRawData(const unsigned int* index, int datasize,
00023                                       int dduID,
00024                                       edm::ESHandle<DTReadOutMapping>& mapping, 
00025                                       std::auto_ptr<DTDigiCollection>& product,
00026                                       std::auto_ptr<DTLocalTriggerCollection>& product2,
00027                                       uint16_t rosList) {
00028  
00029 
00031   const int wordLength = 4;
00032   int numberOfWords = datasize / wordLength;
00033   int robID = 0;
00034   int rosID = 0;
00035 
00036   map<int,int> hitOrder;
00037 
00038   // Loop over the ROS8 words
00039   for ( int i = 1; i < numberOfWords; i++ ) {
00040 
00041     // The word
00042     uint32_t word = index[i];
00043 
00044     // The word type
00045     int type = ( word >> 28 ) & 0xF;
00046 
00047     // Event Header 
00048     if ( type == 15 ) {
00049       robID =   word        & 0x7;
00050       rosID = ( word >> 3 ) & 0xFF;
00051     } 
00052 
00053     // TDC Measurement
00054     else if ( type >= 4 && type <= 5 ) {
00055       
00056       int tdcID = ( word >> 24 ) & 0xF;
00057       int tdcChannel = ( word >> 19 ) & 0x1F;
00058 
00059       int channelIndex = robID << 7 | tdcID << 5 | tdcChannel;
00060       hitOrder[channelIndex]++;
00061 
00062       int tdcMeasurement =  word  & 0x7FFFF;
00063       tdcMeasurement >>= 2;
00064 
00065 
00066       try {
00067 
00068         // Check the ddu ID in the mapping been used
00069         dduID = pset.getUntrackedParameter<int>("dduID",730);
00070 
00071         // Map the RO channel to the DetId and wire
00072         DTWireId detId; 
00073         if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,detId)) {
00074           if (pset.getUntrackedParameter<bool>("debugMode",false)) cout<<"[DTROS8Unpacker] "<<detId<<endl;
00075           int wire = detId.wire();
00076           
00077           // Produce the digi
00078           DTDigi digi(wire, tdcMeasurement, hitOrder[channelIndex]-1);
00079           
00080           // Commit to the event
00081           product->insertDigi(detId.layerId(),digi);
00082         }
00083         else if (pset.getUntrackedParameter<bool>("debugMode",false)) 
00084           cout<<"[DTROS8Unpacker] Missing wire!"<<endl;
00085       }
00086 
00087       catch (cms::Exception & e1) {
00088         cout<<"[DTUnpackingModule]: WARNING: Digi not build!"<<endl; 
00089         return;
00090       }
00091     }
00092     
00093   }
00094 }