1 ///////////////////////////////////////////////////////////////////////
3 // AliITSneuralTracker:
5 // neural network MFT algorithm
6 // for track finding in ITS stand alone
7 // according to the Denby-Peterson model with adaptments to the
10 ///////////////////////////////////////////////////////////////////////
12 #ifndef ALIITSNEURALTRACKER_H
13 #define ALIITSNEURALTRACKER_H
18 #include "AliITSNeuralPoint.h"
20 class AliITSNeuralTracker : public TObject {
24 AliITSNeuralTracker();
25 virtual ~AliITSNeuralTracker();
27 // ******************************************************************************
28 // * Embedded utility class --> >>> NODE <<<
29 // ******************************************************************************
30 // * This class inherits from AliITSNeuralPoint and adds some
31 // * utility pointers for quick path-finding among neurons.
32 // ******************************************************************************
33 class AliITSNode : public AliITSNeuralPoint {
35 AliITSNode():fPosInTree(0),fInnerOf(0),fOuterOf(0),fMatches(0),fNext(0),fPrev(0){}
37 AliITSNode(AliITSNeuralPoint *p, Bool_t init = kTRUE): AliITSNeuralPoint(p),fPosInTree(0),fInnerOf(0),fOuterOf(0),fMatches(0),fNext(0),fPrev(0) {
38 if (init) { fInnerOf = new TObjArray; fOuterOf = new TObjArray; fMatches = new TObjArray;}}
39 AliITSNode(AliITSRecPoint *p, AliITSgeomMatrix *gm)
40 : AliITSNeuralPoint(p,gm),fPosInTree(0),fInnerOf(0),fOuterOf(0),fMatches(0),fNext(0),fPrev(0) {}
43 {fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;}
47 Double_t ThetaDeg() {return GetTheta()*180.0/TMath::Pi();}
49 Int_t GetSector(Double_t secwidth) const {return (Int_t)(GetPhi()/secwidth);}
50 Int_t GetThetaCell() {return (Int_t)(ThetaDeg());}
52 Int_t& PosInTree() {return fPosInTree;}
54 TObjArray*& InnerOf() {return fInnerOf;}
55 TObjArray*& OuterOf() {return fOuterOf;}
56 TObjArray*& Matches() {return fMatches;}
58 AliITSNode*& Next() {return fNext;}
59 AliITSNode*& Prev() {return fPrev;}
62 AliITSNode(const AliITSNode &t);
63 AliITSNode& operator=(const AliITSNode& t);
64 Int_t fPosInTree; // position in tree of converted points
65 TObjArray *fInnerOf; //!
66 TObjArray *fOuterOf; //!
67 TObjArray *fMatches; //!
69 AliITSNode *fNext; //!
70 AliITSNode *fPrev; //!
72 // ******************************************************************************
76 // ******************************************************************************
77 // * Embedded utility class --> >>> NEURON <<<
78 // ******************************************************************************
79 // * Simple class implementing the neural unit.
80 // * Contains the activation and some other pointers
81 // * for purposes similar to the ones in AliITSnode.
82 // ******************************************************************************
83 class AliITSneuron : public TObject {
85 AliITSneuron():fUsed(0),fActivation(0.),fInner(0),fOuter(0),fGain(0) { }
87 virtual ~AliITSneuron() {fInner=fOuter=0;fGain=0;}
91 Double_t Weight(AliITSneuron *n);
92 void Add2Gain(AliITSneuron *n, Double_t multconst, Double_t exponent);
94 Int_t& Used() {return fUsed;}
95 Double_t& Activation() {return fActivation;}
96 AliITSNode*& Inner() {return fInner;}
97 AliITSNode*& Outer() {return fOuter;}
98 TObjArray*& Gain() {return fGain;}
102 AliITSneuron(const AliITSneuron &t);
103 AliITSneuron& operator=(const AliITSneuron& t);
105 Int_t fUsed; // utility flag
106 Double_t fActivation; // Activation value
107 AliITSNode *fInner; //! inner point
108 AliITSNode *fOuter; //! outer point
109 TObjArray *fGain; //! list of sequenced units
111 // ******************************************************************************
115 // ******************************************************************************
116 // * Embedded utility class --> >>> CONNECTION <<<
117 // ******************************************************************************
118 // * Used to implement the neural weighted connection
119 // * in such a way to speed up the retrieval of the
120 // * links among neuron, for a fast update procedure.
121 // ******************************************************************************
122 class AliITSlink : public TObject {
124 AliITSlink() : fWeight(0.), fLinked(0) { }
126 virtual ~AliITSlink() {fLinked = 0;}
129 Double_t& Weight() {return fWeight;}
130 AliITSneuron*& Linked() {return fLinked;}
134 AliITSlink(const AliITSlink &t);
135 AliITSlink& operator=(const AliITSlink& t);
137 Double_t fWeight; // Weight value
138 AliITSneuron *fLinked; //! the connected neuron
140 // ******************************************************************************
143 // Cut related setters
145 void SetHelixMatchCuts(Double_t *min, Double_t *max);
146 void SetThetaCuts2D(Double_t *min, Double_t *max);
147 void SetThetaCuts3D(Double_t *min, Double_t *max);
148 void SetCurvatureCuts(Int_t n, Double_t *cuts);
149 void SetVertex(Double_t x, Double_t y, Double_t z) {fVX=x; fVY=y; fVZ=z;}
150 void SetPolarInterval(Double_t dtheta) {fPolarInterval=dtheta;}
152 // Neural work-flow related setters
154 void SetActThreshold(Double_t val) {fActMinimum = val;}
155 void SetWeightExponent(Double_t a) {fAlignExponent = a;}
156 void SetGainToCostRatio(Double_t a) {fGain2CostRatio = a;}
157 void SetInitInterval(Double_t a, Double_t b) {fEdge1 = a; fEdge2 = b;}
158 void SetTemperature(Double_t a) {fTemperature = a;}
159 void SetVariationLimit(Double_t a) {fStabThreshold = a;}
161 // Points array arrangement & control
163 void CreateArrayStructure(Int_t nsecs);
164 Int_t ArrangePoints(TTree *ptstree);
165 void StoreAbsoluteMatches();
166 Bool_t PassCurvCut(AliITSNode *p1, AliITSNode *p2, Int_t curvidx, Double_t vx, Double_t vy, Double_t vz);
167 Int_t PassAllCuts(AliITSNode *p1, AliITSNode *p2, Int_t curvidx, Double_t vx, Double_t vy, Double_t vz);
169 void PrintMatches(Bool_t stop = kTRUE);
171 // Neural tracker work-flow
173 void NeuralTracking(const char* filesave, TCanvas*& display);
174 void Display(TCanvas*& canvas) const;
175 void ResetNodes(Int_t isector);
176 Int_t CreateNeurons(Int_t sector, Int_t curv); // create neurons
177 Int_t LinkNeurons() const; // create neural connections
178 Double_t Activate(AliITSneuron* &n); // calculates the new neural activation
179 Bool_t Update(); // an updating cycle
180 void CleanNetwork(); // removes deactivated units and resolves competitions
181 Int_t Save(Int_t sectoridx); // save found tracks for # sector
182 TTree* GetChains() {return fChains;}
183 void WriteChains() {fChains->Write();}
187 AliITSNeuralTracker(const AliITSNeuralTracker &n);
188 AliITSNeuralTracker& operator=(const AliITSNeuralTracker& t);
190 Bool_t CheckOccupation() const;
192 Int_t fSectorNum; // number of azymuthal sectors
193 Double_t fSectorWidth; // width of an azymuthal sector (in RADIANS) [used internally]
194 Double_t fPolarInterval; // width of a polar sector (in DEGREES)
196 Double_t fThetaCut2DMin[5]; // lower edge of theta cut range (in DEGREES)
197 Double_t fThetaCut2DMax[5]; // upper edge of theta cut range (in DEGREES)
198 Double_t fThetaCut3DMin[5]; // lower edge of theta cut range (in DEGREES)
199 Double_t fThetaCut3DMax[5]; // upper edge of theta cut range (in DEGREES)
200 Double_t fHelixMatchCutMin[5]; // lower edge of helix matching cut range
201 Double_t fHelixMatchCutMax[5]; // lower edge of helix matching cut range
202 Int_t fCurvNum; // # of curvature cut steps
203 Double_t *fCurvCut; //! value of all curvature cuts
205 Bool_t fStructureOK; // flag to avoid MANY segfault errors
207 Double_t fVX, fVY, fVZ; // estimated vertex coords (for helix matching cut)
209 Double_t fActMinimum; // minimum activation to turn 'on' the unit at the end
210 Double_t fEdge1, fEdge2; // initialization interval for activations
212 Double_t fTemperature; // logistic function temperature parameter
213 Double_t fStabThreshold; // stability threshold
214 Double_t fGain2CostRatio; // ratio between inhibitory and excitory contributions
215 Double_t fAlignExponent; // alignment-dependent weight term
217 Int_t fPoint[6]; // Track point in layers
218 TTree *fChains; //! Output tree
220 TObjArray *fPoints[6][180]; //! recpoints arranged into sectors for processing
221 TObjArray *fNeurons; //! neurons
223 ClassDef(AliITSNeuralTracker, 1)
227 ////////////////////////////////////////////////////////////////////////////////