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));
286 for (
const auto& shower : cscShowerDigis) {
287 const CSCDetId& cscDetId = shower.first;
290 switch (showerType) {
291 case CSCShowerType::lctShower:
292 cscData.
addShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
294 case CSCShowerType::anodeShower:
295 cscData.
addAnodeShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
297 case CSCShowerType::cathodeShower:
298 cscData.
addCathodeShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
300 case CSCShowerType::anodeALCTShower:
301 cscData.
addAnodeALCTShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
304 cscData.
addShower(std::vector<CSCShowerDigi>(shower.second.first, shower.second.second));
310 for (
const auto& jclus : gemPadClusters) {
311 const GEMDetId& gemDetId = jclus.first;
313 const int zendcap = gemDetId.
region() == 1 ? 1 : 2;
317 cscData.add(std::vector<GEMPadDigiCluster>(jclus.second.first, jclus.second.second), gemDetId);
341 add(stripDigis, preTriggers, preTriggerDigis, fedInfo);
342 add(wireDigis, alctDigis, fedInfo);
343 add(comparatorDigis, clctDigis, fedInfo);
344 add(correlatedLCTDigis, fedInfo);
351 if (cscShowerDigis) {
352 add(*cscShowerDigis, fedInfo, CSCShowerType::lctShower);
353 add(*anodeShowerDigis, fedInfo, CSCShowerType::anodeShower);
354 add(*cathodeShowerDigis, fedInfo, CSCShowerType::cathodeShower);
355 add(*anodeALCTShowerDigis, fedInfo, CSCShowerType::anodeALCTShower);
359 if (gemPadDigiClusters) {
360 add(*gemPadDigiClusters, fedInfo);
362 int l1a = eid.
event();
365 if (fedInfo.formatVersion_ == 2005)
367 std::map<int, CSCDCCEventData> dccMap;
375 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
376 chamberItr != fedInfo.theChamberDataMap.end();
378 int indexDCC = mapping->
slink(chamberItr->first);
379 if (indexDCC == idcc) {
381 std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC);
382 if (dccMapItr == dccMap.end()) {
383 throw cms::Exception(
"CSCDigiToRaw") <<
"Bad DCC number:" << indexDCC;
387 int dduId = mapping->
ddu(chamberItr->first);
388 int dduSlot = mapping->
dduSlot(chamberItr->first);
389 int dduInput = mapping->
dduInput(chamberItr->first);
390 int dmbId = mapping->
dmb(chamberItr->first);
391 dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId,
formatVersion_);
397 for (std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin(); dccMapItr != dccMap.end(); ++dccMapItr) {
398 boost::dynamic_bitset<> dccBits = dccMapItr->second.pack();
400 fedRawData.
resize(dccBits.size());
404 cscFEDTrailer.set(fedRawData.
data() + (fedRawData.
size() - 8),
405 fedRawData.
size() / 8,
413 std::map<int, CSCDDUEventData> dduMap;
414 unsigned int ddu_fmt_version = 0x7;
415 const unsigned postLS1_map[] = {841, 842, 843, 844, 845, 846, 847, 848, 849, 831, 832, 833,
416 834, 835, 836, 837, 838, 839, 861, 862, 863, 864, 865, 866,
417 867, 868, 869, 851, 852, 853, 854, 855, 856, 857, 858, 859};
420 for (
unsigned int i = 0;
i < 36;
i++) {
421 unsigned int iddu = postLS1_map[
i];
423 CSCDDUHeader newDDUHeader(bx, l1a, iddu, ddu_fmt_version);
425 dduMap.insert(std::pair<int, CSCDDUEventData>(iddu,
CSCDDUEventData(newDDUHeader)));
429 for (
unsigned int i = 0;
i < 36;
i++) {
430 unsigned int iddu = postLS1_map[
i];
432 for (map<CSCDetId, CSCEventData>::iterator chamberItr = fedInfo.theChamberDataMap.begin();
433 chamberItr != fedInfo.theChamberDataMap.end();
435 unsigned int indexDDU = mapping->
slink(chamberItr->first);
440 int dduID = mapping->
ddu(chamberItr->first);
449 if ((dduID <= 36) && (dduID > 0))
450 indexDDU = postLS1_map[dduID - 1];
454 if (indexDDU == iddu) {
455 std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.find(indexDDU);
456 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,
formatVersion_);
470 for (std::map<int, CSCDDUEventData>::iterator dduMapItr = dduMap.begin(); dduMapItr != dduMap.end(); ++dduMapItr) {
471 boost::dynamic_bitset<> dduBits = dduMapItr->second.pack();
473 fedRawData.
resize(dduBits.size() / 8);
477 cscFEDTrailer.set(fedRawData.
data() + (fedRawData.
size() - 8),
478 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)
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.
void addAnodeShower(const std::vector< CSCShowerDigi > &)
Add/pack anode CSCShower object (from OTMB header)
void addAnodeALCTShower(const std::vector< CSCShowerDigi > &)
Add/pack anode CSCShower objects (from ALCT board data)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void addShower(const std::vector< CSCShowerDigi > &)
Run3 CSC Shower HMT objects.
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)
CSCShowerType
CSC Shower HMT bits types.
CSCDigiToRaw(const edm::ParameterSet &pset)
Constructor.
const uint16_t formatVersion_
unsigned short iChamberType() const
const CSCChamberMap * theElectronicsMap
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 CSCShowerDigiCollection *anodeShowerDigis, const CSCShowerDigiCollection *cathodeShowerDigis, const CSCShowerDigiCollection *anodeALCTShowerDigis, const GEMPadDigiClusterCollection *padDigiClusters, FEDRawDataCollection &fed_buffers, const CSCChamberMap *theMapping, const edm::EventID &eid) const
Take a vector of digis and fill the FEDRawDataCollection.
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.
void addCathodeShower(const std::vector< CSCShowerDigi > &)
Add/pack cathode CSCShower object (from OTMB header)
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...