Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:25:54

0001 /*! \class   TTTrackAssociator
0002  *  \brief   Plugin to create the MC truth for TTTracks.
0003  *  \details After moving from SimDataFormats to DataFormats,
0004  *           the template structure of the class was maintained
0005  *           in order to accomodate any types other than PixelDigis
0006  *           in case there is such a need in the future.
0007  *
0008  *  \author Nicola Pozzobon
0009  *  \date   2013, Jul 19
0010  *  (tidy up: Ian Tomalin, 2020)
0011  *
0012  */
0013 
0014 #ifndef L1_TRACK_TRIGGER_TRACK_ASSOCIATOR_H
0015 #define L1_TRACK_TRIGGER_TRACK_ASSOCIATOR_H
0016 
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "FWCore/Framework/interface/stream/EDProducer.h"
0019 #include "FWCore/Framework/interface/Event.h"
0020 #include "FWCore/Framework/interface/EventSetup.h"
0021 #include "FWCore/Framework/interface/ESHandle.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 
0025 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h"
0026 
0027 #include "L1Trigger/TrackTrigger/interface/classNameFinder.h"
0028 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0029 #include "SimTracker/TrackTriggerAssociation/interface/TTStubAssociationMap.h"
0030 #include "SimTracker/TrackTriggerAssociation/interface/TTTrackAssociationMap.h"
0031 #include "SimTracker/TrackTriggerAssociation/plugins/TTStubAssociator.h"
0032 #include "SimTracker/TrackTriggerAssociation/plugins/TTClusterAssociator.h"
0033 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0034 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0035 
0036 #include <memory>
0037 #include <map>
0038 #include <vector>
0039 
0040 template <typename T>
0041 class TTTrackAssociator : public edm::stream::EDProducer<> {
0042   /// NOTE since pattern hit correlation must be performed within a stacked module, one must store
0043   /// Clusters in a proper way, providing easy access to them in a detector/member-wise way
0044 public:
0045   /// Constructors
0046   explicit TTTrackAssociator(const edm::ParameterSet& iConfig);
0047 
0048   /// Destructor
0049   ~TTTrackAssociator() override;
0050 
0051 private:
0052   /// Data members
0053   std::vector<edm::InputTag> ttTracksInputTags_;
0054 
0055   std::vector<edm::EDGetTokenT<std::vector<TTTrack<T> > > > ttTracksTokens_;
0056   edm::EDGetTokenT<TTStubAssociationMap<T> > ttStubTruthToken_;
0057   edm::EDGetTokenT<TTClusterAssociationMap<T> > ttClusterTruthToken_;
0058 
0059   bool TTTrackAllowOneFalse2SStub;
0060 
0061   /// Mandatory methods
0062   void beginRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
0063   void endRun(const edm::Run& run, const edm::EventSetup& iSetup) override;
0064   void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0065 
0066 };  /// Close class
0067 
0068 /*! \brief   Implementation of methods
0069  *  \details Here, in the header file, the methods which do not depend
0070  *           on the specific type <T> that can fit the template.
0071  *           Other methods, with type-specific features, are implemented
0072  *           in the source file.
0073  */
0074 
0075 /// Constructors
0076 template <typename T>
0077 TTTrackAssociator<T>::TTTrackAssociator(const edm::ParameterSet& iConfig) {
0078   ttTracksInputTags_ = iConfig.getParameter<std::vector<edm::InputTag> >("TTTracks");
0079   ttClusterTruthToken_ = consumes<TTClusterAssociationMap<T> >(iConfig.getParameter<edm::InputTag>("TTClusterTruth"));
0080   ttStubTruthToken_ = consumes<TTStubAssociationMap<T> >(iConfig.getParameter<edm::InputTag>("TTStubTruth"));
0081   TTTrackAllowOneFalse2SStub = iConfig.getParameter<bool>("TTTrackAllowOneFalse2SStub");
0082   if (TTTrackAllowOneFalse2SStub) {
0083     edm::LogInfo("TTTrackAssociator< ") << "Allow track if no more than one 2S stub doesn't match truth.";
0084   } else {
0085     edm::LogInfo("TTTrackAssociator< ") << "All 2S stubs must match truth.";
0086   }
0087 
0088   for (const auto& iTag : ttTracksInputTags_) {
0089     ttTracksTokens_.push_back(consumes<std::vector<TTTrack<T> > >(iTag));
0090 
0091     produces<TTTrackAssociationMap<T> >(iTag.instance());
0092   }
0093 }
0094 
0095 /// Destructor
0096 template <typename T>
0097 TTTrackAssociator<T>::~TTTrackAssociator() {}
0098 
0099 /// Begin run
0100 template <typename T>
0101 void TTTrackAssociator<T>::beginRun(const edm::Run& run, const edm::EventSetup& iSetup) {
0102   /// Print some information when loaded
0103   edm::LogInfo("TTStubAssociator< ") << "TTTrackAssociator< " << templateNameFinder<T>() << " > loaded.";
0104 }
0105 
0106 /// End run
0107 template <typename T>
0108 void TTTrackAssociator<T>::endRun(const edm::Run& run, const edm::EventSetup& iSetup) {}
0109 
0110 /// Implement the producer
0111 template <>
0112 void TTTrackAssociator<Ref_Phase2TrackerDigi_>::produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
0113 
0114 #endif