CbmRoot
CbmRichRingSelectAnn.cxx
Go to the documentation of this file.
1 #include "CbmRichRingSelectAnn.h"
2 #include "CbmRichGeoManager.h"
3 #include "CbmRichRingLight.h"
5 #include "TMultiLayerPerceptron.h"
6 #include "TSystem.h"
7 #include "TTree.h"
8 
9 #include <iostream>
10 
11 using std::cout;
12 using std::endl;
13 
15  : fAnnWeights(""), fNN(NULL), fSelectImpl(NULL) {
16  if (CbmRichGeoManager::GetInstance().fGP->fGeometryType
18  fAnnWeights = string(gSystem->Getenv("VMCWORKDIR"))
19  + "/parameters/rich/rich_v17a_select_ann_weights.txt";
20  } else if (CbmRichGeoManager::GetInstance().fGP->fGeometryType
22  fAnnWeights = string(gSystem->Getenv("VMCWORKDIR"))
23  + "/parameters/rich/rich_v16a_select_ann_weights.txt";
24  } else {
25  fAnnWeights = string(gSystem->Getenv("VMCWORKDIR"))
26  + "/parameters/rich/rich_v17a_select_ann_weights.txt";
27  }
28 }
29 
31 
34 
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:10:xOut", simu);
48  cout << "-I- CbmRichRingSelectAnn: get ANN weight parameters from: "
49  << fAnnWeights << endl;
50  fNN->LoadWeights(fAnnWeights.c_str());
51 }
52 
54  if (ring->GetRadius() >= 10.f || ring->GetRadius() <= 0.f
55  || ring->GetNofHits() <= 5.f || ring->GetRadialPosition() <= 0.f
56  || ring->GetRadialPosition() >= 999.f) {
57 
58  ring->SetSelectionNN(-1.f);
59  return;
60  }
62  if (ring->GetNofHitsOnRing() < 5) {
63  ring->SetSelectionNN(-1.f);
64  return;
65  }
66 
67  ring->SetAngle(fSelectImpl->GetAngle(ring));
68  if (ring->GetAngle() < 0.f || ring->GetAngle() > 6.3f) {
69  ring->SetSelectionNN(-1.f);
70  return;
71  }
72 
73  double params[6];
74  params[0] = ring->GetNofHits() / 45.;
75  params[1] = ring->GetAngle() / 6.28;
76  params[2] = ring->GetNofHitsOnRing() / 45.;
77  params[3] = ring->GetRadialPosition() / 110.;
78  params[4] = ring->GetRadius() / 10.;
79  params[5] = (ring->GetChi2() / ring->GetNofHits()) / 0.4;
80 
81  float nnEval = fNN->Evaluate(0, params);
82 
83  /* float nofHitsEval = ring->GetNofHits() / 35.;
84  if (nofHitsEval > 1) nofHitsEval = 1.;
85  float angleEval = 1. - ring->GetAngle() / 6.29;
86  if (angleEval > 1.) angleEval = 1.;
87  if (angleEval < 0.) angleEval = 0.;
88  float radialPosEval = ring->GetRadialPosition() / 100;
89  if (radialPosEval > 1.) radialPosEval = 1.;
90 
91 
92  nnEval = nofHitsEval * angleEval * radialPosEval;*/
93 
94  ring->SetSelectionNN(nnEval);
95 }
CbmRichRingSelectAnn::fSelectImpl
CbmRichRingSelectImpl * fSelectImpl
Definition: CbmRichRingSelectAnn.h:43
CbmRichRingLight::GetNofHitsOnRing
unsigned short GetNofHitsOnRing() const
Definition: CbmRichRingLight.h:260
f
float f
Definition: L1/vectors/P4_F32vec4.h:24
CbmRichRingSelectAnn::fAnnWeights
std::string fAnnWeights
Definition: CbmRichRingSelectAnn.h:41
CbmRichGeometryTypeTwoWings
@ CbmRichGeometryTypeTwoWings
Definition: CbmRichRecGeoPar.h:24
CbmRichRingLight::SetSelectionNN
void SetSelectionNN(float selectionNN)
Definition: CbmRichRingLight.h:157
CbmRichGeoManager::GetInstance
static CbmRichGeoManager & GetInstance()
Definition: CbmRichGeoManager.h:29
CbmRichRingSelectAnn::Init
virtual void Init()
Initialize ANN.
Definition: CbmRichRingSelectAnn.cxx:32
CbmRichRingLight::GetChi2
float GetChi2() const
Definition: CbmRichRingLight.h:242
CbmRichRingSelectImpl::GetAngle
float GetAngle(CbmRichRingLight *ring)
Definition: CbmRichRingSelectImpl.h:67
CbmRichRingLight::GetRadialPosition
float GetRadialPosition() const
Return radial position of the ring.
Definition: CbmRichRingLight.h:247
CbmRichRingSelectAnn::DoSelect
void DoSelect(CbmRichRingLight *ring)
Definition: CbmRichRingSelectAnn.cxx:53
CbmRichGeoManager.h
CbmRichRingLight::GetNofHits
int GetNofHits() const
Return number of hits in ring.
Definition: CbmRichRingLight.h:108
CbmRichRingSelectAnn.h
Implementation for concrete RICH ring selection algorithm: reject rings using a trained neural net (i...
CbmRichRingSelectAnn::CbmRichRingSelectAnn
CbmRichRingSelectAnn()
Standard constructor.
Definition: CbmRichRingSelectAnn.cxx:14
CbmRichRingLight.h
CbmRichRingSelectImpl
Definition: CbmRichRingSelectImpl.h:28
CbmRichGeometryTypeCylindrical
@ CbmRichGeometryTypeCylindrical
Definition: CbmRichRecGeoPar.h:25
CbmRichRingSelectImpl.h
CbmRichRingLight::GetRadius
float GetRadius() const
Definition: CbmRichRingLight.h:161
CbmRichRingSelectAnn::~CbmRichRingSelectAnn
virtual ~CbmRichRingSelectAnn()
Destructor.
Definition: CbmRichRingSelectAnn.cxx:30
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmRichRingSelectImpl::GetNofHitsOnRingCircle
int GetNofHitsOnRingCircle(CbmRichRingLight *ring)
Definition: CbmRichRingSelectImpl.h:50
CbmRichRingSelectAnn::fNN
TMultiLayerPerceptron * fNN
Definition: CbmRichRingSelectAnn.h:42
CbmRichRingLight::SetAngle
void SetAngle(float angle)
Definition: CbmRichRingLight.h:155
CbmRichRingLight::SetNofHitsOnRing
void SetNofHitsOnRing(unsigned short onring)
Definition: CbmRichRingLight.h:156
CbmRichRingLight
Definition: CbmRichRingLight.h:39
CbmRichRingLight::GetAngle
float GetAngle() const
Definition: CbmRichRingLight.h:258