CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TevMuonProducer.cc
Go to the documentation of this file.
1 
10 // Framework
17 
19 
20 // 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  LogDebug("Muon|RecoMuon|TevMuonProducer") << "constructor called" << endl;
37 
38  // GLB Muon Collection Label
39  theGLBCollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
40  glbMuonsToken=consumes<reco::TrackCollection>(theGLBCollectionLabel);
41  glbMuonsTrajToken=consumes<std::vector<Trajectory> >(theGLBCollectionLabel.label());
42 
43  // service parameters
44  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
45 
46  // the services
47  theService = new MuonServiceProxy(serviceParameters);
48 
49  // TrackRefitter parameters
50  ParameterSet refitterParameters = parameterSet.getParameter<ParameterSet>("RefitterParameters");
51  theRefitter = new GlobalMuonRefitter(refitterParameters, theService);
52 
53  // TrackLoader parameters
54  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
55  edm::ConsumesCollector iC = consumesCollector();
56  theTrackLoader = new MuonTrackLoader(trackLoaderParameters,iC,theService);
57 
58  theRefits = parameterSet.getParameter< std::vector<std::string> >("Refits");
59  theRefitIndex = parameterSet.getParameter< std::vector<int> >("RefitIndex");
60 
61  for(unsigned int ww=0;ww<theRefits.size();ww++){
62  LogDebug("Muon|RecoMuon|TevMuonProducer") << "Refit " << theRefits[ww];
63  produces<reco::TrackCollection>(theRefits[ww]);
64  produces<TrackingRecHitCollection>(theRefits[ww]);
65  produces<reco::TrackExtraCollection>(theRefits[ww]);
66  produces<vector<Trajectory> >(theRefits[ww]) ;
67  produces<TrajTrackAssociationCollection>(theRefits[ww]);
68  produces<reco::TrackToTrackMap>(theRefits[ww]);
69  }
70 }
71 
72 
73 //
74 // destructor
75 //
77 
78  LogTrace("Muon|RecoMuon|TevMuonProducer") << "destructor called" << endl;
79  if (theService) delete theService;
80  if (theRefitter) delete theRefitter;
81  if (theTrackLoader) delete theTrackLoader;
82 }
83 
84 
85 //
86 // reconstruct muons
87 //
88 void TevMuonProducer::produce(Event& event, const EventSetup& eventSetup) {
89 
90  const string metname = "Muon|RecoMuon|TevMuonProducer";
91  LogTrace(metname)<< endl << endl;
92  LogTrace(metname)<< "TeV Muon Reconstruction started" << endl;
93 
94  // Update the services
95  theService->update(eventSetup);
96 
97  theRefitter->setEvent(event);
98 
99  theRefitter->setServices(theService->eventSetup());
100 
101  //Retrieve tracker topology from geometry
103  eventSetup.get<IdealGeometryRecord>().get(tTopoHand);
104  const TrackerTopology *tTopo=tTopoHand.product();
105 
106 
107  // Take the GLB muon container(s)
109  event.getByToken(glbMuonsToken,glbMuons);
110 
111  Handle<vector<Trajectory> > glbMuonsTraj;
112 
113  LogTrace(metname)<< "Taking " << glbMuons->size() << " Global Muons "<<theGLBCollectionLabel<<endl;
114 
115  vector<MuonTrajectoryBuilder::TrackCand> glbTrackCands;
116 
117  event.getByToken(glbMuonsTrajToken, glbMuonsTraj);
118 
119  const reco::TrackCollection *glbTracks = glbMuons.product();
120 
121  for(unsigned int ww=0;ww<theRefits.size();ww++) {
122  LogDebug(metname)<<"TeVRefit for Refit: " <<theRefitIndex[ww];
123  std::vector<std::pair<Trajectory*,reco::TrackRef> > miniMap;
124  vector<Trajectory*> trajectories;
125  reco::TrackRef::key_type trackIndex = 0;
126  for (reco::TrackCollection::const_iterator track = glbTracks->begin(); track!=glbTracks->end(); track++ , ++trackIndex) {
127  reco::TrackRef glbRef(glbMuons,trackIndex);
128 
129  vector<Trajectory> refitted=theRefitter->refit(*track,theRefitIndex[ww],tTopo);
130 
131  if (refitted.size()>0) {
132  Trajectory *refit = new Trajectory(refitted.front());
133  LogDebug(metname)<<"TeVTrackLoader for Refit: " <<theRefits[ww];
134  trajectories.push_back(refit);
135  std::pair<Trajectory*,reco::TrackRef> thisPair(refit,glbRef);
136  miniMap.push_back(thisPair);
137  }
138  }
139  theTrackLoader->loadTracks(trajectories,event,miniMap,theRefits[ww]);
140  }
141 
142  LogTrace(metname) << "Done." << endl;
143 
144 }
#define LogDebug(id)
T getParameter(std::string const &) const
const std::string metname
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
TevMuonProducer(const edm::ParameterSet &)
constructor with config
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)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
virtual ~TevMuonProducer()
destructor
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:170
virtual void produce(edm::Event &, const edm::EventSetup &)
reconstruct muons
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11