]>
Commit | Line | Data |
---|---|---|
f7336fa3 | 1 | void slowClusterAna() { |
2 | ||
3 | ///////////////////////////////////////////////////////////////////////// | |
4 | // | |
5 | // Example macro for the analysis of the TRD cluster | |
6 | // | |
7 | ///////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | // Dynamically link some shared libs | |
10 | if (gClassTable->GetID("AliRun") < 0) { | |
11 | gROOT->LoadMacro("loadlibs.C"); | |
12 | loadlibs(); | |
13 | } | |
14 | ||
15 | // Input file name | |
6f1e466d | 16 | Char_t *alifile = "galice_r_v1.root"; |
f7336fa3 | 17 | |
18 | // Event number | |
19 | Int_t nEvent = 0; | |
20 | ||
21 | // Define the histograms | |
22 | TH1F *hEnergy = new TH1F("hEnergy","Cluster energy",100,0.0,1000.0); | |
23 | ||
24 | // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits | |
25 | TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile); | |
26 | if (!gafl) { | |
27 | cout << "Open the ALIROOT-file " << alifile << endl; | |
28 | gafl = new TFile(alifile); | |
29 | } | |
30 | else { | |
31 | cout << alifile << " is already open" << endl; | |
32 | } | |
33 | ||
34 | // Get AliRun object from file or create it if not on file | |
35 | gAlice = (AliRun*) gafl->Get("gAlice"); | |
36 | if (gAlice) | |
37 | cout << "AliRun object found on file" << endl; | |
38 | else | |
39 | gAlice = new AliRun("gAlice","Alice test program"); | |
40 | ||
41 | // Import the Trees for the event nEvent in the file | |
42 | Int_t nparticles = gAlice->GetEvent(nEvent); | |
43 | if (nparticles <= 0) break; | |
44 | ||
45 | // Get the pointer to the hit-tree | |
46 | TTree *RecTree = gAlice->TreeR(); | |
47 | RecTree->Print(); | |
48 | // Get the pointer to the detector classes | |
49 | AliTRDv1 *TRD = (AliTRDv1*) gAlice->GetDetector("TRD"); | |
50 | // Get the geometry | |
51 | AliTRDgeometry *TRDgeometry = TRD->GetGeometry(); | |
52 | // Get the pointer to the hit container | |
6f1e466d | 53 | TObjArray *RecPointArray = TRD->RecPoints(); |
f7336fa3 | 54 | // Set the branch address |
55 | RecTree->GetBranch("TRDrecPoints")->SetAddress(&RecPointArray); | |
56 | ||
57 | Int_t nEntries = RecTree->GetEntries(); | |
6f1e466d | 58 | cout << "nEntries = " << nEntries << endl; |
f7336fa3 | 59 | |
60 | // Loop through all entries in the tree | |
61 | Int_t nbytes; | |
62 | for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { | |
63 | ||
64 | cout << "iEntry = " << iEntry << endl; | |
65 | ||
66 | // Import the tree | |
67 | nbytes += RecTree->GetEvent(iEntry); | |
68 | ||
6f1e466d | 69 | // Get the number of points in the detector |
f7336fa3 | 70 | Int_t nRecPoint = RecPointArray->GetEntriesFast(); |
71 | cout << " nRecPoint = " << nRecPoint << endl; | |
72 | ||
73 | // Loop through all TRD digits | |
74 | for (Int_t iRecPoint = 0; iRecPoint < nRecPoint; iRecPoint++) { | |
75 | ||
76 | // Get the information for this digit | |
77 | AliTRDrecPoint *RecPoint = (AliTRDrecPoint *) RecPointArray->UncheckedAt(iRecPoint); | |
78 | Int_t detector = RecPoint->GetDetector(); | |
79 | Int_t sector = TRDgeometry->GetSector(detector); | |
80 | Int_t plane = TRDgeometry->GetPlane(detector); | |
81 | Int_t chamber = TRDgeometry->GetChamber(detector); | |
82 | Int_t energy = RecPoint->GetEnergy(); | |
83 | TVector3 pos; | |
84 | RecPoint->GetLocalPosition(pos); | |
85 | ||
86 | hEnergy->Fill((Float_t) energy); | |
87 | ||
88 | } | |
89 | ||
90 | } | |
91 | ||
92 | TCanvas *c1 = new TCanvas("c1","Cluster",50,50,600,400); | |
93 | hEnergy->Draw(); | |
94 | ||
95 | } |