Coding rule violations corrected.
[u/mrichter/AliRoot.git] / ITS / AliITSNeuralTracker.h
CommitLineData
b9d722bc 1///////////////////////////////////////////////////////////////////////
2//
3// AliITSneuralTracker:
4//
5// neural network MFT algorithm
6// for track finding in ITS stand alone
7// according to the Denby-Peterson model with adaptments to the
8// ALICE multiplicity
9//
10///////////////////////////////////////////////////////////////////////
11
ddcce466 12#ifndef ALIITSNEURALTRACKER_H
13#define ALIITSNEURALTRACKER_H
14
15class TObjArray;
16class TCanvas;
17
18#include "AliITSNeuralPoint.h"
19
b9d722bc 20class AliITSNeuralTracker : public TObject {
21
22public:
23
ddcce466 24 AliITSNeuralTracker();
25 AliITSNeuralTracker(const AliITSNeuralTracker &t);
26 AliITSNeuralTracker& operator=(const AliITSNeuralTracker&);
27
b9d722bc 28 virtual ~AliITSNeuralTracker();
29
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 {
37 public:
ddcce466 38 AliITSNode() {fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;}
39 AliITSNode(const AliITSNode &t);
b9d722bc 40 AliITSNode(AliITSNeuralPoint *p, Bool_t init = kTRUE) // declared inline
ddcce466 41 : AliITSNeuralPoint(p) { fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;
42 if (init) { fInnerOf = new TObjArray; fOuterOf = new TObjArray; fMatches = new TObjArray;}}
b9d722bc 43 AliITSNode(AliITSRecPoint *p, AliITSgeomMatrix *gm)
ddcce466 44 : AliITSNeuralPoint(p,gm) {fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;}
b9d722bc 45
46 virtual ~AliITSNode()
47 {fInnerOf = fOuterOf = fMatches = 0; fNext = fPrev = 0;}
ddcce466 48
49 AliITSNode& operator=(const AliITSNode&);
50
b9d722bc 51 Double_t ThetaDeg() {return GetTheta()*180.0/TMath::Pi();}
52
ddcce466 53 Int_t GetSector(Double_t secwidth) const {return (Int_t)(GetPhi()/secwidth);}
b9d722bc 54 Int_t GetThetaCell() {return (Int_t)(ThetaDeg());}
55
ddcce466 56 Int_t& PosInTree() {return fPosInTree;}
57
58 TObjArray*& InnerOf() {return fInnerOf;}
59 TObjArray*& OuterOf() {return fOuterOf;}
60 TObjArray*& Matches() {return fMatches;}
61
62 AliITSNode*& Next() {return fNext;}
63 AliITSNode*& Prev() {return fPrev;}
64
65 private:
66
853a0f19 67 Int_t fPosInTree; // position in tree of converted points
b9d722bc 68
69 TObjArray *fInnerOf; //!
70 TObjArray *fOuterOf; //!
71 TObjArray *fMatches; //!
72
73 AliITSNode *fNext; //!
74 AliITSNode *fPrev; //!
75 };
76 // ******************************************************************************
77
78
79
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 {
88 public:
ddcce466 89 AliITSneuron():fUsed(0),fActivation(0.),fInner(0),fOuter(0),fGain(0) { }
90 AliITSneuron(const AliITSneuron &t);
b9d722bc 91 virtual ~AliITSneuron() {fInner=fOuter=0;fGain=0;}
ddcce466 92
93 AliITSneuron& operator=(const AliITSneuron&);
b9d722bc 94
95 Double_t Weight(AliITSneuron *n);
ddcce466 96 void Add2Gain(AliITSneuron *n, Double_t multconst, Double_t exponent);
97
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;}
103
104 private:
b9d722bc 105
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
111 };
112 // ******************************************************************************
113
114
115
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 {
124 public:
ddcce466 125 AliITSlink() : fWeight(0.), fLinked(0) { }
126 AliITSlink(const AliITSlink &t);
b9d722bc 127 virtual ~AliITSlink() {fLinked = 0;}
ddcce466 128
129 AliITSlink& operator=(const AliITSlink&);
130
131 Double_t& Weight() {return fWeight;}
132 AliITSneuron*& Linked() {return fLinked;}
133
134 private:
b9d722bc 135
136 Double_t fWeight; // Weight value
137 AliITSneuron *fLinked; //! the connected neuron
138 };
139 // ******************************************************************************
140
141
142 // Cut related setters
143
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;}
150
151 // Neural work-flow related setters
152
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;}
159
160 // Points array arrangement & control
161
162 void CreateArrayStructure(Int_t nsecs);
ddcce466 163 Int_t ArrangePoints(TTree *ptstree);
b9d722bc 164 void StoreAbsoluteMatches();
ddcce466 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);
b9d722bc 167 void PrintPoints();
168 void PrintMatches(Bool_t stop = kTRUE);
169
170 // Neural tracker work-flow
171
172 void NeuralTracking(const char* filesave, TCanvas*& display);
853a0f19 173 void Display(TCanvas*& canvas) const;
b9d722bc 174 void ResetNodes(Int_t isector);
175 Int_t CreateNeurons(Int_t sector, Int_t curv); // create neurons
853a0f19 176 Int_t LinkNeurons() const; // create neural connections
b9d722bc 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
ddcce466 180 Int_t Save(Int_t sectoridx); // save found tracks for # sector
b9d722bc 181 TTree* GetChains() {return fChains;}
182 void WriteChains() {fChains->Write();}
183
184private:
185
853a0f19 186 Bool_t CheckOccupation() const;
b9d722bc 187
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)
191
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
200
201 Bool_t fStructureOK; // flag to avoid MANY segfault errors
202
203 Double_t fVX, fVY, fVZ; // estimated vertex coords (for helix matching cut)
204
205 Double_t fActMinimum; // minimum activation to turn 'on' the unit at the end
206 Double_t fEdge1, fEdge2; // initialization interval for activations
207
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
212
213 Int_t fPoint[6]; // Track point in layers
214 TTree *fChains; //! Output tree
215
216 TObjArray *fPoints[6][180]; //! recpoints arranged into sectors for processing
217 TObjArray *fNeurons; //! neurons
218
219 ClassDef(AliITSNeuralTracker, 1)
220};
221
222
223////////////////////////////////////////////////////////////////////////////////
224
225#endif