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 * Nicola Minafra
7 * Laurent Forthomme
8 *
9 ****************************************************************************/
10 
18 
22 
26 
30 
34 
37 
38 #include <string>
39 
41 public:
42  explicit TotemVFATRawToDigi(const edm::ParameterSet &);
43  ~TotemVFATRawToDigi() override;
44 
45  void produce(edm::Event &, const edm::EventSetup &) override;
46  void endStream() override;
47 
48 private:
50 
52 
53  std::vector<unsigned int> fedIds;
54 
58 
61 
62  template <typename DigiType>
63  void run(edm::Event &, const edm::EventSetup &);
64 };
65 
66 using namespace edm;
67 using namespace std;
68 
70  : subSystemName(conf.getParameter<string>("subSystem")),
71  subSystem(ssUndefined),
72  fedIds(conf.getParameter<vector<unsigned int>>("fedIds")),
73  rawDataUnpacker(conf.getParameterSet("RawUnpacking")),
74  rawToDigiConverter(conf.getParameterSet("RawToDigi")) {
75  fedDataToken = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("rawDataTag"));
76 
77  // validate chosen subSystem
78  if (subSystemName == "TrackingStrip")
80  else if (subSystemName == "TimingDiamond")
82  else if (subSystemName == "TotemTiming")
84  else if (subSystemName == "TotemT2")
86 
87  if (subSystem == ssUndefined)
88  throw cms::Exception("TotemVFATRawToDigi::TotemVFATRawToDigi")
89  << "Unknown sub-system string " << subSystemName << "." << endl;
90 
91  // FED (OptoRx) headers and footers
92  produces<vector<TotemFEDInfo>>(subSystemName);
93 
94  // declare products
96  produces<DetSetVector<TotemRPDigi>>(subSystemName);
97 
98  else if (subSystem == ssTimingDiamond)
99  produces<DetSetVector<CTPPSDiamondDigi>>(subSystemName);
100 
101  else if (subSystem == ssTotemTiming)
102  produces<DetSetVector<TotemTimingDigi>>(subSystemName);
103 
104  else if (subSystem == ssTotemT2)
105  produces<edmNew::DetSetVector<TotemT2Digi>>(subSystemName);
106 
107  // set default IDs
108  if (fedIds.empty()) {
109  if (subSystem == ssTrackingStrip) {
111  fedIds.push_back(id);
112 
114  fedIds.push_back(id);
115  }
116 
117  else if (subSystem == ssTimingDiamond) {
119  fedIds.push_back(id);
120  }
121 
122  else if (subSystem == ssTotemTiming) {
124  ++id)
125  fedIds.push_back(id);
126  }
127 
128  else if (subSystem == ssTotemT2) {
130  fedIds.push_back(id);
131  }
132  }
133 
134  // conversion status
135  produces<DetSetVector<TotemVFATStatus>>(subSystemName);
136 
137  totemMappingToken = esConsumes<TotemDAQMapping, TotemReadoutRcd>(ESInputTag("", subSystemName));
138  analysisMaskToken = esConsumes<TotemAnalysisMask, TotemReadoutRcd>(ESInputTag("", subSystemName));
139 }
140 
142 
144  if (subSystem == ssTrackingStrip)
145  run<DetSetVector<TotemRPDigi>>(event, es);
146 
147  else if (subSystem == ssTimingDiamond)
148  run<DetSetVector<CTPPSDiamondDigi>>(event, es);
149 
150  else if (subSystem == ssTotemTiming)
151  run<DetSetVector<TotemTimingDigi>>(event, es);
152 
153  else if (subSystem == ssTotemT2)
154  run<edmNew::DetSetVector<TotemT2Digi>>(event, es);
155 }
156 
157 template <typename DigiType>
159  // get DAQ mapping
161 
162  // get analysis mask to mask channels
164 
165  // raw data handle
167  event.getByToken(fedDataToken, rawData);
168 
169  // book output products
170  vector<TotemFEDInfo> fedInfo;
171  DigiType digi;
172  DetSetVector<TotemVFATStatus> conversionStatus;
173 
174  // raw-data unpacking
175  SimpleVFATFrameCollection vfatCollection;
176  for (const auto &fedId : fedIds) {
177  const FEDRawData &data = rawData->FEDData(fedId);
178  if (data.size() > 0)
179  rawDataUnpacker.run(fedId, data, fedInfo, vfatCollection);
180  }
181 
182  // raw-to-digi conversion
183  rawToDigiConverter.run(vfatCollection, *mapping, *analysisMask, digi, conversionStatus);
184 
185  // commit products to event
186  event.put(make_unique<vector<TotemFEDInfo>>(fedInfo), subSystemName);
187  event.put(make_unique<DigiType>(digi), subSystemName);
188  event.put(make_unique<DetSetVector<TotemVFATStatus>>(conversionStatus), subSystemName);
189 }
190 
192 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< TotemAnalysisMask, TotemReadoutRcd > analysisMaskToken
pps::RawDataUnpacker rawDataUnpacker
edm::ESGetToken< TotemDAQMapping, TotemReadoutRcd > totemMappingToken
enum TotemVFATRawToDigi::@504 subSystem
void run(edm::Event &, const edm::EventSetup &)
std::vector< unsigned int > fedIds
TotemVFATRawToDigi(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
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