CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
ConversionLikelihoodCalculator Class Reference

#include <ConversionLikelihoodCalculator.h>

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_
 
std::unique_ptr< TMVA::Reader > reader_
 

Detailed Description

Definition at line 10 of file ConversionLikelihoodCalculator.h.

Constructor & Destructor Documentation

ConversionLikelihoodCalculator::ConversionLikelihoodCalculator ( )

Definition at line 3 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_.

3  {
4  reader_ = std::make_unique<TMVA::Reader>("!Color:Silent");
5 
6  // std::cout << "Init Reader()" << std::endl;
7 
8  reader_->AddVariable("log(e_over_p)", &log_e_over_p_);
9  reader_->AddVariable("log(abs(cot_theta))", &log_abs_cot_theta_);
10  reader_->AddVariable("log(abs(delta_phi))", &log_abs_delta_phi_);
11  reader_->AddVariable("log(chi2_max_pt)", &log_chi2_max_pt_);
12  reader_->AddVariable("log(chi2_min_pt)", &log_chi2_min_pt_);
13 }
std::unique_ptr< TMVA::Reader > reader_

Member Function Documentation

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

Definition at line 21 of file ConversionLikelihoodCalculator.cc.

References HLT_2018_cff::delta_phi, dqm-mbProfile::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().

21  {
22  if (conversion->nTracks() != 2)
23  return -1.;
24 
25  log_e_over_p_ = log(conversion->EoverP());
26 
27  log_abs_cot_theta_ = log(fabs(conversion->pairCotThetaSeparation()));
28 
29  double delta_phi = conversion->tracks()[0]->innerMomentum().phi() - conversion->tracks()[1]->innerMomentum().phi();
30  double pi = 3.14159265;
31  // phi normalization
32  while (delta_phi > pi)
33  delta_phi -= 2 * pi;
34  while (delta_phi < -pi)
35  delta_phi += 2 * pi;
36  log_abs_delta_phi_ = log(fabs(delta_phi));
37 
38  double chi2_1 = conversion->tracks()[0]->normalizedChi2();
39  double pt_1 = conversion->tracks()[0]->pt();
40 
41  double chi2_2 = conversion->tracks()[1]->normalizedChi2();
42  double pt_2 = conversion->tracks()[1]->pt();
43 
44  double chi2_max_pt = chi2_1;
45  double chi2_min_pt = chi2_2;
46 
47  if (pt_2 > pt_1) {
48  chi2_max_pt = chi2_2;
49  chi2_min_pt = chi2_1;
50  }
51 
52  log_chi2_max_pt_ = log(chi2_max_pt);
53  log_chi2_min_pt_ = log(chi2_min_pt);
54 
55  // std::cout << "log_e_over_p_ " << log_e_over_p_ << std::endl;
56  // std::cout << "log_abs_cot_theta_ " << log_abs_cot_theta_ << std::endl;
57  // std::cout << "log_abs_delta_phi_ " << log_abs_delta_phi_ << std::endl;
58  // std::cout << "log_chi2_max_pt_ " << log_chi2_max_pt_ << std::endl;
59  // std::cout << "log_chi2_min_pt_ " << log_chi2_min_pt_ << std::endl;
60  std::vector<Float_t> inputVec;
61  inputVec.push_back(log_e_over_p_);
62  inputVec.push_back(log_abs_cot_theta_);
63  inputVec.push_back(log_abs_delta_phi_);
64  inputVec.push_back(log_chi2_max_pt_);
65  inputVec.push_back(log_chi2_min_pt_);
66  float like = reader_->EvaluateMVA(inputVec, "Likelihood");
67  // std::cout << "reader_->EvaluateMVA(\"Likelihood\") " << reader_->EvaluateMVA(inputVec,"Likelihood") << std::endl;
68 
69  return like;
70 }
std::unique_ptr< TMVA::Reader > reader_
const Double_t pi
double ConversionLikelihoodCalculator::calculateLikelihood ( reco::Conversion conversion)

Definition at line 72 of file ConversionLikelihoodCalculator.cc.

References HLT_2018_cff::delta_phi, reco::Conversion::EoverP(), dqm-mbProfile::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().

72  {
73  if (conversion.nTracks() != 2)
74  return -1.;
75 
76  log_e_over_p_ = log(conversion.EoverP());
77 
78  log_abs_cot_theta_ = log(fabs(conversion.pairCotThetaSeparation()));
79 
80  double delta_phi = conversion.tracksPin()[0].phi() - conversion.tracksPin()[1].phi();
81  double pi = 3.14159265;
82  // phi normalization
83  while (delta_phi > pi)
84  delta_phi -= 2 * pi;
85  while (delta_phi < -pi)
86  delta_phi += 2 * pi;
87  log_abs_delta_phi_ = log(fabs(delta_phi));
88 
89  double chi2_1 = conversion.tracks()[0]->normalizedChi2();
90  double pt_1 = conversion.tracks()[0]->pt();
91 
92  double chi2_2 = conversion.tracks()[1]->normalizedChi2();
93  double pt_2 = conversion.tracks()[1]->pt();
94 
95  double chi2_max_pt = chi2_1;
96  double chi2_min_pt = chi2_2;
97 
98  if (pt_2 > pt_1) {
99  chi2_max_pt = chi2_2;
100  chi2_min_pt = chi2_1;
101  }
102 
103  log_chi2_max_pt_ = log(chi2_max_pt);
104  log_chi2_min_pt_ = log(chi2_min_pt);
105 
106  // std::cout << "log_e_over_p_ " << log_e_over_p_ << std::endl;
107  // std::cout << "log_abs_cot_theta_ " << log_abs_cot_theta_ << std::endl;
108  // std::cout << "log_abs_delta_phi_ " << log_abs_delta_phi_ << std::endl;
109  // std::cout << "log_chi2_max_pt_ " << log_chi2_max_pt_ << std::endl;
110  // std::cout << "log_chi2_min_pt_ " << log_chi2_min_pt_ << std::endl;
111  std::vector<Float_t> inputVec;
112  inputVec.push_back(log_e_over_p_);
113  inputVec.push_back(log_abs_cot_theta_);
114  inputVec.push_back(log_abs_delta_phi_);
115  inputVec.push_back(log_chi2_max_pt_);
116  inputVec.push_back(log_chi2_min_pt_);
117  float like = reader_->EvaluateMVA(inputVec, "Likelihood");
118  // std::cout << "reader_->EvaluateMVA(\"Likelihood\") " << reader_->EvaluateMVA(inputVec,"Likelihood") << std::endl;
119 
120  return like;
121 }
std::unique_ptr< TMVA::Reader > reader_
double EoverP() const
Definition: Conversion.cc:213
double pairCotThetaSeparation() const
Delta cot(Theta) where Theta is the angle in the (y,z) plane between the two tracks. Original tracks are used.
Definition: Conversion.cc:179
const Double_t pi
unsigned int nTracks() const
Number of tracks= 0,1,2.
Definition: Conversion.h:92
const std::vector< math::XYZVectorF > & tracksPin() const
Vector of track momentum measured at the innermost hit.
Definition: Conversion.h:152
std::vector< edm::RefToBase< reco::Track > > const & tracks() const
vector of track to base references
Definition: Conversion.cc:150
void ConversionLikelihoodCalculator::setWeightsFile ( const char *  weightsFile)

Definition at line 15 of file ConversionLikelihoodCalculator.cc.

References reader_.

15  {
16  // std::cout << "Before BookMVA " << weightsFile << std::endl;
17  reader_->BookMVA("Likelihood", weightsFile);
18  // std::cout << "After BookMVA" << std::endl;
19 }
std::unique_ptr< TMVA::Reader > reader_

Member Data Documentation

float ConversionLikelihoodCalculator::log_abs_cot_theta_
private
float ConversionLikelihoodCalculator::log_abs_delta_phi_
private
float ConversionLikelihoodCalculator::log_chi2_max_pt_
private
float ConversionLikelihoodCalculator::log_chi2_min_pt_
private
float ConversionLikelihoodCalculator::log_e_over_p_
private
std::unique_ptr<TMVA::Reader> ConversionLikelihoodCalculator::reader_
private