{ int i; std::ifstream finFakeAndTrue("example_RichStandard_ann_fake_and_true.txt"); if(!gROOT->GetClass("TMultiLayerPerceptron")) gSystem->Load("libMLP"); TTree *simu = new TTree ("MonteCarlo","MontecarloData"); Float_t x1,x2,x3,x4,x5,x6,x7,x8; simu->Branch("x1", &x1,"x1/F"); simu->Branch("x2", &x2,"x2/F"); simu->Branch("x3", &x3,"x3/F"); simu->Branch("x4", &x4,"x4/F"); simu->Branch("x5", &x5,"x5/F"); simu->Branch("x6", &x6,"x6/F"); simu->Branch("x7", &x7,"x7/F"); simu->Branch("x8", &x8,"x8/F"); Int_t maxNofFake = 3500; Int_t maxNofTrue = 3500; Int_t inputCountTrue = 0; Int_t inputCountFake = 0; while ( !finFakeAndTrue.eof() ){ finFakeAndTrue >> x1 >> x2 >> x3 >> x4 >> x5 >> x6 >> x7 >> x8 ; if ( x8 == -1 && inputCountFake < maxNofFake){ inputCountFake++; simu->Fill(); } if (x8 == 1 && inputCountTrue < maxNofTrue){ inputCountTrue++; simu->Fill(); } if (inputCountFake >= maxNofFake&& inputCountTrue >= maxNofTrue){ break; } } TMultiLayerPerceptron network("x1,x2,x3,x4,x5,x6,x7:30:x8",simu,"Entry$+1"); network.LoadWeights("NeuralNet_RingSelection_Weights.txt"); //network.SetLearningMethod(network.kStochastic); //network.Train(500,"text,update=1"); network.DumpWeights("NeuralNet_RingSelection_Weights.txt"); //TH1F *h = new TH1F("Error","Error",100, 0, 1); TH1F *hANNOutputFake = new TH1F("hANNOutputFake","ANN output",100, -1.2, 1.2); TH1F *hANNOutputTrue = new TH1F("hANNOutputTrue","ANN optput",100, -1.2, 1.2); //hANNOutputTrue->SetLogx(); Double_t ANNCut = -.5; Double_t params[12]; std::ifstream finTest("example_RichStandard_ann_fake_and_true.txt"); Int_t NofFakeLikeTrue = 0; Int_t NofTrueLikeFake = 0; Int_t NofTrueTest = 0; Int_t NofFakeTest = 0; while ( !finTest.eof() ){ finTest >> x1 >> x2 >> x3 >> x4 >> x5 >> x6 >> x7 >> x8 ; if (x8 == -1)NofFakeTest++; if (x8 == 1 )NofTrueTest++; params[0] = x1; params[1] = x2; params[2] = x3; params[3] = x4; params[4] = x5; params[5] = x6; params[6] = x7; Double_t netEval = network.Evaluate(0,params); if (x8 == -1) hANNOutputFake->Fill(netEval); if (x8 == 1) hANNOutputTrue->Fill(netEval); if (netEval > ANNCut && x8 == -1) NofFakeLikeTrue++; if (netEval < ANNCut && x8 == 1) NofTrueLikeFake++; } cout <<"NofTrue = " <SetLogy(); }