AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMFTClusterQA.cxx
Go to the documentation of this file.
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 
27 
28 //====================================================================================================================================================
29 
31  TObject(),
32  fMFTLoader(0),
33  fRunLoader(0),
34  fMFT(0),
35  fNEvents(0),
36  fEv(0),
37  fFileOut(0),
38  fReadDir(0),
39  fOutDir(0)
40 {
41 
42  // default constructor
43 
44  for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
45  fHistNClustersPerEvent[iPlane] = 0;
46  fHistNPixelsPerCluster[iPlane] = 0;
47  fHistClusterSizeX[iPlane] = 0;
48  fHistClusterSizeY[iPlane] = 0;
49  fHistClusterRadialPosition[iPlane] = 0;
50  fClusterScatterPlotXY[iPlane] = 0;
51  }
52 
53 }
54 
55 //====================================================================================================================================================
56 
57 void AliMFTClusterQA::Init(Char_t *readDir, Char_t *outDir, Int_t nEventsToAnalyze) {
58 
59  fReadDir = readDir;
60  fOutDir = outDir;
61 
62  fRunLoader = AliRunLoader::Open(Form("%s/galice.root", fReadDir.Data()));
63  gAlice = fRunLoader->GetAliRun();
64  if (!gAlice) fRunLoader->LoadgAlice();
65  fNEvents = fRunLoader->GetNumberOfEvents();
66  if (nEventsToAnalyze>0) fNEvents = TMath::Min(fNEvents, nEventsToAnalyze);
67 
68  fMFT = (AliMFT*) gAlice->GetDetector("MFT");
69 
70  BookHistos();
71 
72  fMFTLoader = fRunLoader->GetDetectorLoader("MFT");
73  fMFTLoader -> LoadRecPoints("READ");
74 
75 }
76 
77 //====================================================================================================================================================
78 
80 
81  if (fEv>=fNEvents) return kFALSE;
82  AliDebug(1, Form("event %5d",fEv));
83 
84  fRunLoader->GetEvent(fEv);
85  fEv++;
86 
87  if (!fMFTLoader->TreeR()->GetEvent()) return kTRUE;
88 
89  for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
90  Int_t nClusters = fMFT->GetRecPointsList(iPlane)->GetEntries();
91  fHistNClustersPerEvent[iPlane] -> Fill(nClusters);
92  fClusterScatterPlotXY[iPlane] -> Fill(0., 0.); // "scaler" bin
93  AliDebug(1,Form("nClusters = %5d", nClusters));
94  for (Int_t iCluster=0; iCluster<nClusters; iCluster++) {
95  AliMFTCluster *cluster = (AliMFTCluster*) (fMFT->GetRecPointsList(iPlane))->At(iCluster);
96  fHistNPixelsPerCluster[iPlane] -> Fill(cluster->GetSize());
97  fHistClusterSizeX[iPlane] -> Fill(cluster->GetErrX()*1.e4); // converted in microns
98  fHistClusterSizeY[iPlane] -> Fill(cluster->GetErrY()*1.e4); // converted in microns
99  fHistClusterRadialPosition[iPlane] -> Fill(TMath::Sqrt(cluster->GetX()*cluster->GetX()+cluster->GetY()*cluster->GetY()));
100  fClusterScatterPlotXY[iPlane] -> Fill(cluster->GetX(), cluster->GetY());
101  }
102  }
103 
104  return kTRUE;
105 
106 }
107 
108 //====================================================================================================================================================
109 
111 
112  fFileOut = new TFile(Form("%s/MFT.RecPoints.QA.root",fOutDir.Data()), "recreate");
113 
114  for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
115 
116  fHistNClustersPerEvent[iPlane] = new TH1D(Form("fHistNClustersPerEvent_Pl%02d",iPlane),
117  Form("Number of clusters per event in Plane%02d",iPlane),
118  25000, -0.5, 24999.5);
119 
120  fHistNPixelsPerCluster[iPlane] = new TH1D(Form("fHistNPixelsPerCluster_Pl%02d",iPlane),
121  Form("Number of pixels per cluster in Plane%02d",iPlane),
122  15, -0.5, 14.5);
123 
124  fHistClusterSizeX[iPlane] = new TH1D(Form("fHistClusterSizeX_Pl%02d",iPlane),
125  Form("#Deltax for clusters in Plane%02d",iPlane),
126  100, 0., 100.);
127 
128  fHistClusterSizeY[iPlane] = new TH1D(Form("fHistClusterSizeY_Pl%02d",iPlane),
129  Form("#Deltay for clusters in Plane%02d",iPlane),
130  100, 0., 100.);
131 
132  fHistNClustersPerEvent[iPlane] -> SetXTitle("N_{clusters} per Event");
133  fHistNPixelsPerCluster[iPlane] -> SetXTitle("N_{pixels} per Cluster");
134  fHistClusterSizeX[iPlane] -> SetXTitle("#Deltax [#mum]");
135  fHistClusterSizeY[iPlane] -> SetXTitle("#Deltay [#mum]");
136 
137  fHistNClustersPerEvent[iPlane] -> Sumw2();
138  fHistNPixelsPerCluster[iPlane] -> Sumw2();
139  fHistClusterSizeX[iPlane] -> Sumw2();
140  fHistClusterSizeY[iPlane] -> Sumw2();
141 
142  //------------------------------------------------------------
143 
144  Int_t rMax = 20.;//
145 
146  fHistClusterRadialPosition[iPlane] = new TH1D(Form("fHistClusterRadialPosition_Pl%02d",iPlane),
147  Form("Cluster radial position (Plane%02d)",iPlane),
148  rMax, 0, Double_t(rMax)/10.);
149 
150  fClusterScatterPlotXY[iPlane] = new TH2D(Form("fClusterScatterPlotXY_Pl%02d",iPlane),
151  Form("Cluster scatter plot (Plane%02d)",iPlane),
152  2*rMax+1, (-rMax-0.5)/10., (rMax+0.5)/10., 2*rMax+1, (-rMax-0.5)/10., (rMax+0.5)/10.);
153 
154  fHistClusterRadialPosition[iPlane] -> SetXTitle("R [cm]");
155  fClusterScatterPlotXY[iPlane] -> SetXTitle("X [cm]");
156  fClusterScatterPlotXY[iPlane] -> SetYTitle("Y [cm]");
157 
158  fHistClusterRadialPosition[iPlane] -> Sumw2();
159  fClusterScatterPlotXY[iPlane] -> Sumw2();
160 
161  }
162 
163 }
164 
165 //====================================================================================================================================================
166 
168 
169  AliInfo("Writing QA histos...");
170 
171  // ---- equalize radial clusters distribution ----------------------
172 
173  for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
174  for (Int_t iBin=1; iBin<=fHistClusterRadialPosition[iPlane]->GetNbinsX(); iBin++) {
175  Double_t rMin = fHistClusterRadialPosition[iPlane]->GetBinLowEdge(iBin); // in cm
176  Double_t rMax = fHistClusterRadialPosition[iPlane]->GetBinWidth(iBin) + rMin; // in cm
177  Double_t area = 100.*TMath::Pi()*(rMax*rMax - rMin*rMin); // in mm^2
178  Double_t density = fHistClusterRadialPosition[iPlane]->GetBinContent(iBin)/area;
179  fHistClusterRadialPosition[iPlane]->SetBinContent(iBin, density);
180  fHistClusterRadialPosition[iPlane]->SetBinError(iBin, fHistClusterRadialPosition[iPlane]->GetBinError(iBin)/area);
181  }
182  fHistClusterRadialPosition[iPlane] -> SetBinContent(1, fEv); // "scaler" bin
183  }
184 
185  // -----------------------------------------------------------------
186 
187  fFileOut->cd();
188 
189  for (Int_t iPlane=0; iPlane<AliMFTConstants::kNDisks; iPlane++) {
190  fHistNClustersPerEvent[iPlane] -> Write();
191  fHistNPixelsPerCluster[iPlane] -> Write();
192  fHistClusterSizeX[iPlane] -> Write();
193  fHistClusterSizeY[iPlane] -> Write();
194  fHistClusterRadialPosition[iPlane] -> Write();
195  fClusterScatterPlotXY[iPlane] -> Write();
196  }
197 
198  fFileOut -> Close();
199 
200 }
201 
202 //====================================================================================================================================================
TFile * Open(const char *filename, Long64_t &nevents)
TObjArray * GetRecPointsList() const
Definition: AliMFT.h:75
TH1D * fHistNClustersPerEvent[fNMaxPlanes]
Int_t GetSize() const
Definition: AliMFTCluster.h:73
Definition: AliMFT.h:41
Double_t GetY() const
Definition: AliMFTCluster.h:42
TH1D * fHistClusterSizeY[fNMaxPlanes]
TH2D * fClusterScatterPlotXY[fNMaxPlanes]
ClassImp(AliMFTClusterQA) AliMFTClusterQA
TH1D * fHistClusterRadialPosition[fNMaxPlanes]
Double_t GetX() const
Definition: AliMFTCluster.h:41
AliLoader * fMFTLoader
Double_t GetErrY() const
Definition: AliMFTCluster.h:52
AliRun * gAlice
TH1D * fHistClusterSizeX[fNMaxPlanes]
Double_t GetErrX() const
Definition: AliMFTCluster.h:51
AliRunLoader * fRunLoader
void Init(Char_t *readDir, Char_t *outDir, Int_t nEventsToAnalyze)
TH1D * fHistNPixelsPerCluster[fNMaxPlanes]
static const Int_t kNDisks
Number of Disk.