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 
39 
41 
43 
48 
50 
54 
57 
58 //
59 // class declaration
60 //
61 
63 public:
64  explicit CTPPSPixelDigiToRaw(const edm::ParameterSet&);
65  ~CTPPSPixelDigiToRaw() override;
66 
67  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
68 
69 private:
70  void produce(edm::Event&, const edm::EventSetup&) override;
71 
72  // ----------member data ---------------------------
73  unsigned long eventCounter_;
76  bool debug_;
77  std::set<unsigned int> fedIds_;
81  std::vector<CTPPSPixelDataFormatter::PPSPixelIndex> v_iDdet2fed_;
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),
98  allDigiCounter_(0),
99  allWordCounter_(0),
100  mappingLabel_(iConfig.getParameter<std::string>("mappingLabel")) {
101  //register your products
102  tCTPPSPixelDigi_ = consumes<edm::DetSetVector<CTPPSPixelDigi>>(iConfig.getParameter<edm::InputTag>("InputLabel"));
103 
104  // Define EDProduct type
105  produces<FEDRawDataCollection>();
106 }
107 
109 
110 //
111 // member functions
112 //
113 
114 // ------------ method called to produce the data ------------
116  using namespace edm;
117  using namespace std;
118 
119  eventCounter_++;
120 
123 
126 
127  int digiCounter = 0;
128  for (auto const& di : *digiCollection) {
129  digiCounter += (di.data).size();
130  digis[di.id] = di.data;
131  }
132  allDigiCounter_ += digiCounter;
134  if (recordWatcher_.check(iSetup)) {
136  for (const auto& p : mapping->ROCMapping)
138  p.second.iD, p.second.roc, p.first.getROC(), p.first.getFEDId(), p.first.getChannelIdx()});
139  fedIds_ = mapping->fedIds();
140  }
141  CTPPSPixelDataFormatter formatter(mapping->ROCMapping);
142 
143  // create product (raw data)
144  auto buffers = std::make_unique<FEDRawDataCollection>();
145 
147 
148  // convert data to raw
149  formatter.formatRawData(iEvent.id().event(), rawdata, digis, v_iDdet2fed_);
150 
151  // pack raw data into collection
152  for (auto it = fedIds_.begin(); it != fedIds_.end(); it++) {
153  FEDRawData& fedRawData = buffers->FEDData(*it);
154  CTPPSPixelDataFormatter::RawData::iterator fedbuffer = rawdata.find(*it);
155  if (fedbuffer != rawdata.end())
156  fedRawData = fedbuffer->second;
157  }
158  allWordCounter_ += formatter.nWords();
159 
160  if (debug_)
161  LogDebug("CTPPSPixelDigiToRaw") << "Words/Digis this iEvent: " << digiCounter << "(fm:" << formatter.nDigis()
162  << ")/" << formatter.nWords() << " all: " << allDigiCounter_ << "/"
163  << allWordCounter_;
164 
165  iEvent.put(std::move(buffers));
166 }
167 
168 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
171  desc.add<edm::InputTag>("InputLabel", edm::InputTag("RPixDetDigitizer"));
172  desc.add<std::string>("mappingLabel", "RPix");
173  descriptions.add("ctppsPixelRawData", desc);
174 }
175 
176 //define this as a plug-in
ConfigurationDescriptions.h
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
Handle.h
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
CTPPSPixelDataFormatter::nWords
int nWords() const
Definition: CTPPSPixelDataFormatter.h:72
CTPPSPixelDAQMappingRcd.h
CTPPSPixelDigiToRaw::eventCounter_
unsigned long eventCounter_
Definition: CTPPSPixelDigiToRaw.cc:73
CTPPSPixelDigiToRaw::allWordCounter_
int allWordCounter_
Definition: CTPPSPixelDigiToRaw.cc:75
edm::ESWatcher< CTPPSPixelDAQMappingRcd >
ESHandle.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
CTPPSPixelDigiToRaw::debug_
bool debug_
Definition: CTPPSPixelDigiToRaw.cc:76
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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:169
CTPPSPixelDataFormatter.h
CTPPSPixelDigiToRaw
Definition: CTPPSPixelDigiToRaw.cc:62
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
FEDRawData
Definition: FEDRawData.h:19
CTPPSPixelDigiToRaw::v_iDdet2fed_
std::vector< CTPPSPixelDataFormatter::PPSPixelIndex > v_iDdet2fed_
Definition: CTPPSPixelDigiToRaw.cc:81
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: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:115
edm::ESHandle
Definition: DTSurvey.h:22
CTPPSPixelDAQMappingRcd
Definition: CTPPSPixelDAQMappingRcd.h:23
CTPPSPixelDigiToRaw::fedIds_
std::set< unsigned int > fedIds_
Definition: CTPPSPixelDigiToRaw.cc:77
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:78
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSPixelDigiToRaw::CTPPSPixelDigiToRaw
CTPPSPixelDigiToRaw(const edm::ParameterSet &)
Definition: CTPPSPixelDigiToRaw.cc:96
CTPPSPixelDataFormatter::compare
static bool compare(const PPSPixelIndex &a, const PPSPixelIndex &b)
Definition: CTPPSPixelDataFormatter.h:91
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
CTPPSPixelDigiToRaw::allDigiCounter_
int allDigiCounter_
Definition: CTPPSPixelDigiToRaw.cc:74
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::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
CTPPSPixelDigiToRaw::tCTPPSPixelDigi_
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelDigi > > tCTPPSPixelDigi_
Definition: CTPPSPixelDigiToRaw.cc:80
CTPPSPixelDigi.h
CTPPSPixelDataFormatter::nDigis
int nDigis() const
Definition: CTPPSPixelDataFormatter.h:76
InputTag.h
CTPPSPixelDataFormatter
Definition: CTPPSPixelDataFormatter.h:53
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CTPPSPixelDigiToRaw::recordWatcher_
edm::ESWatcher< CTPPSPixelDAQMappingRcd > recordWatcher_
Definition: CTPPSPixelDigiToRaw.cc:79
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
CTPPSPixelDAQMapping.h
CTPPSPixelDigiToRaw::fPos_
CTPPSPixelFramePosition fPos_
Definition: CTPPSPixelDigiToRaw.cc:82
CTPPSPixelDigiToRaw::~CTPPSPixelDigiToRaw
~CTPPSPixelDigiToRaw() override
Definition: CTPPSPixelDigiToRaw.cc:108
Frameworkfwd.h
ESWatcher.h
EventSetup.h
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:28
edm::InputTag
Definition: InputTag.h:15
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443