]>
Commit | Line | Data |
---|---|---|
917559ee | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliTRDqaElectronSpectra.cxx $ */ | |
17 | ||
18 | // | |
19 | // This class is a part of a package of high level QA monitoring for TRD. | |
20 | // | |
21 | // The transverse momentum spectrum is analyzed stack-by-stack | |
22 | // for all tracks, and for electron tracks. | |
23 | // Tracks have to pass quality cuts. | |
24 | // Electrons are waighted with the PID LQ | |
25 | // | |
26 | // S. Radomski | |
27 | // radomski@physi.uni-heidelberg.de | |
28 | // March 2008 | |
29 | // | |
30 | ||
31 | #include "AliTRDqaElectronSpectra.h" | |
32 | #include "AliTRDqaAT.h" | |
33 | ||
34 | #include "TMath.h" | |
35 | #include "TH1D.h" | |
36 | #include "TH2D.h" | |
37 | #include "TFile.h" | |
38 | #include "TTree.h" | |
39 | #include "TChain.h" | |
40 | ||
41 | #include "AliESDEvent.h" | |
42 | #include "AliESDtrack.h" | |
43 | ||
44 | //______________________________________________________________________________ | |
45 | ||
46 | AliTRDqaElectronSpectra::AliTRDqaElectronSpectra() | |
47 | : AliAnalysisTask("",""), | |
48 | fChain(0), | |
49 | fESD(0), | |
50 | fOutputContainer(0), | |
51 | fStatus(0), | |
52 | fSector(0), | |
53 | fTheta(0), | |
54 | fStack(0), | |
55 | fnTracks(0), | |
56 | fnElTracks(0), | |
57 | fTracksRatio(0), | |
58 | fPt(0), | |
59 | fPtElectron(0), | |
60 | fMeanPt(0), | |
61 | fMeanPtElectron(0), | |
62 | fPtStack(0), | |
63 | fPtStackElectron(0), | |
64 | fElectronLQ(0) | |
65 | { | |
66 | // | |
67 | // default dummy constructor | |
68 | // | |
69 | ||
70 | } | |
71 | //______________________________________________________________________________ | |
72 | ||
73 | AliTRDqaElectronSpectra:: AliTRDqaElectronSpectra(AliTRDqaElectronSpectra& /*trd*/) | |
74 | : AliAnalysisTask("",""), | |
75 | fChain(0), | |
76 | fESD(0), | |
77 | fOutputContainer(0), | |
78 | fStatus(0), | |
79 | fSector(0), | |
80 | fTheta(0), | |
81 | fStack(0), | |
82 | fnTracks(0), | |
83 | fnElTracks(0), | |
84 | fTracksRatio(0), | |
85 | fPt(0), | |
86 | fPtElectron(0), | |
87 | fMeanPt(0), | |
88 | fMeanPtElectron(0), | |
89 | fPtStack(0), | |
90 | fPtStackElectron(0), | |
91 | fElectronLQ(0) | |
92 | { | |
93 | // | |
94 | // Dummy copy constructor | |
95 | // | |
96 | ||
97 | //return *this; | |
98 | } | |
99 | ||
100 | ||
101 | //______________________________________________________________________________ | |
102 | AliTRDqaElectronSpectra::AliTRDqaElectronSpectra(const char *name) | |
103 | : AliAnalysisTask(name,""), | |
104 | fChain(0), | |
105 | fESD(0), | |
106 | fOutputContainer(0), | |
107 | fStatus(0), | |
108 | fSector(0), | |
109 | fTheta(0), | |
110 | fStack(0), | |
111 | fnTracks(0), | |
112 | fnElTracks(0), | |
113 | fTracksRatio(0), | |
114 | fPt(0), | |
115 | fPtElectron(0), | |
116 | fMeanPt(0), | |
117 | fMeanPtElectron(0), | |
118 | fPtStack(0), | |
119 | fPtStackElectron(0), | |
120 | fElectronLQ(0) | |
121 | { | |
122 | // Constructor. | |
123 | // Input slot #0 works with an Ntuple | |
124 | DefineInput(0, TChain::Class()); | |
125 | // Output slot #0 writes into a TH1 container | |
126 | DefineOutput(0, TObjArray::Class()) ; | |
127 | } | |
128 | ||
129 | //______________________________________________________________________________ | |
130 | void AliTRDqaElectronSpectra::ConnectInputData(const Option_t *) | |
131 | { | |
132 | // Initialisation of branch container and histograms | |
133 | ||
134 | //AliInfo(Form("*** Initialization of %s", GetName())) ; | |
135 | ||
136 | fChain = (TChain*)GetInputData(0); | |
137 | fESD = new AliESDEvent(); | |
138 | fESD->ReadFromTree(fChain); | |
139 | } | |
140 | ||
141 | //________________________________________________________________________ | |
142 | void AliTRDqaElectronSpectra::CreateOutputObjects() | |
143 | { | |
144 | // build histograms | |
145 | ||
146 | fStatus = new TH1D("status", ";status bit", 32, -0.5, 31.5); | |
147 | fSector = new TH1D("sector", ";sector", 18, -0.5, 17.5); | |
148 | fTheta = new TH1D("theta", ";theta (rad)", 100, -1, 1); | |
149 | fStack = new TH1D("stack", ";stack", 90, -0.5, 89.5); | |
150 | ||
151 | fnTracks = new TH1D("tracks", ";stack;number of tracks", 90, -0.5, 89.5); | |
152 | fnElTracks = new TH1D("elTracks", ";stack;number of electron tracks", 90, -0.5, 89.5); | |
153 | fTracksRatio = new TH1D("fractionElectrons", ";stack;fraction of electron tracks", 90, -0.5, 89.5); | |
154 | ||
155 | fPt = new TH1D("pt", "p_{T} (GeV/c)", 50, 0, 10); | |
156 | fPtElectron = new TH1D("ptElectron", "p_{T} (GeV/c)", 50, 0, 10); | |
157 | ||
158 | fMeanPt = new TH1D("meanPt", ";<p_{T}> (GeV/c)", 100, 0, 5); | |
159 | fMeanPtElectron = new TH1D("meanPtElectron", ";<P_{T}> (GeV/c)", 100, 0, 5); | |
160 | ||
161 | fPtStack = new TH2D("stackPt", ";stack;p_{T} (GeV/c)", 90, -0.5, 89.5, 50, 0, 10); | |
162 | fPtStackElectron = new TH2D("stackPtEl", ";stack;p_{T} (GeV/c)", 90, -0.5, 89.5, 50, 0, 10); | |
163 | ||
164 | fElectronLQ = new TH1D("elLQ", ";likelyhood", 100, 0, 1); | |
165 | ||
166 | Int_t c = 0; | |
167 | fOutputContainer = new TObjArray(50); | |
168 | ||
169 | fOutputContainer->AddAt(fStatus, c++); | |
170 | fOutputContainer->AddAt(fSector, c++); | |
171 | fOutputContainer->AddAt(fTheta, c++); | |
172 | fOutputContainer->AddAt(fStack, c++); | |
173 | ||
174 | fOutputContainer->AddAt(fnTracks, c++); | |
175 | fOutputContainer->AddAt(fnElTracks, c++); | |
176 | fOutputContainer->AddAt(fTracksRatio, c++); | |
177 | ||
178 | fOutputContainer->AddAt(fPt, c++); | |
179 | fOutputContainer->AddAt(fPtElectron, c++); | |
180 | ||
181 | fOutputContainer->AddAt(fMeanPt, c++); | |
182 | fOutputContainer->AddAt(fMeanPtElectron, c++); | |
183 | ||
184 | fOutputContainer->AddAt(fPtStack, c++); | |
185 | fOutputContainer->AddAt(fPtStackElectron, c++); | |
186 | ||
187 | fOutputContainer->AddAt(fElectronLQ, c++); | |
188 | ||
189 | printf("n hist = %d\n", c); | |
190 | } | |
191 | //______________________________________________________________________________ | |
192 | void AliTRDqaElectronSpectra::Exec(Option_t *) | |
193 | { | |
194 | // Process one event | |
195 | Long64_t entry = fChain->GetReadEntry() ; | |
196 | if (!(entry%10)) Info("Exec", "Entry = %ld", entry); | |
197 | ||
198 | // Processing of one event | |
199 | ||
200 | if (!fESD) { | |
201 | //AliError("fESD is not connected to the input!") ; | |
202 | return ; | |
203 | } | |
204 | ||
205 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
206 | //fNTracks->Fill(nTracks); | |
207 | ||
208 | // track loop | |
209 | for(Int_t i=0; i<nTracks; i++) { | |
210 | ||
211 | // | |
212 | // track selection | |
213 | // | |
214 | // param in and Out | |
215 | // TRDrefit and TRDPid bit | |
216 | // | |
217 | ||
218 | AliESDtrack *track = fESD->GetTrack(i); | |
219 | const AliExternalTrackParam *paramOut = track->GetOuterParam(); | |
220 | const AliExternalTrackParam *paramIn = track->GetInnerParam(); | |
221 | ||
222 | // long track .. | |
223 | if (!paramIn) continue; | |
224 | if (!paramOut) continue; | |
225 | ||
226 | UInt_t status = track->GetStatus(); | |
227 | if (!(status & AliESDtrack::kTRDrefit)) continue; | |
228 | if (!(status & AliESDtrack::kTRDpid)) continue; | |
229 | if (track->GetTRDpidQuality() < 6) continue; | |
230 | ||
231 | Int_t sm = AliTRDqaAT::GetSector(paramOut->GetAlpha()); | |
232 | Int_t stack = 5*sm + AliTRDqaAT::GetStack(paramOut); | |
233 | Double_t lq = track->GetTRDpid(AliPID::kElectron); | |
234 | Double_t pt = paramOut->Pt(); | |
235 | ||
236 | //TH1D *fStatus; // track status | |
237 | fSector->Fill(sm); | |
238 | fStack->Fill(stack); | |
239 | fElectronLQ->Fill(lq); | |
240 | ||
241 | fTheta->Fill(paramOut->GetZ() / paramOut->GetX()); | |
242 | ||
243 | fnTracks->Fill(stack); | |
244 | fnElTracks->Fill(stack, lq); | |
245 | ||
246 | fPt->Fill(pt); | |
247 | fPtElectron->Fill(pt, lq); | |
248 | ||
249 | fPtStack->Fill(stack, pt); | |
250 | fPtStackElectron->Fill(stack, pt, lq); | |
251 | } | |
252 | ||
253 | PostData(0, fOutputContainer); | |
254 | } | |
255 | ||
256 | //______________________________________________________________________________ | |
257 | void AliTRDqaElectronSpectra::Terminate(Option_t *) | |
258 | { | |
259 | // save histograms | |
260 | fOutputContainer = (TObjArray*)GetOutputData(0); | |
261 | ||
262 | // build ratios | |
263 | fnTracks = (TH1D*)fOutputContainer->FindObject("tracks"); | |
264 | fnElTracks = (TH1D*)fOutputContainer->FindObject("elTracks"); | |
265 | fTracksRatio = (TH1D*)fOutputContainer->FindObject("fractionElectrons"); | |
266 | ||
267 | AliTRDqaAT::BuildRatio(fTracksRatio, fnElTracks, fnTracks); | |
268 | ||
269 | // save the results | |
270 | ||
271 | TFile *file = new TFile("outElSpectra.root", "RECREATE"); | |
272 | fOutputContainer->Write(); | |
273 | ||
274 | file->Flush(); | |
275 | file->Close(); | |
276 | delete file; | |
277 | ||
278 | //for(Int_t i=0; i<fOutputContainer->GetEntries(); i++) { | |
279 | // TObject *obj = fOu | |
280 | // } | |
281 | } | |
282 | ||
283 | //______________________________________________________________________________ |