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
38 
42 
52 
55 //
56 // class declaration
57 //
58 
60 public:
61  explicit CTPPSTotemDigiToRaw(const edm::ParameterSet&);
62  ~CTPPSTotemDigiToRaw() override;
63 
64  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
65 
66 private:
67  void beginStream(edm::StreamID) override;
68  void produce(edm::Event&, const edm::EventSetup&) override;
69 
70  unsigned long eventCounter_;
71  std::set<unsigned int> fedIds_;
74  bool debug_;
77  std::vector<CTPPSTotemDataFormatter::PPSStripIndex> v_iDdet2fed_;
79 
80  // ----------member data ---------------------------
81 };
82 
83 //
84 // constants, enums and typedefs
85 //
86 
87 //
88 // static data member definitions
89 //
90 
91 //
92 // constructors and destructor
93 //
96  //register your products
97  tTotemRPDigi_ = consumes<edm::DetSetVector<TotemRPDigi>>(iConfig.getParameter<edm::InputTag>("InputLabel"));
98  produces<FEDRawDataCollection>();
99 }
100 
102  edm::LogInfo("CTPPSTotemDigiToRaw") << " CTPPSTotemDigiToRaw destructor!";
103 }
104 
105 //
106 // member functions
107 //
108 
109 // ------------ method called to produce the data ------------
111  using namespace edm;
112  using namespace std;
113  eventCounter_++;
114 
116  iEvent.getByToken(tTotemRPDigi_, digiCollection);
117 
120 
121  int digiCounter = 0;
122  for (auto const& di : *digiCollection) {
123  digiCounter += (di.data).size();
124  digis[di.detId()] = di.data;
125  }
126  allDigiCounter_ += digiCounter;
128  // label of the CTPPS sub-system
129  if (recordWatcher_.check(iSetup)) {
130  iSetup.get<TotemReadoutRcd>().get(mapping);
131  for (const auto& p : mapping->VFATMapping) {
132  //get TotemVFATInfo information
133  fedIds_.emplace(p.first.getFEDId());
134  CTPPSTotemDataFormatter::PPSStripIndex iDdet2fed = {(p.second.symbolicID).symbolicID,
135  p.second.hwID,
136  p.first.getFEDId(),
137  p.first.getIdxInFiber(),
138  p.first.getGOHId()};
139  v_iDdet2fed_.emplace_back(iDdet2fed);
140  }
141  }
142 
143  CTPPSTotemDataFormatter formatter(mapping->VFATMapping);
144 
145  // create product (raw data)
146  auto buffers = std::make_unique<FEDRawDataCollection>();
147 
149 
150  // convert data to raw
151  formatter.formatRawData(iEvent.id().event(), rawdata, digis, v_iDdet2fed_);
152 
153  // pack raw data into collection
154  for (auto it : fedIds_) {
155  FEDRawData& fedRawData = buffers->FEDData(it);
156  CTPPSTotemDataFormatter::RawData::iterator fedbuffer = rawdata.find(it);
157  if (fedbuffer != rawdata.end())
158  fedRawData = fedbuffer->second;
159  }
160  allWordCounter_ += formatter.nWords();
161 
162  if (debug_)
163  LogDebug("CTPPSTotemDigiToRaw") << "Words/Digis this iEvent: " << digiCounter << "(fm:" << formatter.nDigis()
164  << ")/" << formatter.nWords() << " all: " << allDigiCounter_ << "/"
165  << allWordCounter_;
166 
167  iEvent.put(std::move(buffers));
168 }
169 
170 // ------------ method called once each stream before processing any runs, lumis or events ------------
172 
173 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
176  desc.add<edm::InputTag>("InputLabel", edm::InputTag("RPSiDetDigitizer"));
177  descriptions.add("ctppsTotemRawData", desc);
178 }
179 
180 //define this as a plug-in
#define LogDebug(id)
size
Write out results.
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:40
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void beginStream(edm::StreamID) override
EventSetup record for TOTEM readout-related information.
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::unordered_map< int, FEDRawData > RawData
ParameterDescriptionBase * add(U const &iLabel, T const &value)
CTPPSTotemDigiToRaw(const edm::ParameterSet &)
static bool compare(const PPSStripIndex &a, const PPSStripIndex &b)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::map< TotemFramePosition, TotemVFATInfo > VFATMapping
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
edm::ESWatcher< TotemReadoutRcd > recordWatcher_
edm::EventID id() const
Definition: EventBase.h:59
edm::EDGetTokenT< edm::DetSetVector< TotemRPDigi > > tTotemRPDigi_
HLT enums.
T get() const
Definition: EventSetup.h:73
TotemFramePosition fPos_
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511
void formatRawData(unsigned int lvl1_ID, RawData &fedRawData, const Digis &digis, std::vector< PPSStripIndex > v_iDdet2fed)