CMS 3D CMS Logo

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

#include <CSCDigiToRaw.h>

Classes

struct  FindEventDataInfo
 

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) const
 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, FindEventDataInfo &, bool usePreTriggers, bool packEverything) const
 
void add (const CSCWireDigiCollection &wireDigis, const CSCALCTDigiCollection &alctDigis, FindEventDataInfo &, bool packEverything) const
 
void add (const CSCComparatorDigiCollection &comparatorDigis, const CSCCLCTDigiCollection &clctDigis, FindEventDataInfo &, bool packEverything) const
 
void add (const CSCALCTDigiCollection &alctDigis, FindEventDataInfo &) const
 
void add (const CSCCLCTDigiCollection &clctDigis, FindEventDataInfo &) const
 
void add (const CSCCorrelatedLCTDigiCollection &corrLCTDigis, FindEventDataInfo &) const
 
CSCEventDatafindEventData (const CSCDetId &cscDetId, FindEventDataInfo &) const
 pick out the correct data object for this chamber More...
 

Private Attributes

const int alctWindowMax_
 
const int alctWindowMin_
 
const int clctWindowMax_
 
const int clctWindowMin_
 
const int preTriggerWindowMax_
 
const int preTriggerWindowMin_
 

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 123 of file CSCDigiToRaw.cc.

124  : alctWindowMin_(pset.getParameter<int>("alctWindowMin")),
125  alctWindowMax_(pset.getParameter<int>("alctWindowMax")),
126  clctWindowMin_(pset.getParameter<int>("clctWindowMin")),
127  clctWindowMax_(pset.getParameter<int>("clctWindowMax")),
128  preTriggerWindowMin_(pset.getParameter<int>("preTriggerWindowMin")),
129  preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax"))
130 {}
T getParameter(std::string const &) const
const int clctWindowMin_
Definition: CSCDigiToRaw.h:82
const int clctWindowMax_
Definition: CSCDigiToRaw.h:83
const int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:84
const int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:85
const int alctWindowMin_
Definition: CSCDigiToRaw.h:80
const int alctWindowMax_
Definition: CSCDigiToRaw.h:81

Member Function Documentation

void CSCDigiToRaw::add ( const CSCStripDigiCollection stripDigis,
const CSCCLCTPreTriggerCollection preTriggers,
FindEventDataInfo fedInfo,
bool  usePreTriggers,
bool  packEverything 
) const
private

Definition at line 165 of file CSCDigiToRaw.cc.

References cscd2r::accept(), CSCEventData::add(), CSCDetId::endcap(), findEventData(), CSCDigiToRaw::FindEventDataInfo::formatVersion_, CSCStripDigi::getStrip(), plotBeamSpotDB::last, CSCDetId::layer(), preTriggerWindowMax_, preTriggerWindowMin_, CSCDetId::ring(), CSCStripDigi::setStrip(), CSCDetId::station(), digitizers_cfi::strip, and SurfaceOrientation::zplus.

Referenced by add(), createFedBuffers(), counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

170 { //iterate over chambers with strip digis in them
171  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); j!=stripDigis.end(); ++j)
172  {
173  CSCDetId cscDetId=(*j).first;
174  // only digitize if there are pre-triggers
175 
176  bool me1abCheck = fedInfo.formatVersion_ == 2013;
177  /* !!! Testing. Uncomment for production */
178  if (!usePreTriggers || packEverything ||
179  (usePreTriggers && cscd2r::accept(cscDetId, preTriggers, preTriggerWindowMin_, preTriggerWindowMax_, me1abCheck)) )
180  {
181  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
182  bool zplus = (cscDetId.endcap() == 1);
183  bool me1b = (cscDetId.station()==1) && (cscDetId.ring()==1);
184 
185  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
186 
187  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
188  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
189  for ( ; digiItr != last; ++digiItr)
190  {
191  CSCStripDigi digi = *digiItr;
192  int strip = digi.getStrip();
193  if (fedInfo.formatVersion_ == 2013)
194  {
195  if ( me1a && zplus )
196  {
197  digi.setStrip(49-strip); // 1-48 -> 48-1
198  }
199  if ( me1b && !zplus)
200  {
201  digi.setStrip(65-strip); // 1-64 -> 64-1
202  }
203  if ( me1a )
204  {
205  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
206  digi.setStrip(strip+64);
207  }
208 
209  }
210  else
211  {
212  if ( me1a && zplus )
213  {
214  digi.setStrip(17-strip); // 1-16 -> 16-1
215  }
216  if ( me1b && !zplus)
217  {
218  digi.setStrip(65-strip); // 1-64 -> 64-1
219  }
220  if ( me1a )
221  {
222  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
223  digi.setStrip(strip+64);
224  }
225  }
226  cscData.add(digi, cscDetId.layer() );
227  }
228  }
229  }
230 }
int layer() const
Definition: CSCDetId.h:61
int getStrip() const
Definition: CSCStripDigi.h:51
int endcap() const
Definition: CSCDetId.h:93
void setStrip(int istrip)
Definition: CSCStripDigi.h:75
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
const int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:84
const int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:85
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
Definition: CSCDigiToRaw.cc:42
int ring() const
Definition: CSCDetId.h:75
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:86
void CSCDigiToRaw::add ( const CSCWireDigiCollection wireDigis,
const CSCALCTDigiCollection alctDigis,
FindEventDataInfo fedInfo,
bool  packEverything 
) const
private

Definition at line 233 of file CSCDigiToRaw.cc.

References cscd2r::accept(), add(), CSCEventData::add(), alctWindowMax_, alctWindowMin_, findEventData(), CSCDigiToRaw::FindEventDataInfo::formatVersion_, plotBeamSpotDB::last, and CSCDetId::layer().

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

237 {
238  add(alctDigis, fedInfo);
239  for (CSCWireDigiCollection::DigiRangeIterator j=wireDigis.begin(); j!=wireDigis.end(); ++j)
240  {
241  CSCDetId cscDetId=(*j).first;
242  bool me1abCheck = fedInfo.formatVersion_ == 2013;
243  if (packEverything || cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_, me1abCheck))
244  {
245  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
246  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
247  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
248  for ( ; digiItr != last; ++digiItr)
249  {
250  cscData.add(*digiItr, cscDetId.layer() );
251  }
252  }
253  }
254 
255 }
int layer() const
Definition: CSCDetId.h:61
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
Definition: CSCDigiToRaw.cc:42
const int alctWindowMin_
Definition: CSCDigiToRaw.h:80
const int alctWindowMax_
Definition: CSCDigiToRaw.h:81
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers, FindEventDataInfo &, bool usePreTriggers, bool packEverything) const
void CSCDigiToRaw::add ( const CSCComparatorDigiCollection comparatorDigis,
const CSCCLCTDigiCollection clctDigis,
FindEventDataInfo fedInfo,
bool  packEverything 
) const
private

Definition at line 257 of file CSCDigiToRaw.cc.

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

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

261 {
262  add(clctDigis,fedInfo);
263  for (CSCComparatorDigiCollection::DigiRangeIterator j=comparatorDigis.begin(); j!=comparatorDigis.end(); ++j)
264  {
265  CSCDetId cscDetId=(*j).first;
266  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
267  bool me1abCheck = fedInfo.formatVersion_ == 2013;
268  if (packEverything || cscd2r::accept(cscDetId, clctDigis, clctWindowMin_, clctWindowMax_, me1abCheck))
269  {
270  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
271 
272 
273  BOOST_FOREACH(CSCComparatorDigi digi, (*j).second)
274  {
275  if (fedInfo.formatVersion_ == 2013)
276  {
277  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
278  // been done already.
279  if (me1a && digi.getStrip() <= 48)
280  {
281  CSCComparatorDigi digi_corr(64+digi.getStrip(),
282  digi.getComparator(),
283  digi.getTimeBinWord());
284  cscData.add(digi_corr, cscDetId); // This version does ME11 strips swapping
285  // cscData.add(digi_corr, cscDetId.layer()); // This one doesn't
286  }
287  else
288  {
289  cscData.add(digi, cscDetId); // This version does ME11 strips swapping
290  // cscData.add(digi, cscDetId.layer()); // This one doesn't
291  }
292  }
293  else
294  {
295  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
296  // been done already.
297  if (me1a && digi.getStrip() <= 16)
298  {
299  CSCComparatorDigi digi_corr(64+digi.getStrip(),
300  digi.getComparator(),
301  digi.getTimeBinWord());
302  cscData.add(digi_corr, cscDetId.layer());
303  }
304  else
305  {
306  cscData.add(digi, cscDetId.layer());
307  }
308  }
309  }
310  }
311  }
312 }
int getStrip() const
Get the strip number. Counts from 1.
const int clctWindowMin_
Definition: CSCDigiToRaw.h:82
const int clctWindowMax_
Definition: CSCDigiToRaw.h:83
int getComparator() const
Get Comparator readings. Can be 0 or 1.
int layer() const
Definition: CSCDetId.h:61
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
Definition: CSCDigiToRaw.cc:42
int ring() const
Definition: CSCDetId.h:75
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:86
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers, FindEventDataInfo &, bool usePreTriggers, bool packEverything) const
void CSCDigiToRaw::add ( const CSCALCTDigiCollection alctDigis,
FindEventDataInfo fedInfo 
) const
private

Definition at line 314 of file CSCDigiToRaw.cc.

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

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

316 {
317  for (CSCALCTDigiCollection::DigiRangeIterator j=alctDigis.begin(); j!=alctDigis.end(); ++j)
318  {
319  CSCDetId cscDetId=(*j).first;
320  CSCEventData & cscData = findEventData(cscDetId,fedInfo);
321 
322  cscData.add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
323  }
324 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
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,
FindEventDataInfo fedInfo 
) const
private

Definition at line 326 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), CSCDigiToRaw::FindEventDataInfo::formatVersion_, CSCDetId::ring(), and CSCDetId::station().

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

328 {
329  for (CSCCLCTDigiCollection::DigiRangeIterator j=clctDigis.begin(); j!=clctDigis.end(); ++j)
330  {
331  CSCDetId cscDetId=(*j).first;
332  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
333 
334  bool me11a = cscDetId.station() == 1 && cscDetId.ring() == 4;
335  //CLCTs are packed by chamber not by A/B parts in ME11
336  //me11a appears only in simulation with SLHC algorithm settings
337  //without the shift, it's impossible to distinguish A and B parts
338  if (me11a && fedInfo.formatVersion_ == 2013){
339  std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
340  for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
341  if (iC->getCFEB() >= 0 && iC->getCFEB() < 3){//sanity check, mostly
342  (*iC) = CSCCLCTDigi(iC->isValid(), iC->getQuality(), iC->getPattern(), iC->getStripType(),
343  iC->getBend(), iC->getStrip(), iC->getCFEB()+4, iC->getBX(),
344  iC->getTrknmb(), iC->getFullBX());
345  }
346  }
347  cscData.add(shiftedDigis);
348  } else {
349  cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
350  }
351  }
352 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
int ring() const
Definition: CSCDetId.h:75
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:86
void CSCDigiToRaw::add ( const CSCCorrelatedLCTDigiCollection corrLCTDigis,
FindEventDataInfo fedInfo 
) const
private

Definition at line 354 of file CSCDigiToRaw.cc.

References CSCEventData::add(), findEventData(), CSCDigiToRaw::FindEventDataInfo::formatVersion_, CSCDetId::ring(), and CSCDetId::station().

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

355 {
356  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j=corrLCTDigis.begin(); j!=corrLCTDigis.end(); ++j)
357  {
358  CSCDetId cscDetId=(*j).first;
359  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
360 
361  bool me11a = cscDetId.station() == 1 && cscDetId.ring() == 4;
362  //LCTs are packed by chamber not by A/B parts in ME11
363  //me11a appears only in simulation with SLHC algorithm settings
364  //without the shift, it's impossible to distinguish A and B parts
365  if (me11a && fedInfo.formatVersion_ == 2013){
366  std::vector<CSCCorrelatedLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
367  for (std::vector<CSCCorrelatedLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
368  if (iC->getStrip() >= 0 && iC->getStrip() < 96){//sanity check, mostly
369  (*iC) = CSCCorrelatedLCTDigi(iC->getTrknmb(), iC->isValid(), iC->getQuality(),
370  iC->getKeyWG(), iC->getStrip() + 128, iC->getPattern(),
371  iC->getBend(), iC->getBX(), iC->getMPCLink(),
372  iC->getBX0(), iC->getSyncErr(), iC->getCSCID());
373  }
374  }
375  cscData.add(shiftedDigis);
376  } else {
377  cscData.add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
378  }
379  }
380 
381 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
int ring() const
Definition: CSCDetId.h:75
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:86
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 
) const

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 384 of file CSCDigiToRaw.cc.

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

395 {
396 
397  //bits of code from ORCA/Muon/METBFormatter - thanks, Rick:)!
398 
399  //get fed object from fed_buffers
400  // make a map from the index of a chamber to the event data from it
401  FindEventDataInfo fedInfo{mapping, format_version};
402  add(stripDigis, preTriggers,fedInfo, use_pre_triggers, packEverything);
403  add(wireDigis, alctDigis,fedInfo, packEverything);
404  add(comparatorDigis, clctDigis,fedInfo, packEverything);
405  add(correlatedLCTDigis,fedInfo);
406 
407  int l1a=e.id().event(); //need to add increments or get it from lct digis
408  int bx = l1a;//same as above
409  //int startingFED = FEDNumbering::MINCSCFEDID;
410 
411  if (fedInfo.formatVersion_ == 2005)
412  {
413  std::map<int, CSCDCCEventData> dccMap;
414  for (int idcc=FEDNumbering::MINCSCFEDID;
415  idcc<=FEDNumbering::MAXCSCFEDID; ++idcc)
416  {
417  //idcc goes from startingFed to startingFED+7
418  // @@ if ReadoutMapping changes, this'll have to change
419  // DCCs 1,2,4,5 have 5 DDUs. Otherwise, 4
420  //int nDDUs = (idcc < 2) || (idcc ==4) || (idcc ==5)
421  // ? 5 : 4;
422  //@@ WARNING some DCCs only have 4 DDUs, but I'm giving them all 5, for now
423  int nDDUs = 5;
424  dccMap.insert(std::pair<int, CSCDCCEventData>(idcc, CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
425  }
426 
427  for (int idcc=FEDNumbering::MINCSCFEDID;
428  idcc<=FEDNumbering::MAXCSCFEDID; ++idcc)
429  {
430 
431  // for every chamber with data, add to a DDU in this DCC Event
432  for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
433  chamberItr != fedInfo.theChamberDataMap.end(); ++chamberItr)
434  {
435  int indexDCC = mapping->slink(chamberItr->first);
436  if (indexDCC == idcc)
437  {
438  //FIXME (What does this mean? Is something wrong?)
439  std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
440  if (dccMapItr == dccMap.end())
441  {
442  throw cms::Exception("CSCDigiToRaw") << "Bad DCC number:" << indexDCC;
443  }
444  // get id's based on ChamberId from mapping
445 
446  int dduId = mapping->ddu(chamberItr->first);
447  int dduSlot = mapping->dduSlot(chamberItr->first);
448  int dduInput = mapping->dduInput(chamberItr->first);
449  int dmbId = mapping->dmb(chamberItr->first);
450  dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId, format_version);
451  }
452  }
453  }
454 
455  // FIXME: FEDRawData size set to 2*64 to add FED header and trailer
456  for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
457  dccMapItr != dccMap.end(); ++dccMapItr)
458  {
459  boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
460  FEDRawData & fedRawData = fed_buffers.FEDData(dccMapItr->first);
461  fedRawData.resize(dccBits.size());
462  //fill data with dccEvent
463  bitset_utilities::bitsetToChar(dccBits, fedRawData.data());
464  FEDTrailer cscFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
465  cscFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8),
466  fedRawData.size()/8,
467  evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
468  }
469 
470  }
471  else if (format_version == 2013)
472  {
473 
474  std::map<int, CSCDDUEventData> dduMap;
475  unsigned int ddu_fmt_version = 0x7;
476  const unsigned postLS1_map [] = { 841, 842, 843, 844, 845, 846, 847, 848, 849,
477  831, 832, 833, 834, 835, 836, 837, 838, 839,
478  861, 862, 863, 864, 865, 866, 867, 868, 869,
479  851, 852, 853, 854, 855, 856, 857, 858, 859 };
480 
481 
483  for (unsigned int i = 0; i < 36; i++)
484  {
485  unsigned int iddu = postLS1_map[i];
486  // make a new one
487  CSCDDUHeader newDDUHeader(bx,l1a, iddu, ddu_fmt_version);
488 
489  dduMap.insert(std::pair<int, CSCDDUEventData>(iddu, CSCDDUEventData(newDDUHeader) ) );
490  }
491 
492 
494  for (unsigned int i = 0; i < 36; i++)
495  {
496  unsigned int iddu = postLS1_map[i];
497  // for every chamber with data, add to a DDU in this DCC Event
498  for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
499  chamberItr != fedInfo.theChamberDataMap.end(); ++chamberItr)
500  {
501  unsigned int indexDDU = mapping->slink(chamberItr->first);
502 
504  if ( (indexDDU >= FEDNumbering::MINCSCFEDID) && (indexDDU <= FEDNumbering::MAXCSCFEDID) ) // Still preLS1 DCC FEDs mapping
505  {
506 
507  int dduID = mapping->ddu(chamberItr->first); // try to switch to DDU ID mapping
508  if ((dduID >= FEDNumbering::MINCSCDDUFEDID) && (dduID <= FEDNumbering::MAXCSCDDUFEDID) ) // DDU ID is in expectedi post-LS1 FED ID range
509  {
510  indexDDU = dduID;
511  }
512  else // Messy
513  {
514  // Lets try to change pre-LS1 1-36 ID range to post-LS1 MINCSCDDUFEDID - MAXCSCDDUFEDID range
515  dduID &= 0xFF;
516  if ((dduID <= 36) && (dduID > 0)) indexDDU = postLS1_map[dduID -1]; // indexDDU = FEDNumbering::MINCSCDDUFEDID + dduID-1;
517  }
518 
519  }
520 
521  if (indexDDU == iddu)
522  {
523  std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
524  if (dduMapItr == dduMap.end())
525  {
526  throw cms::Exception("CSCDigiToRaw") << "Bad DDU number:" << indexDDU;
527  }
528  // get id's based on ChamberId from mapping
529 
530  int dduInput = mapping->dduInput(chamberItr->first);
531  int dmbId = mapping->dmb(chamberItr->first);
532  // int crateId = mapping->crate(chamberItr->first);
533  dduMapItr->second.add( chamberItr->second, dmbId, dduInput, format_version );
534  }
535  }
536  }
537 
538  // FIXME: FEDRawData size set to 2*64 to add FED header and trailer
539  for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin();
540  dduMapItr != dduMap.end(); ++dduMapItr)
541  {
542  boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
543  FEDRawData & fedRawData = fed_buffers.FEDData(dduMapItr->first);
544  fedRawData.resize(dduBits.size()/8);
545  //fill data with dduEvent
546  bitset_utilities::bitsetToChar(dduBits, fedRawData.data());
547  FEDTrailer cscFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
548  cscFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8),
549  fedRawData.size()/8,
550  evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
551 
552  }
553  }
554 }
01/20/05 A.Tumanov
EventNumber_t event() const
Definition: EventID.h:41
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 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:60
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers, FindEventDataInfo &, bool usePreTriggers, bool packEverything) const
CSCEventData & CSCDigiToRaw::findEventData ( const CSCDetId cscDetId,
FindEventDataInfo info 
) const
private

pick out the correct data object for this chamber

Definition at line 132 of file CSCDigiToRaw.cc.

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

Referenced by add().

133 {
134  CSCDetId chamberId = cscd2r::chamberID(cscDetId);
135  // find the entry into the map
136  map<CSCDetId, CSCEventData>::iterator chamberMapItr = info.theChamberDataMap.find(chamberId);
137  if (chamberMapItr == info.theChamberDataMap.end())
138  {
139  // make an entry, telling it the correct chamberType
140  int chamberType = chamberId.iChamberType();
141  chamberMapItr = info.theChamberDataMap.insert(pair<CSCDetId, CSCEventData>(chamberId, CSCEventData(chamberType, info.formatVersion_))).first;
142  }
143  CSCEventData & cscData = chamberMapItr->second;
144  cscData.dmbHeader()->setCrateAddress(info.theElectronicsMap->crate(cscDetId), info.theElectronicsMap->dmb(cscDetId));
145 
146  if (info.formatVersion_ == 2013)
147  {
148  // Set DMB version field to distinguish between ME11s and other chambers (ME11 - 2, others - 1)
149  bool me11 = ((chamberId.station()==1) && (chamberId.ring()==4)) || ((chamberId.station()==1) && (chamberId.ring()==1));
150  if (me11)
151  {
152  cscData.dmbHeader()->setdmbVersion(2);
153  }
154  else
155  {
156  cscData.dmbHeader()->setdmbVersion(1);
157  }
158 
159  }
160  return cscData;
161 }
static const TGPicture * info(bool iBackgroundIsBlack)
void setdmbVersion(unsigned int version)
Definition: CSCDMBHeader.h:42
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
Definition: CSCDigiToRaw.cc:31
unsigned short iChamberType() const
Definition: CSCDetId.h:107
void setCrateAddress(int crate, int dmbId)
Definition: CSCDMBHeader.h:40
int ring() const
Definition: CSCDetId.h:75
int station() const
Definition: CSCDetId.h:86
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info
Definition: CSCEventData.h:96

Member Data Documentation

const int CSCDigiToRaw::alctWindowMax_
private

Definition at line 81 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::alctWindowMin_
private

Definition at line 80 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::clctWindowMax_
private

Definition at line 83 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::clctWindowMin_
private

Definition at line 82 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::preTriggerWindowMax_
private

Definition at line 85 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::preTriggerWindowMin_
private

Definition at line 84 of file CSCDigiToRaw.h.

Referenced by add().