CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalMuonProducer.cc
Go to the documentation of this file.
1 
14 // Framework
21 
23 
24 // TrackFinder and specific GLB Trajectory Builder
29 
30 // Input and output collection
33 
38 
39 using namespace edm;
40 using namespace std;
41 
42 //
43 // constructor with config
44 //
46 
47  LogTrace("Muon|RecoMuon|GlobalMuonProducer") << "constructor called" << endl;
48 
49  // Parameter set for the Builder
50  ParameterSet trajectoryBuilderParameters = parameterSet.getParameter<ParameterSet>("GLBTrajBuilderParameters");
51  InputTag trackCollectionTag = parameterSet.getParameter<InputTag>("TrackerCollectionLabel");
52  trajectoryBuilderParameters.addParameter<InputTag>("TrackerCollectionLabel",trackCollectionTag);
53 
54  // STA Muon Collection Label
55  theSTACollectionLabel = parameterSet.getParameter<InputTag>("MuonCollectionLabel");
56 
57  // service parameters
58  ParameterSet serviceParameters = parameterSet.getParameter<ParameterSet>("ServiceParameters");
59 
60  // TrackLoader parameters
61  ParameterSet trackLoaderParameters = parameterSet.getParameter<ParameterSet>("TrackLoaderParameters");
62 
63  // the services
64  theService = new MuonServiceProxy(serviceParameters);
65 
66  // instantiate the concrete trajectory builder in the Track Finder
67  MuonTrackLoader* mtl = new MuonTrackLoader(trackLoaderParameters,theService);
68  GlobalMuonTrajectoryBuilder* gmtb = new GlobalMuonTrajectoryBuilder(trajectoryBuilderParameters, theService);
69 
70  theTrackFinder = new MuonTrackFinder(gmtb, mtl);
71 
72  setAlias(parameterSet.getParameter<std::string>("@module_label"));
73  produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
74  produces<TrackingRecHitCollection>().setBranchAlias(theAlias + "RecHits");
75  produces<reco::TrackExtraCollection>().setBranchAlias(theAlias + "TrackExtras");
76  produces<vector<Trajectory> >().setBranchAlias(theAlias + "Trajectories") ;
77  produces<TrajTrackAssociationCollection>().setBranchAlias(theAlias + "TrajTrackMap");
78  produces<reco::MuonTrackLinksCollection>().setBranchAlias(theAlias + "s");
79 }
80 
81 
82 //
83 // destructor
84 //
86 
87  LogTrace("Muon|RecoMuon|GlobalMuonProducer") << "destructor called" << endl;
88  if (theService) delete theService;
89  if (theTrackFinder) delete theTrackFinder;
90 
91 }
92 
93 
94 //
95 // reconstruct muons
96 //
98  const string metname = "Muon|RecoMuon|GlobalMuonProducer";
99  LogTrace(metname)<<endl<<endl<<endl;
100  LogTrace(metname)<<"Global Muon Reconstruction started"<<endl;
101 
102  // Update the services
103  theService->update(eventSetup);
104 
105  // Take the STA muon container(s)
107  event.getByLabel(theSTACollectionLabel,staMuons);
108 
109  Handle<vector<Trajectory> > staMuonsTraj;
110 
111  LogTrace(metname) << "Taking " << staMuons->size() << " Stand Alone Muons "<<theSTACollectionLabel<<endl;
112 
113  vector<MuonTrajectoryBuilder::TrackCand> staTrackCands;
114 
116 
117  edm::Handle<reco::TrackToTrackMap> updatedStaAssoMap;
118 
119  if( event.getByLabel(theSTACollectionLabel.label(), staMuonsTraj) && event.getByLabel(theSTACollectionLabel.label(),staAssoMap) && event.getByLabel(theSTACollectionLabel.label(),updatedStaAssoMap) ) {
120 
121  for(TrajTrackAssociationCollection::const_iterator it = staAssoMap->begin(); it != staAssoMap->end(); ++it){
122  const Ref<vector<Trajectory> > traj = it->key;
123  const reco::TrackRef tkRegular = it->val;
124  reco::TrackRef tkUpdated;
127  if ( theSTACollectionLabel.instance() == "UpdatedAtVtx") {
128  iEnd = updatedStaAssoMap->end();
129  iii = updatedStaAssoMap->find(it->val);
130  if (iii != iEnd ) tkUpdated = (*updatedStaAssoMap)[it->val] ;
131  }
132 
133  int etaFlip1 = ((tkUpdated.isNonnull() && tkRegular.isNonnull()) && ( (tkUpdated->eta() * tkRegular->eta() ) < 0)) ? -1 : 1;
134 
135  const reco::TrackRef tk = ( tkUpdated.isNonnull() && etaFlip1==1 ) ? tkUpdated : tkRegular ;
136 
138  if( traj->isValid() ) tkCand.first = &*traj ;
139  staTrackCands.push_back(tkCand);
140  }
141  } else {
142  for ( unsigned int position = 0; position != staMuons->size(); ++position ) {
143  reco::TrackRef staTrackRef(staMuons,position);
145  staTrackCands.push_back(staCand);
146  }
147  }
148 
149  theTrackFinder->reconstruct(staTrackCands, event);
150 
151 
152  LogTrace(metname)<<"Event loaded"
153  <<"================================"
154  <<endl<<endl;
155 
156 }
T getParameter(std::string const &) const
std::pair< const Trajectory *, reco::TrackRef > TrackCand
virtual void produce(edm::Event &, const edm::EventSetup &)
reconstruct muons
const std::string metname
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
#define LogTrace(id)
virtual ~GlobalMuonProducer()
destructor
key_type key() const
Accessor for product key.
Definition: Ref.h:266
GlobalMuonProducer(const edm::ParameterSet &)
constructor with config