13 #include "boost/dynamic_bitset.hpp" 33 if (chamberId.
ring() ==4)
40 template<
typename LCTCollection>
42 int bxMin,
int bxMax,
bool me1abCheck =
false)
44 if (bxMin == -999)
return true;
49 for (
typename LCTCollection::const_iterator lctItr = lctRange.first;
50 lctItr != lctRange.second; ++lctItr)
52 int bx = lctItr->getBX() - nominalBX;
53 if (bx >= bxMin && bx <= bxMax)
60 bool me1 = cscId.
station() == 1 && cscId.
ring() == 1;
63 if (me1 && result ==
false && me1abCheck){
65 lctRange = lcts.get(me1aId);
66 for (
typename LCTCollection::const_iterator lctItr = lctRange.first;
67 lctItr != lctRange.second; ++lctItr)
69 int bx = lctItr->getBX() - nominalBX;
70 if (bx >= bxMin && bx <= bxMax)
84 int bxMin,
int bxMax,
bool me1abCheck)
86 if (bxMin == -999)
return true;
92 lctItr != lctRange.second; ++lctItr)
94 int bx = *lctItr - nominalBX;
95 if (bx >= bxMin && bx <= bxMax)
101 bool me1a = cscId.
station() == 1 && cscId.
ring() == 4;
102 if (me1a && result ==
false && me1abCheck) {
104 lctRange = lcts.get(cscId);
106 lctItr != lctRange.second; ++lctItr)
108 int bx = *lctItr - nominalBX;
109 if (bx >= bxMin && bx <= bxMax)
123 : alctWindowMin_(pset.getParameter<
int>(
"alctWindowMin")),
124 alctWindowMax_(pset.getParameter<
int>(
"alctWindowMax")),
125 clctWindowMin_(pset.getParameter<
int>(
"clctWindowMin")),
126 clctWindowMax_(pset.getParameter<
int>(
"clctWindowMax")),
127 preTriggerWindowMin_(pset.getParameter<
int>(
"preTriggerWindowMin")),
128 preTriggerWindowMax_(pset.getParameter<
int>(
"preTriggerWindowMax"))
135 map<CSCDetId, CSCEventData>::iterator chamberMapItr = info.
theChamberDataMap.find(chamberId);
148 bool me11 = ((chamberId.
station()==1) && (chamberId.
ring()==4)) || ((chamberId.
station()==1) && (chamberId.
ring()==1));
168 bool packEverything )
const 177 if (!usePreTriggers || packEverything ||
180 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
182 bool me1b = (cscDetId.
station()==1) && (cscDetId.
ring()==1);
186 std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
187 std::vector<CSCStripDigi>::const_iterator
last = (*j).second.second;
188 for ( ; digiItr !=
last; ++digiItr)
225 cscData.
add(digi, cscDetId.
layer() );
235 bool packEverything)
const 237 add(alctDigis, fedInfo);
245 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
246 std::vector<CSCWireDigi>::const_iterator
last = (*j).second.second;
247 for ( ; digiItr !=
last; ++digiItr)
249 cscData.
add(*digiItr, cscDetId.
layer() );
259 bool packEverything)
const 261 add(clctDigis,fedInfo);
262 for (
auto const& j : comparatorDigis)
269 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
272 for(
auto digi = j.second.first; digi != j.second.second; ++digi)
278 if (me1a && digi->getStrip() <= 48)
281 digi->getComparator(),
282 digi->getTimeBinWord());
283 cscData.
add(digi_corr, cscDetId);
288 cscData.
add(*digi, cscDetId);
296 if (me1a && digi->getStrip() <= 16)
299 digi->getComparator(),
300 digi->getTimeBinWord());
301 cscData.
add(digi_corr, cscDetId.
layer());
305 cscData.
add(*digi, cscDetId.
layer());
321 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
333 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
338 std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
339 for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
340 if (iC->getCFEB() >= 0 && iC->getCFEB() < 3){
341 (*iC) =
CSCCLCTDigi(iC->isValid(), iC->getQuality(), iC->getPattern(), iC->getStripType(),
342 iC->getBend(), iC->getStrip(), iC->getCFEB()+4, iC->getBX(),
343 iC->getTrknmb(), iC->getFullBX());
346 cscData.
add(shiftedDigis);
348 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
360 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
365 std::vector<CSCCorrelatedLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
366 for (std::vector<CSCCorrelatedLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
367 if (iC->getStrip() >= 0 && iC->getStrip() < 96){
369 iC->getKeyWG(), iC->getStrip() + 128, iC->getPattern(),
370 iC->getBend(), iC->getBX(), iC->getMPCLink(),
371 iC->getBX0(), iC->getSyncErr(), iC->getCSCID());
374 cscData.
add(shiftedDigis);
376 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
392 Event &
e, uint16_t format_version,
bool use_pre_triggers,
393 bool packEverything)
const 401 add(stripDigis, preTriggers,fedInfo, use_pre_triggers, packEverything);
402 add(wireDigis, alctDigis,fedInfo, packEverything);
403 add(comparatorDigis, clctDigis,fedInfo, packEverything);
404 add(correlatedLCTDigis,fedInfo);
410 if (fedInfo.formatVersion_ == 2005)
412 std::map<int, CSCDCCEventData> dccMap;
423 dccMap.insert(std::pair<int, CSCDCCEventData>(idcc,
CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
431 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
432 chamberItr != fedInfo.theChamberDataMap.end(); ++chamberItr)
434 int indexDCC = mapping->
slink(chamberItr->first);
435 if (indexDCC == idcc)
438 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
439 if (dccMapItr == dccMap.end())
441 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
445 int dduId = mapping->
ddu(chamberItr->first);
446 int dduSlot = mapping->
dduSlot(chamberItr->first);
447 int dduInput = mapping->
dduInput(chamberItr->first);
448 int dmbId = mapping->
dmb(chamberItr->first);
449 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId, format_version);
455 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
456 dccMapItr != dccMap.end(); ++dccMapItr)
458 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
460 fedRawData.
resize(dccBits.size());
464 cscFEDTrailer.set(fedRawData.
data()+(fedRawData.
size()-8),
470 else if (format_version == 2013)
473 std::map<int, CSCDDUEventData> dduMap;
474 unsigned int ddu_fmt_version = 0x7;
475 const unsigned postLS1_map [] = { 841, 842, 843, 844, 845, 846, 847, 848, 849,
476 831, 832, 833, 834, 835, 836, 837, 838, 839,
477 861, 862, 863, 864, 865, 866, 867, 868, 869,
478 851, 852, 853, 854, 855, 856, 857, 858, 859 };
482 for (
unsigned int i = 0;
i < 36;
i++)
484 unsigned int iddu = postLS1_map[
i];
486 CSCDDUHeader newDDUHeader(bx,l1a, iddu, ddu_fmt_version);
488 dduMap.insert(std::pair<int, CSCDDUEventData>(iddu,
CSCDDUEventData(newDDUHeader) ) );
493 for (
unsigned int i = 0;
i < 36;
i++)
495 unsigned int iddu = postLS1_map[
i];
497 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
498 chamberItr != fedInfo.theChamberDataMap.end(); ++chamberItr)
500 unsigned int indexDDU = mapping->
slink(chamberItr->first);
506 int dduID = mapping->
ddu(chamberItr->first);
515 if ((dduID <= 36) && (dduID > 0)) indexDDU = postLS1_map[dduID -1];
520 if (indexDDU == iddu)
522 std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
523 if (dduMapItr == dduMap.end())
525 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DDU number:" << indexDDU;
529 int dduInput = mapping->
dduInput(chamberItr->first);
530 int dmbId = mapping->
dmb(chamberItr->first);
532 dduMapItr->second.add( chamberItr->second, dmbId, dduInput, format_version );
538 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin();
539 dduMapItr != dduMap.end(); ++dduMapItr)
541 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
543 fedRawData.
resize(dduBits.size()/8);
547 cscFEDTrailer.set(fedRawData.
data()+(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::vector< CSCCLCTPreTrigger >::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.
std::pair< const_iterator, const_iterator > Range
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