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