![]() |
![]() |
#include <EventFilter/GctRawToDigi/src/GctDigiToRaw.cc>
Public Member Functions | |
GctDigiToRaw (const edm::ParameterSet &) | |
~GctDigiToRaw () | |
Private Member Functions | |
virtual void | beginJob (const edm::EventSetup &) |
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_ |
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.
00040 : 00041 rctInputLabel_(iConfig.getParameter<edm::InputTag>("rctInputLabel")), 00042 gctInputLabel_(iConfig.getParameter<edm::InputTag>("gctInputLabel")), 00043 packRctEm_(iConfig.getUntrackedParameter<bool>("packRctEm", true)), 00044 packRctCalo_(iConfig.getUntrackedParameter<bool>("packRctCalo", true)), 00045 fedId_(iConfig.getParameter<int>("gctFedId")), 00046 verbose_(iConfig.getUntrackedParameter<bool>("verbose",false)), 00047 counter_(0), 00048 formatTranslator_() 00049 { 00050 LogDebug("GCT") << "GctDigiToRaw will pack FED Id " << fedId_; 00051 00052 //register the products 00053 produces<FEDRawDataCollection>(); 00054 }
GctDigiToRaw::~GctDigiToRaw | ( | ) |
Definition at line 57 of file GctDigiToRaw.cc.
00058 { 00059 // do anything here that needs to be done at destruction time 00060 // (e.g. close files, deallocate resources etc.) 00061 }
void GctDigiToRaw::beginJob | ( | const edm::EventSetup & | ) | [private, virtual] |
void GctDigiToRaw::print | ( | FEDRawData & | data | ) | [private] |
Definition at line 200 of file GctDigiToRaw.cc.
References GenMuonPlsPt100GeV_cfg::cout, d, FEDRawData::data(), lat::endl(), i, FEDRawData::size(), and w.
Referenced by produce().
00200 { 00201 00202 const unsigned char * d = data.data(); 00203 00204 for (unsigned int i=0; i<data.size(); i=i+4) { 00205 uint32_t w = (uint32_t)d[i] + (uint32_t)(d[i+1]<<8) + (uint32_t)(d[i+2]<<16) + (uint32_t)(d[i+3]<<24); 00206 cout << std::hex << std::setw(4) << i/4 << " " << std::setw(8) << w << endl; 00207 } 00208 00209 }
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_, FEDRawData::data(), etHad, etMiss, edm::Handle< T >::failedToGet(), fedId_, formatTranslator_, gctInputLabel_, edm::Event::getByLabel(), edm::Event::id(), jetCounts, edm::InputTag::label(), LogDebug, packRctCalo_, packRctEm_, print(), edm::Handle< T >::product(), edm::Event::put(), rctInputLabel_, FEDRawData::resize(), FEDTrailer::set(), FEDHeader::set(), GctFormatTranslateBase::setPackingBxId(), GctFormatTranslateBase::setPackingEventId(), verbose_, GctFormatTranslateMCLegacy::writeAllRctCaloRegionBlock(), GctFormatTranslateMCLegacy::writeGctOutEmAndEnergyBlock(), GctFormatTranslateMCLegacy::writeGctOutJetBlock(), and GctFormatTranslateMCLegacy::writeRctEmCandBlocks().
00071 { 00072 using namespace edm; 00073 00074 counter_++; // To "simulate" bunch crossings for now... 00075 unsigned int bx = counter_ % 3564; // What's the proper way of doing this? 00076 EventNumber_t eventNumber = iEvent.id().event(); 00077 00078 // Supply bx and EvID to the packer so it can make internal capture block headers. 00079 formatTranslator_.setPackingBxId(bx); 00080 formatTranslator_.setPackingEventId(eventNumber); 00081 00082 // The GCT and RCT input label strings 00083 const std::string gctInputLabelStr = gctInputLabel_.label(); 00084 const std::string rctInputLabelStr = rctInputLabel_.label(); 00085 00086 // get GCT digis 00087 edm::Handle<L1GctEmCandCollection> isoEm; 00088 iEvent.getByLabel(gctInputLabelStr, "isoEm", isoEm); 00089 edm::Handle<L1GctEmCandCollection> nonIsoEm; 00090 iEvent.getByLabel(gctInputLabelStr, "nonIsoEm", nonIsoEm); 00091 edm::Handle<L1GctJetCandCollection> cenJets; 00092 iEvent.getByLabel(gctInputLabelStr, "cenJets", cenJets); 00093 edm::Handle<L1GctJetCandCollection> forJets; 00094 iEvent.getByLabel(gctInputLabelStr, "forJets", forJets); 00095 edm::Handle<L1GctJetCandCollection> tauJets; 00096 iEvent.getByLabel(gctInputLabelStr, "tauJets", tauJets); 00097 edm::Handle<L1GctEtTotalCollection> etTotal; 00098 iEvent.getByLabel(gctInputLabelStr, "", etTotal); 00099 edm::Handle<L1GctEtHadCollection> etHad; 00100 iEvent.getByLabel(gctInputLabelStr, "", etHad); 00101 edm::Handle<L1GctEtMissCollection> etMiss; 00102 iEvent.getByLabel(gctInputLabelStr, "", etMiss); 00103 edm::Handle<L1GctHFRingEtSumsCollection> hfRingSums; 00104 iEvent.getByLabel(gctInputLabelStr, "", hfRingSums); 00105 edm::Handle<L1GctHFBitCountsCollection> hfBitCounts; 00106 iEvent.getByLabel(gctInputLabelStr, "", hfBitCounts); 00107 edm::Handle<L1GctJetCountsCollection> jetCounts; 00108 iEvent.getByLabel(gctInputLabelStr, "", jetCounts); 00109 00110 // get RCT EM Cand digi 00111 bool packRctEmThisEvent = packRctEm_; 00112 edm::Handle<L1CaloEmCollection> rctEm; 00113 if(packRctEmThisEvent) 00114 { 00115 iEvent.getByLabel(rctInputLabelStr, rctEm); 00116 if(rctEm.failedToGet()) 00117 { 00118 packRctEmThisEvent = false; 00119 LogDebug("GCT") << "RCT EM Candidate packing requested, but failed to get them from event!"; 00120 } 00121 } 00122 00123 // get RCT Calo region digi 00124 bool packRctCaloThisEvent = packRctCalo_; 00125 edm::Handle<L1CaloRegionCollection> rctCalo; 00126 if(packRctCaloThisEvent) 00127 { 00128 iEvent.getByLabel(rctInputLabelStr, rctCalo); 00129 if(rctCalo.failedToGet()) 00130 { 00131 packRctCaloThisEvent = false; 00132 LogDebug("GCT") << "RCT Calo Region packing requested, but failed to get them from event!"; 00133 } 00134 } 00135 00136 // create the raw data collection 00137 std::auto_ptr<FEDRawDataCollection> rawColl(new FEDRawDataCollection()); 00138 00139 // get the GCT buffer 00140 FEDRawData& fedRawData=rawColl->FEDData(fedId_); 00141 00142 // set the size & make pointers to the header, beginning of payload, and footer. 00143 unsigned int rawSize = 88; // MUST BE MULTIPLE OF 8! (slink packets are 64 bit, but using 8-bit data struct). 00144 if(packRctEmThisEvent) { rawSize += 232; } // Space for RCT EM Cands. 00145 if(packRctCaloThisEvent) { rawSize += 800; } // Space for RCT Calo Regions (plus a 32-bit word of padding to make divisible by 8) 00146 fedRawData.resize(rawSize); 00147 unsigned char * pHeader = fedRawData.data(); 00148 unsigned char * pPayload = pHeader + 16; // 16 = 8 for slink header + 8 for Greg's versioning header. 00149 unsigned char * pFooter = pHeader + rawSize - 8; 00150 00151 // Write CDF header (exactly as told by Marco Zanetti) 00152 FEDHeader fedHeader(pHeader); 00153 fedHeader.set(pHeader, 1, eventNumber, bx, fedId_); // what should the bx_ID be? 00154 00155 // Pack GCT jet output digis 00156 formatTranslator_.writeGctOutJetBlock(pPayload, 00157 cenJets.product(), 00158 forJets.product(), 00159 tauJets.product(), 00160 hfRingSums.product(), 00161 hfBitCounts.product()); 00162 00163 pPayload += 36; //advance payload pointer 00164 00165 // Pack GCT EM and energy sums digis. 00166 formatTranslator_.writeGctOutEmAndEnergyBlock(pPayload, 00167 isoEm.product(), 00168 nonIsoEm.product(), 00169 etTotal.product(), 00170 etHad.product(), 00171 etMiss.product()); 00172 00173 pPayload += 28; //advance payload pointer 00174 00175 // Pack RCT EM Cands 00176 if(packRctEmThisEvent) 00177 { 00178 formatTranslator_.writeRctEmCandBlocks(pPayload, rctEm.product()); 00179 pPayload+=232; //advance payload pointer 00180 } 00181 00182 // Pack RCT Calo Regions 00183 if(packRctCaloThisEvent) 00184 { 00185 formatTranslator_.writeAllRctCaloRegionBlock(pPayload, rctCalo.product()); 00186 } 00187 00188 // Write CDF footer (exactly as told by Marco Zanetti) 00189 FEDTrailer fedTrailer(pFooter); 00190 fedTrailer.set(pFooter, rawSize/8, evf::compute_crc(pHeader, rawSize), 0, 0); 00191 00192 // Debug output. 00193 if (verbose_) { print(fedRawData); } 00194 00195 // Put the collection in the event. 00196 iEvent.put(rawColl); 00197 }
int GctDigiToRaw::counter_ [private] |
int GctDigiToRaw::fedId_ [private] |
edm::InputTag GctDigiToRaw::gctInputLabel_ [private] |
bool GctDigiToRaw::packRctCalo_ [private] |
bool GctDigiToRaw::packRctEm_ [private] |
edm::InputTag GctDigiToRaw::rctInputLabel_ [private] |
bool GctDigiToRaw::verbose_ [private] |