CMS 3D CMS Logo

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 // Improved by : Salvatore Di Guida
14 // Created: Thu, 28 May 2015 19:54:56 GMT
15 //
16 //
17 
18 
19 // system include files
20 #include <memory>
21 #include <iostream>
22 
23 // user include files
26 
29 
31 
37 
39 
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<int64_t>( "triggerCount" ).setBranchAlias( "triggerCount");
70  produces<BSTRecord>( "bstRecord" ).setBranchAlias( "bstRecord" );
71 }
72 
73 
75 {
76 }
77 
78 
79 //
80 // member functions
81 //
82 
83 // ------------ method called to produce the data ------------
85 {
86  using namespace edm;
87 
89  iEvent.getByToken(dataToken_,rawdata);
90 
91  int nibble=-99;
92  int triggerCount = -99;
93  BSTRecord bstRecord;
94  if( rawdata.isValid() ) {
95  const FEDRawData& tcdsData = rawdata->FEDData(FEDNumbering::MINTCDSuTCAFEDID);
96  if(tcdsData.size()>0){
97  evf::evtn::TCDSRecord tcdsRecord(tcdsData.data());
98  nibble = (int)tcdsRecord.getHeader().getData().header.nibble;
99  triggerCount = (int64_t)tcdsRecord.getHeader().getData().header.triggerCount;
100  uint64_t gpsh = tcdsRecord.getBST().getBST().bst.gpstimehigh;
101  uint32_t gpsl = tcdsRecord.getBST().getBST().bst.gpstimelow;
102  unsigned long long gpstime = static_cast<unsigned long long>((gpsh << 32) + gpsl);
103  unsigned char bstMaster = static_cast<unsigned char>(tcdsRecord.getBST().getBST().bst.bstMaster_bireserved16 >> 8);
104  uint32_t turnCountHigh = tcdsRecord.getBST().getBST().bst.turnCountHigh;
105  uint16_t turnCountLow = tcdsRecord.getBST().getBST().bst.turnCountLow;
106  unsigned int turnCount = static_cast<unsigned int>((turnCountHigh << 16) + turnCountLow);
107  uint32_t lhcFillHigh = tcdsRecord.getBST().getBST().bst.lhcFillHigh;
108  uint16_t lhcFillLow = tcdsRecord.getBST().getBST().bst.lhcFillLow;
109  unsigned int lhcFill = static_cast<unsigned int>((lhcFillHigh << 16) + lhcFillLow);
110  unsigned short beamMode = static_cast<unsigned short>(tcdsRecord.getBST().getBST().bst.beamMode);
111  unsigned char particleType1 = static_cast<unsigned char>(tcdsRecord.getBST().getBST().bst.particleTypes & 0xFF);
112  unsigned char particleType2 = static_cast<unsigned char>(tcdsRecord.getBST().getBST().bst.particleTypes >> 8);
113  unsigned short beamMomentum = static_cast<unsigned short>(tcdsRecord.getBST().getBST().bst.beamMomentum);
114  unsigned int intensityBeam1 = static_cast<unsigned int>(tcdsRecord.getBST().getBST().bst.intensityBeam1);
115  unsigned int intensityBeam2 = static_cast<unsigned int>(tcdsRecord.getBST().getBST().bst.intensityBeam2);
116  bstRecord.set(gpstime, bstMaster, turnCount, lhcFill, beamMode, particleType1, particleType2, beamMomentum, intensityBeam1, intensityBeam2);
117  } else {
118  nibble=-2;
119  triggerCount=-2;
120  }
121  } else {
122  nibble=-1;
123  triggerCount=-1;
124  }
125  //std::cout<<"nibble is "<<nibble<<std::endl;
126 
127  iEvent.put(std::make_unique<int>(nibble), "nibble");
128  iEvent.put(std::make_unique<int64_t>(triggerCount), "triggerCount");
129  iEvent.put(std::make_unique<BSTRecord>(bstRecord), "bstRecord");
130 }
131 
132 
133 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
134 void
136  //The following says we do not know what parameters are allowed so do no validation
137  // Please change this to state exactly what you do use, even if it is no parameters
139  desc.add<edm::InputTag>("InputLabel",edm::InputTag("rawDataCollector"));
140  descriptions.add("tcdsRawToDigi", desc);
141 }
142 
143 //define this as a plug-in
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
TCDSHeader & getHeader()
Definition: FED1024.h:159
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void set(unsigned long long gpstime, unsigned char bstMaster, unsigned int turnCount, unsigned int lhcFill, unsigned short beamMode, unsigned char particleBeam1, unsigned char particleBeam2, unsigned short beamMomentum, unsigned int intensityBeam1, unsigned int intensityBeam2)
Definition: BSTRecord.h:22
struct evf::evtn::TCDSHeader::tcdsheader::@336 header
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 FEDRawData & FEDData(int fedid) const
retrieve data for fed
const tcdsheader & getData()
Definition: FED1024.h:84
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
TcdsRawToDigi(const edm::ParameterSet &)
edm::EDGetTokenT< FEDRawDataCollection > dataToken_
unsigned long long uint64_t
Definition: Time.h:15
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28