]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaRec/AliTRDcheckDetector.cxx
datamember added in AliGeomManager with number of alignable volumes per subdetector...
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDcheckDetector.cxx
1 #include <TFile.h>
2 #include <TH1F.h>
3 #include <TGraph.h>
4 #include <TMath.h>
5 #include <TMap.h>
6 #include <TObjArray.h>
7 #include <TObject.h>
8 #include <TObjString.h>
9 #include <TProfile.h>
10 #include <TProfile2D.h>
11 #include <TROOT.h>
12
13 #include "AliLog.h"
14 #include "AliTRDcluster.h"
15 #include "AliESDHeader.h"
16 #include "AliESDRun.h"
17 #include "AliTRDgeometry.h"
18 #include "AliTRDseedV1.h"
19 #include "AliTRDtrackV1.h"
20 #include "AliTrackReference.h"
21 #include "TTreeStream.h"
22
23 #include "AliTRDtrackInfo/AliTRDtrackInfo.h"
24 #include "AliTRDtrackInfo/AliTRDeventInfo.h"
25 #include "AliTRDcheckDetector.h"
26
27 #include <cstdio>
28 #include <iostream>
29
30 ////////////////////////////////////////////////////////////////////////////
31 //                                                                        //
32 //  Reconstruction QA                                                     //
33 //                                                                        //
34 //  Task doing basic checks for tracking and detector performance         //
35 //                                                                        //
36 //  Authors:                                                              //
37 //    Anton Andronic <A.Andronic@gsi.de>                                  //
38 //    Markus Fasel <M.Fasel@gsi.de>                                       //
39 //                                                                        //
40 ////////////////////////////////////////////////////////////////////////////
41
42 //_______________________________________________________
43 AliTRDcheckDetector::AliTRDcheckDetector():
44   AliTRDrecoTask("DetChecker", "Basic Detector Checker")
45   ,fEventInfo(0x0)
46   ,fTriggerNames(0x0)
47 {
48   //
49   // Default constructor
50   //
51   DefineInput(1,AliTRDeventInfo::Class());
52   InitFunctorList();
53 }
54
55 //_______________________________________________________
56 AliTRDcheckDetector::~AliTRDcheckDetector(){
57   //
58   // Destructor
59   // 
60   if(fEventInfo) delete fEventInfo;
61   if(fTriggerNames) delete fTriggerNames;
62 }
63
64 //_______________________________________________________
65 void AliTRDcheckDetector::ConnectInputData(Option_t *opt){
66   //
67   // Connect the Input data with the task
68   //
69   AliTRDrecoTask::ConnectInputData(opt);
70   fEventInfo = dynamic_cast<AliTRDeventInfo *>(GetInputData(1));
71 }
72
73 //_______________________________________________________
74 void AliTRDcheckDetector::CreateOutputObjects(){
75   //
76   // Create Output Objects
77   //
78   OpenFile(0,"RECREATE");
79   fContainer = Histos();
80   if(!fTriggerNames) fTriggerNames = new TMap();
81 }
82
83 //_______________________________________________________
84 void AliTRDcheckDetector::Exec(Option_t *opt){
85   //
86   // Execution function
87   // Filling TRD quality histos
88   //
89   if(!HasMCdata() && fEventInfo->GetEventHeader()->GetEventType() != 7) return; // For real data we select only physical events
90   AliTRDrecoTask::Exec(opt);  
91   Int_t nTracks = 0;            // Count the number of tracks per event
92   Int_t triggermask = fEventInfo->GetEventHeader()->GetTriggerMask();
93   TString triggername =  fEventInfo->GetRunInfo()->GetFiredTriggerClasses(triggermask);
94   if(fDebugLevel > 6)printf("Trigger cluster: %d, Trigger class: %s\n", triggermask, triggername.Data());
95   dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger))->Fill(triggermask);
96   for(Int_t iti = 0; iti < fTracks->GetEntriesFast(); iti++){
97     if(!fTracks->UncheckedAt(iti)) continue;
98     AliTRDtrackInfo *fTrackInfo = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(iti));
99     if(!fTrackInfo->GetTrack()) continue;
100     nTracks++;
101   }
102   if(nTracks){
103     dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks))->Fill(triggermask);
104     dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist))->Fill(nTracks);
105   }
106   if(triggermask <= 20 && !fTriggerNames->FindObject(Form("%d", triggermask))){
107     fTriggerNames->Add(new TObjString(Form("%d", triggermask)), new TObjString(triggername));
108     // also set the label for both histograms
109     TH1 *histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks));
110     histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername);
111     histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger));
112     histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername);
113   }
114   PostData(0, fContainer);
115 }
116
117 //_______________________________________________________
118 void AliTRDcheckDetector::Terminate(Option_t *){
119   //
120   // Terminate function
121   //
122 }
123
124 //_______________________________________________________
125 Bool_t AliTRDcheckDetector::PostProcess(){
126   //
127   // Do Postprocessing (for the moment set the number of Reference histograms)
128   //
129   
130   TH1 * histo = 0x0;
131   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksEventHist));
132   histo->GetXaxis()->SetTitle("Number of Tracks");
133   histo->GetYaxis()->SetTitle("Events");
134   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclustersHist));
135   histo->GetXaxis()->SetTitle("Number of Clusters");
136   histo->GetYaxis()->SetTitle("Entries");
137   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtrackletsHist));
138   histo->GetXaxis()->SetTitle("Number of Tracklets");
139   histo->GetYaxis()->SetTitle("Entries");
140   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNclusterTrackletHist));
141   histo->GetXaxis()->SetTitle("Number of Clusters");
142   histo->GetYaxis()->SetTitle("Entries");
143   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChi2));
144   histo->GetXaxis()->SetTitle("#chi^2");
145   histo->GetYaxis()->SetTitle("Entries");
146   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNTracksSectorHist));
147   histo->GetXaxis()->SetTitle("Sector");
148   histo->GetYaxis()->SetTitle("Number of Tracks");
149   histo = dynamic_cast<TProfile *>(fContainer->UncheckedAt(kPulseHeight));
150   histo->GetXaxis()->SetTitle("Time / 100ns");
151   histo->GetYaxis()->SetTitle("Average Pulse Height (a. u.)");
152   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kClusterCharge));
153   histo->GetXaxis()->SetTitle("Cluster Charge (a.u.)");
154   histo->GetYaxis()->SetTitle("Entries");
155   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kChargeDeposit));
156   histo->GetXaxis()->SetTitle("Charge Deposit (a.u.)");
157   histo->GetYaxis()->SetTitle("Entries");
158   
159   // Calculate the purity of the trigger clusters
160   histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTrigger));
161   TH1F *histoTracks = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNEventsTriggerTracks));
162   histoTracks->Divide(histo);
163   Float_t purities[20], val = 0;
164   TString triggernames[20];
165   Int_t nTriggerClasses = 0;
166   for(Int_t ibin = 1; ibin <= histo->GetNbinsX(); ibin++){
167     if((val = histoTracks->GetBinContent(ibin))){
168       purities[nTriggerClasses] = val;
169       triggernames[nTriggerClasses] = histoTracks->GetXaxis()->GetBinLabel(ibin);
170       nTriggerClasses++;
171     }
172   }
173   TH1F *hTriggerInf = new TH1F("fTriggerInf", "Trigger Information", TMath::Max(nTriggerClasses, 1), 0, TMath::Max(nTriggerClasses, 1));
174   for(Int_t ibin = 1; ibin <= nTriggerClasses; ibin++){
175     hTriggerInf->SetBinContent(ibin, purities[ibin-1]);
176     hTriggerInf->GetXaxis()->SetBinLabel(ibin, triggernames[ibin-1].Data());
177   }
178   hTriggerInf->GetXaxis()->SetTitle("Trigger Cluster");
179   hTriggerInf->GetYaxis()->SetTitle("Ratio");
180   hTriggerInf->GetYaxis()->SetRangeUser(0,1);
181 //      hTriggerInf->SetMarkerColor(kBlue);
182 //      hTriggerInf->SetMarkerStyle(22);
183   fContainer->Add(hTriggerInf);
184   fNRefFigures = 10;
185   return kTRUE;
186 }
187
188 //_______________________________________________________
189 void AliTRDcheckDetector::GetRefFigure(Int_t ifig){
190   //
191   // Setting Reference Figures
192   //
193   TH1 *h = 0x0;
194   switch(ifig){
195   case 0:       
196     ((TH1F*)fContainer->At(kNTracksEventHist))->Draw("pl");
197     break;
198   case 1:
199     ((TH1F*)fContainer->At(kNclustersHist))->Draw("pl");
200     break;
201   case 2:
202     h = (TH1F*)fContainer->At(kNtrackletsHist);
203     if(!h->GetEntries()) break;
204     h->Scale(100./h->Integral());
205     h->GetXaxis()->SetRangeUser(.5, 6.5);
206     h->SetFillColor(kGreen);
207     h->SetBarOffset(.2);
208     h->SetBarWidth(.6);
209     h->Draw("bar1");
210     break;
211   case 3:
212     ((TH1F*)fContainer->At(kNclusterTrackletHist))->Draw("pc");
213     break;
214   case 4:
215     ((TH1F*)fContainer->At(kChi2))->Draw("");
216     break;
217   case 5:
218     h = (TH1F*)fContainer->At(kNTracksSectorHist);
219     if(!h->GetEntries()) break;
220     h->Scale(100./h->Integral());
221     h->SetFillColor(kGreen);
222     h->SetBarOffset(.2);
223     h->SetBarWidth(.6);
224     h->Draw("bar1");
225     break;
226   case 6:
227     h = (TH1F*)fContainer->At(kPulseHeight);
228     h->SetMarkerStyle(24);
229     h->Draw("e1");
230     break;
231   case 7:
232     ((TH1F*)fContainer->At(kClusterCharge))->Draw("c");
233     break;
234   case 8:
235     ((TH1F*)fContainer->At(kChargeDeposit))->Draw("c");
236     break;
237   case 9: 
238     h=(TH1F*)fContainer->At(kPurity);
239     h->SetBarOffset(.2);
240     h->SetBarWidth(.6);
241     h->SetFillColor(kGreen);
242     h->Draw("bar1");
243     break;
244   default:
245     ((TH1F*)fContainer->At(kNTracksEventHist))->Draw("pl");
246     break;
247   }
248 }
249
250 //_______________________________________________________
251 TObjArray *AliTRDcheckDetector::Histos(){
252   //
253   // Create QA histograms
254   //
255   if(fContainer) return fContainer;
256   
257   fContainer = new TObjArray(25);
258   // Register Histograms
259   fContainer->AddAt(new TH1F("hNtrks", "Number of Tracks per event", 100, 0, 100), kNTracksEventHist);
260   fContainer->AddAt(new TH1F("hEventsTriggerTracks", "Trigger Class (Tracks)", 100, 0, 100), kNEventsTriggerTracks);
261   fContainer->AddAt(new TH1F("hNcls", "Nr. of clusters per track", 181, -0.5, 180.5), kNclustersHist);
262   fContainer->AddAt(new TH1F("hNtls", "Nr. tracklets per track", 7, -0.5, 6.5), kNtrackletsHist);
263   fContainer->AddAt(new TH1F("hNclTls","Mean Number of clusters per tracklet", 31, -0.5, 30.5), kNclusterTrackletHist);
264   fContainer->AddAt(new TH1F("hChi2", "Chi2", 200, 0, 20), kChi2);
265   fContainer->AddAt(new TH1F("hChi2n", "Norm. Chi2 (tracklets)", 50, 0, 5), kChi2Normalized);
266   fContainer->AddAt(new TH1F("hSM", "Track Counts in Supermodule", 18, -0.5, 17.5), kNTracksSectorHist);
267   // Detector signal on Detector-by-Detector basis
268   fContainer->AddAt(new TProfile("hPHdetector", "Average PH", 31, -0.5, 30.5), kPulseHeight);
269   fContainer->AddAt(new TH1F("hQclDetector", "Cluster charge", 200, 0, 1200), kClusterCharge);
270   fContainer->AddAt(new TH1F("hQTdetector", "Total Charge Deposit", 6000, 0, 6000), kChargeDeposit);
271   fContainer->AddAt(new TH1F("hEventsTrigger", "Trigger Class", 100, 0, 100), kNEventsTrigger);
272
273   return fContainer;
274 }
275
276 /*
277 * Plotting Functions
278 */
279
280 //_______________________________________________________
281 TH1 *AliTRDcheckDetector::PlotMeanNClusters(const AliTRDtrackV1 *track){
282   //
283   // Plot the mean number of clusters per tracklet
284   //
285   if(track) fTrack = track;
286   if(!fTrack){
287     AliWarning("No Track defined.");
288     return 0x0;
289   }
290   TH1 *h = 0x0;
291   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclusterTrackletHist)))){
292     AliWarning("No Histogram defined.");
293     return 0x0;
294   }
295   AliTRDseedV1 *tracklet = 0x0;
296   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
297     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
298     h->Fill(tracklet->GetN());
299   }
300   return h;
301 }
302
303 //_______________________________________________________
304 TH1 *AliTRDcheckDetector::PlotNClusters(const AliTRDtrackV1 *track){
305   //
306   // Plot the number of clusters in one track
307   //
308   if(track) fTrack = track;
309   if(!fTrack){
310     AliWarning("No Track defined.");
311     return 0x0;
312   }
313   TH1 *h = 0x0;
314   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersHist)))){
315     AliWarning("No Histogram defined.");
316     return 0x0;
317   }
318   
319   Int_t nclusters = 0;
320   AliTRDseedV1 *tracklet = 0x0;
321   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
322     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
323     nclusters += tracklet->GetN();
324     if(fDebugLevel > 2){
325       Int_t crossing = tracklet->GetNChange();
326       AliTRDcluster *c = 0x0;
327       for(Int_t itime = 0; itime < kNTimeBins; itime++){
328         if(!(c = tracklet->GetClusters(itime))) continue;
329         break;
330       }
331       Int_t detector = c->GetDetector();
332       Float_t sector = static_cast<Int_t>(detector/AliTRDgeometry::kNdets);
333       Float_t theta = TMath::ATan(tracklet->GetZfit(1));
334       Float_t phi = TMath::ATan(tracklet->GetYfit(1));
335       Float_t momentum = 0.;
336       Int_t pdg = 0;
337       Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
338       UShort_t TPCncls = fESD ? fESD->GetTPCncls() : 0;
339       if(fMC){
340         if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
341         pdg = fMC->GetPDG();
342       }
343       (*fDebugStream) << "NClusters"
344         << "Detector="  << detector
345         << "Sector="    << sector
346         << "crossing="  << crossing
347         << "momentum="  << momentum
348         << "pdg="                               << pdg
349         << "theta="                     << theta
350         << "phi="                               << phi
351         << "kinkIndex=" << kinkIndex
352         << "TPCncls="           << TPCncls
353         << "nclusters=" << nclusters
354         << "\n";
355     }
356   }
357   h->Fill(nclusters);
358   return h;
359 }
360
361 //_______________________________________________________
362 TH1 *AliTRDcheckDetector::PlotChi2(const AliTRDtrackV1 *track){
363   //
364   // Plot the chi2 of the track
365   //
366   if(track) fTrack = track;
367   if(!fTrack){
368     AliWarning("No Track defined.");
369     return 0x0;
370   }
371   TH1 *h = 0x0;
372   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChi2)))){
373     AliWarning("No Histogram defined.");
374     return 0x0;
375   }
376   h->Fill(fTrack->GetChi2());
377   return h;
378 }
379
380 //_______________________________________________________
381 TH1 *AliTRDcheckDetector::PlotNormalizedChi2(const AliTRDtrackV1 *track){
382   //
383   // Plot the chi2 of the track
384   //
385   if(track) fTrack = track;
386   if(!fTrack){
387     AliWarning("No Track defined.");
388     return 0x0;
389   }
390   TH1 *h = 0x0;
391   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChi2Normalized)))){
392     AliWarning("No Histogram defined.");
393     return 0x0;
394   }
395   Int_t nTracklets = 0;
396   AliTRDseedV1 *tracklet = 0x0;
397   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
398     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
399     nTracklets++;
400   }
401   h->Fill(fTrack->GetChi2()/nTracklets);
402   return h;
403 }
404
405
406 //_______________________________________________________
407 TH1 *AliTRDcheckDetector::PlotNTracklets(const AliTRDtrackV1 *track){
408   //
409   // Plot the number of tracklets
410   //
411   if(track) fTrack = track;
412   if(!fTrack){
413     AliWarning("No Track defined.");
414     return 0x0;
415   }
416   TH1 *h = 0x0;
417   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsHist)))){
418     AliWarning("No Histogram defined.");
419     return 0x0;
420   }
421   Int_t nTracklets = 0;
422   AliTRDseedV1 *tracklet = 0x0;
423   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
424     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
425     nTracklets++;
426   }
427   h->Fill(nTracklets);
428   return h;
429 }
430
431 //_______________________________________________________
432 TH1 *AliTRDcheckDetector::PlotPulseHeight(const AliTRDtrackV1 *track){
433   //
434   // Plot the average pulse height
435   //
436   if(track) fTrack = track;
437   if(!fTrack){
438     AliWarning("No Track defined.");
439     return 0x0;
440   }
441   TProfile *h = 0x0;
442   if(!(h = dynamic_cast<TProfile *>(fContainer->At(kPulseHeight)))){
443     AliWarning("No Histogram defined.");
444     return 0x0;
445   }
446   AliTRDseedV1 *tracklet = 0x0;
447   AliTRDcluster *c = 0x0;
448   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
449     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK())continue;
450     for(Int_t itime = 0; itime < kNTimeBins; itime++){
451       if(!(c = tracklet->GetClusters(itime))) continue;
452       Int_t localtime        = c->GetLocalTimeBin();
453       Double_t absolute_charge = TMath::Abs(c->GetQ());
454       h->Fill(localtime, absolute_charge);
455       if(fDebugLevel > 3){
456         Int_t crossing = tracklet->GetNChange();
457         Int_t detector = c->GetDetector();
458         Float_t sector = static_cast<Int_t>(detector/AliTRDgeometry::kNdets);
459         Float_t theta = TMath::ATan(tracklet->GetZfit(1));
460         Float_t phi = TMath::ATan(tracklet->GetYfit(1));
461         Float_t momentum = 0.;
462         Int_t pdg = 0;
463         Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
464         UShort_t TPCncls = fESD ? fESD->GetTPCncls() : 0;
465         if(fMC){
466           if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
467           pdg = fMC->GetPDG();
468         }
469         (*fDebugStream) << "PulseHeight"
470           << "Detector="        << detector
471           << "Sector="          << sector
472           << "crossing="        << crossing
473           << "Timebin="         << localtime
474           << "Charge="          << absolute_charge
475           << "momentum="        << momentum
476           << "pdg="                             << pdg
477           << "theta="                   << theta
478           << "phi="                             << phi
479           << "kinkIndex="       << kinkIndex
480           << "TPCncls="         << TPCncls
481           << "\n";
482       }
483     }
484   }
485   return h;
486 }
487
488 //_______________________________________________________
489 TH1 *AliTRDcheckDetector::PlotClusterCharge(const AliTRDtrackV1 *track){
490   //
491   // Plot the cluster charge
492   //
493   if(track) fTrack = track;
494   if(!fTrack){
495     AliWarning("No Track defined.");
496     return 0x0;
497   }
498   TH1 *h = 0x0;
499   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kClusterCharge)))){
500     AliWarning("No Histogram defined.");
501     return 0x0;
502   }
503   AliTRDseedV1 *tracklet = 0x0;
504   AliTRDcluster *c = 0x0;
505   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
506     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK())continue;
507     for(Int_t itime = 0; itime < kNTimeBins; itime++){
508       if(!(c = tracklet->GetClusters(itime))) continue;
509       h->Fill(c->GetQ());
510     }
511   }
512   return h;
513 }
514
515 //_______________________________________________________
516 TH1 *AliTRDcheckDetector::PlotChargeDeposit(const AliTRDtrackV1 *track){
517   //
518   // Plot the charge deposit per chamber
519   //
520   if(track) fTrack = track;
521   if(!fTrack){
522     AliWarning("No Track defined.");
523     return 0x0;
524   }
525   TH1 *h = 0x0;
526   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeDeposit)))){
527     AliWarning("No Histogram defined.");
528     return 0x0;
529   }
530   AliTRDseedV1 *tracklet = 0x0;
531   AliTRDcluster *c = 0x0, *c1 = 0x0;    // c1 for the Debug Stream
532   Double_t Qtot = 0;
533   for(Int_t itl = 0x0; itl < AliTRDgeometry::kNlayer; itl++){
534     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
535     Qtot = 0;
536     c1 = 0x0;
537     for(Int_t itime = 0; itime < kNTimeBins; itime++){
538       if(!(c = tracklet->GetClusters(itime))) continue;
539       if(!c1) c1 = c;
540       Qtot += TMath::Abs(c->GetQ());
541     }
542     h->Fill(Qtot);
543     if(fDebugLevel > 3){
544       Int_t crossing = tracklet->GetNChange();
545       Int_t detector = c1->GetDetector();
546       Float_t sector = static_cast<Int_t>(detector/AliTRDgeometry::kNdets);
547       Float_t theta = TMath::ATan(tracklet->GetZfit(1));
548       Float_t phi = TMath::ATan(tracklet->GetYfit(1));
549       Float_t momentum = 0.;
550       Int_t pdg = 0;
551       Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
552       UShort_t TPCncls = fESD ? fESD->GetTPCncls() : 0;
553       if(fMC){
554               if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
555         pdg = fMC->GetPDG();
556       }
557       (*fDebugStream) << "ChargeDeposit"
558         << "Detector="  << detector
559         << "Sector="    << sector
560         << "crossing="  << crossing
561         << "momentum="  << momentum
562         << "pdg="                               << pdg
563         << "theta="                     << theta
564         << "phi="                               << phi
565         << "kinkIndex=" << kinkIndex
566         << "TPCncls="           << TPCncls
567         << "QT="        << Qtot
568         << "\n";
569     }
570   }
571   return h;
572 }
573
574 //_______________________________________________________
575 TH1 *AliTRDcheckDetector::PlotTracksSector(const AliTRDtrackV1 *track){
576   //
577   // Plot the number of tracks per Sector
578   //
579   if(track) fTrack = track;
580   if(!fTrack){
581     AliWarning("No Track defined.");
582     return 0x0;
583   }
584   TH1 *h = 0x0;
585   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNTracksSectorHist)))){
586     AliWarning("No Histogram defined.");
587     return 0x0;
588   }
589   AliTRDseedV1 *tracklet = 0x0;
590   AliTRDcluster *c = 0x0;
591   Int_t sector = -1;
592   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
593     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
594     for(Int_t itime = 0; itime < kNTimeBins; itime++){
595       if(!(c = tracklet->GetClusters(itime))) continue;
596       sector = static_cast<Int_t>(c->GetDetector()/AliTRDgeometry::kNdets);
597     }
598     break;
599   }
600   h->Fill(sector);
601   return h;
602 }
603