CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTROS8Unpacker.cc
Go to the documentation of this file.
1 
13 
14 #include <iostream>
15 #include <map>
16 
17 
18 using namespace std;
19 using namespace edm;
20 using namespace cms;
21 
22 void DTROS8Unpacker::interpretRawData(const unsigned int* index, int datasize,
23  int dduID,
25  std::auto_ptr<DTDigiCollection>& product,
26  std::auto_ptr<DTLocalTriggerCollection>& product2,
27  uint16_t rosList) {
28 
29 
31  const int wordLength = 4;
32  int numberOfWords = datasize / wordLength;
33  int robID = 0;
34  int rosID = 0;
35 
36  map<int,int> hitOrder;
37 
38  // Loop over the ROS8 words
39  for ( int i = 1; i < numberOfWords; i++ ) {
40 
41  // The word
42  uint32_t word = index[i];
43 
44  // The word type
45  int type = ( word >> 28 ) & 0xF;
46 
47  // Event Header
48  if ( type == 15 ) {
49  robID = word & 0x7;
50  rosID = ( word >> 3 ) & 0xFF;
51  }
52 
53  // TDC Measurement
54  else if ( type >= 4 && type <= 5 ) {
55 
56  int tdcID = ( word >> 24 ) & 0xF;
57  int tdcChannel = ( word >> 19 ) & 0x1F;
58 
59  int channelIndex = robID << 7 | tdcID << 5 | tdcChannel;
60  hitOrder[channelIndex]++;
61 
62  int tdcMeasurement = word & 0x7FFFF;
63  tdcMeasurement >>= 2;
64 
65 
66  try {
67 
68  // Check the ddu ID in the mapping been used
69  dduID = pset.getUntrackedParameter<int>("dduID",730);
70 
71  // Map the RO channel to the DetId and wire
72  DTWireId detId;
73  if ( ! mapping->readOutToGeometry(dduID, rosID, robID, tdcID, tdcChannel,detId)) {
74  if (pset.getUntrackedParameter<bool>("debugMode",false)) cout<<"[DTROS8Unpacker] "<<detId<<endl;
75  int wire = detId.wire();
76 
77  // Produce the digi
78  DTDigi digi(wire, tdcMeasurement, hitOrder[channelIndex]-1);
79 
80  // Commit to the event
81  product->insertDigi(detId.layerId(),digi);
82  }
83  else if (pset.getUntrackedParameter<bool>("debugMode",false))
84  cout<<"[DTROS8Unpacker] Missing wire!"<<endl;
85  }
86 
87  catch (cms::Exception & e1) {
88  cout<<"[DTUnpackingModule]: WARNING: Digi not build!"<<endl;
89  return;
90  }
91  }
92 
93  }
94 }
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)
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
Definition: DTDigi.h:19
tuple cout
Definition: gather_cfg.py:121