ndmspc  0.20250128.0
HepEvent.cxx
1 #include <TString.h>
2 #include <TRandom.h>
3 #include "HepEvent.h"
4 
6 ClassImp(Ndmspc::Hep::Event);
8 
9 namespace Ndmspc {
10 namespace Hep {
11 
12 Event::Event() : TObject(), fID(0), fVx(0.0), fVy(0.0), fVz(0.0), fNTracks(0), fTracks(0)
13 {
17 }
18 
19 Event::Event(Long64_t id, Double_t vx, Double_t vy, Double_t vz)
20  : TObject(), fID(id), fVx(vx), fVy(vy), fVz(vz), fNTracks(0), fTracks(0)
21 {
25 
26  fTracks = new TClonesArray("Ndmspc::Hep::Track");
27  gRandom->SetSeed(0);
28 }
29 
31 {
35 
36  delete fTracks;
37  fTracks = 0;
38 }
39 
41 {
45  return (Track *)fTracks->ConstructedAt(fNTracks++);
46 }
47 void Event::Print(Option_t * option) const
48 {
52  Printf("id=%lld vx=%.3f vy=%.3f vz=%.3f nTracks=%d ", fID, fVx, fVy, fVz, fNTracks);
53 
54  if (!fTracks) return;
55 
56  TString str(option);
57  str.ToLower();
58  if (str.Contains("all")) {
59  Track * t;
60  for (Int_t i = 0; i < fTracks->GetEntries(); i++) {
61  t = (Track *)fTracks->At(i);
62  t->Print();
63  }
64  }
65 }
66 
67 void Event::Clear(Option_t *)
68 {
72  fID = 0;
73  fVx = 0;
74  fVy = 0;
75  fVz = 0;
76 
77  fNTracks = 0;
78  fTracks->Clear("C");
79 }
80 
82 {
86 
87  fVx = gRandom->Gaus();
88  fVy = gRandom->Gaus();
89  fVz = gRandom->Gaus();
90 }
91 
92 } // namespace Hep
93 } // namespace Ndmspc
Event object.
Definition: HepEvent.h:17
virtual ~Event()
Definition: HepEvent.cxx:30
void BuildVertexRandom()
Definition: HepEvent.cxx:81
Track * AddTrack()
Definition: HepEvent.cxx:40
Double_t fVy
Vertex y.
Definition: HepEvent.h:88
Double_t fVz
Vertex z.
Definition: HepEvent.h:89
Long64_t fID
ID of event.
Definition: HepEvent.h:86
TClonesArray * fTracks
Array with all tracks.
Definition: HepEvent.h:93
virtual void Clear(Option_t *option="")
Definition: HepEvent.cxx:67
Double_t fVx
Vertex x.
Definition: HepEvent.h:87
Int_t fNTracks
Number of tracks.
Definition: HepEvent.h:90
virtual void Print(Option_t *option="") const
Definition: HepEvent.cxx:47
Track object.
Definition: HepTrack.h:15
virtual void Print(Option_t *option="") const
Definition: HepTrack.cxx:50