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 
55 
58 
59 //
60 // class declaration
61 //
62 
64 public:
65  explicit CTPPSPixelDigiToRaw(const edm::ParameterSet&);
66  ~CTPPSPixelDigiToRaw() override;
67 
68  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
69 
70 private:
71  void produce(edm::Event&, const edm::EventSetup&) override;
72 
73  // ----------member data ---------------------------
74  unsigned long eventCounter_;
77  bool debug_;
78  std::set<unsigned int> fedIds_;
83  std::vector<CTPPSPixelDataFormatter::PPSPixelIndex> v_iDdet2fed_;
85 };
86 
87 //
88 // constants, enums and typedefs
89 //
90 
91 //
92 // static data member definitions
93 //
94 
95 //
96 // constructors and destructor
97 //
99  : eventCounter_(0),
100  allDigiCounter_(0),
101  allWordCounter_(0),
102  mappingLabel_(iConfig.getParameter<std::string>("mappingLabel")) {
103  //register your products
104  tCTPPSPixelDigi_ = consumes<edm::DetSetVector<CTPPSPixelDigi>>(iConfig.getParameter<edm::InputTag>("InputLabel"));
105  tCTPPSPixelDAQMapping_ = esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>();
106 
107  // Define EDProduct type
108  produces<FEDRawDataCollection>();
109 }
110 
112 
113 //
114 // member functions
115 //
116 
117 // ------------ method called to produce the data ------------
119  using namespace edm;
120  using namespace std;
121 
122  eventCounter_++;
123 
126 
129 
130  int digiCounter = 0;
131  for (auto const& di : *digiCollection) {
132  digiCounter += (di.data).size();
133  digis[di.id] = di.data;
134  }
135  allDigiCounter_ += digiCounter;
137  if (recordWatcher_.check(iSetup)) {
139  for (const auto& p : mapping->ROCMapping)
141  p.second.iD, p.second.roc, p.first.getROC(), p.first.getFEDId(), p.first.getChannelIdx()});
142  fedIds_ = mapping->fedIds();
143  }
144  CTPPSPixelDataFormatter formatter(mapping->ROCMapping);
145 
146  // create product (raw data)
147  auto buffers = std::make_unique<FEDRawDataCollection>();
148 
150 
151  // convert data to raw
152  formatter.formatRawData(iEvent.id().event(), rawdata, digis, v_iDdet2fed_);
153 
154  // pack raw data into collection
155  for (auto it = fedIds_.begin(); it != fedIds_.end(); it++) {
156  FEDRawData& fedRawData = buffers->FEDData(*it);
157  CTPPSPixelDataFormatter::RawData::iterator fedbuffer = rawdata.find(*it);
158  if (fedbuffer != rawdata.end())
159  fedRawData = fedbuffer->second;
160  }
161  allWordCounter_ += formatter.nWords();
162 
163  if (debug_)
164  LogDebug("CTPPSPixelDigiToRaw") << "Words/Digis this iEvent: " << digiCounter << "(fm:" << formatter.nDigis()
165  << ")/" << formatter.nWords() << " all: " << allDigiCounter_ << "/"
166  << allWordCounter_;
167 
168  iEvent.put(std::move(buffers));
169 }
170 
171 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
174  desc.add<edm::InputTag>("InputLabel", edm::InputTag("RPixDetDigitizer"));
175  desc.add<std::string>("mappingLabel", "RPix");
176  descriptions.add("ctppsPixelRawData", desc);
177 }
178 
179 //define this as a plug-in
ConfigurationDescriptions.h
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
Handle.h
MessageLogger.h
CTPPSPixelDataFormatter::nWords
int nWords() const
Definition: CTPPSPixelDataFormatter.h:72
CTPPSPixelDAQMappingRcd.h
CTPPSPixelDigiToRaw::eventCounter_
unsigned long eventCounter_
Definition: CTPPSPixelDigiToRaw.cc:74
CTPPSPixelDigiToRaw::allWordCounter_
int allWordCounter_
Definition: CTPPSPixelDigiToRaw.cc:76
edm::ESWatcher< CTPPSPixelDAQMappingRcd >
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
CTPPSPixelDigiToRaw::debug_
bool debug_
Definition: CTPPSPixelDigiToRaw.cc:77
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CTPPSPixelFramePosition.h
CTPPSPixelFramePosition
Definition: CTPPSPixelFramePosition.h:27
EDProducer.h
CTPPSPixelDigiToRaw::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CTPPSPixelDigiToRaw.cc:172
CTPPSPixelDataFormatter.h
CTPPSPixelDigiToRaw
Definition: CTPPSPixelDigiToRaw.cc:63
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
FEDRawData
Definition: FEDRawData.h:19
CTPPSPixelDigiToRaw::v_iDdet2fed_
std::vector< CTPPSPixelDataFormatter::PPSPixelIndex > v_iDdet2fed_
Definition: CTPPSPixelDigiToRaw.cc:83
MakerMacros.h
l1t_dqm_sourceclient-live_cfg.fedRawData
fedRawData
Definition: l1t_dqm_sourceclient-live_cfg.py:188
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
CTPPSPixelDigiToRaw::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CTPPSPixelDigiToRaw.cc:118
edm::ESHandle
Definition: DTSurvey.h:22
CTPPSPixelDigiToRaw::fedIds_
std::set< unsigned int > fedIds_
Definition: CTPPSPixelDigiToRaw.cc:78
CTPPSPixelDataFormatter::PPSPixelIndex
Definition: CTPPSPixelDataFormatter.h:78
ParameterSetDescription.h
CTPPSPixelDataFormatter::RawData
std::unordered_map< int, FEDRawData > RawData
Definition: CTPPSPixelDataFormatter.h:57
CTPPSPixelDigiToRaw::mappingLabel_
std::string mappingLabel_
Definition: CTPPSPixelDigiToRaw.cc:79
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSPixelDigiToRaw::CTPPSPixelDigiToRaw
CTPPSPixelDigiToRaw(const edm::ParameterSet &)
Definition: CTPPSPixelDigiToRaw.cc:98
CTPPSPixelDataFormatter::compare
static bool compare(const PPSPixelIndex &a, const PPSPixelIndex &b)
Definition: CTPPSPixelDataFormatter.h:91
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CTPPSPixelDigiToRaw::allDigiCounter_
int allDigiCounter_
Definition: CTPPSPixelDigiToRaw.cc:75
CTPPSPixelDataFormatter::Digis
std::unordered_map< cms_uint32_t, DetDigis > Digis
Definition: CTPPSPixelDataFormatter.h:66
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
FEDRawDataCollection.h
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::stream::EDProducer
Definition: EDProducer.h:38
apvshotsanalyzer_cfi.digiCollection
digiCollection
Definition: apvshotsanalyzer_cfi.py:4
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
edm::ESGetToken< CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd >
CTPPSPixelDigiToRaw::tCTPPSPixelDigi_
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelDigi > > tCTPPSPixelDigi_
Definition: CTPPSPixelDigiToRaw.cc:81
CTPPSPixelDigi.h
CTPPSPixelDataFormatter::nDigis
int nDigis() const
Definition: CTPPSPixelDataFormatter.h:76
InputTag.h
CTPPSPixelDataFormatter
Definition: CTPPSPixelDataFormatter.h:53
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
CTPPSPixelDigiToRaw::recordWatcher_
edm::ESWatcher< CTPPSPixelDAQMappingRcd > recordWatcher_
Definition: CTPPSPixelDigiToRaw.cc:80
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
CTPPSPixelDAQMapping.h
CTPPSPixelDigiToRaw::fPos_
CTPPSPixelFramePosition fPos_
Definition: CTPPSPixelDigiToRaw.cc:84
CTPPSPixelDigiToRaw::~CTPPSPixelDigiToRaw
~CTPPSPixelDigiToRaw() override
Definition: CTPPSPixelDigiToRaw.cc:111
Frameworkfwd.h
ESWatcher.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CTPPSPixelDigiToRaw::tCTPPSPixelDAQMapping_
edm::ESGetToken< CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd > tCTPPSPixelDAQMapping_
Definition: CTPPSPixelDigiToRaw.cc:82
ParameterSet.h
edm::Event
Definition: Event.h:73
CTPPSPixelDataFormatter::formatRawData
void formatRawData(unsigned int lvl1_ID, RawData &fedRawData, const Digis &digis, std::vector< PPSPixelIndex > v_iDdet2fed)
Definition: CTPPSPixelDataFormatter.cc:190
StreamID.h
taus_updatedMVAIds_cff.mapping
mapping
Definition: taus_updatedMVAIds_cff.py:29
edm::InputTag
Definition: InputTag.h:15
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443