]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/fastClusterAna.C
Resolved merge conflict
[u/mrichter/AliRoot.git] / TRD / fastClusterAna.C
CommitLineData
d5a17faf 1void fastClusterAna() {
5c7f4665 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_v0.root";
17
18 // Event number
19 Int_t nEvent = 0;
20
21 // Define the objects
22 AliTRDv1 *TRD;
23 TClonesArray *TRDCluster;
24 AliTRDcluster *OneTRDcluster;
25
26 TH1F *hZ = new TH1F("hZ","Cluster z-position",700,-350.0,350.0);
27
28 // Connect the AliRoot file containing Geometry, Kine, Hits, and Digits
29 TFile *gafl = (TFile*) gROOT->GetListOfFiles()->FindObject(alifile);
30 if (!gafl) {
31 cout << "Open the ALIROOT-file " << alifile << endl;
32 gafl = new TFile(alifile);
33 }
34 else {
35 cout << alifile << " is already open" << endl;
36 }
37
38 // Get AliRun object from file or create it if not on file
39 if (!gAlice) {
40 gAlice = (AliRun*) gafl->Get("gAlice");
41 if (gAlice)
42 cout << "AliRun object found on file" << endl;
43 else
44 gAlice = new AliRun("gAlice","Alice test program");
45 }
46
47 // Import the Trees for the event nEvent in the file
48 Int_t nparticles = gAlice->GetEvent(nEvent);
49 cout << "nparticles = " << nparticles << endl;
50 if (nparticles <= 0) break;
51
52 // Get the pointer to the tree
53 TTree *ClusterTree = gAlice->TreeD();
54
55 // Get the pointer to the detector classes
56 TRD = (AliTRDv1 *) gAlice->GetDetector("TRD");
57 // Get the pointer to the hit container
58 if (TRD) TRDCluster = TRD->Cluster();
59
60 // Reconstruct the address
61 ClusterTree->GetBranch("TRDcluster")->SetAddress(&TRDCluster);
62
63 Int_t nEntries = ClusterTree->GetEntries();
64 cout << "Number of entries in cluster tree = " << nEntries << endl;
65
66 // Loop through all entries in the tree
67 Int_t nbytes;
68 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
69
70 cout << "iEntry = " << iEntry << endl;
71
72 // Import the tree
73 gAlice->ResetDigits();
74 nbytes += ClusterTree->GetEvent(iEntry);
75
76 // Get the number of digits in the detector
77 Int_t nTRDCluster = TRDCluster->GetEntriesFast();
78 cout << " nTRDCluster = " << nTRDCluster << endl;
79
80 // Loop through all TRD digits
81 for (Int_t iTRDCluster = 0; iTRDCluster < nTRDCluster; iTRDCluster++) {
82
83 // Get the information for this digit
84 OneTRDcluster = (AliTRDcluster*) TRDCluster->UncheckedAt(iTRDCluster);
85 hZ->Fill(OneTRDcluster->fZ);
86
87 }
88
89 }
90
91 hZ->Draw();
92
93}