1 // Usage in compiled mode
2 // gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include");
3 // gROOT->LoadMacro("test.C+");
6 #if !defined(__CINT__) || defined(__MAKECINT__)
13 #include <TStopwatch.h>
15 #include <TParticle.h>
17 // AliRoot include files
18 #include "AliESDEvent.h"
19 #include "AliRunLoader.h"
25 void test(const char * sdir ="signal",
26 const char * bdir ="backgr") {
33 // Signal file, tree, and branch
35 name += "/AliESDs.root";
36 TFile * fSig = TFile::Open(name.Data());
37 TTree * tSig = (TTree*)fSig->Get("esdTree");
39 AliESDEvent * esdSig = new AliESDEvent();// The signal ESD object is put here
40 esdSig->ReadFromTree(tSig);
42 // Run loader (signal events)
44 name += "/galice.root";
45 AliRunLoader* rlSig = AliRunLoader::Open(name.Data());
47 // Run loader (underlying events)
49 name += "/galice.root";
50 AliRunLoader* rlUnd = AliRunLoader::Open(name.Data(),"Underlying");
55 gAlice = rlSig->GetAliRun();
57 // Now load kinematics and event header
58 rlSig->LoadKinematics();
60 rlUnd->LoadKinematics();
63 // Loop on events: check that MC and data contain the same number of events
64 Long64_t nevSig = rlSig->GetNumberOfEvents();
65 Long64_t nevUnd = rlUnd->GetNumberOfEvents();
66 Long64_t nSigPerUnd = nevSig/nevUnd;
68 cout << nevSig << " signal events" << endl;
69 cout << nevUnd << " underlying events" << endl;
70 cout << nSigPerUnd << " signal events per one underlying" << endl;
72 for (Int_t iev=0; iev<nevSig; iev++) {
73 cout << "Signal event " << iev << endl;
74 Int_t ievUnd = iev/nSigPerUnd;
75 cout << "Underlying event " << ievUnd << endl;
79 // Get signal kinematics
81 // Get underlying kinematics
82 rlUnd->GetEvent(ievUnd);
85 AliStack * stackSig = rlSig->Stack();
86 Int_t nPartSig = stackSig->GetNtrack();
87 AliStack * stackUnd = rlUnd->Stack();
88 Int_t nPartUnd = stackUnd->GetNtrack();
90 Int_t nrec = esdSig->GetNumberOfTracks();
91 cout << nrec << " reconstructed tracks" << endl;
92 for(Int_t irec=0; irec<nrec; irec++) {
93 AliESDtrack * track = esdSig->GetTrack(irec);
94 UInt_t label = TMath::Abs(track->GetTPCLabel());
95 if (label>=10000000) {
96 // Underlying event. 10000000 is the
97 // value of fkMASKSTEP in AliRunDigitizer
98 // cout << " Track from the underlying event" << endl;
100 if (label>=nPartUnd) continue;
101 TParticle * part = stackUnd->Particle(label);
102 if(part) part->Print();
105 cout << " Track " << label << " from the signal event" << endl;
106 if (label>=nPartSig) {
107 cout <<"Strange, label outside the range "<< endl;
110 TParticle * part = stackSig->Particle(label);
111 if(part) part->Print();