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)
68 if (bxMin == -999)
return true;
74 lctItr != lctRange.second; ++lctItr)
76 int bx = *lctItr - nominalBX;
77 if (bx >= bxMin && bx <= bxMax)
90 : alctWindowMin_(pset.getParameter<int>(
"alctWindowMin")),
91 alctWindowMax_(pset.getParameter<int>(
"alctWindowMax")),
92 clctWindowMin_(pset.getParameter<int>(
"clctWindowMin")),
93 clctWindowMax_(pset.getParameter<int>(
"clctWindowMax")),
94 preTriggerWindowMin_(pset.getParameter<int>(
"preTriggerWindowMin")),
95 preTriggerWindowMax_(pset.getParameter<int>(
"preTriggerWindowMax")),
97 usePreTriggers_(
true),
98 packEverything_(
false)
112 map<CSCDetId, CSCEventData>::iterator chamberMapItr =
theChamberDataMap.find(chamberId);
125 bool me11 = ((chamberId.
station()==1) && (chamberId.
ring()==4)) || ((chamberId.
station()==1) && (chamberId.
ring()==1));
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)
198 cscData.
add(digi, cscDetId.
layer() );
215 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
216 std::vector<CSCWireDigi>::const_iterator
last = (*j).second.second;
217 for ( ; digiItr !=
last; ++digiItr)
219 cscData.
add(*digiItr, cscDetId.
layer() );
236 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
250 cscData.
add(digi_corr, cscDetId);
255 cscData.
add(digi, cscDetId);
268 cscData.
add(digi_corr, cscDetId.
layer());
272 cscData.
add(digi, cscDetId.
layer());
287 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
298 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
309 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
324 Event &
e, uint16_t format_version,
bool use_pre_triggers,
336 add(stripDigis, preTriggers);
337 add(wireDigis, alctDigis);
338 add(comparatorDigis, clctDigis);
339 add(correlatedLCTDigis);
347 std::map<int, CSCDCCEventData> dccMap;
358 dccMap.insert(std::pair<int, CSCDCCEventData>(idcc,
CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
366 for (map<CSCDetId, CSCEventData>::iterator chamberItr =
theChamberDataMap.begin();
369 int indexDCC = mapping->
slink(chamberItr->first);
370 if (indexDCC == idcc)
373 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
374 if (dccMapItr == dccMap.end())
376 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
380 int dduId = mapping->
ddu(chamberItr->first);
381 int dduSlot = mapping->
dduSlot(chamberItr->first);
382 int dduInput = mapping->
dduInput(chamberItr->first);
383 int dmbId = mapping->
dmb(chamberItr->first);
384 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId,
formatVersion_);
390 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
391 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),
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,
411 831, 832, 833, 834, 835, 836, 837, 838, 839,
412 861, 862, 863, 864, 865, 866, 867, 868, 869,
413 851, 852, 853, 854, 855, 856, 857, 858, 859 };
417 for (
unsigned int i = 0;
i < 36;
i++)
419 unsigned int iddu = postLS1_map[
i];
421 CSCDDUHeader newDDUHeader(bx,l1a, iddu, ddu_fmt_version);
423 dduMap.insert(std::pair<int, CSCDDUEventData>(iddu,
CSCDDUEventData(newDDUHeader) ) );
428 for (
unsigned int i = 0;
i < 36;
i++)
430 unsigned int iddu = postLS1_map[
i];
432 for (map<CSCDetId, CSCEventData>::iterator chamberItr =
theChamberDataMap.begin();
435 unsigned int indexDDU = mapping->
slink(chamberItr->first);
441 int dduID = mapping->
ddu(chamberItr->first);
450 if ((dduID <= 36) && (dduID > 0)) indexDDU = postLS1_map[dduID -1];
455 if (indexDDU == iddu)
457 std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
458 if (dduMapItr == dduMap.end())
460 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DDU number:" << indexDDU;
464 int dduInput = mapping->
dduInput(chamberItr->first);
465 int dmbId = mapping->
dmb(chamberItr->first);
467 dduMapItr->second.add( chamberItr->second, dmbId, dduInput,
formatVersion_ );
473 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin();
474 dduMapItr != dduMap.end(); ++dduMapItr)
476 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
478 fedRawData.
resize(dduBits.size()/8);
482 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.
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)
unsigned short iChamberType()
PixelRecoRange< float > Range
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)
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax)
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