#include <EventFilter/GctRawToDigi/src/GctDigiToRaw.cc>
Public Member Functions | |
GctDigiToRaw (const edm::ParameterSet &) | |
~GctDigiToRaw () | |
Private Member Functions | |
virtual void | beginJob () |
virtual void | endJob () |
void | print (FEDRawData &data) |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
int | counter_ |
int | fedId_ |
GctFormatTranslateMCLegacy | formatTranslator_ |
edm::InputTag | gctInputLabel_ |
bool | packRctCalo_ |
bool | packRctEm_ |
edm::InputTag | rctInputLabel_ |
bool | verbose_ |
Description: Produce fake GCT raw data from digis
Implementation: <Notes on="" implementation>="">
Definition at line 42 of file GctDigiToRaw.h.
GctDigiToRaw::GctDigiToRaw | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 40 of file GctDigiToRaw.cc.
References fedId_, and LogDebug.
: rctInputLabel_(iConfig.getParameter<edm::InputTag>("rctInputLabel")), gctInputLabel_(iConfig.getParameter<edm::InputTag>("gctInputLabel")), packRctEm_(iConfig.getUntrackedParameter<bool>("packRctEm", true)), packRctCalo_(iConfig.getUntrackedParameter<bool>("packRctCalo", true)), fedId_(iConfig.getParameter<int>("gctFedId")), verbose_(iConfig.getUntrackedParameter<bool>("verbose",false)), counter_(0), formatTranslator_() { LogDebug("GCT") << "GctDigiToRaw will pack FED Id " << fedId_; //register the products produces<FEDRawDataCollection>(); }
GctDigiToRaw::~GctDigiToRaw | ( | ) |
Definition at line 57 of file GctDigiToRaw.cc.
{ // do anything here that needs to be done at destruction time // (e.g. close files, deallocate resources etc.) }
void GctDigiToRaw::beginJob | ( | void | ) | [private, virtual] |
void GctDigiToRaw::endJob | ( | void | ) | [private, virtual] |
void GctDigiToRaw::print | ( | FEDRawData & | data | ) | [private] |
Definition at line 203 of file GctDigiToRaw.cc.
References gather_cfg::cout, FEDRawData::data(), i, and FEDRawData::size().
Referenced by produce().
void GctDigiToRaw::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 70 of file GctDigiToRaw.cc.
References evf::compute_crc(), counter_, edm::EventID::event(), fedId_, formatTranslator_, gctInputLabel_, edm::Event::getByLabel(), edm::EventBase::id(), edm::InputTag::label(), LogDebug, packRctCalo_, packRctEm_, print(), edm::Event::put(), rctInputLabel_, FEDRawData::resize(), FEDTrailer::set(), FEDHeader::set(), GctFormatTranslateBase::setPackingBxId(), GctFormatTranslateBase::setPackingEventId(), verbose_, GctFormatTranslateMCLegacy::writeAllRctCaloRegionBlock(), GctFormatTranslateMCLegacy::writeGctOutEmAndEnergyBlock(), GctFormatTranslateMCLegacy::writeGctOutJetBlock(), and GctFormatTranslateMCLegacy::writeRctEmCandBlocks().
{ using namespace edm; counter_++; // To "simulate" bunch crossings for now... unsigned int bx = counter_ % 3564; // What's the proper way of doing this? EventNumber_t eventNumber = iEvent.id().event(); // Supply bx and EvID to the packer so it can make internal capture block headers. formatTranslator_.setPackingBxId(bx); formatTranslator_.setPackingEventId(eventNumber); // The GCT and RCT input label strings const std::string gctInputLabelStr = gctInputLabel_.label(); const std::string rctInputLabelStr = rctInputLabel_.label(); // get GCT digis edm::Handle<L1GctEmCandCollection> isoEm; iEvent.getByLabel(gctInputLabelStr, "isoEm", isoEm); edm::Handle<L1GctEmCandCollection> nonIsoEm; iEvent.getByLabel(gctInputLabelStr, "nonIsoEm", nonIsoEm); edm::Handle<L1GctJetCandCollection> cenJets; iEvent.getByLabel(gctInputLabelStr, "cenJets", cenJets); edm::Handle<L1GctJetCandCollection> forJets; iEvent.getByLabel(gctInputLabelStr, "forJets", forJets); edm::Handle<L1GctJetCandCollection> tauJets; iEvent.getByLabel(gctInputLabelStr, "tauJets", tauJets); edm::Handle<L1GctEtTotalCollection> etTotal; iEvent.getByLabel(gctInputLabelStr, "", etTotal); edm::Handle<L1GctEtHadCollection> etHad; iEvent.getByLabel(gctInputLabelStr, "", etHad); edm::Handle<L1GctEtMissCollection> etMiss; iEvent.getByLabel(gctInputLabelStr, "", etMiss); edm::Handle<L1GctHFRingEtSumsCollection> hfRingSums; iEvent.getByLabel(gctInputLabelStr, "", hfRingSums); edm::Handle<L1GctHFBitCountsCollection> hfBitCounts; iEvent.getByLabel(gctInputLabelStr, "", hfBitCounts); edm::Handle<L1GctHtMissCollection> htMiss; iEvent.getByLabel(gctInputLabelStr, "", htMiss); edm::Handle<L1GctJetCountsCollection> jetCounts; iEvent.getByLabel(gctInputLabelStr, "", jetCounts); // get RCT EM Cand digi bool packRctEmThisEvent = packRctEm_; edm::Handle<L1CaloEmCollection> rctEm; if(packRctEmThisEvent) { iEvent.getByLabel(rctInputLabelStr, rctEm); if(rctEm.failedToGet()) { packRctEmThisEvent = false; LogDebug("GCT") << "RCT EM Candidate packing requested, but failed to get them from event!"; } } // get RCT Calo region digi bool packRctCaloThisEvent = packRctCalo_; edm::Handle<L1CaloRegionCollection> rctCalo; if(packRctCaloThisEvent) { iEvent.getByLabel(rctInputLabelStr, rctCalo); if(rctCalo.failedToGet()) { packRctCaloThisEvent = false; LogDebug("GCT") << "RCT Calo Region packing requested, but failed to get them from event!"; } } // create the raw data collection std::auto_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection()); // get the GCT buffer FEDRawData& fedRawData=rawColl->FEDData(fedId_); // set the size & make pointers to the header, beginning of payload, and footer. unsigned int rawSize = 88; // MUST BE MULTIPLE OF 8! (slink packets are 64 bit, but using 8-bit data struct). if(packRctEmThisEvent) { rawSize += 232; } // Space for RCT EM Cands. if(packRctCaloThisEvent) { rawSize += 800; } // Space for RCT Calo Regions (plus a 32-bit word of padding to make divisible by 8) fedRawData.resize(rawSize); unsigned char * pHeader = fedRawData.data(); unsigned char * pPayload = pHeader + 16; // 16 = 8 for slink header + 8 for Greg's versioning header. unsigned char * pFooter = pHeader + rawSize - 8; // Write CDF header (exactly as told by Marco Zanetti) FEDHeader fedHeader(pHeader); fedHeader.set(pHeader, 1, eventNumber, bx, fedId_); // what should the bx_ID be? // Pack GCT jet output digis formatTranslator_.writeGctOutJetBlock(pPayload, cenJets.product(), forJets.product(), tauJets.product(), hfRingSums.product(), hfBitCounts.product(), htMiss.product()); pPayload += 36; //advance payload pointer // Pack GCT EM and energy sums digis. formatTranslator_.writeGctOutEmAndEnergyBlock(pPayload, isoEm.product(), nonIsoEm.product(), etTotal.product(), etHad.product(), etMiss.product()); pPayload += 28; //advance payload pointer // Pack RCT EM Cands if(packRctEmThisEvent) { formatTranslator_.writeRctEmCandBlocks(pPayload, rctEm.product()); pPayload+=232; //advance payload pointer } // Pack RCT Calo Regions if(packRctCaloThisEvent) { formatTranslator_.writeAllRctCaloRegionBlock(pPayload, rctCalo.product()); } // Write CDF footer (exactly as told by Marco Zanetti) FEDTrailer fedTrailer(pFooter); fedTrailer.set(pFooter, rawSize/8, evf::compute_crc(pHeader, rawSize), 0, 0); // Debug output. if (verbose_) { print(fedRawData); } // Put the collection in the event. iEvent.put(rawColl); }
int GctDigiToRaw::counter_ [private] |
Definition at line 71 of file GctDigiToRaw.h.
Referenced by produce().
int GctDigiToRaw::fedId_ [private] |
Definition at line 65 of file GctDigiToRaw.h.
Referenced by GctDigiToRaw(), and produce().
Definition at line 74 of file GctDigiToRaw.h.
Referenced by produce().
edm::InputTag GctDigiToRaw::gctInputLabel_ [private] |
Definition at line 58 of file GctDigiToRaw.h.
Referenced by produce().
bool GctDigiToRaw::packRctCalo_ [private] |
Definition at line 62 of file GctDigiToRaw.h.
Referenced by produce().
bool GctDigiToRaw::packRctEm_ [private] |
Definition at line 61 of file GctDigiToRaw.h.
Referenced by produce().
edm::InputTag GctDigiToRaw::rctInputLabel_ [private] |
Definition at line 57 of file GctDigiToRaw.h.
Referenced by produce().
bool GctDigiToRaw::verbose_ [private] |
Definition at line 68 of file GctDigiToRaw.h.
Referenced by produce().