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 hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () 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_
 
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 34 of file DTuROSDigiToRaw.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 26 of file DTuROSDigiToRaw.cc.

References debug_, DTDigiInputTag_, feds_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, FEDNumbering::MAXDTUROSFEDID, FEDNumbering::MINDTUROSFEDID, nfeds_, and Raw_token.

26  : eventNum(0) {
27  produces<FEDRawDataCollection>();
28 
29  DTDigiInputTag_ = pset.getParameter<edm::InputTag>("digiColl");
30 
31  debug_ = pset.getUntrackedParameter<bool>("debug", false);
32 
34  feds_.push_back(i);
35 
36  nfeds_ = feds_.size();
37 
38  Raw_token = consumes<DTDigiCollection>(DTDigiInputTag_);
39 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag DTDigiInputTag_
std::vector< int > feds_
unsigned int eventNum
edm::EDGetTokenT< DTDigiCollection > Raw_token
DTuROSDigiToRaw::~DTuROSDigiToRaw ( )
override

Destructor.

Definition at line 41 of file DTuROSDigiToRaw.cc.

41 {}

Member Function Documentation

void DTuROSDigiToRaw::clear ( void  )
private
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 54 of file DTuROSDigiToRaw.cc.

References edm::EventID::event(), eventNum, feds_, edm::EventSetup::get(), edm::Event::getByToken(), edm::EventBase::id(), taus_updatedMVAIds_cff::mapping, nfeds_, process(), and Raw_token.

Referenced by produce().

54  {
55  eventNum = e.id().event();
56 
58  e.getByToken(Raw_token, digis);
59 
61  c.get<DTReadOutMappingRcd>().get(mapping);
62 
63  for (int w_i = 0; w_i < nfeds_; ++w_i) {
64  process(feds_[w_i], digis, mapping, data);
65  }
66 
67  return true;
68 }
EventNumber_t event() const
Definition: EventID.h:40
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< int > feds_
unsigned int eventNum
edm::EDGetTokenT< DTDigiCollection > Raw_token
void process(int DTuROSFED, edm::Handle< DTDigiCollection > digis, edm::ESHandle< DTReadOutMapping > mapping, FEDRawDataCollection &data)
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:73
edm::InputTag DTuROSDigiToRaw::getDTDigiInputTag ( )
inlineprivate

Definition at line 81 of file DTuROSDigiToRaw.h.

References DTDigiInputTag_.

81 { return DTDigiInputTag_; }
edm::InputTag DTDigiInputTag_
void DTuROSDigiToRaw::process ( int  DTuROSFED,
edm::Handle< DTDigiCollection digis,
edm::ESHandle< DTReadOutMapping mapping,
FEDRawDataCollection data 
)
private

Definition at line 70 of file DTuROSDigiToRaw.cc.

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

Referenced by Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::dumpPython(), fillRawData(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::open(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::outputEventContent(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProcess(), and Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor::setProperty().

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

Produce digis out of raw data.

Definition at line 43 of file DTuROSDigiToRaw.cc.

References data, fillRawData(), eostools::move(), and edm::Event::put().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

43  {
45 
46  if (!fillRawData(e, c, data))
47  return;
48 
49  auto fed_product = std::make_unique<FEDRawDataCollection>(data);
50 
51  e.put(std::move(fed_product));
52 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool fillRawData(edm::Event &e, const edm::EventSetup &c, FEDRawDataCollection &data)
Generate and fill FED raw data for a full event.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
def move(src, dest)
Definition: eostools.py:511
int DTuROSDigiToRaw::theCRT ( int  ddu,
int  ros 
)
private

Definition at line 290 of file DTuROSDigiToRaw.cc.

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

Referenced by process().

290  {
291  if (ros > 6 && ddu > 774)
292  ddu = ddu - 5;
293 
294  if (ddu == 770)
296  else if (ddu == 771)
298  else if (ddu == 772)
299  return FEDNumbering::MINDTUROSFEDID + 1;
301 }
int DTuROSDigiToRaw::theLNK ( int  ddu,
int  ros,
int  rob 
)
private

Definition at line 317 of file DTuROSDigiToRaw.cc.

References DEFINE_FWK_MODULE, and MainPageGenerator::link.

Referenced by process().

317  {
318  int link = rob;
319  if (rob > 14)
320  link = rob + 1;
321  if (rob == 24)
322  link = 15;
323  link += ((ros - 1) % 3) * 24;
324  if (rob == 23)
325  link = ros - 1;
326  return link;
327 }
int DTuROSDigiToRaw::theSLT ( int  ddu,
int  ros,
int  rob 
)
private

Definition at line 303 of file DTuROSDigiToRaw.cc.

Referenced by process().

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

Member Data Documentation

int DTuROSDigiToRaw::bslts[DOCESLOTS]
private

Definition at line 59 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().

bool DTuROSDigiToRaw::debug_
private

Definition at line 53 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw().

int DTuROSDigiToRaw::dslts[DOCESLOTS]
private

Definition at line 59 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().

edm::InputTag DTuROSDigiToRaw::DTDigiInputTag_
private

Definition at line 51 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and getDTDigiInputTag().

unsigned int DTuROSDigiToRaw::eventNum
private

Definition at line 49 of file DTuROSDigiToRaw.h.

Referenced by fillRawData(), and process().

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

Definition at line 57 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

int DTuROSDigiToRaw::nfeds_
private

Definition at line 55 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

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

Definition at line 83 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

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

Definition at line 61 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().