CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TcdsRawToDigi.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ProdTutorial/TcdsRawToDigi
4 // Class: TcdsRawToDigi
5 //
11 //
12 // Original Author: Chris Palmer
13 // Created: Thu, 28 May 2015 19:54:56 GMT
14 //
15 //
16 
17 
18 // system include files
19 #include <memory>
20 #include <iostream>
21 
22 // user include files
25 
28 
30 
31 
36 
39 
41 
42 
43 using namespace std;
44 
45 //
46 // class declaration
47 //
48 
49 
51  public:
52  explicit TcdsRawToDigi(const edm::ParameterSet&);
53  ~TcdsRawToDigi();
54 
55  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
56 
57  private:
58  virtual void produce(edm::Event&, const edm::EventSetup&) override;
59 
61 
62 };
63 
65 {
66  edm::InputTag dataLabel = iConfig.getParameter<edm::InputTag>("InputLabel");
67  dataToken_=consumes<FEDRawDataCollection>(dataLabel);
68  produces<int>( "nibble" ).setBranchAlias( "nibble");
69  produces<int>( "triggerCount" ).setBranchAlias( "triggerCount");
70 }
71 
72 
74 {
75 }
76 
77 
78 //
79 // member functions
80 //
81 
82 // ------------ method called to produce the data ------------
84 {
85  using namespace edm;
86 
88  iEvent.getByToken(dataToken_,rawdata);
89 
90  int nibble=-99;
91  int triggerCount = -99;
92  if( rawdata.isValid() ) {
93  const FEDRawData& tcdsData = rawdata->FEDData(FEDNumbering::MINTCDSuTCAFEDID);
94  if(tcdsData.size()>0){
95  evf::evtn::TCDSRecord tcdsRecord(tcdsData.data());
96  nibble = (int)tcdsRecord.getHeader().getData().header.nibble;
97  triggerCount = (int)tcdsRecord.getHeader().getData().header.triggerCount;
98  } else {
99  nibble=-2;
100  triggerCount=-2;
101  }
102  } else {
103  nibble=-1;
104  triggerCount=-1;
105  }
106  //std::cout<<"nibble is "<<nibble<<std::endl;
107 
108  iEvent.put(std::make_unique<int>(nibble), "nibble");
109  iEvent.put(std::make_unique<int>(triggerCount), "triggerCount");
110 }
111 
112 
113 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
114 void
116  //The following says we do not know what parameters are allowed so do no validation
117  // Please change this to state exactly what you do use, even if it is no parameters
119  desc.add<edm::InputTag>("InputLabel",edm::InputTag("rawDataCollector"));
120  descriptions.add("tcdsRawToDigi", desc);
121 }
122 
123 //define this as a plug-in
T getParameter(std::string const &) const
TCDSHeader & getHeader()
Definition: FED1024.h:150
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:230
const tcdsheader & getData()
Definition: FED1024.h:84
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
ParameterDescriptionBase * add(U const &iLabel, T const &value)
TcdsRawToDigi(const edm::ParameterSet &)
struct evf::evtn::TCDSHeader::tcdsheader::@322 header
edm::EDGetTokenT< FEDRawDataCollection > dataToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
dictionary rawdata
Definition: lumiPlot.py:393