CbmRoot
CbmKresSelectAnn.cxx
Go to the documentation of this file.
1 
14 #include "CbmKresSelectAnn.h"
15 
16 #include <boost/assign/list_of.hpp>
17 
18 #include <iostream>
19 #include <string>
20 #include <vector>
21 
22 #include "TMath.h"
23 #include "TSystem.h"
24 #include "TTree.h"
25 
26 
27 using namespace std;
28 
29 CbmKresSelectAnn::CbmKresSelectAnn() : fAnnWeights(), fNN(nullptr) {}
30 
32 
34  TTree* simu = new TTree("MonteCarlo", "MontecarloData");
35  Double_t x[6];
36  Double_t xOut;
37 
38  simu->Branch("x0", &x[0], "x0/D");
39  simu->Branch("x1", &x[1], "x1/D");
40  simu->Branch("x2", &x[2], "x2/D");
41  simu->Branch("x3", &x[3], "x3/D");
42  simu->Branch("x4", &x[4], "x4/D");
43  simu->Branch("x5", &x[5], "x5/D");
44  simu->Branch("xOut", &xOut, "xOut/D");
45 
46  fNN = new TMultiLayerPerceptron("x0,x1,x2,x3,x4,x5:12:xOut", simu);
47 
48  fAnnWeights = string(gSystem->Getenv("VMCWORKDIR"))
49  + "/analysis/conversion2/KresAnalysis_ann_weights.txt";
50  cout << "-I- CbmKresSelectAnn: get ANN weight parameters from: "
51  << fAnnWeights << endl;
52  fNN->LoadWeights(fAnnWeights.c_str());
53 }
54 
55 double CbmKresSelectAnn::DoSelect(double InvariantMass,
56  double OpeningAngle,
57  double PlaneAngle_last,
58  double ZPos,
59  TVector3 Momentum1,
60  TVector3 Momentum2) {
61  double AnnValue = 0;
62 
63  double p1 =
64  TMath::Sqrt(Momentum1.X() * Momentum1.X() + Momentum1.Y() * Momentum1.Y()
65  + Momentum1.Z() * Momentum1.Z());
66  double p2 =
67  TMath::Sqrt(Momentum2.X() * Momentum2.X() + Momentum2.Y() * Momentum2.Y()
68  + Momentum2.Z() * Momentum2.Z());
69 
70  if (InvariantMass > 0.5 || OpeningAngle > 45 || ZPos > 100 || p1 > 10
71  || p2 > 10) {
72  return AnnValue = -1;
73  }
74 
75 
76  double params[6];
77 
78  params[0] = InvariantMass / 0.1;
79  params[1] = OpeningAngle / 30;
80  params[2] = PlaneAngle_last / 30;
81  params[3] = ZPos / 100;
82  params[4] = p1 / 5;
83  params[5] = p2 / 5;
84 
85  if (params[0] > 1.0) params[0] = 1.0;
86  if (params[1] > 1.0) params[1] = 1.0;
87  if (params[2] > 1.0) params[2] = 1.0;
88  if (params[3] > 1.0) params[3] = 1.0;
89  if (params[4] > 1.0) params[4] = 1.0;
90  if (params[5] > 1.0) params[5] = 1.0;
91 
92  AnnValue = fNN->Evaluate(0, params);
93 
94  return AnnValue;
95 }
CbmKresSelectAnn::fAnnWeights
std::string fAnnWeights
Definition: CbmKresSelectAnn.h:29
CbmKresSelectAnn::fNN
TMultiLayerPerceptron * fNN
Definition: CbmKresSelectAnn.h:30
CbmKresSelectAnn::Init
void Init()
Definition: CbmKresSelectAnn.cxx:33
CbmKresSelectAnn.h
CbmKresSelectAnn::DoSelect
double DoSelect(double InvariantMass, double OpeningAngle, double PlaneAngle_last, double ZPos, TVector3 Momentum1, TVector3 Momentum2)
Definition: CbmKresSelectAnn.cxx:55
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmKresSelectAnn::CbmKresSelectAnn
CbmKresSelectAnn()
Definition: CbmKresSelectAnn.cxx:29
CbmKresSelectAnn::~CbmKresSelectAnn
virtual ~CbmKresSelectAnn()
Definition: CbmKresSelectAnn.cxx:31