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 //
95  : eventCounter_(0), allDigiCounter_(0), allWordCounter_(0) {
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
ConfigurationDescriptions.h
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
CTPPSTotemDigiToRaw::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CTPPSTotemDigiToRaw.cc:174
FEDNumbering.h
edm::StreamID
Definition: StreamID.h:30
CTPPSTotemDigiToRaw::fPos_
TotemFramePosition fPos_
Definition: CTPPSTotemDigiToRaw.cc:78
Handle.h
TotemReadoutRcd.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
edm::ESWatcher< TotemReadoutRcd >
ESHandle.h
CTPPSTotemDigiToRaw::tTotemRPDigi_
edm::EDGetTokenT< edm::DetSetVector< TotemRPDigi > > tTotemRPDigi_
Definition: CTPPSTotemDigiToRaw.cc:76
CTPPSTotemDigiToRaw
Definition: CTPPSTotemDigiToRaw.cc:59
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
TotemDAQMapping.h
edm::LogInfo
Definition: MessageLogger.h:254
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
CTPPSTotemDataFormatter::nDigis
int nDigis() const
Definition: CTPPSTotemDataFormatter.h:54
CTPPSTotemDigiToRaw::allDigiCounter_
int allDigiCounter_
Definition: CTPPSTotemDigiToRaw.cc:72
CTPPSTotemDataFormatter::Digis
std::unordered_map< cms_uint32_t, DetDigis > Digis
Definition: CTPPSTotemDataFormatter.h:49
CTPPSTotemDataFormatter::PPSStripIndex
Definition: CTPPSTotemDataFormatter.h:56
TotemReadoutRcd
EventSetup record for TOTEM readout-related information.
Definition: TotemReadoutRcd.h:16
VFATFrameCollection.h
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
CTPPSTotemDigiToRaw::recordWatcher_
edm::ESWatcher< TotemReadoutRcd > recordWatcher_
Definition: CTPPSTotemDigiToRaw.cc:75
CTPPSTotemDigiToRaw::beginStream
void beginStream(edm::StreamID) override
Definition: CTPPSTotemDigiToRaw.cc:171
FEDRawData
Definition: FEDRawData.h:19
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:182
CTPPSTotemDataFormatter.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CTPPSTotemDigiToRaw::eventCounter_
unsigned long eventCounter_
Definition: CTPPSTotemDigiToRaw.cc:70
edm::ESHandle
Definition: DTSurvey.h:22
ParameterSetDescription.h
CTPPSTotemDataFormatter::RawData
std::unordered_map< int, FEDRawData > RawData
Definition: CTPPSTotemDataFormatter.h:47
CTPPSTotemDigiToRaw::CTPPSTotemDigiToRaw
CTPPSTotemDigiToRaw(const edm::ParameterSet &)
Definition: CTPPSTotemDigiToRaw.cc:94
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
TotemVFATStatus.h
CTPPSTotemDigiToRaw::~CTPPSTotemDigiToRaw
~CTPPSTotemDigiToRaw() override
Definition: CTPPSTotemDigiToRaw.cc:101
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
TotemFramePosition
Definition: TotemFramePosition.h:31
CTPPSTotemDataFormatter::compare
static bool compare(const PPSStripIndex &a, const PPSStripIndex &b)
Definition: CTPPSTotemDataFormatter.h:69
ModuleDef.h
TotemFramePosition.h
iEvent
int iEvent
Definition: GenABIO.cc:224
CTPPSTotemDigiToRaw::allWordCounter_
int allWordCounter_
Definition: CTPPSTotemDigiToRaw.cc:73
FEDRawDataCollection.h
CTPPSTotemDigiToRaw::v_iDdet2fed_
std::vector< CTPPSTotemDataFormatter::PPSStripIndex > v_iDdet2fed_
Definition: CTPPSTotemDigiToRaw.cc:77
CTPPSTotemDataFormatter::nWords
int nWords() const
Definition: CTPPSTotemDataFormatter.h:53
edm::stream::EDProducer
Definition: EDProducer.h:38
apvshotsanalyzer_cfi.digiCollection
digiCollection
Definition: apvshotsanalyzer_cfi.py:4
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
get
#define get
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
ESWatcher.h
TotemRPDetId.h
CTPPSTotemDigiToRaw::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CTPPSTotemDigiToRaw.cc:110
EventSetup.h
CTPPSTotemDigiToRaw::fedIds_
std::set< unsigned int > fedIds_
Definition: CTPPSTotemDigiToRaw.cc:71
CTPPSTotemDataFormatter
Definition: CTPPSTotemDataFormatter.h:37
ParameterSet.h
TotemRPDigi.h
edm::Event
Definition: Event.h:73
StreamID.h
taus_updatedMVAIds_cff.mapping
mapping
Definition: taus_updatedMVAIds_cff.py:28
CTPPSTotemDigiToRaw::debug_
bool debug_
Definition: CTPPSTotemDigiToRaw.cc:74
CTPPSTotemDataFormatter::formatRawData
void formatRawData(unsigned int lvl1_ID, RawData &fedRawData, const Digis &digis, std::vector< PPSStripIndex > v_iDdet2fed)
Definition: CTPPSTotemDataFormatter.cc:43
edm::InputTag
Definition: InputTag.h:15
DetIdCollection.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443