EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmRichRingSelectAnn.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmRichRingSelectAnn.cxx
1 #include "CbmRichRingSelectAnn.h"
2 #include "CbmRichRingLight.h"
4 
5 #include "TTree.h"
6 #include "TSystem.h"
7 #include "TMultiLayerPerceptron.h"
8 
9 #include <iostream>
10 
11 using std::cout;
12 using std::endl;
13 
15  fAnnWeights(""),
16  fNN(NULL),
17  fSelectImpl(NULL)
18 {
19  fAnnWeights = string(gSystem->Getenv("VMCWORKDIR")) +"/parameters/rich/rich_select_ann_weights.txt";
20 }
21 
23 {
24 
25 }
26 
28 {
30 
31  TTree *simu = new TTree ("MonteCarlo","MontecarloData");
32  Double_t x[6];
33  Double_t xOut;
34 
35  simu->Branch("x0", &x[0],"x0/D");
36  simu->Branch("x1", &x[1],"x1/D");
37  simu->Branch("x2", &x[2],"x2/D");
38  simu->Branch("x3", &x[3],"x3/D");
39  simu->Branch("x4", &x[4],"x4/D");
40  simu->Branch("x5", &x[5],"x5/D");
41  simu->Branch("xOut", &xOut,"xOut/D");
42 
43  fNN = new TMultiLayerPerceptron("x0,x1,x2,x3,x4,x5:10:xOut", simu);
44  cout << "-I- CbmRichRingSelectNeuralNet: get NeuralNet weight parameters from: " << fAnnWeights << endl;
45  fNN->LoadWeights(fAnnWeights.c_str());
46 
47 }
48 
50  CbmRichRingLight* ring)
51 {
52  if (ring->GetRadius() >= 10.f || ring->GetRadius() <= 0.f ||
53  ring->GetNofHits() <= 5.f ||
54  ring->GetRadialPosition() <= 0.f || ring->GetRadialPosition() >= 999.f ){
55 
56  ring->SetSelectionNN(-1.f);
57  return;
58  }
60  if (ring->GetNofHitsOnRing() < 5){
61  ring->SetSelectionNN(-1.f);
62  return;
63  }
64 
65  ring->SetAngle(fSelectImpl->GetAngle(ring));
66  if (ring->GetAngle() < 0.f || ring->GetAngle() > 6.3f){
67  ring->SetSelectionNN(-1.f);
68  return;
69  }
70 
71  double params[6];
72  params[0] = ring->GetNofHits() / 45.;
73  params[1] = ring->GetAngle() / 6.28;
74  params[2] = ring->GetNofHitsOnRing() / 45.;
75  params[3] = ring->GetRadialPosition() / 110.;
76  params[4] = ring->GetRadius() / 10.;
77  params[5] = (ring->GetChi2() / ring->GetNofHits()) / 0.4;
78 
79  float nnEval = fNN->Evaluate(0, params);
80 
81  ring->SetSelectionNN(nnEval);
82 }