1 // Title: Sample Analysis Macro for looking at data on STAR NTuples
2 // Author: Jim Thomas jhthomas@lbl.gov
3 // Modified: Mikolaj Krzewicki mikolaj.krzewicki@cern.ch
15 gSystem->Load("libTree.so");
16 gSystem->Load("libVMC.so");
17 gSystem->Load("libPhysics.so");
18 gSystem->Load("libPWG2flowCommon");
20 Long64_t EventCounter = 0 ;
21 Int_t TrackCounter = 0 ;
22 Int_t PrintInfo = 1 ; // Print event and track data (1/0) (on/off)
23 Int_t PDG_ID ; // for PID test using Particle Data Group PID names
25 TH1F* myHistogram = new TH1F("Pt","Transverse Momentum", 100, 0.0, 3.0) ;
26 TCanvas* myCanvas = new TCanvas("c1","c1",150,50,500,500) ;
28 myHistogram -> Draw() ; // Prepare the histogram and canvas for updates
30 AliStarEventReader* starReader = new AliStarEventReader( "/data/alice3/jthomas/testData/") ;
31 AliStarEvent* starEvent = starReader->GetEvent();
33 while ( starReader->GetNextEvent() ) // Get next event
35 if ( !starReader->AcceptEvent(starEvent) ) continue; // Test if the event is good
37 if ( PrintInfo == 1 ) starEvent->Print() ; // Print basic information for this event
39 if ((EventCounter%100) == 0)
44 for ( Int_t j = 0 ; j < starEvent->GetNumberOfTracks() ; j++ )
46 AliStarTrack* starTrack = starEvent->GetTrack(j); // Get next track
47 if ( !starReader->AcceptTrack(starTrack) ) continue; // Test if the track is good
49 // Do something useful with the track
50 if ( TrackCounter<5 && PrintInfo==1 ) starTrack->Print(); ; // Print the track data
52 PDG_ID = starReader->ParticleID(starTrack); // Assign Particle Data Book ID number to track (very simple PID algorithm)
53 // Note this is an overly simplified ID algorithm and should really be extended for serious work
54 if ( PDG_ID == 211 ) myHistogram->Fill( starTrack->GetPt() ) ;
55 TrackCounter ++ ; // Count the number of accepted and analyzed tracks
58 //starEvent->Print("all"); //if you want to print info for all tracks
61 if ( PrintInfo == 1 ) // Talk to the user and decide whether to continue, or stop.
63 cout << endl << "Enter 0 to quit, 1 to continue, 2 to continue without printing " << endl ;
66 if ( k == 2 ) PrintInfo = 0 ;
71 if ( (EventCounter%10000) == 0 ) cout << EventCounter << endl ;
72 if ( (EventCounter%10000) == 0 ) myCanvas->Update() ;
75 myCanvas->Update() ; // Final update of histograms
77 starReader = NULL ; // Prepare to exit