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