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