]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/PODs.h
Refix triangle/vertex accessors.
[u/mrichter/AliRoot.git] / EVE / Reve / PODs.h
1 // $Header$
2
3 #ifndef REVE_PODs_H
4 #define REVE_PODs_H
5
6 #include <TObject.h>
7 #include <TMath.h>
8
9 #include <TParticle.h>
10
11 namespace Reve {
12
13 /**************************************************************************/
14 // PODs.h
15 /**************************************************************************/
16
17 // Basic structures for Reve. Design criteria:
18 //
19 //  * provide basic cross-referencing functionality;
20 //
21 //  * small memory/disk footprint (floats / count on compression in
22 //  split mode);
23 //
24 //  * simple usage from tree selections;
25 //
26 //  * placement in TClonesArray (composites are TObject derived);
27 //
28 //  * minimal member-naming (impossible to make everybody happy).
29
30 void DisablePODTObjectStreamers();
31
32 /**************************************************************************/
33 // Vector
34 /**************************************************************************/
35
36 // Minimal Float_t copy of TVector3.
37 // Used to represent points and momenta.
38
39 class Vector
40 {
41 public:
42   Float_t x, y, z;
43
44   Vector() : x(0), y(0), z(0) {}
45   Vector(Float_t _x, Float_t _y, Float_t _z) : x(_x), y(_y), z(_z) {}
46   virtual ~Vector() {}
47
48   Float_t* c_vec() { return &x; }
49   void Set(Float_t*  v) { x=v[0]; y=v[1]; z=v[2]; }
50   void Set(Double_t* v) { x=v[0]; y=v[1]; z=v[2]; }
51   void Set(Float_t  _x, Float_t  _y, Float_t  _z) { x=_x; y=_y; z=_z; }
52   void Set(Double_t _x, Double_t _y, Double_t _z) { x=_x; y=_y; z=_z; }
53   void Set(const TVector3& v) { x=v.x(); y=v.y(); z=v.z(); }
54
55   Float_t Phi()      const;
56   Float_t Theta()    const;
57   Float_t CosTheta() const;
58   Float_t Eta()      const;
59
60   Float_t Mag()  const { return TMath::Sqrt(x*x+y*y+z*z);}
61   Float_t Mag2() const { return x*x+y*y+z*z;}
62
63   Float_t Perp()  const { return TMath::Sqrt(x*x+y*y);}
64   Float_t Perp2() const { return x*x+y*y;}
65   Float_t R()     const { return Perp(); }
66
67   Float_t Distance(const Vector& v) const;
68   Float_t SquareDistance(const Vector& v) const;
69
70   ClassDef(Vector, 1);
71 };
72
73 inline Float_t Vector::Phi() const
74 { return x == 0.0 && y == 0.0 ? 0.0 : TMath::ATan2(y,x); }
75
76 inline Float_t Vector::Theta() const
77 { return x == 0.0 && y == 0.0 && z == 0.0 ? 0.0 : TMath::ATan2(Perp(),z); }
78
79 inline Float_t Vector::CosTheta() const
80 { Float_t ptot = Mag(); return ptot == 0.0 ? 1.0 : z/ptot; }
81
82 inline Float_t Vector::Distance( const Vector& b) const
83 {
84   return TMath::Sqrt((x - b.x)*(x - b.x) + (y - b.y)*(y - b.y) + (z - b.z)*(z - b.z));
85 }
86 inline Float_t Vector::SquareDistance(const Vector& b) const
87 {
88   return ((x - b.x)*(x - b.x) + (y - b.y)*(y - b.y) + (z - b.z)*(z - b.z));
89 }
90
91 /**************************************************************************/
92 // PathMark
93 /**************************************************************************/
94
95 class PathMark
96 {
97  public:
98   enum Type_e       { Reference, Daughter, Decay }; 
99
100   Vector V, P;
101   Float_t time;
102   Type_e type;
103
104   PathMark(Type_e t=Reference) : V(), P(), time (0), type(t) {}
105   virtual ~PathMark() {}
106
107   const char* type_name();
108
109   ClassDef(PathMark, 1);
110 };
111
112 /**************************************************************************/
113 // MCTrack
114 /**************************************************************************/
115
116 class MCTrack : public TParticle // ?? Copy stuff over ??
117 {
118 public:
119   Int_t   label;       // Label of the track
120   Int_t   index;       // Index of the track (in some source array)
121   Int_t   eva_label;   // Label of primary particle
122
123   Bool_t  decayed;     // True if decayed during tracking.
124   // ?? Perhaps end-of-tracking point/momentum would be better.
125   Float_t t_decay;     // Decay time
126   Vector  V_decay;     // Decay vertex
127   Vector  P_decay;     // Decay momentum
128
129   MCTrack() : label(-1), index(-1), eva_label(-1),
130               decayed(false), t_decay(0), V_decay(), P_decay() {}
131   virtual ~MCTrack() {}
132
133   MCTrack& operator=(const TParticle& p)
134   { *((TParticle*)this) = p; return *this; }
135
136   void ResetPdgCode() { fPdgCode = 0; }
137
138   ClassDef(MCTrack, 1);
139 };
140
141
142 /**************************************************************************/
143 // MCTrackRef
144 /**************************************************************************/
145
146 // Not used.
147
148 class MCTrackRef : public TObject
149 {
150 public:
151   Int_t   label;
152   Int_t   status;
153   Vector  V;
154   Vector  P;
155   Float_t length;
156   Float_t time;
157
158   MCTrackRef() : label(-1), status(-1), V(), P(), length(0), time(0) {}
159   virtual ~MCTrackRef() {}
160
161   ClassDef(MCTrackRef, 1)
162 };
163
164
165 /**************************************************************************/
166 // Hit
167 /**************************************************************************/
168
169 // Representation of a hit.
170
171 // Members det_id (and subdet_id) serve for cross-referencing into
172 // geometry. Hits should be stored in det_id (+some label ordering) in
173 // order to maximize branch compression.
174
175
176 class Hit : public TObject
177 {
178 public:
179   UShort_t det_id;    // Custom detector id
180   UShort_t subdet_id; // Custom sub-detector id
181   Int_t    label;     // Label of particle that produced the hit
182   Int_t    eva_label;
183   Vector   V;         // Vertex
184
185   // ?? Float_t charge. Probably specific.
186
187   Hit() : det_id(0), subdet_id(0), label(0), eva_label(0), V() {}
188   virtual ~Hit() {}
189
190   ClassDef(Hit, 1);
191 };
192
193
194 /**************************************************************************/
195 // Cluster
196 /**************************************************************************/
197
198 // Base class for reconstructed clusters
199
200 // ?? Should Hit and cluster have common base? No.
201
202 class Cluster : public TObject
203 {
204 public:
205   UShort_t det_id;    // Custom detector id
206   UShort_t subdet_id; // Custom sub-detector id
207   Int_t    label[3];  // Labels of particles that contributed hits
208   // ?? Should include reconstructed track using it? Rather not, separate.
209
210   Vector   V;         // Vertex
211   // Vector   W;         // Cluster widths
212   // ?? Coord system? Special variables Wz, Wy?
213
214   Cluster() : det_id(0), subdet_id(0), V() { label[0] = label[1] = label [2] = 0; }
215   virtual ~Cluster() {}
216
217   ClassDef(Cluster, 1);
218 };
219
220
221 /**************************************************************************/
222 // RecTrack
223 /**************************************************************************/
224
225 class RecTrack : public TObject
226 {
227 public:
228   Int_t   label;       // Label of the track
229   Int_t   index;       // Index of the track (in some source array)
230   Int_t   status;      // Status as exported from reconstruction
231   Int_t   sign;
232   Vector  V;           // Start vertex from reconstruction
233   Vector  P;           // Reconstructed momentum at start vertex
234   Float_t beta;
235
236   // PID data missing
237
238   RecTrack() : label(-1), index(-1), status(0), sign(0), V(), P(), beta(0) {}
239   virtual ~RecTrack() {}
240
241   Float_t Pt() { return P.Perp(); }
242
243   ClassDef(RecTrack, 1);
244 };
245
246 // Another class with specified points/clusters
247
248
249 /**************************************************************************/
250 // RecKink
251 /**************************************************************************/
252
253 class RecKink : public RecTrack
254 {
255 public:
256   Int_t   label_sec;  // Label of the secondary track
257   Vector  V_end;      // End vertex: last point on the primary track
258   Vector  V_kink;     // Kink vertex: reconstructed position of the kink
259   Vector  P_sec;      // Momentum of secondary track
260
261   RecKink() : RecTrack(), label_sec(0), V_end(), V_kink(), P_sec() {}
262   virtual ~RecKink() {}
263
264   ClassDef(RecKink, 1);
265 };
266
267
268 /**************************************************************************/
269 // RecV0
270 /**************************************************************************/
271
272 class RecV0 : public TObject
273 {
274 public:
275   Int_t  status;
276
277   Vector V_neg;       // Vertex of negative track
278   Vector P_neg;       // Momentum of negative track
279   Vector V_pos;       // Vertex of positive track
280   Vector P_pos;       // Momentum of positive track
281
282   Vector V_ca;        // Point of closest approach
283   Vector V0_birth;    // Reconstucted birth point of neutral particle
284
285   // ? Data from simulation.
286   Int_t label;        // Neutral mother label read from kinematics
287   Int_t pdg;          // PDG code of mother
288   Int_t d_label[2];   // Daughter labels ?? Rec labels present anyway.
289
290   RecV0() : status(), V_neg(), P_neg(), V_pos(), P_pos(),
291             V_ca(), V0_birth(), label(0), pdg(0)
292   { d_label[0] = d_label[1] = 0; }
293   virtual ~RecV0() {}
294
295   ClassDef(RecV0, 1);
296 };
297
298 /**************************************************************************/
299 /**************************************************************************/
300
301 // Missing primary vertex.
302
303 // Missing GenInfo, RecInfo.
304
305 class GenInfo : public TObject
306 {
307 public:
308   Bool_t       is_rec;   // is reconstructed
309   Bool_t       has_V0;
310   Bool_t       has_kink;
311   Int_t        label;
312   Int_t        n_hits;
313   Int_t        n_clus;
314
315   GenInfo() : is_rec(false), has_V0(false), has_kink(false),
316               label(0), n_hits(0), n_clus(0) {}
317   virtual ~GenInfo() {}
318
319   ClassDef(GenInfo, 1);
320 };
321
322 /**************************************************************************/
323 /**************************************************************************/
324
325 // This whole construction is highly embarrassing. It requires
326 // shameless copying of experiment data. What is good about this
327 // scheme:
328 //
329 // 1) Filters can be applied at copy time so that only part of the
330 // data is copied over.
331 //
332 // 2) Once the data is extracted it can be used without experiment
333 // software. Thus, external service can provide this data and local
334 // client can be really thin.
335 //
336 // 3) Some pretty advanced visualization schemes/selections can be
337 // implemented in a general framework by providing data extractors
338 // only. This is also good for PR or VIP displays.
339 //
340 // 4) These classes can be extended by particular implementations. The
341 // container classes will use TClonesArray with user-specified element
342 // class.
343
344 // The common behaviour could be implemented entirely without usage of
345 // a common base classes, by just specifying names of members that
346 // retrieve specific data. This is fine as long as one only uses tree
347 // selections but becomes painful for extraction of data into local
348 // structures (could a) use interpreter but this is an overkill and
349 // would cause serious trouble for multi-threaded environment; b) use
350 // member offsets and data-types from the dictionary).
351
352 }
353
354 #endif