ndhep  0.1.0
Event.cc
1 #include <TString.h>
2 #include <TRandom.h>
3 #include "Event.hh"
4 
6 ClassImp(NDHep::Event);
8 
9 namespace NDHep
10 {
11 
13  : TObject(), fID(0), fVx(0.0), fVy(0.0), fVz(0.0), fNTracks(0), fTracks(0)
14 {
18 }
19 
20 Event::Event(Long64_t id, Double_t vx, Double_t vy, Double_t vz)
21  : TObject(), fID(id), fVx(vx), fVy(vy), fVz(vz), fNTracks(0), fTracks(0)
22 {
26 
27  fTracks = new TClonesArray("NDHep::Track");
28  gRandom->SetSeed(0);
29 }
30 
32 {
36 
37  delete fTracks;
38  fTracks = 0;
39 }
40 
42 {
46  return (Track *)fTracks->ConstructedAt(fNTracks++);
47 }
48 void Event::Print(Option_t *option) const
49 {
53  Printf("id=%lld vx=%.3f vy=%.3f vz=%.3f nTracks=%d ", fID, fVx, fVy, fVz,
54  fNTracks);
55 
56  if (!fTracks)
57  return;
58 
59  TString str(option);
60  str.ToLower();
61  if (str.Contains("all"))
62  {
63  Track *t;
64  for (Int_t i = 0; i < fTracks->GetEntries(); i++)
65  {
66  t = (Track *)fTracks->At(i);
67  t->Print();
68  }
69  }
70 }
71 
72 void Event::Clear(Option_t *)
73 {
77  fID = 0;
78  fVx = 0;
79  fVy = 0;
80  fVz = 0;
81 
82  fNTracks = 0;
83  fTracks->Clear("C");
84 }
85 
87 {
91 
92  fVx = gRandom->Gaus();
93  fVy = gRandom->Gaus();
94  fVz = gRandom->Gaus();
95 }
96 
97 } // namespace NDHep
Int_t fNTracks
Number of tracks.
Definition: Event.hh:91
void BuildVertexRandom()
Definition: Event.cc:86
TClonesArray * fTracks
Array with all tracks.
Definition: Event.hh:94
Double_t fVx
Vertex x.
Definition: Event.hh:88
virtual void Print(Option_t *option="") const
Definition: Event.cc:48
Event object.
Definition: Event.hh:16
Track object.
Definition: Track.hh:14
virtual void Print(Option_t *option="") const
Definition: Track.cc:53
Long64_t fID
ID of event.
Definition: Event.hh:87
Track * AddTrack()
Definition: Event.cc:41
virtual ~Event()
Definition: Event.cc:31
Double_t fVz
Vertex z.
Definition: Event.hh:90
Double_t fVy
Vertex y.
Definition: Event.hh:89
virtual void Clear(Option_t *option="")
Definition: Event.cc:72