]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/slowClusterAna.C
Major upgrades to the strip structure
[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
411a9c2c 16 Char_t *alifile = "galice.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
411a9c2c 46 Char_t treeName[14];
47 sprintf(treeName,"TRDrecPoints%d", nEvent);
48 TTree *RecTree = gafl->Get(treeName);
f7336fa3 49 RecTree->Print();
50 // Get the pointer to the detector classes
51 AliTRDv1 *TRD = (AliTRDv1*) gAlice->GetDetector("TRD");
52 // Get the geometry
53 AliTRDgeometry *TRDgeometry = TRD->GetGeometry();
54 // Get the pointer to the hit container
6f1e466d 55 TObjArray *RecPointArray = TRD->RecPoints();
f7336fa3 56 // Set the branch address
57 RecTree->GetBranch("TRDrecPoints")->SetAddress(&RecPointArray);
58
59 Int_t nEntries = RecTree->GetEntries();
6f1e466d 60 cout << "nEntries = " << nEntries << endl;
f7336fa3 61
62 // Loop through all entries in the tree
63 Int_t nbytes;
64 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
65
f7336fa3 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();
f7336fa3 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}