Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:01:55

0001 /****************************************************************************
0002 *
0003 * This is a part of TOTEM offline software.
0004 * Authors:
0005 *   Hubert Niewiadomski
0006 *   Jan Kašpar (jan.kaspar@gmail.com)
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/CTPPSReco/interface/TotemRPCluster.h"
0020 #include "DataFormats/CTPPSReco/interface/TotemRPRecHit.h"
0021 
0022 #include "RecoPPS/Local/interface/TotemRPRecHitProducerAlgorithm.h"
0023 
0024 //----------------------------------------------------------------------------------------------------
0025 
0026 class TotemRPRecHitProducer : public edm::stream::EDProducer<> {
0027 public:
0028   explicit TotemRPRecHitProducer(const edm::ParameterSet& conf);
0029 
0030   ~TotemRPRecHitProducer() override {}
0031 
0032   void produce(edm::Event& e, const edm::EventSetup& c) override;
0033   static void fillDescriptions(edm::ConfigurationDescriptions&);
0034 
0035 private:
0036   const edm::ParameterSet conf_;
0037   int verbosity_;
0038 
0039   TotemRPRecHitProducerAlgorithm algorithm_;
0040 
0041   edm::InputTag tagCluster_;
0042   edm::EDGetTokenT<edm::DetSetVector<TotemRPCluster>> tokenCluster_;
0043 };
0044 
0045 //----------------------------------------------------------------------------------------------------
0046 //----------------------------------------------------------------------------------------------------
0047 
0048 using namespace std;
0049 using namespace edm;
0050 
0051 //----------------------------------------------------------------------------------------------------
0052 
0053 TotemRPRecHitProducer::TotemRPRecHitProducer(const edm::ParameterSet& conf) : conf_(conf), algorithm_(conf) {
0054   verbosity_ = conf.getParameter<int>("verbosity");
0055 
0056   tagCluster_ = conf.getParameter<edm::InputTag>("tagCluster");
0057   tokenCluster_ = consumes<edm::DetSetVector<TotemRPCluster>>(tagCluster_);
0058 
0059   produces<edm::DetSetVector<TotemRPRecHit>>();
0060 }
0061 
0062 //----------------------------------------------------------------------------------------------------
0063 
0064 void TotemRPRecHitProducer::produce(edm::Event& e, const edm::EventSetup& es) {
0065   // get input
0066   edm::Handle<edm::DetSetVector<TotemRPCluster>> input;
0067   e.getByToken(tokenCluster_, input);
0068 
0069   // prepare output
0070   DetSetVector<TotemRPRecHit> output;
0071 
0072   // build reco hits
0073   for (auto& ids : *input) {
0074     DetSet<TotemRPRecHit>& ods = output.find_or_insert(ids.detId());
0075     algorithm_.buildRecoHits(ids, ods);
0076   }
0077 
0078   // save output
0079   e.put(make_unique<DetSetVector<TotemRPRecHit>>(output));
0080 }
0081 
0082 //----------------------------------------------------------------------------------------------------
0083 
0084 void TotemRPRecHitProducer::fillDescriptions(edm::ConfigurationDescriptions& descr) {
0085   edm::ParameterSetDescription desc;
0086 
0087   desc.add<edm::InputTag>("tagCluster", edm::InputTag("totemRPClusterProducer"))
0088       ->setComment("input clusters collection to retrieve");
0089   desc.add<int>("verbosity", 0);
0090 
0091   descr.add("totemRPRecHitProducer", desc);
0092 }
0093 
0094 //----------------------------------------------------------------------------------------------------
0095 
0096 DEFINE_FWK_MODULE(TotemRPRecHitProducer);