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
18 
20 
21 // TrackFinder and specific GLB Trajectory Builder
26 
27 
28 using namespace edm;
29 using namespace std;
30 
31 //
32 // constructor with config
33 //
35 
36  LogTrace("L3MuonProducer") << "constructor called" << endl;
37 
38  // Parameter set for the Builder
39  ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("L3TrajBuilderParameters");
40 
41  // L2 Muon Collection Label
42  theL2CollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
43  l2MuonToken_ = consumes<reco::TrackCollection>(theL2CollectionLabel);
44  l2MuonTrajToken_ = consumes<std::vector<Trajectory> >(theL2CollectionLabel.label());
45  l2AssoMapToken_ = consumes<TrajTrackAssociationCollection>(theL2CollectionLabel.label());
46  updatedL2AssoMapToken_ = consumes<reco::TrackToTrackMap>(theL2CollectionLabel.label());
47 
48  // service parameters
49  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
50 
51  // TrackLoader parameters
52  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
53 
54  // the services
55  theService = new MuonServiceProxy(serviceParameters);
56  ConsumesCollector iC = consumesCollector();
57 
58  // instantiate the concrete trajectory builder in the Track Finder
59  MuonTrackLoader* mtl = new MuonTrackLoader(trackLoaderParameters,iC,theService);
60  L3MuonTrajectoryBuilder* l3mtb = new L3MuonTrajectoryBuilder(trajectoryBuilderParameters, theService,iC);
61  theTrackFinder = new MuonTrackFinder(l3mtb, mtl);
62 
63  theL2SeededTkLabel = trackLoaderParameters.getUntrackedParameter<std::string>("MuonSeededTracksInstance",std::string());
64 
65  produces<reco::TrackCollection>(theL2SeededTkLabel);
66  produces<TrackingRecHitCollection>(theL2SeededTkLabel);
67  produces<reco::TrackExtraCollection>(theL2SeededTkLabel);
68  produces<vector<Trajectory> >(theL2SeededTkLabel) ;
69  produces<TrajTrackAssociationCollection>(theL2SeededTkLabel);
70 
71  produces<reco::TrackCollection>();
72  produces<TrackingRecHitCollection>();
73  produces<reco::TrackExtraCollection>();
74  produces<vector<Trajectory> >() ;
75  produces<TrajTrackAssociationCollection>();
76 
77  produces<reco::MuonTrackLinksCollection>();
78 
79 }
80 
81 
82 //
83 // destructor
84 //
86 
87  LogTrace("L3MuonProducer") << "destructor called" << endl;
88  if (theService) delete theService;
89  if (theTrackFinder) delete theTrackFinder;
90 
91 }
92 
93 
94 //
95 // reconstruct muons
96 //
97 void L3MuonProducer::produce(Event& event, const EventSetup& eventSetup) {
98  const string metname = "Muon|RecoMuon|L3MuonProducer";
99  LogTrace(metname)<<endl<<endl<<endl;
100  LogTrace(metname)<<"L3 Muon Reconstruction started"<<endl;
101 
102  typedef vector<Trajectory> TrajColl;
103 
104  // Update the services
105  theService->update(eventSetup);
106 
107  // Take the L2 muon container(s)
108  LogTrace(metname)<<"Taking the L2 Muons "<<theL2CollectionLabel<<endl;
109 
110 
112  event.getByToken(l2MuonToken_,L2Muons);
113 
114  Handle<vector<Trajectory> > L2MuonsTraj;
115  vector<MuonTrajectoryBuilder::TrackCand> L2TrackCands;
116 
117 
118  event.getByToken(l2MuonTrajToken_, L2MuonsTraj);
119 
121  event.getByToken(l2AssoMapToken_,L2AssoMap);
122 
123  edm::Handle<reco::TrackToTrackMap> updatedL2AssoMap;
124  event.getByToken(updatedL2AssoMapToken_,updatedL2AssoMap);
125 
126 
127 
128  for(TrajTrackAssociationCollection::const_iterator it = L2AssoMap->begin(); it != L2AssoMap->end(); ++it){
129  const Ref<vector<Trajectory> > traj = it->key;
130  const reco::TrackRef tkRegular = it->val;
131  reco::TrackRef tkUpdated;
134  if ( theL2CollectionLabel.instance() == "UpdatedAtVtx") {
135  iEnd = updatedL2AssoMap->end();
136  iii = updatedL2AssoMap->find(it->val);
137  if (iii != iEnd ) tkUpdated = (*updatedL2AssoMap)[it->val] ;
138  }
139 
140  const reco::TrackRef tk = ( tkUpdated.isNonnull() ) ? tkUpdated : tkRegular ;
141 
143  if( traj->isValid() ) L2Cand.first = &*traj ;
144  L2TrackCands.push_back(L2Cand);
145  }
146 
147  theTrackFinder->reconstruct(L2TrackCands, event);
148 
149  LogTrace(metname)<<"Event loaded"
150  <<"================================"
151  <<endl<<endl;
152 
153 }
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
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
virtual void produce(edm::Event &, const edm::EventSetup &)
reconstruct muons
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11