15 #include "boost/dynamic_bitset.hpp"
30 : alctWindowMin_(pset.getParameter<int>(
"alctWindowMin")),
31 alctWindowMax_(pset.getParameter<int>(
"alctWindowMax")),
32 clctWindowMin_(pset.getParameter<int>(
"clctWindowMin")),
33 clctWindowMax_(pset.getParameter<int>(
"clctWindowMax")),
34 preTriggerWindowMin_(pset.getParameter<int>(
"preTriggerWindowMin")),
35 preTriggerWindowMax_(pset.getParameter<int>(
"preTriggerWindowMax")),
37 formatVersion_(pset.getParameter<unsigned>(
"formatVersion")),
40 packEverything_(pset.getParameter<bool>(
"packEverything")),
41 usePreTriggers_(pset.getParameter<bool>(
"usePreTriggers")),
42 packByCFEB_(pset.getParameter<bool>(
"packByCFEB")) {}
47 map<CSCDetId, CSCEventData>::iterator chamberMapItr = info.
theChamberDataMap.find(chamberId);
60 bool me11 = ((chamberId.
station() == 1) && (chamberId.
ring() == 4)) ||
61 ((chamberId.
station() == 1) && (chamberId.
ring() == 1));
81 std::vector<bool> preTriggerInCFEB;
93 bool me1a = (cscDetId.
station() == 1) && (cscDetId.
ring() == 4);
95 bool me1b = (cscDetId.
station() == 1) && (cscDetId.
ring() == 1);
99 std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first;
100 std::vector<CSCStripDigi>::const_iterator
last = (*j).second.second;
101 for (; digiItr !=
last; ++digiItr) {
120 if (me1b && !zplus) {
133 if (me1b && !zplus) {
141 cscData.
add(digi, cscDetId.
layer());
150 add(alctDigis, fedInfo);
156 std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first;
157 std::vector<CSCWireDigi>::const_iterator
last = (*j).second.second;
158 for (; digiItr !=
last; ++digiItr) {
159 cscData.
add(*digiItr, cscDetId.
layer());
168 add(clctDigis, fedInfo);
169 for (
auto const&
j : comparatorDigis) {
174 bool me1a = (cscDetId.
station() == 1) && (cscDetId.
ring() == 4);
182 for (
auto digi =
j.second.first; digi !=
j.second.second; ++digi) {
188 cscData.
add(digi_corr, cscDetId);
190 cscData.
add(*digi, cscDetId);
198 cscData.
add(digi_corr, cscDetId.
layer());
200 cscData.
add(*digi, cscDetId.
layer());
213 cscData.
add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second));
222 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
227 std::vector<CSCCLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
228 for (std::vector<CSCCLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
242 cscData.
add(shiftedDigis);
244 cscData.
add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second));
254 bool me11a = cscDetId.
station() == 1 && cscDetId.
ring() == 4;
259 std::vector<CSCCorrelatedLCTDigi> shiftedDigis((*j).second.first, (*j).second.second);
260 for (std::vector<CSCCorrelatedLCTDigi>::iterator iC = shiftedDigis.begin(); iC != shiftedDigis.end(); ++iC) {
276 cscData.
add(shiftedDigis);
278 cscData.
add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second));
284 for (
const auto& shower : cscShowerDigis) {
285 const CSCDetId& cscDetId = shower.first;
288 cscData.
add(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
293 for (
const auto& jclus : gemPadClusters) {
294 const GEMDetId& gemDetId = jclus.first;
296 const int zendcap = gemDetId.
region() == 1 ? 1 : 2;
300 cscData.add(std::vector<GEMPadDigiCluster>(jclus.second.first, jclus.second.second), gemDetId);
320 add(stripDigis, preTriggers, preTriggerDigis, fedInfo);
321 add(wireDigis, alctDigis, fedInfo);
322 add(comparatorDigis, clctDigis, fedInfo);
323 add(correlatedLCTDigis, fedInfo);
326 if (cscShowerDigis) {
327 add(*cscShowerDigis, fedInfo);
331 if (gemPadDigiClusters) {
332 add(*gemPadDigiClusters, fedInfo);
334 int l1a = eid.
event();
337 if (fedInfo.formatVersion_ == 2005)
339 std::map<int, CSCDCCEventData> dccMap;
347 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
348 chamberItr != fedInfo.theChamberDataMap.end();
350 int indexDCC = mapping->
slink(chamberItr->first);
351 if (indexDCC == idcc) {
353 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
354 if (dccMapItr == dccMap.end()) {
355 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
359 int dduId = mapping->
ddu(chamberItr->first);
360 int dduSlot = mapping->
dduSlot(chamberItr->first);
361 int dduInput = mapping->
dduInput(chamberItr->first);
362 int dmbId = mapping->
dmb(chamberItr->first);
363 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId,
formatVersion_);
369 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin(); dccMapItr != dccMap.end(); ++dccMapItr) {
370 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
372 fedRawData.
resize(dccBits.size());
376 cscFEDTrailer.set(fedRawData.
data() + (fedRawData.
size() - 8),
377 fedRawData.
size() / 8,
385 std::map<int, CSCDDUEventData> dduMap;
386 unsigned int ddu_fmt_version = 0x7;
387 const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
388 834, 835, 836, 837, 838, 839, 861, 862, 863, 864, 865, 866,
389 867, 868, 869, 851, 852, 853, 854, 855, 856, 857, 858, 859};
392 for (
unsigned int i = 0;
i < 36;
i++) {
393 unsigned int iddu = postLS1_map[
i];
395 CSCDDUHeader newDDUHeader(bx, l1a, iddu, ddu_fmt_version);
397 dduMap.insert(std::pair<int, CSCDDUEventData>(iddu,
CSCDDUEventData(newDDUHeader)));
401 for (
unsigned int i = 0;
i < 36;
i++) {
402 unsigned int iddu = postLS1_map[
i];
404 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
405 chamberItr != fedInfo.theChamberDataMap.end();
407 unsigned int indexDDU = mapping->
slink(chamberItr->first);
412 int dduID = mapping->
ddu(chamberItr->first);
421 if ((dduID <= 36) && (dduID > 0))
422 indexDDU = postLS1_map[dduID - 1];
426 if (indexDDU == iddu) {
427 std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
428 if (dduMapItr == dduMap.end()) {
429 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DDU number:" << indexDDU;
433 int dduInput = mapping->
dduInput(chamberItr->first);
434 int dmbId = mapping->
dmb(chamberItr->first);
436 dduMapItr->second.add(chamberItr->second, dmbId, dduInput,
formatVersion_);
442 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin(); dduMapItr != dduMap.end(); ++dduMapItr) {
443 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
445 fedRawData.
resize(dduBits.size() / 8);
449 cscFEDTrailer.set(fedRawData.
data() + (fedRawData.
size() - 8),
450 fedRawData.
size() / 8,
EventNumber_t event() const
int getCFEB() const
Get the CFEB number. Counts from 0.
bool accept(const CSCDetId &cscId, const LCTCollection &lcts, int bxMin, int bxMax, int nominalBX)
void createFedBuffers(const CSCStripDigiCollection &stripDigis, const CSCWireDigiCollection &wireDigis, const CSCComparatorDigiCollection &comparatorDigis, const CSCALCTDigiCollection &alctDigis, const CSCCLCTDigiCollection &clctDigis, const CSCCLCTPreTriggerCollection *preTriggers, const CSCCLCTPreTriggerDigiCollection *preTriggerDigis, const CSCCorrelatedLCTDigiCollection &correlatedLCTDigis, const CSCShowerDigiCollection *showerDigis, const GEMPadDigiClusterCollection *padDigiClusters, FEDRawDataCollection &fed_buffers, const CSCChamberMap *theMapping, const edm::EventID &eid) const
Take a vector of digis and fill the FEDRawDataCollection.
int ddu(const CSCDetId &) const
ddu id for given DetId
int dmb(const CSCDetId &) const
dmb id for given DetId
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_
constexpr int region() const
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 &cscDetId)
CSCDigiToRaw(const edm::ParameterSet &pset)
Constructor.
const uint16_t formatVersion_
unsigned short iChamberType() const
const CSCChamberMap * theElectronicsMap
constexpr int chamber() const
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
ChamberDataMap theChamberDataMap
void add(const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection *preTriggers, const CSCCLCTPreTriggerDigiCollection *preTriggerDigis, FindEventDataInfo &) const
int crate(const CSCDetId &) const
Interface required use in digi-to-raw.
constexpr int station() const
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.
const CSCDMBHeader * dmbHeader() const
the DAQ motherboard header. A good place for event and chamber info
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...