Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-16 03:23:29

0001 #include "FWCore/Framework/interface/stream/EDProducer.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 
0005 #include "DataFormats/NanoAOD/interface/FlatTable.h"
0006 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0007 #include "DataFormats/TrackReco/interface/Track.h"
0008 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0009 
0010 class SiStripOnTrackClusterTableProducerBase : public edm::stream::EDProducer<> {
0011 public:
0012   explicit SiStripOnTrackClusterTableProducerBase(const edm::ParameterSet& params)
0013       : m_name(params.getParameter<std::string>("name")),
0014         m_doc(params.existsAs<std::string>("doc") ? params.getParameter<std::string>("doc") : ""),
0015         m_extension(params.existsAs<bool>("extension") ? params.getParameter<bool>("extension") : true),
0016         m_tracks_token(consumes<edm::View<reco::Track>>(params.getParameter<edm::InputTag>("Tracks"))),
0017         m_association_token(consumes<TrajTrackAssociationCollection>(params.getParameter<edm::InputTag>("Tracks"))) {
0018     produces<nanoaod::FlatTable>();
0019   }
0020   ~SiStripOnTrackClusterTableProducerBase() override;
0021 
0022   void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) final;
0023 
0024   struct OnTrackCluster {
0025     uint32_t det;
0026     const SiStripCluster* cluster;
0027     const Trajectory* traj;
0028     const reco::Track* track;
0029     const TrajectoryMeasurement& measurement;
0030     OnTrackCluster(uint32_t detId,
0031                    const SiStripCluster* stripCluster,
0032                    const Trajectory* trajectory,
0033                    const reco::Track* track_,
0034                    const TrajectoryMeasurement& measurement_)
0035         : det{detId}, cluster{stripCluster}, traj{trajectory}, track{track_}, measurement{measurement_} {}
0036   };
0037 
0038   virtual void fillTable(const std::vector<OnTrackCluster>& clusters,
0039                          const edm::View<reco::Track>& tracks,
0040                          nanoaod::FlatTable* table,
0041                          const edm::EventSetup& iSetup) = 0;
0042 
0043   template <typename VALUES>
0044   static void addColumn(nanoaod::FlatTable* table, const std::string& name, VALUES&& values, const std::string& doc) {
0045     using value_type = typename std::remove_reference<VALUES>::type::value_type;
0046     table->template addColumn<value_type>(name, values, doc);
0047   }
0048 
0049 private:
0050   const std::string m_name;
0051   const std::string m_doc;
0052   bool m_extension;
0053 
0054   const edm::EDGetTokenT<edm::View<reco::Track>> m_tracks_token;
0055   const edm::EDGetTokenT<TrajTrackAssociationCollection> m_association_token;
0056 };