CMS 3D CMS Logo

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