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 
18 // system include files
19 #include <memory>
20 #include <iostream>
21 
22 // user include files
25 
28 
30 
32 
36 
41 
42 
43 //
44 // class declaration
45 //
46 
47 
49 public:
51  ~OnlineMetaDataRawToDigi() override;
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 private:
56  void produce(edm::Event&, const edm::EventSetup&) override;
58 
60 };
61 
63 {
64  edm::InputTag dataLabel = iConfig.getParameter<edm::InputTag>("onlineMetaDataInputLabel");
65  dataToken_=consumes<FEDRawDataCollection>(dataLabel);
66 
67  produces<CTPPSRecord>();
68  produces<DCSRecord>();
69  produces<OnlineLuminosityRecord>();
70  produces<reco::BeamSpot>();
71 }
72 
73 
75 
76 
77 //
78 // member functions
79 //
80 
81 // ------------ method called to produce the data ------------
83 {
84  using namespace edm;
85 
87  iEvent.getByToken(dataToken_,rawdata);
88 
89  DCSRecord dcsRecord;
90  CTPPSRecord ctppsRecord;
91  OnlineLuminosityRecord onlineLuminosityRecord;
93 
94  if( rawdata.isValid() ) {
95  const FEDRawData& onlineMetaDataRaw = rawdata->FEDData(FEDNumbering::MINMetaDataSoftFEDID);
96  const unsigned char* payload = onlineMetaDataRaw.data() + FEDHeader::length;
97 
98  if ( onlineMetaDataRaw.size() >= FEDHeader::length + sizeof(uint8_t) ) {
99  const uint8_t version = *(reinterpret_cast<uint8_t const*>(payload));
100  if ( version == 1 && onlineMetaDataRaw.size() >= FEDHeader::length + sizeof(online::Data_v1) ) {
101  online::Data_v1 const* onlineMetaData = reinterpret_cast<online::Data_v1 const*>(payload);
102  dcsRecord = DCSRecord(onlineMetaData->dcs);
103  onlineLuminosityRecord = OnlineLuminosityRecord(onlineMetaData->luminosity);
104  onlineBeamSpot = getBeamSpot(onlineMetaData->beamSpot);
105  }
106  else if ( version == 2 && onlineMetaDataRaw.size() >= FEDHeader::length + sizeof(online::Data_v2) ) {
107  online::Data_v2 const* onlineMetaData = reinterpret_cast<online::Data_v2 const*>(payload);
108  ctppsRecord = CTPPSRecord(onlineMetaData->ctpps);
109  dcsRecord = DCSRecord(onlineMetaData->dcs);
110  onlineLuminosityRecord = OnlineLuminosityRecord(onlineMetaData->luminosity);
111  onlineBeamSpot = getBeamSpot(onlineMetaData->beamSpot);
112  }
113  }
114  }
115 
116  iEvent.put(std::make_unique<CTPPSRecord>(ctppsRecord));
117  iEvent.put(std::make_unique<DCSRecord>(dcsRecord));
118  iEvent.put(std::make_unique<OnlineLuminosityRecord>(onlineLuminosityRecord));
119  iEvent.put(std::make_unique<reco::BeamSpot>(onlineBeamSpot));
120 }
121 
122 
124 {
125  reco::BeamSpot::Point point(beamSpot.x,beamSpot.y,beamSpot.z);
126 
128  matrix(0,0) = beamSpot.errX*beamSpot.errX;
129  matrix(1,1) = beamSpot.errY*beamSpot.errY;
130  matrix(2,2) = beamSpot.errZ*beamSpot.errZ;
131  matrix(3,3) = beamSpot.errSigmaZ*beamSpot.errSigmaZ;
132  matrix(4,4) = beamSpot.errDxdz*beamSpot.errDxdz;
133  matrix(5,5) = beamSpot.errDydz*beamSpot.errDydz;
134  matrix(6,6) = beamSpot.errWidthX*beamSpot.errWidthX;
135  // Note: errWidthY is not part of the CovarianceMatrix
136 
137  reco::BeamSpot bs(point,
138  beamSpot.sigmaZ,
139  beamSpot.dxdz,
140  beamSpot.dydz,
141  beamSpot.widthX,
142  matrix,
144 
145  bs.setBeamWidthY(beamSpot.widthY);
146 
147  return bs;
148 }
149 
150 
151 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
154  desc.add<edm::InputTag>("onlineMetaDataInputLabel",edm::InputTag("rawDataCollector"));
155  descriptions.add("onlineMetaDataRawToDigi", desc);
156 }
157 
158 //define this as a plug-in
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:31
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
const Luminosity_v1 luminosity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
static const uint32_t length
Definition: FEDHeader.h:54
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Class to contain the online luminosity from soft FED 1022.
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Class to contain DCS information from soft FED 1022.
Definition: DCSRecord.h:22
void produce(edm::Event &, const edm::EventSetup &) override
const Luminosity_v1 luminosity
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int iEvent
Definition: GenABIO.cc:230
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void setBeamWidthY(double v)
Definition: BeamSpot.h:109
const CTPPS_v1 ctpps
edm::EDGetTokenT< FEDRawDataCollection > dataToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
reco::BeamSpot getBeamSpot(const online::BeamSpot_v1 &) const
OnlineMetaDataRawToDigi(const edm::ParameterSet &)
const BeamSpot_v1 beamSpot
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const DCS_v1 dcs
Class to contain CTPPS information from soft FED 1022.
Definition: CTPPSRecord.h:22
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:28
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