CMS 3D CMS Logo

TotemVFATRawToDigi.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Authors:
5 * Jan Kašpar (jan.kaspar@gmail.com)
6 *
7 ****************************************************************************/
8 
16 
20 
22 
26 
30 
34 
36 
37 #include <string>
38 
40 public:
41  explicit TotemVFATRawToDigi(const edm::ParameterSet &);
42  ~TotemVFATRawToDigi() override;
43 
44  void produce(edm::Event &, const edm::EventSetup &) override;
45  void endStream() override;
46 
47 private:
49 
51 
52  std::vector<unsigned int> fedIds;
53 
57 
60 
61  template <typename DigiType>
62  void run(edm::Event &, const edm::EventSetup &);
63 };
64 
65 using namespace edm;
66 using namespace std;
67 
69  : subSystemName(conf.getParameter<string>("subSystem")),
70  subSystem(ssUndefined),
71  fedIds(conf.getParameter<vector<unsigned int>>("fedIds")),
72  rawDataUnpacker(conf.getParameterSet("RawUnpacking")),
73  rawToDigiConverter(conf.getParameterSet("RawToDigi")) {
74  fedDataToken = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("rawDataTag"));
75 
76  // validate chosen subSystem
77  if (subSystemName == "TrackingStrip")
79  else if (subSystemName == "TimingDiamond")
81  else if (subSystemName == "TotemTiming")
83 
84  if (subSystem == ssUndefined)
85  throw cms::Exception("TotemVFATRawToDigi::TotemVFATRawToDigi")
86  << "Unknown sub-system string " << subSystemName << "." << endl;
87 
88  // FED (OptoRx) headers and footers
89  produces<vector<TotemFEDInfo>>(subSystemName);
90 
91  // declare products
93  produces<DetSetVector<TotemRPDigi>>(subSystemName);
94 
95  else if (subSystem == ssTimingDiamond)
96  produces<DetSetVector<CTPPSDiamondDigi>>(subSystemName);
97 
98  else if (subSystem == ssTotemTiming)
99  produces<DetSetVector<TotemTimingDigi>>(subSystemName);
100 
101  // set default IDs
102  if (fedIds.empty()) {
103  if (subSystem == ssTrackingStrip) {
105  fedIds.push_back(id);
106 
108  fedIds.push_back(id);
109  }
110 
111  else if (subSystem == ssTimingDiamond) {
113  fedIds.push_back(id);
114  }
115 
116  else if (subSystem == ssTotemTiming) {
118  ++id)
119  fedIds.push_back(id);
120  }
121  }
122 
123  // conversion status
124  produces<DetSetVector<TotemVFATStatus>>(subSystemName);
125 
126  totemMappingToken = esConsumes<TotemDAQMapping, TotemReadoutRcd>(ESInputTag("", subSystemName));
127  analysisMaskToken = esConsumes<TotemAnalysisMask, TotemReadoutRcd>(ESInputTag("", subSystemName));
128 }
129 
131 
133  if (subSystem == ssTrackingStrip)
134  run<DetSetVector<TotemRPDigi>>(event, es);
135 
136  else if (subSystem == ssTimingDiamond)
137  run<DetSetVector<CTPPSDiamondDigi>>(event, es);
138 
139  else if (subSystem == ssTotemTiming)
140  run<DetSetVector<TotemTimingDigi>>(event, es);
141 }
142 
143 template <typename DigiType>
145  // get DAQ mapping
147 
148  // get analysis mask to mask channels
150 
151  // raw data handle
153  event.getByToken(fedDataToken, rawData);
154 
155  // book output products
156  vector<TotemFEDInfo> fedInfo;
157  DigiType digi;
158  DetSetVector<TotemVFATStatus> conversionStatus;
159 
160  // raw-data unpacking
161  SimpleVFATFrameCollection vfatCollection;
162  for (const auto &fedId : fedIds) {
163  const FEDRawData &data = rawData->FEDData(fedId);
164  if (data.size() > 0)
165  rawDataUnpacker.run(fedId, data, fedInfo, vfatCollection);
166  }
167 
168  // raw-to-digi conversion
169  rawToDigiConverter.run(vfatCollection, *mapping, *analysisMask, digi, conversionStatus);
170 
171  // commit products to event
172  event.put(make_unique<vector<TotemFEDInfo>>(fedInfo), subSystemName);
173  event.put(make_unique<DigiType>(digi), subSystemName);
174  event.put(make_unique<DetSetVector<TotemVFATStatus>>(conversionStatus), subSystemName);
175 }
176 
178 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< TotemAnalysisMask, TotemReadoutRcd > analysisMaskToken
pps::RawDataUnpacker rawDataUnpacker
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< TotemDAQMapping, TotemReadoutRcd > totemMappingToken
void run(edm::Event &, const edm::EventSetup &)
std::vector< unsigned int > fedIds
TotemVFATRawToDigi(const edm::ParameterSet &)
enum TotemVFATRawToDigi::@505 subSystem
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
int run(int fedId, const FEDRawData &data, std::vector< TotemFEDInfo > &fedInfoColl, SimpleVFATFrameCollection &coll) const
Unpack data from FED with fedId into ‘coll’ collection.
Collection of code to convert TOTEM raw data into digi.
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken
Collection of code for unpacking of TOTEM raw-data.
ParameterSet const & getParameterSet(ParameterSetID const &id)
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void printSummaries() const
Print error summaries.
RawToDigiConverter rawToDigiConverter
void produce(edm::Event &, const edm::EventSetup &) override
void run(const VFATFrameCollection &coll, const TotemDAQMapping &mapping, const TotemAnalysisMask &mask, edm::DetSetVector< TotemRPDigi > &digi, edm::DetSetVector< TotemVFATStatus > &status)
Creates RP digi.
Definition: event.py:1
void endStream() override