CMS 3D CMS Logo

Public Member Functions | Private Attributes

ConversionLikelihoodCalculator Class Reference

#include <ConversionLikelihoodCalculator.h>

List of all members.

Public Member Functions

double calculateLikelihood (reco::ConversionRef conversion)
double calculateLikelihood (reco::Conversion &conversion)
 ConversionLikelihoodCalculator ()
void setWeightsFile (const char *weightsFile)

Private Attributes

float log_abs_cot_theta_
float log_abs_delta_phi_
float log_chi2_max_pt_
float log_chi2_min_pt_
float log_e_over_p_
TMVA::Reader * reader_

Detailed Description

Definition at line 9 of file ConversionLikelihoodCalculator.h.


Constructor & Destructor Documentation

ConversionLikelihoodCalculator::ConversionLikelihoodCalculator ( )

Definition at line 4 of file ConversionLikelihoodCalculator.cc.

References log_abs_cot_theta_, log_abs_delta_phi_, log_chi2_max_pt_, log_chi2_min_pt_, log_e_over_p_, and reader_.

{
   reader_ = new TMVA::Reader("!Color:Silent");
   
//   std::cout << "Init Reader()" << std::endl;

   reader_->AddVariable("log(e_over_p)",        &log_e_over_p_);
   reader_->AddVariable("log(abs(cot_theta))",  &log_abs_cot_theta_);
   reader_->AddVariable("log(abs(delta_phi))",  &log_abs_delta_phi_);
   reader_->AddVariable("log(chi2_max_pt)", &log_chi2_max_pt_);
   reader_->AddVariable("log(chi2_min_pt)", &log_chi2_min_pt_);

}

Member Function Documentation

double ConversionLikelihoodCalculator::calculateLikelihood ( reco::ConversionRef  conversion)

Definition at line 25 of file ConversionLikelihoodCalculator.cc.

References kinem::delta_phi(), funct::log(), log_abs_cot_theta_, log_abs_delta_phi_, log_chi2_max_pt_, log_chi2_min_pt_, log_e_over_p_, pi, and reader_.

Referenced by ConvertedPhotonProducer::buildCollections().

{
   if (conversion->nTracks() != 2) return -1.;
   
   log_e_over_p_ = log(conversion->EoverP());

   log_abs_cot_theta_ = log(fabs(conversion->pairCotThetaSeparation()));

   double delta_phi = conversion->tracks()[0]->innerMomentum().phi()-conversion->tracks()[1]->innerMomentum().phi();
   double pi = 3.14159265;
   // phi normalization
   while (delta_phi > pi) delta_phi -= 2*pi;
   while (delta_phi < -pi) delta_phi += 2*pi;
   log_abs_delta_phi_ = log(fabs(delta_phi));

   double chi2_1 = conversion->tracks()[0]->normalizedChi2();
   double pt_1 = conversion->tracks()[0]->pt();

   double chi2_2 = conversion->tracks()[1]->normalizedChi2();
   double pt_2 = conversion->tracks()[1]->pt();

   double chi2_max_pt=chi2_1;
   double chi2_min_pt=chi2_2;

   if (pt_2 > pt_1) {
      chi2_max_pt=chi2_2;
      chi2_min_pt=chi2_1;
   }

   log_chi2_max_pt_ = log(chi2_max_pt);
   log_chi2_min_pt_ = log(chi2_min_pt);

//   std::cout << "log_e_over_p_ " << log_e_over_p_ << std::endl;
//   std::cout << "log_abs_cot_theta_ " << log_abs_cot_theta_ << std::endl;
//   std::cout << "log_abs_delta_phi_ " << log_abs_delta_phi_ << std::endl;
//   std::cout << "log_chi2_max_pt_ " << log_chi2_max_pt_ << std::endl;
//   std::cout << "log_chi2_min_pt_ " << log_chi2_min_pt_ << std::endl;
   std::vector<Float_t> inputVec;
   inputVec.push_back(log_e_over_p_ );
   inputVec.push_back(log_abs_cot_theta_ );
   inputVec.push_back(log_abs_delta_phi_ );
   inputVec.push_back(log_chi2_max_pt_ );
   inputVec.push_back(log_chi2_min_pt_ );
   float like = reader_->EvaluateMVA(inputVec,"Likelihood");
//   std::cout << "reader_->EvaluateMVA(\"Likelihood\") " << reader_->EvaluateMVA(inputVec,"Likelihood") << std::endl;

   return like;
}
double ConversionLikelihoodCalculator::calculateLikelihood ( reco::Conversion conversion)

Definition at line 74 of file ConversionLikelihoodCalculator.cc.

References kinem::delta_phi(), reco::Conversion::EoverP(), funct::log(), log_abs_cot_theta_, log_abs_delta_phi_, log_chi2_max_pt_, log_chi2_min_pt_, log_e_over_p_, reco::Conversion::nTracks(), reco::Conversion::pairCotThetaSeparation(), pi, reader_, reco::Conversion::tracks(), and reco::Conversion::tracksPin().

{

   if (conversion.nTracks() != 2) return -1.;
   
   log_e_over_p_ = log(conversion.EoverP());

   log_abs_cot_theta_ = log(fabs(conversion.pairCotThetaSeparation()));


   double delta_phi = conversion.tracksPin()[0].phi()-conversion.tracksPin()[1].phi();
   double pi = 3.14159265;
   // phi normalization
   while (delta_phi > pi) delta_phi -= 2*pi;
   while (delta_phi < -pi) delta_phi += 2*pi;
   log_abs_delta_phi_ = log(fabs(delta_phi));

   double chi2_1 = conversion.tracks()[0]->normalizedChi2();
   double pt_1 = conversion.tracks()[0]->pt();

   double chi2_2 = conversion.tracks()[1]->normalizedChi2();
   double pt_2 = conversion.tracks()[1]->pt();

   double chi2_max_pt=chi2_1;
   double chi2_min_pt=chi2_2;

   if (pt_2 > pt_1) {
      chi2_max_pt=chi2_2;
      chi2_min_pt=chi2_1;
   }

   log_chi2_max_pt_ = log(chi2_max_pt);
   log_chi2_min_pt_ = log(chi2_min_pt);

//   std::cout << "log_e_over_p_ " << log_e_over_p_ << std::endl;
//   std::cout << "log_abs_cot_theta_ " << log_abs_cot_theta_ << std::endl;
//   std::cout << "log_abs_delta_phi_ " << log_abs_delta_phi_ << std::endl;
//   std::cout << "log_chi2_max_pt_ " << log_chi2_max_pt_ << std::endl;
//   std::cout << "log_chi2_min_pt_ " << log_chi2_min_pt_ << std::endl;
   std::vector<Float_t> inputVec;
   inputVec.push_back(log_e_over_p_ );
   inputVec.push_back(log_abs_cot_theta_ );
   inputVec.push_back(log_abs_delta_phi_ );
   inputVec.push_back(log_chi2_max_pt_ );
   inputVec.push_back(log_chi2_min_pt_ );
   float like = reader_->EvaluateMVA(inputVec,"Likelihood");
//   std::cout << "reader_->EvaluateMVA(\"Likelihood\") " << reader_->EvaluateMVA(inputVec,"Likelihood") << std::endl;

   return like;
}
void ConversionLikelihoodCalculator::setWeightsFile ( const char *  weightsFile)

Definition at line 18 of file ConversionLikelihoodCalculator.cc.

References reader_.

{
//   std::cout << "Before BookMVA " << weightsFile << std::endl;
   reader_->BookMVA("Likelihood", weightsFile);
//   std::cout << "After  BookMVA" << std::endl;
}

Member Data Documentation

TMVA::Reader* ConversionLikelihoodCalculator::reader_ [private]