00001 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00002 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00003 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "CalibFormats/CastorObjects/interface/CastorDbService.h"
00006 #include "CalibFormats/CastorObjects/interface/CastorDbRecord.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include <iostream>
00009
00010
00011 #include "EventFilter/CastorRawToDigi/plugins/CastorDigiToRaw.h"
00012
00013 using namespace std;
00014
00015
00016 CastorDigiToRaw::CastorDigiToRaw(edm::ParameterSet const& conf) :
00017 castorTag_(conf.getUntrackedParameter("CASTOR",edm::InputTag())),
00018 calibTag_(conf.getUntrackedParameter("CALIB",edm::InputTag())),
00019 trigTag_(conf.getUntrackedParameter("TRIG",edm::InputTag()))
00020 {
00021 produces<FEDRawDataCollection>();
00022 }
00023
00024
00025 CastorDigiToRaw::~CastorDigiToRaw() { }
00026
00027
00028 void CastorDigiToRaw::produce(edm::Event& e, const edm::EventSetup& es)
00029 {
00030 CastorPacker::Collections colls;
00031
00032
00033
00034 edm::Handle<CastorDigiCollection> castor;
00035 if (!castorTag_.label().empty()) {
00036 e.getByLabel(castorTag_,castor);
00037 colls.castorCont=castor.product();
00038 }
00039
00040 edm::ESHandle<CastorDbService> pSetup;
00041 es.get<CastorDbRecord>().get( pSetup );
00042 const CastorElectronicsMap* readoutMap=pSetup->getCastorMapping();
00043
00044 std::auto_ptr<FEDRawDataCollection> raw=std::auto_ptr<FEDRawDataCollection>(new FEDRawDataCollection());
00045
00046
00047
00048
00049 const int ifed_first=690;
00050 const int ifed_last=693;
00051
00052 int orbitN=e.id().event();
00053 int bcnN=2000;
00054
00055
00056 for (int ifed=ifed_first; ifed<=ifed_last; ++ifed) {
00057 FEDRawData& fed = raw->FEDData(ifed);
00058 try {
00059 packer_.pack(ifed,ifed-ifed_first, e.id().event(),
00060 orbitN, bcnN, colls, *readoutMap, fed);
00061 } catch (cms::Exception& e) {
00062 edm::LogWarning("Unpacking error") << e.what();
00063 } catch (...) {
00064 edm::LogWarning("Unpacking exception");
00065 }
00066 }
00067
00068 e.put(raw);
00069 }
00070
00071