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