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 
15 
19 
21 
25 
29 
33 
35 
36 #include <string>
37 
39 public:
40  explicit TotemVFATRawToDigi(const edm::ParameterSet &);
41  ~TotemVFATRawToDigi() override;
42 
43  void produce(edm::Event &, const edm::EventSetup &) override;
44  void endStream() override;
45 
46 private:
48 
50 
51  std::vector<unsigned int> fedIds;
52 
54 
57 
58  template <typename DigiType>
59  void run(edm::Event &, const edm::EventSetup &);
60 };
61 
62 using namespace edm;
63 using namespace std;
64 
66  : subSystemName(conf.getParameter<string>("subSystem")),
68  fedIds(conf.getParameter<vector<unsigned int>>("fedIds")),
69  rawDataUnpacker(conf.getParameterSet("RawUnpacking")),
70  rawToDigiConverter(conf.getParameterSet("RawToDigi")) {
71  fedDataToken = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("rawDataTag"));
72 
73  // validate chosen subSystem
74  if (subSystemName == "TrackingStrip")
76  else if (subSystemName == "TimingDiamond")
78  else if (subSystemName == "TotemTiming")
80 
81  if (subSystem == ssUndefined)
82  throw cms::Exception("TotemVFATRawToDigi::TotemVFATRawToDigi")
83  << "Unknown sub-system string " << subSystemName << "." << endl;
84 
85  // FED (OptoRx) headers and footers
86  produces<vector<TotemFEDInfo>>(subSystemName);
87 
88  // declare products
90  produces<DetSetVector<TotemRPDigi>>(subSystemName);
91 
92  else if (subSystem == ssTimingDiamond)
93  produces<DetSetVector<CTPPSDiamondDigi>>(subSystemName);
94 
95  else if (subSystem == ssTotemTiming)
96  produces<DetSetVector<TotemTimingDigi>>(subSystemName);
97 
98  // set default IDs
99  if (fedIds.empty()) {
100  if (subSystem == ssTrackingStrip) {
102  fedIds.push_back(id);
103 
105  fedIds.push_back(id);
106  }
107 
108  else if (subSystem == ssTimingDiamond) {
110  fedIds.push_back(id);
111  }
112 
113  else if (subSystem == ssTotemTiming) {
115  ++id)
116  fedIds.push_back(id);
117  }
118  }
119 
120  // conversion status
121  produces<DetSetVector<TotemVFATStatus>>(subSystemName);
122 }
123 
125 
127  if (subSystem == ssTrackingStrip)
128  run<DetSetVector<TotemRPDigi>>(event, es);
129 
130  else if (subSystem == ssTimingDiamond)
131  run<DetSetVector<CTPPSDiamondDigi>>(event, es);
132 
133  else if (subSystem == ssTotemTiming)
134  run<DetSetVector<TotemTimingDigi>>(event, es);
135 }
136 
137 template <typename DigiType>
139  // get DAQ mapping
141  es.get<TotemReadoutRcd>().get(subSystemName, mapping);
142 
143  // get analysis mask to mask channels
144  ESHandle<TotemAnalysisMask> analysisMask;
145  es.get<TotemReadoutRcd>().get(subSystemName, analysisMask);
146 
147  // raw data handle
149  event.getByToken(fedDataToken, rawData);
150 
151  // book output products
152  vector<TotemFEDInfo> fedInfo;
153  DigiType digi;
154  DetSetVector<TotemVFATStatus> conversionStatus;
155 
156  // raw-data unpacking
157  SimpleVFATFrameCollection vfatCollection;
158  for (const auto &fedId : fedIds) {
159  const FEDRawData &data = rawData->FEDData(fedId);
160  if (data.size() > 0)
161  rawDataUnpacker.run(fedId, data, fedInfo, vfatCollection);
162  }
163 
164  // raw-to-digi conversion
165  rawToDigiConverter.run(vfatCollection, *mapping, *analysisMask, digi, conversionStatus);
166 
167  // commit products to event
168  event.put(make_unique<vector<TotemFEDInfo>>(fedInfo), subSystemName);
169  event.put(make_unique<DigiType>(digi), subSystemName);
170  event.put(make_unique<DetSetVector<TotemVFATStatus>>(conversionStatus), subSystemName);
171 }
172 
174 
T getParameter(std::string const &) const
pps::RawDataUnpacker rawDataUnpacker
enum TotemVFATRawToDigi::@426 subSystem
ParameterSet const & getParameterSet(ParameterSetID const &id)
EventSetup record for TOTEM readout-related information.
void run(edm::Event &, const edm::EventSetup &)
std::vector< unsigned int > fedIds
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
TotemVFATRawToDigi(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int run(int fedId, const FEDRawData &data, std::vector< TotemFEDInfo > &fedInfoColl, SimpleVFATFrameCollection &coll) const
Unpack data from FED with fedId into `coll&#39; collection.
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void printSummaries() const
Print error summaries.
Collection of code to convert TOTEM raw data into digi.
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken
Collection of code for unpacking of TOTEM raw-data.
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
T get() const
Definition: EventSetup.h:73
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