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 
12 // Framework
19 
21 
22 // TrackFinder and specific GLB Trajectory Builder
28 
29 // Input and output collection
32 
39 
40 using namespace edm;
41 using namespace std;
42 
43 //
44 // constructor with config
45 //
47 
48  LogDebug("Muon|RecoMuon|TevMuonProducer") << "constructor called" << endl;
49 
50  // GLB Muon Collection Label
51  theGLBCollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
52 
53  // service parameters
54  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
55 
56  // the services
57  theService = new MuonServiceProxy(serviceParameters);
58 
59  // TrackRefitter parameters
60  ParameterSet refitterParameters = parameterSet.getParameter<ParameterSet>("RefitterParameters");
61  theRefitter = new GlobalMuonRefitter(refitterParameters, theService);
62 
63  // TrackLoader parameters
64  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
65  theTrackLoader = new MuonTrackLoader(trackLoaderParameters,theService);
66 
67  theRefits = parameterSet.getParameter< std::vector<std::string> >("Refits");
68  theRefitIndex = parameterSet.getParameter< std::vector<int> >("RefitIndex");
69 
70  for(unsigned int ww=0;ww<theRefits.size();ww++){
71  LogDebug("Muon|RecoMuon|TevMuonProducer") << "Refit " << theRefits[ww];
72  produces<reco::TrackCollection>(theRefits[ww]);
73  produces<TrackingRecHitCollection>(theRefits[ww]);
74  produces<reco::TrackExtraCollection>(theRefits[ww]);
75  produces<vector<Trajectory> >(theRefits[ww]) ;
76  produces<TrajTrackAssociationCollection>(theRefits[ww]);
77  produces<reco::TrackToTrackMap>(theRefits[ww]);
78  }
79 }
80 
81 
82 //
83 // destructor
84 //
86 
87  LogTrace("Muon|RecoMuon|TevMuonProducer") << "destructor called" << endl;
88  if (theService) delete theService;
89  if (theRefitter) delete theRefitter;
90  if (theTrackLoader) delete theTrackLoader;
91 }
92 
93 
94 //
95 // reconstruct muons
96 //
97 void TevMuonProducer::produce(Event& event, const EventSetup& eventSetup) {
98 
99  const string metname = "Muon|RecoMuon|TevMuonProducer";
100  LogTrace(metname)<< endl << endl;
101  LogTrace(metname)<< "TeV Muon Reconstruction started" << endl;
102 
103  // Update the services
104  theService->update(eventSetup);
105 
106  theRefitter->setEvent(event);
107 
108  theRefitter->setServices(theService->eventSetup());
109 
110  //Retrieve tracker topology from geometry
112  eventSetup.get<IdealGeometryRecord>().get(tTopoHand);
113  const TrackerTopology *tTopo=tTopoHand.product();
114 
115 
116  // Take the GLB muon container(s)
118  event.getByLabel(theGLBCollectionLabel,glbMuons);
119 
120  Handle<vector<Trajectory> > glbMuonsTraj;
121 
122  LogTrace(metname)<< "Taking " << glbMuons->size() << " Global Muons "<<theGLBCollectionLabel<<endl;
123 
124  vector<MuonTrajectoryBuilder::TrackCand> glbTrackCands;
125 
126  event.getByLabel(theGLBCollectionLabel.label(), glbMuonsTraj);
127 
128  const reco::TrackCollection *glbTracks = glbMuons.product();
129 
130  for(unsigned int ww=0;ww<theRefits.size();ww++) {
131  LogDebug(metname)<<"TeVRefit for Refit: " <<theRefitIndex[ww];
132  std::vector<std::pair<Trajectory*,reco::TrackRef> > miniMap;
133  vector<Trajectory*> trajectories;
134  reco::TrackRef::key_type trackIndex = 0;
135  for (reco::TrackCollection::const_iterator track = glbTracks->begin(); track!=glbTracks->end(); track++ , ++trackIndex) {
136  reco::TrackRef glbRef(glbMuons,trackIndex);
137 
138  vector<Trajectory> refitted=theRefitter->refit(*track,theRefitIndex[ww],tTopo);
139 
140  if (refitted.size()>0) {
141  Trajectory *refit = new Trajectory(refitted.front());
142  LogDebug(metname)<<"TeVTrackLoader for Refit: " <<theRefits[ww];
143  trajectories.push_back(refit);
144  std::pair<Trajectory*,reco::TrackRef> thisPair(refit,glbRef);
145  miniMap.push_back(thisPair);
146  }
147  }
148  theTrackLoader->loadTracks(trajectories,event,miniMap,theRefits[ww]);
149  }
150 
151  LogTrace(metname) << "Done." << endl;
152 
153 }
#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:74
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