Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:56

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/global/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::global::EDProducer<> {
0042 public:
0043   explicit LTCRawToDigi(const edm::ParameterSet&);
0044 
0045   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0046 
0047 private:
0048   // ----------member data ---------------------------
0049 };
0050 
0051 //
0052 // constants, enums and typedefs
0053 //
0054 
0055 //
0056 // static data member definitions
0057 //
0058 
0059 //
0060 // constructors and destructor
0061 //
0062 LTCRawToDigi::LTCRawToDigi(const edm::ParameterSet& iConfig) {
0063   //register your products
0064   produces<LTCDigiCollection>();
0065 }
0066 
0067 //
0068 // member functions
0069 //
0070 
0071 // ------------ method called to produce the data  ------------
0072 void LTCRawToDigi::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0073   using namespace edm;
0074   const int LTCFedIDLo = 815;
0075   const int LTCFedIDHi = 823;
0076 
0077   // Get a handle to the FED data collection
0078   edm::Handle<FEDRawDataCollection> rawdata;
0079   iEvent.getByLabel("source", rawdata);
0080 
0081   // create collection we'll save in the event record
0082   auto pOut = std::make_unique<LTCDigiCollection>();
0083 
0084   // Loop over all possible FED's with the appropriate FED ID
0085   for (int id = LTCFedIDLo; id <= LTCFedIDHi; ++id) {
0086     /// Take a reference to this FED's data
0087     const FEDRawData& fedData = rawdata->FEDData(id);
0088     unsigned short int length = fedData.size();
0089     if (!length)
0090       continue;  // bank does not exist
0091     LTCDigi ltcDigi(fedData.data());
0092     pOut->push_back(ltcDigi);
0093   }
0094   iEvent.put(std::move(pOut));
0095 }
0096 
0097 //define this as a plug-in
0098 DEFINE_FWK_MODULE(LTCRawToDigi);