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 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  formatVersion_(2005),
131  usePreTriggers_(true),
132  packEverything_(false)
133 {}
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 175 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().

177 { //iterate over chambers with strip digis in them
178  for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); j!=stripDigis.end(); ++j)
179  {
180  CSCDetId cscDetId=(*j).first;
181  // only digitize if there are pre-triggers
182 
183  bool me1abCheck = formatVersion_ == 2013;
184  /* !!! Testing. Uncomment for production */
186  (usePreTriggers_ && cscd2r::accept(cscDetId, preTriggers, preTriggerWindowMin_, preTriggerWindowMax_, me1abCheck)) )
187  {
188  bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4);
189  bool zplus = (cscDetId.endcap() == 1);
190  bool me1b = (cscDetId.station()==1) && (cscDetId.ring()==1);
191 
192  CSCEventData & cscData = findEventData(cscDetId);
193 
194  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
195  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
196  for ( ; digiItr != last; ++digiItr)
197  {
198  CSCStripDigi digi = *digiItr;
199  int strip = digi.getStrip();
200  if (formatVersion_ == 2013)
201  {
202  if ( me1a && zplus )
203  {
204  digi.setStrip(49-strip); // 1-48 -> 48-1
205  }
206  if ( me1b && !zplus)
207  {
208  digi.setStrip(65-strip); // 1-64 -> 64-1
209  }
210  if ( me1a )
211  {
212  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
213  digi.setStrip(strip+64);
214  }
215 
216  }
217  else
218  {
219  if ( me1a && zplus )
220  {
221  digi.setStrip(17-strip); // 1-16 -> 16-1
222  }
223  if ( me1b && !zplus)
224  {
225  digi.setStrip(65-strip); // 1-64 -> 64-1
226  }
227  if ( me1a )
228  {
229  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
230  digi.setStrip(strip+64);
231  }
232  }
233  cscData.add(digi, cscDetId.layer() );
234  }
235  }
236  }
237 }
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
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
Definition: CSCDigiToRaw.cc:42
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
int station() const
Definition: CSCDetId.h:99
void CSCDigiToRaw::add ( const CSCWireDigiCollection wireDigis,
const CSCALCTDigiCollection alctDigis 
)
private

Definition at line 240 of file CSCDigiToRaw.cc.

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

Referenced by counter.Counter::register().

242 {
243  add(alctDigis);
244  for (CSCWireDigiCollection::DigiRangeIterator j=wireDigis.begin(); j!=wireDigis.end(); ++j)
245  {
246  CSCDetId cscDetId=(*j).first;
247  bool me1abCheck = formatVersion_ == 2013;
248  if (packEverything_ || cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_, me1abCheck))
249  {
250  CSCEventData & cscData = findEventData(cscDetId);
251  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
252  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
253  for ( ; digiItr != last; ++digiItr)
254  {
255  cscData.add(*digiItr, cscDetId.layer() );
256  }
257  }
258  }
259 
260 }
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:68
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
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
Definition: CSCDigiToRaw.cc:42
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 CSCComparatorDigiCollection comparatorDigis,
const CSCCLCTDigiCollection clctDigis 
)
private

Definition at line 262 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().

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

Definition at line 317 of file CSCDigiToRaw.cc.

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

Referenced by counter.Counter::register().

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

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

Referenced by counter.Counter::register().

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

Definition at line 355 of file CSCDigiToRaw.cc.

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

Referenced by counter.Counter::register().

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

Definition at line 135 of file CSCDigiToRaw.cc.

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

Referenced by createFedBuffers().

136 {
137  theChamberDataMap.clear();
139 }
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 385 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().

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

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