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