File indexing completed on 2024-04-06 12:27:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011
0012 #include "FWCore/Framework/interface/stream/EDProducer.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016
0017 #include "DataFormats/Common/interface/DetSetVector.h"
0018 #include "DataFormats/Common/interface/DetSet.h"
0019 #include "DataFormats/CTPPSDigi/interface/TotemRPDigi.h"
0020
0021 #include "RecoPPS/Local/interface/TotemRPClusterProducerAlgorithm.h"
0022
0023
0024
0025
0026
0027
0028 class TotemRPClusterProducer : public edm::stream::EDProducer<> {
0029 public:
0030 explicit TotemRPClusterProducer(const edm::ParameterSet& conf);
0031
0032 ~TotemRPClusterProducer() override {}
0033
0034 void produce(edm::Event& e, const edm::EventSetup& c) override;
0035 static void fillDescriptions(edm::ConfigurationDescriptions&);
0036
0037 private:
0038 edm::ParameterSet conf_;
0039 int verbosity_;
0040 edm::InputTag digiInputTag_;
0041 edm::EDGetTokenT<edm::DetSetVector<TotemRPDigi>> digiInputTagToken_;
0042
0043 TotemRPClusterProducerAlgorithm algorithm_;
0044
0045 void run(const edm::DetSetVector<TotemRPDigi>& input, edm::DetSetVector<TotemRPCluster>& output);
0046 };
0047
0048
0049
0050
0051 using namespace std;
0052 using namespace edm;
0053
0054
0055
0056 TotemRPClusterProducer::TotemRPClusterProducer(edm::ParameterSet const& conf) : conf_(conf), algorithm_(conf) {
0057 verbosity_ = conf.getParameter<int>("verbosity");
0058
0059 digiInputTag_ = conf.getParameter<edm::InputTag>("tagDigi");
0060 digiInputTagToken_ = consumes<edm::DetSetVector<TotemRPDigi>>(digiInputTag_);
0061
0062 produces<edm::DetSetVector<TotemRPCluster>>();
0063 }
0064
0065
0066
0067 void TotemRPClusterProducer::produce(edm::Event& e, const edm::EventSetup& es) {
0068
0069 edm::Handle<edm::DetSetVector<TotemRPDigi>> input;
0070 e.getByToken(digiInputTagToken_, input);
0071
0072
0073 DetSetVector<TotemRPCluster> output;
0074
0075
0076 if (!input->empty())
0077 run(*input, output);
0078
0079
0080 e.put(make_unique<DetSetVector<TotemRPCluster>>(output));
0081 }
0082
0083
0084
0085 void TotemRPClusterProducer::run(const edm::DetSetVector<TotemRPDigi>& input,
0086 edm::DetSetVector<TotemRPCluster>& output) {
0087 for (const auto& ds_digi : input) {
0088 edm::DetSet<TotemRPCluster>& ds_cluster = output.find_or_insert(ds_digi.id);
0089
0090 algorithm_.buildClusters(ds_digi.id, ds_digi.data, ds_cluster.data);
0091 }
0092 }
0093
0094
0095
0096 void TotemRPClusterProducer::fillDescriptions(edm::ConfigurationDescriptions& descr) {
0097 edm::ParameterSetDescription desc;
0098
0099 desc.add<edm::InputTag>("tagDigi", edm::InputTag("totemRPRawToDigi", "TrackingStrip"))
0100 ->setComment("input digis collection to retrieve");
0101 desc.add<int>("verbosity", 0);
0102
0103 descr.add("totemRPClusterProducer", desc);
0104 }
0105
0106
0107
0108 DEFINE_FWK_MODULE(TotemRPClusterProducer);