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 AliITSNeuralTracker(const AliITSNeuralTracker &t);
26 AliITSNeuralTracker& operator=(const AliITSNeuralTracker&);
28 virtual ~AliITSNeuralTracker();
30 // ******************************************************************************
31 // * Embedded utility class --> >>> NODE <<<
32 // ******************************************************************************
33 // * This class inherits from AliITSNeuralPoint and adds some
34 // * utility pointers for quick path-finding among neurons.
35 // ******************************************************************************
36 class AliITSNode : public AliITSNeuralPoint {
38 AliITSNode() {fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;}
39 AliITSNode(const AliITSNode &t);
40 AliITSNode(AliITSNeuralPoint *p, Bool_t init = kTRUE) // declared inline
41 : AliITSNeuralPoint(p) { fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;
42 if (init) { fInnerOf = new TObjArray; fOuterOf = new TObjArray; fMatches = new TObjArray;}}
43 AliITSNode(AliITSRecPoint *p, AliITSgeomMatrix *gm)
44 : AliITSNeuralPoint(p,gm) {fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;}
47 {fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;}
49 AliITSNode& operator=(const AliITSNode&);
51 Double_t ThetaDeg() {return GetTheta()*180.0/TMath::Pi();}
53 Int_t GetSector(Double_t secwidth) const {return (Int_t)(GetPhi()/secwidth);}
54 Int_t GetThetaCell() {return (Int_t)(ThetaDeg());}
56 Int_t& PosInTree() {return fPosInTree;}
58 TObjArray*& InnerOf() {return fInnerOf;}
59 TObjArray*& OuterOf() {return fOuterOf;}
60 TObjArray*& Matches() {return fMatches;}
62 AliITSNode*& Next() {return fNext;}
63 AliITSNode*& Prev() {return fPrev;}
67 Int_t fPosInTree; // position in tree of converted points
69 TObjArray *fInnerOf; //!
70 TObjArray *fOuterOf; //!
71 TObjArray *fMatches; //!
73 AliITSNode *fNext; //!
74 AliITSNode *fPrev; //!
76 // ******************************************************************************
80 // ******************************************************************************
81 // * Embedded utility class --> >>> NEURON <<<
82 // ******************************************************************************
83 // * Simple class implementing the neural unit.
84 // * Contains the activation and some other pointers
85 // * for purposes similar to the ones in AliITSnode.
86 // ******************************************************************************
87 class AliITSneuron : public TObject {
89 AliITSneuron():fUsed(0),fActivation(0.),fInner(0),fOuter(0),fGain(0) { }
90 AliITSneuron(const AliITSneuron &t);
91 virtual ~AliITSneuron() {fInner=fOuter=0;fGain=0;}
93 AliITSneuron& operator=(const AliITSneuron&);
95 Double_t Weight(AliITSneuron *n);
96 void Add2Gain(AliITSneuron *n, Double_t multconst, Double_t exponent);
98 Int_t& Used() {return fUsed;}
99 Double_t& Activation() {return fActivation;}
100 AliITSNode*& Inner() {return fInner;}
101 AliITSNode*& Outer() {return fOuter;}
102 TObjArray*& Gain() {return fGain;}
106 Int_t fUsed; // utility flag
107 Double_t fActivation; // Activation value
108 AliITSNode *fInner; //! inner point
109 AliITSNode *fOuter; //! outer point
110 TObjArray *fGain; //! list of sequenced units
112 // ******************************************************************************
116 // ******************************************************************************
117 // * Embedded utility class --> >>> CONNECTION <<<
118 // ******************************************************************************
119 // * Used to implement the neural weighted connection
120 // * in such a way to speed up the retrieval of the
121 // * links among neuron, for a fast update procedure.
122 // ******************************************************************************
123 class AliITSlink : public TObject {
125 AliITSlink() : fWeight(0.), fLinked(0) { }
126 AliITSlink(const AliITSlink &t);
127 virtual ~AliITSlink() {fLinked = 0;}
129 AliITSlink& operator=(const AliITSlink&);
131 Double_t& Weight() {return fWeight;}
132 AliITSneuron*& Linked() {return fLinked;}
136 Double_t fWeight; // Weight value
137 AliITSneuron *fLinked; //! the connected neuron
139 // ******************************************************************************
142 // Cut related setters
144 void SetHelixMatchCuts(Double_t *min, Double_t *max);
145 void SetThetaCuts2D(Double_t *min, Double_t *max);
146 void SetThetaCuts3D(Double_t *min, Double_t *max);
147 void SetCurvatureCuts(Int_t n, Double_t *cuts);
148 void SetVertex(Double_t x, Double_t y, Double_t z) {fVX=x; fVY=y; fVZ=z;}
149 void SetPolarInterval(Double_t dtheta) {fPolarInterval=dtheta;}
151 // Neural work-flow related setters
153 void SetActThreshold(Double_t val) {fActMinimum = val;}
154 void SetWeightExponent(Double_t a) {fAlignExponent = a;}
155 void SetGainToCostRatio(Double_t a) {fGain2CostRatio = a;}
156 void SetInitInterval(Double_t a, Double_t b) {fEdge1 = a; fEdge2 = b;}
157 void SetTemperature(Double_t a) {fTemperature = a;}
158 void SetVariationLimit(Double_t a) {fStabThreshold = a;}
160 // Points array arrangement & control
162 void CreateArrayStructure(Int_t nsecs);
163 Int_t ArrangePoints(TTree *ptstree);
164 void StoreAbsoluteMatches();
165 Bool_t PassCurvCut(AliITSNode *p1, AliITSNode *p2, Int_t curvidx, Double_t vx, Double_t vy, Double_t vz);
166 Int_t PassAllCuts(AliITSNode *p1, AliITSNode *p2, Int_t curvidx, Double_t vx, Double_t vy, Double_t vz);
168 void PrintMatches(Bool_t stop = kTRUE);
170 // Neural tracker work-flow
172 void NeuralTracking(const char* filesave, TCanvas*& display);
173 void Display(TCanvas*& canvas) const;
174 void ResetNodes(Int_t isector);
175 Int_t CreateNeurons(Int_t sector, Int_t curv); // create neurons
176 Int_t LinkNeurons() const; // create neural connections
177 Double_t Activate(AliITSneuron* &n); // calculates the new neural activation
178 Bool_t Update(); // an updating cycle
179 void CleanNetwork(); // removes deactivated units and resolves competitions
180 Int_t Save(Int_t sectoridx); // save found tracks for # sector
181 TTree* GetChains() {return fChains;}
182 void WriteChains() {fChains->Write();}
186 Bool_t CheckOccupation() const;
188 Int_t fSectorNum; // number of azymuthal sectors
189 Double_t fSectorWidth; // width of an azymuthal sector (in RADIANS) [used internally]
190 Double_t fPolarInterval; // width of a polar sector (in DEGREES)
192 Double_t fThetaCut2DMin[5]; // lower edge of theta cut range (in DEGREES)
193 Double_t fThetaCut2DMax[5]; // upper edge of theta cut range (in DEGREES)
194 Double_t fThetaCut3DMin[5]; // lower edge of theta cut range (in DEGREES)
195 Double_t fThetaCut3DMax[5]; // upper edge of theta cut range (in DEGREES)
196 Double_t fHelixMatchCutMin[5]; // lower edge of helix matching cut range
197 Double_t fHelixMatchCutMax[5]; // lower edge of helix matching cut range
198 Int_t fCurvNum; // # of curvature cut steps
199 Double_t *fCurvCut; //! value of all curvature cuts
201 Bool_t fStructureOK; // flag to avoid MANY segfault errors
203 Double_t fVX, fVY, fVZ; // estimated vertex coords (for helix matching cut)
205 Double_t fActMinimum; // minimum activation to turn 'on' the unit at the end
206 Double_t fEdge1, fEdge2; // initialization interval for activations
208 Double_t fTemperature; // logistic function temperature parameter
209 Double_t fStabThreshold; // stability threshold
210 Double_t fGain2CostRatio; // ratio between inhibitory and excitory contributions
211 Double_t fAlignExponent; // alignment-dependent weight term
213 Int_t fPoint[6]; // Track point in layers
214 TTree *fChains; //! Output tree
216 TObjArray *fPoints[6][180]; //! recpoints arranged into sectors for processing
217 TObjArray *fNeurons; //! neurons
219 ClassDef(AliITSNeuralTracker, 1)
223 ////////////////////////////////////////////////////////////////////////////////