Hello,
So …
I modified the mlpHiggs in order to do the do position rconstruction.
The code:
----------------------- code -------------------------------
void mlpPosRecon(Int_t ntrain=100) {
if (!gROOT->GetClass(“TMultiLayerPerceptron”)) {
gSystem->Load(“libMLP”);
}
const char *fname = “outfile_1000.root”;
TFile *input = 0;
if (!gSystem->AccessPathName(fname)) {
input = TFile::Open(fname);
}
if (!input) return;
TTree *training = (TTree *) input->Get(“tree”);
bool PMT0,PMT1,PMT2,PMT3,
PMT4,PMT5,PMT6,PMT7,
PMT8,PMT9,PMT10,PMT11;
int X, Y;
double x, y;
training->SetBranchAddress(“PMT0”, &PMT0);
training->SetBranchAddress(“PMT1”, &PMT1);
training->SetBranchAddress(“PMT2”, &PMT2);
training->SetBranchAddress(“PMT3”, &PMT3);
training->SetBranchAddress(“PMT4”, &PMT4);
training->SetBranchAddress(“PMT5”, &PMT5);
training->SetBranchAddress(“PMT6”, &PMT6);
training->SetBranchAddress(“PMT7”, &PMT7);
training->SetBranchAddress(“PMT8”, &PMT8);
training->SetBranchAddress(“PMT9”, &PMT9);
training->SetBranchAddress(“PMT10”, &PMT10);
training->SetBranchAddress(“PMT11”, &PMT11);
training->SetBranchAddress(“X”, &X);
training->SetBranchAddress(“Y”, &Y);
TMultiLayerPerceptron *mlp = new TMultiLayerPerceptron(“PMT0,PMT1,PMT2,PMT3,PMT4,PMT5,PMT6,PMT7,PMT8,PMT9,PMT10,PMT11:5:3:X,Y”,
training,“Entry$%2”,"(Entry$+1)%2");
mlp->SetLearningMethod(mlp->kBFGS);
mlp->Train(ntrain, “text,graph,update=10”);
mlp->DumpWeights(“weigts”);
mlp->Export(“test”,“c++”);
//training ends
/* ------- --------- -------- -------- ------- -------- ---------*/
// Use TMLPAnalyzer to see what it looks for
TCanvas* mlpa_canvas = new TCanvas(“mlpa_canvas”,“Network analysis”);
mlpa_canvas->Divide(2,2);
TMLPAnalyzer ana(mlp);
// Initialisation
ana.GatherInformations();
// output to the console
ana.CheckNetwork();
mlpa_canvas->cd(1);
// shows how each variable influences the network
ana.DrawDInputs();
mlpa_canvas->cd(2);
// shows the network structure
mlp->Draw();
mlpa_canvas->cd(3);
ana.DrawTruthDeviations();
mlpa_canvas->cd(4);
Double_t params[12];
int Xold, Yold;
TH1D* diffx = new TH1D(“diffx”, “diffx”, 320, -16, 16);
TH2D* histx = new TH2D(“histx”, “histx”, 160, 0, 16, 16, 0, 16);
TH2D* histy = new TH2D(“histy”, “histy”, 160, 0, 16, 16, 0, 16);
TH1D* norm = new TH1D(“norm”, “norm”, 10000, 0, 10);
TH2D* norm2 = new TH2D(“norm2”, “norm2”, 10000, 0, 10, 16, 0, 16);
// in order of the simplicity I want to reconstruct the same events with which I trained the network
for (int i = 0; i < training->GetEntries(); i++) {
training->GetEntry(i);
params[0] = PMT0;
params[1] = PMT1;
params[2] = PMT2;
params[3] = PMT3;
params[4] = PMT4;
params[5] = PMT5;
params[6] = PMT6;
params[7] = PMT7;
params[8] = PMT8;
params[9] = PMT9;
params[10] = PMT10;
params[11] = PMT11;
diffx->Fill(mlp->Evaluate(0, params)-X);
histx->Fill(mlp->Evaluate(0, params), X);
histy->Fill(mlp->Evaluate(1, params), Y);
if(X != 0){
norm->Fill(mlp->Evaluate(0, params)/X);
cout << mlp->Evaluate(0, params) << "; " << X << "; " << mlp->Evaluate(0, params)/X << endl;
norm2->Fill(mlp->Evaluate(0, params)/X, X);
}
}
diffx->Draw();
}
------------------------------- end of code ---------------------------
The result is strange:
The “input” of both variables X and Y are between 0 and 16. The “output” result of the network is between -8 and 8. This wouldnt be a problem. but there is no correlation between the input and the reconstructed value (at least I cant see any).
I tried to use normailized variables (between 0 and 1), but the result is the same.
Instead of sending you ps files, I sending the tree and the code …
Am I doing something wrong or … ?
Thanx in advance,
k.
PS: The data set is comind from a measurement.
We read out the light from a aerogel detector with 12 pmts placed around the the black-box of the aerogel.
Than we shot the box with charged pion-beam.
Outside the box there was two plastic-strip detector consists 16 strips each (this is the X and Y information), and the data was written out if the aerogel, and the two strip-detectors were in coincidence …
This is not the cleanest data ever (just because of the physical processes …), but it is clean enough to see correlation if we weight the PMT-signals …
outfile_1000.root (45.2 KB)