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
00039 for ( int i = 1; i < numberOfWords; i++ ) {
00040
00041
00042 uint32_t word = index[i];
00043
00044
00045 int type = ( word >> 28 ) & 0xF;
00046
00047
00048 if ( type == 15 ) {
00049 robID = word & 0x7;
00050 rosID = ( word >> 3 ) & 0xFF;
00051 }
00052
00053
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
00069 dduID = pset.getUntrackedParameter<int>("dduID",730);
00070
00071
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
00078 DTDigi digi(wire, tdcMeasurement, hitOrder[channelIndex]-1);
00079
00080
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 }