Go to the documentation of this file.00001 #include "EventFilter/DTRawToDigi/plugins/DTDigiToRawModule.h"
00002 #include "EventFilter/DTRawToDigi/plugins/DTDigiToRaw.h"
00003 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00004 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00005 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/Framework/interface/Event.h"
00008
00009 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
00010 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
00011 #include "FWCore/Utilities/interface/CRC16.h"
00012
00013 #include "CondFormats/DataRecord/interface/DTReadOutMappingRcd.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015
00016 #include <iostream>
00017
00018 using namespace edm;
00019 using namespace std;
00020
00021 DTDigiToRawModule::DTDigiToRawModule(const edm::ParameterSet& ps) {
00022 produces<FEDRawDataCollection>();
00023
00024 dduID = ps.getUntrackedParameter<int>("dduID", 770);
00025 debug = ps.getUntrackedParameter<bool>("debugMode", false);
00026 digicoll = ps.getParameter<edm::InputTag>("digiColl");
00027
00028 useStandardFEDid_ = ps.getUntrackedParameter<bool>("useStandardFEDid", true);
00029 minFEDid_ = ps.getUntrackedParameter<int>("minFEDid", 770);
00030 maxFEDid_ = ps.getUntrackedParameter<int>("maxFEDid", 775);
00031
00032 packer = new DTDigiToRaw(ps);
00033 if (debug) cout << "[DTDigiToRawModule]: constructor" << endl;
00034 }
00035
00036 DTDigiToRawModule::~DTDigiToRawModule(){
00037 delete packer;
00038 if (debug) cout << "[DTDigiToRawModule]: destructor" << endl;
00039 }
00040
00041
00042 void DTDigiToRawModule::produce(Event & e, const EventSetup& iSetup) {
00043
00044 auto_ptr<FEDRawDataCollection> fed_buffers(new FEDRawDataCollection);
00045
00046
00047 Handle<DTDigiCollection> digis;
00048 e.getByLabel(digicoll, digis);
00049
00050
00051 edm::ESHandle<DTReadOutMapping> map;
00052 iSetup.get<DTReadOutMappingRcd>().get( map );
00053
00054
00055 int FEDIDmin = 0, FEDIDMax = 0;
00056 if (useStandardFEDid_){
00057 FEDIDmin = FEDNumbering::MINDTFEDID;
00058 FEDIDMax = FEDNumbering::MAXDTFEDID;
00059 }
00060 else {
00061 FEDIDmin = minFEDid_;
00062 FEDIDMax = maxFEDid_;
00063 }
00064
00065 for (int id=FEDIDmin; id<=FEDIDMax; ++id){
00066
00067 packer->SetdduID(id);
00068 FEDRawData* rawData = packer->createFedBuffers(*digis, map);
00069
00070 FEDRawData& fedRawData = fed_buffers->FEDData(id);
00071 fedRawData = *rawData;
00072 delete rawData;
00073
00074 FEDHeader dtFEDHeader(fedRawData.data());
00075 dtFEDHeader.set(fedRawData.data(), 0, e.id().event(), 0, id);
00076
00077 FEDTrailer dtFEDTrailer(fedRawData.data()+(fedRawData.size()-8));
00078 dtFEDTrailer.set(fedRawData.data()+(fedRawData.size()-8), fedRawData.size()/8, evf::compute_crc(fedRawData.data(),fedRawData.size()), 0, 0);
00079
00080 }
00081
00082 e.put(fed_buffers);
00083
00084 }
00085