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

105  : alctWindowMin_(pset.getParameter<int>("alctWindowMin")),
106  alctWindowMax_(pset.getParameter<int>("alctWindowMax")),
107  clctWindowMin_(pset.getParameter<int>("clctWindowMin")),
108  clctWindowMax_(pset.getParameter<int>("clctWindowMax")),
109  preTriggerWindowMin_(pset.getParameter<int>("preTriggerWindowMin")),
110  preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax")) {}
T getParameter(std::string const &) const
const int clctWindowMin_
Definition: CSCDigiToRaw.h:76
const int clctWindowMax_
Definition: CSCDigiToRaw.h:77
const int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:78
const int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:79
const int alctWindowMin_
Definition: CSCDigiToRaw.h:74
const int alctWindowMax_
Definition: CSCDigiToRaw.h:75

Member Function Documentation

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

Definition at line 139 of file CSCDigiToRaw.cc.

References cscd2r::accept(), CSCEventData::add(), CSCDetId::endcap(), findEventData(), CSCDigiToRaw::FindEventDataInfo::formatVersion_, CSCStripDigi::getStrip(), dqmiolumiharvest::j, dqmdumpme::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().

143  { //iterate over chambers with strip digis in them
144  for (CSCStripDigiCollection::DigiRangeIterator j = stripDigis.begin(); j != stripDigis.end(); ++j) {
145  CSCDetId cscDetId = (*j).first;
146  // only digitize if there are pre-triggers
147 
148  bool me1abCheck = fedInfo.formatVersion_ == 2013;
149  /* !!! Testing. Uncomment for production */
150  if (!usePreTriggers || packEverything ||
151  (usePreTriggers &&
152  cscd2r::accept(cscDetId, preTriggers, preTriggerWindowMin_, preTriggerWindowMax_, me1abCheck))) {
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, fedInfo);
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  CSCStripDigi digi = *digiItr;
163  int strip = digi.getStrip();
164  if (fedInfo.formatVersion_ == 2013) {
165  if (me1a && zplus) {
166  digi.setStrip(49 - strip); // 1-48 -> 48-1
167  }
168  if (me1b && !zplus) {
169  digi.setStrip(65 - strip); // 1-64 -> 64-1
170  }
171  if (me1a) {
172  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
173  digi.setStrip(strip + 64);
174  }
175 
176  } else {
177  if (me1a && zplus) {
178  digi.setStrip(17 - strip); // 1-16 -> 16-1
179  }
180  if (me1b && !zplus) {
181  digi.setStrip(65 - strip); // 1-64 -> 64-1
182  }
183  if (me1a) {
184  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
185  digi.setStrip(strip + 64);
186  }
187  }
188  cscData.add(digi, cscDetId.layer());
189  }
190  }
191  }
192 }
int layer() const
Definition: CSCDetId.h:56
int getStrip() const
Definition: CSCStripDigi.h:41
int endcap() const
Definition: CSCDetId.h:85
void setStrip(int istrip)
Definition: CSCStripDigi.h:62
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
const int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:78
const int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:79
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
Definition: CSCDigiToRaw.cc:38
int ring() const
Definition: CSCDetId.h:68
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:79
void CSCDigiToRaw::add ( const CSCWireDigiCollection wireDigis,
const CSCALCTDigiCollection alctDigis,
FindEventDataInfo fedInfo,
bool  packEverything 
) const
private

Definition at line 194 of file CSCDigiToRaw.cc.

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

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

197  {
198  add(alctDigis, fedInfo);
199  for (CSCWireDigiCollection::DigiRangeIterator j = wireDigis.begin(); j != wireDigis.end(); ++j) {
200  CSCDetId cscDetId = (*j).first;
201  bool me1abCheck = fedInfo.formatVersion_ == 2013;
202  if (packEverything || cscd2r::accept(cscDetId, alctDigis, alctWindowMin_, alctWindowMax_, me1abCheck)) {
203  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
204  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
205  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
206  for (; digiItr != last; ++digiItr) {
207  cscData.add(*digiItr, cscDetId.layer());
208  }
209  }
210  }
211 }
int layer() const
Definition: CSCDetId.h:56
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:38
const int alctWindowMin_
Definition: CSCDigiToRaw.h:74
const int alctWindowMax_
Definition: CSCDigiToRaw.h:75
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 213 of file CSCDigiToRaw.cc.

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

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

216  {
217  add(clctDigis, fedInfo);
218  for (auto const& j : comparatorDigis) {
219  CSCDetId cscDetId = j.first;
220  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
221  bool me1abCheck = fedInfo.formatVersion_ == 2013;
222  if (packEverything || cscd2r::accept(cscDetId, clctDigis, clctWindowMin_, clctWindowMax_, me1abCheck)) {
223  bool me1a = (cscDetId.station() == 1) && (cscDetId.ring() == 4);
224 
225  for (auto digi = j.second.first; digi != j.second.second; ++digi) {
226  if (fedInfo.formatVersion_ == 2013) {
227  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
228  // been done already.
229  if (me1a && digi->getStrip() <= 48) {
230  CSCComparatorDigi digi_corr(64 + digi->getStrip(), digi->getComparator(), digi->getTimeBinWord());
231  cscData.add(digi_corr, cscDetId); // This version does ME11 strips swapping
232  // cscData.add(digi_corr, cscDetId.layer()); // This one doesn't
233  } else {
234  cscData.add(*digi, cscDetId); // This version does ME11 strips swapping
235  // cscData.add(digi, cscDetId.layer()); // This one doesn't
236  }
237  } else {
238  // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
239  // been done already.
240  if (me1a && digi->getStrip() <= 16) {
241  CSCComparatorDigi digi_corr(64 + digi->getStrip(), digi->getComparator(), digi->getTimeBinWord());
242  cscData.add(digi_corr, cscDetId.layer());
243  } else {
244  cscData.add(*digi, cscDetId.layer());
245  }
246  }
247  }
248  }
249  }
250 }
const int clctWindowMin_
Definition: CSCDigiToRaw.h:76
const int clctWindowMax_
Definition: CSCDigiToRaw.h:77
int layer() const
Definition: CSCDetId.h:56
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:38
int ring() const
Definition: CSCDetId.h:68
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:79
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 252 of file CSCDigiToRaw.cc.

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

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

252  {
253  for (CSCALCTDigiCollection::DigiRangeIterator j = alctDigis.begin(); j != alctDigis.end(); ++j) {
254  CSCDetId cscDetId = (*j).first;
255  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
256 
257  cscData.add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
258  }
259 }
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 261 of file CSCDigiToRaw.cc.

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

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

261  {
262  for (CSCCLCTDigiCollection::DigiRangeIterator j = clctDigis.begin(); j != clctDigis.end(); ++j) {
263  CSCDetId cscDetId = (*j).first;
264  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
265 
266  bool me11a = cscDetId.station() == 1 && cscDetId.ring() == 4;
267  //CLCTs are packed by chamber not by A/B parts in ME11
268  //me11a appears only in simulation with SLHC algorithm settings
269  //without the shift, it's impossible to distinguish A and B parts
270  if (me11a && fedInfo.formatVersion_ == 2013) {
271  std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
272  for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
273  if (iC->getCFEB() >= 0 && iC->getCFEB() < 3) { //sanity check, mostly
274  (*iC) = CSCCLCTDigi(iC->isValid(),
275  iC->getQuality(),
276  iC->getPattern(),
277  iC->getStripType(),
278  iC->getBend(),
279  iC->getStrip(),
280  iC->getCFEB() + 4,
281  iC->getBX(),
282  iC->getTrknmb(),
283  iC->getFullBX());
284  }
285  }
286  cscData.add(shiftedDigis);
287  } else {
288  cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
289  }
290  }
291 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
int ring() const
Definition: CSCDetId.h:68
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:79
void CSCDigiToRaw::add ( const CSCCorrelatedLCTDigiCollection corrLCTDigis,
FindEventDataInfo fedInfo 
) const
private

Definition at line 293 of file CSCDigiToRaw.cc.

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

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

293  {
294  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j = corrLCTDigis.begin(); j != corrLCTDigis.end(); ++j) {
295  CSCDetId cscDetId = (*j).first;
296  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
297 
298  bool me11a = cscDetId.station() == 1 && cscDetId.ring() == 4;
299  //LCTs are packed by chamber not by A/B parts in ME11
300  //me11a appears only in simulation with SLHC algorithm settings
301  //without the shift, it's impossible to distinguish A and B parts
302  if (me11a && fedInfo.formatVersion_ == 2013) {
303  std::vector<CSCCorrelatedLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
304  for (std::vector<CSCCorrelatedLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
305  if (iC->getStrip() >= 0 && iC->getStrip() < 96) { //sanity check, mostly
306  (*iC) = CSCCorrelatedLCTDigi(iC->getTrknmb(),
307  iC->isValid(),
308  iC->getQuality(),
309  iC->getKeyWG(),
310  iC->getStrip() + 128,
311  iC->getPattern(),
312  iC->getBend(),
313  iC->getBX(),
314  iC->getMPCLink(),
315  iC->getBX0(),
316  iC->getSyncErr(),
317  iC->getCSCID());
318  }
319  }
320  cscData.add(shiftedDigis);
321  } else {
322  cscData.add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
323  }
324  }
325 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
int ring() const
Definition: CSCDetId.h:68
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:79
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 327 of file CSCDigiToRaw.cc.

References add(), bitset_utilities::bitsetToChar(), l1GtPatternGenerator_cfi::bx, evf::compute_crc(), FEDRawData::data(), CSCChamberMap::ddu(), CSCChamberMap::dduInput(), CSCChamberMap::dduSlot(), CSCChamberMap::dmb(), edm::EventID::event(), Exception, FEDRawDataCollection::FEDData(), l1t_dqm_sourceclient-live_cfg::fedRawData, 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().

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

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

Member Data Documentation

const int CSCDigiToRaw::alctWindowMax_
private

Definition at line 75 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::alctWindowMin_
private

Definition at line 74 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::clctWindowMax_
private

Definition at line 77 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::clctWindowMin_
private

Definition at line 76 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::preTriggerWindowMax_
private

Definition at line 79 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::preTriggerWindowMin_
private

Definition at line 78 of file CSCDigiToRaw.h.

Referenced by add().