|
1 | | -#include "RecoPPS/Local/interface/CTPPSPixelRecHitProducer.h" |
2 | | - |
3 | | -CTPPSPixelRecHitProducer::CTPPSPixelRecHitProducer(const edm::ParameterSet &conf) : param_(conf), cluster2hit_(conf) { |
4 | | - src_ = conf.getParameter<edm::InputTag>("RPixClusterTag"); |
5 | | - verbosity_ = conf.getUntrackedParameter<int>("RPixVerbosity"); |
6 | | - tokenCTPPSPixelCluster_ = consumes<edm::DetSetVector<CTPPSPixelCluster> >(src_); |
7 | | - produces<edm::DetSetVector<CTPPSPixelRecHit> >(); |
8 | | - pixelTopologyToken_ = esConsumes<PPSPixelTopology, PPSPixelTopologyRcd>(); |
9 | | -} |
| 1 | +/********************************************************************** |
| 2 | + * |
| 3 | + * Author: F.Ferro - INFN Genova |
| 4 | + * |
| 5 | + **********************************************************************/ |
10 | 6 |
|
11 | | -CTPPSPixelRecHitProducer::~CTPPSPixelRecHitProducer() {} |
| 7 | +#include "CondFormats/DataRecord/interface/PPSPixelTopologyRcd.h" |
| 8 | +#include "CondFormats/PPSObjects/interface/PPSPixelTopology.h" |
| 9 | +#include "DataFormats/CTPPSDetId/interface/CTPPSPixelDetId.h" |
| 10 | +#include "DataFormats/CTPPSReco/interface/CTPPSPixelCluster.h" |
| 11 | +#include "DataFormats/CTPPSReco/interface/CTPPSPixelRecHit.h" |
| 12 | +#include "DataFormats/Common/interface/DetSet.h" |
| 13 | +#include "DataFormats/Common/interface/DetSetVector.h" |
| 14 | +#include "DataFormats/Common/interface/Handle.h" |
| 15 | +#include "DataFormats/DetId/interface/DetId.h" |
| 16 | +#include "FWCore/Framework/interface/ESHandle.h" |
| 17 | +#include "FWCore/Framework/interface/Event.h" |
| 18 | +#include "FWCore/Framework/interface/EventSetup.h" |
| 19 | +#include "FWCore/Framework/interface/global/EDProducer.h" |
| 20 | +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" |
| 21 | +#include "FWCore/ParameterSet/interface/ParameterSet.h" |
| 22 | +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" |
| 23 | +#include "FWCore/Utilities/interface/EDGetToken.h" |
| 24 | +#include "FWCore/Utilities/interface/EDPutToken.h" |
| 25 | +#include "FWCore/Utilities/interface/ESGetToken.h" |
| 26 | +#include "FWCore/Utilities/interface/InputTag.h" |
| 27 | +#include "RecoPPS/Local/interface/RPixClusterToHit.h" |
12 | 28 |
|
13 | | -void CTPPSPixelRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { |
14 | | - edm::ParameterSetDescription desc; |
15 | | - desc.addUntracked<int>("RPixVerbosity", 0); |
16 | | - desc.add<edm::InputTag>("RPixClusterTag", edm::InputTag("ctppsPixelClusters")); |
17 | | - descriptions.add("ctppsPixelRecHits", desc); |
18 | | -} |
| 29 | +class CTPPSPixelRecHitProducer : public edm::global::EDProducer<> { |
| 30 | +public: |
| 31 | + explicit CTPPSPixelRecHitProducer(const edm::ParameterSet ¶m); |
| 32 | + |
| 33 | + ~CTPPSPixelRecHitProducer() override = default; |
19 | 34 |
|
20 | | -void CTPPSPixelRecHitProducer::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { |
21 | | - edm::Handle<edm::DetSetVector<CTPPSPixelCluster> > rpCl; |
22 | | - iEvent.getByToken(tokenCTPPSPixelCluster_, rpCl); |
| 35 | + void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override; |
23 | 36 |
|
24 | | - edm::ESHandle<PPSPixelTopology> thePixelTopology = iSetup.getHandle(pixelTopologyToken_); |
| 37 | + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); |
25 | 38 |
|
26 | | - edm::DetSetVector<CTPPSPixelRecHit> output; |
| 39 | +private: |
| 40 | + const edm::ESGetToken<PPSPixelTopology, PPSPixelTopologyRcd> pixelTopologyToken_; |
| 41 | + const edm::EDGetTokenT<edm::DetSetVector<CTPPSPixelCluster>> clustersToken_; |
| 42 | + const edm::EDPutTokenT<edm::DetSetVector<CTPPSPixelRecHit>> rechitsToken_; |
| 43 | + const RPixClusterToHit clusterToHit_; |
| 44 | +}; |
27 | 45 |
|
28 | | - // run reconstruction |
29 | | - if (!rpCl->empty()) |
30 | | - run(*rpCl, output, *thePixelTopology); |
| 46 | +CTPPSPixelRecHitProducer::CTPPSPixelRecHitProducer(const edm::ParameterSet &config) |
| 47 | + : pixelTopologyToken_(esConsumes<PPSPixelTopology, PPSPixelTopologyRcd>()), |
| 48 | + clustersToken_( |
| 49 | + consumes<edm::DetSetVector<CTPPSPixelCluster>>(config.getParameter<edm::InputTag>("RPixClusterTag"))), |
| 50 | + rechitsToken_(produces<edm::DetSetVector<CTPPSPixelRecHit>>()), |
| 51 | + clusterToHit_(config) {} |
31 | 52 |
|
32 | | - iEvent.put(std::make_unique<edm::DetSetVector<CTPPSPixelRecHit> >(output)); |
| 53 | +void CTPPSPixelRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { |
| 54 | + edm::ParameterSetDescription desc; |
| 55 | + desc.add<edm::InputTag>("RPixClusterTag", edm::InputTag("ctppsPixelClusters")); |
| 56 | + desc.addUntracked<int>("RPixVerbosity", 0); // used by RPixClusterToHit |
| 57 | + descriptions.add("ctppsPixelRecHits", desc); |
33 | 58 | } |
34 | 59 |
|
35 | | -void CTPPSPixelRecHitProducer::run(const edm::DetSetVector<CTPPSPixelCluster> &input, |
36 | | - edm::DetSetVector<CTPPSPixelRecHit> &output, |
37 | | - const PPSPixelTopology &ppt) { |
38 | | - for (const auto &ds_cluster : input) { |
39 | | - edm::DetSet<CTPPSPixelRecHit> &ds_rechit = output.find_or_insert(ds_cluster.id); |
| 60 | +void CTPPSPixelRecHitProducer::produce(edm::StreamID, edm::Event &event, edm::EventSetup const &setup) const { |
| 61 | + PPSPixelTopology const &thePixelTopology = setup.getData(pixelTopologyToken_); |
| 62 | + edm::DetSetVector<CTPPSPixelCluster> const &clusters = event.get(clustersToken_); |
| 63 | + edm::DetSetVector<CTPPSPixelRecHit> rechits; |
| 64 | + rechits.reserve(clusters.size()); |
| 65 | + |
| 66 | + // run the reconstruction |
| 67 | + for (auto const &cluster : clusters) { |
| 68 | + edm::DetSet<CTPPSPixelRecHit> &rechit = rechits.find_or_insert(cluster.id); |
| 69 | + rechit.data.reserve(cluster.data.size()); |
40 | 70 |
|
41 | | - //calculate the cluster parameters and convert it into a rechit |
42 | | - cluster2hit_.buildHits(ds_cluster.id, ds_cluster.data, ds_rechit.data, ppt); |
| 71 | + // calculate the cluster parameters and convert it into a rechit |
| 72 | + clusterToHit_.buildHits(cluster.id, cluster.data, rechit.data, thePixelTopology); |
43 | 73 | } |
| 74 | + |
| 75 | + event.emplace(rechitsToken_, std::move(rechits)); |
44 | 76 | } |
45 | 77 |
|
| 78 | +#include "FWCore/Framework/interface/MakerMacros.h" |
46 | 79 | DEFINE_FWK_MODULE(CTPPSPixelRecHitProducer); |
0 commit comments