00001 #include "RecoEgamma/EgammaTools/interface/ConversionLikelihoodCalculator.h" 00002 00003 00004 ConversionLikelihoodCalculator::ConversionLikelihoodCalculator() 00005 { 00006 reader_ = new TMVA::Reader(); 00007 00008 reader_->AddVariable("log(e_over_p)", &log_e_over_p_); 00009 reader_->AddVariable("log(abs(cot_theta))", &log_abs_cot_theta_); 00010 reader_->AddVariable("log(abs(delta_phi))", &log_abs_delta_phi_); 00011 reader_->AddVariable("log(chi2_max_pt)", &log_chi2_max_pt_); 00012 reader_->AddVariable("log(chi2_min_pt)", &log_chi2_min_pt_); 00013 00014 } 00015 00016 void ConversionLikelihoodCalculator::setWeightsFile(const char * weightsFile) 00017 { 00018 reader_->BookMVA("Likelihood", weightsFile); 00019 } 00020 00021 double ConversionLikelihoodCalculator::calculateLikelihood(reco::ConversionRef conversion) 00022 { 00023 if (conversion->nTracks() != 2) return -1.; 00024 00025 log_e_over_p_ = log(conversion->EoverP()); 00026 00027 log_abs_cot_theta_ = log(fabs(conversion->pairCotThetaSeparation())); 00028 00029 double delta_phi = conversion->tracks()[0]->innerMomentum().phi()-conversion->tracks()[1]->innerMomentum().phi(); 00030 double pi = 3.14159265; 00031 // phi normalization 00032 while (delta_phi > pi) delta_phi -= 2*pi; 00033 while (delta_phi < -pi) delta_phi += 2*pi; 00034 log_abs_delta_phi_ = log(fabs(delta_phi)); 00035 00036 double chi2_1 = conversion->tracks()[0]->normalizedChi2(); 00037 double pt_1 = conversion->tracks()[0]->pt(); 00038 00039 double chi2_2 = conversion->tracks()[1]->normalizedChi2(); 00040 double pt_2 = conversion->tracks()[1]->pt(); 00041 00042 double chi2_max_pt=chi2_1; 00043 double chi2_min_pt=chi2_2; 00044 00045 if (pt_2 > pt_1) { 00046 chi2_max_pt=chi2_2; 00047 chi2_min_pt=chi2_1; 00048 } 00049 00050 log_chi2_max_pt_ = log(chi2_max_pt); 00051 log_chi2_min_pt_ = log(chi2_min_pt); 00052 00053 return reader_->EvaluateMVA("Likelihood"); 00054 }