CMS 3D CMS Logo

TrackAssociatorEDProducer.cc
Go to the documentation of this file.
1 //
2 // Original Author: Stefano Magni
3 // Created: Fri Mar 9 10:52:11 CET 2007
4 //
5 //
6 
7 // system include files
8 #include <memory>
9 #include <string>
10 
11 // user include files
13 
16 
18 
20 
22 
25 
27 
28 //
29 // class decleration
30 //
31 
33 public:
35  ~TrackAssociatorEDProducer() override;
36 
37 private:
38  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
39 
41 
45 };
46 
48  : theIgnoremissingtrackcollection(pset.getUntrackedParameter<bool>("ignoremissingtrackcollection", false)) {
49  produces<reco::SimToRecoCollection>();
50  produces<reco::RecoToSimCollection>();
51 
52  TPCollectionToken_ = consumes<TrackingParticleCollection>(pset.getParameter<edm::InputTag>("label_tp"));
53  trackCollectionToken_ = consumes<edm::View<reco::Track>>(pset.getParameter<edm::InputTag>("label_tr"));
54  associatorToken_ = consumes<reco::TrackToTrackingParticleAssociator>(pset.getParameter<edm::InputTag>("associator"));
55 }
56 
58 
59 //
60 // member functions
61 //
62 
63 // ------------ method called to produce the data ------------
65  using namespace edm;
66 
68  iEvent.getByToken(associatorToken_, theAssociator);
69 
71  iEvent.getByToken(TPCollectionToken_, TPCollection);
72 
74  bool trackAvailable = iEvent.getByToken(trackCollectionToken_, trackCollection);
75 
76  std::unique_ptr<reco::RecoToSimCollection> rts;
77  std::unique_ptr<reco::SimToRecoCollection> str;
78 
79  if (theIgnoremissingtrackcollection && !trackAvailable) {
80  // the track collection is not in the event and we're being told to ignore
81  // this. do not output anything to the event, other wise this would be
82  // considered as inefficiency.
83  } else {
84  // associate tracks
85  LogTrace("TrackValidator") << "Calling associateRecoToSim method"
86  << "\n";
87  reco::RecoToSimCollection recSimColl = theAssociator->associateRecoToSim(trackCollection, TPCollection);
88 
89  LogTrace("TrackValidator") << "Calling associateSimToReco method"
90  << "\n";
91  reco::SimToRecoCollection simRecColl = theAssociator->associateSimToReco(trackCollection, TPCollection);
92 
93  rts = std::make_unique<reco::RecoToSimCollection>(recSimColl);
94  str = std::make_unique<reco::SimToRecoCollection>(simRecColl);
95 
96  iEvent.put(std::move(rts));
97  iEvent.put(std::move(str));
98  }
99 }
100 
101 // define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
electrons_cff.bool
bool
Definition: electrons_cff.py:393
TrackAssociatorEDProducer::theIgnoremissingtrackcollection
bool theIgnoremissingtrackcollection
Definition: TrackAssociatorEDProducer.cc:40
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
ESHandle.h
edm::EDGetTokenT< TrackingParticleCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::TrackToTrackingParticleAssociator::associateRecoToSim
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
Definition: TrackToTrackingParticleAssociator.h:64
TrackAssociatorEDProducer::~TrackAssociatorEDProducer
~TrackAssociatorEDProducer() override
Definition: TrackAssociatorEDProducer.cc:57
edm::Handle< reco::TrackToTrackingParticleAssociator >
TrackAssociatorEDProducer::TPCollectionToken_
edm::EDGetTokenT< TrackingParticleCollection > TPCollectionToken_
Definition: TrackAssociatorEDProducer.cc:42
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
str
#define str(s)
Definition: TestProcessor.cc:51
TrackAssociatorEDProducer::TrackAssociatorEDProducer
TrackAssociatorEDProducer(const edm::ParameterSet &)
Definition: TrackAssociatorEDProducer.cc:47
EDGetToken.h
edm::global::EDProducer
Definition: EDProducer.h:32
TrackToTrackingParticleAssociator.h
edm::ParameterSet
Definition: ParameterSet.h:47
duplicaterechits_cfi.trackCollection
trackCollection
Definition: duplicaterechits_cfi.py:4
Event.h
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >
TrackAssociatorEDProducer::associatorToken_
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associatorToken_
Definition: TrackAssociatorEDProducer.cc:44
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
TrackAssociatorEDProducer
Definition: TrackAssociatorEDProducer.cc:32
TrackingParticle.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::TrackToTrackingParticleAssociator::associateSimToReco
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
Definition: TrackToTrackingParticleAssociator.h:71
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
ParameterSet.h
TrackAssociatorEDProducer::trackCollectionToken_
edm::EDGetTokenT< edm::View< reco::Track > > trackCollectionToken_
Definition: TrackAssociatorEDProducer.cc:43
EDProducer.h
edm::Event
Definition: Event.h:73
TrackAssociatorEDProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: TrackAssociatorEDProducer.cc:64
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27