CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
CSCDigiToRaw Class Reference

#include <CSCDigiToRaw.h>

Public Member Functions

void createFedBuffers (const CSCStripDigiCollection &stripDigis, const CSCWireDigiCollection &wireDigis, const CSCComparatorDigiCollection &comparatorDigis, const CSCALCTDigiCollection &alctDigis, const CSCCLCTDigiCollection &clctDigis, const CSCCLCTPreTriggerCollection &preTriggers, const CSCCorrelatedLCTDigiCollection &correlatedLCTDigis, FEDRawDataCollection &fed_buffers, const CSCChamberMap *theMapping, edm::Event &e, uint16_t theFormatVersion=2005, bool usePreTriggers=true, bool packEverything=false)
 Take a vector of digis and fill the FEDRawDataCollection. More...
 
 CSCDigiToRaw (const edm::ParameterSet &pset)
 Constructor. More...
 

Private Member Functions

void add (const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
 
void add (const CSCWireDigiCollection &wireDigis, const CSCALCTDigiCollection &alctDigis)
 
void add (const CSCComparatorDigiCollection &comparatorDigis, const CSCCLCTDigiCollection &clctDigis)
 
void add (const CSCALCTDigiCollection &alctDigis)
 
void add (const CSCCLCTDigiCollection &clctDigis)
 
void add (const CSCCorrelatedLCTDigiCollection &corrLCTDigis)
 
void beginEvent (const CSCChamberMap *electronicsMap)
 
CSCEventDatafindEventData (const CSCDetId &cscDetId)
 pick out the correct data object for this chamber More...
 

Private Attributes

int alctWindowMax_
 
int alctWindowMin_
 
int clctWindowMax_
 
int clctWindowMin_
 
uint16_t formatVersion_
 
bool packEverything_
 
int preTriggerWindowMax_
 
int preTriggerWindowMin_
 
std::map< CSCDetId, CSCEventDatatheChamberDataMap
 
const CSCChamberMaptheElectronicsMap
 
bool usePreTriggers_
 

Detailed Description

Author
A. Tumanov - Rice

Definition at line 23 of file CSCDigiToRaw.h.

Constructor & Destructor Documentation

CSCDigiToRaw::CSCDigiToRaw ( const edm::ParameterSet pset)
explicit

Constructor.

Definition at line 89 of file CSCDigiToRaw.cc.

90  : alctWindowMin_(pset.getParameter<int>("alctWindowMin")),
91  alctWindowMax_(pset.getParameter<int>("alctWindowMax")),
92  clctWindowMin_(pset.getParameter<int>("clctWindowMin")),
93  clctWindowMax_(pset.getParameter<int>("clctWindowMax")),
94  preTriggerWindowMin_(pset.getParameter<int>("preTriggerWindowMin")),
95  preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax")),
96  formatVersion_(2005),
97  usePreTriggers_(true),
98  packEverything_(false)
99 {}
T getParameter(std::string const &) const
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:68
bool usePreTriggers_
Definition: CSCDigiToRaw.h:69
bool packEverything_
Definition: CSCDigiToRaw.h:70
int clctWindowMin_
Definition: CSCDigiToRaw.h:64
int alctWindowMax_
Definition: CSCDigiToRaw.h:63
int alctWindowMin_
Definition: CSCDigiToRaw.h:62
int clctWindowMax_
Definition: CSCDigiToRaw.h:65
int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:66
int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:67

Member Function Documentation

void CSCDigiToRaw::add ( const CSCStripDigiCollection stripDigis,
const CSCCLCTPreTriggerCollection preTriggers 
)
private

Definition at line 141 of file CSCDigiToRaw.cc.

References cscd2r::accept(), CSCEventData::add(), CSCDetId::endcap(), findEventData(), formatVersion_, CSCStripDigi::getStrip(), j, prof2calltree::last, CSCDetId::layer(), packEverything_, preTriggerWindowMax_, preTriggerWindowMin_, CSCDetId::ring(), CSCStripDigi::setStrip(), CSCDetId::station(), usePreTriggers_, and SurfaceOrientation::zplus.

Referenced by add(), createFedBuffers(), and counter.Counter::register().

143 { //iterate over chambers with strip digis in them
144  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); j!=stripDigis.end(); ++j)
145  {
146  CSCDetId cscDetId=(*j).first;
147  // only digitize if there are pre-triggers
148 
149  /* !!! Testing. Uncomment for production */
152  {
153  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
154  bool zplus = (cscDetId.endcap() == 1);
155  bool me1b = (cscDetId.station()==1) && (cscDetId.ring()==1);
156 
157  CSCEventData & cscData = findEventData(cscDetId);
158 
159  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
160  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
161  for ( ; digiItr != last; ++digiItr)
162  {
163  CSCStripDigi digi = *digiItr;
164  int strip = digi.getStrip();
165  if (formatVersion_ == 2013)
166  {
167  if ( me1a && zplus )
168  {
169  digi.setStrip(49-strip); // 1-48 -> 48-1
170  }
171  if ( me1b && !zplus)
172  {
173  digi.setStrip(65-strip); // 1-64 -> 64-1
174  }
175  if ( me1a )
176  {
177  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
178  digi.setStrip(strip+64);
179  }
180 
181  }
182  else
183  {
184  if ( me1a && zplus )
185  {
186  digi.setStrip(17-strip); // 1-16 -> 16-1
187  }
188  if ( me1b && !zplus)
189  {
190  digi.setStrip(65-strip); // 1-64 -> 64-1
191  }
192  if ( me1a )
193  {
194  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
195  digi.setStrip(strip+64);
196  }
197  }
198  cscData.add(digi, cscDetId.layer() );
199  }
200  }
201  }
202 }
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:68
bool usePreTriggers_
Definition: CSCDigiToRaw.h:69
bool packEverything_
Definition: CSCDigiToRaw.h:70
int layer() const
Definition: CSCDetId.h:74
int getStrip() const
Definition: CSCStripDigi.h:51
int endcap() const
Definition: CSCDetId.h:106
void setStrip(int istrip)
Definition: CSCStripDigi.h:75
int j
Definition: DBlmapReader.cc:9
int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:66
int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:67
int ring() const
Definition: CSCDetId.h:88
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax)
Definition: CSCDigiToRaw.cc:42
int station() const
Definition: CSCDetId.h:99
void CSCDigiToRaw::add ( const CSCWireDigiCollection wireDigis,
const CSCALCTDigiCollection alctDigis 
)
private

Definition at line 205 of file CSCDigiToRaw.cc.

References cscd2r::accept(), add(), CSCEventData::add(), alctWindowMax_, alctWindowMin_, findEventData(), j, prof2calltree::last, CSCDetId::layer(), and packEverything_.

Referenced by counter.Counter::register().

207 {
208  add(alctDigis);
209  for (CSCWireDigiCollection::DigiRangeIterator j=wireDigis.begin(); j!=wireDigis.end(); ++j)
210  {
211  CSCDetId cscDetId=(*j).first;
212  if (packEverything_ || cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_))
213  {
214  CSCEventData & cscData = findEventData(cscDetId);
215  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
216  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
217  for ( ; digiItr != last; ++digiItr)
218  {
219  cscData.add(*digiItr, cscDetId.layer() );
220  }
221  }
222  }
223 
224 }
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
bool packEverything_
Definition: CSCDigiToRaw.h:70
int layer() const
Definition: CSCDetId.h:74
int alctWindowMax_
Definition: CSCDigiToRaw.h:63
int alctWindowMin_
Definition: CSCDigiToRaw.h:62
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax)
Definition: CSCDigiToRaw.cc:42
void CSCDigiToRaw::add ( const CSCComparatorDigiCollection comparatorDigis,
const CSCCLCTDigiCollection clctDigis 
)
private

Definition at line 226 of file CSCDigiToRaw.cc.

References cscd2r::accept(), add(), CSCEventData::add(), clctWindowMax_, clctWindowMin_, findEventData(), formatVersion_, CSCComparatorDigi::getComparator(), CSCComparatorDigi::getStrip(), CSCComparatorDigi::getTimeBinWord(), j, CSCDetId::layer(), packEverything_, CSCDetId::ring(), and CSCDetId::station().

Referenced by counter.Counter::register().

228 {
229  add(clctDigis);
230  for (CSCComparatorDigiCollection::DigiRangeIterator j=comparatorDigis.begin(); j!=comparatorDigis.end(); ++j)
231  {
232  CSCDetId cscDetId=(*j).first;
233  CSCEventData & cscData = findEventData(cscDetId);
234  if (packEverything_ || cscd2r::accept(cscDetId, clctDigis, clctWindowMin_, clctWindowMax_))
235  {
236  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
237 
238 
239  BOOST_FOREACH(CSCComparatorDigi digi, (*j).second)
240  {
241  if (formatVersion_ == 2013)
242  {
243  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
244  // been done already.
245  if (me1a && digi.getStrip() <= 48)
246  {
247  CSCComparatorDigi digi_corr(64+digi.getStrip(),
248  digi.getComparator(),
249  digi.getTimeBinWord());
250  cscData.add(digi_corr, cscDetId); // This version does ME11 strips swapping
251  // cscData.add(digi_corr, cscDetId.layer()); // This one doesn't
252  }
253  else
254  {
255  cscData.add(digi, cscDetId); // This version does ME11 strips swapping
256  // cscData.add(digi, cscDetId.layer()); // This one doesn't
257  }
258  }
259  else
260  {
261  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
262  // been done already.
263  if (me1a && digi.getStrip() <= 16)
264  {
265  CSCComparatorDigi digi_corr(64+digi.getStrip(),
266  digi.getComparator(),
267  digi.getTimeBinWord());
268  cscData.add(digi_corr, cscDetId.layer());
269  }
270  else
271  {
272  cscData.add(digi, cscDetId.layer());
273  }
274  }
275  }
276  }
277  }
278 }
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
int getStrip() const
Get the strip number.
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:68
bool packEverything_
Definition: CSCDigiToRaw.h:70
int clctWindowMin_
Definition: CSCDigiToRaw.h:64
int getComparator() const
Get Comparator readings.
int layer() const
Definition: CSCDetId.h:74
int j
Definition: DBlmapReader.cc:9
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
int clctWindowMax_
Definition: CSCDigiToRaw.h:65
int ring() const
Definition: CSCDetId.h:88
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax)
Definition: CSCDigiToRaw.cc:42
int station() const
Definition: CSCDetId.h:99
void CSCDigiToRaw::add ( const CSCALCTDigiCollection alctDigis)
private

Definition at line 280 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), and j.

Referenced by counter.Counter::register().

281 {
282  for (CSCALCTDigiCollection::DigiRangeIterator j=alctDigis.begin(); j!=alctDigis.end(); ++j)
283  {
284  CSCDetId cscDetId=(*j).first;
285  CSCEventData & cscData = findEventData(cscDetId);
286 
287  cscData.add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
288  }
289 }
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
void CSCDigiToRaw::add ( const CSCCLCTDigiCollection clctDigis)
private

Definition at line 291 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), and j.

Referenced by counter.Counter::register().

292 {
293  for (CSCCLCTDigiCollection::DigiRangeIterator j=clctDigis.begin(); j!=clctDigis.end(); ++j)
294  {
295  CSCDetId cscDetId=(*j).first;
296  CSCEventData & cscData = findEventData(cscDetId);
297 
298  cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
299  }
300 }
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
void CSCDigiToRaw::add ( const CSCCorrelatedLCTDigiCollection corrLCTDigis)
private

Definition at line 302 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), and j.

Referenced by counter.Counter::register().

303 {
304  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j=corrLCTDigis.begin(); j!=corrLCTDigis.end(); ++j)
305  {
306  CSCDetId cscDetId=(*j).first;
307  CSCEventData & cscData = findEventData(cscDetId);
308 
309  cscData.add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
310  }
311 
312 }
int j
Definition: DBlmapReader.cc:9
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
void CSCDigiToRaw::beginEvent ( const CSCChamberMap electronicsMap)
private

Definition at line 101 of file CSCDigiToRaw.cc.

References ecaldqm::electronicsMap(), theChamberDataMap, and theElectronicsMap.

Referenced by createFedBuffers().

102 {
103  theChamberDataMap.clear();
105 }
const CSCChamberMap * theElectronicsMap
Definition: CSCDigiToRaw.h:61
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:60
EcalElectronicsMapping const * electronicsMap(0)
void CSCDigiToRaw::createFedBuffers ( const CSCStripDigiCollection stripDigis,
const CSCWireDigiCollection wireDigis,
const CSCComparatorDigiCollection comparatorDigis,
const CSCALCTDigiCollection alctDigis,
const CSCCLCTDigiCollection clctDigis,
const CSCCLCTPreTriggerCollection preTriggers,
const CSCCorrelatedLCTDigiCollection correlatedLCTDigis,
FEDRawDataCollection fed_buffers,
const CSCChamberMap theMapping,
edm::Event e,
uint16_t  theFormatVersion = 2005,
bool  usePreTriggers = true,
bool  packEverything = false 
)

Take a vector of digis and fill the FEDRawDataCollection.

Handle pre-LS1 format data

Handle post-LS1 format data

2013 Format

Create dummy DDU buffers

Loop over post-LS1 DDU FEDs

Lets handle possible mapping issues

Definition at line 315 of file CSCDigiToRaw.cc.

References add(), beginEvent(), bitset_utilities::bitsetToChar(), evf::compute_crc(), FEDRawData::data(), CSCChamberMap::ddu(), CSCChamberMap::dduInput(), CSCChamberMap::dduSlot(), CSCChamberMap::dmb(), edm::EventID::event(), edm::hlt::Exception, FEDRawDataCollection::FEDData(), formatVersion_, i, edm::EventBase::id(), FEDNumbering::MAXCSCDDUFEDID, FEDNumbering::MAXCSCFEDID, FEDNumbering::MINCSCDDUFEDID, FEDNumbering::MINCSCFEDID, packEverything_, FEDRawData::resize(), FEDRawData::size(), CSCChamberMap::slink(), theChamberDataMap, and usePreTriggers_.

Referenced by CSCDigiToRawModule::produce().

326 {
327 
328  formatVersion_ = format_version;
329  usePreTriggers_ = use_pre_triggers;
330  packEverything_ = packEverything;
331  //bits of code from ORCA/Muon/METBFormatter - thanks, Rick:)!
332 
333  //get fed object from fed_buffers
334  // make a map from the index of a chamber to the event data from it
335  beginEvent(mapping);
336  add(stripDigis, preTriggers);
337  add(wireDigis, alctDigis);
338  add(comparatorDigis, clctDigis);
339  add(correlatedLCTDigis);
340 
341  int l1a=e.id().event(); //need to add increments or get it from lct digis
342  int bx = l1a;//same as above
343  //int startingFED = FEDNumbering::MINCSCFEDID;
344 
345  if (formatVersion_ == 2005)
346  {
347  std::map<int, CSCDCCEventData> dccMap;
348  for (int idcc=FEDNumbering::MINCSCFEDID;
349  idcc<=FEDNumbering::MAXCSCFEDID; ++idcc)
350  {
351  //idcc goes from startingFed to startingFED+7
352  // @@ if ReadoutMapping changes, this'll have to change
353  // DCCs 1,2,4,5 have 5 DDUs. Otherwise, 4
354  //int nDDUs = (idcc < 2) || (idcc ==4) || (idcc ==5)
355  // ? 5 : 4;
356  //@@ WARNING some DCCs only have 4 DDUs, but I'm giving them all 5, for now
357  int nDDUs = 5;
358  dccMap.insert(std::pair<int, CSCDCCEventData>(idcc, CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
359  }
360 
361  for (int idcc=FEDNumbering::MINCSCFEDID;
362  idcc<=FEDNumbering::MAXCSCFEDID; ++idcc)
363  {
364 
365  // for every chamber with data, add to a DDU in this DCC Event
366  for (map<CSCDetId, CSCEventData>::iterator chamberItr = theChamberDataMap.begin();
367  chamberItr != theChamberDataMap.end(); ++chamberItr)
368  {
369  int indexDCC = mapping->slink(chamberItr->first);
370  if (indexDCC == idcc)
371  {
372  //FIXME (What does this mean? Is something wrong?)
373  std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
374  if (dccMapItr == dccMap.end())
375  {
376  throw cms::Exception("CSCDigiToRaw") << "Bad DCC number:" << indexDCC;
377  }
378  // get id's based on ChamberId from mapping
379 
380  int dduId = mapping->ddu(chamberItr->first);
381  int dduSlot = mapping->dduSlot(chamberItr->first);
382  int dduInput = mapping->dduInput(chamberItr->first);
383  int dmbId = mapping->dmb(chamberItr->first);
384  dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId, formatVersion_);
385  }
386  }
387  }
388 
389  // FIXME: FEDRawData size set to 2*64 to add FED header and trailer
390  for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
391  dccMapItr != dccMap.end(); ++dccMapItr)
392  {
393  boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
394  FEDRawData & fedRawData = fed_buffers.FEDData(dccMapItr->first);
395  fedRawData.resize(dccBits.size());
396  //fill data with dccEvent
397  bitset_utilities::bitsetToChar(dccBits, fedRawData.data());
398  FEDTrailer cscFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
399  cscFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8),
400  fedRawData.size()/8,
401  evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
402  }
403 
404  }
405  else if (formatVersion_ == 2013)
406  {
407 
408  std::map<int, CSCDDUEventData> dduMap;
409  unsigned int ddu_fmt_version = 0x7;
410  const unsigned postLS1_map [] = { 841, 842, 843, 844, 845, 846, 847, 848, 849,
411  831, 832, 833, 834, 835, 836, 837, 838, 839,
412  861, 862, 863, 864, 865, 866, 867, 868, 869,
413  851, 852, 853, 854, 855, 856, 857, 858, 859 };
414 
415 
417  for (unsigned int i = 0; i < 36; i++)
418  {
419  unsigned int iddu = postLS1_map[i];
420  // make a new one
421  CSCDDUHeader newDDUHeader(bx,l1a, iddu, ddu_fmt_version);
422 
423  dduMap.insert(std::pair<int, CSCDDUEventData>(iddu, CSCDDUEventData(newDDUHeader) ) );
424  }
425 
426 
428  for (unsigned int i = 0; i < 36; i++)
429  {
430  unsigned int iddu = postLS1_map[i];
431  // for every chamber with data, add to a DDU in this DCC Event
432  for (map<CSCDetId, CSCEventData>::iterator chamberItr = theChamberDataMap.begin();
433  chamberItr != theChamberDataMap.end(); ++chamberItr)
434  {
435  unsigned int indexDDU = mapping->slink(chamberItr->first);
436 
438  if ( (indexDDU >= FEDNumbering::MINCSCFEDID) && (indexDDU <= FEDNumbering::MAXCSCFEDID) ) // Still preLS1 DCC FEDs mapping
439  {
440 
441  int dduID = mapping->ddu(chamberItr->first); // try to switch to DDU ID mapping
442  if ((dduID >= FEDNumbering::MINCSCDDUFEDID) && (dduID <= FEDNumbering::MAXCSCDDUFEDID) ) // DDU ID is in expectedi post-LS1 FED ID range
443  {
444  indexDDU = dduID;
445  }
446  else // Messy
447  {
448  // Lets try to change pre-LS1 1-36 ID range to post-LS1 MINCSCDDUFEDID - MAXCSCDDUFEDID range
449  dduID &= 0xFF;
450  if ((dduID <= 36) && (dduID > 0)) indexDDU = postLS1_map[dduID -1]; // indexDDU = FEDNumbering::MINCSCDDUFEDID + dduID-1;
451  }
452 
453  }
454 
455  if (indexDDU == iddu)
456  {
457  std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
458  if (dduMapItr == dduMap.end())
459  {
460  throw cms::Exception("CSCDigiToRaw") << "Bad DDU number:" << indexDDU;
461  }
462  // get id's based on ChamberId from mapping
463 
464  int dduInput = mapping->dduInput(chamberItr->first);
465  int dmbId = mapping->dmb(chamberItr->first);
466  // int crateId = mapping->crate(chamberItr->first);
467  dduMapItr->second.add( chamberItr->second, dmbId, dduInput, formatVersion_ );
468  }
469  }
470  }
471 
472  // FIXME: FEDRawData size set to 2*64 to add FED header and trailer
473  for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin();
474  dduMapItr != dduMap.end(); ++dduMapItr)
475  {
476  boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
477  FEDRawData & fedRawData = fed_buffers.FEDData(dduMapItr->first);
478  fedRawData.resize(dduBits.size()/8);
479  //fill data with dduEvent
480  bitset_utilities::bitsetToChar(dduBits, fedRawData.data());
481  FEDTrailer cscFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
482  cscFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8),
483  fedRawData.size()/8,
484  evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
485 
486  }
487  }
488 }
01/20/05 A.Tumanov
EventNumber_t event() const
Definition: EventID.h:41
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
int i
Definition: DBlmapReader.cc:9
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:68
bool usePreTriggers_
Definition: CSCDigiToRaw.h:69
bool packEverything_
Definition: CSCDigiToRaw.h:70
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
void beginEvent(const CSCChamberMap *electronicsMap)
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:60
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
edm::EventID id() const
Definition: EventBase.h:56
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
CSCEventData & CSCDigiToRaw::findEventData ( const CSCDetId cscDetId)
private

pick out the correct data object for this chamber

Definition at line 108 of file CSCDigiToRaw.cc.

References cscd2r::chamberID(), CSCChamberMap::crate(), CSCChamberMap::dmb(), CSCEventData::dmbHeader(), formatVersion_, CSCDetId::iChamberType(), CSCDetId::ring(), CSCDMBHeader::setCrateAddress(), CSCDMBHeader::setdmbVersion(), CSCDetId::station(), theChamberDataMap, and theElectronicsMap.

Referenced by add().

109 {
110  CSCDetId chamberId = cscd2r::chamberID(cscDetId);
111  // find the entry into the map
112  map<CSCDetId, CSCEventData>::iterator chamberMapItr = theChamberDataMap.find(chamberId);
113  if (chamberMapItr == theChamberDataMap.end())
114  {
115  // make an entry, telling it the correct chamberType
116  int chamberType = chamberId.iChamberType();
117  chamberMapItr = theChamberDataMap.insert(pair<CSCDetId, CSCEventData>(chamberId, CSCEventData(chamberType, formatVersion_))).first;
118  }
119  CSCEventData & cscData = chamberMapItr->second;
120  cscData.dmbHeader()->setCrateAddress(theElectronicsMap->crate(cscDetId), theElectronicsMap->dmb(cscDetId));
121 
122  if (formatVersion_ == 2013)
123  {
124  // Set DMB version field to distinguish between ME11s and other chambers (ME11 - 2, others - 1)
125  bool me11 = ((chamberId.station()==1) && (chamberId.ring()==4)) || ((chamberId.station()==1) && (chamberId.ring()==1));
126  if (me11)
127  {
128  cscData.dmbHeader()->setdmbVersion(2);
129  }
130  else
131  {
132  cscData.dmbHeader()->setdmbVersion(1);
133  }
134 
135  }
136  return cscData;
137 }
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:68
int dmb(const CSCDetId &) const
dmb id for given DetId
void setdmbVersion(unsigned int version)
Definition: CSCDMBHeader.h:43
const CSCChamberMap * theElectronicsMap
Definition: CSCDigiToRaw.h:61
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
Definition: CSCDigiToRaw.cc:31
void setCrateAddress(int crate, int dmbId)
Definition: CSCDMBHeader.h:41
unsigned short iChamberType()
Definition: CSCDetId.h:120
int ring() const
Definition: CSCDetId.h:88
std::map< CSCDetId, CSCEventData > theChamberDataMap
Definition: CSCDigiToRaw.h:60
int crate(const CSCDetId &) const
Interface required use in digi-to-raw.
int station() const
Definition: CSCDetId.h:99
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info
Definition: CSCEventData.h:96

Member Data Documentation

int CSCDigiToRaw::alctWindowMax_
private

Definition at line 63 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::alctWindowMin_
private

Definition at line 62 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::clctWindowMax_
private

Definition at line 65 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::clctWindowMin_
private

Definition at line 64 of file CSCDigiToRaw.h.

Referenced by add().

uint16_t CSCDigiToRaw::formatVersion_
private

Definition at line 68 of file CSCDigiToRaw.h.

Referenced by add(), createFedBuffers(), and findEventData().

bool CSCDigiToRaw::packEverything_
private

Definition at line 70 of file CSCDigiToRaw.h.

Referenced by add(), and createFedBuffers().

int CSCDigiToRaw::preTriggerWindowMax_
private

Definition at line 67 of file CSCDigiToRaw.h.

Referenced by add().

int CSCDigiToRaw::preTriggerWindowMin_
private

Definition at line 66 of file CSCDigiToRaw.h.

Referenced by add().

std::map<CSCDetId, CSCEventData> CSCDigiToRaw::theChamberDataMap
private

Definition at line 60 of file CSCDigiToRaw.h.

Referenced by beginEvent(), createFedBuffers(), and findEventData().

const CSCChamberMap* CSCDigiToRaw::theElectronicsMap
private

Definition at line 61 of file CSCDigiToRaw.h.

Referenced by beginEvent(), and findEventData().

bool CSCDigiToRaw::usePreTriggers_
private

Definition at line 69 of file CSCDigiToRaw.h.

Referenced by add(), and createFedBuffers().