Logo ROOT   6.10/09
Reference Guide
TEveVSD.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TEveVSD.h"
13 #include "TFile.h"
14 
15 /** \class TEveVSD
16 \ingroup TEve
17 Visualization Summary Data - a collection of trees holding standard
18 event data in experiment independent format.
19 */
20 
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 /// Constructor.
25 
26 TEveVSD::TEveVSD(const char* , const char*) :
27  TObject(),
28 
29  fFile (0),
30  fDirectory (0),
31  fBuffSize (32000),
32  fVerbose (0),
33 
34  fTreeK (0),
35  fTreeH (0),
36  fTreeC (0),
37  fTreeR (0),
38  fTreeKK (0),
39  fTreeV0 (0),
40  fTreeCC (0),
41  fTreeGI (0),
42 
43  fK(), fpK (&fK),
44  fH(), fpH (&fH),
45  fC(), fpC (&fC),
46  fR(), fpR (&fR),
47  fKK(), fpKK(&fKK),
48  fV0(), fpV0(&fV0),
49  fCC(), fpCC(&fCC),
50  fGI(), fpGI(&fGI)
51 {
52 }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Destructor.
56 
58 {
59 }
60 
61 ////////////////////////////////////////////////////////////////////////////////
62 /// Set directory in which the trees are (or will be) created.
63 
65 {
66  fDirectory = dir;
67 }
68 
69 ////////////////////////////////////////////////////////////////////////////////
70 /// Create internal trees.
71 
73 {
74  fDirectory->cd();
75  fTreeK = new TTree("Kinematics", "Simulated tracks.");
76  fTreeH = new TTree("Hits", "Combined detector hits.");
77  fTreeC = new TTree("Clusters", "Reconstructed clusters.");
78  fTreeR = new TTree("RecTracks", "Reconstructed tracks.");
79  fTreeKK = new TTree("RecKinks", "Reconstructed kinks.");
80  fTreeV0 = new TTree("RecV0s", "Reconstructed V0s.");
81  fTreeCC = new TTree("RecCascades","Reconstructed cascades.");
82  fTreeGI = new TTree("TEveMCRecCrossRef", "Objects prepared for cross query.");
83 }
84 
85 ////////////////////////////////////////////////////////////////////////////////
86 /// Delete internal trees.
87 
89 {
90  delete fTreeK; fTreeK = 0;
91  delete fTreeH; fTreeH = 0;
92  delete fTreeC; fTreeC = 0;
93  delete fTreeR; fTreeR = 0;
94  delete fTreeV0; fTreeV0 = 0;
95  delete fTreeKK; fTreeKK = 0;
96  delete fTreeGI; fTreeGI = 0;
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Create internal VSD branches.
101 
103 {
104  if (fTreeK) fTreeK ->Branch("K", "TEveMCTrack", &fpK);
105  if (fTreeH) fTreeH ->Branch("H", "TEveHit", &fpH);
106  if (fTreeC) fTreeC ->Branch("C", "TEveCluster", &fpC);
107  if (fTreeR) fTreeR ->Branch("R", "TEveRecTrack", &fpR);
108  if (fTreeKK) fTreeKK->Branch("KK", "TEveRecKink", &fpKK);
109  if (fTreeV0) fTreeV0->Branch("V0", "TEveRecV0", &fpV0);
110 
111  if (fTreeGI)
112  {
113  fTreeGI->Branch("GI", "TEveMCRecCrossRef", &fpGI);
114  fTreeGI->Branch("K.", "TEveMCTrack", &fpK);
115  fTreeGI->Branch("R.", "TEveRecTrack", &fpR);
116  }
117 }
118 
119 ////////////////////////////////////////////////////////////////////////////////
120 /// Set branche addresses of internal trees.
121 
123 {
124  if (fTreeK) fTreeK ->SetBranchAddress("K", &fpK);
125  if (fTreeH) fTreeH ->SetBranchAddress("H", &fpH);
126  if (fTreeC) fTreeC ->SetBranchAddress("C", &fpC);
127  if (fTreeR) fTreeR ->SetBranchAddress("R", &fpR);
128  if (fTreeKK) fTreeKK->SetBranchAddress("KK", &fpKK);
129  if (fTreeV0) fTreeV0->SetBranchAddress("V0", &fpV0);
130 
131  if (fTreeGI)
132  {
133  fTreeGI->SetBranchAddress("GI", &fpGI);
134  fTreeGI->SetBranchAddress("K.", &fpK);
135  fTreeGI->SetBranchAddress("R.", &fpR);
136  }
137 }
138 
139 ////////////////////////////////////////////////////////////////////////////////
140 /// Does nothing here ... reimplemented in sub-classes.
141 
143 {
144 }
145 
146 ////////////////////////////////////////////////////////////////////////////////
147 /// Load internal trees from directory.
148 
150 {
151  static const TEveException eH("TEveVSD::LoadTrees ");
152 
153  if (fDirectory == 0)
154  throw eH + "directory not set.";
155 
156  fTreeK = (TTree*) fDirectory->Get("Kinematics");
157  if (fTreeK == 0 && fVerbose) {
158  printf("%s Kinematics not available in fDirectory %s.\n",
159  eH.Data(), fDirectory->GetName());
160  }
161 
162  fTreeH = (TTree*) fDirectory->Get("Hits");
163  if (fTreeH == 0 && fVerbose) {
164  printf("%s Hits not available in fDirectory %s.\n",
165  eH.Data(), fDirectory->GetName());
166  }
167 
168  fTreeC = (TTree*) fDirectory->Get("Clusters");
169  if (fTreeC == 0 && fVerbose) {
170  printf("%s Clusters not available in fDirectory %s.\n",
171  eH.Data(), fDirectory->GetName());
172  }
173 
174  fTreeR = (TTree*) fDirectory->Get("RecTracks");
175  if (fTreeR == 0 && fVerbose) {
176  printf("%s RecTracks not available in fDirectory %s.\n",
177  eH.Data(), fDirectory->GetName());
178  }
179 
180  fTreeKK = (TTree*) fDirectory->Get("RecKinks");
181  if (fTreeKK == 0 && fVerbose) {
182  printf("%s Kinks not available in fDirectory %s.\n",
183  eH.Data(), fDirectory->GetName());
184  }
185 
186  fTreeV0 = (TTree*) fDirectory->Get("RecV0s");
187  if (fTreeV0 == 0 && fVerbose) {
188  printf("%s V0 not available in fDirectory %s.\n",
189  eH.Data(), fDirectory->GetName());
190  }
191 
192  fTreeGI = (TTree*)fDirectory->Get("TEveMCRecCrossRef");
193  if(fTreeGI == 0 && fVerbose) {
194  printf("%s TEveMCRecCrossRef not available in fDirectory %s.\n",
195  eH.Data(), fDirectory->GetName());
196  }
197 
198 }
199 
200 ////////////////////////////////////////////////////////////////////////////////
201 /// Disable TObject streamers for those VSD structs that inherit from
202 /// TObject directly.
203 
205 {
206  // TEveVector is not TObject
207 
208  // TEveMCTrack derives from TParticle
209  TParticle::Class()->IgnoreTObjectStreamer(true);
210 
211  TEveHit::Class()->IgnoreTObjectStreamer(true);
212  TEveCluster::Class()->IgnoreTObjectStreamer(true);
213 
214  TEveRecTrack::Class()->IgnoreTObjectStreamer(true);
215  // TEveRecKink derives from TEveRecTrack
216 
217  TEveRecV0::Class()->IgnoreTObjectStreamer(true);
218 
219  TEveMCRecCrossRef::Class()->IgnoreTObjectStreamer(true);
220 }
virtual void SetDirectory(TDirectory *dir)
Set directory in which the trees are (or will be) created.
Definition: TEveVSD.cxx:64
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
static void DisableTObjectStreamersForVSDStruct()
Disable TObject streamers for those VSD structs that inherit from TObject directly.
Definition: TEveVSD.cxx:204
TEveMCTrack * fpK
Definition: TEveVSD.h:41
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
Definition: TDirectory.cxx:729
virtual void DeleteTrees()
Delete internal trees.
Definition: TEveVSD.cxx:88
Int_t fVerbose
Definition: TEveVSD.h:29
TTree * fTreeH
Kinematics.
Definition: TEveVSD.h:33
TTree * fTreeK
Definition: TEveVSD.h:32
virtual void CreateTrees()
Create internal trees.
Definition: TEveVSD.cxx:72
virtual void LoadTrees()
Load internal trees from directory.
Definition: TEveVSD.cxx:149
TEveVSD(const TEveVSD &)
TDirectory * fDirectory
Definition: TEveVSD.h:26
virtual ~TEveVSD()
Destructor.
Definition: TEveVSD.cxx:57
TEveRecV0 * fpV0
Definition: TEveVSD.h:46
TTree * fTreeR
Clusters.
Definition: TEveVSD.h:35
void Class()
Definition: Class.C:29
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
Definition: TTree.cxx:7873
TEveMCRecCrossRef * fpGI
Definition: TEveVSD.h:48
TTree * fTreeV0
Kinks.
Definition: TEveVSD.h:37
virtual void SetBranchAddresses()
Set branche addresses of internal trees.
Definition: TEveVSD.cxx:122
TEveRecTrack * fpR
Definition: TEveVSD.h:44
TEveCluster * fpC
Definition: TEveVSD.h:43
TTree * fTreeKK
Reconstructed tracks.
Definition: TEveVSD.h:36
TEveHit * fpH
Definition: TEveVSD.h:42
#define ClassImp(name)
Definition: Rtypes.h:336
TEveRecKink * fpKK
Definition: TEveVSD.h:45
Describe directory structure in memory.
Definition: TDirectory.h:34
TTree * fTreeGI
Cascades.
Definition: TEveVSD.h:39
virtual void CreateBranches()
Create internal VSD branches.
Definition: TEveVSD.cxx:102
Visualization Summary Data - a collection of trees holding standard event data in experiment independ...
Definition: TEveVSD.h:19
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
Definition: TTree.cxx:1660
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
Definition: TDirectory.cxx:435
virtual void WriteTrees()
Does nothing here ... reimplemented in sub-classes.
Definition: TEveVSD.cxx:142
Exception class thrown by TEve classes and macros.
Definition: TEveUtil.h:102
A TTree object has a header with a name and a title.
Definition: TTree.h:78
TTree * fTreeC
Hits.
Definition: TEveVSD.h:34
TTree * fTreeCC
VO's.
Definition: TEveVSD.h:38
const char * Data() const
Definition: TString.h:347