#include <CSCDigiToRaw.h>
Public Member Functions | |
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. | |
CSCDigiToRaw (const edm::ParameterSet &pset) | |
Constructor. | |
Private Member Functions | |
void | add (const CSCStripDigiCollection &stripDigis, const CSCCLCTPreTriggerCollection &preTriggers) |
void | add (const CSCComparatorDigiCollection &comparatorDigis, const CSCCLCTDigiCollection &clctDigis) |
void | add (const CSCALCTDigiCollection &alctDigis) |
void | add (const CSCCorrelatedLCTDigiCollection &corrLCTDigis) |
void | add (const CSCCLCTDigiCollection &clctDigis) |
void | add (const CSCWireDigiCollection &wireDigis) |
void | beginEvent (const CSCChamberMap *electronicsMap) |
CSCDetId | chamberID (const CSCDetId &cscDetId) const |
takes layer ID, converts to chamber ID, switching ME1A to ME11 | |
CSCEventData & | findEventData (const CSCDetId &cscDetId) |
pick out the correct data object for this chamber | |
Private Attributes | |
bool | requireCLCTForComparators_ |
bool | requirePreTrigger_ |
std::map< CSCDetId, CSCEventData > | theChamberDataMap |
const CSCChamberMap * | theElectronicsMap |
CSCDigiToRaw::CSCDigiToRaw | ( | const edm::ParameterSet & | pset | ) | [explicit] |
Constructor.
Definition at line 30 of file CSCDigiToRaw.cc.
: requirePreTrigger_(pset.getParameter<bool>("requirePreTrigger")), requireCLCTForComparators_(pset.getParameter<bool>("requireCLCTForComparators")) {}
void CSCDigiToRaw::add | ( | const CSCStripDigiCollection & | stripDigis, |
const CSCCLCTPreTriggerCollection & | preTriggers | ||
) | [private] |
Definition at line 62 of file CSCDigiToRaw.cc.
References CSCEventData::add(), chamberID(), CSCDetId::endcap(), findEventData(), CSCStripDigi::getStrip(), j, prof2calltree::last, CSCDetId::layer(), requirePreTrigger_, CSCDetId::ring(), CSCStripDigi::setStrip(), CSCDetId::station(), strip(), and SurfaceOrientation::zplus.
Referenced by createFedBuffers().
{ //iterate over chambers with strip digis in them for (CSCStripDigiCollection::DigiRangeIterator j=stripDigis.begin(); j!=stripDigis.end(); ++j) { CSCDetId cscDetId=(*j).first; CSCDetId chamberId = chamberID(cscDetId); // only digitize if there are pre-triggers CSCCLCTPreTriggerCollection::Range preTriggerRange = preTriggers.get(chamberId); if(!requirePreTrigger_ || preTriggerRange.first != preTriggerRange.second) { bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4); bool zplus = (cscDetId.endcap() == 1); bool me1b = (cscDetId.station()==1) && (cscDetId.ring()==1); CSCEventData & cscData = findEventData(cscDetId); std::vector<CSCStripDigi>::const_iterator digiItr = (*j).second.first; std::vector<CSCStripDigi>::const_iterator last = (*j).second.second; for( ; digiItr != last; ++digiItr) { CSCStripDigi digi = *digiItr; int strip = digi.getStrip(); if ( me1a && zplus ) { digi.setStrip(17-strip); } // 1-16 -> 16-1 if ( me1b && !zplus) { digi.setStrip(65-strip);} // 1-64 -> 64-1 if ( me1a ) { strip = digi.getStrip(); digi.setStrip(strip+64);} // reset back 1-16 to 65-80 digi cscData.add(digi, cscDetId.layer() ); } } } }
void CSCDigiToRaw::add | ( | const CSCWireDigiCollection & | wireDigis | ) | [private] |
Definition at line 96 of file CSCDigiToRaw.cc.
References CSCEventData::add(), findEventData(), j, prof2calltree::last, and CSCDetId::layer().
{ for (CSCWireDigiCollection::DigiRangeIterator j=wireDigis.begin(); j!=wireDigis.end(); ++j) { CSCDetId cscDetId=(*j).first; CSCEventData & cscData = findEventData(cscDetId); std::vector<CSCWireDigi>::const_iterator digiItr = (*j).second.first; std::vector<CSCWireDigi>::const_iterator last = (*j).second.second; for( ; digiItr != last; ++digiItr) { cscData.add(*digiItr, cscDetId.layer() ); } } }
void CSCDigiToRaw::add | ( | const CSCCorrelatedLCTDigiCollection & | corrLCTDigis | ) | [private] |
Definition at line 167 of file CSCDigiToRaw.cc.
References CSCEventData::add(), findEventData(), and j.
{ for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator j=corrLCTDigis.begin(); j!=corrLCTDigis.end(); ++j) { CSCDetId cscDetId=(*j).first; CSCEventData & cscData = findEventData(cscDetId); cscData.add(std::vector<CSCCorrelatedLCTDigi>((*j).second.first, (*j).second.second)); } }
void CSCDigiToRaw::add | ( | const CSCComparatorDigiCollection & | comparatorDigis, |
const CSCCLCTDigiCollection & | clctDigis | ||
) | [private] |
Definition at line 113 of file CSCDigiToRaw.cc.
References CSCEventData::add(), chamberID(), findEventData(), CSCComparatorDigi::getComparator(), CSCComparatorDigi::getStrip(), CSCComparatorDigi::getTimeBinWord(), j, CSCDetId::layer(), requireCLCTForComparators_, CSCDetId::ring(), and CSCDetId::station().
{ for (CSCComparatorDigiCollection::DigiRangeIterator j=comparatorDigis.begin(); j!=comparatorDigis.end(); ++j) { CSCDetId cscDetId=(*j).first; CSCEventData & cscData = findEventData(cscDetId); CSCDetId chamberId = chamberID(cscDetId); CSCCLCTDigiCollection::Range chamberClcts = clctDigis.get(chamberId); if(!requireCLCTForComparators_ || chamberClcts.first != chamberClcts.second) { bool me1a = (cscDetId.station()==1) && (cscDetId.ring()==4); BOOST_FOREACH(CSCComparatorDigi digi, (*j).second) { // Move ME1/A comparators from CFEB=0 to CFEB=4 if this has not // been done already. if (me1a && digi.getStrip() <= 16) { CSCComparatorDigi digi_corr(64+digi.getStrip(), digi.getComparator(), digi.getTimeBinWord()); cscData.add(digi_corr, cscDetId.layer()); } else { cscData.add(digi, cscDetId.layer()); } } } } }
void CSCDigiToRaw::add | ( | const CSCCLCTDigiCollection & | clctDigis | ) | [private] |
Definition at line 156 of file CSCDigiToRaw.cc.
References CSCEventData::add(), findEventData(), and j.
{ for (CSCCLCTDigiCollection::DigiRangeIterator j=clctDigis.begin(); j!=clctDigis.end(); ++j) { CSCDetId cscDetId=(*j).first; CSCEventData & cscData = findEventData(cscDetId); cscData.add(std::vector<CSCCLCTDigi>((*j).second.first, (*j).second.second)); } }
void CSCDigiToRaw::add | ( | const CSCALCTDigiCollection & | alctDigis | ) | [private] |
Definition at line 145 of file CSCDigiToRaw.cc.
References CSCEventData::add(), findEventData(), and j.
{ for (CSCALCTDigiCollection::DigiRangeIterator j=alctDigis.begin(); j!=alctDigis.end(); ++j) { CSCDetId cscDetId=(*j).first; CSCEventData & cscData = findEventData(cscDetId); cscData.add(std::vector<CSCALCTDigi>((*j).second.first, (*j).second.second)); } }
void CSCDigiToRaw::beginEvent | ( | const CSCChamberMap * | electronicsMap | ) | [private] |
Definition at line 35 of file CSCDigiToRaw.cc.
References theChamberDataMap, and theElectronicsMap.
Referenced by createFedBuffers().
{ theChamberDataMap.clear(); theElectronicsMap = electronicsMap; }
takes layer ID, converts to chamber ID, switching ME1A to ME11
Definition at line 180 of file CSCDigiToRaw.cc.
References CSCDetId::chamber(), CSCDetId::chamberId(), CSCDetId, CSCDetId::endcap(), CSCDetId::ring(), and CSCDetId::station().
Referenced by add(), and findEventData().
void CSCDigiToRaw::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.
Definition at line 190 of file CSCDigiToRaw.cc.
References add(), beginEvent(), bitset_utilities::bitsetToChar(), evf::compute_crc(), FEDRawData::data(), CSCChamberMap::ddu(), CSCChamberMap::dduInput(), CSCChamberMap::dduSlot(), CSCChamberMap::dmb(), edm::EventID::event(), Exception, FEDRawDataCollection::FEDData(), edm::EventBase::id(), FEDNumbering::MAXCSCFEDID, FEDNumbering::MINCSCFEDID, FEDRawData::resize(), FEDRawData::size(), CSCChamberMap::slink(), and theChamberDataMap.
Referenced by CSCDigiToRawModule::produce().
{ //bits of code from ORCA/Muon/METBFormatter - thanks, Rick:)! //get fed object from fed_buffers // make a map from the index of a chamber to the event data from it beginEvent(mapping); add(stripDigis, preTriggers); add(wireDigis); add(comparatorDigis, clctDigis); add(alctDigis); add(clctDigis); add(correlatedLCTDigis); int l1a=e.id().event(); //need to add increments or get it from lct digis int bx = 0;//same as above //int startingFED = FEDNumbering::MINCSCFEDID; std::map<int, CSCDCCEventData> dccMap; for (int idcc=FEDNumbering::MINCSCFEDID; idcc<=FEDNumbering::MAXCSCFEDID;++idcc) { //idcc goes from startingFed to startingFED+7 // @@ if ReadoutMapping changes, this'll have to change // DCCs 1,2,4,5 have 5 DDUs. Otherwise, 4 //int nDDUs = (idcc < 2) || (idcc ==4) || (idcc ==5) // ? 5 : 4; //@@ WARNING some DCCs only have 4 DDUs, but I'm giving them all 5, for now int nDDUs = 5; dccMap.insert(std::pair<int, CSCDCCEventData>(idcc, CSCDCCEventData(idcc, nDDUs, bx, l1a) ) ); // for every chamber with data, add to a DDU in this DCC Event for(map<CSCDetId, CSCEventData>::iterator chamberItr = theChamberDataMap.begin(); chamberItr != theChamberDataMap.end(); ++chamberItr) { //std::cout<<"inside the pack loop" <<std::endl; int indexDCC = mapping->slink(chamberItr->first); if(indexDCC == idcc) { //FIXME (What does this mean? Is something wrong?) std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.find(indexDCC); if(dccMapItr == dccMap.end()) { throw cms::Exception("CSCDigiToRaw") << "Bad DCC number:" << indexDCC; } // get id's based on ChamberId from mapping int dduId = mapping->ddu(chamberItr->first); int dduSlot = mapping->dduSlot(chamberItr->first); int dduInput = mapping->dduInput(chamberItr->first); int dmbId = mapping->dmb(chamberItr->first); dccMapItr->second.addChamber(chamberItr->second, dduId, dduSlot, dduInput, dmbId); } } } // FIXME: FEDRawData size set to 2*64 to add FED header and trailer for(std::map<int, CSCDCCEventData>::iterator dccMapItr = dccMap.begin(); dccMapItr != dccMap.end(); ++dccMapItr) { boost::dynamic_bitset<> dccBits = dccMapItr->second.pack(); FEDRawData & fedRawData = fed_buffers.FEDData(dccMapItr->first); fedRawData.resize(dccBits.size()); //fill data with dccEvent bitset_utilities::bitsetToChar(dccBits, fedRawData.data()); FEDTrailer cscFEDTrailer(fedRawData.data()+(fedRawData.size()-8)); cscFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8), fedRawData.size()/8, evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0); } }
CSCEventData & CSCDigiToRaw::findEventData | ( | const CSCDetId & | cscDetId | ) | [private] |
pick out the correct data object for this chamber
Definition at line 42 of file CSCDigiToRaw.cc.
References chamberID(), CSCChamberMap::crate(), CSCChamberMap::dmb(), CSCEventData::dmbHeader(), CSCDetId::iChamberType(), CSCDMBHeader::setCrateAddress(), theChamberDataMap, and theElectronicsMap.
Referenced by add().
{ CSCDetId chamberId = chamberID(cscDetId); //std::cout<<"wire id"<<cscDetId<<std::endl; // find the entry into the map map<CSCDetId, CSCEventData>::iterator chamberMapItr = theChamberDataMap.find(chamberId); if(chamberMapItr == theChamberDataMap.end()) { // make an entry, telling it the correct chamberType int chamberType = chamberId.iChamberType(); chamberMapItr = theChamberDataMap.insert(pair<CSCDetId, CSCEventData>(chamberId, CSCEventData(chamberType))).first; } CSCEventData & cscData = chamberMapItr->second; cscData.dmbHeader()->setCrateAddress(theElectronicsMap->crate(cscDetId), theElectronicsMap->dmb(cscDetId)); return cscData; }
bool CSCDigiToRaw::requireCLCTForComparators_ [private] |
Definition at line 66 of file CSCDigiToRaw.h.
Referenced by add().
bool CSCDigiToRaw::requirePreTrigger_ [private] |
Definition at line 65 of file CSCDigiToRaw.h.
Referenced by add().
std::map<CSCDetId, CSCEventData> CSCDigiToRaw::theChamberDataMap [private] |
Definition at line 62 of file CSCDigiToRaw.h.
Referenced by beginEvent(), createFedBuffers(), and findEventData().
const CSCChamberMap* CSCDigiToRaw::theElectronicsMap [private] |
Definition at line 63 of file CSCDigiToRaw.h.
Referenced by beginEvent(), and findEventData().