Using by default AliHMPIDv2 instead of AliHMPIDv1
[u/mrichter/AliRoot.git] / test / gun / test.C
CommitLineData
3928b038 1// Usage in compiled mode
2// gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include");
3// gROOT->LoadMacro("test.C+");
4// test()
5
6#if !defined(__CINT__) || defined(__MAKECINT__)
7
8// Root include files
9#include <Riostream.h>
10#include <TFile.h>
11#include <TTree.h>
12#include <TBranch.h>
13#include <TStopwatch.h>
14#include <TObject.h>
15#include <TParticle.h>
16
17// AliRoot include files
18#include "AliESD.h"
19#include "AliRunLoader.h"
20#include "AliRun.h"
21#include "AliStack.h"
22
23#endif
24
25void test(const char * sdir =".") {
26
27 TStopwatch timer;
28 timer.Start();
29
30 TString name;
31
32 // Signal file, tree, and branch
33 name = sdir;
34 name += "/AliESDs.root";
35 TFile * fSig = TFile::Open(name.Data());
36 TTree * tSig = (TTree*)fSig->Get("esdTree");
37 TBranch * bSig = tSig->GetBranch("ESD");
38
39 AliESD * esdSig = 0; // The signal ESD object is put here
40 bSig->SetAddress(&esdSig);
41
42 // Run loader (signal events)
43 name = sdir;
44 name += "/galice.root";
45 AliRunLoader* rlSig = AliRunLoader::Open(name.Data());
46
47 // gAlice
48 rlSig->LoadgAlice();
49 gAlice = rlSig->GetAliRun();
50
51 // Now load kinematics and event header
52 rlSig->LoadKinematics();
53 rlSig->LoadHeader();
54
55 // Loop on events: check that MC and data contain the same number of events
56 Long64_t nevSig = rlSig->GetNumberOfEvents();
57
58 cout << nevSig << " signal events" << endl;
59
60 Int_t lab[3]; // Labels from TOF
61 Double_t mom[3]; // Track momentum
62
63 for (Int_t iev=0; iev<nevSig; iev++) {
64 cout << "---------- Signal event ----------" << iev << endl;
65
66 // Get signal ESD
67 bSig->GetEntry(iev);
68
69 // Particle stack
70 rlSig->GetEvent(iev);
71 AliStack * stackSig = rlSig->Stack();
72 stackSig->DumpPStack();
73 Int_t nPartSig = stackSig->GetNtrack();
74
75 Int_t nrec = esdSig->GetNumberOfTracks();
76 cout << nrec << " reconstructed tracks" << endl;
77 for(Int_t irec=0; irec<nrec; irec++) {
78 AliESDtrack * track = esdSig->GetTrack(irec);
79 cout << "Labels:" << endl;
80 cout << "Global: "<< track->GetLabel() << endl;
81 cout << "ITS: "<< track->GetITSLabel() << endl;
82 cout << "TPC: "<< track->GetTPCLabel() << endl;
83 cout << "TRD: "<< track->GetTRDLabel() << endl;
84 track->GetTOFLabel(lab);
85 cout << "TOF: "<< lab[0] <<" "<< lab[1] <<" "<< lab[2] << endl;
86 UInt_t label = TMath::Abs(track->GetLabel());
87 if (label>=10000000) {
88 // Underlying event. 10000000 is the
89 // value of fkMASKSTEP in AliRunDigitizer
90 cout <<"Strange, there should be no underlying event"<<endl;
91 }
92 else {
93 if (label>=nPartSig) {
94 cout <<"Strange, label outside the range"<< endl;
95 continue;
96 }
97 TParticle * part = stackSig->Particle(label);
98 if(part) part->Print();
99 track->GetPxPyPz(mom);
100 cout <<"Momentum: "<< mom[0] <<" "<< mom[1] <<" "<< mom[2] <<endl;
101 }
102
103 }
104
105 }
106
107 fSig->Close();
108
109 timer.Stop();
110 timer.Print();
111}