CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoMuon/TrackingTools/src/DirectMuonTrajectoryBuilder.cc

Go to the documentation of this file.
00001 
00009 #include "RecoMuon/TrackingTools/interface/DirectMuonTrajectoryBuilder.h"
00010 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00011 
00012 #include "TrackingTools/TrackRefitter/interface/SeedTransformer.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 
00017 using namespace edm;
00018 using namespace std;
00019 
00020 
00021 DirectMuonTrajectoryBuilder::DirectMuonTrajectoryBuilder(const ParameterSet& par, 
00022                                                          const MuonServiceProxy* service):theService(service){
00023   
00024   // The seed transformer (used to refit the seed and get the seed transient state)
00025   //  ParameterSet seedTransformerPSet = par.getParameter<ParameterSet>("SeedTransformerParameters");
00026   ParameterSet seedTransformerParameters = par.getParameter<ParameterSet>("SeedTransformerParameters");
00027   theSeedTransformer = new SeedTransformer(seedTransformerParameters);
00028 }
00029 
00030 DirectMuonTrajectoryBuilder::~DirectMuonTrajectoryBuilder(){
00031 
00032   LogTrace("Muon|RecoMuon|DirectMuonTrajectoryBuilder") 
00033     << "DirectMuonTrajectoryBuilder destructor called" << endl;
00034   
00035   if(theSeedTransformer) delete theSeedTransformer;
00036 }
00037 
00038 MuonTrajectoryBuilder::TrajectoryContainer 
00039 DirectMuonTrajectoryBuilder::trajectories(const TrajectorySeed& seed){
00040   
00041   // Set the services for the seed transformer
00042   theSeedTransformer->setServices(theService->eventSetup());
00043 
00044   const string metname = "Muon|RecoMuon|DirectMuonTrajectoryBuilder";
00045   
00046   MuonTrajectoryBuilder::TrajectoryContainer trajectoryContainer;
00047   
00048   vector<Trajectory> seedTrajectories = theSeedTransformer->seedTransform(seed);
00049   
00050   if(!seedTrajectories.empty())
00051     for(vector<Trajectory>::const_iterator trajectory = seedTrajectories.begin(); trajectory!=seedTrajectories.end(); ++trajectory)
00052       trajectoryContainer.push_back(new Trajectory(*trajectory));
00053   else LogTrace(metname) << "Seed not refitted";
00054     
00055   
00056   return  trajectoryContainer;
00057 
00058 
00059 // std::pair<bool, Trajectory> 
00060 // SETFilter::bwfit_SET(const TrajectorySeed &trajectorySeed  , 
00061 //                                const TransientTrackingRecHit::ConstRecHitContainer & trajRH,
00062 //                                const TrajectoryStateOnSurface & firstTsos) {
00063 //   // get the actual fitter - Kalman fit
00064 //   theService->eventSetup().get<TrajectoryFitter::Record>().get(theBWLightFitterName, theBWLightFitter);
00065 //   vector<Trajectory> refitted;
00066 //   Trajectory trajectory;
00067 //   // the actual Kalman Fit
00068 //   refitted = theBWLightFitter->fit(trajectorySeed, trajRH, firstTsos);                                  
00069 //   if(!refitted.empty()){
00070 //     // under tests...
00071 //     bool applyPruning = false;
00072 //     if(applyPruning){
00073 //       double previousTheta = trajRH[0]->globalPosition().theta();
00074 //       double previousWeight = 0.;
00075 //       std::vector <double> weights(trajRH.size());
00076 //       std::vector <double> weight_diff(trajRH.size());
00077 //       for(unsigned int iRH = 0; iRH<trajRH.size();++iRH){
00078 //      double weight = trajRH[iRH]->globalPosition().theta() - previousTheta;
00079 //      weights.at(iRH)= weight;
00080 //      double weightDiff = weight + previousWeight;
00081 //      weight_diff.at(iRH) = weightDiff;
00082 //      std::cout<<" iRH = "<<iRH<<" globPos"<< trajRH[iRH]->globalPosition()<<" weight = "<<weight<<" weightDiff = "<<weightDiff<<std::endl;
00083 //      previousTheta = trajRH[iRH]->globalPosition().theta();
00084 //      previousWeight = weight;
00085 
00086 //       }
00087 //       Trajectory::DataContainer measurements_segments = refitted.front().measurements();
00088 //       if(measurements_segments.size() != trajRH.size()){
00089 //      std::cout<<" measurements_segments.size() = "<<measurements_segments.size()<<
00090 //        " trajRH.size() = "<<trajRH.size()<<std::endl;
00091 //      std::cout<<" THIS IS NOT SUPPOSED TO HAPPEN! CHECK THE CODE (pruning)"<<std::endl;
00092 //       }
00093 //       std::vector <int> badHits;
00094 //       TransientTrackingRecHit::ConstRecHitContainer trajRH_pruned;
00095 //       for(unsigned int iMeas = 0; iMeas<measurements_segments.size();++iMeas){
00096 //      // we have to apply pruning on the base of intermed. chi2 of measurements
00097 //      // and then refit again!
00098 //      std::cout<<" after refitter : iMeas = "<<iMeas<<"  estimate() = "<< measurements_segments[iMeas].estimate()<<
00099 //        " globPos = "<< measurements_segments[iMeas].recHit()->globalPosition()<<std::endl;
00100 //      //const TransientTrackingRecHit::ConstRecHitContainer trajRH_pruned;
00101 //      bool pruningCondition = fabs(weights[iMeas])>0.0011 && fabs(weight_diff[iMeas])>0.0011;
00102 //      std::cout<<" weights[iMeas] = "<<weights[iMeas]<<" weight_diff[iMeas] = "<<weight_diff[iMeas]<<" pruningCondition = "<<pruningCondition<<std::endl;
00103 //      //bool pruningCondition = (measurements_segments[iMeas].estimate()>50);
00104 //      if(iMeas && pruningCondition && measurements_segments.size() == trajRH.size()){// first is kept for technical reasons (for now)
00105 //        badHits.push_back(iMeas);
00106 //      }
00107 //      else{
00108 //        trajRH_pruned.push_back(trajRH[iMeas]);
00109 //      }
00110 //       }
00111 //       if(float(measurements_segments.size())/float(badHits.size()) >0.5 &&
00112 //       measurements_segments.size() - badHits.size() > 6){
00113 //      std::cout<<" this is pruning ; badHits.size() = "<<badHits.size()<<std::endl;
00114 //      refitted = theBWLightFitter->fit(trajectorySeed, trajRH_pruned, firstTsos);  
00115 //       }
00116 //     }
00117 //     std::pair<bool, Trajectory> refitResult = make_pair(true,refitted.front());
00118 //     //return RefitResult(true,refitted.front());
00119 //     return refitResult;
00120 //   }
00121 //   else{
00122 //     //    std::cout<<" refitted.empty() = "<<refitted.empty()<<std::endl;
00123 //     std::pair<bool, Trajectory> refitResult = make_pair(false,trajectory);
00124 //     //return RefitResult(false,trajectory);
00125 //     return refitResult;
00126 //   }
00127 }
00128 
00129 
00130 MuonTrajectoryBuilder::CandidateContainer 
00131 DirectMuonTrajectoryBuilder::trajectories(const TrackCand&)
00132 {
00133   return MuonTrajectoryBuilder::CandidateContainer();
00134 }
00135 
00136 
00137 
00138 void DirectMuonTrajectoryBuilder::setEvent(const edm::Event& event){
00139 }
00140 
00141