]>
Commit | Line | Data |
---|---|---|
f553869e | 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 | |
4 | // Date: 04-Aug-2010 | |
5 | // | |
6 | ||
7 | #include "TCanvas.h" | |
8 | #include "TH1F.h" | |
9 | #include "TMath.h" | |
10 | #include "TNtuple.h" | |
11 | #include "TLeaf.h" | |
12 | ||
13 | void readStarEvents() | |
14 | { | |
c855d803 | 15 | gSystem->Load("libTree.so"); |
16 | gSystem->Load("libVMC.so"); | |
17 | gSystem->Load("libPhysics.so"); | |
2e311896 | 18 | gSystem->Load("libPWGflowBase"); |
f553869e | 19 | |
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 | |
24 | ||
25 | TH1F* myHistogram = new TH1F("Pt","Transverse Momentum", 100, 0.0, 3.0) ; | |
26 | TCanvas* myCanvas = new TCanvas("c1","c1",150,50,500,500) ; | |
27 | myCanvas -> cd() ; | |
28 | myHistogram -> Draw() ; // Prepare the histogram and canvas for updates | |
29 | ||
30 | AliStarEventReader* starReader = new AliStarEventReader( "/data/alice3/jthomas/testData/") ; | |
31 | AliStarEvent* starEvent = starReader->GetEvent(); | |
32 | ||
33 | while ( starReader->GetNextEvent() ) // Get next event | |
34 | { | |
35 | if ( !starReader->AcceptEvent(starEvent) ) continue; // Test if the event is good | |
36 | ||
37 | if ( PrintInfo == 1 ) starEvent->Print() ; // Print basic information for this event | |
38 | ||
39 | if ((EventCounter%100) == 0) | |
40 | { | |
41 | TrackCounter = 0 ; | |
42 | ||
43 | //loop over track | |
44 | for ( Int_t j = 0 ; j < starEvent->GetNumberOfTracks() ; j++ ) | |
45 | { | |
46 | AliStarTrack* starTrack = starEvent->GetTrack(j); // Get next track | |
47 | if ( !starReader->AcceptTrack(starTrack) ) continue; // Test if the track is good | |
48 | ||
49 | // Do something useful with the track | |
50 | if ( TrackCounter<5 && PrintInfo==1 ) starTrack->Print(); ; // Print the track data | |
51 | ||
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 | |
56 | } | |
57 | ||
58 | //starEvent->Print("all"); //if you want to print info for all tracks | |
59 | ||
60 | ||
61 | if ( PrintInfo == 1 ) // Talk to the user and decide whether to continue, or stop. | |
62 | { | |
63 | cout << endl << "Enter 0 to quit, 1 to continue, 2 to continue without printing " << endl ; | |
64 | Int_t k = 0 ; | |
65 | cin >> k ; | |
66 | if ( k == 2 ) PrintInfo = 0 ; | |
67 | if (k <= 0) return ; | |
68 | } | |
69 | } | |
70 | EventCounter ++ ; | |
71 | if ( (EventCounter%10000) == 0 ) cout << EventCounter << endl ; | |
72 | if ( (EventCounter%10000) == 0 ) myCanvas->Update() ; | |
73 | } | |
74 | ||
75 | myCanvas->Update() ; // Final update of histograms | |
76 | delete starReader ; | |
77 | starReader = NULL ; // Prepare to exit | |
78 | } |