]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/scripts/evtwrite.cc
Updated misalignment macros (Raffaele)
[u/mrichter/AliRoot.git] / RALICE / scripts / evtwrite.cc
1 //////////////////////////////////////////////////////////////////////////
2 // Test of the AliEvent, AliTrack, AliVertex and AliJet functionality.
3 // Various tracks are created and some momenta and masses are entered
4 // 'by hand'. These tracks are then grouped into vertices and jets
5 // using the RALICE facilities to build events.
6 // In the program several events of different size are created to enable
7 // testing of the multiple event structure on the output file.
8 // The data structures are written onto the output file events.root
9 // 
10 //--- NvE 28-may-2001 UU-SAP Utrecht ***
11 //////////////////////////////////////////////////////////////////////////
12 {
13  gSystem->Load("ralice");
14
15  // Create an output file and a Tree 
16  TFile* f=new TFile("events.root","RECREATE","AliEvent test output");
17  TTree* tree=new TTree("T","Test tree for AliEvent output");
18
19  // Define an event (this is also the main vertex)
20  AliEvent* vmain=new AliEvent();
21
22  // Branch in the tree for trk output
23  Int_t split=0;
24  Int_t bsize=32000;
25  tree->Branch("Events","AliEvent",&vmain,bsize,split); 
26
27  // Define some particle data
28  Float_t p1[3]={0,0,1};
29  Float_t p2[3]={0,0,-1};
30  Float_t p3[3]={1,0,0};
31  Float_t p4[3]={-1,0,0};
32
33  Ali3Vector p;
34
35  AliTrack t1,t2,t3,t4;
36
37  AliJet j1,j2;
38
39  AliVertex vt,vj,v1,v2;
40
41  Float_t pos[3]={0,0,0};
42
43  Double_t m1,m2,thcms,phicms;
44  Double_t pi=acos(-1.);
45
46  Int_t nev=5; // The number of events to be created for the output file
47  for (Int_t iev=1; iev<=nev; iev++)
48  {
49   cout << endl;
50   cout << " === Going for event number : " << iev << endl;
51   cout << endl;
52
53   vmain->SetRunNumber(12345);
54   vmain->SetEventNumber(iev);
55
56   if ((iev != 1) && (iev != 4)) // Create first and 4th event as empty
57   {
58
59    cout << " Event : " << iev << endl;
60
61    p.SetVector(p1,"car");
62    t1.Set3Momentum(p);
63    t1.SetMass(0.135);
64    t1.SetCharge(1);
65
66    p.SetVector(p2,"car");
67    t2.Set3Momentum(p);
68    t2.SetMass(0.135);
69    t2.SetCharge(2);
70
71    p.SetVector(p3,"car");
72    t3.Set3Momentum(p);
73    t3.SetMass(0.135);
74    t3.SetCharge(3);
75
76    p.SetVector(p4,"car");
77    t4.Set3Momentum(p);
78    t4.SetMass(0.135);
79    t4.SetCharge(4);
80
81    if (iev != 3) // No decays for event number 3
82    { 
83     // Testing decay of t3
84     m1=0.01;
85     m2=0.02;
86     thcms=0;
87     phicms=0;
88     t3.Decay(m1,m2,thcms,phicms);
89
90     // Test second level decay
91     m1=0.001;
92     m2=0.002;
93     thcms=0;
94     phicms=0;
95
96     AliTrack* tx;
97     for (Int_t i=1; i<=t3.GetNdecay(); i++)
98     {
99      tx=t3.GetDecayTrack(i);
100      tx->Decay(m1,m2,thcms,phicms);
101     }
102    }
103
104    j1.AddTrack(t1);
105    j1.AddTrack(t2);
106
107    j2.AddTrack(t3);
108    j2.AddTrack(t4);
109
110    // Vertex testing with Tracks
111    vt.AddTrack(t1);
112    vt.AddTrack(t2);
113    vt.AddTrack(t3);
114    vt.AddTrack(t4);
115    pos[0]=1;
116    pos[1]=2;
117    pos[2]=3;
118    vt.SetPosition(pos,"car");
119
120    // Vertex testing with Jets
121    vj.AddJet(j1);
122    vj.AddJet(j2);
123    pos[0]=4;
124    pos[1]=5;
125    pos[2]=6;
126    vj.SetPosition(pos,"car");
127
128    // Secondary Vertex testing
129    v1.AddTrack(t1);
130    v1.AddTrack(t2);
131    v1.AddTrack(t4);
132    pos[0]=11;
133    pos[1]=12;
134    pos[2]=13;
135    v1.SetPosition(pos,"car");
136
137    v2.AddTrack(t2);
138    v2.AddTrack(t3);
139    pos[0]=21;
140    pos[1]=22;
141    pos[2]=23;
142    v2.SetPosition(pos,"car");
143
144    v1.AddVertex(v2); // Make v2 a secondary vertex of v1
145
146    // Define the main vertex vmain and connect all tracks and vertices to it
147    pos[0]=0.01;
148    pos[1]=0.02;
149    pos[2]=0.03;
150    vmain->SetPosition(pos,"car");
151    vmain->AddTrack(t1);
152    vmain->AddTrack(t2);
153    vmain->AddTrack(t3);
154    vmain->AddTrack(t4);
155    if (iev != 2) // These vertices are absent in event number 2
156    {
157     vmain->AddVertex(vt);
158     vmain->AddVertex(vj);
159    }
160    vmain->AddVertex(v1);
161   }
162    
163   // Print the full event data structure
164   vmain.ListAll();
165
166   // Write the complete structure to the output Tree
167   tree->Fill();
168
169   // Reset the complete main Vertex structure
170   vmain->Reset();
171   vt.Reset();
172   vj.Reset();
173   v1.Reset();
174   v2.Reset();
175   t1.Reset();
176   t2.Reset();
177   t3.Reset();
178   t4.Reset();
179   j1.Reset();
180   j2.Reset();
181  }
182
183  // Provide overview of the Tree contents
184  cout << endl;
185  tree->Print();
186
187  // Close output file
188  f->Write();
189  f->Close();
190 }