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