Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:11

0001 // -*- C++ -*-
0002 //
0003 // Package:    LTCRawToDigi
0004 // Class:      LTCRawToDigi
0005 //
0006 /**\class LTCRawToDigi LTCRawToDigi.cc EventFilter/LTCRawToDigi/src/LTCRawToDigi.cc
0007 
0008  Description: Unpack FED data to LTC bank. LTCs are FED id 816-823.
0009 
0010  Implementation:
0011      No comments
0012 */
0013 //
0014 // Original Author:  Peter Wittich
0015 //         Created:  Tue May  9 07:47:59 CDT 2006
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/EDProducer.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 
0031 //FEDRawData
0032 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0033 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0034 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0035 // LTC class
0036 #include "DataFormats/LTCDigi/interface/LTCDigi.h"
0037 //
0038 // class declaration
0039 //
0040 
0041 class LTCRawToDigi : public edm::EDProducer {
0042 public:
0043   explicit LTCRawToDigi(const edm::ParameterSet&);
0044   ~LTCRawToDigi() override;
0045 
0046   void produce(edm::Event&, const edm::EventSetup&) override;
0047 
0048 private:
0049   // ----------member data ---------------------------
0050 };
0051 
0052 //
0053 // constants, enums and typedefs
0054 //
0055 
0056 //
0057 // static data member definitions
0058 //
0059 
0060 //
0061 // constructors and destructor
0062 //
0063 LTCRawToDigi::LTCRawToDigi(const edm::ParameterSet& iConfig) {
0064   //register your products
0065   produces<LTCDigiCollection>();
0066 }
0067 
0068 LTCRawToDigi::~LTCRawToDigi() {
0069   // do anything here that needs to be done at desctruction time
0070   // (e.g. close files, deallocate resources etc.)
0071 }
0072 
0073 //
0074 // member functions
0075 //
0076 
0077 // ------------ method called to produce the data  ------------
0078 void LTCRawToDigi::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0079   using namespace edm;
0080   const int LTCFedIDLo = 815;
0081   const int LTCFedIDHi = 823;
0082 
0083   // Get a handle to the FED data collection
0084   edm::Handle<FEDRawDataCollection> rawdata;
0085   iEvent.getByLabel("source", rawdata);
0086 
0087   // create collection we'll save in the event record
0088   auto pOut = std::make_unique<LTCDigiCollection>();
0089 
0090   // Loop over all possible FED's with the appropriate FED ID
0091   for (int id = LTCFedIDLo; id <= LTCFedIDHi; ++id) {
0092     /// Take a reference to this FED's data
0093     const FEDRawData& fedData = rawdata->FEDData(id);
0094     unsigned short int length = fedData.size();
0095     if (!length)
0096       continue;  // bank does not exist
0097     LTCDigi ltcDigi(fedData.data());
0098     pOut->push_back(ltcDigi);
0099   }
0100   iEvent.put(std::move(pOut));
0101 }
0102 
0103 //define this as a plug-in
0104 DEFINE_FWK_MODULE(LTCRawToDigi);