]>
Commit | Line | Data |
---|---|---|
95cda7cf | 1 | #include <TFile.h> |
23abf4db | 2 | #include <TH1F.h> |
abc70aaf | 3 | #include <TGraph.h> |
23abf4db | 4 | #include <TMath.h> |
2a4a428a | 5 | #include <TMap.h> |
23abf4db | 6 | #include <TObjArray.h> |
2a4a428a | 7 | #include <TObject.h> |
8 | #include <TObjString.h> | |
23abf4db | 9 | #include <TProfile.h> |
9e548ae7 | 10 | #include <TProfile2D.h> |
95cda7cf | 11 | #include <TROOT.h> |
23abf4db | 12 | |
13 | #include "AliTRDcluster.h" | |
a24151d1 | 14 | #include "AliESDHeader.h" |
15 | #include "AliESDRun.h" | |
23abf4db | 16 | #include "AliTRDseedV1.h" |
17 | #include "AliTRDtrackV1.h" | |
18 | #include "TTreeStream.h" | |
19 | ||
20 | #include "AliTRDtrackInfo/AliTRDtrackInfo.h" | |
a24151d1 | 21 | #include "AliTRDtrackInfo/AliTRDeventInfo.h" |
23abf4db | 22 | #include "AliTRDcheckDetector.h" |
23 | ||
95cda7cf | 24 | #include <cstdio> |
56f8e2b1 | 25 | #include <iostream> |
95cda7cf | 26 | |
23abf4db | 27 | //////////////////////////////////////////////////////////////////////////// |
28 | // // | |
29 | // Reconstruction QA // | |
30 | // // | |
31 | // Task doing basic checks for tracking and detector performance // | |
32 | // // | |
33 | // Authors: // | |
34 | // Anton Andronic <A.Andronic@gsi.de> // | |
35 | // Markus Fasel <M.Fasel@gsi.de> // | |
36 | // // | |
37 | //////////////////////////////////////////////////////////////////////////// | |
38 | ||
39 | //_______________________________________________________ | |
40 | AliTRDcheckDetector::AliTRDcheckDetector(): | |
93e41bce | 41 | AliTRDrecoTask("DetChecker", "Basic Detector Checker") |
a24151d1 | 42 | ,fEventInfo(0x0) |
2a4a428a | 43 | ,fTriggerNames(0x0) |
23abf4db | 44 | { |
2b468513 | 45 | // |
46 | // Default constructor | |
47 | // | |
a24151d1 | 48 | DefineInput(1,AliTRDeventInfo::Class()); |
23abf4db | 49 | } |
50 | ||
51 | //_______________________________________________________ | |
52 | AliTRDcheckDetector::~AliTRDcheckDetector(){ | |
2b468513 | 53 | // |
54 | // Destructor | |
55 | // | |
a24151d1 | 56 | if(fEventInfo) delete fEventInfo; |
2a4a428a | 57 | if(fTriggerNames) delete fTriggerNames; |
23abf4db | 58 | } |
59 | ||
a24151d1 | 60 | //_______________________________________________________ |
61 | void AliTRDcheckDetector::ConnectInputData(Option_t *opt){ | |
a391a274 | 62 | // |
63 | // Connect the Input data with the task | |
64 | // | |
65 | AliTRDrecoTask::ConnectInputData(opt); | |
66 | fEventInfo = dynamic_cast<AliTRDeventInfo *>(GetInputData(1)); | |
a24151d1 | 67 | } |
68 | ||
23abf4db | 69 | //_______________________________________________________ |
70 | void AliTRDcheckDetector::CreateOutputObjects(){ | |
2b468513 | 71 | // |
72 | // Create Output Objects | |
73 | // | |
9e548ae7 | 74 | fContainer = new TObjArray(25); |
23abf4db | 75 | // Register Histograms |
a24151d1 | 76 | fContainer->Add(new TH1F("hNtrks", "Number of Tracks per event", 100, 0, 100)); |
9e548ae7 | 77 | fContainer->Add(new TH1F("hEventsTriggerTracks", "Trigger Class (Tracks)", 100, 0, 100)); |
959f550d | 78 | fContainer->Add(new TH1F("hNcls", "Nr. of clusters per track", 181, -0.5, 180.5)); |
79 | fContainer->Add(new TH1F("hNtls", "Nr. tracklets per track", 7, -0.5, 6.5)); | |
80 | fContainer->Add(new TH1F("hNclTls","Mean Number of clusters per tracklet", 31, -0.5, 30.5)); | |
a24151d1 | 81 | fContainer->Add(new TH1F("hChi2", "Chi2", 200, 0, 20)); |
82 | fContainer->Add(new TH1F("hChi2n", "Norm. Chi2 (tracklets)", 50, 0, 5)); | |
9e548ae7 | 83 | fContainer->Add(new TH1F("hSM", "Track Counts in Supermodule", 18, -0.5, 17.5)); |
a391a274 | 84 | // Detector signal on Detector-by-Detector basis |
9e548ae7 | 85 | fContainer->Add(new TProfile("hPHdetector", "Average PH", 31, -0.5, 30.5)); |
86 | fContainer->Add(new TH1F("hQclDetector", "Cluster charge", 200, 0, 1200)); | |
87 | fContainer->Add(new TH1F("hQTdetector", "Total Charge Deposit", 6000, 0, 6000)); | |
88 | fContainer->Add(new TH1F("hEventsTrigger", "Trigger Class", 100, 0, 100)); | |
2b468513 | 89 | |
2a4a428a | 90 | fTriggerNames = new TMap(); |
23abf4db | 91 | } |
92 | ||
93 | //_______________________________________________________ | |
94 | void AliTRDcheckDetector::Exec(Option_t *){ | |
2b468513 | 95 | // |
96 | // Execution function | |
97 | // Filling TRD quality histos | |
98 | // | |
9e548ae7 | 99 | if(!HasMCdata() && fEventInfo->GetEventHeader()->GetEventType() != 7) return; // For real data we select only physical events |
2b468513 | 100 | Int_t nTracks = 0; // Count the number of tracks per event |
a24151d1 | 101 | Int_t triggermask = fEventInfo->GetEventHeader()->GetTriggerMask(); |
afefec95 | 102 | TString triggername = fEventInfo->GetRunInfo()->GetFiredTriggerClasses(triggermask); |
9e548ae7 | 103 | if(fDebugLevel > 6)printf("Trigger cluster: %d, Trigger class: %s\n", triggermask, triggername.Data()); |
a24151d1 | 104 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger))->Fill(triggermask); |
2b468513 | 105 | AliTRDtrackInfo *fTrackInfo = 0x0; |
106 | AliTRDtrackV1 *fTRDtrack = 0x0; | |
107 | AliTRDseedV1 *fTracklet = 0x0; | |
108 | AliTRDcluster *fTRDcluster = 0x0; | |
109 | for(Int_t iti = 0; iti < fTracks->GetEntriesFast(); iti++){ | |
110 | fTrackInfo = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(iti)); | |
b718144c | 111 | if(!fTrackInfo || !(fTRDtrack = fTrackInfo->GetTrack())) continue; |
2b468513 | 112 | Int_t nclusters = fTRDtrack->GetNumberOfClusters(); |
113 | Int_t ntracklets = fTRDtrack->GetNumberOfTracklets(); | |
114 | Float_t chi2 = fTRDtrack->GetChi2(); | |
115 | // Fill Histograms | |
116 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclustersHist))->Fill(nclusters); | |
117 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsHist))->Fill(ntracklets); | |
118 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2))->Fill(chi2); | |
119 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2Normalized))->Fill(chi2/static_cast<Float_t>(ntracklets)); | |
120 | // now loop over single tracklets | |
121 | if(ntracklets > 2){ | |
122 | Int_t sector = -1; | |
123 | for(Int_t ilayer = 0; ilayer < kNLayers; ilayer++){ | |
124 | if(!(fTracklet = fTRDtrack->GetTracklet(ilayer)) || !fTracklet->IsOK()) continue; | |
125 | Float_t nClustersTracklet = fTracklet->GetN(); | |
126 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclusterTrackletHist))->Fill(nClustersTracklet); | |
127 | if(nClustersTracklet){ | |
128 | Float_t Qtot = 0; | |
129 | Int_t detector = -1; | |
130 | for(Int_t itb = 0; itb < kNTimebins; itb++){ | |
131 | if(!(fTRDcluster = fTracklet->GetClusters(itb))) continue; | |
132 | Int_t localtime = fTRDcluster->GetLocalTimeBin(); | |
133 | Double_t clusterCharge = fTRDcluster->GetQ(); | |
134 | detector = fTRDcluster->GetDetector(); | |
135 | sector = static_cast<Int_t>(detector/kNDetectorsSector); | |
136 | Double_t absolute_charge = TMath::Abs(clusterCharge); | |
137 | Qtot += absolute_charge; | |
2b468513 | 138 | dynamic_cast<TProfile *>(fContainer->UncheckedAt(kPulseHeight))->Fill(localtime, absolute_charge); |
2b468513 | 139 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kClusterCharge))->Fill(absolute_charge); |
9e548ae7 | 140 | if(fDebugLevel > 2){ |
a391a274 | 141 | (*fDebugStream) << "PulseHeight" |
142 | << "Detector=" << detector | |
143 | << "Sector=" << sector | |
144 | << "Timebin=" << localtime | |
145 | << "Charge=" << absolute_charge | |
146 | << "\n"; | |
9e548ae7 | 147 | } |
2b468513 | 148 | } |
2b468513 | 149 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChargeDeposit))->Fill(Qtot); |
6bdb4b99 | 150 | Int_t crossing = fTracklet->GetNChange(); |
9e548ae7 | 151 | if(fDebugLevel > 3){ |
a391a274 | 152 | (*fDebugStream) << "ChargeDeposit" |
6bdb4b99 | 153 | << "Detector=" << detector |
154 | << "Sector=" << sector | |
155 | << "nclusters=" << nClustersTracklet | |
156 | << "crossing=" << crossing | |
157 | << "QT=" << Qtot | |
a391a274 | 158 | << "\n"; |
9e548ae7 | 159 | } |
2b468513 | 160 | } |
161 | } | |
162 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksSectorHist))->Fill(sector); | |
163 | } | |
164 | nTracks++; | |
165 | } | |
959f550d | 166 | if(nTracks){ |
a391a274 | 167 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks))->Fill(triggermask); |
168 | dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist))->Fill(nTracks); | |
959f550d | 169 | } |
9e548ae7 | 170 | if(triggermask <= 20 && !fTriggerNames->FindObject(Form("%d", triggermask))){ |
2a4a428a | 171 | fTriggerNames->Add(new TObjString(Form("%d", triggermask)), new TObjString(triggername)); |
9e548ae7 | 172 | // also set the label for both histograms |
173 | TH1 *histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks)); | |
174 | histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername); | |
175 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger)); | |
176 | histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername); | |
177 | } | |
2b468513 | 178 | PostData(0, fContainer); |
23abf4db | 179 | } |
180 | ||
181 | //_______________________________________________________ | |
182 | void AliTRDcheckDetector::Terminate(Option_t *){ | |
2b468513 | 183 | // |
184 | // Terminate function | |
185 | // | |
23abf4db | 186 | } |
187 | ||
95cda7cf | 188 | //_______________________________________________________ |
189 | Bool_t AliTRDcheckDetector::PostProcess(){ | |
a391a274 | 190 | // |
191 | // Do Postprocessing (for the moment set the number of Reference histograms) | |
192 | // | |
193 | ||
194 | TH1 * histo = 0x0; | |
195 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist)); | |
196 | histo->GetXaxis()->SetTitle("Number of Tracks"); | |
197 | histo->GetYaxis()->SetTitle("Events"); | |
198 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclustersHist)); | |
199 | histo->GetXaxis()->SetTitle("Number of Clusters"); | |
200 | histo->GetYaxis()->SetTitle("Entries"); | |
201 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsHist)); | |
202 | histo->GetXaxis()->SetTitle("Number of Tracklets"); | |
203 | histo->GetYaxis()->SetTitle("Entries"); | |
204 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclusterTrackletHist)); | |
205 | histo->GetXaxis()->SetTitle("Number of Clusters"); | |
206 | histo->GetYaxis()->SetTitle("Entries"); | |
207 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2)); | |
208 | histo->GetXaxis()->SetTitle("#chi^2"); | |
209 | histo->GetYaxis()->SetTitle("Entries"); | |
210 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksSectorHist)); | |
211 | histo->GetXaxis()->SetTitle("Sector"); | |
212 | histo->GetYaxis()->SetTitle("Number of Tracks"); | |
213 | histo = dynamic_cast<TProfile *>(fContainer->UncheckedAt(kPulseHeight)); | |
214 | histo->GetXaxis()->SetTitle("Time / 100ns"); | |
215 | histo->GetYaxis()->SetTitle("Average Pulse Height (a. u.)"); | |
216 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kClusterCharge)); | |
217 | histo->GetXaxis()->SetTitle("Cluster Charge (a.u.)"); | |
218 | histo->GetYaxis()->SetTitle("Entries"); | |
219 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChargeDeposit)); | |
220 | histo->GetXaxis()->SetTitle("Charge Deposit (a.u.)"); | |
221 | histo->GetYaxis()->SetTitle("Entries"); | |
222 | ||
223 | // Calculate the purity of the trigger clusters | |
224 | histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger)); | |
225 | TH1F *histoTracks = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks)); | |
226 | histoTracks->Divide(histo); | |
227 | Float_t purities[20], val = 0; | |
228 | TString triggernames[20]; | |
229 | Int_t nTriggerClasses = 0; | |
230 | for(Int_t ibin = 1; ibin <= histo->GetNbinsX(); ibin++){ | |
231 | if((val = histoTracks->GetBinContent(ibin))){ | |
232 | purities[nTriggerClasses] = val; | |
233 | triggernames[nTriggerClasses] = histoTracks->GetXaxis()->GetBinLabel(ibin); | |
234 | nTriggerClasses++; | |
235 | } | |
236 | } | |
237 | TH1F *hTriggerInf = new TH1F("fTriggerInf", "Trigger Information", TMath::Max(nTriggerClasses, 1), 0, TMath::Max(nTriggerClasses, 1)); | |
238 | for(Int_t ibin = 1; ibin <= nTriggerClasses; ibin++){ | |
239 | hTriggerInf->SetBinContent(ibin, purities[ibin-1]); | |
240 | hTriggerInf->GetXaxis()->SetBinLabel(ibin, triggernames[ibin-1].Data()); | |
241 | } | |
242 | hTriggerInf->GetXaxis()->SetTitle("Trigger Cluster"); | |
243 | hTriggerInf->GetYaxis()->SetTitle("Ratio"); | |
244 | hTriggerInf->GetYaxis()->SetRangeUser(0,1); | |
9e548ae7 | 245 | // hTriggerInf->SetMarkerColor(kBlue); |
246 | // hTriggerInf->SetMarkerStyle(22); | |
a391a274 | 247 | fContainer->Add(hTriggerInf); |
248 | fNRefFigures = 10; | |
249 | return kTRUE; | |
95cda7cf | 250 | } |
251 | ||
252 | //_______________________________________________________ | |
a391a274 | 253 | void AliTRDcheckDetector::GetRefFigure(Int_t ifig){ |
254 | // | |
255 | // Setting Reference Figures | |
256 | // | |
257 | TH1 *h = 0x0; | |
258 | switch(ifig){ | |
259 | case 0: | |
260 | ((TH1F*)fContainer->At(kNTracksEventHist))->Draw("pl"); | |
261 | break; | |
262 | case 1: | |
263 | ((TH1F*)fContainer->At(kNclustersHist))->Draw("pl"); | |
264 | break; | |
265 | case 2: | |
266 | h = (TH1F*)fContainer->At(kNtrackletsHist); | |
267 | if(!h->GetEntries()) break; | |
268 | h->Scale(100./h->Integral()); | |
269 | h->GetXaxis()->SetRangeUser(.5, 6.5); | |
270 | h->SetFillColor(kGreen); | |
271 | h->SetBarOffset(.2); | |
272 | h->SetBarWidth(.6); | |
273 | h->Draw("bar1"); | |
274 | break; | |
275 | case 3: | |
276 | ((TH1F*)fContainer->At(kNclusterTrackletHist))->Draw("pc"); | |
277 | break; | |
278 | case 4: | |
279 | ((TH1F*)fContainer->At(kChi2))->Draw(""); | |
280 | break; | |
281 | case 5: | |
282 | h = (TH1F*)fContainer->At(kNTracksSectorHist); | |
283 | if(!h->GetEntries()) break; | |
284 | h->Scale(100./h->Integral()); | |
285 | h->SetFillColor(kGreen); | |
286 | h->SetBarOffset(.2); | |
287 | h->SetBarWidth(.6); | |
288 | h->Draw("bar1"); | |
289 | break; | |
290 | case 6: | |
291 | h = (TH1F*)fContainer->At(kPulseHeight); | |
292 | h->SetMarkerStyle(24); | |
293 | h->Draw("e1"); | |
294 | break; | |
295 | case 7: | |
296 | ((TH1F*)fContainer->At(kClusterCharge))->Draw("c"); | |
297 | break; | |
298 | case 8: | |
299 | ((TH1F*)fContainer->At(kChargeDeposit))->Draw("c"); | |
300 | break; | |
301 | case 9: | |
302 | h=(TH1F*)fContainer->At(kPurity); | |
303 | h->SetBarOffset(.2); | |
304 | h->SetBarWidth(.6); | |
305 | h->SetFillColor(kGreen); | |
306 | h->Draw("bar1"); | |
307 | break; | |
308 | default: | |
309 | ((TH1F*)fContainer->At(kNTracksEventHist))->Draw("pl"); | |
310 | break; | |
311 | } | |
95cda7cf | 312 | } |
313 |