-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * *
- * Author: Alberto Pulvirenti. *
- * *
- * Permission to use, copy, modify and distribute this software and its *
- * documentation strictly for non-commercial purposes is hereby granted *
- * without fee, provided that the above copyright notice appears in all *
- * copies and that both the copyright notice and this permission notice *
- * appear in the supporting documentation. The authors make no claims *
- * about the suitability of this software for any purpose. *
- * It is provided "as is" without express or implied warranty. *
- * *
- * AN ITS STAND-ALONE "NEURAL" TRACK FINDER *
- * ---------------------------------------- *
- * This class implements the Denby-Peterson algorithm for track finding *
- * in the ITS stand-alone, by means of a neural network simulation. *
- * Many parameters have to be set for the neural network to operate *
- * correctly and with a good efficiency. *
- * The neural tracker must be feeded with a TTree filled with objects *
- * of the class "AliITSNeuralPoint", into a single branch called *
- * "Points". *
- **************************************************************************/
-
-//#define NEURAL_LINEAR
-#include <fstream>
+///**************************************************************************
+// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+// * *
+// * Author: Alberto Pulvirenti. *
+// * *
+// * Permission to use, copy, modify and distribute this software and its *
+// * documentation strictly for non-commercial purposes is hereby granted *
+// * without fee, provided that the above copyright notice appears in all *
+// * copies and that both the copyright notice and this permission notice *
+// * appear in the supporting documentation. The authors make no claims *
+// * about the suitability of this software for any purpose. *
+// * It is provided "as is" without express or implied warranty. *
+// * *
+// * AN ITS STAND-ALONE "NEURAL" TRACK FINDER *
+// * ---------------------------------------- *
+// * This class implements the Denby-Peterson algorithm for track finding *
+// * in the ITS stand-alone, by means of a neural network simulation. *
+// * Many parameters have to be set for the neural network to operate *
+// * correctly and with a good efficiency. *
+// * The neural tracker must be feeded with a TTree filled with objects *
+// * of the class "AliITSNeuralPoint", into a single branch called *
+// * "Points". *
+// **************************************************************************/
+
+//#include <fstream>
#include <Riostream.h>
#include <stdlib.h>
-#include <TROOT.h>
+//#include <TROOT.h>
#include <TFile.h>
#include <TTree.h>
#include <TMath.h>
#include <TLine.h>
-#include <TMarker.h>
+//#include <TMarker.h>
#include <TRandom.h>
#include <TString.h>
#include <TCanvas.h>
#include <TVector3.h>
-#include <TParticle.h>
+//#include <TParticle.h>
#include <TObjArray.h>
-#include <TList.h>
+//#include <TList.h>
-#include "AliITSNeuralPoint.h"
#include "AliITSNeuralTracker.h"
-using namespace std;
+class AliITSNeuralPoint;
+
+//using namespace std;
ClassImp(AliITSNeuralTracker)
//--------------------------------------------------------------------------------------------
// It Destroys all the dynamic arrays and
// clears the TCollections and the points tree
- cout << "Starting destructor..." << endl;
-
delete [] fCurvCut;
Int_t ilayer, itheta;
if (fStructureOK) {
- cout << "Deleting points..." << endl;
for (ilayer = 0; ilayer < 6; ilayer++) {
for (itheta = 0; itheta < 180; itheta++) {
fPoints[ilayer][itheta]->SetOwner();
delete fPoints[ilayer][itheta];
}
}
- cout << "Deleting neurons..." << endl;
fNeurons->SetOwner();
delete fNeurons;
}
- cout << "AliITSNeuralTracker destructed completely!" << endl;
}
//
//--------------------------------------------------------------------------------------------
//
-void AliITSNeuralTracker::Display(TCanvas*& canv)
+void AliITSNeuralTracker::Display(TCanvas*& canv) const
{
+ // Displays the neural segments
+
Double_t x1, y1, x2, y2;
canv->Clear();
TObjArrayIter iter(fNeurons);
for (;;) {
AliITSneuron *unit = (AliITSneuron*)iter.Next();
if (!unit) break;
- if (unit->fActivation < fActMinimum) continue;
- x1 = unit->fInner->X();
- x2 = unit->fOuter->X();
- y1 = unit->fInner->Y();
- y2 = unit->fOuter->Y();
+ if (unit->Activation() < fActMinimum) continue;
+ x1 = unit->Inner()->X();
+ x2 = unit->Outer()->X();
+ y1 = unit->Inner()->Y();
+ y2 = unit->Outer()->Y();
TLine *line = new TLine(x1, y1, x2, y2);
canv->cd();
line->Draw();
//
void AliITSNeuralTracker::SetThetaCuts2D(Double_t *min, Double_t *max)
{
+ // Cut setter
+
Int_t i;
Double_t temp;
for (i = 0; i < 5; i++) {
//
void AliITSNeuralTracker::SetThetaCuts3D(Double_t *min, Double_t *max)
{
+ // Cut setter
+
Int_t i;
Double_t temp;
for (i = 0; i < 5; i++) {
//
void AliITSNeuralTracker::SetHelixMatchCuts(Double_t *min, Double_t *max)
{
+ // Cut setter
+
Int_t i;
Double_t temp;
for (i = 0; i < 5; i++) {
//
//--------------------------------------------------------------------------------------------
//
-Int_t AliITSNeuralTracker::ArrangePoints(TTree* pts_tree)
+Int_t AliITSNeuralTracker::ArrangePoints(TTree* ptstree)
{
// POINTS STORAGE INTO ARRAY
//
// Returns the number of points collected (if successful) or 0 (otherwise)
// check: if the points tree is NULL or empty, there is nothing to do...
- if ( !pts_tree || (pts_tree && !(Int_t)pts_tree->GetEntries()) ) {
+ if ( !ptstree || (ptstree && !(Int_t)ptstree->GetEntries()) ) {
Error("ArrangePoints", "Points tree is NULL or empty: no points to arrange");
return 0;
}
AliITSNode *created = 0;
AliITSNeuralPoint *cursor = 0;
- pts_tree->SetBranchAddress("pos", &pos);
- pts_tree->SetBranchAddress("Points", &cursor);
- nentries = (Int_t)pts_tree->GetEntries();
+ ptstree->SetBranchAddress("pos", &pos);
+ ptstree->SetBranchAddress("Points", &cursor);
+ nentries = (Int_t)ptstree->GetEntries();
for (ientry = 0; ientry < nentries; ientry++) {
- pts_tree->GetEntry(ientry);
+ ptstree->GetEntry(ientry);
// creates the object
created = new AliITSNode(cursor, kTRUE);
created->SetUser(-1);
- created->fPosInTree = pos;
+ created->PosInTree() = pos;
// finds the sector in phi
isector = created->GetSector(fSectorWidth);
itheta = created->GetThetaCell();
//--------------------------------------------------------------------------------------------
//
Bool_t AliITSNeuralTracker::PassCurvCut
-(AliITSNode *p1, AliITSNode *p2, Int_t curv_index, Double_t vx, Double_t vy, Double_t vz)
+(AliITSNode *p1, AliITSNode *p2, Int_t curvindex, Double_t vx, Double_t vy, Double_t vz)
{
// CURVATURE CUT EVALUATOR
//
// Checks the passsed point pair w.r. to the current curvature cut
// Returns the result of the check.
- if (curv_index < 0 || curv_index >= fCurvNum) {
- Error("PassCurvCut", "Curv index %d out of range", curv_index);
+ if (curvindex < 0 || curvindex >= fCurvNum) {
+ Error("PassCurvCut", "Curv index %d out of range", curvindex);
return kFALSE;
}
// Find the reference layer
Int_t lay1 = p1->GetLayer();
Int_t lay2 = p2->GetLayer();
- Int_t ref_layer = (lay1 < lay2) ? lay1 : lay2;
+ Int_t reflayer = (lay1 < lay2) ? lay1 : lay2;
Double_t x1 = p1->X() - vx;
Double_t x2 = p2->X() - vx;
/* FOR OLD VERSION
if (den != 0.) {
curv = fabs(num / den);
- if (curv > fCurvCut[curv_index]) return kFALSE;
+ if (curv > fCurvCut[curvindex]) return kFALSE;
return kTRUE;
}
else
*/
// NEW VERSION
if (den != 0.) {
- curv = fabs(num / den);
- if (curv > fCurvCut[curv_index]) return kFALSE;
+ curv = TMath::Abs(num / den);
+ if (curv > fCurvCut[curvindex]) return kFALSE;
}
else
return kFALSE;
// calculation of helix matching
Double_t arc1 = 2.0 * r1 * curv;
Double_t arc2 = 2.0 * r2 * curv;
- Double_t hel_match = 0.0;
+ Double_t helmatch = 0.0;
if (arc1 > -1.0 && arc1 < 1.0) arc1 = asin(arc1);
else arc1 = ((arc1 > 0.0) ? 0.5 : 1.5) * TMath::Pi();
if (arc2 > -1.0 && arc2 < 1.0) arc2 = asin(arc2);
arc1 /= 2.0 * curv;
arc2 /= 2.0 * curv;
if (arc1 == 0.0 || arc2 == 0.0) return kFALSE;
- hel_match = fabs(z1 / arc1 - z2 / arc2);
- return (hel_match >= fHelixMatchCutMin[ref_layer] && hel_match <= fHelixMatchCutMax[ref_layer]);
+ helmatch = TMath::Abs(z1 / arc1 - z2 / arc2);
+ return (helmatch >= fHelixMatchCutMin[reflayer] && helmatch <= fHelixMatchCutMax[reflayer]);
// END NEW VERSION
}
//
//--------------------------------------------------------------------------------------------
//
Int_t AliITSNeuralTracker::PassAllCuts
-(AliITSNode *p1, AliITSNode *p2, Int_t curv_index, Double_t vx, Double_t vy, Double_t vz)
+(AliITSNode *p1, AliITSNode *p2, Int_t curvindex, Double_t vx, Double_t vy, Double_t vz)
{
// GLOBAL CUT EVALUATOR
//
// 5 - helix cut not passed
// 6 - curvature inxed out of range
- if (curv_index < 0 || curv_index >= fCurvNum) return 6;
+ if (curvindex < 0 || curvindex >= fCurvNum) return 6;
// Find the reference layer
Int_t lay1 = p1->GetLayer();
Int_t lay2 = p2->GetLayer();
- Int_t ref_layer = (lay1 < lay2) ? lay1 : lay2;
+ Int_t reflayer = (lay1 < lay2) ? lay1 : lay2;
// Swap points in order that r1 < r2
AliITSNode *temp = 0;
TVector3 v01(z1, r1, 0.0);
TVector3 v12(z2 - z1, r2 - r1, 0.0);
dtheta = v01.Angle(v12) * 180.0 / TMath::Pi();
- TVector3 V01(x1, y1, z1);
- TVector3 V12(x2 - x1, y2 - y1, z2 - z1);
- dtheta3 = V01.Angle(V12) * 180.0 / TMath::Pi();
- if (dtheta < fThetaCut2DMin[ref_layer] || dtheta > fThetaCut2DMax[ref_layer]) return 1;
- if (dtheta3 < fThetaCut3DMin[ref_layer] || dtheta3 > fThetaCut3DMax[ref_layer]) return 2;
+ TVector3 vv01(x1, y1, z1);
+ TVector3 vv12(x2 - x1, y2 - y1, z2 - z1);
+ dtheta3 = vv01.Angle(vv12) * 180.0 / TMath::Pi();
+ if (dtheta < fThetaCut2DMin[reflayer] || dtheta > fThetaCut2DMax[reflayer]) return 1;
+ if (dtheta3 < fThetaCut3DMin[reflayer] || dtheta3 > fThetaCut3DMax[reflayer]) return 2;
// calculation of curvature
Double_t dx = x1 - x2, dy = y1 - y2;
Double_t den = r1*r2*sqrt(dx*dx + dy*dy);
Double_t curv = 0.;
if (den != 0.) {
- curv = fabs(num / den);
- if (curv > fCurvCut[curv_index]) return 3;
+ curv = TMath::Abs(num / den);
+ if (curv > fCurvCut[curvindex]) return 3;
}
else
return 4;
// calculation of helix matching
Double_t arc1 = 2.0 * r1 * curv;
Double_t arc2 = 2.0 * r2 * curv;
- Double_t hel_match = 0.0;
+ Double_t helmatch = 0.0;
if (arc1 > -1.0 && arc1 < 1.0) arc1 = asin(arc1);
else arc1 = ((arc1 > 0.0) ? 0.5 : 1.5) * TMath::Pi();
if (arc2 > -1.0 && arc2 < 1.0) arc2 = asin(arc2);
arc1 /= 2.0 * curv;
arc2 /= 2.0 * curv;
if (arc1 == 0.0 || arc2 == 0.0) return kFALSE;
- hel_match = fabs(z1 / arc1 - z2 / arc2);
- if (hel_match < fHelixMatchCutMin[ref_layer] || hel_match > fHelixMatchCutMax[ref_layer]) return 5;
+ helmatch = TMath::Abs(z1 / arc1 - z2 / arc2);
+ if (helmatch < fHelixMatchCutMin[reflayer] || helmatch > fHelixMatchCutMax[reflayer]) return 5;
return 0;
}
Int_t ilayer, isector, itheta1, itheta2, check;
TObjArray *list1 = 0, *list2 = 0;
AliITSNode *node1 = 0, *node2 = 0;
- Double_t theta_min, theta_max;
+ Double_t thetamin, thetamax;
Int_t imin, imax;
for (isector = 0; isector < fSectorNum; isector++) {
TObjArrayIter iter1(list1);
while ( (node1 = (AliITSNode*)iter1.Next()) ) {
if (node1->GetUser() >= 0) continue;
- node1->fMatches->Clear();
- theta_min = node1->ThetaDeg() - fPolarInterval;
- theta_max = node1->ThetaDeg() + fPolarInterval;
- imin = (Int_t)theta_min;
- imax = (Int_t)theta_max;
+ node1->Matches()->Clear();
+ thetamin = node1->ThetaDeg() - fPolarInterval;
+ thetamax = node1->ThetaDeg() + fPolarInterval;
+ imin = (Int_t)thetamin;
+ imax = (Int_t)thetamax;
if (imin < 0) imin = 0;
if (imax > 179) imax = 179;
for (itheta2 = imin; itheta2 <= imax; itheta2++) {
check = PassAllCuts(node1, node2, fCurvNum - 1, fVX, fVY, fVZ);
switch (check) {
case 0:
- node1->fMatches->AddLast(node2);
+ node1->Matches()->AddLast(node2);
break;
case 1:
//Info("StoreAbsoluteMatches", "Layer %d: THETA 2D cut not passed", ilayer);
//
void AliITSNeuralTracker::PrintMatches(Bool_t stop)
{
+ // Prints the matches for each point
+
TFile *ft = new TFile("its_findables_v1.root");
TTree *tt = (TTree*)ft->Get("Tracks");
Int_t it, nP, nU, lab, nF = (Int_t)tt->GetEntries();
TObjArrayIter points(sector);
while ( (node1 = (AliITSNode*)points.Next()) ) {
for (it = 0; it < 3; it++) id[it] = node1->GetLabel(it);
- nF = (Int_t)node1->fMatches->GetSize();
+ nF = (Int_t)node1->Matches()->GetSize();
cout << "Node layer: " << node1->GetLayer() << ", labels: ";
cout << id[0] << " " << id[1] << " " << id[2] << " --> ";
if (!nF) {
if (strU.Contains(Form("|%d|", id[it])))
cout << "Belongs to findable (post-Kalman) track " << id[it] << endl;
}
- TObjArrayIter Matches(node1->fMatches);
- while ( (node2 = (AliITSNode*)Matches.Next()) ) {
+ TObjArrayIter matches(node1->Matches());
+ while ( (node2 = (AliITSNode*)matches.Next()) ) {
cout << "Match with " << node2;
Int_t *sh = node1->SharedID(node2);
for (Int_t k = 0; k < 3; k++)
//
void AliITSNeuralTracker::ResetNodes(Int_t isector)
{
+ // Clears some utility arrays for each node
+
Int_t ilayer, itheta;
TObjArray *sector = 0;
AliITSNode *node = 0;
for (;;) {
node = (AliITSNode*)iter.Next();
if (!node) break;
- node->fInnerOf->Clear();
- node->fOuterOf->Clear();
- delete node->fInnerOf;
- delete node->fOuterOf;
- node->fInnerOf = new TObjArray;
- node->fOuterOf = new TObjArray;
+ node->InnerOf()->Clear();
+ node->OuterOf()->Clear();
+ delete node->InnerOf();
+ delete node->OuterOf();
+ node->InnerOf() = new TObjArray;
+ node->OuterOf() = new TObjArray;
}
}
}
//--------------------------------------------------------------------------------------------
//
void AliITSNeuralTracker::NeuralTracking(const char* filesave, TCanvas*& display)
+{
// This is the public method that operates the tracking.
// It works sector by sector, and at the end saves the found tracks.
// Other methods are privare because they have no meaning id used alone,
// and sometimes they could get segmentation faults due to uninitialized
// datamembert they require to work on.
// The argument is a file where the final results have to be stored.
-{
+
Bool_t isStable = kFALSE;
Int_t i, nUnits = 0, nLinks = 0, nTracks = 0, sectTracks = 0, totTracks = 0;
//
//--------------------------------------------------------------------------------------------
//
-Int_t AliITSNeuralTracker::CreateNeurons(Int_t sector_idx, Int_t curv_idx)
+Int_t AliITSNeuralTracker::CreateNeurons(Int_t sectoridx, Int_t curvidx)
+{
// Fills the neuron arrays, following the cut criteria for the selected step
// (secnum = sector to analyze, curvnum = curvature cut step to use)
// It also sets the initial random activation.
// the 'flag' argument is used to decide if the lower edge in the intevral
// of the accepted curvatures is given by zero (kFALSE) or by the preceding used cut (kTRUE)
// (if this is the first step, anyway, the minimum is always zero)
-{
- ResetNodes(sector_idx);
+
+ ResetNodes(sectoridx);
if (fNeurons) delete fNeurons;
fNeurons = new TObjArray;
AliITSneuron *unit = 0;
Int_t itheta, neurons = 0;
- TObjArray *lst_sector = 0;
+ TObjArray *lstsector = 0;
// NEW VERSION
Double_t vx[6], vy[6], vz[6];
AliITSNode *p[6] = {0, 0, 0, 0, 0, 0};
for (itheta = 0; itheta < 180; itheta++) {
- lst_sector = (TObjArray*)fPoints[0][itheta]->At(sector_idx);
- TObjArrayIter lay0(lst_sector);
+ lstsector = (TObjArray*)fPoints[0][itheta]->At(sectoridx);
+ TObjArrayIter lay0(lstsector);
while ( (p[0] = (AliITSNode*)lay0.Next()) ) {
if (p[0]->GetUser() >= 0) continue;
vx[0] = fVX;
vy[0] = fVY;
vz[0] = fVZ;
- TObjArrayIter lay1(p[0]->fMatches);
+ TObjArrayIter lay1(p[0]->Matches());
while ( (p[1] = (AliITSNode*)lay1.Next()) ) {
if (p[1]->GetUser() >= 0) continue;
- if (!PassCurvCut(p[0], p[1], curv_idx, fVX, fVY, fVZ)) continue;
+ if (!PassCurvCut(p[0], p[1], curvidx, fVX, fVY, fVZ)) continue;
unit = new AliITSneuron;
- unit->fInner = p[0];
- unit->fOuter = p[1];
- unit->fActivation = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
- unit->fGain = new TObjArray;
+ unit->Inner() = p[0];
+ unit->Outer() = p[1];
+ unit->Activation() = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
+ unit->Gain() = new TObjArray;
fNeurons->AddLast(unit);
- p[0]->fInnerOf->AddLast(unit);
- p[1]->fOuterOf->AddLast(unit);
+ p[0]->InnerOf()->AddLast(unit);
+ p[1]->OuterOf()->AddLast(unit);
neurons++;
vx[1] = p[0]->X();
vy[1] = p[0]->Y();
vz[1] = p[0]->Z();
- TObjArrayIter lay2(p[1]->fMatches);
+ TObjArrayIter lay2(p[1]->Matches());
while ( (p[2] = (AliITSNode*)lay2.Next()) ) {
if (p[2]->GetUser() >= 0) continue;
- if (!PassCurvCut(p[1], p[2], curv_idx, vx[1], vy[1], vz[1])) continue;
+ if (!PassCurvCut(p[1], p[2], curvidx, vx[1], vy[1], vz[1])) continue;
unit = new AliITSneuron;
- unit->fInner = p[1];
- unit->fOuter = p[2];
- unit->fActivation = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
- unit->fGain = new TObjArray;
+ unit->Inner() = p[1];
+ unit->Outer() = p[2];
+ unit->Activation() = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
+ unit->Gain() = new TObjArray;
fNeurons->AddLast(unit);
- p[1]->fInnerOf->AddLast(unit);
- p[2]->fOuterOf->AddLast(unit);
+ p[1]->InnerOf()->AddLast(unit);
+ p[2]->OuterOf()->AddLast(unit);
neurons++;
vx[2] = p[1]->X();
vy[2] = p[1]->Y();
vz[2] = p[1]->Z();
- TObjArrayIter lay3(p[2]->fMatches);
+ TObjArrayIter lay3(p[2]->Matches());
while ( (p[3] = (AliITSNode*)lay3.Next()) ) {
if (p[3]->GetUser() >= 0) continue;
- if (!PassCurvCut(p[2], p[3], curv_idx, vx[2], vy[2], vz[2])) continue;
+ if (!PassCurvCut(p[2], p[3], curvidx, vx[2], vy[2], vz[2])) continue;
unit = new AliITSneuron;
- unit->fInner = p[2];
- unit->fOuter = p[3];
- unit->fActivation = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
- unit->fGain = new TObjArray;
+ unit->Inner() = p[2];
+ unit->Outer() = p[3];
+ unit->Activation() = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
+ unit->Gain() = new TObjArray;
fNeurons->AddLast(unit);
- p[2]->fInnerOf->AddLast(unit);
- p[3]->fOuterOf->AddLast(unit);
+ p[2]->InnerOf()->AddLast(unit);
+ p[3]->OuterOf()->AddLast(unit);
neurons++;
vx[3] = p[2]->X();
vy[3] = p[2]->Y();
vz[3] = p[2]->Z();
- TObjArrayIter lay4(p[3]->fMatches);
+ TObjArrayIter lay4(p[3]->Matches());
while ( (p[4] = (AliITSNode*)lay4.Next()) ) {
if (p[4]->GetUser() >= 0) continue;
- if (!PassCurvCut(p[3], p[4], curv_idx, vx[3], vy[3], vz[3])) continue;
+ if (!PassCurvCut(p[3], p[4], curvidx, vx[3], vy[3], vz[3])) continue;
unit = new AliITSneuron;
- unit->fInner = p[3];
- unit->fOuter = p[4];
- unit->fActivation = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
- unit->fGain = new TObjArray;
+ unit->Inner() = p[3];
+ unit->Outer() = p[4];
+ unit->Activation() = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
+ unit->Gain() = new TObjArray;
fNeurons->AddLast(unit);
- p[3]->fInnerOf->AddLast(unit);
- p[4]->fOuterOf->AddLast(unit);
+ p[3]->InnerOf()->AddLast(unit);
+ p[4]->OuterOf()->AddLast(unit);
neurons++;
vx[4] = p[3]->X();
vy[4] = p[3]->Y();
vz[4] = p[3]->Z();
- TObjArrayIter lay5(p[4]->fMatches);
+ TObjArrayIter lay5(p[4]->Matches());
while ( (p[5] = (AliITSNode*)lay5.Next()) ) {
if (p[5]->GetUser() >= 0) continue;
- if (!PassCurvCut(p[4], p[5], curv_idx, vx[4], vy[4], vz[4])) continue;
+ if (!PassCurvCut(p[4], p[5], curvidx, vx[4], vy[4], vz[4])) continue;
unit = new AliITSneuron;
- unit->fInner = p[4];
- unit->fOuter = p[5];
- unit->fActivation = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
- unit->fGain = new TObjArray;
+ unit->Inner() = p[4];
+ unit->Outer() = p[5];
+ unit->Activation() = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
+ unit->Gain() = new TObjArray;
fNeurons->AddLast(unit);
- p[4]->fInnerOf->AddLast(unit);
- p[5]->fOuterOf->AddLast(unit);
+ p[4]->InnerOf()->AddLast(unit);
+ p[5]->OuterOf()->AddLast(unit);
neurons++;
} // while (p[5])
} // while (p[4])
/* OLD VERSION
for (ilayer = 0; ilayer < 6; ilayer++) {
for (itheta = 0; itheta < 180; itheta++) {
- lst_sector = (TObjArray*)fPoints[ilayer][itheta]->At(sector_idx);
- TObjArrayIter inners(lst_sector);
+ lstsector = (TObjArray*)fPoints[ilayer][itheta]->At(sectoridx);
+ TObjArrayIter inners(lstsector);
while ( (inner = (AliITSNode*)inners.Next()) ) {
if (inner->GetUser() >= 0) continue;
- TObjArrayIter outers(inner->fMatches);
+ TObjArrayIter outers(inner->Matches());
while ( (outer = (AliITSNode*)outers.Next()) ) {
if (outer->GetUser() >= 0) continue;
- if (!PassCurvCut(inner, outer, curv_idx, fVX, fVY, fVZ)) continue;
+ if (!PassCurvCut(inner, outer, curvidx, fVX, fVY, fVZ)) continue;
unit = new AliITSneuron;
- unit->fInner = inner;
- unit->fOuter = outer;
- unit->fActivation = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
- unit->fGain = new TObjArray;
+ unit->Inner() = inner;
+ unit->Outer() = outer;
+ unit->Activation() = gRandom->Rndm() * (fEdge1 - fEdge2) + fEdge2;
+ unit->Gain() = new TObjArray;
fNeurons->AddLast(unit);
- inner->fInnerOf->AddLast(unit);
- outer->fOuterOf->AddLast(unit);
+ inner->InnerOf()->AddLast(unit);
+ outer->OuterOf()->AddLast(unit);
neurons++;
} // for (;;)
} // for (;;)
//
//
//
-Int_t AliITSNeuralTracker::LinkNeurons()
+Int_t AliITSNeuralTracker::LinkNeurons() const
+{
// Creates the neural synapses among all neurons
// which share a point.
-{
+
Int_t total = 0;
- TObjArrayIter iter(fNeurons), *test_iter;
+ TObjArrayIter iter(fNeurons), *testiter;
AliITSneuron *neuron = 0, *test = 0;
for (;;) {
neuron = (AliITSneuron*)iter.Next();
if (!neuron) break;
// gain contributors
- test_iter = (TObjArrayIter*)neuron->fInner->fOuterOf->MakeIterator();
+ testiter = (TObjArrayIter*)neuron->Inner()->OuterOf()->MakeIterator();
for (;;) {
- test = (AliITSneuron*)test_iter->Next();
+ test = (AliITSneuron*)testiter->Next();
if (!test) break;
neuron->Add2Gain(test, fGain2CostRatio, fAlignExponent);
total++;
}
- delete test_iter;
- test_iter = (TObjArrayIter*)neuron->fOuter->fInnerOf->MakeIterator();
+ delete testiter;
+ testiter = (TObjArrayIter*)neuron->Outer()->InnerOf()->MakeIterator();
for (;;) {
- test = (AliITSneuron*)test_iter->Next();
+ test = (AliITSneuron*)testiter->Next();
if (!test) break;
neuron->Add2Gain(test, fGain2CostRatio, fAlignExponent);
total++;
}
- delete test_iter;
+ delete testiter;
}
return total;
}
//
//
Bool_t AliITSNeuralTracker::Update()
+{
// A complete updating cycle with the asynchronous method
// when the neural network is stable, kTRUE is returned.
-{
+
Double_t actVar = 0.0, totDiff = 0.0;
TObjArrayIter iter(fNeurons);
AliITSneuron *unit;
//
//
void AliITSNeuralTracker::CleanNetwork()
+{
// Removes all deactivated neurons, and resolves the competitions
// to the advantage of the most active unit
-{
+
AliITSneuron *unit = 0;
TObjArrayIter neurons(fNeurons);
while ( (unit = (AliITSneuron*)neurons.Next()) ) {
- if (unit->fActivation < fActMinimum) {
- unit->fInner->fInnerOf->Remove(unit);
- unit->fOuter->fOuterOf->Remove(unit);
+ if (unit->Activation() < fActMinimum) {
+ unit->Inner()->InnerOf()->Remove(unit);
+ unit->Outer()->OuterOf()->Remove(unit);
delete fNeurons->Remove(unit);
}
}
AliITSneuron *enemy = 0;
neurons.Reset();
while ( (unit = (AliITSneuron*)neurons.Next()) ) {
- nIn = (Int_t)unit->fInner->fInnerOf->GetSize();
- nOut = (Int_t)unit->fOuter->fOuterOf->GetSize();
+ nIn = (Int_t)unit->Inner()->InnerOf()->GetSize();
+ nOut = (Int_t)unit->Outer()->OuterOf()->GetSize();
if (nIn < 2 && nOut < 2) continue;
removed = kFALSE;
if (nIn > 1) {
- TObjArrayIter competing(unit->fInner->fInnerOf);
+ TObjArrayIter competing(unit->Inner()->InnerOf());
while ( (enemy = (AliITSneuron*)competing.Next()) ) {
- if (unit->fActivation > enemy->fActivation) {
- enemy->fInner->fInnerOf->Remove(enemy);
- enemy->fOuter->fOuterOf->Remove(enemy);
+ if (unit->Activation() > enemy->Activation()) {
+ enemy->Inner()->InnerOf()->Remove(enemy);
+ enemy->Outer()->OuterOf()->Remove(enemy);
delete fNeurons->Remove(enemy);
}
else {
- unit->fInner->fInnerOf->Remove(unit);
- unit->fOuter->fOuterOf->Remove(unit);
+ unit->Inner()->InnerOf()->Remove(unit);
+ unit->Outer()->OuterOf()->Remove(unit);
delete fNeurons->Remove(unit);
removed = kTRUE;
break;
if (removed) continue;
}
if (nOut > 1) {
- TObjArrayIter competing(unit->fOuter->fOuterOf);
+ TObjArrayIter competing(unit->Outer()->OuterOf());
while ( (enemy = (AliITSneuron*)competing.Next()) ) {
- if (unit->fActivation > enemy->fActivation) {
- enemy->fInner->fInnerOf->Remove(enemy);
- enemy->fOuter->fOuterOf->Remove(enemy);
+ if (unit->Activation() > enemy->Activation()) {
+ enemy->Inner()->InnerOf()->Remove(enemy);
+ enemy->Outer()->OuterOf()->Remove(enemy);
delete fNeurons->Remove(enemy);
}
else {
- unit->fInner->fInnerOf->Remove(unit);
- unit->fOuter->fOuterOf->Remove(unit);
+ unit->Inner()->InnerOf()->Remove(unit);
+ unit->Outer()->OuterOf()->Remove(unit);
delete fNeurons->Remove(unit);
removed = kTRUE;
break;
//
//
//
-Bool_t AliITSNeuralTracker::CheckOccupation()
+Bool_t AliITSNeuralTracker::CheckOccupation() const
{
+// checks if a track recognized has a point for each layer
Int_t i;
for (i = 0; i < 6; i++) if (fPoint[i] < 0) return kFALSE;
return kTRUE;
//
//
//
-Int_t AliITSNeuralTracker::Save(Int_t sector_id)
+Int_t AliITSNeuralTracker::Save(Int_t sectorid)
+{
// Creates chains of active neurons, in order to
// find the tracks obtained as the neural network output.
-{
+
// every chain is started from the neurons in the first 2 layers
Int_t i, check, stored = 0;
- Double_t test_act = 0;
+ Int_t a = sectorid; a = 0;
+ Double_t testact = 0;
AliITSneuron *unit = 0, *cursor = 0, *fwd = 0;
AliITSNode *node = 0;
- TObjArrayIter iter(fNeurons), *fwd_iter;
+ TObjArrayIter iter(fNeurons), *fwditer;
TObjArray *removedUnits = new TObjArray(0);
TObjArray *removedPoints = new TObjArray(6);
removedUnits->SetOwner(kFALSE);
for (i = 0; i < 6; i++) fPoint[i] = -1;
unit = (AliITSneuron*)iter.Next();
if (!unit) break;
- if (unit->fInner->GetLayer() > 0) continue;
- fPoint[unit->fInner->GetLayer()] = unit->fInner->fPosInTree;
- fPoint[unit->fOuter->GetLayer()] = unit->fOuter->fPosInTree;
- node = unit->fOuter;
+ if (unit->Inner()->GetLayer() > 0) continue;
+ fPoint[unit->Inner()->GetLayer()] = unit->Inner()->PosInTree();
+ fPoint[unit->Outer()->GetLayer()] = unit->Outer()->PosInTree();
+ node = unit->Outer();
removedUnits->AddLast(unit);
- removedPoints->AddAt(unit->fInner, unit->fInner->GetLayer());
- removedPoints->AddAt(unit->fOuter, unit->fOuter->GetLayer());
+ removedPoints->AddAt(unit->Inner(), unit->Inner()->GetLayer());
+ removedPoints->AddAt(unit->Outer(), unit->Outer()->GetLayer());
while (node) {
- test_act = fActMinimum;
- fwd_iter = (TObjArrayIter*)node->fInnerOf->MakeIterator();
+ testact = fActMinimum;
+ fwditer = (TObjArrayIter*)node->InnerOf()->MakeIterator();
fwd = 0;
for (;;) {
- cursor = (AliITSneuron*)fwd_iter->Next();
+ cursor = (AliITSneuron*)fwditer->Next();
if (!cursor) break;
- if (cursor->fUsed) continue;
- if (cursor->fActivation >= test_act) {
- test_act = cursor->fActivation;
+ if (cursor->Used()) continue;
+ if (cursor->Activation() >= testact) {
+ testact = cursor->Activation();
fwd = cursor;
}
}
if (!fwd) break;
removedUnits->AddLast(fwd);
- node = fwd->fOuter;
- fPoint[node->GetLayer()] = node->fPosInTree;
+ node = fwd->Outer();
+ fPoint[node->GetLayer()] = node->PosInTree();
removedPoints->AddAt(node, node->GetLayer());
}
check = 0;
node = (AliITSNode*)removedPoints->At(i);
node->SetUser(1);
}
- fwd_iter = (TObjArrayIter*)removedUnits->MakeIterator();
+ fwditer = (TObjArrayIter*)removedUnits->MakeIterator();
for (;;) {
- cursor = (AliITSneuron*)fwd_iter->Next();
+ cursor = (AliITSneuron*)fwditer->Next();
if(!cursor) break;
- cursor->fUsed = 1;
+ cursor->Used() = 1;
}
}
}
return stored;
}
/*
-Int_t AliITSNeuralTracker::Save(Int_t sector_idx)
+Int_t AliITSNeuralTracker::Save(Int_t sectoridx)
// Creates chains of active neurons, in order to
// find the tracks obtained as the neural network output.
{
// every chain is started from the neurons in the first 2 layers
// 00111111 00011111 00101111 00110111
- Int_t allow_mask[] = { 0x3F, 0x1F, 0x2F, 0x37,
+ Int_t allowmask[] = { 0x3F, 0x1F, 0x2F, 0x37,
0x3B, 0x3D, 0x3E };
// 00111011 00111101 00111110
- Double_t test_fwd = 0., test_back = 0.;
+ Double_t test_fwd = 0., testback = 0.;
Int_t ilayer, itheta;
AliITSNode *node = 0;
AliITSneuron *fwd = 0, *back = 0;
- TList *list_sector = 0;
+ TList *listsector = 0;
cout << "A -" << fActMinimum << "-" << flush;
for (ilayer = 0; ilayer < 6; ilayer++) {
for (itheta = 0; itheta < 180; itheta++) {
- list_sector = (TList*)fPoints[ilayer][itheta]->At(sector_idx);
- TListIter iter(list_sector);
+ listsector = (TList*)fPoints[ilayer][itheta]->At(sectoridx);
+ TListIter iter(listsector);
while ( (node = (AliITSNode*)iter.Next()) ) {
- TListIter fwd_iter(node->fInnerOf);
- TListIter back_iter(node->fOuterOf);
- test_fwd = test_back = fActMinimum;
- while ( (fwd = (AliITSneuron*)fwd_iter.Next()) ) {
- if (fwd->fActivation > test_fwd) {
- test_fwd = fwd->fActivation;
- node->fNext = fwd->fOuter;
+ TListIter fwditer(node->InnerOf());
+ TListIter backiter(node->OuterOf());
+ testfwd = testback = fActMinimum;
+ while ( (fwd = (AliITSneuron*)fwditer.Next()) ) {
+ if (fwd->Activation() > testfwd) {
+ testfwd = fwd->Activation();
+ node->fNext = fwd->Outer();
}
}
- while ( (back = (AliITSneuron*)back_iter.Next()) ) {
- if (back->fActivation > test_back) {
- test_back = back->fActivation;
- node->fPrev = back->fInner;
+ while ( (back = (AliITSneuron*)backiter.Next()) ) {
+ if (back->Activation() > testback) {
+ testback = back->Activation();
+ node->fPrev = back->Inner();
}
}
}
cout << "B" << flush;
for (ilayer = 0; ilayer < 5; ilayer++) {
for (itheta = 0; itheta < 180; itheta++) {
- list_sector = (TList*)fPoints[ilayer][itheta]->At(sector_idx);
- TListIter iter(list_sector);
+ listsector = (TList*)fPoints[ilayer][itheta]->At(sectoridx);
+ TListIter iter(listsector);
while ( (node = (AliITSNode*)iter.Next()) ) {
if (node->fNext) {
if (node->fNext->fPrev != node) node->fNext = 0;
AliITSNode *temp = 0;
TList *list[2];
for (itheta = 0; itheta < 180; itheta++) {
- list[0] = (TList*)fPoints[0][itheta]->At(sector_idx);
- list[1] = (TList*)fPoints[1][itheta]->At(sector_idx);
+ list[0] = (TList*)fPoints[0][itheta]->At(sectoridx);
+ list[1] = (TList*)fPoints[1][itheta]->At(sectoridx);
for (i = 0; i < 2; i++) {
TListIter iter(list[i]);
while ( (node = (AliITSNode*)iter.Next()) ) {
}
ok = kFALSE;
mask = chain->OccupationMask();
- for (im = 0; im < 7; im++) ok = ok || (mask == allow_mask[im]);
+ for (im = 0; im < 7; im++) ok = ok || (mask == allowmask[im]);
if (!ok) {
delete chain;
continue;
//
//
Double_t AliITSNeuralTracker::Activate(AliITSneuron* &unit)
+{
// Computes the new neural activation and
// returns the variation w.r.t the previous one
-{
+
if (!unit) return 0.0;
- Double_t sum_gain = 0.0, sum_cost = 0.0, input, actOld, actNew;
+ Double_t sumgain = 0.0, sumcost = 0.0, input, actOld, actNew;
// sum gain contributions
- TObjArrayIter *iter = (TObjArrayIter*)unit->fGain->MakeIterator();
+ TObjArrayIter *iter = (TObjArrayIter*)unit->Gain()->MakeIterator();
AliITSlink *link;
for(;;) {
link = (AliITSlink*)iter->Next();
if (!link) break;
- sum_gain += link->fLinked->fActivation * link->fWeight;
+ sumgain += link->Linked()->Activation() * link->Weight();
}
// sum cost contributions
- TObjArrayIter *test_iter = (TObjArrayIter*)unit->fInner->fInnerOf->MakeIterator();
+ TObjArrayIter *testiter = (TObjArrayIter*)unit->Inner()->InnerOf()->MakeIterator();
AliITSneuron *linked = 0;
for (;;) {
- linked = (AliITSneuron*)test_iter->Next();
+ linked = (AliITSneuron*)testiter->Next();
if (!linked) break;
if (linked == unit) continue;
- sum_cost += linked->fActivation;
+ sumcost += linked->Activation();
}
- delete test_iter;
- test_iter = (TObjArrayIter*)unit->fOuter->fOuterOf->MakeIterator();
+ delete testiter;
+ testiter = (TObjArrayIter*)unit->Outer()->OuterOf()->MakeIterator();
for (;;) {
- linked = (AliITSneuron*)test_iter->Next();
+ linked = (AliITSneuron*)testiter->Next();
if (!linked) break;
if (linked == unit) continue;
- sum_cost += linked->fActivation;
+ sumcost += linked->Activation();
}
- //cout << "gain = " << sum_gain << ", cost = " << sum_cost << endl;
+ //cout << "gain = " << sumgain << ", cost = " << sumcost << endl;
- input = (sum_gain - sum_cost) / fTemperature;
- actOld = unit->fActivation;
+ input = (sumgain - sumcost) / fTemperature;
+ actOld = unit->Activation();
#ifdef NEURAL_LINEAR
if (input <= -2.0 * fTemperature)
actNew = 0.0;
#else
actNew = 1.0 / (1.0 + TMath::Exp(-input));
#endif
- unit->fActivation = actNew;
+ unit->Activation() = actNew;
return TMath::Abs(actNew - actOld);
}
//
//
//
-void AliITSNeuralTracker::AliITSneuron::Add2Gain(AliITSneuron *n, Double_t mult_const, Double_t exponent)
+void AliITSNeuralTracker::AliITSneuron::Add2Gain(AliITSneuron *n, Double_t multconst, Double_t exponent)
{
+// Adds a neuron to the collection of sequenced ones of another neuron
+
AliITSlink *link = new AliITSlink;
- link->fLinked = n;
+ link->Linked() = n;
Double_t weight = Weight(n);
- link->fWeight = mult_const * TMath::Power(weight, exponent);
+ link->Weight() = multconst * TMath::Power(weight, exponent);
fGain->AddLast(link);
}
//
//
Double_t AliITSNeuralTracker::AliITSneuron::Weight(AliITSneuron *n)
{
- TVector3 me(fOuter->X() - fInner->X(), fOuter->Y() - fInner->Y(), fOuter->Z() - fInner->Z());
- TVector3 it(n->fOuter->X() - n->fInner->X(), n->fOuter->Y() - n->fInner->Y(), n->fOuter->Z() - n->fInner->Z());
+// computes synaptic weight
+ TVector3 me(Outer()->X() - Inner()->X(), Outer()->Y() - Inner()->Y(), Outer()->Z() - Inner()->Z());
+ TVector3 it(n->Outer()->X() - n->Inner()->X(), n->Outer()->Y() - n->Inner()->Y(), n->Outer()->Z() - n->Inner()->Z());
Double_t angle = me.Angle(it);
Double_t weight = 1.0 - sin(angle);
return weight;
}
+//
+//
+//
+//
+AliITSNeuralTracker::AliITSNeuralTracker(const AliITSNeuralTracker &t)
+: TObject((TObject&)t)
+{
+ // NO copy constructor
+ Fatal("AliITSNeuralTracker", "No copy constructor allowed!");
+ exit(0);
+}
+AliITSNeuralTracker& AliITSNeuralTracker::operator=(const AliITSNeuralTracker&)
+{
+ // NO assignment operator
+ Fatal("AliITSNeuralTracker", "No assignment allowed!");
+ return *this;
+}
+//
+AliITSNeuralTracker::AliITSNode::AliITSNode(const AliITSNode &t)
+: AliITSNeuralPoint((AliITSNeuralPoint&)t)
+{
+ // NO copy constructor
+ Fatal("AliITSNode", "No copy constructor allowed!");
+ exit(0);
+}
+AliITSNeuralTracker::AliITSNode& AliITSNeuralTracker::AliITSNode::operator=(const AliITSNode&)
+{
+ // NO assignment operator
+ Fatal("AliITSNode", "No assignment allowed!");
+ return *this;
+}
+//
+AliITSNeuralTracker::AliITSneuron::AliITSneuron(const AliITSneuron &t)
+: TObject((TObject&)t)
+{
+ // NO copy constructor
+ Fatal("AliITSneuron", "No copy constructor allowed!");
+ exit(0);
+}
+AliITSNeuralTracker::AliITSneuron& AliITSNeuralTracker::AliITSneuron::operator=(const AliITSneuron&)
+{
+ // NO assignment operator
+ Fatal("AliITSneuron", "No assignment allowed!");
+ return *this;
+}
+//
+AliITSNeuralTracker::AliITSlink::AliITSlink(const AliITSlink &t)
+: TObject((TObject&)t)
+{
+ // NO copy constructor
+ Fatal("AliITSlink", "No copy constructor allowed!");
+ exit(0);
+}
+AliITSNeuralTracker::AliITSlink& AliITSNeuralTracker::AliITSlink::operator=(const AliITSlink&)
+{
+ // NO assignment operator
+ Fatal("AliITSlink", "No assignment allowed!");
+ return *this;
+}
+
+
+