CMS 3D CMS Logo

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

#include <CSCDigiToRaw.h>

Classes

struct  FindEventDataInfo
 

Public Types

enum  CSCShowerType { lctShower = 0, anodeShower = 1, cathodeShower = 2, anodeALCTShower = 3 }
 CSC Shower HMT bits types. More...
 

Public Member Functions

void createFedBuffers (const CSCStripDigiCollection &stripDigis, const CSCWireDigiCollection &wireDigis, const CSCComparatorDigiCollection &comparatorDigis, const CSCALCTDigiCollection &alctDigis, const CSCCLCTDigiCollection &clctDigis, const CSCCLCTPreTriggerCollection *preTriggers, const CSCCLCTPreTriggerDigiCollection *preTriggerDigis, const CSCCorrelatedLCTDigiCollection &correlatedLCTDigis, const CSCShowerDigiCollection *showerDigis, const CSCShowerDigiCollection *anodeShowerDigis, const CSCShowerDigiCollection *cathodeShowerDigis, const CSCShowerDigiCollection *anodeALCTShowerDigis, const GEMPadDigiClusterCollection *padDigiClusters, FEDRawDataCollection &fed_buffers, const CSCChamberMap *theMapping, const edm::EventID &eid) 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, const CSCCLCTPreTriggerDigiCollection *preTriggerDigis, FindEventDataInfo &) const
 
void add (const CSCWireDigiCollection &wireDigis, const CSCALCTDigiCollection &alctDigis, FindEventDataInfo &) const
 
void add (const CSCComparatorDigiCollection &comparatorDigis, const CSCCLCTDigiCollection &clctDigis, FindEventDataInfo &) const
 
void add (const CSCALCTDigiCollection &alctDigis, FindEventDataInfo &) const
 
void add (const CSCCLCTDigiCollection &clctDigis, FindEventDataInfo &) const
 
void add (const CSCCorrelatedLCTDigiCollection &corrLCTDigis, FindEventDataInfo &) const
 
void add (const CSCShowerDigiCollection &cscShowerDigis, FindEventDataInfo &, enum CSCShowerType shower=CSCShowerType::lctShower) const
 Run3 packing of CSCShower objects depending on shower HMT type. More...
 
void add (const GEMPadDigiClusterCollection &gemPadClusters, FindEventDataInfo &) const
 Run3 adding GEM GE11 Pad Clusters trigger objects. More...
 
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_
 
uint16_t formatVersion_
 
bool packByCFEB_
 
bool packEverything_
 
const int preTriggerWindowMax_
 
const int preTriggerWindowMin_
 
bool usePreTriggers_
 

Detailed Description

Author
A. Tumanov - Rice

Definition at line 26 of file CSCDigiToRaw.h.

Member Enumeration Documentation

CSC Shower HMT bits types.

Enumerator
lctShower 
anodeShower 
cathodeShower 
anodeALCTShower 

Definition at line 29 of file CSCDigiToRaw.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 29 of file CSCDigiToRaw.cc.

30  : alctWindowMin_(pset.getParameter<int>("alctWindowMin")),
31  alctWindowMax_(pset.getParameter<int>("alctWindowMax")),
32  clctWindowMin_(pset.getParameter<int>("clctWindowMin")),
33  clctWindowMax_(pset.getParameter<int>("clctWindowMax")),
34  preTriggerWindowMin_(pset.getParameter<int>("preTriggerWindowMin")),
35  preTriggerWindowMax_(pset.getParameter<int>("preTriggerWindowMax")),
36  // pre-LS1 - '2005'. post-LS1 - '2013', Run3 - '2020'
37  formatVersion_(pset.getParameter<unsigned>("formatVersion")),
38  // don't check for consistency with trig primitives
39  // overrides usePreTriggers
40  packEverything_(pset.getParameter<bool>("packEverything")),
41  usePreTriggers_(pset.getParameter<bool>("usePreTriggers")),
42  packByCFEB_(pset.getParameter<bool>("packByCFEB")) {}
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:91
bool usePreTriggers_
Definition: CSCDigiToRaw.h:93
const int clctWindowMin_
Definition: CSCDigiToRaw.h:86
bool packEverything_
Definition: CSCDigiToRaw.h:92
const int clctWindowMax_
Definition: CSCDigiToRaw.h:87
const int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:88
const int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:89
const int alctWindowMin_
Definition: CSCDigiToRaw.h:84
const int alctWindowMax_
Definition: CSCDigiToRaw.h:85
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool packByCFEB_
Definition: CSCDigiToRaw.h:94

Member Function Documentation

void CSCDigiToRaw::add ( const CSCStripDigiCollection stripDigis,
const CSCCLCTPreTriggerCollection preTriggers,
const CSCCLCTPreTriggerDigiCollection preTriggerDigis,
FindEventDataInfo fedInfo 
) const
private

Definition at line 71 of file CSCDigiToRaw.cc.

References CSCDigiToRawAccept::accept(), CSCEventData::add(), CSCConstants::CLCT_CENTRAL_BX, CSCDetId::endcap(), findEventData(), CSCDigiToRaw::FindEventDataInfo::formatVersion_, CSCStripDigi::getCFEB(), CSCStripDigi::getStrip(), dqmiolumiharvest::j, dqmdumpme::last, CSCDetId::layer(), CSCConstants::MAX_CFEBS_RUN2, CSCConstants::NUM_CFEBS_ME1B, CSCConstants::NUM_STRIPS_ME1A_GANGED, CSCConstants::NUM_STRIPS_ME1A_UNGANGED, CSCConstants::NUM_STRIPS_ME1B, packByCFEB_, packEverything_, preTriggerWindowMax_, preTriggerWindowMin_, CSCDetId::ring(), CSCStripDigi::setStrip(), CSCDetId::station(), digitizers_cfi::strip, usePreTriggers_, and SurfaceOrientation::zplus.

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

74  {
75  //iterate over chambers with strip digis in them
76  for (CSCStripDigiCollection::DigiRangeIterator j = stripDigis.begin(); j != stripDigis.end(); ++j) {
77  CSCDetId cscDetId = (*j).first;
78  // only digitize if there are pre-triggers
79 
80  // determine where the pretriggers are
81  std::vector<bool> preTriggerInCFEB;
82  preTriggerInCFEB.resize(CSCConstants::MAX_CFEBS_RUN2);
83 
84  // pretrigger flag must be set and the pretrigger collection must be nonzero!
85  const bool usePreTriggers = usePreTriggers_ and preTriggers != nullptr;
86  if (!usePreTriggers || packEverything_ ||
87  (usePreTriggers && CSCDigiToRawAccept::accept(cscDetId,
88  *preTriggerDigis,
92  preTriggerInCFEB))) {
93  bool me1a = (cscDetId.station() == 1) && (cscDetId.ring() == 4);
94  bool zplus = (cscDetId.endcap() == 1);
95  bool me1b = (cscDetId.station() == 1) && (cscDetId.ring() == 1);
96 
97  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
98 
99  std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
100  std::vector<CSCStripDigi>::const_iterator last = (*j).second.second;
101  for (; digiItr != last; ++digiItr) {
102  CSCStripDigi digi = *digiItr;
103  int strip = digi.getStrip();
104  int cfeb = digi.getCFEB();
105  // CSC strip digis in ME1/a have CFEB number 0, 1, or 2
106  // But a pretrigger in ME1/a has CFEB number 4, 5, or 6 (+4)
107  if (me1a)
109 
110  // At this point, if we are packing by CFEBs and there is no
111  // pretrigger in this CFEB, ignore this strip digi
112  if (packByCFEB_ and not preTriggerInCFEB[cfeb])
113  continue;
114 
115  // From LS1 on ME1a strips are unganged
116  if (fedInfo.formatVersion_ >= 2013) {
117  if (me1a && zplus) {
118  digi.setStrip(CSCConstants::NUM_STRIPS_ME1A_UNGANGED + 1 - strip); // 1-48 -> 48-1
119  }
120  if (me1b && !zplus) {
121  digi.setStrip(CSCConstants::NUM_STRIPS_ME1B + 1 - strip); // 1-64 -> 64-1
122  }
123  if (me1a) {
124  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
126  }
127  }
128  // During Run-1 ME1a strips are triple-ganged
129  else {
130  if (me1a && zplus) {
131  digi.setStrip(CSCConstants::NUM_STRIPS_ME1A_GANGED + 1 - strip); // 1-16 -> 16-1
132  }
133  if (me1b && !zplus) {
134  digi.setStrip(CSCConstants::NUM_STRIPS_ME1B + 1 - strip); // 1-64 -> 64-1
135  }
136  if (me1a) {
137  strip = digi.getStrip(); // reset back 1-16 to 65-80 digi
139  }
140  }
141  cscData.add(digi, cscDetId.layer());
142  }
143  }
144  }
145 }
int getCFEB() const
Get the CFEB number. Counts from 0.
Definition: CSCStripDigi.cc:25
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, int nominalBX)
bool usePreTriggers_
Definition: CSCDigiToRaw.h:93
bool packEverything_
Definition: CSCDigiToRaw.h:92
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:65
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
const int preTriggerWindowMin_
Definition: CSCDigiToRaw.h:88
const int preTriggerWindowMax_
Definition: CSCDigiToRaw.h:89
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
tuple last
Definition: dqmdumpme.py:56
bool packByCFEB_
Definition: CSCDigiToRaw.h:94
void CSCDigiToRaw::add ( const CSCWireDigiCollection wireDigis,
const CSCALCTDigiCollection alctDigis,
FindEventDataInfo fedInfo 
) const
private

Definition at line 147 of file CSCDigiToRaw.cc.

References CSCDigiToRawAccept::accept(), add(), CSCEventData::add(), CSCConstants::ALCT_CENTRAL_BX, alctWindowMax_, alctWindowMin_, findEventData(), dqmiolumiharvest::j, dqmdumpme::last, CSCDetId::layer(), and packEverything_.

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

149  {
150  add(alctDigis, fedInfo);
151  for (CSCWireDigiCollection::DigiRangeIterator j = wireDigis.begin(); j != wireDigis.end(); ++j) {
152  CSCDetId cscDetId = (*j).first;
155  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
156  std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
157  std::vector<CSCWireDigi>::const_iterator last = (*j).second.second;
158  for (; digiItr != last; ++digiItr) {
159  cscData.add(*digiItr, cscDetId.layer());
160  }
161  }
162  }
163 }
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, int nominalBX)
bool packEverything_
Definition: CSCDigiToRaw.h:92
int layer() const
Definition: CSCDetId.h:56
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
const int alctWindowMin_
Definition: CSCDigiToRaw.h:84
const int alctWindowMax_
Definition: CSCDigiToRaw.h:85
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection *preTriggers, const CSCCLCTPreTriggerDigiCollection *preTriggerDigis, FindEventDataInfo &) const
Definition: CSCDigiToRaw.cc:71
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
tuple last
Definition: dqmdumpme.py:56
void CSCDigiToRaw::add ( const CSCComparatorDigiCollection comparatorDigis,
const CSCCLCTDigiCollection clctDigis,
FindEventDataInfo fedInfo 
) const
private

Definition at line 165 of file CSCDigiToRaw.cc.

References CSCDigiToRawAccept::accept(), add(), CSCEventData::add(), CSCConstants::CLCT_CENTRAL_BX, clctWindowMax_, clctWindowMin_, findEventData(), CSCDigiToRaw::FindEventDataInfo::formatVersion_, dqmiolumiharvest::j, CSCDetId::layer(), CSCConstants::NUM_STRIPS_ME1A_GANGED, CSCConstants::NUM_STRIPS_ME1A_UNGANGED, CSCConstants::NUM_STRIPS_ME1B, packEverything_, CSCDetId::ring(), and CSCDetId::station().

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

167  {
168  add(clctDigis, fedInfo);
169  for (auto const& j : comparatorDigis) {
170  CSCDetId cscDetId = j.first;
171  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
174  bool me1a = (cscDetId.station() == 1) && (cscDetId.ring() == 4);
175 
176  /*
177  Add the comparator digi to the fedInfo.
178  Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not
179  been done already.
180  Consider the case for triple-ganged and unganged ME1A strips
181  */
182  for (auto digi = j.second.first; digi != j.second.second; ++digi) {
183  if (fedInfo.formatVersion_ >= 2013) {
184  // unganged case
185  if (me1a && digi->getStrip() <= CSCConstants::NUM_STRIPS_ME1A_UNGANGED) {
186  CSCComparatorDigi digi_corr(
187  CSCConstants::NUM_STRIPS_ME1B + digi->getStrip(), digi->getComparator(), digi->getTimeBinWord());
188  cscData.add(digi_corr, cscDetId);
189  } else {
190  cscData.add(*digi, cscDetId);
191  }
192  }
193  // triple-ganged case
194  else {
195  if (me1a && digi->getStrip() <= CSCConstants::NUM_STRIPS_ME1A_GANGED) {
196  CSCComparatorDigi digi_corr(
197  CSCConstants::NUM_STRIPS_ME1B + digi->getStrip(), digi->getComparator(), digi->getTimeBinWord());
198  cscData.add(digi_corr, cscDetId.layer());
199  } else {
200  cscData.add(*digi, cscDetId.layer());
201  }
202  }
203  }
204  }
205  }
206 }
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, int nominalBX)
const int clctWindowMin_
Definition: CSCDigiToRaw.h:86
bool packEverything_
Definition: CSCDigiToRaw.h:92
const int clctWindowMax_
Definition: CSCDigiToRaw.h:87
int layer() const
Definition: CSCDetId.h:56
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
int ring() const
Definition: CSCDetId.h:68
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection *preTriggers, const CSCCLCTPreTriggerDigiCollection *preTriggerDigis, FindEventDataInfo &) const
Definition: CSCDigiToRaw.cc:71
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
int station() const
Definition: CSCDetId.h:79
void CSCDigiToRaw::add ( const CSCALCTDigiCollection alctDigis,
FindEventDataInfo fedInfo 
) const
private

Definition at line 208 of file CSCDigiToRaw.cc.

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

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

208  {
209  for (CSCALCTDigiCollection::DigiRangeIterator j = alctDigis.begin(); j != alctDigis.end(); ++j) {
210  CSCDetId cscDetId = (*j).first;
211  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
212 
213  cscData.add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
214  }
215 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
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 217 of file CSCDigiToRaw.cc.

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

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

217  {
218  for (CSCCLCTDigiCollection::DigiRangeIterator j = clctDigis.begin(); j != clctDigis.end(); ++j) {
219  CSCDetId cscDetId = (*j).first;
220  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
221 
222  bool me11a = cscDetId.station() == 1 && cscDetId.ring() == 4;
223  //CLCTs are packed by chamber not by A/B parts in ME11
224  //me11a appears only in simulation with SLHC algorithm settings
225  //without the shift, it's impossible to distinguish A and B parts
226  if (me11a && fedInfo.formatVersion_ >= 2013) {
227  std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
228  for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
229  if (iC->getCFEB() < CSCConstants::NUM_CFEBS_ME1A_UNGANGED) { //sanity check, mostly
230  (*iC) = CSCCLCTDigi(iC->isValid(),
231  iC->getQuality(),
232  iC->getPattern(),
233  iC->getStripType(),
234  iC->getBend(),
235  iC->getStrip(),
236  iC->getCFEB() + CSCConstants::NUM_CFEBS_ME1B,
237  iC->getBX(),
238  iC->getTrknmb(),
239  iC->getFullBX());
240  }
241  }
242  cscData.add(shiftedDigis);
243  } else {
244  cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
245  }
246  }
247 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
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 249 of file CSCDigiToRaw.cc.

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

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

249  {
250  for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j = corrLCTDigis.begin(); j != corrLCTDigis.end(); ++j) {
251  CSCDetId cscDetId = (*j).first;
252  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
253 
254  bool me11a = cscDetId.station() == 1 && cscDetId.ring() == 4;
255  //LCTs are packed by chamber not by A/B parts in ME11
256  //me11a appears only in simulation with SLHC algorithm settings
257  //without the shift, it's impossible to distinguish A and B parts
258  if (me11a && fedInfo.formatVersion_ >= 2013) {
259  std::vector<CSCCorrelatedLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
260  for (std::vector<CSCCorrelatedLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
261  if (iC->getStrip() < CSCConstants::NUM_HALF_STRIPS_ME1A_UNGANGED) { //sanity check, mostly
262  (*iC) = CSCCorrelatedLCTDigi(iC->getTrknmb(),
263  iC->isValid(),
264  iC->getQuality(),
265  iC->getKeyWG(),
266  iC->getStrip() + CSCConstants::NUM_HALF_STRIPS_ME1B,
267  iC->getPattern(),
268  iC->getBend(),
269  iC->getBX(),
270  iC->getMPCLink(),
271  iC->getBX0(),
272  iC->getSyncErr(),
273  iC->getCSCID());
274  }
275  }
276  cscData.add(shiftedDigis);
277  } else {
278  cscData.add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
279  }
280  }
281 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
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 CSCShowerDigiCollection cscShowerDigis,
FindEventDataInfo fedInfo,
enum CSCShowerType  shower = CSCShowerType::lctShower 
) const
private

Run3 packing of CSCShower objects depending on shower HMT type.

Definition at line 283 of file CSCDigiToRaw.cc.

References CSCEventData::addAnodeALCTShower(), CSCEventData::addAnodeShower(), CSCEventData::addCathodeShower(), CSCEventData::addShower(), and findEventData().

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

285  {
286  for (const auto& shower : cscShowerDigis) {
287  const CSCDetId& cscDetId = shower.first;
288  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
289 
290  switch (showerType) {
291  case CSCShowerType::lctShower:
292  cscData.addShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
293  break;
294  case CSCShowerType::anodeShower:
295  cscData.addAnodeShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
296  break;
297  case CSCShowerType::cathodeShower:
298  cscData.addCathodeShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
299  break;
300  case CSCShowerType::anodeALCTShower:
301  cscData.addAnodeALCTShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
302  break;
303  default:
304  cscData.addShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
305  }
306  }
307 }
void addAnodeShower(const std::vector< CSCShowerDigi > &)
Add/pack anode CSCShower object (from OTMB header)
void addAnodeALCTShower(const std::vector< CSCShowerDigi > &)
Add/pack anode CSCShower objects (from ALCT board data)
void addShower(const std::vector< CSCShowerDigi > &)
Run3 CSC Shower HMT objects.
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
void addCathodeShower(const std::vector< CSCShowerDigi > &)
Add/pack cathode CSCShower object (from OTMB header)
void CSCDigiToRaw::add ( const GEMPadDigiClusterCollection gemPadClusters,
FindEventDataInfo fedInfo 
) const
private

Run3 adding GEM GE11 Pad Clusters trigger objects.

Definition at line 309 of file CSCDigiToRaw.cc.

References GEMDetId::chamber(), findEventData(), GEMDetId::region(), and GEMDetId::station().

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

309  {
310  for (const auto& jclus : gemPadClusters) {
311  const GEMDetId& gemDetId = jclus.first;
312 
313  const int zendcap = gemDetId.region() == 1 ? 1 : 2;
314  CSCDetId cscDetId(zendcap, gemDetId.station(), 1, gemDetId.chamber(), 0);
315  CSCEventData& cscData = findEventData(cscDetId, fedInfo);
316 
317  cscData.add(std::vector<GEMPadDigiCluster>(jclus.second.first, jclus.second.second), gemDetId);
318  }
319 }
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
Definition: CSCDigiToRaw.cc:44
constexpr int region() const
Definition: GEMDetId.h:171
constexpr int chamber() const
Definition: GEMDetId.h:183
constexpr int station() const
Definition: GEMDetId.h:179
void CSCDigiToRaw::createFedBuffers ( const CSCStripDigiCollection stripDigis,
const CSCWireDigiCollection wireDigis,
const CSCComparatorDigiCollection comparatorDigis,
const CSCALCTDigiCollection alctDigis,
const CSCCLCTDigiCollection clctDigis,
const CSCCLCTPreTriggerCollection preTriggers,
const CSCCLCTPreTriggerDigiCollection preTriggerDigis,
const CSCCorrelatedLCTDigiCollection correlatedLCTDigis,
const CSCShowerDigiCollection showerDigis,
const CSCShowerDigiCollection anodeShowerDigis,
const CSCShowerDigiCollection cathodeShowerDigis,
const CSCShowerDigiCollection anodeALCTShowerDigis,
const GEMPadDigiClusterCollection padDigiClusters,
FEDRawDataCollection fed_buffers,
const CSCChamberMap theMapping,
const edm::EventID eid 
) 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 321 of file CSCDigiToRaw.cc.

References add(), bitset_utilities::bitsetToChar(), makePileupJSON::bx, evf::compute_crc(), FEDRawData::data(), CSCChamberMap::ddu(), CSCChamberMap::dduInput(), CSCChamberMap::dduSlot(), CSCChamberMap::dmb(), edm::EventID::event(), Exception, FEDRawDataCollection::FEDData(), formatVersion_, mps_fire::i, FEDNumbering::MAXCSCDDUFEDID, FEDNumbering::MAXCSCFEDID, FEDNumbering::MINCSCDDUFEDID, FEDNumbering::MINCSCFEDID, CSCConstants::NUM_DDUS, FEDRawData::resize(), FEDRawData::size(), and CSCChamberMap::slink().

336  {
337  //get fed object from fed_buffers
338  // make a map from the index of a chamber to the event data from it
339  FindEventDataInfo fedInfo{mapping, formatVersion_};
340 
341  add(stripDigis, preTriggers, preTriggerDigis, fedInfo);
342  add(wireDigis, alctDigis, fedInfo);
343  add(comparatorDigis, clctDigis, fedInfo);
344  add(correlatedLCTDigis, fedInfo);
345 
346  // Starting Run-3, the CSC DAQ will pack/unpack CSC showers
347  // lctShower 4-bits sent from OTMB to MPC in trigger data
348  // anodeShower - anodeHMT 2-bits in OTMB
349  // cathodeShower - cathodeHMT 2-bits in OTMB
350  // anodeALCTShower - vector of anode HMT 2-bits per ALCT bx sent by ALCT board to OTMB
351  if (cscShowerDigis) {
352  add(*cscShowerDigis, fedInfo, CSCShowerType::lctShower);
353  add(*anodeShowerDigis, fedInfo, CSCShowerType::anodeShower);
354  add(*cathodeShowerDigis, fedInfo, CSCShowerType::cathodeShower);
355  add(*anodeALCTShowerDigis, fedInfo, CSCShowerType::anodeALCTShower);
356  }
357 
358  // Starting Run-3, the CSC DAQ will pack/unpack GEM clusters
359  if (gemPadDigiClusters) {
360  add(*gemPadDigiClusters, fedInfo);
361  }
362  int l1a = eid.event(); //need to add increments or get it from lct digis
363  int bx = l1a; //same as above
364 
365  if (fedInfo.formatVersion_ == 2005)
366  {
367  std::map<int, CSCDCCEventData> dccMap;
368  //idcc goes from startingFed to startingFED+7
369  for (int idcc = FEDNumbering::MINCSCFEDID; idcc <= FEDNumbering::MAXCSCFEDID; ++idcc) {
370  dccMap.insert(std::pair<int, CSCDCCEventData>(idcc, CSCDCCEventData(idcc, CSCConstants::NUM_DDUS, bx, l1a)));
371  }
372 
373  for (int idcc = FEDNumbering::MINCSCFEDID; idcc <= FEDNumbering::MAXCSCFEDID; ++idcc) {
374  // for every chamber with data, add to a DDU in this DCC Event
375  for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
376  chamberItr != fedInfo.theChamberDataMap.end();
377  ++chamberItr) {
378  int indexDCC = mapping->slink(chamberItr->first);
379  if (indexDCC == idcc) {
380  //FIXME (What does this mean? Is something wrong?)
381  std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
382  if (dccMapItr == dccMap.end()) {
383  throw cms::Exception("CSCDigiToRaw") << "Bad DCC number:" << indexDCC;
384  }
385  // get id's based on ChamberId from mapping
386 
387  int dduId = mapping->ddu(chamberItr->first);
388  int dduSlot = mapping->dduSlot(chamberItr->first);
389  int dduInput = mapping->dduInput(chamberItr->first);
390  int dmbId = mapping->dmb(chamberItr->first);
391  dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId, formatVersion_);
392  }
393  }
394  }
395 
396  // FIXME: FEDRawData size set to 2*64 to add FED header and trailer
397  for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin(); dccMapItr != dccMap.end(); ++dccMapItr) {
398  boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
399  FEDRawData& fedRawData = fed_buffers.FEDData(dccMapItr->first);
400  fedRawData.resize(dccBits.size());
401  //fill data with dccEvent
402  bitset_utilities::bitsetToChar(dccBits, fedRawData.data());
403  FEDTrailer cscFEDTrailer(fedRawData.data() + (fedRawData.size() - 8));
404  cscFEDTrailer.set(fedRawData.data() + (fedRawData.size() - 8),
405  fedRawData.size() / 8,
406  evf::compute_crc(fedRawData.data(), fedRawData.size()),
407  0,
408  0);
409  }
410  }
412  else if (formatVersion_ >= 2013) {
413  std::map<int, CSCDDUEventData> dduMap;
414  unsigned int ddu_fmt_version = 0x7;
415  const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
416  834, 835, 836, 837, 838, 839, 861, 862, 863, 864, 865, 866,
417  867, 868, 869, 851, 852, 853, 854, 855, 856, 857, 858, 859};
418 
420  for (unsigned int i = 0; i < 36; i++) {
421  unsigned int iddu = postLS1_map[i];
422  // make a new one
423  CSCDDUHeader newDDUHeader(bx, l1a, iddu, ddu_fmt_version);
424 
425  dduMap.insert(std::pair<int, CSCDDUEventData>(iddu, CSCDDUEventData(newDDUHeader)));
426  }
427 
429  for (unsigned int i = 0; i < 36; i++) {
430  unsigned int iddu = postLS1_map[i];
431  // for every chamber with data, add to a DDU in this DCC Event
432  for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
433  chamberItr != fedInfo.theChamberDataMap.end();
434  ++chamberItr) {
435  unsigned int indexDDU = mapping->slink(chamberItr->first);
436 
438  // Still preLS1 DCC FEDs mapping
439  if ((indexDDU >= FEDNumbering::MINCSCFEDID) && (indexDDU <= FEDNumbering::MAXCSCFEDID)) {
440  int dduID = mapping->ddu(chamberItr->first); // try to switch to DDU ID mapping
441  // DDU ID is in expectedi post-LS1 FED ID range
442  if ((dduID >= FEDNumbering::MINCSCDDUFEDID) && (dduID <= FEDNumbering::MAXCSCDDUFEDID)) {
443  indexDDU = dduID;
444  } else // Messy
445  {
446  // Lets try to change pre-LS1 1-36 ID range to post-LS1 MINCSCDDUFEDID - MAXCSCDDUFEDID range
447  dduID &= 0xFF;
448  // indexDDU = FEDNumbering::MINCSCDDUFEDID + dduID-1;
449  if ((dduID <= 36) && (dduID > 0))
450  indexDDU = postLS1_map[dduID - 1];
451  }
452  }
453 
454  if (indexDDU == iddu) {
455  std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
456  if (dduMapItr == dduMap.end()) {
457  throw cms::Exception("CSCDigiToRaw") << "Bad DDU number:" << indexDDU;
458  }
459  // get id's based on ChamberId from mapping
460 
461  int dduInput = mapping->dduInput(chamberItr->first);
462  int dmbId = mapping->dmb(chamberItr->first);
463  // int crateId = mapping->crate(chamberItr->first);
464  dduMapItr->second.add(chamberItr->second, dmbId, dduInput, formatVersion_);
465  }
466  }
467  }
468 
469  // FIXME: FEDRawData size set to 2*64 to add FED header and trailer
470  for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin(); dduMapItr != dduMap.end(); ++dduMapItr) {
471  boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
472  FEDRawData& fedRawData = fed_buffers.FEDData(dduMapItr->first);
473  fedRawData.resize(dduBits.size() / 8);
474  //fill data with dduEvent
475  bitset_utilities::bitsetToChar(dduBits, fedRawData.data());
476  FEDTrailer cscFEDTrailer(fedRawData.data() + (fedRawData.size() - 8));
477  cscFEDTrailer.set(fedRawData.data() + (fedRawData.size() - 8),
478  fedRawData.size() / 8,
479  evf::compute_crc(fedRawData.data(), fedRawData.size()),
480  0,
481  0);
482  }
483  }
484 }
01/20/05 A.Tumanov
EventNumber_t event() const
Definition: EventID.h:40
uint16_t formatVersion_
Definition: CSCDigiToRaw.h:91
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
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection *preTriggers, const CSCCLCTPreTriggerDigiCollection *preTriggerDigis, FindEventDataInfo &) const
Definition: CSCDigiToRaw.cc:71
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
CSCEventData & CSCDigiToRaw::findEventData ( const CSCDetId cscDetId,
FindEventDataInfo info 
) const
private

pick out the correct data object for this chamber

Definition at line 44 of file CSCDigiToRaw.cc.

References CSCDigiToRawAccept::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().

44  {
45  CSCDetId chamberId = CSCDigiToRawAccept::chamberID(cscDetId);
46  // find the entry into the map
47  map<CSCDetId, CSCEventData>::iterator chamberMapItr = info.theChamberDataMap.find(chamberId);
48  if (chamberMapItr == info.theChamberDataMap.end()) {
49  // make an entry, telling it the correct chamberType
50  int chamberType = chamberId.iChamberType();
51  chamberMapItr = info.theChamberDataMap
52  .insert(pair<CSCDetId, CSCEventData>(chamberId, CSCEventData(chamberType, info.formatVersion_)))
53  .first;
54  }
55  CSCEventData& cscData = chamberMapItr->second;
56  cscData.dmbHeader()->setCrateAddress(info.theElectronicsMap->crate(cscDetId), info.theElectronicsMap->dmb(cscDetId));
57 
58  if (info.formatVersion_ >= 2013) {
59  // Set DMB version field to distinguish between ME11s and other chambers (ME11 - 2, others - 1)
60  bool me11 = ((chamberId.station() == 1) && (chamberId.ring() == 4)) ||
61  ((chamberId.station() == 1) && (chamberId.ring() == 1));
62  if (me11) {
63  cscData.dmbHeader()->setdmbVersion(2);
64  } else {
65  cscData.dmbHeader()->setdmbVersion(1);
66  }
67  }
68  return cscData;
69 }
static const TGPicture * info(bool iBackgroundIsBlack)
void setdmbVersion(unsigned int version)
Definition: CSCDMBHeader.h:32
CSCDetId chamberID(const CSCDetId &cscDetId)
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:73

Member Data Documentation

const int CSCDigiToRaw::alctWindowMax_
private

Definition at line 85 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::alctWindowMin_
private

Definition at line 84 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::clctWindowMax_
private

Definition at line 87 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::clctWindowMin_
private

Definition at line 86 of file CSCDigiToRaw.h.

Referenced by add().

uint16_t CSCDigiToRaw::formatVersion_
private

Definition at line 91 of file CSCDigiToRaw.h.

Referenced by createFedBuffers().

bool CSCDigiToRaw::packByCFEB_
private

Definition at line 94 of file CSCDigiToRaw.h.

Referenced by add().

bool CSCDigiToRaw::packEverything_
private

Definition at line 92 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::preTriggerWindowMax_
private

Definition at line 89 of file CSCDigiToRaw.h.

Referenced by add().

const int CSCDigiToRaw::preTriggerWindowMin_
private

Definition at line 88 of file CSCDigiToRaw.h.

Referenced by add().

bool CSCDigiToRaw::usePreTriggers_
private

Definition at line 93 of file CSCDigiToRaw.h.

Referenced by add().