CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/EventFilter/LTCRawToDigi/src/LTCRawToDigi.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    LTCRawToDigi
00004 // Class:      LTCRawToDigi
00005 // 
00013 //
00014 // Original Author:  Peter Wittich
00015 //         Created:  Tue May  9 07:47:59 CDT 2006
00016 // $Id: LTCRawToDigi.cc,v 1.4 2006/10/27 01:35:24 wmtan Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 
00033 //FEDRawData 
00034 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00035 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00036 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00037 // LTC class
00038 #include "DataFormats/LTCDigi/interface/LTCDigi.h"
00039 //
00040 // class declaration
00041 //
00042 
00043 class LTCRawToDigi : public edm::EDProducer {
00044    public:
00045       explicit LTCRawToDigi(const edm::ParameterSet&);
00046       ~LTCRawToDigi();
00047 
00048 
00049       virtual void produce(edm::Event&, const edm::EventSetup&);
00050    private:
00051       // ----------member data ---------------------------
00052 };
00053 
00054 //
00055 // constants, enums and typedefs
00056 //
00057 
00058 //
00059 // static data member definitions
00060 //
00061 
00062 //
00063 // constructors and destructor
00064 //
00065 LTCRawToDigi::LTCRawToDigi(const edm::ParameterSet& iConfig)
00066 {
00067    //register your products
00068    produces<LTCDigiCollection>();
00069 }
00070 
00071 
00072 LTCRawToDigi::~LTCRawToDigi()
00073 {
00074  
00075    // do anything here that needs to be done at desctruction time
00076    // (e.g. close files, deallocate resources etc.)
00077 
00078 }
00079 
00080 
00081 //
00082 // member functions
00083 //
00084 
00085 // ------------ method called to produce the data  ------------
00086 void
00087 LTCRawToDigi::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00088 {
00089   using namespace edm;
00090   const int LTCFedIDLo = 815;
00091   const int LTCFedIDHi = 823;
00092 
00093   // Get a handle to the FED data collection
00094   edm::Handle<FEDRawDataCollection> rawdata;
00095   iEvent.getByLabel("source" , rawdata);
00096 
00097   // create collection we'll save in the event record
00098   std::auto_ptr<LTCDigiCollection> pOut(new LTCDigiCollection());
00099 
00100   // Loop over all possible FED's with the appropriate FED ID
00101   for ( int id = LTCFedIDLo; id <= LTCFedIDHi; ++id ) {
00103     const FEDRawData & fedData = rawdata->FEDData(id);
00104     unsigned short int length =  fedData.size();
00105     if ( ! length ) 
00106       continue; // bank does not exist
00107     LTCDigi ltcDigi(fedData.data());
00108     pOut->push_back(ltcDigi);
00109   }
00110   iEvent.put(pOut);
00111 }
00112 
00113 //define this as a plug-in
00114 DEFINE_FWK_MODULE(LTCRawToDigi);