13 #include "boost/dynamic_bitset.hpp" 31 if (chamberId.
ring() == 4) {
37 template <
typename LCTCollection>
45 for (
typename LCTCollection::const_iterator lctItr = lctRange.first; lctItr != lctRange.second; ++lctItr) {
46 int bx = lctItr->getBX() - nominalBX;
47 if (bx >= bxMin && bx <= bxMax) {
56 if (me1 && result ==
false && me1abCheck) {
58 lctRange = lcts.get(me1aId);
59 for (
typename LCTCollection::const_iterator lctItr = lctRange.first; lctItr != lctRange.second; ++lctItr) {
60 int bx = lctItr->getBX() - nominalBX;
61 if (bx >= bxMin && bx <= bxMax) {
81 int bx = *lctItr - nominalBX;
82 if (bx >= bxMin && bx <= bxMax) {
87 bool me1a = cscId.
station() == 1 && cscId.
ring() == 4;
88 if (me1a && result ==
false && me1abCheck) {
90 lctRange = lcts.get(cscId);
92 int bx = *lctItr - nominalBX;
93 if (bx >= bxMin && bx <= bxMax) {
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")) {}
115 map<CSCDetId, CSCEventData>::iterator chamberMapItr = info.
theChamberDataMap.find(chamberId);
128 bool me11 = ((chamberId.
station() == 1) && (chamberId.
ring() == 4)) ||
129 ((chamberId.
station() == 1) && (chamberId.
ring() == 1));
150 if (!usePreTriggers || packEverything ||
153 bool me1a = (cscDetId.
station() == 1) && (cscDetId.
ring() == 4);
155 bool me1b = (cscDetId.
station() == 1) && (cscDetId.
ring() == 1);
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) {
168 if (me1b && !zplus) {
180 if (me1b && !zplus) {
188 cscData.
add(digi, cscDetId.
layer());
198 add(alctDigis, 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());
217 add(clctDigis, fedInfo);
218 for (
auto const&
j : comparatorDigis) {
223 bool me1a = (cscDetId.
station() == 1) && (cscDetId.
ring() == 4);
225 for (
auto digi =
j.second.first; digi !=
j.second.second; ++digi) {
229 if (me1a && digi->getStrip() <= 48) {
230 CSCComparatorDigi digi_corr(64 + digi->getStrip(), digi->getComparator(), digi->getTimeBinWord());
231 cscData.
add(digi_corr, cscDetId);
234 cscData.
add(*digi, cscDetId);
240 if (me1a && digi->getStrip() <= 16) {
241 CSCComparatorDigi digi_corr(64 + digi->getStrip(), digi->getComparator(), digi->getTimeBinWord());
242 cscData.
add(digi_corr, cscDetId.
layer());
244 cscData.
add(*digi, cscDetId.
layer());
257 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
266 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
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) {
286 cscData.
add(shiftedDigis);
288 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
298 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
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) {
310 iC->getStrip() + 128,
320 cscData.
add(shiftedDigis);
322 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
337 uint16_t format_version,
338 bool use_pre_triggers,
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);
354 if (fedInfo.formatVersion_ == 2005)
356 std::map<int, CSCDCCEventData> dccMap;
365 dccMap.insert(std::pair<int, CSCDCCEventData>(idcc,
CSCDCCEventData(idcc, nDDUs, bx, l1a)));
370 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
371 chamberItr != fedInfo.theChamberDataMap.end();
373 int indexDCC = mapping->
slink(chamberItr->first);
374 if (indexDCC == idcc) {
376 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
377 if (dccMapItr == dccMap.end()) {
378 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
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);
392 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin(); dccMapItr != dccMap.end(); ++dccMapItr) {
393 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
395 fedRawData.
resize(dccBits.size());
399 cscFEDTrailer.set(fedRawData.
data() + (fedRawData.
size() - 8),
400 fedRawData.
size() / 8,
406 }
else if (format_version == 2013)
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};
415 for (
unsigned int i = 0;
i < 36;
i++) {
416 unsigned int iddu = postLS1_map[
i];
418 CSCDDUHeader newDDUHeader(bx, l1a, iddu, ddu_fmt_version);
420 dduMap.insert(std::pair<int, CSCDDUEventData>(iddu,
CSCDDUEventData(newDDUHeader)));
424 for (
unsigned int i = 0;
i < 36;
i++) {
425 unsigned int iddu = postLS1_map[
i];
427 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
428 chamberItr != fedInfo.theChamberDataMap.end();
430 unsigned int indexDDU = mapping->
slink(chamberItr->first);
435 int dduID = mapping->
ddu(chamberItr->first);
444 if ((dduID <= 36) && (dduID > 0))
445 indexDDU = postLS1_map[dduID - 1];
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;
456 int dduInput = mapping->
dduInput(chamberItr->first);
457 int dmbId = mapping->
dmb(chamberItr->first);
459 dduMapItr->second.add(chamberItr->second, dmbId, dduInput, format_version);
465 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin(); dduMapItr != dduMap.end(); ++dduMapItr) {
466 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
468 fedRawData.
resize(dduBits.size() / 8);
472 cscFEDTrailer.set(fedRawData.
data() + (fedRawData.
size() - 8),
473 fedRawData.
size() / 8,
EventNumber_t event() const
bool accept(const CSCDetId &cscId, const CSCCLCTPreTriggerCollection &lcts, int bxMin, int bxMax, bool me1abCheck)
PixelRecoRange< float > Range
int ddu(const CSCDetId &) const
ddu id for given DetId
int dmb(const CSCDetId &) const
dmb id for given DetId
size_t size() const
Lenght of the data buffer in bytes.
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void setStrip(int istrip)
CSCEventData & findEventData(const CSCDetId &cscDetId, FindEventDataInfo &) const
pick out the correct data object for this chamber
void resize(size_t newsize)
int slink(const CSCDetId &) const
slink id for given DetId
const int preTriggerWindowMin_
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
const int preTriggerWindowMax_
int dduInput(const CSCDetId &) const
ddu input for given DetId
CSCDetId chamberId() const
CSCDetId chamberID(const CSCDetId &cscDetId)
takes layer ID, converts to chamber ID, switching ME1A to ME11
CSCDigiToRaw(const edm::ParameterSet &pset)
Constructor.
const uint16_t formatVersion_
unsigned short iChamberType() const
const CSCChamberMap * theElectronicsMap
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
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.
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
ChamberDataMap theChamberDataMap
int crate(const CSCDetId &) const
Interface required use in digi-to-raw.
std::pair< const_iterator, const_iterator > Range
std::vector< DigiType >::const_iterator const_iterator
int dduSlot(const CSCDetId &) const
ddu slot for given DetId
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers, FindEventDataInfo &, bool usePreTriggers, bool packEverything) const
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info