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

123  : alctWindowMin_(pset.getParameter<int>("alctWindowMin")),
124  alctWindowMax_(pset.getParameter<int>("alctWindowMax")),
125  clctWindowMin_(pset.getParameter<int>("clctWindowMin")),
126  clctWindowMax_(pset.getParameter<int>("clctWindowMax")),
127  preTriggerWindowMin_(pset.getParameter<int>("preTriggerWindowMin")),
128  preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax"))
129 {}
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 164 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().

169 { //iterate over chambers with strip digis in them
170  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); j!=stripDigis.end(); ++j)
171  {
172  CSCDetId cscDetId=(*j).first;
173  // only digitize if there are pre-triggers
174 
175  bool me1abCheck = fedInfo.formatVersion_ == 2013;
176  /* !!! Testing. Uncomment for production */
177  if (!usePreTriggers || packEverything ||
178  (usePreTriggers && cscd2r::accept(cscDetId, preTriggers, preTriggerWindowMin_, preTriggerWindowMax_, me1abCheck)) )
179  {
180  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
181  bool zplus = (cscDetId.endcap() == 1);
182  bool me1b = (cscDetId.station()==1) && (cscDetId.ring()==1);
183 
184  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
185 
186  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
187  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
188  for ( ; digiItr != last; ++digiItr)
189  {
190  CSCStripDigi digi = *digiItr;
191  int strip = digi.getStrip();
192  if (fedInfo.formatVersion_ == 2013)
193  {
194  if ( me1a && zplus )
195  {
196  digi.setStrip(49-strip); // 1-48 -> 48-1
197  }
198  if ( me1b && !zplus)
199  {
200  digi.setStrip(65-strip); // 1-64 -> 64-1
201  }
202  if ( me1a )
203  {
204  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
205  digi.setStrip(strip+64);
206  }
207 
208  }
209  else
210  {
211  if ( me1a && zplus )
212  {
213  digi.setStrip(17-strip); // 1-16 -> 16-1
214  }
215  if ( me1b && !zplus)
216  {
217  digi.setStrip(65-strip); // 1-64 -> 64-1
218  }
219  if ( me1a )
220  {
221  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
222  digi.setStrip(strip+64);
223  }
224  }
225  cscData.add(digi, cscDetId.layer() );
226  }
227  }
228  }
229 }
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:41
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 232 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().

236 {
237  add(alctDigis, fedInfo);
238  for (CSCWireDigiCollection::DigiRangeIterator j=wireDigis.begin(); j!=wireDigis.end(); ++j)
239  {
240  CSCDetId cscDetId=(*j).first;
241  bool me1abCheck = fedInfo.formatVersion_ == 2013;
242  if (packEverything || cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_, me1abCheck))
243  {
244  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
245  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
246  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
247  for ( ; digiItr != last; ++digiItr)
248  {
249  cscData.add(*digiItr, cscDetId.layer() );
250  }
251  }
252  }
253 
254 }
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:41
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 256 of file CSCDigiToRaw.cc.

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

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

260 {
261  add(clctDigis,fedInfo);
262  for (auto const& j : comparatorDigis)
263  {
264  CSCDetId cscDetId=j.first;
265  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
266  bool me1abCheck = fedInfo.formatVersion_ == 2013;
267  if (packEverything || cscd2r::accept(cscDetId, clctDigis, clctWindowMin_, clctWindowMax_, me1abCheck))
268  {
269  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
270 
271 
272  for(auto digi = j.second.first; digi != j.second.second; ++digi)
273  {
274  if (fedInfo.formatVersion_ == 2013)
275  {
276  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
277  // been done already.
278  if (me1a && digi->getStrip() <= 48)
279  {
280  CSCComparatorDigi digi_corr(64+digi->getStrip(),
281  digi->getComparator(),
282  digi->getTimeBinWord());
283  cscData.add(digi_corr, cscDetId); // This version does ME11 strips swapping
284  // cscData.add(digi_corr, cscDetId.layer()); // This one doesn't
285  }
286  else
287  {
288  cscData.add(*digi, cscDetId); // This version does ME11 strips swapping
289  // cscData.add(digi, cscDetId.layer()); // This one doesn't
290  }
291  }
292  else
293  {
294  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
295  // been done already.
296  if (me1a && digi->getStrip() <= 16)
297  {
298  CSCComparatorDigi digi_corr(64+digi->getStrip(),
299  digi->getComparator(),
300  digi->getTimeBinWord());
301  cscData.add(digi_corr, cscDetId.layer());
302  }
303  else
304  {
305  cscData.add(*digi, cscDetId.layer());
306  }
307  }
308  }
309  }
310  }
311 }
const int clctWindowMin_
Definition: CSCDigiToRaw.h:82
const int clctWindowMax_
Definition: CSCDigiToRaw.h:83
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:41
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 313 of file CSCDigiToRaw.cc.

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

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

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

327 {
328  for (CSCCLCTDigiCollection::DigiRangeIterator j=clctDigis.begin(); j!=clctDigis.end(); ++j)
329  {
330  CSCDetId cscDetId=(*j).first;
331  CSCEventData & cscData = findEventData(cscDetId, fedInfo);
332 
333  bool me11a = cscDetId.station() == 1 && cscDetId.ring() == 4;
334  //CLCTs are packed by chamber not by A/B parts in ME11
335  //me11a appears only in simulation with SLHC algorithm settings
336  //without the shift, it's impossible to distinguish A and B parts
337  if (me11a && fedInfo.formatVersion_ == 2013){
338  std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
339  for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
340  if (iC->getCFEB() >= 0 && iC->getCFEB() < 3){//sanity check, mostly
341  (*iC) = CSCCLCTDigi(iC->isValid(), iC->getQuality(), iC->getPattern(), iC->getStripType(),
342  iC->getBend(), iC->getStrip(), iC->getCFEB()+4, iC->getBX(),
343  iC->getTrknmb(), iC->getFullBX());
344  }
345  }
346  cscData.add(shiftedDigis);
347  } else {
348  cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
349  }
350  }
351 }
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 353 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().

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

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

132 {
133  CSCDetId chamberId = cscd2r::chamberID(cscDetId);
134  // find the entry into the map
135  map<CSCDetId, CSCEventData>::iterator chamberMapItr = info.theChamberDataMap.find(chamberId);
136  if (chamberMapItr == info.theChamberDataMap.end())
137  {
138  // make an entry, telling it the correct chamberType
139  int chamberType = chamberId.iChamberType();
140  chamberMapItr = info.theChamberDataMap.insert(pair<CSCDetId, CSCEventData>(chamberId, CSCEventData(chamberType, info.formatVersion_))).first;
141  }
142  CSCEventData & cscData = chamberMapItr->second;
143  cscData.dmbHeader()->setCrateAddress(info.theElectronicsMap->crate(cscDetId), info.theElectronicsMap->dmb(cscDetId));
144 
145  if (info.formatVersion_ == 2013)
146  {
147  // Set DMB version field to distinguish between ME11s and other chambers (ME11 - 2, others - 1)
148  bool me11 = ((chamberId.station()==1) && (chamberId.ring()==4)) || ((chamberId.station()==1) && (chamberId.ring()==1));
149  if (me11)
150  {
151  cscData.dmbHeader()->setdmbVersion(2);
152  }
153  else
154  {
155  cscData.dmbHeader()->setdmbVersion(1);
156  }
157 
158  }
159  return cscData;
160 }
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:30
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().