CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DTuROSDigiToRaw Class Reference

#include <DTuROSDigiToRaw.h>

Inheritance diagram for DTuROSDigiToRaw:
edm::stream::EDProducer<>

Public Member Functions

 DTuROSDigiToRaw (const edm::ParameterSet &pset)
 Constructor. More...
 
bool fillRawData (edm::Event &e, const edm::EventSetup &c, FEDRawDataCollection &data)
 Generate and fill FED raw data for a full event. More...
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 Produce digis out of raw data. More...
 
 ~DTuROSDigiToRaw () override
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void clear ()
 
edm::InputTag getDTDigiInputTag ()
 
void process (int DTuROSFED, edm::Handle< DTDigiCollection > digis, edm::ESHandle< DTReadOutMapping > mapping, FEDRawDataCollection &data)
 
int theCRT (int ddu, int ros)
 
int theLNK (int ddu, int ros, int rob)
 
int theSLT (int ddu, int ros, int rob)
 

Private Attributes

int bslts [DOCESLOTS]
 
bool debug_
 
int dslts [DOCESLOTS]
 
edm::InputTag DTDigiInputTag_
 
unsigned int eventNum
 
std::vector< int > feds_
 
edm::ESGetToken< DTReadOutMapping, DTReadOutMappingRcdmapping_token_
 
int nfeds_
 
edm::EDGetTokenT< DTDigiCollectionRaw_token
 
std::vector< int > wslts [DOCESLOTS]
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

L1 DT uROS Raw-to-Digi

J. Troconiz - UAM Madrid

Definition at line 37 of file DTuROSDigiToRaw.h.

Constructor & Destructor Documentation

◆ DTuROSDigiToRaw()

DTuROSDigiToRaw::DTuROSDigiToRaw ( const edm::ParameterSet pset)

Constructor.

Definition at line 24 of file DTuROSDigiToRaw.cc.

24  : eventNum(0) {
25  produces<FEDRawDataCollection>();
26 
27  DTDigiInputTag_ = pset.getParameter<edm::InputTag>("digiColl");
28 
29  debug_ = pset.getUntrackedParameter<bool>("debug", false);
30 
32  feds_.push_back(i);
33 
34  nfeds_ = feds_.size();
35 
36  Raw_token = consumes<DTDigiCollection>(DTDigiInputTag_);
37  mapping_token_ = esConsumes<DTReadOutMapping, DTReadOutMappingRcd>();
38 }

References debug_, DTDigiInputTag_, feds_, mps_fire::i, mapping_token_, FEDNumbering::MAXDTUROSFEDID, FEDNumbering::MINDTUROSFEDID, nfeds_, muonDTDigis_cfi::pset, and Raw_token.

◆ ~DTuROSDigiToRaw()

DTuROSDigiToRaw::~DTuROSDigiToRaw ( )
override

Destructor.

Definition at line 40 of file DTuROSDigiToRaw.cc.

40 {}

Member Function Documentation

◆ clear()

void DTuROSDigiToRaw::clear ( void  )
private

Definition at line 278 of file DTuROSDigiToRaw.cc.

278  {
279  for (int sltit = 0; sltit < DOCESLOTS; sltit++) {
280  bslts[sltit] = 0;
281  dslts[sltit] = 0;
282  wslts[sltit].clear();
283  }
284 
285  return;
286 }

References bslts, DOCESLOTS, dslts, and wslts.

Referenced by process().

◆ fillRawData()

bool DTuROSDigiToRaw::fillRawData ( edm::Event e,
const edm::EventSetup c,
FEDRawDataCollection data 
)

Generate and fill FED raw data for a full event.

Definition at line 53 of file DTuROSDigiToRaw.cc.

53  {
54  eventNum = e.id().event();
55 
57  e.getByToken(Raw_token, digis);
58 
60 
61  for (int w_i = 0; w_i < nfeds_; ++w_i) {
62  process(feds_[w_i], digis, mapping, data);
63  }
64 
65  return true;
66 }

References HltBtagPostValidation_cff::c, data, MillePedeFileConverter_cfg::e, eventNum, feds_, taus_updatedMVAIds_cff::mapping, mapping_token_, nfeds_, process(), and Raw_token.

Referenced by produce().

◆ getDTDigiInputTag()

edm::InputTag DTuROSDigiToRaw::getDTDigiInputTag ( )
inlineprivate

Definition at line 84 of file DTuROSDigiToRaw.h.

84 { return DTDigiInputTag_; }

References DTDigiInputTag_.

◆ process()

void DTuROSDigiToRaw::process ( int  DTuROSFED,
edm::Handle< DTDigiCollection digis,
edm::ESHandle< DTReadOutMapping mapping,
FEDRawDataCollection data 
)
private

Definition at line 68 of file DTuROSDigiToRaw.cc.

71  {
72  clear();
73 
74  //--> DTDigi analysis
75 
77  for (dttax = digis->begin(); dttax != digis->end(); ++dttax) {
78  const DTDigiCollection::Range& dttar = (*dttax).second;
79  const DTLayerId dttal = (*dttax).first;
80  for (DTDigiCollection::const_iterator ta = dttar.first; ta != dttar.second; ++ta) {
81  int wheelId = dttal.wheel();
82  int sectorId = dttal.sector();
83  int stationId = dttal.station();
84  int slId = dttal.superlayer();
85  int layerId = dttal.layer();
86  int cellId = (*ta).wire();
87 
88  int dduId, rosId, robId, tdcId, tdcChannel;
89  if (!mapping->geometryToReadOut(
90  wheelId, stationId, sectorId, slId, layerId, cellId, dduId, rosId, robId, tdcId, tdcChannel)) {
91  int crate = theCRT(dduId, rosId);
92 
93  if (crate != DTuROSFED)
94  continue;
95 
96  int slot = theSLT(dduId, rosId, robId);
97  int link = theLNK(dduId, rosId, robId);
98 
99  int tdcTime = (*ta).countsTDC();
100 
101  bslts[slot - 1]++;
102 
103  int word = ((link & 0x7F) << 21) + ((tdcId & 0x03) << 19) + ((tdcChannel & 0x1F) << 14) + (tdcTime & 0x3FFF);
104 
105  wslts[slot - 1].push_back(word);
106  }
107  }
108  }
109 
110  int lines = 4;
111  int nslts = 0;
112 
113  for (int sltit = 0; sltit < DOCESLOTS; sltit++) {
114  if (bslts[sltit] == 0)
115  continue;
116  nslts += 1;
117  lines += 1;
118 
119  dslts[sltit] = ((bslts[sltit] + 1) / 2) + 5;
120  lines += dslts[sltit];
121  }
122 
123  FEDRawData& dttfdata = data.FEDData(DTuROSFED);
124  dttfdata.resize(lines * 8); // size in bytes
125  unsigned char* lineFED = dttfdata.data();
126 
127  int dataWord1, dataWord2;
128 
129  //--> Header
130 
131  dataWord1 = 0x50000000 + (eventNum & 0xFFFFFF);
132  dataWord2 = (DTuROSFED & 0xFFF) << 8;
133 
134  int newCRC = 0xFFFF;
135  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
136 
137  *((int*)lineFED) = dataWord2;
138  lineFED += 4;
139  *((int*)lineFED) = dataWord1;
140 
141  //--> AMC sizes
142 
143  dataWord1 = (nslts & 0xF) << 20;
144  dataWord2 = 0;
145 
146  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
147 
148  lineFED += 4;
149  *((int*)lineFED) = dataWord2;
150  lineFED += 4;
151  *((int*)lineFED) = dataWord1;
152 
153  for (int sltit = 0; sltit < DOCESLOTS; sltit++) {
154  if (bslts[sltit] == 0)
155  continue;
156 
157  dataWord1 = (dslts[sltit] & 0xFFFFFF);
158  dataWord2 = ((sltit + 1) & 0xF) << 16;
159 
160  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
161 
162  lineFED += 4;
163  *((int*)lineFED) = dataWord2;
164  lineFED += 4;
165  *((int*)lineFED) = dataWord1;
166  }
167 
168  //--> AMC data
169 
170  for (int sltit = 0; sltit < DOCESLOTS; sltit++) {
171  if (bslts[sltit] == 0)
172  continue;
173 
174  dataWord1 = ((sltit + 1) & 0xF) << 24;
175  dataWord2 = 0;
176 
177  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
178 
179  lineFED += 4;
180  *((int*)lineFED) = dataWord2;
181  lineFED += 4;
182  *((int*)lineFED) = dataWord1;
183 
184  dataWord1 = 0;
185  dataWord2 = 0;
186 
187  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
188 
189  lineFED += 4;
190  *((int*)lineFED) = dataWord2;
191  lineFED += 4;
192  *((int*)lineFED) = dataWord1;
193 
194  for (int nhit = 0; nhit < bslts[sltit] / 2; nhit++) {
195  dataWord1 = 0x20000000 + wslts[sltit].at(nhit * 2);
196  dataWord2 = wslts[sltit].at(nhit * 2 + 1);
197 
198  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
199 
200  lineFED += 4;
201  *((int*)lineFED) = dataWord2;
202  lineFED += 4;
203  *((int*)lineFED) = dataWord1;
204  }
205 
206  if (bslts[sltit] % 2 == 1) {
207  dataWord1 = 0x20000000 + wslts[sltit].at(bslts[sltit] - 1);
208  dataWord2 = 0x1FFFFFFF;
209 
210  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
211 
212  lineFED += 4;
213  *((int*)lineFED) = dataWord2;
214  lineFED += 4;
215  *((int*)lineFED) = dataWord1;
216  }
217 
218  dataWord1 = 0x40000000;
219  dataWord2 = 0;
220 
221  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
222 
223  lineFED += 4;
224  *((int*)lineFED) = dataWord2;
225  lineFED += 4;
226  *((int*)lineFED) = dataWord1;
227 
228  dataWord1 = 0x40000000;
229  dataWord2 = 0;
230 
231  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
232 
233  lineFED += 4;
234  *((int*)lineFED) = dataWord2;
235  lineFED += 4;
236  *((int*)lineFED) = dataWord1;
237 
238  dataWord1 = 0;
239  dataWord2 = (dslts[sltit] & 0xFFFFF);
240 
241  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
242 
243  lineFED += 4;
244  *((int*)lineFED) = dataWord2;
245  lineFED += 4;
246  *((int*)lineFED) = dataWord1;
247  }
248 
249  //--> Trailer - line 1
250 
251  dataWord1 = 0;
252  dataWord2 = 0;
253 
254  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
255 
256  lineFED += 4;
257  *((int*)lineFED) = dataWord2;
258  lineFED += 4;
259  *((int*)lineFED) = dataWord1;
260 
261  //--> Trailer - line 2
262 
263  dataWord1 = 0xA0000000 + (lines & 0xFFFFFF);
264  dataWord2 = 0;
265 
266  dt_crc::calcCRC(dataWord1, dataWord2 & 0xFFFF, newCRC);
267 
268  dataWord2 += (newCRC & 0xFFFF) << 16;
269 
270  lineFED += 4;
271  *((int*)lineFED) = dataWord2;
272  lineFED += 4;
273  *((int*)lineFED) = dataWord1;
274 
275  return;
276 }

References bslts, dt_crc::calcCRC(), clear(), FEDRawData::data(), data, DOCESLOTS, dslts, eventNum, DTLayerId::layer(), groupFilesInBlocks::lines, MainPageGenerator::link, taus_updatedMVAIds_cff::mapping, FEDRawData::resize(), DTChamberId::sector(), DTChamberId::station(), DTSuperLayerId::superlayer(), theCRT(), theLNK(), theSLT(), DTChamberId::wheel(), and wslts.

Referenced by fillRawData().

◆ produce()

void DTuROSDigiToRaw::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Produce digis out of raw data.

Definition at line 42 of file DTuROSDigiToRaw.cc.

42  {
44 
45  if (!fillRawData(e, c, data))
46  return;
47 
48  auto fed_product = std::make_unique<FEDRawDataCollection>(data);
49 
50  e.put(std::move(fed_product));
51 }

References HltBtagPostValidation_cff::c, data, MillePedeFileConverter_cfg::e, fillRawData(), and eostools::move().

◆ theCRT()

int DTuROSDigiToRaw::theCRT ( int  ddu,
int  ros 
)
private

Definition at line 288 of file DTuROSDigiToRaw.cc.

288  {
289  if (ros > 6 && ddu > 774)
290  ddu = ddu - 5;
291 
292  if (ddu == 770)
294  else if (ddu == 771)
296  else if (ddu == 772)
297  return FEDNumbering::MINDTUROSFEDID + 1;
299 }

References FEDNumbering::MAXDTUROSFEDID, and FEDNumbering::MINDTUROSFEDID.

Referenced by process().

◆ theLNK()

int DTuROSDigiToRaw::theLNK ( int  ddu,
int  ros,
int  rob 
)
private

Definition at line 315 of file DTuROSDigiToRaw.cc.

315  {
316  int link = rob;
317  if (rob > 14)
318  link = rob + 1;
319  if (rob == 24)
320  link = 15;
321  link += ((ros - 1) % 3) * 24;
322  if (rob == 23)
323  link = ros - 1;
324  return link;
325 }

References MainPageGenerator::link.

Referenced by process().

◆ theSLT()

int DTuROSDigiToRaw::theSLT ( int  ddu,
int  ros,
int  rob 
)
private

Definition at line 301 of file DTuROSDigiToRaw.cc.

301  {
302  if (ros > 6 && ddu > 774)
303  ddu = ddu - 5;
304 
305  int slot = ((ros - 1) / 3) + 1;
306  if (rob == 23)
307  slot = 5;
308  if (ddu == 771)
309  slot += 6;
310  else if (ddu == 774)
311  slot += 6;
312  return slot;
313 }

Referenced by process().

Member Data Documentation

◆ bslts

int DTuROSDigiToRaw::bslts[DOCESLOTS]
private

Definition at line 62 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().

◆ debug_

bool DTuROSDigiToRaw::debug_
private

Definition at line 56 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw().

◆ dslts

int DTuROSDigiToRaw::dslts[DOCESLOTS]
private

Definition at line 62 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().

◆ DTDigiInputTag_

edm::InputTag DTuROSDigiToRaw::DTDigiInputTag_
private

Definition at line 54 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and getDTDigiInputTag().

◆ eventNum

unsigned int DTuROSDigiToRaw::eventNum
private

Definition at line 52 of file DTuROSDigiToRaw.h.

Referenced by fillRawData(), and process().

◆ feds_

std::vector<int> DTuROSDigiToRaw::feds_
private

Definition at line 60 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

◆ mapping_token_

edm::ESGetToken<DTReadOutMapping, DTReadOutMappingRcd> DTuROSDigiToRaw::mapping_token_
private

Definition at line 87 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

◆ nfeds_

int DTuROSDigiToRaw::nfeds_
private

Definition at line 58 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

◆ Raw_token

edm::EDGetTokenT<DTDigiCollection> DTuROSDigiToRaw::Raw_token
private

Definition at line 86 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

◆ wslts

std::vector<int> DTuROSDigiToRaw::wslts[DOCESLOTS]
private

Definition at line 64 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().

mps_fire.i
i
Definition: mps_fire.py:428
DTuROSDigiToRaw::theLNK
int theLNK(int ddu, int ros, int rob)
Definition: DTuROSDigiToRaw.cc:315
DTuROSDigiToRaw::dslts
int dslts[DOCESLOTS]
Definition: DTuROSDigiToRaw.h:62
MainPageGenerator.link
link
Definition: MainPageGenerator.py:271
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
DTuROSDigiToRaw::nfeds_
int nfeds_
Definition: DTuROSDigiToRaw.h:58
DTSuperLayerId::superlayer
int superlayer() const
Return the superlayer number (deprecated method name)
Definition: DTSuperLayerId.h:42
DTuROSDigiToRaw::fillRawData
bool fillRawData(edm::Event &e, const edm::EventSetup &c, FEDRawDataCollection &data)
Generate and fill FED raw data for a full event.
Definition: DTuROSDigiToRaw.cc:53
edm::Handle< DTDigiCollection >
FEDNumbering::MINDTUROSFEDID
Definition: FEDNumbering.h:111
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
MuonDigiCollection::const_iterator
std::vector< DigiType >::const_iterator const_iterator
Definition: MuonDigiCollection.h:94
FEDRawData
Definition: FEDRawData.h:19
DTuROSDigiToRaw::Raw_token
edm::EDGetTokenT< DTDigiCollection > Raw_token
Definition: DTuROSDigiToRaw.h:86
word
uint64_t word
Definition: CTPPSTotemDataFormatter.cc:29
edm::ESHandle< DTReadOutMapping >
DTuROSDigiToRaw::feds_
std::vector< int > feds_
Definition: DTuROSDigiToRaw.h:60
DTuROSDigiToRaw::debug_
bool debug_
Definition: DTuROSDigiToRaw.h:56
DTLayerId
Definition: DTLayerId.h:12
groupFilesInBlocks.lines
lines
Definition: groupFilesInBlocks.py:95
DTuROSDigiToRaw::mapping_token_
edm::ESGetToken< DTReadOutMapping, DTReadOutMappingRcd > mapping_token_
Definition: DTuROSDigiToRaw.h:87
DTuROSDigiToRaw::process
void process(int DTuROSFED, edm::Handle< DTDigiCollection > digis, edm::ESHandle< DTReadOutMapping > mapping, FEDRawDataCollection &data)
Definition: DTuROSDigiToRaw.cc:68
DOCESLOTS
static const int DOCESLOTS
Definition: DTuROSControlData.h:19
DTuROSDigiToRaw::bslts
int bslts[DOCESLOTS]
Definition: DTuROSDigiToRaw.h:62
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
eostools.move
def move(src, dest)
Definition: eostools.py:511
dt_crc::calcCRC
void calcCRC(long, int &)
Definition: DTCRC.cc:3
DTuROSDigiToRaw::theSLT
int theSLT(int ddu, int ros, int rob)
Definition: DTuROSDigiToRaw.cc:301
DTuROSDigiToRaw::theCRT
int theCRT(int ddu, int ros)
Definition: DTuROSDigiToRaw.cc:288
FEDRawData::resize
void resize(size_t newsize)
Definition: FEDRawData.cc:28
DTuROSDigiToRaw::DTDigiInputTag_
edm::InputTag DTDigiInputTag_
Definition: DTuROSDigiToRaw.h:54
DTuROSDigiToRaw::eventNum
unsigned int eventNum
Definition: DTuROSDigiToRaw.h:52
MuonDigiCollection::Range
std::pair< const_iterator, const_iterator > Range
Definition: MuonDigiCollection.h:95
DTuROSDigiToRaw::clear
void clear()
Definition: DTuROSDigiToRaw.cc:278
DTuROSDigiToRaw::wslts
std::vector< int > wslts[DOCESLOTS]
Definition: DTuROSDigiToRaw.h:64
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
DigiContainerIterator
Definition: MuonDigiCollection.h:30
DTLayerId::layer
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
FEDNumbering::MAXDTUROSFEDID
Definition: FEDNumbering.h:112
taus_updatedMVAIds_cff.mapping
mapping
Definition: taus_updatedMVAIds_cff.py:29
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
edm::InputTag
Definition: InputTag.h:15
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37