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")),
96 theFormatVersion(2005),
111 map<CSCDetId, CSCEventData>::iterator chamberMapItr =
theChamberDataMap.find(chamberId);
124 bool me11 = ((chamberId.
station()==1) && (chamberId.
ring()==4)) || ((chamberId.
station()==1) && (chamberId.
ring()==1));
152 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
154 bool me1b = (cscDetId.
station()==1) && (cscDetId.
ring()==1);
158 std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
159 std::vector<CSCStripDigi>::const_iterator
last = (*j).second.second;
160 for ( ; digiItr !=
last; ++digiItr)
197 cscData.
add(digi, cscDetId.
layer() );
214 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
215 std::vector<CSCWireDigi>::const_iterator
last = (*j).second.second;
216 for ( ; digiItr !=
last; ++digiItr)
218 cscData.
add(*digiItr, cscDetId.
layer() );
235 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
249 cscData.
add(digi_corr, cscDetId);
254 cscData.
add(digi, cscDetId);
267 cscData.
add(digi_corr, cscDetId.
layer());
271 cscData.
add(digi, cscDetId.
layer());
286 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
297 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
308 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
323 Event &
e, uint16_t format_version,
bool use_pre_triggers)
333 add(stripDigis, preTriggers);
334 add(wireDigis, alctDigis);
335 add(comparatorDigis, clctDigis);
336 add(correlatedLCTDigis);
344 std::map<int, CSCDCCEventData> dccMap;
355 dccMap.insert(std::pair<int, CSCDCCEventData>(idcc,
CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
363 for (map<CSCDetId, CSCEventData>::iterator chamberItr =
theChamberDataMap.begin();
366 int indexDCC = mapping->
slink(chamberItr->first);
367 if (indexDCC == idcc)
370 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
371 if (dccMapItr == dccMap.end())
373 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
377 int dduId = mapping->
ddu(chamberItr->first);
378 int dduSlot = mapping->
dduSlot(chamberItr->first);
379 int dduInput = mapping->
dduInput(chamberItr->first);
380 int dmbId = mapping->
dmb(chamberItr->first);
381 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId,
theFormatVersion);
387 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
388 dccMapItr != dccMap.end(); ++dccMapItr)
390 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
392 fedRawData.
resize(dccBits.size());
396 cscFEDTrailer.set(fedRawData.
data()+(fedRawData.
size()-8),
405 std::map<int, CSCDDUEventData> dduMap;
406 unsigned int ddu_fmt_version = 0x7;
407 const unsigned postLS1_map [] = { 841, 842, 843, 844, 845, 846, 847, 848, 849,
408 831, 832, 833, 834, 835, 836, 837, 838, 839,
409 861, 862, 863, 864, 865, 866, 867, 868, 869,
410 851, 852, 853, 854, 855, 856, 857, 858, 859 };
414 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) ) );
425 for (
unsigned int i = 0;
i < 36;
i++)
427 unsigned int iddu = postLS1_map[
i];
429 for (map<CSCDetId, CSCEventData>::iterator chamberItr =
theChamberDataMap.begin();
432 unsigned int indexDDU = mapping->
slink(chamberItr->first);
438 int dduID = mapping->
ddu(chamberItr->first);
447 if ((dduID <= 36) && (dduID > 0)) indexDDU = postLS1_map[dduID -1];
452 if (indexDDU == iddu)
454 std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
455 if (dduMapItr == dduMap.end())
457 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DDU number:" << indexDDU;
461 int dduInput = mapping->
dduInput(chamberItr->first);
462 int dmbId = mapping->
dmb(chamberItr->first);
464 dduMapItr->second.add( chamberItr->second, dmbId, dduInput,
theFormatVersion );
470 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin();
471 dduMapItr != dduMap.end(); ++dduMapItr)
473 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
475 fedRawData.
resize(dduBits.size()/8);
479 cscFEDTrailer.set(fedRawData.
data()+(fedRawData.
size()-8),
EventNumber_t event() const
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers)
uint16_t theFormatVersion
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
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info
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)
Take a vector of digis and fill the FEDRawDataCollection.