]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDanalyzeCluster.C
Updated VZERO source
[u/mrichter/AliRoot.git] / TRD / AliTRDanalyzeCluster.C
CommitLineData
4a0fe73c 1Int_t AliTRDanalyzeCluster()
2{
3 //
4 // Analyzes the cluster
5 //
6
7 Int_t rc = 0;
8
9 if (!gAlice) {
10 cout << "<AliTRDanalyzeCluster> No AliRun object found" << endl;
11 rc = 1;
12 return rc;
13 }
14 gAlice->GetEvent(0);
15
16 // Get the pointer to the TRD detector
abaf1f1d 17 AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD");
18 if (!trd) {
4a0fe73c 19 cout << "<AliTRDanalyzeCluster> No TRD detector found" << endl;
20 rc = 2;
21 return rc;
22 }
23
24 // Define the histograms
f9428ca8 25 TH1F *hClusAll = new TH1F("hClusAll" ,"Amplitude of the cluster (all)"
26 ,501,-0.5,500.5);
27 TH1F *hClusNoise = new TH1F("hClusNoise","Amplitude of the cluster (noise)"
28 , 5,-0.5, 4.5);
29 TH1F *hClusEl = new TH1F("hClusEl" ,"Amplitude of the cluster (electron)"
30 ,501,-0.5,500.5);
31 TH1F *hClusPi = new TH1F("hClusPi" ,"Amplitude of the cluster (pion)"
32 ,501,-0.5,500.5);
4a0fe73c 33
34 // Get the pointer to the geometry object
abaf1f1d 35 AliTRDgeometry *geo;
36 if (trd) {
37 geo = trd->GetGeometry();
4a0fe73c 38 }
39 else {
40 cout << "<AliTRDanalyzeCluster> No TRD geometry found" << endl;
41 rc = 3;
42 return rc;
43 }
44
45 // Get the pointer to the hit-tree
46 TFile *file = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
abaf1f1d 47 TTree *clusterTree = (TTree *) file->Get("TreeR0_TRD");
48 if (!(clusterTree)) {
f9428ca8 49 cout << "<AliTRDanalyzeCluster> No tree with clusters found" << endl;
4a0fe73c 50 rc = 4;
51 return rc;
52 }
53
54 // Get the pointer to the hit container
abaf1f1d 55 TObjArray *clusterArray = trd->RecPoints();
56 if (!(clusterArray)) {
57 cout << "<AliTRDanalyzeCluster> No clusterArray found" << endl;
4a0fe73c 58 rc = 5;
59 return rc;
60 }
61
62 // Set the branch address
abaf1f1d 63 clusterTree->GetBranch("TRDcluster")->SetAddress(&clusterArray);
64 Int_t nEntries = clusterTree->GetEntries();
f9428ca8 65 cout << "<AliTRDanalyzeCluster> Number of entries in the cluster tree = "
66 << nEntries
67 << endl;
4a0fe73c 68
69 Int_t countCluster = 0;
abaf1f1d 70 Int_t countOverlap = 0;
4a0fe73c 71
72 // Loop through all entries in the tree
73 Int_t nbytes;
74 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
75
76 // Import the tree
abaf1f1d 77 nbytes += clusterTree->GetEvent(iEntry);
4a0fe73c 78
79 // Get the number of points in the detector
abaf1f1d 80 Int_t nCluster = clusterArray->GetEntriesFast();
4a0fe73c 81
82 // Loop through all TRD digits
f9428ca8 83 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
4a0fe73c 84
85 // Get the information for this digit
abaf1f1d 86 AliTRDcluster *cluster = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
87 Int_t detector = cluster->GetDetector();
88 Int_t sector = geo->GetSector(detector);
89 Int_t plane = geo->GetPlane(detector);
90 Int_t chamber = geo->GetChamber(detector);
91 Float_t energy = cluster->GetQ();
92 Int_t track0 = cluster->GetTrackIndex(0);
93 Int_t track1 = cluster->GetTrackIndex(1);
94 Int_t track2 = cluster->GetTrackIndex(2);
95 TParticle *particle = 0;
4a0fe73c 96 if (track0 > -1) {
abaf1f1d 97 particle = gAlice->Particle(track0);
4a0fe73c 98 }
99
100 countCluster++;
abaf1f1d 101 if (!cluster->Isolated()) countOverlap++;
4a0fe73c 102
103 // Total spectrum
f9428ca8 104 hClusAll->Fill(energy);
4a0fe73c 105
abaf1f1d 106 if (cluster->Isolated()) {
4a0fe73c 107
f9428ca8 108 // Noise spectrum
109 if (track0 < 0) {
110 hClusNoise->Fill(energy);
111 }
112
113 // Electron cluster
abaf1f1d 114 if ((particle) && (particle->GetPdgCode() == 11) && (track1 < 0)) {
f9428ca8 115 hClusEl->Fill(energy);
116 }
117
118 // Pion cluster
abaf1f1d 119 if ((particle) && (particle->GetPdgCode() == -211) && (track1 < 0)) {
f9428ca8 120 hClusPi->Fill(energy);
121 }
4a0fe73c 122
4a0fe73c 123 }
124
125 }
126
127 }
128
abaf1f1d 129 cout << "<AliTRDanalyzeCluster> Found " << countCluster << " cluster in total" << endl;
130 cout << "<AliTRDanalyzeCluster> Found " << countOverlap << " overlapping cluster" << endl;
f9428ca8 131 cout << endl;
4a0fe73c 132
133 TCanvas *cCluster = new TCanvas("cCluster","AliTRDanalyzeCluster",50,50,600,600);
134 cCluster->Divide(2,2);
135
136 TF1 *fun;
137 cCluster->cd(1);
138 gPad->SetLogy();
139 hClusAll->Fit("landau","0");
140 fun = (TF1 *) hClusAll->GetListOfFunctions()->First();
141 Float_t meanAll = fun->GetParameter(1);
142 hClusAll->Draw();
143 fun->SetLineColor(2);
144 fun->Draw("SAME");
145
146 cCluster->cd(2);
147 gPad->SetLogy();
4a0fe73c 148 Float_t meanNoise = hClusNoise->GetMean();
149 hClusNoise->Draw();
150
151 cCluster->cd(3);
152 gPad->SetLogy();
153 hClusEl->Fit("landau","0");
154 fun = (TF1 *) hClusEl->GetListOfFunctions()->First();
155 fun->SetLineColor(2);
156 Float_t meanEl = fun->GetParameter(1);
157 hClusEl->Draw();
158 fun->Draw("SAME");
159
160 cCluster->cd(4);
161 gPad->SetLogy();
162 hClusPi->Fit("landau","0");
163 fun = (TF1 *) hClusPi->GetListOfFunctions()->First();
164 fun->SetLineColor(2);
165 Float_t meanPi = fun->GetParameter(1);
166 hClusPi->Draw();
167 fun->Draw("SAME");
168
169 cout << endl;
170 cout << "##################################################################" << endl;
171 cout << " Mean all = " << meanAll << endl;
172 cout << " Mean noise = " << meanNoise << endl;
173 cout << " Mean electrons = " << meanEl << endl;
174 cout << " Mean pions = " << meanPi << endl;
175 cout << "##################################################################" << endl;
176 cout << endl;
177
178 return rc;
179
180}