Line data Source code
1 : #include "TObject.h"
2 : #include "AliRunLoader.h"
3 : #include "AliRun.h"
4 : #include "AliLoader.h"
5 : #include "AliMFT.h"
6 : #include "TClonesArray.h"
7 : #include "AliMFTCluster.h"
8 : #include "AliMFTSegmentation.h"
9 : #include "TFile.h"
10 : #include "TH1D.h"
11 : #include "TH2D.h"
12 : #include "AliLog.h"
13 : #include "TString.h"
14 : #include "TTree.h"
15 :
16 : #include "AliMFTClusterQA.h"
17 :
18 : //====================================================================================================================================================
19 : //
20 : // Class for the analysis of the MFT clusters (a.k.a. rec points). Few QA histograms are created
21 : //
22 : // Contact author: antonio.uras@cern.ch
23 : //
24 : //====================================================================================================================================================
25 :
26 12 : ClassImp(AliMFTClusterQA)
27 :
28 : //====================================================================================================================================================
29 :
30 : AliMFTClusterQA::AliMFTClusterQA():
31 0 : TObject(),
32 0 : fMFTLoader(0),
33 0 : fRunLoader(0),
34 0 : fMFT(0),
35 0 : fNEvents(0),
36 0 : fEv(0),
37 0 : fFileOut(0),
38 0 : fReadDir(0),
39 0 : fOutDir(0)
40 0 : {
41 :
42 : // default constructor
43 :
44 0 : for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
45 0 : fHistNClustersPerEvent[iPlane] = 0;
46 0 : fHistNPixelsPerCluster[iPlane] = 0;
47 0 : fHistClusterSizeX[iPlane] = 0;
48 0 : fHistClusterSizeY[iPlane] = 0;
49 0 : fHistClusterRadialPosition[iPlane] = 0;
50 0 : fClusterScatterPlotXY[iPlane] = 0;
51 : }
52 :
53 0 : }
54 :
55 : //====================================================================================================================================================
56 :
57 : void AliMFTClusterQA::Init(Char_t *readDir, Char_t *outDir, Int_t nEventsToAnalyze) {
58 :
59 0 : fReadDir = readDir;
60 0 : fOutDir = outDir;
61 :
62 0 : fRunLoader = AliRunLoader::Open(Form("%s/galice.root", fReadDir.Data()));
63 0 : gAlice = fRunLoader->GetAliRun();
64 0 : if (!gAlice) fRunLoader->LoadgAlice();
65 0 : fNEvents = fRunLoader->GetNumberOfEvents();
66 0 : if (nEventsToAnalyze>0) fNEvents = TMath::Min(fNEvents, nEventsToAnalyze);
67 :
68 0 : fMFT = (AliMFT*) gAlice->GetDetector("MFT");
69 :
70 0 : BookHistos();
71 :
72 0 : fMFTLoader = fRunLoader->GetDetectorLoader("MFT");
73 0 : fMFTLoader -> LoadRecPoints("READ");
74 :
75 0 : }
76 :
77 : //====================================================================================================================================================
78 :
79 : Bool_t AliMFTClusterQA::LoadNextEvent() {
80 :
81 0 : if (fEv>=fNEvents) return kFALSE;
82 0 : AliDebug(1, Form("event %5d",fEv));
83 :
84 0 : fRunLoader->GetEvent(fEv);
85 0 : fEv++;
86 :
87 0 : if (!fMFTLoader->TreeR()->GetEvent()) return kTRUE;
88 :
89 0 : for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
90 0 : Int_t nClusters = fMFT->GetRecPointsList(iPlane)->GetEntries();
91 0 : fHistNClustersPerEvent[iPlane] -> Fill(nClusters);
92 0 : fClusterScatterPlotXY[iPlane] -> Fill(0., 0.); // "scaler" bin
93 0 : AliDebug(1,Form("nClusters = %5d", nClusters));
94 0 : for (Int_t iCluster=0; iCluster<nClusters; iCluster++) {
95 0 : AliMFTCluster *cluster = (AliMFTCluster*) (fMFT->GetRecPointsList(iPlane))->At(iCluster);
96 0 : fHistNPixelsPerCluster[iPlane] -> Fill(cluster->GetSize());
97 0 : fHistClusterSizeX[iPlane] -> Fill(cluster->GetErrX()*1.e4); // converted in microns
98 0 : fHistClusterSizeY[iPlane] -> Fill(cluster->GetErrY()*1.e4); // converted in microns
99 0 : fHistClusterRadialPosition[iPlane] -> Fill(TMath::Sqrt(cluster->GetX()*cluster->GetX()+cluster->GetY()*cluster->GetY()));
100 0 : fClusterScatterPlotXY[iPlane] -> Fill(cluster->GetX(), cluster->GetY());
101 : }
102 : }
103 :
104 0 : return kTRUE;
105 :
106 0 : }
107 :
108 : //====================================================================================================================================================
109 :
110 : void AliMFTClusterQA::BookHistos() {
111 :
112 0 : fFileOut = new TFile(Form("%s/MFT.RecPoints.QA.root",fOutDir.Data()), "recreate");
113 :
114 0 : for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
115 :
116 0 : fHistNClustersPerEvent[iPlane] = new TH1D(Form("fHistNClustersPerEvent_Pl%02d",iPlane),
117 0 : Form("Number of clusters per event in Plane%02d",iPlane),
118 : 25000, -0.5, 24999.5);
119 :
120 0 : fHistNPixelsPerCluster[iPlane] = new TH1D(Form("fHistNPixelsPerCluster_Pl%02d",iPlane),
121 0 : Form("Number of pixels per cluster in Plane%02d",iPlane),
122 : 15, -0.5, 14.5);
123 :
124 0 : fHistClusterSizeX[iPlane] = new TH1D(Form("fHistClusterSizeX_Pl%02d",iPlane),
125 0 : Form("#Deltax for clusters in Plane%02d",iPlane),
126 : 100, 0., 100.);
127 :
128 0 : fHistClusterSizeY[iPlane] = new TH1D(Form("fHistClusterSizeY_Pl%02d",iPlane),
129 0 : Form("#Deltay for clusters in Plane%02d",iPlane),
130 : 100, 0., 100.);
131 :
132 0 : fHistNClustersPerEvent[iPlane] -> SetXTitle("N_{clusters} per Event");
133 0 : fHistNPixelsPerCluster[iPlane] -> SetXTitle("N_{pixels} per Cluster");
134 0 : fHistClusterSizeX[iPlane] -> SetXTitle("#Deltax [#mum]");
135 0 : fHistClusterSizeY[iPlane] -> SetXTitle("#Deltay [#mum]");
136 :
137 0 : fHistNClustersPerEvent[iPlane] -> Sumw2();
138 0 : fHistNPixelsPerCluster[iPlane] -> Sumw2();
139 0 : fHistClusterSizeX[iPlane] -> Sumw2();
140 0 : fHistClusterSizeY[iPlane] -> Sumw2();
141 :
142 : //------------------------------------------------------------
143 :
144 : Int_t rMax = 20.;//
145 :
146 0 : fHistClusterRadialPosition[iPlane] = new TH1D(Form("fHistClusterRadialPosition_Pl%02d",iPlane),
147 0 : Form("Cluster radial position (Plane%02d)",iPlane),
148 0 : rMax, 0, Double_t(rMax)/10.);
149 :
150 0 : fClusterScatterPlotXY[iPlane] = new TH2D(Form("fClusterScatterPlotXY_Pl%02d",iPlane),
151 0 : Form("Cluster scatter plot (Plane%02d)",iPlane),
152 0 : 2*rMax+1, (-rMax-0.5)/10., (rMax+0.5)/10., 2*rMax+1, (-rMax-0.5)/10., (rMax+0.5)/10.);
153 :
154 0 : fHistClusterRadialPosition[iPlane] -> SetXTitle("R [cm]");
155 0 : fClusterScatterPlotXY[iPlane] -> SetXTitle("X [cm]");
156 0 : fClusterScatterPlotXY[iPlane] -> SetYTitle("Y [cm]");
157 :
158 0 : fHistClusterRadialPosition[iPlane] -> Sumw2();
159 0 : fClusterScatterPlotXY[iPlane] -> Sumw2();
160 :
161 : }
162 :
163 0 : }
164 :
165 : //====================================================================================================================================================
166 :
167 : void AliMFTClusterQA::Terminate() {
168 :
169 0 : AliInfo("Writing QA histos...");
170 :
171 : // ---- equalize radial clusters distribution ----------------------
172 :
173 0 : for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
174 0 : for (Int_t iBin=1; iBin<=fHistClusterRadialPosition[iPlane]->GetNbinsX(); iBin++) {
175 0 : Double_t rMin = fHistClusterRadialPosition[iPlane]->GetBinLowEdge(iBin); // in cm
176 0 : Double_t rMax = fHistClusterRadialPosition[iPlane]->GetBinWidth(iBin) + rMin; // in cm
177 0 : Double_t area = 100.*TMath::Pi()*(rMax*rMax - rMin*rMin); // in mm^2
178 0 : Double_t density = fHistClusterRadialPosition[iPlane]->GetBinContent(iBin)/area;
179 0 : fHistClusterRadialPosition[iPlane]->SetBinContent(iBin, density);
180 0 : fHistClusterRadialPosition[iPlane]->SetBinError(iBin, fHistClusterRadialPosition[iPlane]->GetBinError(iBin)/area);
181 : }
182 0 : fHistClusterRadialPosition[iPlane] -> SetBinContent(1, fEv); // "scaler" bin
183 : }
184 :
185 : // -----------------------------------------------------------------
186 :
187 0 : fFileOut->cd();
188 :
189 0 : for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
190 0 : fHistNClustersPerEvent[iPlane] -> Write();
191 0 : fHistNPixelsPerCluster[iPlane] -> Write();
192 0 : fHistClusterSizeX[iPlane] -> Write();
193 0 : fHistClusterSizeY[iPlane] -> Write();
194 0 : fHistClusterRadialPosition[iPlane] -> Write();
195 0 : fClusterScatterPlotXY[iPlane] -> Write();
196 : }
197 :
198 0 : fFileOut -> Close();
199 :
200 0 : }
201 :
202 : //====================================================================================================================================================
|