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 
34 #include <string>
35 
36 //----------------------------------------------------------------------------------------------------
37 
39 {
40  public:
41  explicit TotemVFATRawToDigi(const edm::ParameterSet&);
43 
44  virtual void produce(edm::Event&, const edm::EventSetup&) override;
45  virtual void endStream() override;
46 
47  private:
49 
51 
52  std::vector<unsigned int> fedIds;
53 
55 
58 
59  template <typename DigiType>
60  void run(edm::Event&, const edm::EventSetup&);
61 };
62 
63 //----------------------------------------------------------------------------------------------------
64 
65 using namespace edm;
66 using namespace std;
67 
68 //----------------------------------------------------------------------------------------------------
69 
71  subSystemName(conf.getParameter<string>("subSystem")),
73  fedIds(conf.getParameter< vector<unsigned int> >("fedIds")),
74  rawDataUnpacker(conf.getParameterSet("RawUnpacking")),
75  rawToDigiConverter(conf.getParameterSet("RawToDigi"))
76 {
77  fedDataToken = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("rawDataTag"));
78 
79  // validate chosen subSystem
80  if (subSystemName == "TrackingStrip")
82  if (subSystemName == "TimingDiamond")
84 
85  if (subSystem == ssUndefined)
86  throw cms::Exception("TotemVFATRawToDigi::TotemVFATRawToDigi") << "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 
96  produces< DetSetVector<CTPPSDiamondDigi> >(subSystemName);
97 
98  // set default IDs
99  if (fedIds.empty())
100  {
101  if (subSystem == ssTrackingStrip)
102  {
104  fedIds.push_back(id);
105 
107  fedIds.push_back(id);
108  }
109 
110  if (subSystem == ssTimingDiamond)
111  {
112 
114  fedIds.push_back(id);
115  }
116  }
117 
118  // conversion status
119  produces< DetSetVector<TotemVFATStatus> >(subSystemName);
120 }
121 
122 //----------------------------------------------------------------------------------------------------
123 
125 {
126 }
127 
128 //----------------------------------------------------------------------------------------------------
129 
131 {
132  if (subSystem == ssTrackingStrip)
133  run< DetSetVector<TotemRPDigi> >(event, es);
134 
135  if (subSystem == ssTimingDiamond)
136  run< DetSetVector<CTPPSDiamondDigi> >(event, es);
137 }
138 
139 //----------------------------------------------------------------------------------------------------
140 
141 template <typename DigiType>
143 {
144  // get DAQ mapping
146  es.get<TotemReadoutRcd>().get(subSystemName, mapping);
147 
148  // get analysis mask to mask channels
149  ESHandle<TotemAnalysisMask> analysisMask;
150  es.get<TotemReadoutRcd>().get(subSystemName, analysisMask);
151 
152  // raw data handle
154  event.getByToken(fedDataToken, rawData);
155 
156  // book output products
157  vector<TotemFEDInfo> fedInfo;
158  DigiType digi;
159  DetSetVector<TotemVFATStatus> conversionStatus;
160 
161  // raw-data unpacking
162  SimpleVFATFrameCollection vfatCollection;
163  for (const auto &fedId : fedIds)
164  {
165  const FEDRawData &data = rawData->FEDData(fedId);
166  if (data.size() > 0)
167  rawDataUnpacker.Run(fedId, data, fedInfo, vfatCollection);
168  }
169 
170  // raw-to-digi conversion
171  rawToDigiConverter.Run(vfatCollection, *mapping, *analysisMask, digi, conversionStatus);
172 
173  // commit products to event
174  event.put(make_unique<vector<TotemFEDInfo>>(fedInfo), subSystemName);
175  event.put(make_unique<DigiType>(digi), subSystemName);
176  event.put(make_unique<DetSetVector<TotemVFATStatus>>(conversionStatus), subSystemName);
177 }
178 
179 //----------------------------------------------------------------------------------------------------
180 
182 {
184 }
185 
T getParameter(std::string const &) const
void Run(const VFATFrameCollection &coll, const TotemDAQMapping &mapping, const TotemAnalysisMask &mask, edm::DetSetVector< TotemRPDigi > &digi, edm::DetSetVector< TotemVFATStatus > &status)
Creates RP digi.
Collection of code for unpacking of TOTEM raw-data.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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:47
TotemVFATRawToDigi(const edm::ParameterSet &)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
enum TotemVFATRawToDigi::@332 subSystem
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
const T & get() const
Definition: EventSetup.h:55
ctpps::RawDataUnpacker rawDataUnpacker
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
RawToDigiConverter rawToDigiConverter
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition: event.py:1
virtual void endStream() override
int Run(int fedId, const FEDRawData &data, std::vector< TotemFEDInfo > &fedInfoColl, SimpleVFATFrameCollection &coll) const
Unpack data from FED with fedId into `coll&#39; collection.