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