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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 35 of file DTuROSDigiToRaw.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 27 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.

27  : eventNum(0) {
28 
29  produces<FEDRawDataCollection>();
30 
31  DTDigiInputTag_ = pset.getParameter<edm::InputTag>("digiColl");
32 
33  debug_ = pset.getUntrackedParameter<bool>("debug", false);
34 
36  feds_.push_back(i);
37 
38  nfeds_ = feds_.size();
39 
40  Raw_token = consumes<DTDigiCollection>(DTDigiInputTag_);
41 
42 }
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 45 of file DTuROSDigiToRaw.cc.

45 {}

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 61 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().

61  {
62 
63  eventNum = e.id().event();
64 
66  e.getByToken(Raw_token, digis);
67 
69  c.get<DTReadOutMappingRcd>().get( mapping );
70 
71  for (int w_i = 0; w_i < nfeds_; ++w_i) {
72  process(feds_[w_i], digis, mapping, data);
73  }
74 
75  return true;
76 }
EventNumber_t event() const
Definition: EventID.h:41
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
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:60
T get() const
Definition: EventSetup.h:68
edm::InputTag DTuROSDigiToRaw::getDTDigiInputTag ( )
inlineprivate

Definition at line 85 of file DTuROSDigiToRaw.h.

References DTDigiInputTag_.

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

Definition at line 79 of file DTuROSDigiToRaw.cc.

References bslts, dt_crc::calcCRC(), clear(), FEDRawData::data(), DOCESLOTS, dslts, eventNum, FEDRawDataCollection::FEDData(), DTReadOutMapping::geometryToReadOut(), DTLayerId::layer(), groupFilesInBlocks::lines, 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().

82  {
83 
84 
85  clear();
86 
87 
88  //--> DTDigi analysis
89 
91  for (dttax = digis->begin(); dttax != digis->end(); ++dttax){
92  const DTDigiCollection::Range& dttar = (*dttax).second;
93  const DTLayerId dttal = (*dttax).first;
94  for (DTDigiCollection::const_iterator ta = dttar.first; ta != dttar.second; ++ta) {
95 
96  int wheelId = dttal.wheel();
97  int sectorId = dttal.sector();
98  int stationId = dttal.station();
99  int slId = dttal.superlayer();
100  int layerId = dttal.layer();
101  int cellId = (*ta).wire();
102 
103  int dduId, rosId, robId, tdcId, tdcChannel;
104  if ( ! mapping->geometryToReadOut(wheelId, stationId, sectorId, slId, layerId, cellId,
105  dduId, rosId, robId, tdcId, tdcChannel)) {
106 
107  int crate = theCRT(dduId, rosId);
108 
109  if (crate != DTuROSFED) continue;
110 
111  int slot = theSLT(dduId, rosId, robId);
112  int link = theLNK(dduId, rosId, robId);
113 
114  int tdcTime = (*ta).countsTDC();
115 
116  bslts[slot-1]++;
117 
118  int word = ( (link&0x7F)<<21)
119  + ( (tdcId&0x03)<<19)
120  + ((tdcChannel&0x1F)<<14)
121  + ( tdcTime&0x3FFF );
122 
123  wslts[slot-1].push_back(word);
124 
125  }
126  }
127  }
128 
129 
130  int lines = 4;
131  int nslts = 0;
132 
133  for (int sltit = 0; sltit < DOCESLOTS; sltit++) {
134 
135  if (bslts[sltit] == 0) continue;
136  nslts += 1;
137  lines += 1;
138 
139  dslts[sltit] = ((bslts[sltit]+1)/2)+5;
140  lines += dslts[sltit];
141  }
142 
143  FEDRawData& dttfdata = data.FEDData(DTuROSFED);
144  dttfdata.resize(lines*8); // size in bytes
145  unsigned char* lineFED=dttfdata.data();
146 
147  int dataWord1, dataWord2;
148 
149  //--> Header
150 
151  dataWord1 = 0x50000000
152  + (eventNum&0xFFFFFF);
153  dataWord2 = (DTuROSFED&0xFFF)<<8;
154 
155  int newCRC = 0xFFFF;
156  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
157 
158  *((int*)lineFED)=dataWord2;
159  lineFED+=4;
160  *((int*)lineFED)=dataWord1;
161 
162  //--> AMC sizes
163 
164  dataWord1 = (nslts&0xF)<<20;
165  dataWord2 = 0;
166 
167  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
168 
169  lineFED+=4;
170  *((int*)lineFED)=dataWord2;
171  lineFED+=4;
172  *((int*)lineFED)=dataWord1;
173 
174  for (int sltit = 0; sltit < DOCESLOTS; sltit++) {
175 
176  if (bslts[sltit] == 0) continue;
177 
178  dataWord1 = (dslts[sltit]&0xFFFFFF);
179  dataWord2 = ((sltit+1)&0xF)<<16;
180 
181  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
182 
183  lineFED+=4;
184  *((int*)lineFED)=dataWord2;
185  lineFED+=4;
186  *((int*)lineFED)=dataWord1;
187  }
188 
189  //--> AMC data
190 
191  for (int sltit = 0; sltit < DOCESLOTS; sltit++) {
192 
193  if (bslts[sltit] == 0) continue;
194 
195  dataWord1 = ((sltit+1)&0xF)<<24;
196  dataWord2 = 0;
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  dataWord1 = 0;
206  dataWord2 = 0;
207 
208  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
209 
210  lineFED+=4;
211  *((int*)lineFED)=dataWord2;
212  lineFED+=4;
213  *((int*)lineFED)=dataWord1;
214 
215  for (int nhit = 0; nhit < bslts[sltit]/2; nhit++) {
216 
217  dataWord1 = 0x20000000
218  + wslts[sltit].at(nhit*2);
219  dataWord2 = wslts[sltit].at(nhit*2+1);
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 
229  if (bslts[sltit]%2 == 1) {
230 
231  dataWord1 = 0x20000000
232  + wslts[sltit].at(bslts[sltit]-1);
233  dataWord2 = 0x1FFFFFFF;
234 
235  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
236 
237  lineFED+=4;
238  *((int*)lineFED)=dataWord2;
239  lineFED+=4;
240  *((int*)lineFED)=dataWord1;
241  }
242 
243  dataWord1 = 0x40000000;
244  dataWord2 = 0;
245 
246  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
247 
248  lineFED+=4;
249  *((int*)lineFED)=dataWord2;
250  lineFED+=4;
251  *((int*)lineFED)=dataWord1;
252 
253  dataWord1 = 0x40000000;
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  dataWord1 = 0;
264  dataWord2 = (dslts[sltit]&0xFFFFF);
265 
266  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
267 
268  lineFED+=4;
269  *((int*)lineFED)=dataWord2;
270  lineFED+=4;
271  *((int*)lineFED)=dataWord1;
272  }
273 
274  //--> Trailer - line 1
275 
276  dataWord1 = 0;
277  dataWord2 = 0;
278 
279  dt_crc::calcCRC(dataWord1, dataWord2, newCRC);
280 
281  lineFED+=4;
282  *((int*)lineFED)=dataWord2;
283  lineFED+=4;
284  *((int*)lineFED)=dataWord1;
285 
286  //--> Trailer - line 2
287 
288  dataWord1 = 0xA0000000
289  + (lines&0xFFFFFF);
290  dataWord2 = 0;
291 
292  dt_crc::calcCRC(dataWord1, dataWord2&0xFFFF, newCRC);
293 
294  dataWord2 += (newCRC&0xFFFF)<<16;
295 
296  lineFED+=4;
297  *((int*)lineFED)=dataWord2;
298  lineFED+=4;
299  *((int*)lineFED)=dataWord1;
300 
301  return;
302 }
std::vector< int > wslts[DOCESLOTS]
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
int theSLT(int ddu, int ros, int rob)
static const int DOCESLOTS
int bslts[DOCESLOTS]
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
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::vector< DTDigi >::const_iterator const_iterator
void calcCRC(long, int &)
Definition: DTCRC.cc:3
int sector() const
Definition: DTChamberId.h:61
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
std::pair< const_iterator, const_iterator > Range
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
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 48 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().

48  {
49 
51 
52  if (!fillRawData(e, c, data)) return;
53 
54  auto fed_product = std::make_unique<FEDRawDataCollection>(data);
55 
56  e.put(std::move(fed_product));
57 
58 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
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:82
def move(src, dest)
Definition: eostools.py:511
int DTuROSDigiToRaw::theCRT ( int  ddu,
int  ros 
)
private

Definition at line 318 of file DTuROSDigiToRaw.cc.

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

Referenced by process().

318  {
319 
320  if (ros > 6 && ddu > 774) ddu = ddu - 5;
321 
322  if (ddu == 770) return FEDNumbering::MINDTUROSFEDID;
323  else if (ddu == 771) return FEDNumbering::MINDTUROSFEDID;
324  else if (ddu == 772) return FEDNumbering::MINDTUROSFEDID+1;
326 }
int DTuROSDigiToRaw::theLNK ( int  ddu,
int  ros,
int  rob 
)
private

Definition at line 341 of file DTuROSDigiToRaw.cc.

References DEFINE_FWK_MODULE.

Referenced by process().

341  {
342 
343  int link = rob;
344  if (rob > 14) link = rob+1;
345  if (rob == 24) link = 15;
346  link += ((ros-1)%3)*24;
347  if (rob == 23) link = ros-1;
348  return link;
349 }
int DTuROSDigiToRaw::theSLT ( int  ddu,
int  ros,
int  rob 
)
private

Definition at line 329 of file DTuROSDigiToRaw.cc.

Referenced by process().

329  {
330 
331  if (ros > 6 && ddu > 774) ddu = ddu - 5;
332 
333  int slot = ((ros-1)/3)+1;
334  if (rob == 23) slot = 5;
335  if (ddu == 771) slot += 6;
336  else if (ddu == 774) slot += 6;
337  return slot;
338 }

Member Data Documentation

int DTuROSDigiToRaw::bslts[DOCESLOTS]
private

Definition at line 63 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().

bool DTuROSDigiToRaw::debug_
private

Definition at line 57 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw().

int DTuROSDigiToRaw::dslts[DOCESLOTS]
private

Definition at line 63 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().

edm::InputTag DTuROSDigiToRaw::DTDigiInputTag_
private

Definition at line 55 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and getDTDigiInputTag().

unsigned int DTuROSDigiToRaw::eventNum
private

Definition at line 53 of file DTuROSDigiToRaw.h.

Referenced by fillRawData(), and process().

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

Definition at line 61 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

int DTuROSDigiToRaw::nfeds_
private

Definition at line 59 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

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

Definition at line 87 of file DTuROSDigiToRaw.h.

Referenced by DTuROSDigiToRaw(), and fillRawData().

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

Definition at line 65 of file DTuROSDigiToRaw.h.

Referenced by clear(), and process().