CMS 3D CMS Logo

OnlineMetaDataRawToDigi.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EventFilter/OnlineMetaDataRawToDigi
4 // Class: OnlineMetaDataRawToDigi
5 //
11 //
12 // Original Author: Remigius K Mommsen (Fermilab)
13 // Created: Wed, 22 Nov 2017 18:19:56 GMT
14 //
15 //
16 
17 // system include files
18 #include <memory>
19 #include <iostream>
20 
21 // user include files
24 
27 
29 
31 
35 
40 
41 //
42 // class declaration
43 //
44 
46 public:
48  ~OnlineMetaDataRawToDigi() override;
49 
50  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
51 
52 private:
53  void produce(edm::Event&, const edm::EventSetup&) override;
55 
57 };
58 
60  edm::InputTag dataLabel = iConfig.getParameter<edm::InputTag>("onlineMetaDataInputLabel");
61  dataToken_ = consumes<FEDRawDataCollection>(dataLabel);
62 
63  produces<CTPPSRecord>();
64  produces<DCSRecord>();
65  produces<OnlineLuminosityRecord>();
66  produces<reco::BeamSpot>();
67 }
68 
70 
71 //
72 // member functions
73 //
74 
75 // ------------ method called to produce the data ------------
77  using namespace edm;
78 
80  iEvent.getByToken(dataToken_, rawdata);
81 
83  CTPPSRecord ctppsRecord;
84  OnlineLuminosityRecord onlineLuminosityRecord;
86 
87  if (rawdata.isValid()) {
88  const FEDRawData& onlineMetaDataRaw = rawdata->FEDData(FEDNumbering::MINMetaDataSoftFEDID);
89  const unsigned char* payload = onlineMetaDataRaw.data() + FEDHeader::length;
90 
91  if (onlineMetaDataRaw.size() >= FEDHeader::length + sizeof(uint8_t)) {
92  const uint8_t version = *(reinterpret_cast<uint8_t const*>(payload));
93  if (version == 1 && onlineMetaDataRaw.size() >= FEDHeader::length + sizeof(online::Data_v1)) {
94  online::Data_v1 const* onlineMetaData = reinterpret_cast<online::Data_v1 const*>(payload);
95  dcsRecord = DCSRecord(onlineMetaData->dcs);
96  onlineLuminosityRecord = OnlineLuminosityRecord(onlineMetaData->luminosity);
97  onlineBeamSpot = getBeamSpot(onlineMetaData->beamSpot);
98  } else if (version == 2 && onlineMetaDataRaw.size() >= FEDHeader::length + sizeof(online::Data_v2)) {
99  online::Data_v2 const* onlineMetaData = reinterpret_cast<online::Data_v2 const*>(payload);
100  ctppsRecord = CTPPSRecord(onlineMetaData->ctpps);
101  dcsRecord = DCSRecord(onlineMetaData->dcs);
102  onlineLuminosityRecord = OnlineLuminosityRecord(onlineMetaData->luminosity);
103  onlineBeamSpot = getBeamSpot(onlineMetaData->beamSpot);
104  } else if (version == 3 && onlineMetaDataRaw.size() >= FEDHeader::length + sizeof(online::Data_v3)) {
105  online::Data_v3 const* onlineMetaData = reinterpret_cast<online::Data_v3 const*>(payload);
106  ctppsRecord = CTPPSRecord(onlineMetaData->ctpps);
107  dcsRecord = DCSRecord(onlineMetaData->dcs);
108  onlineLuminosityRecord = OnlineLuminosityRecord(onlineMetaData->luminosity);
109  onlineBeamSpot = getBeamSpot(onlineMetaData->beamSpot);
110  }
111  }
112  }
113 
114  iEvent.put(std::make_unique<CTPPSRecord>(ctppsRecord));
115  iEvent.put(std::make_unique<DCSRecord>(dcsRecord));
116  iEvent.put(std::make_unique<OnlineLuminosityRecord>(onlineLuminosityRecord));
117  iEvent.put(std::make_unique<reco::BeamSpot>(onlineBeamSpot));
118 }
119 
122 
124  matrix(0, 0) = beamSpot.errX * beamSpot.errX;
125  matrix(1, 1) = beamSpot.errY * beamSpot.errY;
126  matrix(2, 2) = beamSpot.errZ * beamSpot.errZ;
127  matrix(3, 3) = beamSpot.errSigmaZ * beamSpot.errSigmaZ;
128  matrix(4, 4) = beamSpot.errDxdz * beamSpot.errDxdz;
129  matrix(5, 5) = beamSpot.errDydz * beamSpot.errDydz;
130  matrix(6, 6) = beamSpot.errWidthX * beamSpot.errWidthX;
131  // Note: errWidthY is not part of the CovarianceMatrix
132 
135 
136  bs.setBeamWidthY(beamSpot.widthY);
137 
138  return bs;
139 }
140 
141 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
144  desc.add<edm::InputTag>("onlineMetaDataInputLabel", edm::InputTag("rawDataCollector"));
145  descriptions.add("onlineMetaDataRawToDigi", desc);
146 }
147 
148 //define this as a plug-in
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:29
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const Luminosity_v1 luminosity
static const uint32_t length
Definition: FEDHeader.h:54
Class to contain the online luminosity from soft FED 1022.
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:27
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Class to contain DCS information from soft FED 1022.
Definition: DCSRecord.h:20
void produce(edm::Event &, const edm::EventSetup &) override
const Luminosity_v1 luminosity
int iEvent
Definition: GenABIO.cc:224
const CTPPS_v1 ctpps
reco::BeamSpot getBeamSpot(const online::BeamSpot_v1 &) const
edm::EDGetTokenT< FEDRawDataCollection > dataToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const BeamSpot_v1 beamSpot
const Luminosity_v1 luminosity
OnlineMetaDataRawToDigi(const edm::ParameterSet &)
const BeamSpot_v1 beamSpot
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const DCS_v1 dcs
bool isValid() const
Definition: HandleBase.h:70
Class to contain CTPPS information from soft FED 1022.
Definition: CTPPSRecord.h:20
const DCS_v1 dcs
HLT enums.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
const BeamSpot_v1 beamSpot
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
const DCS_v2 dcs
const CTPPS_v1 ctpps