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