CMS 3D CMS Logo

ScalersRawToDigi.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EventFilter/ScalersRawToDigi
4 // Class: ScalersRawToDigi
5 //
12 //
13 // Original Author: William Badgett
14 // Created: Wed Nov 14 07:47:59 CDT 2006
15 //
16 
17 #include <memory>
18 
25 
26 // FEDRawData
29 
30 // Scalers classes
39 
41 public:
42  explicit ScalersRawToDigi(const edm::ParameterSet&);
43 
44  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
47 
48 private:
56 };
57 
58 // Constructor
60  : fedToken_{consumes<FEDRawDataCollection>(iConfig.getParameter<edm::InputTag>("scalersInputTag"))},
61  bunchPutToken_{produces<L1AcceptBunchCrossingCollection>()},
62  l1ScalerPutToken_{produces<L1TriggerScalersCollection>()},
63  lvl1ScalerPutToken_{produces<Level1TriggerScalersCollection>()},
64  lumiScalerPutToken_{produces<LumiScalersCollection>()},
65  beamSpotPutToken_{produces<BeamSpotOnlineCollection>()},
66  dcsPutToken_{produces<DcsStatusCollection>()} {}
67 
70  desc.add<edm::InputTag>("scalersInputTag", edm::InputTag("rawDataCollector"));
71  descriptions.add("scalersRawToDigi", desc);
72 }
73 
74 // Method called to produce the data
76  using namespace edm;
77 
78  // Get the FED data collection
79  auto const& rawdata = iEvent.get(fedToken_);
80 
82 
83  L1TriggerScalersCollection pOldTrigger;
84 
86 
88 
89  BeamSpotOnlineCollection pBeamSpotOnline;
90  DcsStatusCollection pDcsStatus;
91 
93  const FEDRawData& fedData = rawdata.FEDData(ScalersRaw::SCALERS_FED_ID);
94  unsigned short int length = fedData.size();
95  if (length > 0) {
96  int nWords = length / 8;
97  int nBytesExtra = 0;
98 
99  const ScalersEventRecordRaw_v6* raw = (struct ScalersEventRecordRaw_v6*)fedData.data();
100  if ((raw->version == 1) || (raw->version == 2)) {
101  pOldTrigger.emplace_back(fedData.data());
102  nBytesExtra = length - sizeof(struct ScalersEventRecordRaw_v1);
103  } else if (raw->version >= 3) {
104  pTrigger.emplace_back(fedData.data());
105  if (raw->version >= 6) {
106  nBytesExtra = ScalersRaw::N_BX_v6 * sizeof(unsigned long long);
107  } else {
108  nBytesExtra = ScalersRaw::N_BX_v2 * sizeof(unsigned long long);
109  }
110  }
111 
112  pLumi.emplace_back(fedData.data());
113 
114  if ((nBytesExtra >= 8) && ((nBytesExtra % 8) == 0)) {
115  unsigned long long const* data = (unsigned long long const*)fedData.data();
116 
117  int nWordsExtra = nBytesExtra / 8;
118  for (int i = 0; i < nWordsExtra; i++) {
119  int index = nWords - (nWordsExtra + 1) + i;
120  pBunch.emplace_back(i, data[index]);
121  }
122  }
123 
124  if (raw->version >= 4) {
125  pBeamSpotOnline.emplace_back(fedData.data());
126 
127  pDcsStatus.emplace_back(fedData.data());
128  }
129  }
130  iEvent.emplace(l1ScalerPutToken_, std::move(pOldTrigger));
131  iEvent.emplace(lvl1ScalerPutToken_, std::move(pTrigger));
132  iEvent.emplace(lumiScalerPutToken_, std::move(pLumi));
133  iEvent.emplace(bunchPutToken_, std::move(pBunch));
134  iEvent.emplace(beamSpotPutToken_, std::move(pBeamSpotOnline));
135  iEvent.emplace(dcsPutToken_, std::move(pDcsStatus));
136 }
137 
138 // Define this as a plug-in
std::vector< BeamSpotOnline > BeamSpotOnlineCollection
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDPutTokenT< DcsStatusCollection > dcsPutToken_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
int iEvent
Definition: GenABIO.cc:224
ScalersRawToDigi(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< L1AcceptBunchCrossing > L1AcceptBunchCrossingCollection
std::vector< DcsStatus > DcsStatusCollection
Definition: DcsStatus.h:110
const edm::EDPutTokenT< BeamSpotOnlineCollection > beamSpotPutToken_
const edm::EDPutTokenT< L1TriggerScalersCollection > l1ScalerPutToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< Level1TriggerScalers > Level1TriggerScalersCollection
const edm::EDPutTokenT< LumiScalersCollection > lumiScalerPutToken_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
const edm::EDPutTokenT< L1AcceptBunchCrossingCollection > bunchPutToken_
const edm::EDGetTokenT< FEDRawDataCollection > fedToken_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:144
std::vector< L1TriggerScalers > L1TriggerScalersCollection
const edm::EDPutTokenT< Level1TriggerScalersCollection > lvl1ScalerPutToken_
def move(src, dest)
Definition: eostools.py:511