]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITStrackerANN.h
New version of Neural Tracking which works with AliITSclusterV2 data and returns...
[u/mrichter/AliRoot.git] / ITS / AliITStrackerANN.h
CommitLineData
cec46807 1// AliITStrackerANN header file.
2// Class definition for the Neural Tracking implementation
3// for the ALICE ITS stand-alone.
4// Author: A. Pulvirenti
5// Email : alberto.pulvirenti@ct.infn.it
6
7#ifndef ALIITSTRACKERANN_H
8#define ALIITSTRACKERANN_H
9
10#include "AliITStrackerV2.h"
11
12class AliITSgeom;
13class TArrayI;
14
15class AliITStrackerANN : public AliITStrackerV2
16{
17public:
18
19 /* Constructors */
20 AliITStrackerANN() : AliITStrackerV2() { /* does nothing */ };
21 AliITStrackerANN(const AliITSgeom *geom, Int_t msglev = 0);
22 AliITStrackerANN(const AliITStrackerANN &n) : AliITStrackerV2((AliITStrackerV2&)n)
23 { /* nothing */ }
24 AliITStrackerANN& operator=(const AliITStrackerANN& /*arg*/)
25 { return *this; }
26
27 /* Destructor */
28 // virtual ~AliITStrackerANN();
29
30
31 /*********************************************
32 >> AliITSnode <<
33 ----------------
34 An ITS point in the global reference frame.
35 *********************************************/
36 class AliITSnode : public TObject {
37 public:
38
39 AliITSnode();
40 ~AliITSnode();
41 AliITSnode(const AliITSnode &n) : TObject((TObject&)n)
42 { /* nothing */ }
43 AliITSnode& operator=(const AliITSnode& /*arg*/)
44 { return *this; }
45
46 /* (NODE) Function to extract layer info from cluster index */
47 Int_t GetLayer() const {Int_t lay = (fClusterRef & 0xf0000000) >> 28; return lay;}
48
49 /* (NODE) Getter and Setter for the 'fUsed' flag */
50 Bool_t IsUsed() const {return fUsed;}
51 void Use() {fUsed = kTRUE;}
52
53 /* (NODE) Geometrical functions */
54 Double_t GetR2() const {return TMath::Sqrt(GetR2sq());} // xy radius
55 Double_t GetR3() const {return TMath::Sqrt(GetR3sq());} // xyz radius
56 Double_t GetR2sq() const {return fX*fX+fY*fY;} // xy radius^2
57 Double_t GetR3sq() const {return GetR2sq()+fZ*fZ;} // xyz radius^2
58 Double_t GetPhi() const;
59 Double_t GetTheta() const {return TMath::ATan2(GetR2(),fZ);} // polar angle
60 Double_t GetError(Option_t *opt); // errors on coords
61
62 /* Data members references */
63 Double_t& X() {return fX;}
64 Double_t& Y() {return fY;}
65 Double_t& Z() {return fZ;}
66 Double_t& ErrX2() {return fEX2;}
67 Double_t& ErrY2() {return fEY2;}
68 Double_t& ErrZ2() {return fEZ2;}
69 Int_t& ClusterRef() {return fClusterRef;}
70
71 TObjArray*& Matches() {return fMatches;}
72 TObjArray*& InnerOf() {return fInnerOf;}
73 TObjArray*& OuterOf() {return fOuterOf;}
74 AliITSnode*& Next() {return fNext;}
75 AliITSnode*& Prev() {return fPrev;}
76
77 private:
78
79 Double_t fX; // X in global reference system
80 Double_t fY; // Y in global reference system
81 Double_t fZ; // Z in global reference system
82 Double_t fEX2; // X error in global reference system
83 Double_t fEY2; // Y error in global reference system
84 Double_t fEZ2; // Z error in global reference system
85
86 Bool_t fUsed; // usage flag
87 Int_t fClusterRef; // reference index for related cluster
88 TObjArray *fMatches; //! array of well-matched cluster indexes
89 TObjArray *fInnerOf; //! array of neurons starting from *this
90 TObjArray *fOuterOf; //! array of neurons entering *this
91 AliITSnode *fNext; //! pointer to the next node in the found track
92 AliITSnode *fPrev; //! pointer to the previous node in the found track
93
94 };
95 /* End of AliITSnode class */
96
97
98 /***************************************
99 >> AliITSneuron <<
100 ------------------
101 A single unit in the neural network.
102 ***************************************/
103 class AliITSneuron : public TObject {
104 public:
105
106 /* (NEURON) Constructor: alocates the sequenced units array */
107 AliITSneuron() : fUsed(0), fActivation(0.), fInner(0), fOuter(0), fGain(0)
108 {fGain = new TObjArray;}
109 AliITSneuron(AliITSnode *inner, AliITSnode *outer, Double_t minAct, Double_t maxAct);
110 AliITSneuron(const AliITSneuron &n) : TObject((TObject&)n)
111 { /* nothing */ }
112 AliITSneuron& operator=(const AliITSneuron& /*arg*/)
113 { return *this; }
114
115
116 /* (NEURON) Destructor: frees memory from dynamic allocated objects */
117 virtual ~AliITSneuron()
118 { fInner = fOuter = 0; fGain->SetOwner(kFALSE); fGain->Clear(); delete fGain; }
119
120 /* Compute neural activation from the network */
121 Double_t Activate(Double_t temperature);
122
123 /* Data members references */
124 Int_t& Used() {return fUsed;}
125 Double_t& Activation() {return fActivation;}
126 AliITSnode*& Inner() {return fInner;}
127 AliITSnode*& Outer() {return fOuter;}
128 TObjArray*& Gain() {return fGain;}
129
130 private:
131
132 Int_t fUsed; // utility flag
133 Double_t fActivation; // Activation value
134 AliITSnode *fInner; //! inner point
135 AliITSnode *fOuter; //! outer point
136 TObjArray *fGain; //! list of sequenced units
137
138 };
139 /* End of NEURON class */
140
141
142 /**************************************************
143 >> AliITSlink <<
144 ----------------
145 A synaptic connected unit in the neural network.
146 **************************************************/
147 class AliITSlink : public TObject {
148 public:
149
150 AliITSlink() {fWeight = 0.0; fLinked = 0;}
151 AliITSlink(Double_t w, AliITSneuron *n) : fWeight(w), fLinked(n) { }
152 virtual ~AliITSlink() {fLinked = 0;}
153 AliITSlink(const AliITSlink &n) : TObject((TObject&)n)
154 { /* nothing */ }
155 AliITSlink& operator=(const AliITSlink& /*arg*/)
156 { return *this; }
157
158 /* contribution */
159 Double_t Contribution() {return fLinked->Activation() * fWeight;}
160
161 private:
162
163 Double_t fWeight; // Weight value
164 AliITSneuron *fLinked; //! Connected neuron
165
166 };
167 /* End of AliITSlink class */
168
169 /**************************************
170 >> AliITStrackANN <<
171 ----------------
172 A track found by the neural network.
173 **************************************/
174 class AliITStrackANN : public TObject {
175 public:
176
177 AliITStrackANN(Int_t dim = 0);
178 AliITStrackANN(const AliITStrackANN &n) : TObject((TObject&)n)
179 { /* nothing */ }
180 AliITStrackANN& operator=(const AliITStrackANN& /*arg*/)
181 { return *this; }
182
183 Double_t& XCenter() {return fXCenter;}
184 Double_t& YCenter() {return fYCenter;}
185 Double_t& Radius() {return fRadius;}
186 Double_t& Curv() {return fCurv;}
187 Double_t& ImpactParameterTrans() {return fDTrans;}
188 Double_t& ImpactParameterLong() {return fDLong;}
189 Double_t& TanLambda() {return fTanLambda;}
190 Double_t& Phi() {return fPhi;}
191
192 AliITSnode* operator[](Int_t i) const {return ((i>=0&&i<fNPoints)?fNode[i]:0);}
193 AliITSnode* GetNode(Int_t i) const {return ((i>=0&&i<fNPoints)?fNode[i]:0);}
194 void SetNode(Int_t i, AliITSnode*& ref) {if (i>=0&&i<fNPoints) fNode[i] = ref;}
195
196 Int_t CheckOccupation() const;
197 Bool_t RiemannFit();
198
199 private:
200
201 Int_t fNPoints; // nuber of track elements
202
203 Double_t fXCenter; // X of bending circle center
204 Double_t fYCenter; // Y of bending circle center
205 Double_t fRadius; // radius of bending circle
206 Double_t fCurv; // signed curvature of bending circle
207 Double_t fDTrans; // transverse impact parameter
208 Double_t fDLong; // longitudinal impact parameter
209 Double_t fTanLambda; // tangent of dip angle
210 Double_t fPhi; // initial direction of transverse momentum
211
212 AliITSnode **fNode; // pointers to track elements
213
214 };
215 /* End of AliITStrackANN class */
216
217 /* Geometry setter */
218 void SetITSgeom(AliITSgeom *geom) {fGeom = (AliITSgeom*)geom;}
219
220 /* Flag setter */
221 void SetMessageLevel(Int_t lev) {fMsgLevel = lev;}
222
223 /* Cut setters */
224 void SetCuts(Int_t ncurv = 0, Double_t *curv = 0, // curvature (number of cuts and array)
225 Double_t *theta2D = 0, // cut in theta 2D (rho-z)
226 Double_t *theta3D = 0, // cut in theta 3D (x-y-z)
227 Double_t *helix = 0); // cut for helix-matching
228
229 /* Setter for overall Theta cut */
230 void SetPolarInterval(Double_t dtheta) {fPolarInterval=dtheta;}
231
232 /* Neural work-flow setters */
233 void SetActThreshold(Double_t val) {fActMinimum = val;}
234 void SetWeightExponent(Double_t a) {fExponent = a;}
235 void SetGainToCostRatio(Double_t a) {fGain2CostRatio = a;}
236 void SetInitInterval(Double_t a, Double_t b) {fEdge1 = a; fEdge2 = b;}
237 void SetTemperature(Double_t a) {fTemperature = a;}
238 void SetVariationLimit(Double_t a) {fStabThreshold = a;}
239
240 /* Vertex setter */
241 void SetVertex(Double_t x, Double_t y, Double_t z) {fVertexX=x;fVertexY=y;fVertexZ=z;}
242
243 /* Node management for neural network creation */
244 Bool_t GetGlobalXYZ(Int_t refClust,
245 Double_t &x, Double_t &y, Double_t &z,
246 Double_t &ex2, Double_t &ey2, Double_t &ez2);
247 AliITSnode* AddNode(Int_t index);
248 void CreateArrayStructure(Int_t nsecs);
249 Int_t ArrangePoints(char *exportFile = 0);
250 void StoreOverallMatches();
251 Bool_t PassCurvCut(AliITSnode *p1, AliITSnode *p2, Int_t curvStep, Double_t vx, Double_t vy, Double_t vz);
252 Int_t PassAllCuts(AliITSnode *p1, AliITSnode *p2, Int_t curvStep, Double_t vx, Double_t vy, Double_t vz);
253 void PrintMatches(Bool_t stop = kTRUE);
254
255 /* Neural tracking operations */
256 // void NeuralTracking(const char* filesave, TCanvas*& display);
257 void ResetNodes(Int_t isector);
258 Int_t CreateNetwork(Int_t sector, Int_t curvStep); // create network
259 Int_t CreateNeurons(AliITSnode *node, Int_t curvStep, Double_t vx, Double_t vy, Double_t vz); // create neurons starting from given point
260 Int_t LinkNeurons(); // create neural connections
261 Bool_t Update(); // an updating cycle
262 void FollowChains(Int_t sector); // follows the chains of active neurons
263 Int_t SaveTracks(Int_t sector); // saves the found tracks
264 void CleanNetwork(); // removes deactivated units and resolve competitions
265 //Int_t Save(Int_t sector); // save found tracks for # sector
266 Int_t StoreTracks(); // save found tracks for # sector
267
268 /* Fit procedures */
269 void ExportTracks(const char *file) const;
270
271private:
272
273 /* Neural synaptic weight */
274 Double_t Weight(AliITSneuron *nAB, AliITSneuron *nBC);
275
276 /* Usefuls constant angle values */
277 static const Double_t fgkPi = 3.141592653; // pi
278 static const Double_t fgkHalfPi = 1.570796327; // pi / 2
279 static const Double_t fgkTwoPi = 6.283185307; // 2 * pi
280
281 /* Primary vertex position */
282 Double_t fVertexX; // X
283 Double_t fVertexY; // Y
284 Double_t fVertexZ; // Z
285
286 /* ITS barrel sectioning */
287 Int_t fSectorNum; // number of azimutal sectors
288 Double_t fSectorWidth; // width of barrel sector (in RAD) [used internally]
289 Double_t fPolarInterval; // width of a polar sector (in DEGREES)
290
291 /* Cuts */
292 Double_t fThetaCut2D[5]; // upper edge of theta cut range (in DEGREES)
293 Double_t fThetaCut3D[5]; // upper edge of theta cut range (in DEGREES)
294 Double_t fHelixMatchCut[5]; // lower edge of helix matching cut range
295 Int_t fCurvNum; // # of curvature cut steps
296 Double_t *fCurvCut; //! value of all curvature cuts
297
298 /* Neural network work-flow parameters */
299 Double_t fActMinimum; // minimum activation to turn 'on' the unit at the end
300 Double_t fEdge1, fEdge2; // initialization interval for activations
301 Double_t fStabThreshold; // stability threshold
302 Double_t fTemperature; // slope in logistic function
303 Double_t fGain2CostRatio; // ratio between inhibitory and excitory contributions
304 Double_t fExponent; // alignment-dependent weight term
305
306 /* Object arrays for data storing and related counters */
307 Int_t fNLayers; // Number of ITS layers
308 Int_t *fFirstModInLayer; //! Index of first module index for each layer
309 TArrayI **fIndexMap; //! Map of cluster indexes (in AliITSlayer) with reference to
310 // the location in the cluster Tree (module, pos in array)
311 Int_t fTrackClust[6]; // Track point in layers
312 TObjArray *fFoundTracks; //! Found tracks
313 TObjArray ***fNodes; //! recpoints arranged into sectors for processing
314 TObjArray *fNeurons; //! neurons
315
316 /* Flags */
317 Int_t fMsgLevel; // To allow the on-screen printing of messages
318 Bool_t fStructureOK; // Check if the nested TObjArray structure of nodes is created
319
320 /* ALICE related objects */
321 AliITSgeom *fGeom; //! ITS Geometry
322
323 /* ROOT class implementation routines */
324 ClassDef(AliITStrackerANN, 1)
325};
326
327#endif