CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L3MuonProducer.cc
Go to the documentation of this file.
1 
11 // Framework
17 
19 
20 // TrackFinder and specific GLB Trajectory Builder
25 
26 
27 using namespace edm;
28 using namespace std;
29 
30 //
31 // constructor with config
32 //
34 
35  LogTrace("L3MuonProducer") << "constructor called" << endl;
36 
37  // Parameter set for the Builder
38  ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("L3TrajBuilderParameters");
39 
40  // L2 Muon Collection Label
41  theL2CollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
42  l2MuonToken_ = consumes<reco::TrackCollection>(theL2CollectionLabel);
43  l2MuonTrajToken_ = consumes<std::vector<Trajectory> >(theL2CollectionLabel.label());
44  l2AssoMapToken_ = consumes<TrajTrackAssociationCollection>(theL2CollectionLabel.label());
45  updatedL2AssoMapToken_ = consumes<reco::TrackToTrackMap>(theL2CollectionLabel.label());
46 
47  // service parameters
48  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
49 
50  // TrackLoader parameters
51  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
52 
53  // the services
54  theService = new MuonServiceProxy(serviceParameters);
55  ConsumesCollector iC = consumesCollector();
56 
57  // instantiate the concrete trajectory builder in the Track Finder
58  MuonTrackLoader* mtl = new MuonTrackLoader(trackLoaderParameters,iC,theService);
59  L3MuonTrajectoryBuilder* l3mtb = new L3MuonTrajectoryBuilder(trajectoryBuilderParameters, theService,iC);
60  theTrackFinder = new MuonTrackFinder(l3mtb, mtl);
61 
62  theL2SeededTkLabel = trackLoaderParameters.getUntrackedParameter<std::string>("MuonSeededTracksInstance",std::string());
63 
64  produces<reco::TrackCollection>(theL2SeededTkLabel);
65  produces<TrackingRecHitCollection>(theL2SeededTkLabel);
66  produces<reco::TrackExtraCollection>(theL2SeededTkLabel);
67  produces<vector<Trajectory> >(theL2SeededTkLabel) ;
68  produces<TrajTrackAssociationCollection>(theL2SeededTkLabel);
69 
70  produces<reco::TrackCollection>();
71  produces<TrackingRecHitCollection>();
72  produces<reco::TrackExtraCollection>();
73  produces<vector<Trajectory> >() ;
74  produces<TrajTrackAssociationCollection>();
75 
76  produces<reco::MuonTrackLinksCollection>();
77 
78 }
79 
80 
81 //
82 // destructor
83 //
85 
86  LogTrace("L3MuonProducer") << "destructor called" << endl;
87  if (theService) delete theService;
88  if (theTrackFinder) delete theTrackFinder;
89 
90 }
91 
92 
93 //
94 // reconstruct muons
95 //
96 void L3MuonProducer::produce(Event& event, const EventSetup& eventSetup) {
97  const string metname = "Muon|RecoMuon|L3MuonProducer";
98  LogTrace(metname)<<endl<<endl<<endl;
99  LogTrace(metname)<<"L3 Muon Reconstruction started"<<endl;
100 
101  typedef vector<Trajectory> TrajColl;
102 
103  // Update the services
104  theService->update(eventSetup);
105 
106  // Take the L2 muon container(s)
107  LogTrace(metname)<<"Taking the L2 Muons "<<theL2CollectionLabel<<endl;
108 
109 
111  event.getByToken(l2MuonToken_,L2Muons);
112 
113  Handle<vector<Trajectory> > L2MuonsTraj;
114  vector<MuonTrajectoryBuilder::TrackCand> L2TrackCands;
115 
116 
117  event.getByToken(l2MuonTrajToken_, L2MuonsTraj);
118 
120  event.getByToken(l2AssoMapToken_,L2AssoMap);
121 
122  edm::Handle<reco::TrackToTrackMap> updatedL2AssoMap;
123  event.getByToken(updatedL2AssoMapToken_,updatedL2AssoMap);
124 
125 
126 
127  for(TrajTrackAssociationCollection::const_iterator it = L2AssoMap->begin(); it != L2AssoMap->end(); ++it){
128  const Ref<vector<Trajectory> > traj = it->key;
129  const reco::TrackRef tkRegular = it->val;
130  reco::TrackRef tkUpdated;
133  if ( theL2CollectionLabel.instance() == "UpdatedAtVtx") {
134  iEnd = updatedL2AssoMap->end();
135  iii = updatedL2AssoMap->find(it->val);
136  if (iii != iEnd ) tkUpdated = (*updatedL2AssoMap)[it->val] ;
137  }
138 
139  const reco::TrackRef tk = ( tkUpdated.isNonnull() ) ? tkUpdated : tkRegular ;
140 
142  if( traj->isValid() ) L2Cand.first = &*traj ;
143  L2TrackCands.push_back(L2Cand);
144  }
145 
146  theTrackFinder->reconstruct(L2TrackCands, event);
147 
148  LogTrace(metname)<<"Event loaded"
149  <<"================================"
150  <<endl<<endl;
151 
152 }
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::pair< const Trajectory *, reco::TrackRef > TrackCand
const std::string metname
key_type key() const
Accessor for product key.
Definition: Ref.h:266
tuple L2Muons
Definition: L2Muons_cfi.py:6
virtual ~L3MuonProducer()
destructor
virtual void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muons
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
#define LogTrace(id)
L3MuonProducer(const edm::ParameterSet &)
constructor with config
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11