CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
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 //----------------------------------------------------------------------------------------------------
63 
64 using namespace edm;
65 using namespace std;
66 
67 //----------------------------------------------------------------------------------------------------
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 {
76  fedDataToken = consumes<FEDRawDataCollection>(conf.getParameter<edm::InputTag>("rawDataTag"));
77 
78  // validate chosen subSystem
79  if (subSystemName == "TrackingStrip")
81  if (subSystemName == "TimingDiamond")
83 
84  if (subSystem == ssUndefined)
85  throw cms::Exception("TotemVFATRawToDigi::TotemVFATRawToDigi") << "Unknown sub-system string " << subSystemName << "." << endl;
86 
87  // FED (OptoRx) headers and footers
88  produces< vector<TotemFEDInfo> >(subSystemName);
89 
90  // declare products
92  produces< DetSetVector<TotemRPDigi> >(subSystemName);
93 
95  produces< DetSetVector<CTPPSDiamondDigi> >(subSystemName);
96 
97  // set default IDs
98  if (fedIds.empty())
99  {
100  if (subSystem == ssTrackingStrip)
101  {
103  fedIds.push_back(id);
104  }
105 
106  if (subSystem == ssTimingDiamond)
107  {
108 
110  fedIds.push_back(id);
111  }
112  }
113 
114  // conversion status
115  produces< DetSetVector<TotemVFATStatus> >(subSystemName);
116 }
117 
118 //----------------------------------------------------------------------------------------------------
119 
121 {
122 }
123 
124 //----------------------------------------------------------------------------------------------------
125 
127 {
128  if (subSystem == ssTrackingStrip)
129  run< DetSetVector<TotemRPDigi> >(event, es);
130 
131  if (subSystem == ssTimingDiamond)
132  run< DetSetVector<CTPPSDiamondDigi> >(event, es);
133 }
134 
135 //----------------------------------------------------------------------------------------------------
136 
137 template <typename DigiType>
139 {
140  // get DAQ mapping
142  es.get<TotemReadoutRcd>().get(subSystemName, mapping);
143 
144  // get analysis mask to mask channels
145  ESHandle<TotemAnalysisMask> analysisMask;
146  es.get<TotemReadoutRcd>().get(subSystemName, analysisMask);
147 
148  // raw data handle
150  event.getByToken(fedDataToken, rawData);
151 
152  // book output products
153  vector<TotemFEDInfo> fedInfo;
154  DigiType digi;
155  DetSetVector<TotemVFATStatus> conversionStatus;
156 
157  // raw-data unpacking
158  SimpleVFATFrameCollection vfatCollection;
159  for (const auto &fedId : fedIds)
160  {
161  const FEDRawData &data = rawData->FEDData(fedId);
162  if (data.size() > 0)
163  rawDataUnpacker.Run(fedId, data, fedInfo, vfatCollection);
164  }
165 
166  // raw-to-digi conversion
167  rawToDigiConverter.Run(vfatCollection, *mapping, *analysisMask, digi, conversionStatus);
168 
169  // commit products to event
170  event.put(make_unique<vector<TotemFEDInfo>>(fedInfo), subSystemName);
171  event.put(make_unique<DigiType>(digi), subSystemName);
172  event.put(make_unique<DetSetVector<TotemVFATStatus>>(conversionStatus), subSystemName);
173 }
174 
175 //----------------------------------------------------------------------------------------------------
176 
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.
enum TotemVFATRawToDigi::@318 subSystem
#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 &)
Collection of code for unpacking of TOTEM raw-data.
RawDataUnpacker rawDataUnpacker
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
Collection of code to convert TOTEM raw data into digi.
edm::EDGetTokenT< FEDRawDataCollection > fedDataToken
const T & get() const
Definition: EventSetup.h:56
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
RawToDigiConverter rawToDigiConverter
virtual void produce(edm::Event &, const edm::EventSetup &) 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.