Conding violations
[u/mrichter/AliRoot.git] / EVGEN / TestPrimaries.C
CommitLineData
754a67f2 1void TestPrimaries(Int_t evNumber1=0, Int_t evNumber2=0)
2{
3// Dynamically link some shared libs
4 if (gClassTable->GetID("AliRun") < 0) {
5 gROOT->LoadMacro("loadlibs.C");
6 loadlibs();
7 }
8// Connect the Root Galice file containing Geometry, Kine and Hits
1d93d37b 9 AliRunLoader* rl = AliRunLoader::Open("galice.root");
754a67f2 10//
1d93d37b 11 TDatabasePDG* DataBase = TDatabasePDG::Instance();
754a67f2 12
13// Create some histograms
14
15 TH1F *thetaH = new TH1F("thetaH","Theta distribution",180,0,180);
16 TH1F *phiH = new TH1F("phiH","Phi distribution" ,180,-180,180);
17 TH1F *etaH = new TH1F("etaH","Pseudorapidity",120,-12,12);
18 TH1F *yH = new TH1F("yH","Rapidity distribution",120,-12,12);
19 TH1F *eH = new TH1F("eH","Energy distribution",100,0,100);
a78c8623 20 TH1F *eetaH = new TH1F("eetaH","Pseudorapidity",120,0,12);
754a67f2 21 TH1F *ptH = new TH1F("ptH","Pt distribution",150,0,15);
22//
23// Loop over events
24//
1d93d37b 25 rl->LoadKinematics();
26 rl->LoadHeader();
754a67f2 27
28 for (Int_t nev=0; nev<= evNumber2; nev++) {
1d93d37b 29 rl->GetEvent(nev);
30 AliStack* stack = rl->Stack();
31 Int_t npart = stack->GetNprimary();
754a67f2 32 if (nev < evNumber1) continue;
754a67f2 33//
34// Loop over primary particles (jpsi. upsilon, ...)
35//
14b783fa 36
754a67f2 37 for (Int_t part=0; part<npart; part++) {
1d93d37b 38 TParticle *MPart = stack->Particle(part);
754a67f2 39 Int_t mpart = MPart->GetPdgCode();
40 Int_t child1 = MPart->GetFirstDaughter();
41 Int_t child2 = MPart->GetLastDaughter();
42 Int_t mother = MPart->GetFirstMother();
754a67f2 43 Float_t Pt = MPart->Pt();
44 Float_t E = MPart->Energy();
45 Float_t Pz = MPart->Pz();
46 Float_t Py = MPart->Py();
47 Float_t Px = MPart->Px();
48 Float_t pT = TMath::Sqrt(Px*Px+Py*Py);
49 Float_t theta = MPart->Theta();
50 Float_t phi = MPart->Phi()-TMath::Pi();
51 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
73e54f72 52 Float_t y = 0.5*TMath::Log((E+Pz+1.e-13)/(E-Pz+1.e-13));
a78c8623 53
54 if (child1 >= 0) continue;
1d93d37b 55 if (DataBase->GetParticle(mpart)->Charge() == 0) continue;
a78c8623 56 Float_t wgt = 1./(Float_t ((evNumber2-evNumber1)+1.));
57 thetaH->Fill(theta*180./TMath::Pi(),wgt);
58 phiH->Fill(phi*180./TMath::Pi(),wgt);
59 etaH->Fill(eta,5.*wgt);
754a67f2 60 eetaH->Fill(eta,E);
a78c8623 61 yH->Fill(y,5.*wgt);
62 eH->Fill(E,wgt);
63 ptH->Fill(pT,wgt);
754a67f2 64 } // primary loop
65 }
66
67//Create a canvas, set the view range, show histograms
68 TCanvas *c1 = new TCanvas("c1","Canvas 1",400,10,600,700);
69 c1->Divide(2,2);
70 c1->cd(1); ptH->Draw();
71 c1->cd(2); etaH->Draw();
72 c1->cd(3); yH->Draw();
1d93d37b 73 c1->cd(4); eH->Draw();
754a67f2 74
75 TCanvas *c2 = new TCanvas("c2","Canvas 1",400,10,600,700);
76 c2->Divide(2,2);
77 c2->cd(1); phiH->Draw();
78 c2->cd(2); thetaH->Draw();
79 c2->cd(3); eetaH->Draw();
a78c8623 80
1d93d37b 81 TFile* f = new TFile("kineH.root", "update");
82 ptH->Write();
83 etaH->Write();
84 yH->Write();
85 phiH->Write();
86 f->Close();
87
a78c8623 88
754a67f2 89}
90
91
92
93
94
95
96