13 #include "boost/dynamic_bitset.hpp" 14 #include "boost/foreach.hpp" 34 if (chamberId.
ring() ==4)
41 template<
typename LCTCollection>
43 int bxMin,
int bxMax,
bool me1abCheck =
false)
45 if (bxMin == -999)
return true;
50 for (
typename LCTCollection::const_iterator lctItr = lctRange.first;
51 lctItr != lctRange.second; ++lctItr)
53 int bx = lctItr->getBX() - nominalBX;
54 if (bx >= bxMin && bx <= bxMax)
61 bool me1 = cscId.
station() == 1 && cscId.
ring() == 1;
64 if (me1 && result ==
false && me1abCheck){
66 lctRange = lcts.get(me1aId);
67 for (
typename LCTCollection::const_iterator lctItr = lctRange.first;
68 lctItr != lctRange.second; ++lctItr)
70 int bx = lctItr->getBX() - nominalBX;
71 if (bx >= bxMin && bx <= bxMax)
85 int bxMin,
int bxMax,
bool me1abCheck)
87 if (bxMin == -999)
return true;
93 lctItr != lctRange.second; ++lctItr)
95 int bx = *lctItr - nominalBX;
96 if (bx >= bxMin && bx <= bxMax)
102 bool me1a = cscId.
station() == 1 && cscId.
ring() == 4;
103 if (me1a && result ==
false && me1abCheck) {
105 lctRange = lcts.get(cscId);
107 lctItr != lctRange.second; ++lctItr)
109 int bx = *lctItr - nominalBX;
110 if (bx >= bxMin && bx <= bxMax)
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"))
136 map<CSCDetId, CSCEventData>::iterator chamberMapItr = info.
theChamberDataMap.find(chamberId);
149 bool me11 = ((chamberId.
station()==1) && (chamberId.
ring()==4)) || ((chamberId.
station()==1) && (chamberId.
ring()==1));
169 bool packEverything )
const 178 if (!usePreTriggers || packEverything ||
181 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
183 bool me1b = (cscDetId.
station()==1) && (cscDetId.
ring()==1);
187 std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
188 std::vector<CSCStripDigi>::const_iterator
last = (*j).second.second;
189 for ( ; digiItr !=
last; ++digiItr)
226 cscData.
add(digi, cscDetId.
layer() );
236 bool packEverything)
const 238 add(alctDigis, fedInfo);
246 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
247 std::vector<CSCWireDigi>::const_iterator
last = (*j).second.second;
248 for ( ; digiItr !=
last; ++digiItr)
250 cscData.
add(*digiItr, cscDetId.
layer() );
260 bool packEverything)
const 262 add(clctDigis,fedInfo);
270 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
284 cscData.
add(digi_corr, cscDetId);
289 cscData.
add(digi, cscDetId);
302 cscData.
add(digi_corr, cscDetId.
layer());
306 cscData.
add(digi, cscDetId.
layer());
322 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
334 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
339 std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
340 for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
341 if (iC->getCFEB() >= 0 && iC->getCFEB() < 3){
342 (*iC) =
CSCCLCTDigi(iC->isValid(), iC->getQuality(), iC->getPattern(), iC->getStripType(),
343 iC->getBend(), iC->getStrip(), iC->getCFEB()+4, iC->getBX(),
344 iC->getTrknmb(), iC->getFullBX());
347 cscData.
add(shiftedDigis);
349 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
361 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
366 std::vector<CSCCorrelatedLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
367 for (std::vector<CSCCorrelatedLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
368 if (iC->getStrip() >= 0 && iC->getStrip() < 96){
370 iC->getKeyWG(), iC->getStrip() + 128, iC->getPattern(),
371 iC->getBend(), iC->getBX(), iC->getMPCLink(),
372 iC->getBX0(), iC->getSyncErr(), iC->getCSCID());
375 cscData.
add(shiftedDigis);
377 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
393 Event &
e, uint16_t format_version,
bool use_pre_triggers,
394 bool packEverything)
const 402 add(stripDigis, preTriggers,fedInfo, use_pre_triggers, packEverything);
403 add(wireDigis, alctDigis,fedInfo, packEverything);
404 add(comparatorDigis, clctDigis,fedInfo, packEverything);
405 add(correlatedLCTDigis,fedInfo);
411 if (fedInfo.formatVersion_ == 2005)
413 std::map<int, CSCDCCEventData> dccMap;
424 dccMap.insert(std::pair<int, CSCDCCEventData>(idcc,
CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
432 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
433 chamberItr != fedInfo.theChamberDataMap.end(); ++chamberItr)
435 int indexDCC = mapping->
slink(chamberItr->first);
436 if (indexDCC == idcc)
439 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
440 if (dccMapItr == dccMap.end())
442 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
446 int dduId = mapping->
ddu(chamberItr->first);
447 int dduSlot = mapping->
dduSlot(chamberItr->first);
448 int dduInput = mapping->
dduInput(chamberItr->first);
449 int dmbId = mapping->
dmb(chamberItr->first);
450 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId, format_version);
456 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
457 dccMapItr != dccMap.end(); ++dccMapItr)
459 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
461 fedRawData.
resize(dccBits.size());
465 cscFEDTrailer.set(fedRawData.
data()+(fedRawData.
size()-8),
471 else if (format_version == 2013)
474 std::map<int, CSCDDUEventData> dduMap;
475 unsigned int ddu_fmt_version = 0x7;
476 const unsigned postLS1_map [] = { 841, 842, 843, 844, 845, 846, 847, 848, 849,
477 831, 832, 833, 834, 835, 836, 837, 838, 839,
478 861, 862, 863, 864, 865, 866, 867, 868, 869,
479 851, 852, 853, 854, 855, 856, 857, 858, 859 };
483 for (
unsigned int i = 0;
i < 36;
i++)
485 unsigned int iddu = postLS1_map[
i];
487 CSCDDUHeader newDDUHeader(bx,l1a, iddu, ddu_fmt_version);
489 dduMap.insert(std::pair<int, CSCDDUEventData>(iddu,
CSCDDUEventData(newDDUHeader) ) );
494 for (
unsigned int i = 0;
i < 36;
i++)
496 unsigned int iddu = postLS1_map[
i];
498 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
499 chamberItr != fedInfo.theChamberDataMap.end(); ++chamberItr)
501 unsigned int indexDDU = mapping->
slink(chamberItr->first);
507 int dduID = mapping->
ddu(chamberItr->first);
516 if ((dduID <= 36) && (dduID > 0)) indexDDU = postLS1_map[dduID -1];
521 if (indexDDU == iddu)
523 std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
524 if (dduMapItr == dduMap.end())
526 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DDU number:" << indexDDU;
530 int dduInput = mapping->
dduInput(chamberItr->first);
531 int dmbId = mapping->
dmb(chamberItr->first);
533 dduMapItr->second.add( chamberItr->second, dmbId, dduInput, format_version );
539 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin();
540 dduMapItr != dduMap.end(); ++dduMapItr)
542 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
544 fedRawData.
resize(dduBits.size()/8);
548 cscFEDTrailer.set(fedRawData.
data()+(fedRawData.
size()-8),
EventNumber_t event() const
int getStrip() const
Get the strip number. Counts from 1.
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
int getComparator() const
Get Comparator readings. Can be 0 or 1.
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_
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
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