15 #include "boost/dynamic_bitset.hpp"
16 #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"))
109 map<CSCDetId, CSCEventData>::iterator chamberMapItr =
theChamberDataMap.find(chamberId);
132 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
134 bool me1b = (cscDetId.
station()==1) && (cscDetId.
ring()==1);
138 std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
139 std::vector<CSCStripDigi>::const_iterator
last = (*j).second.second;
140 for( ; digiItr !=
last; ++digiItr)
144 if ( me1a && zplus ) { digi.
setStrip(17-strip); }
145 if ( me1b && !zplus) { digi.
setStrip(65-strip);}
147 cscData.
add(digi, cscDetId.
layer() );
164 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
165 std::vector<CSCWireDigi>::const_iterator
last = (*j).second.second;
166 for( ; digiItr !=
last; ++digiItr)
168 cscData.
add(*digiItr, cscDetId.
layer() );
185 bool me1a = (cscDetId.
station()==1) && (cscDetId.
ring()==4);
191 if (me1a && digi.
getStrip() <= 16) {
195 cscData.
add(digi_corr, cscDetId.
layer());
198 cscData.
add(digi, cscDetId.
layer());
212 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
223 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
234 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
257 add(stripDigis, preTriggers);
258 add(wireDigis, alctDigis);
259 add(comparatorDigis, clctDigis);
260 add(correlatedLCTDigis);
266 std::map<int, CSCDCCEventData> dccMap;
277 dccMap.insert(std::pair<int, CSCDCCEventData>(idcc,
CSCDCCEventData(idcc, nDDUs, bx, l1a) ) );
280 for(map<CSCDetId, CSCEventData>::iterator chamberItr =
theChamberDataMap.begin();
284 int indexDCC = mapping->
slink(chamberItr->first);
288 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
289 if(dccMapItr == dccMap.end())
291 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
295 int dduId = mapping->
ddu(chamberItr->first);
296 int dduSlot = mapping->
dduSlot(chamberItr->first);
297 int dduInput = mapping->
dduInput(chamberItr->first);
298 int dmbId = mapping->
dmb(chamberItr->first);
299 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId);
305 for(std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin();
306 dccMapItr != dccMap.end(); ++dccMapItr)
308 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
310 fedRawData.
resize(dccBits.size());
314 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.
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)
Take a vector of digis and fill the FEDRawDataCollection.
const EcalElectronicsMapping * electronicsMap
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< DigiType >::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
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