]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/AliTRDcheckDetector.cxx
new utility class for TRD PID (Alex W)
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDcheckDetector.cxx
CommitLineData
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>
95cda7cf 10#include <TROOT.h>
23abf4db 11
12#include "AliTRDcluster.h"
13#include "AliTRDseedV1.h"
14#include "AliTRDtrackV1.h"
15#include "TTreeStream.h"
16
17#include "AliTRDtrackInfo/AliTRDtrackInfo.h"
18#include "AliTRDcheckDetector.h"
19
95cda7cf 20#include <cstdio>
21
23abf4db 22////////////////////////////////////////////////////////////////////////////
23// //
24// Reconstruction QA //
25// //
26// Task doing basic checks for tracking and detector performance //
27// //
28// Authors: //
29// Anton Andronic <A.Andronic@gsi.de> //
30// Markus Fasel <M.Fasel@gsi.de> //
31// //
32////////////////////////////////////////////////////////////////////////////
33
34//_______________________________________________________
35AliTRDcheckDetector::AliTRDcheckDetector():
abc70aaf 36 AliTRDrecoTask("detChecker", "Basic Detector Checker")
2b468513 37 ,fPHSdetector(0x0)
38 ,fPHSsector(0x0)
39 ,fQCLdetector(0x0)
40 ,fQCLsector(0x0)
41 ,fQTdetector(0x0)
42 ,fQTsector(0x0)
2a4a428a 43 ,fTriggerNames(0x0)
23abf4db 44{
2b468513 45 //
46 // Default constructor
47 //
23abf4db 48}
49
50//_______________________________________________________
51AliTRDcheckDetector::~AliTRDcheckDetector(){
2b468513 52 //
53 // Destructor
54 //
55 if(fPHSdetector) delete fPHSdetector;
56 if(fPHSsector) delete fPHSsector;
57 if(fQCLdetector) delete fQCLdetector;
58 if(fQCLsector) delete fQCLsector;
59 if(fQTdetector) delete fQTdetector;
60 if(fQTsector) delete fQTsector;
2a4a428a 61 if(fTriggerNames) delete fTriggerNames;
23abf4db 62}
63
64//_______________________________________________________
65void AliTRDcheckDetector::CreateOutputObjects(){
2b468513 66 //
67 // Create Output Objects
68 //
69 fContainer = new TObjArray();
70 TH1F *hNtrks = new TH1F("hNtrks", "Number of Tracks per event", 100, 0, 100);
d85cd79c 71 TH1F *hNcls = new TH1F("hNcls", "Nr. of clusters per track", 30, 0, 180);
23abf4db 72 TH1F *hNtls = new TH1F("hNtls", "Nr. tracklets per track", 10, 0, 10);
73 TH1F *hNclTls = new TH1F("hNclTls","Mean Number of clusters per tracklet", 30, 0, 30);
74 TH1F *hChi2 = new TH1F("hChi2", "Chi2", 200, 0, 20);
75 TH1F *hChi2n = new TH1F("hChi2n", "Norm. Chi2 (tracklets)", 50, 0, 5);
76 TH1F *hSM = new TH1F("hSM", "Track Counts in Supermodule", 18, 0., 18.);
77 TH1F *hQcl = new TH1F("hQcl1", "Cluster charge", 200, -1200, 1200);
78 TProfile *hPH = new TProfile("hPH", "Average PH", 31, -0.5, 30.5);
79 TH1F * hQT = new TH1F("hQT", "Total Charge Deposit", 6000, 0, 6000);
abc70aaf 80 TH1F * hEventsTrigger = new TH1F("hEventsTrigger", "Trigger Class", 20, 0, 20);
23abf4db 81 // Register Histograms
82 fContainer->Add(hNtrks);
abc70aaf 83 fContainer->Add(hEventsTrigger);
2b468513 84 fContainer->Add(hNcls);
85 fContainer->Add(hNtls);
86 fContainer->Add(hNclTls);
87 fContainer->Add(hChi2);
88 fContainer->Add(hChi2n);
89 fContainer->Add(hSM);
90 fContainer->Add(hPH);
91 fContainer->Add(hQcl);
92 fContainer->Add(hQT);
23abf4db 93
2b468513 94 // Initialise the PHS, cluster charge and total charge deposit histograms for each detector
95 fPHSdetector = new TObjArray();
d85cd79c 96 fPHSdetector->SetName("fPHSdetector");
2b468513 97 fQCLdetector = new TObjArray();
d85cd79c 98 fQCLdetector->SetName("fQCLdetector");
2b468513 99 fQTdetector = new TObjArray();
d85cd79c 100 fQTdetector->SetName("fQTdetector");
2b468513 101 for(Int_t idet = 0; idet < kNDetectors; idet++){
102 fPHSdetector->Add(new TProfile(Form("hPHSdet%d", idet), Form("Average Pulse Height in Detector %d", idet), 31, -0.5, 30.5));
103 fQCLdetector->Add(new TH1F(Form("hQd%d",idet),Form("Qd%d",idet), 100,0,5000));
104 fQTdetector->Add(new TH1F(Form("hQTd%d", idet), Form("Qtotal%d", idet), 6000, 0, 6000));
105 }
106 fContainer->Add(fPHSdetector);
107 fContainer->Add(fQCLdetector);
108 fContainer->Add(fQTdetector);
109
110 // Initialise the PHS, cluster charge and total charge deposit histograms for each sector
111 fPHSsector = new TObjArray();
d85cd79c 112 fPHSsector->SetName("fPHSsector");
2b468513 113 fQCLsector = new TObjArray();
d85cd79c 114 fQCLsector->SetName("fQCLsector");
2b468513 115 fQTsector = new TObjArray();
d85cd79c 116 fQTsector->SetName("fQTsector");
2b468513 117 for(Int_t isec = 0; isec < kNSectors; isec++){
118 fPHSsector->Add(new TProfile(Form("hPHSsec%d", isec), Form("Average Pulse Height in Sector %d", isec), 31, -0.5, 30.5));
119 fQCLsector->Add(new TH1F(Form("hQd%d",isec),Form("Qd%d",isec), 100,0,5000));
120 fQTsector->Add(new TH1F(Form("hQTd%d", isec), Form("Qtotal%d", isec), 6000, 0, 6000));
121 }
122 fContainer->Add(fPHSsector);
123 fContainer->Add(fQCLsector);
124 fContainer->Add(fQTsector);
2a4a428a 125 fTriggerNames = new TMap();
126 fTriggerNames->SetName("fTriggerNames");
127 fContainer->Add(fTriggerNames);
23abf4db 128}
129
130//_______________________________________________________
131void AliTRDcheckDetector::Exec(Option_t *){
2b468513 132 //
133 // Execution function
134 // Filling TRD quality histos
135 //
136 Int_t nTracks = 0; // Count the number of tracks per event
abc70aaf 137 Int_t triggermask = 0;
2a4a428a 138 TString triggername = "notrack";
2b468513 139 AliTRDtrackInfo *fTrackInfo = 0x0;
140 AliTRDtrackV1 *fTRDtrack = 0x0;
141 AliTRDseedV1 *fTracklet = 0x0;
142 AliTRDcluster *fTRDcluster = 0x0;
143 for(Int_t iti = 0; iti < fTracks->GetEntriesFast(); iti++){
144 fTrackInfo = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(iti));
145 if(!fTrackInfo || !(fTRDtrack = fTrackInfo->GetTRDtrack())) continue;
2a4a428a 146 if(!triggermask){
147 triggermask = fTrackInfo->GetTriggerCluster();
148 triggername = fTrackInfo->GetTriggerClassName();
149 }
2b468513 150 Int_t nclusters = fTRDtrack->GetNumberOfClusters();
151 Int_t ntracklets = fTRDtrack->GetNumberOfTracklets();
152 Float_t chi2 = fTRDtrack->GetChi2();
153 // Fill Histograms
154 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclustersHist))->Fill(nclusters);
155 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsHist))->Fill(ntracklets);
156 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2))->Fill(chi2);
157 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2Normalized))->Fill(chi2/static_cast<Float_t>(ntracklets));
158 // now loop over single tracklets
159 if(ntracklets > 2){
160 Int_t sector = -1;
161 for(Int_t ilayer = 0; ilayer < kNLayers; ilayer++){
162 if(!(fTracklet = fTRDtrack->GetTracklet(ilayer)) || !fTracklet->IsOK()) continue;
163 Float_t nClustersTracklet = fTracklet->GetN();
164 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclusterTrackletHist))->Fill(nClustersTracklet);
165 if(nClustersTracklet){
166 Float_t Qtot = 0;
167 Int_t detector = -1;
168 for(Int_t itb = 0; itb < kNTimebins; itb++){
169 if(!(fTRDcluster = fTracklet->GetClusters(itb))) continue;
170 Int_t localtime = fTRDcluster->GetLocalTimeBin();
171 Double_t clusterCharge = fTRDcluster->GetQ();
172 detector = fTRDcluster->GetDetector();
173 sector = static_cast<Int_t>(detector/kNDetectorsSector);
174 Double_t absolute_charge = TMath::Abs(clusterCharge);
175 Qtot += absolute_charge;
176 // Fill Histograms
177 // 1st. PHS
178 dynamic_cast<TProfile *>(fContainer->UncheckedAt(kPulseHeight))->Fill(localtime, absolute_charge);
179 dynamic_cast<TProfile *>(fPHSdetector->UncheckedAt(detector))->Fill(localtime, absolute_charge);
180 dynamic_cast<TProfile *>(fPHSsector->UncheckedAt(sector))->Fill(localtime, absolute_charge);
181 // 2nd. cluster charge
182 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kClusterCharge))->Fill(absolute_charge);
183 dynamic_cast<TH1F *>(fQCLdetector->UncheckedAt(detector))->Fill(absolute_charge);
184 dynamic_cast<TH1F *>(fQCLsector->UncheckedAt(sector))->Fill(absolute_charge);
185 }
186 // Fill total cluster charge histograms
187 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChargeDeposit))->Fill(Qtot);
188 dynamic_cast<TH1F *>(fQTdetector->UncheckedAt(detector))->Fill(Qtot);
189 dynamic_cast<TH1F *>(fQTsector->UncheckedAt(sector))->Fill(Qtot);
190 }
191 }
192 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksSectorHist))->Fill(sector);
193 }
194 nTracks++;
195 }
196 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist))->Fill(nTracks);
2a4a428a 197 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger))->Fill(triggermask);
198 if(!fTriggerNames->FindObject(Form("%d", triggermask)))
199 fTriggerNames->Add(new TObjString(Form("%d", triggermask)), new TObjString(triggername));
2b468513 200 PostData(0, fContainer);
23abf4db 201}
202
203//_______________________________________________________
204void AliTRDcheckDetector::Terminate(Option_t *){
2b468513 205 //
206 // Terminate function
207 //
23abf4db 208}
209
95cda7cf 210//_______________________________________________________
211Bool_t AliTRDcheckDetector::PostProcess(){
212 //
213 // Do Postprocessing (for the moment set the number of Reference histograms)
214 //
215
216 TH1 * histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist));
217 histo->GetXaxis()->SetTitle("Number of Tracks");
218 histo->GetYaxis()->SetTitle("Events");
219 // Calculate percentage of events containing tracks
9fbe6f3e 220 Int_t entries = (Int_t)histo->GetEntries();
221 Float_t percTracks = entries > 0 ? (entries - histo->GetBinContent(1))/Float_t(entries) : 0.;
222 printf("Percentage of Events containing TRD Tracks: %6.3f %%\n", 1.E2*percTracks);
95cda7cf 223 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclustersHist));
224 histo->GetXaxis()->SetTitle("Number of Clusters");
225 histo->GetYaxis()->SetTitle("Entries");
226 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsHist));
227 histo->GetXaxis()->SetTitle("Number of Tracklets");
228 histo->GetYaxis()->SetTitle("Entries");
229 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclusterTrackletHist));
230 histo->GetXaxis()->SetTitle("Number of Clusters");
231 histo->GetYaxis()->SetTitle("Entries");
232 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2));
233 histo->GetXaxis()->SetTitle("#chi^2");
234 histo->GetYaxis()->SetTitle("Entries");
235 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksSectorHist));
236 histo->GetXaxis()->SetTitle("Sector");
237 histo->GetYaxis()->SetTitle("Number of Tracks");
95cda7cf 238 histo = dynamic_cast<TProfile *>(fContainer->UncheckedAt(kPulseHeight));
239 histo->GetXaxis()->SetTitle("Time / 100ns");
240 histo->GetYaxis()->SetTitle("Average Pulse Height (a. u.)");
241 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kClusterCharge));
242 histo->GetXaxis()->SetTitle("Cluster Charge (a.u.)");
243 histo->GetYaxis()->SetTitle("Entries");
244 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChargeDeposit));
245 histo->GetXaxis()->SetTitle("Charge Deposit (a.u.)");
246 histo->GetYaxis()->SetTitle("Entries");
abc70aaf 247 // Calculate the Percentage of events containing tracks as function of the trigger cluster
248 histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger));
249 Double_t nEvents = histo->Integral();
2a4a428a 250 fTriggerNames = dynamic_cast<TMap *>(fContainer->UncheckedAt(17));
251 TH1F *percentages = new TH1F("fTriggerInf", "Trigger Information", fTriggerNames->GetEntries(), 0, fTriggerNames->GetEntries());
252 TObject *triggerclass = 0x0;
253 Int_t ipt=0;
254 for(Int_t ibin = 0; ibin < histo->GetNbinsX(); ibin++){
255 if((triggerclass = fTriggerNames->FindObject(Form("%d",ibin)))){
256 TObjString *label = dynamic_cast<TObjString *>(dynamic_cast<TPair *>(triggerclass)->Value());
257 //printf("Trigger Pattern for class %d: %s\n", ibin, label->String().Data());
258 //printf("Percentage of Events: %f\n", histo->GetBinContent(histo->FindBin(ibin))/nEvents);
259 percentages->SetBinContent(percentages->FindBin(ipt), histo->GetBinContent(histo->FindBin(ibin))/nEvents);
260 percentages->GetXaxis()->SetBinLabel(percentages->FindBin(ipt),label->String().Data());
261 ipt++;
262 }
263 }
abc70aaf 264 percentages->GetXaxis()->SetTitle("Trigger Cluster");
2a4a428a 265 percentages->GetYaxis()->SetTitle("%Events");
266 percentages->GetYaxis()->SetRangeUser(0,1);
267// percentages->SetMarkerColor(kBlue);
268// percentages->SetMarkerStyle(22);
abc70aaf 269 fContainer->Add(percentages);
270 fNRefFigures = 10;
95cda7cf 271 return kTRUE;
272}
273
274//_______________________________________________________
22a4ab0c 275void AliTRDcheckDetector::GetRefFigure(Int_t ifig, Int_t &first, Int_t &last, Option_t *opt){
95cda7cf 276 //
277 // Setting Reference Figures
278 //
2a4a428a 279 opt = "pl";
95cda7cf 280 switch(ifig){
abc70aaf 281 case 0: first = last = kNTracksEventHist;
282 break;
283 case 1: first = last = kNclustersHist;
95cda7cf 284 break;
abc70aaf 285 case 2: first = last = kNtrackletsHist;
95cda7cf 286 break;
abc70aaf 287 case 3: first = last = kNclusterTrackletHist;
95cda7cf 288 break;
abc70aaf 289 case 4: first = last = kChi2;
95cda7cf 290 break;
abc70aaf 291 case 5: first = last = kNTracksSectorHist;
95cda7cf 292 break;
abc70aaf 293 case 6: first = last = kPulseHeight;
95cda7cf 294 break;
abc70aaf 295 case 7: first = last = kClusterCharge;
95cda7cf 296 break;
abc70aaf 297 case 8: first = last = kChargeDeposit;
95cda7cf 298 break;
22a4ab0c 299 case 9: first = last = kPostProcessing;
2a4a428a 300 opt="bar";
95cda7cf 301 break;
abc70aaf 302 default: first = last = kNTracksEventHist;
95cda7cf 303 break;
304 };
305}
306