/****************************************************************************** * $Id: CbmRichRingSelectNeuralNet.cxx,v 1.1 2006/09/13 14:53:31 hoehne Exp $ * * Class : CbmRichRingSelect2DCuts * Description : Implementation for concrete RICH ring selection algorithm: * reject rings using a trained neural net (input file with weights needed!) * store resulting value (0-1) in "SelectionNN": * 0 = good rings * 1 = rings to be rejected * --> choose a value in between depending on required purity/ efficiency * * Author : Simeon Lebedev * E-mail : salebedev@jinr.ru * ******************************************************************************* * $Log: CbmRichRingSelectNeuralNet.cxx,v $ * Revision 1.1 2006/09/13 14:53:31 hoehne * initial version * * * *******************************************************************************/ #include "CbmRichRingSelectNeuralNet.h" #include "CbmRichHit.h" #include "CbmRichRing.h" #include "TMultiLayerPerceptron.h" #include "TTree.h" using namespace std; //-------------------------------------------------------------------------- // ----- Default constructor ------------------------------------------- CbmRichRingSelectNeuralNet::CbmRichRingSelectNeuralNet() { fVerbose = 1; } // ----- Standard constructor ------------------------------------------ CbmRichRingSelectNeuralNet::CbmRichRingSelectNeuralNet ( Int_t verbose, const char* NNFile ) { fVerbose = verbose; fNeuralNetWeights = NNFile; } // ----- Destructor ---------------------------------------------------- CbmRichRingSelectNeuralNet::~CbmRichRingSelectNeuralNet() {} // ----- Initialization ---------------------------------------------------- void CbmRichRingSelectNeuralNet::Init () { TTree *simu = new TTree ("MonteCarlo","MontecarloData"); Float_t x1,x2,x3,x5,x7,x8; Int_t x4,x6,x9; simu->Branch("x1", &x1,"x1/F"); simu->Branch("x2", &x2,"x2/F"); simu->Branch("x3", &x3,"x3/F"); simu->Branch("x4", &x4,"x4/I"); simu->Branch("x5", &x5,"x5/F"); simu->Branch("x6", &x6,"x6/I"); simu->Branch("x7", &x7,"x7/F"); simu->Branch("x8", &x8,"x8/F"); simu->Branch("x9", &x9,"x9/I"); fNN = new TMultiLayerPerceptron("x1,x2,x3,x4,x5,x6,x7,x8:30:x9",simu); //char* NeuralNetWeights = "NeuralNet_RingSelection_Weights.txt"; cout << "-I- CbmRichRingSelectNeuralNet: get NeuralNet weight parameters from: " << fNeuralNetWeights << endl; fNN->LoadWeights(fNeuralNetWeights); } // ----- Exec ---------------------------------------------------- void CbmRichRingSelectNeuralNet::DoSelect(CbmRichRing* ring, TClonesArray* rProjArray) { Double_t lChi2 = GetChi2(ring); if (fVerbose > 1) cout << " RingSelectNN: GetChi2 = " << lChi2 << endl; UInt_t lTBSum = GetTBSum(ring); if (fVerbose > 1) cout << " RingSelectNN: GetTBSum = " << lTBSum << endl; Double_t lAngle = GetAngle(ring); if (fVerbose > 1) cout << " RingSelectNN: GetAngle = " << lAngle << endl; Double_t lRadPos = GetRadPos(ring); if (fVerbose > 1) cout << " RingSelectNN: GetRadPos = " << lRadPos << endl; Double_t lTrackD = GetTrackDist(ring,rProjArray); if (fVerbose > 1) cout << " RingSelectNN: GetTrackDist = " << lTrackD << endl; Int_t lNofHits = ring->GetNoOfHits(); if (fVerbose > 1) cout << " RingSelectNN: GetNoOfHits = " << lNofHits << endl; Double_t lRadius = ring->GetRadius(); if (fVerbose > 1) cout << " RingSelectNN: GetRadius = " << lRadius << endl; Double_t nnPar[8]; nnPar[0] = lAngle; nnPar[1] = lChi2; nnPar[2] = lRadPos; nnPar[3] = lTBSum; nnPar[4] = lTrackD; nnPar[5] = lNofHits; nnPar[6] = (Double_t)lTBSum/(Double_t)lNofHits; nnPar[7] = lRadius; Double_t nnEval = fNN->Evaluate(0,nnPar); if (fVerbose > 1) cout <<"nnEval = "<SetSelectionNN(nnEval); } // ------------------------------------------------------------------------- ClassImp(CbmRichRingSelectNeuralNet)