CMS 3D CMS Logo

CTPPSTotemDigiToRaw.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: temp/CTPPSTotemDigiToRaw
4 // Class: CTPPSTotemDigiToRaw
5 //
13 //
14 // Original Author: Dilson De Jesus Damiao
15 // Maria Elena Pol
16 // Created: Tue, 11 Sep 2018 17:12:12 GMT
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
39 
43 
53 
56 //
57 // class declaration
58 //
59 
61 public:
62  explicit CTPPSTotemDigiToRaw(const edm::ParameterSet&);
63  ~CTPPSTotemDigiToRaw() override;
64 
65  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
66 
67 private:
68  void beginStream(edm::StreamID) override;
69  void produce(edm::Event&, const edm::EventSetup&) override;
70 
71  unsigned long eventCounter_;
72  std::set<unsigned int> fedIds_;
75  bool debug_;
79  std::vector<CTPPSTotemDataFormatter::PPSStripIndex> v_iDdet2fed_;
81 
82  // ----------member data ---------------------------
83 };
84 
85 //
86 // constants, enums and typedefs
87 //
88 
89 //
90 // static data member definitions
91 //
92 
93 //
94 // constructors and destructor
95 //
97  : eventCounter_(0), allDigiCounter_(0), allWordCounter_(0) {
98  //register your products
99  tTotemRPDigi_ = consumes<edm::DetSetVector<TotemRPDigi>>(iConfig.getParameter<edm::InputTag>("InputLabel"));
100  tTotemDAQMapping_ = esConsumes<TotemDAQMapping, TotemReadoutRcd>();
101  produces<FEDRawDataCollection>();
102 }
103 
105  edm::LogInfo("CTPPSTotemDigiToRaw") << " CTPPSTotemDigiToRaw destructor!";
106 }
107 
108 //
109 // member functions
110 //
111 
112 // ------------ method called to produce the data ------------
114  using namespace edm;
115  using namespace std;
116  eventCounter_++;
117 
119  iEvent.getByToken(tTotemRPDigi_, digiCollection);
120 
123 
124  int digiCounter = 0;
125  for (auto const& di : *digiCollection) {
126  digiCounter += (di.data).size();
127  digis[di.detId()] = di.data;
128  }
129  allDigiCounter_ += digiCounter;
131  // label of the CTPPS sub-system
132  if (recordWatcher_.check(iSetup)) {
134  for (const auto& p : mapping->VFATMapping) {
135  //get TotemVFATInfo information
136  fedIds_.emplace(p.first.getFEDId());
137  CTPPSTotemDataFormatter::PPSStripIndex iDdet2fed = {(p.second.symbolicID).symbolicID,
138  p.second.hwID,
139  p.first.getFEDId(),
140  p.first.getIdxInFiber(),
141  p.first.getGOHId()};
142  v_iDdet2fed_.emplace_back(iDdet2fed);
143  }
144  }
145 
146  CTPPSTotemDataFormatter formatter(mapping->VFATMapping);
147 
148  // create product (raw data)
149  auto buffers = std::make_unique<FEDRawDataCollection>();
150 
152 
153  // convert data to raw
154  formatter.formatRawData(iEvent.id().event(), rawdata, digis, v_iDdet2fed_);
155 
156  // pack raw data into collection
157  for (auto it : fedIds_) {
158  FEDRawData& fedRawData = buffers->FEDData(it);
159  CTPPSTotemDataFormatter::RawData::iterator fedbuffer = rawdata.find(it);
160  if (fedbuffer != rawdata.end())
161  fedRawData = fedbuffer->second;
162  }
163  allWordCounter_ += formatter.nWords();
164 
165  if (debug_)
166  LogDebug("CTPPSTotemDigiToRaw") << "Words/Digis this iEvent: " << digiCounter << "(fm:" << formatter.nDigis()
167  << ")/" << formatter.nWords() << " all: " << allDigiCounter_ << "/"
168  << allWordCounter_;
169 
170  iEvent.put(std::move(buffers));
171 }
172 
173 // ------------ method called once each stream before processing any runs, lumis or events ------------
175 
176 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
179  desc.add<edm::InputTag>("InputLabel", edm::InputTag("RPSiDetDigitizer"));
180  descriptions.add("ctppsTotemRawData", desc);
181 }
182 
183 //define this as a plug-in
size
Write out results.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void beginStream(edm::StreamID) override
std::set< unsigned int > fedIds_
std::unordered_map< cms_uint32_t, DetDigis > Digis
std::vector< CTPPSTotemDataFormatter::PPSStripIndex > v_iDdet2fed_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:224
std::unordered_map< int, FEDRawData > RawData
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
CTPPSTotemDigiToRaw(const edm::ParameterSet &)
Log< level::Info, false > LogInfo
static bool compare(const PPSStripIndex &a, const PPSStripIndex &b)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::ESGetToken< TotemDAQMapping, TotemReadoutRcd > tTotemDAQMapping_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESWatcher< TotemReadoutRcd > recordWatcher_
edm::EDGetTokenT< edm::DetSetVector< TotemRPDigi > > tTotemRPDigi_
HLT enums.
TotemFramePosition fPos_
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)
void formatRawData(unsigned int lvl1_ID, RawData &fedRawData, const Digis &digis, std::vector< PPSStripIndex > v_iDdet2fed)