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 using namespace reco;
31 
32 //
33 // constructor with config
34 //
36 
37  LogDebug("Muon|RecoMuon|TevMuonProducer") << "constructor called" << endl;
38 
39  // GLB Muon Collection Label
40  theGLBCollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
41  glbMuonsToken=consumes<reco::TrackCollection>(theGLBCollectionLabel);
42  glbMuonsTrajToken=consumes<std::vector<Trajectory> >(theGLBCollectionLabel.label());
43 
44  // service parameters
45  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
46 
47  // the services
48  theService = new MuonServiceProxy(serviceParameters);
49  edm::ConsumesCollector iC = consumesCollector();
50 
51  // TrackRefitter parameters
52  ParameterSet refitterParameters = parameterSet.getParameter<ParameterSet>("RefitterParameters");
53  theRefitter = new GlobalMuonRefitter(refitterParameters, theService, iC);
54 
55  // TrackLoader parameters
56  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
57  theTrackLoader = new MuonTrackLoader(trackLoaderParameters,iC,theService);
58 
59  theRefits = parameterSet.getParameter< std::vector<std::string> >("Refits");
60  theRefitIndex = parameterSet.getParameter< std::vector<int> >("RefitIndex");
61 
62  for(unsigned int ww=0;ww<theRefits.size();ww++){
63  LogDebug("Muon|RecoMuon|TevMuonProducer") << "Refit " << theRefits[ww];
64  produces<reco::TrackCollection>(theRefits[ww]);
65  produces<TrackingRecHitCollection>(theRefits[ww]);
66  produces<reco::TrackExtraCollection>(theRefits[ww]);
67  produces<vector<Trajectory> >(theRefits[ww]) ;
68  produces<TrajTrackAssociationCollection>(theRefits[ww]);
69  produces<reco::TrackToTrackMap>(theRefits[ww]);
70  }
71  produces<DYTestimators> ("dytInfo");
72 }
73 
74 
75 //
76 // destructor
77 //
79 
80  LogTrace("Muon|RecoMuon|TevMuonProducer") << "destructor called" << endl;
81  if (theService) delete theService;
82  if (theRefitter) delete theRefitter;
83  if (theTrackLoader) delete theTrackLoader;
84 }
85 
86 
87 //
88 // reconstruct muons
89 //
90 void TevMuonProducer::produce(Event& event, const EventSetup& eventSetup) {
91 
92  const string metname = "Muon|RecoMuon|TevMuonProducer";
93  LogTrace(metname)<< endl << endl;
94  LogTrace(metname)<< "TeV Muon Reconstruction started" << endl;
95 
96  // Update the services
97  theService->update(eventSetup);
98 
99  theRefitter->setEvent(event);
100 
101  theRefitter->setServices(theService->eventSetup());
102 
103  //Retrieve tracker topology from geometry
105  eventSetup.get<IdealGeometryRecord>().get(tTopoHand);
106  const TrackerTopology *tTopo=tTopoHand.product();
107 
108 
109  // Take the GLB muon container(s)
111  event.getByToken(glbMuonsToken,glbMuons);
112 
113  std::auto_ptr<DYTestimators> dytInfo(new DYTestimators);
114  DYTestimators::Filler filler(*dytInfo);
115  size_t GLBmuonSize = glbMuons->size();
116  vector<DYTInfo> dytTmp(GLBmuonSize);
117 
118  Handle<vector<Trajectory> > glbMuonsTraj;
119 
120  LogTrace(metname)<< "Taking " << glbMuons->size() << " Global Muons "<<theGLBCollectionLabel<<endl;
121 
122  vector<MuonTrajectoryBuilder::TrackCand> glbTrackCands;
123 
124  event.getByToken(glbMuonsTrajToken, glbMuonsTraj);
125 
126  const reco::TrackCollection *glbTracks = glbMuons.product();
127 
128  for(unsigned int ww=0;ww<theRefits.size();ww++) {
129  LogDebug(metname)<<"TeVRefit for Refit: " <<theRefitIndex[ww];
130  std::vector<std::pair<Trajectory*,reco::TrackRef> > miniMap;
131  vector<Trajectory*> trajectories;
132  reco::TrackRef::key_type trackIndex = 0;
133  int glbCounter = 0;
134  for (reco::TrackCollection::const_iterator track = glbTracks->begin(); track!=glbTracks->end(); track++ , ++trackIndex) {
135  reco::TrackRef glbRef(glbMuons,trackIndex);
136 
137  vector<Trajectory> refitted=theRefitter->refit(*track,theRefitIndex[ww],tTopo);
138 
139  if (theRefits[ww] == "dyt") dytTmp[glbCounter] = *theRefitter->getDYTInfo();
140  glbCounter++;
141 
142  if (refitted.size()>0) {
143  Trajectory *refit = new Trajectory(refitted.front());
144  LogDebug(metname)<<"TeVTrackLoader for Refit: " <<theRefits[ww];
145  trajectories.push_back(refit);
146  std::pair<Trajectory*,reco::TrackRef> thisPair(refit,glbRef);
147  miniMap.push_back(thisPair);
148  }
149  }
150  theTrackLoader->loadTracks(trajectories,event,miniMap,theRefits[ww]);
151  }
152 
153  filler.insert(glbMuons, dytTmp.begin(), dytTmp.end());
154  filler.fill();
155  event.put(dytInfo, "dytInfo");
156 
157  LogTrace(metname) << "Done." << endl;
158 }
#define LogDebug(id)
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
reconstruct muons
const std::string metname
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
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
ParameterSet const & parameterSet(Provenance const &provenance)
Definition: Provenance.cc:11