Add new TRD classes
[u/mrichter/AliRoot.git] / TRD / slowClusterAna.C
CommitLineData
f7336fa3 1void 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
16 Char_t *alifile = "galice_c_v1.root";
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
53 TClonesArray *RecPointArray = TRD->RecPoints();
54 // Set the branch address
55 RecTree->GetBranch("TRDrecPoints")->SetAddress(&RecPointArray);
56
57 Int_t nEntries = RecTree->GetEntries();
58
59 // Loop through all entries in the tree
60 Int_t nbytes;
61 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
62
63 cout << "iEntry = " << iEntry << endl;
64
65 // Import the tree
66 nbytes += RecTree->GetEvent(iEntry);
67
68 // Get the number of digits in the detector
69 Int_t nRecPoint = RecPointArray->GetEntriesFast();
70 cout << " nRecPoint = " << nRecPoint << endl;
71
72 // Loop through all TRD digits
73 for (Int_t iRecPoint = 0; iRecPoint < nRecPoint; iRecPoint++) {
74
75 // Get the information for this digit
76 AliTRDrecPoint *RecPoint = (AliTRDrecPoint *) RecPointArray->UncheckedAt(iRecPoint);
77 Int_t detector = RecPoint->GetDetector();
78 Int_t sector = TRDgeometry->GetSector(detector);
79 Int_t plane = TRDgeometry->GetPlane(detector);
80 Int_t chamber = TRDgeometry->GetChamber(detector);
81 Int_t energy = RecPoint->GetEnergy();
82 TVector3 pos;
83 RecPoint->GetLocalPosition(pos);
84
85 hEnergy->Fill((Float_t) energy);
86
87 }
88
89 }
90
91 TCanvas *c1 = new TCanvas("c1","Cluster",50,50,600,400);
92 hEnergy->Draw();
93
94}