CMS 3D CMS Logo

DTDigiToRaw.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <iostream>
6 
7 using namespace edm;
8 using namespace std;
9 
11  debug = pset.getUntrackedParameter<bool>("debugMode", false);
12  if (debug)
13  cout << "[DTDigiToRaw]: constructor" << endl;
14 }
15 
17  if (debug)
18  cout << "[DTDigiToRaw]: destructor" << endl;
19 }
20 
22  int NROS = 12;
23  int NROB = 25;
24 
25  vector<uint32_t> words;
26 
28  << WORDTYPESHIFT;
29 
31  << WORDTYPESHIFT;
32 
33  int NWords = 2;
34  words.push_back(0);
35  words.push_back(0);
36 
38  detUnitIt = digis.begin();
39 
40  bool b_ros[12] = {false, false, false, false, false, false, false, false, false, false, false, false};
41  vector<uint32_t> w_ROBROS[12][25];
42 
43  for (detUnitIt = digis.begin(); detUnitIt != digis.end(); ++detUnitIt) {
44  const DTLayerId layerId = (*detUnitIt).first;
45  const DTDigiCollection::Range& digiRange = (*detUnitIt).second;
46  // Loop over all digis in the given range
47 
48  for (DTDigiCollection::const_iterator digi = digiRange.first; digi != digiRange.second; digi++) {
49  int dduId = -1, rosId = -1, robId = -1, tdcId = -1, channelId = -1;
50 
51  int layer = layerId.layer();
52  DTSuperLayerId superlayerID = layerId.superlayerId();
53  int superlayer = superlayerID.superlayer();
54  DTChamberId chamberID = superlayerID.chamberId();
55  int station = chamberID.station();
56  int wheel = chamberID.wheel();
57  int sector = chamberID.sector();
58 
59  int searchstatus = map->geometryToReadOut(wheel,
60  station,
61  sector,
62  superlayer,
63  layer,
64  (*digi).wire(), //"input"
65  dduId,
66  rosId,
67  robId,
68  tdcId,
69  channelId); //"output"
70 
71  if (searchstatus == 1 && debug)
72  cout << "[DTDigiToRaw]: warning, geometryToReadOut status = 1" << endl;
73 
74  //create FED corresponding to current ddu
75  if (dduID_ != dduId)
76  continue;
77 
78  DTTDCMeasurementWord dttdc_mw;
79  uint32_t word;
80  int ntdc = (*digi).countsTDC();
81  dttdc_mw.set(word, 0, 0, 0, tdcId, channelId, ntdc * 4); //FIXME
82 
83  //provisional fix
84  DTTDCMeasurementWord tdcMeasurementWord(word);
85  int tdcIDCheck = tdcMeasurementWord.tdcID();
86  int tdcChannelCheck = tdcMeasurementWord.tdcChannel();
87  int tdcCountsCheck = tdcMeasurementWord.tdcTime();
88  if (tdcIDCheck == tdcId && channelId == tdcChannelCheck && ntdc == tdcCountsCheck) {
89  if (rosId <= NROS && rosId > 0)
90  b_ros[rosId - 1] = true;
91  else if (debug) {
92  cout << "[DTDigiToRaw]: invalid value for rosId" << endl;
93  }
94 
95  w_ROBROS[rosId - 1][robId].push_back(word);
96  }
97  }
98  }
99 
100  uint32_t therosList = 0;
101  for (int i_ros = 0; i_ros < NROS; i_ros++) {
102  if (b_ros[i_ros])
103  therosList += uint32_t(pow(2.0, i_ros));
104  }
105 
106  if (debug)
107  cout << "[DTDigiToRaw]: therosList = " << therosList << endl;
108 
109  for (int i_ros = 0; i_ros < NROS; i_ros++) {
110  if (b_ros[i_ros]) {
111  words.push_back(fakeROSHeaderWord);
112  NWords++;
113  }
114 
115  for (int i_rob = 0; i_rob < NROB; i_rob++) {
116  vector<uint32_t>::const_iterator i_robros;
117  if (w_ROBROS[i_ros][i_rob].begin() != w_ROBROS[i_ros][i_rob].end()) {
118  uint32_t word = 0;
119  DTROBHeaderWord rob_header;
120  rob_header.set(word, i_rob, 0, 0);
121  //static void set(uint32_t &word, int rob_id, int event_id, int bunch_id)
122  words.push_back(word);
123  NWords++;
124 
125  int n_robros = 0;
126  for (i_robros = w_ROBROS[i_ros][i_rob].begin(); i_robros != w_ROBROS[i_ros][i_rob].end(); i_robros++) {
127  NWords++;
128  words.push_back((*i_robros));
129  n_robros++;
130  }
131 
132  NWords++;
133  DTROBTrailerWord rob_trailer;
134  rob_trailer.set(word, i_rob, 0, n_robros + 2);
135  //static void set(uint32_t &word, int rob_id, int event_id, int word_count)
136  words.push_back(word);
137  }
138  }
139 
140  if (b_ros[i_ros]) {
141  words.push_back(fakeROSTrailerWord);
142  NWords++;
143  }
144  }
145 
146  if (NWords % 2 == 1) {
147  words.push_back(0);
148  NWords++;
149  }
150 
151  words.push_back(0);
152  words.push_back(0);
153  //include rosList in raw data information
154  uint32_t secondstatusword = therosList << 16;
155  words.push_back(secondstatusword);
156 
157  words.push_back(0);
158  words.push_back(0);
159  words.push_back(0);
160 
161  // Write Raw Data
162  int dataSize = words.size() * sizeof(Word32);
163  FEDRawData* rawData = new FEDRawData(dataSize);
164  Word64* word64 = reinterpret_cast<Word64*>(rawData->data());
165  for (unsigned int i = 0; i < words.size(); i += 2) {
166  *word64 = (Word64(words[i]) << 32) | words[i + 1];
167  word64++;
168  }
169 
170  return rawData;
171 }
172 
173 void DTDigiToRaw::SetdduID(int x) { dduID_ = x; }
DTDigiToRaw(const edm::ParameterSet &ps)
Constructor.
Definition: DTDigiToRaw.cc:10
int tdcTime() const
Definition: DTDDUWords.h:492
#define WORDCONTROLSHIFT
Definition: DTDDUWords.h:11
void SetdduID(int dduid)
Definition: DTDigiToRaw.cc:173
int tdcChannel() const
Definition: DTDDUWords.h:491
static void set(uint32_t &word, int rob_id, int event_id, int bunch_id)
Definition: DTDDUWords.h:357
static const uint32_t trailerControlWord
Definition: DTDDUWords.h:180
constexpr int pow(int x)
Definition: conifer.h:24
static void set(uint32_t &word, int rob_id, int event_id, int word_count)
Definition: DTDDUWords.h:389
unsigned int Word32
Definition: DTDigiToRaw.h:28
int tdcID() const
<== OBSOLETE!!
Definition: DTDDUWords.h:490
T getUntrackedParameter(std::string const &, T const &) const
uint64_t word
const edm::ParameterSet pset
Definition: DTDigiToRaw.h:30
DTChamberId chamberId() const
Return the corresponding ChamberId.
CSCDetId chamberID(const CSCDetId &cscDetId)
#define WORDTYPESHIFT
Definition: DTDDUWords.h:13
FEDRawData * createFedBuffers(const DTDigiCollection &digis, edm::ESHandle< DTReadOutMapping > &mapping)
Take a vector of digis and fill the FEDRawDataCollection.
Definition: DTDigiToRaw.cc:21
long long Word64
Definition: DTDigiToRaw.h:29
int superlayer() const
Return the superlayer number (deprecated method name)
int station() const
Definition: CSCDetId.h:79
std::pair< const_iterator, const_iterator > Range
static const uint32_t rosTypeWord
Word Type bits definitions.
Definition: DTDDUWords.h:188
std::vector< DigiType >::const_iterator const_iterator
static void set(uint32_t &word, int pc, int paf, int hu, int tdc_id, int tdc_channel, int tdc_time)
Definition: DTDDUWords.h:494
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
HLT enums.
virtual ~DTDigiToRaw()
Destructor.
Definition: DTDigiToRaw.cc:16
float x
static const uint32_t headerControlWord
Control bits definitions.
Definition: DTDDUWords.h:179
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45