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