CMS 3D CMS Logo

CTPPSPixelDigiToRaw.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CTPPSPixelDigiToRaw
4 // Class: CTPPSPixelDigiToRaw
5 //
13 //
14 // Original Author: Dilson De Jesus Damiao
15 // Maria Elena Pol
16 // Created: Wed, 12 Sep 2018 12:59:49 GMT
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
32 
40 
42 
44 
49 
51 
56 
59 
60 //
61 // class declaration
62 //
63 
65 public:
66  explicit CTPPSPixelDigiToRaw(const edm::ParameterSet&);
67  ~CTPPSPixelDigiToRaw() override;
68 
69  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
70 
71 private:
72  void produce(edm::Event&, const edm::EventSetup&) override;
73 
74  // ----------member data ---------------------------
75  unsigned long eventCounter_;
78  bool debug_;
79  std::set<unsigned int> fedIds_;
84  std::vector<CTPPSPixelDataFormatter::PPSPixelIndex> v_iDdet2fed_;
87  bool isRun3_;
88 };
89 
90 //
91 // constants, enums and typedefs
92 //
93 
94 //
95 // static data member definitions
96 //
97 
98 //
99 // constructors and destructor
100 //
102  : eventCounter_(0),
103  allDigiCounter_(0),
104  allWordCounter_(0),
105  debug_(false),
106  mappingLabel_(iConfig.getParameter<std::string>("mappingLabel")),
107  eSummary_("CTPPSPixelDataFormatter", "[ctppsPixelRawToDigi]", false) {
108  //register your products
109  tCTPPSPixelDigi_ = consumes<edm::DetSetVector<CTPPSPixelDigi>>(iConfig.getParameter<edm::InputTag>("InputLabel"));
110  tCTPPSPixelDAQMapping_ = esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>();
111 
112  // Define EDProduct type
113  produces<FEDRawDataCollection>();
114 
115  isRun3_ = iConfig.getParameter<bool>("isRun3");
116 }
117 
119 
120 //
121 // member functions
122 //
123 
124 // ------------ method called to produce the data ------------
126  using namespace edm;
127  using namespace std;
128 
129  eventCounter_++;
130 
133 
136 
137  int digiCounter = 0;
138  for (auto const& di : *digiCollection) {
139  digiCounter += (di.data).size();
140  digis[di.id] = di.data;
141  }
142  allDigiCounter_ += digiCounter;
144 
146  for (const auto& p : mapping->ROCMapping)
148  p.second.iD, p.second.roc, p.first.getROC(), p.first.getFEDId(), p.first.getChannelIdx()});
149  fedIds_ = mapping->fedIds();
150 
151  CTPPSPixelDataFormatter formatter(mapping->ROCMapping, eSummary_);
152 
153  // create product (raw data)
154  auto buffers = std::make_unique<FEDRawDataCollection>();
155 
157 
158  // convert data to raw
159  formatter.formatRawData(isRun3_, iEvent.id().event(), rawdata, digis, v_iDdet2fed_);
160 
161  // pack raw data into collection
162  for (auto it = fedIds_.begin(); it != fedIds_.end(); it++) {
163  FEDRawData& fedRawData = buffers->FEDData(*it);
164  CTPPSPixelDataFormatter::RawData::iterator fedbuffer = rawdata.find(*it);
165  if (fedbuffer != rawdata.end())
166  fedRawData = fedbuffer->second;
167  }
168  allWordCounter_ += formatter.nWords();
169 
170  if (debug_)
171  LogDebug("CTPPSPixelDigiToRaw") << "Words/Digis this iEvent: " << digiCounter << "(fm:" << formatter.nDigis()
172  << ")/" << formatter.nWords() << " all: " << allDigiCounter_ << "/"
173  << allWordCounter_;
174 
175  iEvent.put(std::move(buffers));
176 }
177 
178 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
181  desc.add<bool>("isRun3", true);
182  desc.add<edm::InputTag>("InputLabel", edm::InputTag("RPixDetDigitizer"));
183  desc.add<std::string>("mappingLabel", "RPix");
184  descriptions.add("ctppsPixelRawData", desc);
185 }
186 
187 //define this as a plug-in
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unordered_map< int, FEDRawData > RawData
edm::ESWatcher< CTPPSPixelDAQMappingRcd > recordWatcher_
static bool compare(const PPSPixelIndex &a, const PPSPixelIndex &b)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
std::unordered_map< cms_uint32_t, DetDigis > Digis
std::vector< CTPPSPixelDataFormatter::PPSPixelIndex > v_iDdet2fed_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelDigi > > tCTPPSPixelDigi_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
void formatRawData(const bool &isRun3, unsigned int lvl1_ID, RawData &fedRawData, const Digis &digis, std::vector< PPSPixelIndex > v_iDdet2fed)
void produce(edm::Event &, const edm::EventSetup &) override
edm::ESGetToken< CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd > tCTPPSPixelDAQMapping_
CTPPSPixelFramePosition fPos_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
CTPPSPixelErrorSummary eSummary_
CTPPSPixelDigiToRaw(const edm::ParameterSet &)
std::set< unsigned int > fedIds_
HLT enums.
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)