CMS 3D CMS Logo

DirectMuonTrajectoryBuilder.cc
Go to the documentation of this file.
1 
9 
11 
14 
15 using namespace edm;
16 using namespace std;
17 
18 
20  const MuonServiceProxy* service):theService(service){
21 
22  // The seed transformer (used to refit the seed and get the seed transient state)
23  // ParameterSet seedTransformerPSet = par.getParameter<ParameterSet>("SeedTransformerParameters");
24  ParameterSet seedTransformerParameters = par.getParameter<ParameterSet>("SeedTransformerParameters");
25  theSeedTransformer = new SeedTransformer(seedTransformerParameters);
26 }
27 
29 
30  LogTrace("Muon|RecoMuon|DirectMuonTrajectoryBuilder")
31  << "DirectMuonTrajectoryBuilder destructor called" << endl;
32 
34 }
35 
38 
39  // Set the services for the seed transformer
41 
42  const string metname = "Muon|RecoMuon|DirectMuonTrajectoryBuilder";
43 
45 
46  vector<Trajectory> seedTrajectories = theSeedTransformer->seedTransform(seed);
47 
48  if(!seedTrajectories.empty())
49  for(vector<Trajectory>::const_iterator trajectory = seedTrajectories.begin(); trajectory!=seedTrajectories.end(); ++trajectory)
50  trajectoryContainer.push_back(new Trajectory(*trajectory));
51  else LogTrace(metname) << "Seed not refitted";
52 
53 
54  return trajectoryContainer;
55 
56 
57 // std::pair<bool, Trajectory>
58 // SETFilter::bwfit_SET(const TrajectorySeed &trajectorySeed ,
59 // const TransientTrackingRecHit::ConstRecHitContainer & trajRH,
60 // const TrajectoryStateOnSurface & firstTsos) {
61 // // get the actual fitter - Kalman fit
62 // theService->eventSetup().get<TrajectoryFitter::Record>().get(theBWLightFitterName, theBWLightFitter);
63 // vector<Trajectory> refitted;
64 // Trajectory trajectory;
65 // // the actual Kalman Fit
66 // refitted = theBWLightFitter->fit(trajectorySeed, trajRH, firstTsos);
67 // if(!refitted.empty()){
68 // // under tests...
69 // bool applyPruning = false;
70 // if(applyPruning){
71 // double previousTheta = trajRH[0]->globalPosition().theta();
72 // double previousWeight = 0.;
73 // std::vector <double> weights(trajRH.size());
74 // std::vector <double> weight_diff(trajRH.size());
75 // for(unsigned int iRH = 0; iRH<trajRH.size();++iRH){
76 // double weight = trajRH[iRH]->globalPosition().theta() - previousTheta;
77 // weights.at(iRH)= weight;
78 // double weightDiff = weight + previousWeight;
79 // weight_diff.at(iRH) = weightDiff;
80 // std::cout<<" iRH = "<<iRH<<" globPos"<< trajRH[iRH]->globalPosition()<<" weight = "<<weight<<" weightDiff = "<<weightDiff<<std::endl;
81 // previousTheta = trajRH[iRH]->globalPosition().theta();
82 // previousWeight = weight;
83 
84 // }
85 // Trajectory::DataContainer measurements_segments = refitted.front().measurements();
86 // if(measurements_segments.size() != trajRH.size()){
87 // std::cout<<" measurements_segments.size() = "<<measurements_segments.size()<<
88 // " trajRH.size() = "<<trajRH.size()<<std::endl;
89 // std::cout<<" THIS IS NOT SUPPOSED TO HAPPEN! CHECK THE CODE (pruning)"<<std::endl;
90 // }
91 // std::vector <int> badHits;
92 // TransientTrackingRecHit::ConstRecHitContainer trajRH_pruned;
93 // for(unsigned int iMeas = 0; iMeas<measurements_segments.size();++iMeas){
94 // // we have to apply pruning on the base of intermed. chi2 of measurements
95 // // and then refit again!
96 // std::cout<<" after refitter : iMeas = "<<iMeas<<" estimate() = "<< measurements_segments[iMeas].estimate()<<
97 // " globPos = "<< measurements_segments[iMeas].recHit()->globalPosition()<<std::endl;
98 // //const TransientTrackingRecHit::ConstRecHitContainer trajRH_pruned;
99 // bool pruningCondition = fabs(weights[iMeas])>0.0011 && fabs(weight_diff[iMeas])>0.0011;
100 // std::cout<<" weights[iMeas] = "<<weights[iMeas]<<" weight_diff[iMeas] = "<<weight_diff[iMeas]<<" pruningCondition = "<<pruningCondition<<std::endl;
101 // //bool pruningCondition = (measurements_segments[iMeas].estimate()>50);
102 // if(iMeas && pruningCondition && measurements_segments.size() == trajRH.size()){// first is kept for technical reasons (for now)
103 // badHits.push_back(iMeas);
104 // }
105 // else{
106 // trajRH_pruned.push_back(trajRH[iMeas]);
107 // }
108 // }
109 // if(float(measurements_segments.size())/float(badHits.size()) >0.5 &&
110 // measurements_segments.size() - badHits.size() > 6){
111 // std::cout<<" this is pruning ; badHits.size() = "<<badHits.size()<<std::endl;
112 // refitted = theBWLightFitter->fit(trajectorySeed, trajRH_pruned, firstTsos);
113 // }
114 // }
115 // std::pair<bool, Trajectory> refitResult = make_pair(true,refitted.front());
116 // //return RefitResult(true,refitted.front());
117 // return refitResult;
118 // }
119 // else{
120 // // std::cout<<" refitted.empty() = "<<refitted.empty()<<std::endl;
121 // std::pair<bool, Trajectory> refitResult = make_pair(false,trajectory);
122 // //return RefitResult(false,trajectory);
123 // return refitResult;
124 // }
125 }
126 
127 
130 {
132 }
133 
134 
135 
137 }
138 
139 
T getParameter(std::string const &) const
MuonCandidate::CandidateContainer CandidateContainer
void setEvent(const edm::Event &event) override
pass the Event to the algo at each event
std::pair< const Trajectory *, reco::TrackRef > TrackCand
const std::string metname
void setServices(const edm::EventSetup &)
Set the services needed by the SeedTransformer.
MuonCandidate::TrajectoryContainer TrajectoryContainer
~DirectMuonTrajectoryBuilder() override
destructor
std::vector< Trajectory > seedTransform(const TrajectorySeed &) const
Performs the fit.
#define LogTrace(id)
TrajectoryContainer trajectories(const TrajectorySeed &) override
return a container of the reconstructed trajectories compatible with a given seed ...
DirectMuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *)
constructor
HLT enums.
Definition: event.py:1