13 #include "boost/dynamic_bitset.hpp"
14 #include "boost/foreach.hpp"
34 if (chamberId.
ring() ==4)
41 template<
typename LCTCollection>
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)
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)
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")),
130 formatVersion_(2005),
131 usePreTriggers_(
true),
132 packEverything_(
false)
146 map<CSCDetId, CSCEventData>::iterator chamberMapItr =
theChamberDataMap.find(chamberId);
159 bool me11 = ((chamberId.
station()==1) && (chamberId.
ring()==4)) || ((chamberId.
station()==1) && (chamberId.
ring()==1));
188 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
190 bool me1b = (cscDetId.
station()==1) && (cscDetId.
ring()==1);
194 std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
195 std::vector<CSCStripDigi>::const_iterator
last = (*j).second.second;
196 for ( ; digiItr !=
last; ++digiItr)
233 cscData.
add(digi, cscDetId.
layer() );
251 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
252 std::vector<CSCWireDigi>::const_iterator
last = (*j).second.second;
253 for ( ; digiItr !=
last; ++digiItr)
255 cscData.
add(*digiItr, cscDetId.
layer() );
273 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
287 cscData.
add(digi_corr, cscDetId);
292 cscData.
add(digi, cscDetId);
305 cscData.
add(digi_corr, cscDetId.
layer());
309 cscData.
add(digi, cscDetId.
layer());
324 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
335 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
340 std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
341 for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
342 if (iC->getCFEB() >= 0 && iC->getCFEB() < 3){
343 (*iC) =
CSCCLCTDigi(iC->isValid(), iC->getQuality(), iC->getPattern(), iC->getStripType(),
344 iC->getBend(), iC->getStrip(), iC->getCFEB()+4, iC->getBX(),
345 iC->getTrknmb(), iC->getFullBX());
348 cscData.
add(shiftedDigis);
350 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
362 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
367 std::vector<CSCCorrelatedLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
368 for (std::vector<CSCCorrelatedLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
369 if (iC->getStrip() >= 0 && iC->getStrip() < 96){
371 iC->getKeyWG(), iC->getStrip() + 128, iC->getPattern(),
372 iC->getBend(), iC->getBX(), iC->getMPCLink(),
373 iC->getBX0(), iC->getSyncErr(), iC->getCSCID());
376 cscData.
add(shiftedDigis);
378 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
394 Event &
e, uint16_t format_version,
bool use_pre_triggers,
406 add(stripDigis, preTriggers);
407 add(wireDigis, alctDigis);
408 add(comparatorDigis, clctDigis);
409 add(correlatedLCTDigis);
417 std::map<int, CSCDCCEventData> dccMap;
428 dccMap.insert(std::pair<int, CSCDCCEventData>(idcc,
CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
436 for (map<CSCDetId, CSCEventData>::iterator chamberItr =
theChamberDataMap.begin();
439 int indexDCC = mapping->
slink(chamberItr->first);
440 if (indexDCC == idcc)
443 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
444 if (dccMapItr == dccMap.end())
446 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
450 int dduId = mapping->
ddu(chamberItr->first);
451 int dduSlot = mapping->
dduSlot(chamberItr->first);
452 int dduInput = mapping->
dduInput(chamberItr->first);
453 int dmbId = mapping->
dmb(chamberItr->first);
454 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId,
formatVersion_);
460 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
461 dccMapItr != dccMap.end(); ++dccMapItr)
463 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
465 fedRawData.
resize(dccBits.size());
469 cscFEDTrailer.set(fedRawData.
data()+(fedRawData.
size()-8),
478 std::map<int, CSCDDUEventData> dduMap;
479 unsigned int ddu_fmt_version = 0x7;
480 const unsigned postLS1_map [] = { 841, 842, 843, 844, 845, 846, 847, 848, 849,
481 831, 832, 833, 834, 835, 836, 837, 838, 839,
482 861, 862, 863, 864, 865, 866, 867, 868, 869,
483 851, 852, 853, 854, 855, 856, 857, 858, 859 };
487 for (
unsigned int i = 0;
i < 36;
i++)
489 unsigned int iddu = postLS1_map[
i];
491 CSCDDUHeader newDDUHeader(bx,l1a, iddu, ddu_fmt_version);
493 dduMap.insert(std::pair<int, CSCDDUEventData>(iddu,
CSCDDUEventData(newDDUHeader) ) );
498 for (
unsigned int i = 0;
i < 36;
i++)
500 unsigned int iddu = postLS1_map[
i];
502 for (map<CSCDetId, CSCEventData>::iterator chamberItr =
theChamberDataMap.begin();
505 unsigned int indexDDU = mapping->
slink(chamberItr->first);
511 int dduID = mapping->
ddu(chamberItr->first);
520 if ((dduID <= 36) && (dduID > 0)) indexDDU = postLS1_map[dduID -1];
525 if (indexDDU == iddu)
527 std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
528 if (dduMapItr == dduMap.end())
530 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DDU number:" << indexDDU;
534 int dduInput = mapping->
dduInput(chamberItr->first);
535 int dmbId = mapping->
dmb(chamberItr->first);
537 dduMapItr->second.add( chamberItr->second, dmbId, dduInput,
formatVersion_ );
543 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin();
544 dduMapItr != dduMap.end(); ++dduMapItr)
546 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
548 fedRawData.
resize(dduBits.size()/8);
552 cscFEDTrailer.set(fedRawData.
data()+(fedRawData.
size()-8),
EventNumber_t event() const
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
int getStrip() const
Get the strip number.
PixelRecoRange< float > Range
int ddu(const CSCDetId &) const
ddu id for given DetId
int dmb(const CSCDetId &) const
dmb id for given DetId
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
int getComparator() const
Get Comparator readings.
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)
const CSCChamberMap * theElectronicsMap
void resize(size_t newsize)
int slink(const CSCDetId &) const
slink id for given DetId
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
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.
int getTimeBinWord() const
Return the word with each bit corresponding to a time bin.
void beginEvent(const CSCChamberMap *electronicsMap)
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, bool me1abCheck=false)
unsigned short iChamberType()
std::map< CSCDetId, CSCEventData > theChamberDataMap
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
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
CSCEventData & findEventData(const CSCDetId &cscDetId)
pick out the correct data object for this chamber
void add(const CSCStripDigi &, int layer)
routines to add digis to the data
EcalElectronicsMapping const * electronicsMap(0)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
std::pair< const_iterator, const_iterator > Range
volatile std::atomic< bool > shutdown_flag 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)
Take a vector of digis and fill the FEDRawDataCollection.
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info