// @(#)root/eve:$Id$
// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TEveVSDStructs
#define ROOT_TEveVSDStructs

#include "TObject.h"
#include "TParticle.h"
#include "TEveVector.h"

/******************************************************************************/
// VSD Structures
/******************************************************************************/

// Basic structures for Reve VSD concept. Design criteria:
//
//  * provide basic cross-referencing functionality;
//
//  * small memory/disk footprint (floats / count on compression in
//    split mode);
//
//  * simple usage from tree selections;
//
//  * placement in TClonesArray (composites are TObject derived);
//
//  * minimal member-naming (impossible to make everybody happy).
//


/******************************************************************************/
// TEveMCTrack
/******************************************************************************/

class TEveMCTrack : public TParticle // ?? Copy stuff over ??
{
public:
   Int_t       fLabel;      // Label of the track
   Int_t       fIndex;      // Index of the track (in some source array)
   Int_t       fEvaLabel;   // Label of primary particle

   Bool_t      fDecayed;    // True if decayed during tracking.
   // ?? Perhaps end-of-tracking point/momentum would be better.
   Float_t     fTDecay;     // Decay time
   TEveVector  fVDecay;     // Decay vertex
   TEveVector  fPDecay;     // Decay momentum

   TEveMCTrack() : fLabel(-1), fIndex(-1), fEvaLabel(-1),
                   fDecayed(kFALSE), fTDecay(0), fVDecay(), fPDecay() {}
   virtual ~TEveMCTrack() {}

   TEveMCTrack& operator=(const TParticle& p)
   { *((TParticle*)this) = p; return *this; }

   void ResetPdgCode() { fPdgCode = 0; }

   ClassDef(TEveMCTrack, 1); // Monte Carlo track (also used in VSD).
};


/******************************************************************************/
// TEveHit
/******************************************************************************/

// Representation of a hit.

// Members det_id (and fSubdetId) serve for cross-referencing into
// geometry. Hits should be stored in fDetId (+some label ordering) in
// order to maximize branch compression.


class TEveHit : public TObject
{
public:
   UShort_t     fDetId;    // Custom detector id.
   UShort_t     fSubdetId; // Custom sub-detector id.
   Int_t        fLabel;    // Label of particle that produced the hit.
   Int_t        fEvaLabel; // Label of primary particle, ancestor of label.
   TEveVector   fV;        // Hit position.

   // Float_t charge; probably specific.

   TEveHit() : fDetId(0), fSubdetId(0), fLabel(0), fEvaLabel(0), fV() {}
   virtual ~TEveHit() {}

   ClassDef(TEveHit, 1); // Monte Carlo hit (also used in VSD).
};


/******************************************************************************/
// TEveCluster
/******************************************************************************/

// Base class for reconstructed clusters

// ?? Should TEveHit and cluster have common base? No.

class TEveCluster : public TObject
{
public:
   UShort_t     fDetId;     // Custom detector id.
   UShort_t     fSubdetId;  // Custom sub-detector id.
   Int_t        fLabel[3];  // Labels of particles that contributed hits.

   // ?? Should include reconstructed track(s) using it? Rather not, separate.

   TEveVector      fV;      // Vertex.
   // TEveVector   fW;      // Cluster widths.
   // Coord system? Errors and/or widths Wz, Wy?

   TEveCluster() : fDetId(0), fSubdetId(0), fV() { fLabel[0] = fLabel[1] = fLabel[2] = 0; }
   virtual ~TEveCluster() {}

   ClassDef(TEveCluster, 1); // Reconstructed cluster (also used in VSD).
};


/******************************************************************************/
// TEveRecTrack
/******************************************************************************/
template <typename TT>
class TEveRecTrackT : public TObject
{
public:
   Int_t           fLabel;       // Label of the track.
   Int_t           fIndex;       // Index of the track (in some source array).
   Int_t           fStatus;      // Status as exported from reconstruction.
   Int_t           fSign;        // Charge of the track.
   TEveVectorT<TT> fV;           // Start vertex from reconstruction.
   TEveVectorT<TT> fP;           // Reconstructed momentum at start vertex.
   TT              fBeta;        // Relativistic beta factor.
   Double32_t      fDcaXY;       // dca xy to the primary vertex
   Double32_t      fDcaZ;        // dca z to the primary vertex
   Double32_t      fPVX;         //
   Double32_t      fPVY;         //
   Double32_t      fPVZ;         //
   // PID data missing

   TEveRecTrackT() : fLabel(-1), fIndex(-1), fStatus(0), fSign(0), fV(), fP(), fBeta(0), fDcaXY(0), fDcaZ(0), fPVX(0), fPVY(0), fPVZ(0) {}
   virtual ~TEveRecTrackT() {}

   Float_t Pt() { return fP.Perp(); }

   ClassDef(TEveRecTrackT, 2); // Template for reconstructed track (also used in VSD).
};

typedef TEveRecTrackT<Float_t>  TEveRecTrack;
typedef TEveRecTrackT<Float_t>  TEveRecTrackF;
typedef TEveRecTrackT<Double_t> TEveRecTrackD;

/******************************************************************************/
// TEveRecKink
/******************************************************************************/

class TEveRecKink : public TObject
{
public:

   TEveVector  fVKink;          // Kink vertex: reconstructed position of the kink
   TEveVector  fPMother;        // Momentum of the mother track
   TEveVector  fVMother;        // Vertex of the mother track
   TEveVector  fPDaughter;      // Momentum of the daughter track
   TEveVector  fVDaughter;      // Vertex of the daughter track
   Double32_t  fKinkAngle[3];   // three angles
   Int_t       fSign;           // sign of the track
   Int_t       fStatus;         // Status as exported from reconstruction

   // Data from simulation
   Int_t       fKinkLabel[2];   // Labels of the mother and daughter tracks
   Int_t       fKinkIndex[2];   // Indices of the mother and daughter tracks
   Int_t       fKinkPdg[2];     // PDG code of mother and daughter.

   TEveRecKink() : fVKink(), fPMother(), fVMother(), fPDaughter(), fVDaughter(), fSign(0), fStatus(0)
   {
     fKinkAngle[0] = fKinkAngle[1] = fKinkAngle[2] = 0;
     fKinkLabel[0] = fKinkLabel[1] = 0;
     fKinkIndex[0] = fKinkIndex[1] = 0;
     fKinkPdg[0]   = fKinkPdg[1]   = 0;
   }
   virtual ~TEveRecKink() {}

   ClassDef(TEveRecKink, 1); // Reconstructed kink (also used in VSD).
};


/******************************************************************************/
// TEveRecV0
/******************************************************************************/

class TEveRecV0 : public TObject
{
public:
   Int_t      fStatus;

   TEveVector fVNeg;       // Vertex of negative track.
   TEveVector fPNeg;       // Momentum of negative track.
   TEveVector fVPos;       // Vertex of positive track.
   TEveVector fPPos;       // Momentum of positive track.

   TEveVector fVCa;        // Point of closest approach.
   TEveVector fV0Birth;    // Reconstucted birth point of neutral particle.

   // ? Data from simulation.
   Int_t      fLabel;      // Neutral mother label read from kinematics.
   Int_t      fPdg;        // PDG code of mother.
   Int_t      fDLabel[2];  // Daughter labels.

   TEveRecV0() : fStatus(), fVNeg(), fPNeg(), fVPos(), fPPos(),
                 fVCa(), fV0Birth(), fLabel(0), fPdg(0)
   { fDLabel[0] = fDLabel[1] = 0; }
   virtual ~TEveRecV0() {}

   ClassDef(TEveRecV0, 1); // Reconstructed V0 (also used in VSD).
};


/******************************************************************************/
// TEveRecCascade
/******************************************************************************/

class TEveRecCascade : public TObject
{
public:
   Int_t      fStatus;

   TEveVector fVBac;         // Vertex of bachelor track.
   TEveVector fPBac;         // Momentum of bachelor track.

   TEveVector fCascadeVCa;   // Point of closest approach for Cascade.
   TEveVector fCascadeBirth; // Reconstucted birth point of cascade particle.

   // ? Data from simulation.
   Int_t      fLabel;        // Cascade mother label read from kinematics.
   Int_t      fPdg;          // PDG code of mother.
   Int_t      fDLabel;       // Daughter label.

   TEveRecCascade() : fStatus(),  fVBac(), fPBac(),
                      fCascadeVCa(), fCascadeBirth(),
                      fLabel(0), fPdg(0), fDLabel(0) {}
   virtual ~TEveRecCascade() {}

   ClassDef(TEveRecCascade, 1); // Reconstructed Cascade (also used in VSD).
};


/******************************************************************************/
// TEveMCRecCrossRef
/******************************************************************************/

class TEveMCRecCrossRef : public TObject
{
public:
   Bool_t       fIsRec;   // Is reconstructed.
   Bool_t       fHasV0;
   Bool_t       fHasKink;
   Int_t        fLabel;
   Int_t        fNHits;
   Int_t        fNClus;

   TEveMCRecCrossRef() : fIsRec(false), fHasV0(false), fHasKink(false),
                         fLabel(0), fNHits(0), fNClus(0) {}
   virtual ~TEveMCRecCrossRef() {}

   ClassDef(TEveMCRecCrossRef, 1); // Cross-reference of sim/rec data per particle (also used in VSD).
};


/******************************************************************************/
// Missing primary vertex class.
/******************************************************************************/


/******************************************************************************/
/******************************************************************************/

// This whole construction is somewhat doubtable. It requires
// shameless copying of experiment data. What is good about this
// scheme:
//
// 1) Filters can be applied at copy time so that only part of the
// data is copied over.
//
// 2) Once the data is extracted it can be used without experiment
// software. Thus, external service can provide this data and local
// client can be really thin.
//
// 3) Some pretty advanced visualization schemes/selections can be
// implemented in a general framework by providing data extractors
// only. This is also good for PR or VIP displays.
//
// 4) These classes can be extended by particular implementations. The
// container classes will use TClonesArray with user-specified element
// class.

// The common behaviour could be implemented entirely without usage of
// a common base classes, by just specifying names of members that
// retrieve specific data. This is fine as long as one only uses tree
// selections but becomes painful for extraction of data into local
// structures (could a) use interpreter but this is an overkill and
// would cause serious trouble for multi-threaded environment; b) use
// member offsets and data-types from the dictionary).

#endif
 TEveVSDStructs.h:1
 TEveVSDStructs.h:2
 TEveVSDStructs.h:3
 TEveVSDStructs.h:4
 TEveVSDStructs.h:5
 TEveVSDStructs.h:6
 TEveVSDStructs.h:7
 TEveVSDStructs.h:8
 TEveVSDStructs.h:9
 TEveVSDStructs.h:10
 TEveVSDStructs.h:11
 TEveVSDStructs.h:12
 TEveVSDStructs.h:13
 TEveVSDStructs.h:14
 TEveVSDStructs.h:15
 TEveVSDStructs.h:16
 TEveVSDStructs.h:17
 TEveVSDStructs.h:18
 TEveVSDStructs.h:19
 TEveVSDStructs.h:20
 TEveVSDStructs.h:21
 TEveVSDStructs.h:22
 TEveVSDStructs.h:23
 TEveVSDStructs.h:24
 TEveVSDStructs.h:25
 TEveVSDStructs.h:26
 TEveVSDStructs.h:27
 TEveVSDStructs.h:28
 TEveVSDStructs.h:29
 TEveVSDStructs.h:30
 TEveVSDStructs.h:31
 TEveVSDStructs.h:32
 TEveVSDStructs.h:33
 TEveVSDStructs.h:34
 TEveVSDStructs.h:35
 TEveVSDStructs.h:36
 TEveVSDStructs.h:37
 TEveVSDStructs.h:38
 TEveVSDStructs.h:39
 TEveVSDStructs.h:40
 TEveVSDStructs.h:41
 TEveVSDStructs.h:42
 TEveVSDStructs.h:43
 TEveVSDStructs.h:44
 TEveVSDStructs.h:45
 TEveVSDStructs.h:46
 TEveVSDStructs.h:47
 TEveVSDStructs.h:48
 TEveVSDStructs.h:49
 TEveVSDStructs.h:50
 TEveVSDStructs.h:51
 TEveVSDStructs.h:52
 TEveVSDStructs.h:53
 TEveVSDStructs.h:54
 TEveVSDStructs.h:55
 TEveVSDStructs.h:56
 TEveVSDStructs.h:57
 TEveVSDStructs.h:58
 TEveVSDStructs.h:59
 TEveVSDStructs.h:60
 TEveVSDStructs.h:61
 TEveVSDStructs.h:62
 TEveVSDStructs.h:63
 TEveVSDStructs.h:64
 TEveVSDStructs.h:65
 TEveVSDStructs.h:66
 TEveVSDStructs.h:67
 TEveVSDStructs.h:68
 TEveVSDStructs.h:69
 TEveVSDStructs.h:70
 TEveVSDStructs.h:71
 TEveVSDStructs.h:72
 TEveVSDStructs.h:73
 TEveVSDStructs.h:74
 TEveVSDStructs.h:75
 TEveVSDStructs.h:76
 TEveVSDStructs.h:77
 TEveVSDStructs.h:78
 TEveVSDStructs.h:79
 TEveVSDStructs.h:80
 TEveVSDStructs.h:81
 TEveVSDStructs.h:82
 TEveVSDStructs.h:83
 TEveVSDStructs.h:84
 TEveVSDStructs.h:85
 TEveVSDStructs.h:86
 TEveVSDStructs.h:87
 TEveVSDStructs.h:88
 TEveVSDStructs.h:89
 TEveVSDStructs.h:90
 TEveVSDStructs.h:91
 TEveVSDStructs.h:92
 TEveVSDStructs.h:93
 TEveVSDStructs.h:94
 TEveVSDStructs.h:95
 TEveVSDStructs.h:96
 TEveVSDStructs.h:97
 TEveVSDStructs.h:98
 TEveVSDStructs.h:99
 TEveVSDStructs.h:100
 TEveVSDStructs.h:101
 TEveVSDStructs.h:102
 TEveVSDStructs.h:103
 TEveVSDStructs.h:104
 TEveVSDStructs.h:105
 TEveVSDStructs.h:106
 TEveVSDStructs.h:107
 TEveVSDStructs.h:108
 TEveVSDStructs.h:109
 TEveVSDStructs.h:110
 TEveVSDStructs.h:111
 TEveVSDStructs.h:112
 TEveVSDStructs.h:113
 TEveVSDStructs.h:114
 TEveVSDStructs.h:115
 TEveVSDStructs.h:116
 TEveVSDStructs.h:117
 TEveVSDStructs.h:118
 TEveVSDStructs.h:119
 TEveVSDStructs.h:120
 TEveVSDStructs.h:121
 TEveVSDStructs.h:122
 TEveVSDStructs.h:123
 TEveVSDStructs.h:124
 TEveVSDStructs.h:125
 TEveVSDStructs.h:126
 TEveVSDStructs.h:127
 TEveVSDStructs.h:128
 TEveVSDStructs.h:129
 TEveVSDStructs.h:130
 TEveVSDStructs.h:131
 TEveVSDStructs.h:132
 TEveVSDStructs.h:133
 TEveVSDStructs.h:134
 TEveVSDStructs.h:135
 TEveVSDStructs.h:136
 TEveVSDStructs.h:137
 TEveVSDStructs.h:138
 TEveVSDStructs.h:139
 TEveVSDStructs.h:140
 TEveVSDStructs.h:141
 TEveVSDStructs.h:142
 TEveVSDStructs.h:143
 TEveVSDStructs.h:144
 TEveVSDStructs.h:145
 TEveVSDStructs.h:146
 TEveVSDStructs.h:147
 TEveVSDStructs.h:148
 TEveVSDStructs.h:149
 TEveVSDStructs.h:150
 TEveVSDStructs.h:151
 TEveVSDStructs.h:152
 TEveVSDStructs.h:153
 TEveVSDStructs.h:154
 TEveVSDStructs.h:155
 TEveVSDStructs.h:156
 TEveVSDStructs.h:157
 TEveVSDStructs.h:158
 TEveVSDStructs.h:159
 TEveVSDStructs.h:160
 TEveVSDStructs.h:161
 TEveVSDStructs.h:162
 TEveVSDStructs.h:163
 TEveVSDStructs.h:164
 TEveVSDStructs.h:165
 TEveVSDStructs.h:166
 TEveVSDStructs.h:167
 TEveVSDStructs.h:168
 TEveVSDStructs.h:169
 TEveVSDStructs.h:170
 TEveVSDStructs.h:171
 TEveVSDStructs.h:172
 TEveVSDStructs.h:173
 TEveVSDStructs.h:174
 TEveVSDStructs.h:175
 TEveVSDStructs.h:176
 TEveVSDStructs.h:177
 TEveVSDStructs.h:178
 TEveVSDStructs.h:179
 TEveVSDStructs.h:180
 TEveVSDStructs.h:181
 TEveVSDStructs.h:182
 TEveVSDStructs.h:183
 TEveVSDStructs.h:184
 TEveVSDStructs.h:185
 TEveVSDStructs.h:186
 TEveVSDStructs.h:187
 TEveVSDStructs.h:188
 TEveVSDStructs.h:189
 TEveVSDStructs.h:190
 TEveVSDStructs.h:191
 TEveVSDStructs.h:192
 TEveVSDStructs.h:193
 TEveVSDStructs.h:194
 TEveVSDStructs.h:195
 TEveVSDStructs.h:196
 TEveVSDStructs.h:197
 TEveVSDStructs.h:198
 TEveVSDStructs.h:199
 TEveVSDStructs.h:200
 TEveVSDStructs.h:201
 TEveVSDStructs.h:202
 TEveVSDStructs.h:203
 TEveVSDStructs.h:204
 TEveVSDStructs.h:205
 TEveVSDStructs.h:206
 TEveVSDStructs.h:207
 TEveVSDStructs.h:208
 TEveVSDStructs.h:209
 TEveVSDStructs.h:210
 TEveVSDStructs.h:211
 TEveVSDStructs.h:212
 TEveVSDStructs.h:213
 TEveVSDStructs.h:214
 TEveVSDStructs.h:215
 TEveVSDStructs.h:216
 TEveVSDStructs.h:217
 TEveVSDStructs.h:218
 TEveVSDStructs.h:219
 TEveVSDStructs.h:220
 TEveVSDStructs.h:221
 TEveVSDStructs.h:222
 TEveVSDStructs.h:223
 TEveVSDStructs.h:224
 TEveVSDStructs.h:225
 TEveVSDStructs.h:226
 TEveVSDStructs.h:227
 TEveVSDStructs.h:228
 TEveVSDStructs.h:229
 TEveVSDStructs.h:230
 TEveVSDStructs.h:231
 TEveVSDStructs.h:232
 TEveVSDStructs.h:233
 TEveVSDStructs.h:234
 TEveVSDStructs.h:235
 TEveVSDStructs.h:236
 TEveVSDStructs.h:237
 TEveVSDStructs.h:238
 TEveVSDStructs.h:239
 TEveVSDStructs.h:240
 TEveVSDStructs.h:241
 TEveVSDStructs.h:242
 TEveVSDStructs.h:243
 TEveVSDStructs.h:244
 TEveVSDStructs.h:245
 TEveVSDStructs.h:246
 TEveVSDStructs.h:247
 TEveVSDStructs.h:248
 TEveVSDStructs.h:249
 TEveVSDStructs.h:250
 TEveVSDStructs.h:251
 TEveVSDStructs.h:252
 TEveVSDStructs.h:253
 TEveVSDStructs.h:254
 TEveVSDStructs.h:255
 TEveVSDStructs.h:256
 TEveVSDStructs.h:257
 TEveVSDStructs.h:258
 TEveVSDStructs.h:259
 TEveVSDStructs.h:260
 TEveVSDStructs.h:261
 TEveVSDStructs.h:262
 TEveVSDStructs.h:263
 TEveVSDStructs.h:264
 TEveVSDStructs.h:265
 TEveVSDStructs.h:266
 TEveVSDStructs.h:267
 TEveVSDStructs.h:268
 TEveVSDStructs.h:269
 TEveVSDStructs.h:270
 TEveVSDStructs.h:271
 TEveVSDStructs.h:272
 TEveVSDStructs.h:273
 TEveVSDStructs.h:274
 TEveVSDStructs.h:275
 TEveVSDStructs.h:276
 TEveVSDStructs.h:277
 TEveVSDStructs.h:278
 TEveVSDStructs.h:279
 TEveVSDStructs.h:280
 TEveVSDStructs.h:281
 TEveVSDStructs.h:282
 TEveVSDStructs.h:283
 TEveVSDStructs.h:284
 TEveVSDStructs.h:285
 TEveVSDStructs.h:286
 TEveVSDStructs.h:287
 TEveVSDStructs.h:288
 TEveVSDStructs.h:289
 TEveVSDStructs.h:290
 TEveVSDStructs.h:291
 TEveVSDStructs.h:292
 TEveVSDStructs.h:293
 TEveVSDStructs.h:294
 TEveVSDStructs.h:295
 TEveVSDStructs.h:296
 TEveVSDStructs.h:297
 TEveVSDStructs.h:298
 TEveVSDStructs.h:299
 TEveVSDStructs.h:300
 TEveVSDStructs.h:301
 TEveVSDStructs.h:302
 TEveVSDStructs.h:303
 TEveVSDStructs.h:304
 TEveVSDStructs.h:305
 TEveVSDStructs.h:306
 TEveVSDStructs.h:307
 TEveVSDStructs.h:308
 TEveVSDStructs.h:309
 TEveVSDStructs.h:310