Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:08

0001 #include <cmath>
0002 #include <vector>
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
0006 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0007 
0008 #include "RecoVertex/GhostTrackFitter/interface/GhostTrackState.h"
0009 #include "RecoVertex/GhostTrackFitter/interface/GhostTrackPrediction.h"
0010 
0011 #include "RecoVertex/GhostTrackFitter/interface/PositiveSideGhostTrackFitter.h"
0012 
0013 using namespace reco;
0014 
0015 GhostTrackPrediction PositiveSideGhostTrackFitter::fit(const GhostTrackFitter::PredictionUpdater &updater,
0016                                                        const GhostTrackPrediction &prior,
0017                                                        std::vector<GhostTrackState> &states,
0018                                                        double &ndof,
0019                                                        double &chi2) {
0020   double rho = prior.rho();
0021   for (unsigned int i = 0; i < states.size(); i++) {
0022     GhostTrackState &state = states[i];
0023     state.linearize(prior, true, .5 / rho);
0024   }
0025 
0026   GhostTrackPrediction pred = actualFitter_->fit(updater, prior, states, ndof, chi2);
0027 
0028   double origin = pred.lambda(origin_);
0029   bool done = true;
0030   for (unsigned int i = 0; i < states.size(); i++) {
0031     GhostTrackState &state = states[i];
0032     double lambda = state.lambda();
0033     if (lambda < origin && (origin - lambda) < 3.5) {
0034       GhostTrackState testState = state;
0035       testState.linearize(pred, 2. * origin - lambda);
0036       double ndof, chi2;
0037 
0038       if (testState.isValid()) {
0039         updater.contribution(prior, testState, ndof, chi2, true);
0040         if (ndof > 0. && chi2 < 10.) {
0041           state = testState;
0042           if (state.weight() != 1.)
0043             state.setWeight(3.);
0044           done = false;
0045         }
0046       } else {
0047         edm::LogError("InvalidGhostTrackState") << "Invalid GhostTrackState encountered!";
0048       }
0049     }
0050   }
0051 
0052   if (!done) {
0053     for (unsigned int i = 0; i < states.size(); i++) {
0054       GhostTrackState &state = states[i];
0055       double lambda = state.lambda();
0056       if (state.weight() != 1. && lambda < origin) {
0057         double weight = std::exp(10. * (origin - lambda) - .1);
0058         state.setWeight(std::min(state.weight(), weight));
0059       }
0060     }
0061 
0062     pred = actualFitter_->fit(updater, prior, states, ndof, chi2);
0063   }
0064 
0065   return pred;
0066 }