]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaRec/AliTRDcheckDET.cxx
restore include headers
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDcheckDET.cxx
1 ////////////////////////////////////////////////////////////////////////////
2 //                                                                        //
3 //                                                                        //
4 //  Basic checks for tracking and detector performance                    //
5 //  
6 //     For the moment (15.10.2009) the following checks are implemented    //
7 //       - Number of clusters/track
8 //       - Number of clusters/tracklet
9 //       - Number of tracklets/track from different sources (Barrel, StandAlone)
10 //       - Number of findable tracklets
11 //       - Number of tracks per event and TRD sector
12 //       - <PH>
13 //       - Chi2 distribution for tracks
14 //       - Charge distribution per cluster and tracklet
15 //       - Number of events and tracks per trigger source 
16 //       - Trigger purity
17 //       - Track and Tracklet propagation status
18 //
19 //  Authors:                                                              //
20 //    Anton Andronic <A.Andronic@gsi.de>                                  //
21 //    Alexandru Bercuci <A.Bercuci@gsi.de>                                //
22 //    Markus Fasel <M.Fasel@gsi.de>                                       //
23 //                                                                        //
24 ////////////////////////////////////////////////////////////////////////////
25
26 #include <TAxis.h>
27 #include <TCanvas.h>
28 #include <TFile.h>
29 #include <TH1F.h>
30 #include <TH1I.h>
31 #include <TF1.h>
32 #include <TGaxis.h>
33 #include <TGraph.h>
34 #include <TLegend.h>
35 #include <TMath.h>
36 #include <TMap.h>
37 #include <TObjArray.h>
38 #include <TObject.h>
39 #include <TObjString.h>
40
41 #include <TPad.h>
42 #include <TProfile.h>
43 #include <TProfile2D.h>
44 #include <TROOT.h>
45
46 #include "AliLog.h"
47 #include "AliTRDcluster.h"
48 #include "AliESDHeader.h"
49 #include "AliESDRun.h"
50 #include "AliESDtrack.h"
51 #include "AliTRDgeometry.h"
52 #include "AliTRDpadPlane.h"
53 #include "AliTRDSimParam.h"
54 #include "AliTRDseedV1.h"
55 #include "AliTRDtrackV1.h"
56 #include "AliTRDtrackerV1.h"
57 #include "AliTRDReconstructor.h"
58 #include "AliTrackReference.h"
59 #include "AliTrackPointArray.h"
60 #include "AliTracker.h"
61 #include "TTreeStream.h"
62
63 #include "info/AliTRDtrackInfo.h"
64 #include "info/AliTRDeventInfo.h"
65 #include "AliTRDcheckDET.h"
66
67 #include <cstdio>
68 #include <iostream>
69
70 ClassImp(AliTRDcheckDET)
71
72 //_______________________________________________________
73 AliTRDcheckDET::AliTRDcheckDET():
74   AliTRDrecoTask("checkDET", "Basic TRD data checker")
75   ,fEventInfo(0x0)
76   ,fTriggerNames(0x0)
77   ,fReconstructor(0x0)
78   ,fGeo(0x0)
79 {
80   //
81   // Default constructor
82   //
83   DefineInput(1,AliTRDeventInfo::Class());
84   fReconstructor = new AliTRDReconstructor;
85   fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
86   fGeo = new AliTRDgeometry;
87   InitFunctorList();
88 }
89
90 //_______________________________________________________
91 AliTRDcheckDET::~AliTRDcheckDET(){
92   //
93   // Destructor
94   // 
95   if(fTriggerNames) delete fTriggerNames;
96   delete fReconstructor;
97   delete fGeo;
98 }
99
100 //_______________________________________________________
101 void AliTRDcheckDET::ConnectInputData(Option_t *opt){
102   //
103   // Connect the Input data with the task
104   //
105   AliTRDrecoTask::ConnectInputData(opt);
106   fEventInfo = dynamic_cast<AliTRDeventInfo *>(GetInputData(1));
107 }
108
109 //_______________________________________________________
110 void AliTRDcheckDET::CreateOutputObjects(){
111   //
112   // Create Output Objects
113   //
114   OpenFile(0,"RECREATE");
115   fContainer = Histos();
116   if(!fTriggerNames) fTriggerNames = new TMap();
117 }
118
119 //_______________________________________________________
120 void AliTRDcheckDET::Exec(Option_t *opt){
121   //
122   // Execution function
123   // Filling TRD quality histos
124   //
125   if(!HasMCdata() && fEventInfo->GetEventHeader()->GetEventType() != 7) return; // For real data we select only physical events
126   AliTRDrecoTask::Exec(opt);  
127   Int_t nTracks = 0;            // Count the number of tracks per event
128   Int_t triggermask = fEventInfo->GetEventHeader()->GetTriggerMask();
129   TString triggername =  fEventInfo->GetRunInfo()->GetFiredTriggerClasses(triggermask);
130   if(fDebugLevel > 6)printf("Trigger cluster: %d, Trigger class: %s\n", triggermask, triggername.Data());
131   dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTrigger))->Fill(triggermask);
132   for(Int_t iti = 0; iti < fTracks->GetEntriesFast(); iti++){
133     if(!fTracks->UncheckedAt(iti)) continue;
134     AliTRDtrackInfo *fTrackInfo = dynamic_cast<AliTRDtrackInfo *>(fTracks->UncheckedAt(iti));
135     if(!fTrackInfo->GetTrack()) continue;
136     nTracks++;
137   }
138   if(nTracks){
139     dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTriggerTracks))->Fill(triggermask);
140     dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtracksEvent))->Fill(nTracks);
141   }
142   if(triggermask <= 20 && !fTriggerNames->FindObject(Form("%d", triggermask))){
143     fTriggerNames->Add(new TObjString(Form("%d", triggermask)), new TObjString(triggername));
144     // also set the label for both histograms
145     TH1 *histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTriggerTracks));
146     histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername);
147     histo = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTrigger));
148     histo->GetXaxis()->SetBinLabel(histo->FindBin(triggermask), triggername);
149   }
150   PostData(0, fContainer);
151 }
152
153 //_______________________________________________________
154 void AliTRDcheckDET::Terminate(Option_t *){
155   //
156   // Terminate function
157   //
158 }
159
160 //_______________________________________________________
161 Bool_t AliTRDcheckDET::PostProcess(){
162   //
163   // Do Postprocessing (for the moment set the number of Reference histograms)
164   //
165   
166   TH1 * h = 0x0;
167   
168   // Calculate of the trigger clusters purity
169   h = dynamic_cast<TH1F *>(fContainer->FindObject("hEventsTrigger"));
170   TH1F *h1 = dynamic_cast<TH1F *>(fContainer->FindObject("hEventsTriggerTracks"));
171   h1->Divide(h);
172   Float_t purities[20], val = 0;
173   TString triggernames[20];
174   Int_t nTriggerClasses = 0;
175   for(Int_t ibin = 1; ibin <= h->GetNbinsX(); ibin++){
176     if((val = h1->GetBinContent(ibin))){
177       purities[nTriggerClasses] = val;
178       triggernames[nTriggerClasses] = h1->GetXaxis()->GetBinLabel(ibin);
179       nTriggerClasses++;
180     }
181   }
182   h = dynamic_cast<TH1F *>(fContainer->UncheckedAt(kTriggerPurity));
183   TAxis *ax = h->GetXaxis();
184   for(Int_t itrg = 0; itrg < nTriggerClasses; itrg++){
185     h->Fill(itrg, purities[itrg]);
186     ax->SetBinLabel(itrg+1, triggernames[itrg].Data());
187   }
188   ax->SetRangeUser(-0.5, nTriggerClasses+.5);
189   h->GetYaxis()->SetRangeUser(0,1);
190
191   fNRefFigures = 18;
192
193   return kTRUE;
194 }
195
196 //_______________________________________________________
197 Bool_t AliTRDcheckDET::GetRefFigure(Int_t ifig){
198   //
199   // Setting Reference Figures
200   //
201   gPad->SetLogy(0);
202   gPad->SetLogx(0);
203   TH1 *h = 0x0;
204   switch(ifig){
205   case kNclustersTrack:
206     (h=(TH1F*)fContainer->FindObject("hNcls"))->Draw("pl");
207     PutTrendValue("NClustersTrack", h->GetMean(), h->GetRMS());
208     return kTRUE;
209   case kNclustersTracklet:
210     (h =(TH1F*)fContainer->FindObject("hNclTls"))->Draw("pc");
211     PutTrendValue("NClustersTracklet", h->GetMean(), h->GetRMS());
212     return kTRUE;
213   case kNtrackletsTrack:
214     h=MakePlotNTracklets();
215     PutTrendValue("NTrackletsTrack", h->GetMean(), h->GetRMS());
216     return kTRUE;
217   case kNtrackletsCross:
218     h = (TH1F*)fContainer->FindObject("hNtlsCross");
219     if(!MakeBarPlot(h, kRed)) break;
220     PutTrendValue("NTrackletsCross", h->GetMean(), h->GetRMS());
221     return kTRUE;
222   case kNtrackletsFindable:
223     h = (TH1F*)fContainer->FindObject("hNtlsFindable");
224     if(!MakeBarPlot(h, kGreen)) break;
225     PutTrendValue("NTrackletsFindable", h->GetMean(), h->GetRMS());
226     return kTRUE;
227   case kNtracksEvent:
228     (h = (TH1F*)fContainer->FindObject("hNtrks"))->Draw("pl");
229     PutTrendValue("NTracksEvent", h->GetMean(), h->GetRMS());
230     return kTRUE;
231   case kNtracksSector:
232     h = (TH1F*)fContainer->FindObject("hNtrksSector");
233     if(!MakeBarPlot(h, kGreen)) break;
234     PutTrendValue("NTracksSector", h->GetMean(2), h->GetRMS(2));
235     return kTRUE;
236   case kTrackStatus:
237     ((TH1I *)fContainer->FindObject("hTrackStatus"))->Draw("c");
238     gPad->SetLogy(1);
239     return kTRUE;
240   case kTrackletStatus:
241     ((TH2S *)fContainer->FindObject("hTrackletStatus"))->Draw("colz");
242     gPad->SetLogy(0);
243     return kTRUE;
244   case kChi2:
245     MakePlotChi2();
246     return kTRUE;
247   case kPH:
248     MakePlotPulseHeight();
249     gPad->SetLogy(0);
250     return kTRUE;
251   case kChargeCluster:
252     (h = (TH1F*)fContainer->FindObject("hQcl"))->Draw("c");
253     gPad->SetLogy(1);
254     PutTrendValue("ChargeCluster", h->GetMaximumBin(), h->GetRMS());
255     return kTRUE;
256   case kChargeTracklet:
257     (h=(TH1F*)fContainer->FindObject("hQtrklt"))->Draw("c");
258     PutTrendValue("ChargeTracklet", h->GetMaximumBin(), h->GetRMS());
259     return kTRUE;
260   case kNeventsTrigger:
261     ((TH1F*)fContainer->FindObject("hEventsTrigger"))->Draw("");
262     return kTRUE;
263   case kNeventsTriggerTracks:
264     ((TH1F*)fContainer->FindObject("hEventsTriggerTracks"))->Draw("");
265     return kTRUE;
266   case kTriggerPurity: 
267     if(!MakeBarPlot((TH1F*)fContainer->FindObject("hTriggerPurity"), kGreen)) break;
268     break;
269   default:
270     break;
271   }
272   AliInfo(Form("Reference plot [%d] missing result", ifig));
273   return kFALSE;
274 }
275
276 //_______________________________________________________
277 TObjArray *AliTRDcheckDET::Histos(){
278   //
279   // Create QA histograms
280   //
281   if(fContainer) return fContainer;
282   
283   fContainer = new TObjArray(20);
284   //fContainer->SetOwner(kTRUE);
285
286   // Register Histograms
287   TH1 * h = NULL;
288   TAxis *axis = NULL;
289   if(!(h = (TH1F *)gROOT->FindObject("hNcls"))){
290     h = new TH1F("hNcls", "N_{clusters} / track", 181, -0.5, 180.5);
291     h->GetXaxis()->SetTitle("N_{clusters}");
292     h->GetYaxis()->SetTitle("Entries");
293   } else h->Reset();
294   fContainer->AddAt(h, kNclustersTrack);
295
296   if(!(h = (TH1F *)gROOT->FindObject("hNclTls"))){
297     h = new TH1F("hNclTls","N_{clusters} / tracklet", 51, -0.5, 50.5);
298     h->GetXaxis()->SetTitle("N_{clusters}");
299     h->GetYaxis()->SetTitle("Entries");
300   } else h->Reset();
301   fContainer->AddAt(h, kNclustersTracklet);
302
303   if(!(h = (TH1F *)gROOT->FindObject("hNtls"))){
304     h = new TH1F("hNtls", "N_{tracklets} / track", AliTRDgeometry::kNlayer, 0.5, 6.5);
305     h->GetXaxis()->SetTitle("N^{tracklet}");
306     h->GetYaxis()->SetTitle("freq. [%]");
307   } else h->Reset();
308   fContainer->AddAt(h, kNtrackletsTrack);
309
310   if(!(h = (TH1F *)gROOT->FindObject("htlsSTA"))){
311     h = new TH1F("hNtlsSTA", "N_{tracklets} / track (Stand Alone)", AliTRDgeometry::kNlayer, 0.5, 6.5);
312     h->GetXaxis()->SetTitle("N^{tracklet}");
313     h->GetYaxis()->SetTitle("freq. [%]");
314   }
315   fContainer->AddAt(h, kNtrackletsSTA);
316
317   if(!(h = (TH1F *)gROOT->FindObject("htlsBAR"))){
318     h = new TH1F("hNtlsBAR", "N_{tracklets} / track (Barrel)", AliTRDgeometry::kNlayer, 0.5, 6.5);
319     h->GetXaxis()->SetTitle("N^{tracklet}");
320     h->GetYaxis()->SetTitle("freq. [%]");
321   }
322   fContainer->AddAt(h, kNtrackletsBAR);
323
324   // 
325   if(!(h = (TH1F *)gROOT->FindObject("hNtlsCross"))){
326     h = new TH1F("hNtlsCross", "N_{tracklets}^{cross} / track", 7, -0.5, 6.5);
327     h->GetXaxis()->SetTitle("n_{row cross}");
328     h->GetYaxis()->SetTitle("freq. [%]");
329   } else h->Reset();
330   fContainer->AddAt(h, kNtrackletsCross);
331
332   if(!(h = (TH1F *)gROOT->FindObject("hNtlsFindable"))){
333     h = new TH1F("hNtlsFindable", "Found/Findable Tracklets" , 101, -0.005, 1.005);
334     h->GetXaxis()->SetTitle("r [a.u]");
335     h->GetYaxis()->SetTitle("Entries");
336   } else h->Reset();
337   fContainer->AddAt(h, kNtrackletsFindable);
338
339   if(!(h = (TH1F *)gROOT->FindObject("hNtrks"))){
340     h = new TH1F("hNtrks", "N_{tracks} / event", 100, 0, 100);
341     h->GetXaxis()->SetTitle("N_{tracks}");
342     h->GetYaxis()->SetTitle("Entries");
343   } else h->Reset();
344   fContainer->AddAt(h, kNtracksEvent);
345
346   if(!(h = (TH1F *)gROOT->FindObject("hNtrksSector"))){
347     h = new TH1F("hNtrksSector", "N_{tracks} / sector", AliTRDgeometry::kNsector, -0.5, 17.5);
348     h->GetXaxis()->SetTitle("sector");
349     h->GetYaxis()->SetTitle("freq. [%]");
350   } else h->Reset();
351   fContainer->AddAt(h, kNtracksSector);
352
353   if(!(h = (TH1I *)gROOT->FindObject("hTrackStatus"))){
354     h = new TH1I("hTrackStatus", "Track Status", 7,0,7);
355     axis = h->GetXaxis();
356     axis->SetBinLabel(axis->GetFirst() + 0, "OK");
357     axis->SetBinLabel(axis->GetFirst() + 1, "PROL");
358     axis->SetBinLabel(axis->GetFirst() + 2, "PROP");
359     axis->SetBinLabel(axis->GetFirst() + 3, "ADJ");
360     axis->SetBinLabel(axis->GetFirst() + 4, "SNP");
361     axis->SetBinLabel(axis->GetFirst() + 5, "TLIN");
362     axis->SetBinLabel(axis->GetFirst() + 6, "UP");
363   }
364   fContainer->AddAt(h, kTrackStatus);
365
366   if(!(h = (TH2S *)gROOT->FindObject("hTrackletStatus"))){
367     h = new TH2S("hTrackletStatus", "Tracklet status", 6,0,6,8,0,8);
368     axis = h->GetYaxis();
369     axis->SetBinLabel(1, "OK");
370     axis->SetBinLabel(2, "Geom");
371     axis->SetBinLabel(3, "Boun");
372     axis->SetBinLabel(4, "NoCl");
373     axis->SetBinLabel(5, "NoAttach");
374     axis->SetBinLabel(6, "NoClTr");
375     axis->SetBinLabel(7, "NoFit");
376     axis->SetBinLabel(8, "Chi2");
377     h->GetXaxis()->SetTitle("layer");
378   }
379   fContainer->AddAt(h, kTrackletStatus);
380
381   // <PH> histos
382   TObjArray *arr = new TObjArray(2);
383   arr->SetOwner(kTRUE);  arr->SetName("<PH>");
384   fContainer->AddAt(arr, kPH);
385   if(!(h = (TH1F *)gROOT->FindObject("hPHt"))){
386     h = new TProfile("hPHt", "<PH>", 31, -0.5, 30.5);
387     h->GetXaxis()->SetTitle("Time / 100ns");
388     h->GetYaxis()->SetTitle("<PH> [a.u]");
389   } else h->Reset();
390   arr->AddAt(h, 0);
391   if(!(h = (TH1F *)gROOT->FindObject("hPHx")))
392     h = new TProfile("hPHx", "<PH>", 31, -0.08, 4.88);
393   else h->Reset();
394   arr->AddAt(h, 1);
395
396   // Chi2 histos
397   if(!(h = (TH2S*)gROOT->FindObject("hChi2"))){
398     h = new TH2S("hChi2", "#chi^{2} per track", AliTRDgeometry::kNlayer, .5, AliTRDgeometry::kNlayer+.5, 100, 0, 50);
399     h->SetXTitle("ndf");
400     h->SetYTitle("#chi^{2}/ndf");
401     h->SetZTitle("entries");
402   } else h->Reset();
403   fContainer->AddAt(h, kChi2);
404
405   if(!(h = (TH1F *)gROOT->FindObject("hQcl"))){
406     h = new TH1F("hQcl", "Q_{cluster}", 200, 0, 1200);
407     h->GetXaxis()->SetTitle("Q_{cluster} [a.u.]");
408     h->GetYaxis()->SetTitle("Entries");
409   }else h->Reset();
410   fContainer->AddAt(h, kChargeCluster);
411
412   if(!(h = (TH1F *)gROOT->FindObject("hQtrklt"))){
413     h = new TH1F("hQtrklt", "Q_{tracklet}", 6000, 0, 6000);
414     h->GetXaxis()->SetTitle("Q_{tracklet} [a.u.]");
415     h->GetYaxis()->SetTitle("Entries");
416   }else h->Reset();
417   fContainer->AddAt(h, kChargeTracklet);
418
419
420   if(!(h = (TH1F *)gROOT->FindObject("hEventsTrigger")))
421     h = new TH1F("hEventsTrigger", "Trigger Class", 100, 0, 100);
422   else h->Reset();
423   fContainer->AddAt(h, kNeventsTrigger);
424
425   if(!(h = (TH1F *)gROOT->FindObject("hEventsTriggerTracks")))
426     h = new TH1F("hEventsTriggerTracks", "Trigger Class (Tracks)", 100, 0, 100);
427   else h->Reset();
428   fContainer->AddAt(h, kNeventsTriggerTracks);
429
430   if(!(h = (TH1F *)gROOT->FindObject("hTriggerPurity"))){
431     h = new TH1F("hTriggerPurity", "Trigger Purity", 10, -0.5, 9.5);
432     h->GetXaxis()->SetTitle("Trigger Cluster");
433     h->GetYaxis()->SetTitle("freq.");
434   } else h->Reset();
435   fContainer->AddAt(h, kTriggerPurity);
436
437   return fContainer;
438 }
439
440 /*
441 * Plotting Functions
442 */
443
444 //_______________________________________________________
445 TH1 *AliTRDcheckDET::PlotTrackStatus(const AliTRDtrackV1 *track){
446   //
447   // Plot the track status
448   //
449   if(track) fTrack = track;
450   if(!fTrack){
451     AliWarning("No Track defined.");
452     return 0x0;
453   }
454   TH1 *h = 0x0;
455   if(!(h = dynamic_cast<TH1I *>(fContainer->At(kTrackStatus)))){
456     AliWarning("No Histogram defined.");
457     return 0x0;
458   }
459   h->Fill(fTrack->GetStatusTRD());
460   return h;
461 }
462
463 //_______________________________________________________
464 TH1 *AliTRDcheckDET::PlotTrackletStatus(const AliTRDtrackV1 *track){
465   //
466   // Plot the track status
467   //
468   if(track) fTrack = track;
469   if(!fTrack){
470     AliWarning("No Track defined.");
471     return 0x0;
472   }
473   TH1 *h = 0x0;
474   if(!(h = dynamic_cast<TH2S *>(fContainer->At(kTrackletStatus)))){
475     AliWarning("No Histogram defined.");
476     return 0x0;
477   }
478   UChar_t status = 0;
479   for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
480     status = fTrack->GetStatusTRD(il);
481     h->Fill(il, status);
482   }
483   return h;
484 }
485
486 //_______________________________________________________
487 TH1 *AliTRDcheckDET::PlotNClustersTracklet(const AliTRDtrackV1 *track){
488   //
489   // Plot the mean number of clusters per tracklet
490   //
491   if(track) fTrack = track;
492   if(!fTrack){
493     AliWarning("No Track defined.");
494     return 0x0;
495   }
496   TH1 *h = 0x0;
497   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersTracklet)))){
498     AliWarning("No Histogram defined.");
499     return 0x0;
500   }
501   AliTRDseedV1 *tracklet = 0x0;
502   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
503     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
504     h->Fill(tracklet->GetN2());
505   }
506   return h;
507 }
508
509 //_______________________________________________________
510 TH1 *AliTRDcheckDET::PlotNClustersTrack(const AliTRDtrackV1 *track){
511   //
512   // Plot the number of clusters in one track
513   //
514   if(track) fTrack = track;
515   if(!fTrack){
516     AliWarning("No Track defined.");
517     return 0x0;
518   }
519   TH1 *h = 0x0;
520   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersTrack)))){
521     AliWarning("No Histogram defined.");
522     return 0x0;
523   }
524   
525   Int_t nclusters = 0;
526   AliTRDseedV1 *tracklet = 0x0;
527   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
528     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
529     nclusters += tracklet->GetN();
530     if(fDebugLevel > 2){
531       Int_t crossing = Int_t(tracklet->IsRowCross());
532       Int_t detector = tracklet->GetDetector();
533       Float_t theta = TMath::ATan(tracklet->GetZref(1));
534       Float_t phi = TMath::ATan(tracklet->GetYref(1));
535       Float_t momentum = 0.;
536       Int_t pdg = 0;
537       Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
538       UShort_t nclsTPC = fESD ? fESD->GetTPCncls() : 0;
539       if(fMC){
540         if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
541         pdg = fMC->GetPDG();
542       }
543       (*fDebugStream) << "NClustersTrack"
544         << "Detector="  << detector
545         << "crossing="  << crossing
546         << "momentum="  << momentum
547         << "pdg="                               << pdg
548         << "theta="                     << theta
549         << "phi="                               << phi
550         << "kinkIndex=" << kinkIndex
551         << "TPCncls="           << nclsTPC
552         << "nclusters=" << nclusters
553         << "\n";
554     }
555   }
556   h->Fill(nclusters);
557   return h;
558 }
559
560
561 //_______________________________________________________
562 TH1 *AliTRDcheckDET::PlotNTrackletsTrack(const AliTRDtrackV1 *track){
563   //
564   // Plot the number of tracklets
565   //
566   if(track) fTrack = track;
567   if(!fTrack){
568     AliWarning("No Track defined.");
569     return 0x0;
570   }
571   TH1 *h = 0x0, *hMethod = 0x0;
572   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsTrack)))){
573     AliWarning("No Histogram defined.");
574     return 0x0;
575   }
576   Int_t status = fESD->GetStatus();
577 /*  printf("in/out/refit/pid: TRD[%d|%d|%d|%d]\n", status &AliESDtrack::kTRDin ? 1 : 0, status &AliESDtrack::kTRDout ? 1 : 0, status &AliESDtrack::kTRDrefit ? 1 : 0, status &AliESDtrack::kTRDpid ? 1 : 0);*/
578   if((status & AliESDtrack::kTRDin) != 0){
579     // Full BarrelTrack
580     if(!(hMethod = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsBAR))))
581       AliWarning("Method: Barrel.  Histogram not processed!");
582   } else {
583     // Stand alone Track
584     if(!(hMethod = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsSTA))))
585       AliWarning("Method: StandAlone.  Histogram not processed!");
586   }
587   Int_t nTracklets = fTrack->GetNumberOfTracklets();
588   h->Fill(nTracklets);
589   hMethod->Fill(nTracklets);
590   if(fDebugLevel > 3){
591     if(nTracklets == 1){
592       // If we have one Tracklet, check in which layer this happens
593       Int_t layer = -1;
594       AliTRDseedV1 *tracklet = 0x0;
595       for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
596         if((tracklet = fTrack->GetTracklet(il)) && tracklet->IsOK()){layer =  il; break;}
597       }
598       (*fDebugStream) << "NTrackletsTrack"
599         << "Layer=" << layer
600         << "\n";
601     }
602   }
603   return h;
604 }
605
606
607 //_______________________________________________________
608 TH1 *AliTRDcheckDET::PlotNTrackletsRowCross(const AliTRDtrackV1 *track){
609   //
610   // Plot the number of tracklets
611   //
612   if(track) fTrack = track;
613   if(!fTrack){
614     AliWarning("No Track defined.");
615     return 0x0;
616   }
617   TH1 *h = 0x0;
618   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsCross)))){
619     AliWarning("No Histogram defined.");
620     return 0x0;
621   }
622
623   Int_t ncross = 0;
624   AliTRDseedV1 *tracklet = 0x0;
625   for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
626     if(!(tracklet = fTrack->GetTracklet(il)) || !tracklet->IsOK()) continue;
627
628     if(tracklet->IsRowCross()) ncross++;
629   }
630   h->Fill(ncross);
631   return h;
632 }
633
634 //_______________________________________________________
635 TH1 *AliTRDcheckDET::PlotFindableTracklets(const AliTRDtrackV1 *track){
636   //
637   // Plots the ratio of number of tracklets vs.
638   // number of findable tracklets
639   //
640   // Findable tracklets are defined as track prolongation
641   // to layer i does not hit the dead area +- epsilon
642   //
643   // In order to check whether tracklet hist active area in Layer i, 
644   // the track is refitted and the fitted position + an uncertainty 
645   // range is compared to the chamber border (also with a different
646   // uncertainty)
647   //
648   // For the track fit two cases are distinguished:
649   // If the track is a stand alone track (defined by the status bit 
650   // encoding, then the track is fitted with the tilted Rieman model
651   // Otherwise the track is fitted with the Kalman fitter in two steps:
652   // Since the track parameters are give at the outer point, we first 
653   // fit in direction inwards. Afterwards we fit again in direction outwards
654   // to extrapolate the track to layers which are not reached by the track
655   // For the Kalman model, the radial track points have to be shifted by
656   // a distance epsilon in the direction that we want to fit
657   //
658   const Float_t epsilon = 0.01;   // dead area tolerance
659   const Float_t epsilonR = 1;    // shift in radial direction of the anode wire position (Kalman filter only)
660   const Float_t deltaY = 0.7;    // Tolerance in the track position in y-direction
661   const Float_t deltaZ = 7.0;    // Tolerance in the track position in z-direction (Padlength)
662   Double_t xAnode[AliTRDgeometry::kNlayer] = {300.2, 312.8, 325.4, 338.0, 350.6, 363.2}; // Take the default X0
663  
664   if(track) fTrack = track;
665   if(!fTrack){
666     AliWarning("No Track defined.");
667     return 0x0;
668   }
669   TH1 *h = 0x0;
670   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsFindable)))){
671     AliWarning("No Histogram defined.");
672     return 0x0;
673   }
674   Int_t nFound = 0, nFindable = 0;
675   Int_t stack = -1;
676   Double_t ymin = 0., ymax = 0., zmin = 0., zmax = 0.;
677   Double_t y = 0., z = 0.;
678   AliTRDseedV1 *tracklet = 0x0;
679   AliTRDpadPlane *pp;  
680   for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
681     if((tracklet = fTrack->GetTracklet(il)) && tracklet->IsOK()){
682       tracklet->SetReconstructor(fReconstructor);
683       nFound++;
684     }
685   }
686   // 2 Different cases:
687   // 1st stand alone: here we cannot propagate, but be can do a Tilted Rieman Fit
688   // 2nd barrel track: here we propagate the track to the layers
689   AliTrackPoint points[6];
690   Float_t xyz[3];
691   memset(xyz, 0, sizeof(Float_t) * 3);
692   if(((fESD->GetStatus() & AliESDtrack::kTRDout) > 0) && !((fESD->GetStatus() & AliESDtrack::kTRDin) > 0)){
693     // stand alone track
694     for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
695       xyz[0] = xAnode[il];
696       points[il].SetXYZ(xyz);
697     }
698     AliTRDtrackerV1::FitRiemanTilt(const_cast<AliTRDtrackV1 *>(fTrack), 0x0, kTRUE, 6, points);
699   } else {
700     // barrel track
701     //
702     // 2 Steps:
703     // -> Kalman inwards
704     // -> Kalman outwards
705     AliTRDtrackV1 copyTrack(*fTrack);  // Do Kalman on a (non-constant) copy of the track
706     AliTrackPoint pointsInward[6], pointsOutward[6];
707     for(Int_t il = AliTRDgeometry::kNlayer; il--;){
708       // In order to avoid complications in the Kalman filter if the track points have the same radial
709       // position like the tracklets, we have to shift the radial postion of the anode wire by epsilon
710       // in the direction we want to go
711       // The track points have to be in reverse order for the Kalman Filter inwards
712       xyz[0] = xAnode[AliTRDgeometry::kNlayer - il - 1] - epsilonR;
713       pointsInward[il].SetXYZ(xyz);
714       xyz[0] = xAnode[il] + epsilonR;
715       pointsOutward[il].SetXYZ(xyz);
716     }
717     /*for(Int_t ipt = 0; ipt < AliTRDgeometry::kNlayer; ipt++)
718       printf("%d. X = %f\n", ipt, points[ipt].GetX());*/
719     // Kalman inwards
720     AliTRDtrackerV1::FitKalman(&copyTrack, 0x0, kFALSE, 6, pointsInward);
721     memcpy(points, pointsInward, sizeof(AliTrackPoint) * 6); // Preliminary store the inward results in the Array points
722     // Kalman outwards
723     AliTRDtrackerV1::FitKalman(&copyTrack, 0x0, kTRUE, 6, pointsInward);
724     memcpy(points, pointsOutward, sizeof(AliTrackPoint) * AliTRDgeometry::kNlayer);
725   }
726   for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
727     y = points[il].GetY();
728     z = points[il].GetZ();
729     if((stack = fGeo->GetStack(z, il)) < 0) continue; // Not findable
730     pp = fGeo->GetPadPlane(il, stack);
731     ymin = pp->GetCol0() + epsilon;
732     ymax = pp->GetColEnd() - epsilon; 
733     zmin = pp->GetRowEnd() + epsilon; 
734     zmax = pp->GetRow0() - epsilon;
735     // ignore y-crossing (material)
736     if((z + deltaZ > zmin && z - deltaZ < zmax) && (y + deltaY > ymin && y - deltaY < ymax)) nFindable++;
737       if(fDebugLevel > 3){
738         Double_t posTracklet[2] = {tracklet ? tracklet->GetYfit(0) : 0, tracklet ? tracklet->GetZfit(0) : 0};
739         Int_t hasTracklet = tracklet ? 1 : 0;
740         (*fDebugStream)   << "FindableTracklets"
741           << "layer="     << il
742           << "ytracklet=" << posTracklet[0]
743           << "ytrack="    << y
744           << "ztracklet=" << posTracklet[1]
745           << "ztrack="    << z
746           << "tracklet="  << hasTracklet
747           << "\n";
748       }
749   }
750   
751   h->Fill(nFindable > 0 ? TMath::Min(nFound/static_cast<Double_t>(nFindable), 1.) : 1);
752   if(fDebugLevel > 2) AliInfo(Form("Findable[Found]: %d[%d|%f]", nFindable, nFound, nFound/static_cast<Float_t>(nFindable > 0 ? nFindable : 1)));
753   return h;
754 }
755
756
757 //_______________________________________________________
758 TH1 *AliTRDcheckDET::PlotChi2(const AliTRDtrackV1 *track){
759   //
760   // Plot the chi2 of the track
761   //
762   if(track) fTrack = track;
763   if(!fTrack){
764     AliWarning("No Track defined.");
765     return 0x0;
766   }
767   TH1 *h = 0x0;
768   if(!(h = dynamic_cast<TH2S*>(fContainer->At(kChi2)))) {
769     AliWarning("No Histogram defined.");
770     return 0x0;
771   }
772   Int_t n = fTrack->GetNumberOfTracklets();
773   if(!n) return 0x0;
774
775   h->Fill(n, fTrack->GetChi2()/n);
776   return h;
777 }
778
779
780 //_______________________________________________________
781 TH1 *AliTRDcheckDET::PlotPHt(const AliTRDtrackV1 *track){
782   //
783   // Plot the average pulse height
784   //
785   if(track) fTrack = track;
786   if(!fTrack){
787     AliWarning("No Track defined.");
788     return 0x0;
789   }
790   TProfile *h = 0x0;
791   if(!(h = dynamic_cast<TProfile *>(((TObjArray*)(fContainer->At(kPH)))->At(0)))){
792     AliWarning("No Histogram defined.");
793     return 0x0;
794   }
795   AliTRDseedV1 *tracklet = 0x0;
796   AliTRDcluster *c = 0x0;
797   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
798     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK())continue;
799     Int_t crossing = Int_t(tracklet->IsRowCross());
800     Int_t detector = tracklet->GetDetector();
801     tracklet->ResetClusterIter();
802     while((c = tracklet->NextCluster())){
803       if(!c->IsInChamber()) continue;
804       Int_t localtime        = c->GetLocalTimeBin();
805       Double_t absoluteCharge = TMath::Abs(c->GetQ());
806       h->Fill(localtime, absoluteCharge);
807       if(fDebugLevel > 3){
808         Double_t distance[2];
809         GetDistanceToTracklet(distance, tracklet, c);
810         Float_t theta = TMath::ATan(tracklet->GetZref(1));
811         Float_t phi = TMath::ATan(tracklet->GetYref(1));
812         Float_t momentum = 0.;
813         Int_t pdg = 0;
814         Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
815         UShort_t TPCncls = fESD ? fESD->GetTPCncls() : 0;
816         if(fMC){
817           if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
818           pdg = fMC->GetPDG();
819         }
820         (*fDebugStream) << "PHt"
821           << "Detector="        << detector
822           << "crossing="        << crossing
823           << "Timebin="         << localtime
824           << "Charge="          << absoluteCharge
825           << "momentum="        << momentum
826           << "pdg="                             << pdg
827           << "theta="                   << theta
828           << "phi="                             << phi
829           << "kinkIndex="       << kinkIndex
830           << "TPCncls="         << TPCncls
831           << "dy="        << distance[0]
832           << "dz="        << distance[1]
833           << "c.="        << c
834           << "\n";
835       }
836     }
837   }
838   return h;
839 }
840
841 //_______________________________________________________
842 TH1 *AliTRDcheckDET::PlotPHx(const AliTRDtrackV1 *track){
843   //
844   // Plots the average pulse height vs the distance from the anode wire
845   // (plus const anode wire offset)
846   //
847   if(track) fTrack = track;
848   if(!fTrack){
849     AliWarning("No Track defined.");
850     return 0x0;
851   }
852   TProfile *h = 0x0;
853   if(!(h = dynamic_cast<TProfile *>(((TObjArray*)(fContainer->At(kPH)))->At(1)))){
854     AliWarning("No Histogram defined.");
855     return 0x0;
856   }
857   Float_t offset = .5*AliTRDgeometry::CamHght();
858   AliTRDseedV1 *tracklet = 0x0;
859   AliTRDcluster *c = 0x0;
860   Double_t distance = 0;
861   Double_t x, y;
862   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
863     if(!(tracklet = fTrack->GetTracklet(itl)) || !(tracklet->IsOK())) continue;
864     tracklet->ResetClusterIter();
865     while((c = tracklet->NextCluster())){
866       if(!c->IsInChamber()) continue;
867       x = c->GetX()-AliTRDcluster::GetXcorr(c->GetLocalTimeBin());
868       y = c->GetY()-AliTRDcluster::GetYcorr(AliTRDgeometry::GetLayer(c->GetDetector()), c->GetCenter());
869
870       distance = tracklet->GetX0() - (c->GetX() + 0.3) + offset;
871       h->Fill(distance, TMath::Abs(c->GetQ()));
872     }
873   }  
874   return h;
875 }
876
877 //_______________________________________________________
878 TH1 *AliTRDcheckDET::PlotChargeCluster(const AliTRDtrackV1 *track){
879   //
880   // Plot the cluster charge
881   //
882   if(track) fTrack = track;
883   if(!fTrack){
884     AliWarning("No Track defined.");
885     return 0x0;
886   }
887   TH1 *h = 0x0;
888   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeCluster)))){
889     AliWarning("No Histogram defined.");
890     return 0x0;
891   }
892   AliTRDseedV1 *tracklet = 0x0;
893   AliTRDcluster *c = 0x0;
894   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
895     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK())continue;
896     for(Int_t itime = 0; itime < AliTRDtrackerV1::GetNTimeBins(); itime++){
897       if(!(c = tracklet->GetClusters(itime))) continue;
898       h->Fill(c->GetQ());
899     }
900   }
901   return h;
902 }
903
904 //_______________________________________________________
905 TH1 *AliTRDcheckDET::PlotChargeTracklet(const AliTRDtrackV1 *track){
906   //
907   // Plot the charge deposit per chamber
908   //
909   if(track) fTrack = track;
910   if(!fTrack){
911     AliWarning("No Track defined.");
912     return 0x0;
913   }
914   TH1 *h = 0x0;
915   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeTracklet)))){
916     AliWarning("No Histogram defined.");
917     return 0x0;
918   }
919   AliTRDseedV1 *tracklet = 0x0;
920   AliTRDcluster *c = 0x0;
921   Double_t qTot = 0;
922   Int_t nTracklets =fTrack->GetNumberOfTracklets();
923   for(Int_t itl = 0x0; itl < AliTRDgeometry::kNlayer; itl++){
924     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
925     qTot = 0.;
926     for(Int_t ic = AliTRDseedV1::kNclusters; ic--;){
927       if(!(c = tracklet->GetClusters(ic))) continue;
928       qTot += TMath::Abs(c->GetQ());
929     }
930     h->Fill(qTot);
931     if(fDebugLevel > 3){
932       Int_t crossing = (Int_t)tracklet->IsRowCross();
933       Int_t detector = tracklet->GetDetector();
934       Float_t theta = TMath::ATan(tracklet->GetZfit(1));
935       Float_t phi = TMath::ATan(tracklet->GetYfit(1));
936       Float_t momentum = 0.;
937       Int_t pdg = 0;
938       Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
939       UShort_t nclsTPC = fESD ? fESD->GetTPCncls() : 0;
940       if(fMC){
941               if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
942         pdg = fMC->GetPDG();
943       }
944       (*fDebugStream) << "ChargeTracklet"
945         << "Detector="  << detector
946         << "crossing="  << crossing
947         << "momentum="  << momentum
948         << "nTracklets="<< nTracklets
949         << "pdg="                               << pdg
950         << "theta="                     << theta
951         << "phi="                               << phi
952         << "kinkIndex=" << kinkIndex
953         << "TPCncls="           << nclsTPC
954         << "QT="        << qTot
955         << "\n";
956     }
957   }
958   return h;
959 }
960
961 //_______________________________________________________
962 TH1 *AliTRDcheckDET::PlotNTracksSector(const AliTRDtrackV1 *track){
963   //
964   // Plot the number of tracks per Sector
965   //
966   if(track) fTrack = track;
967   if(!fTrack){
968     AliWarning("No Track defined.");
969     return 0x0;
970   }
971   TH1 *h = 0x0;
972   if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtracksSector)))){
973     AliWarning("No Histogram defined.");
974     return 0x0;
975   }
976
977   // TODO we should compare with
978   // sector = Int_t(track->GetAlpha() / AliTRDgeometry::GetAlpha());
979
980   AliTRDseedV1 *tracklet = 0x0;
981   Int_t sector = -1;
982   for(Int_t itl = 0; itl < AliTRDgeometry::kNlayer; itl++){
983     if(!(tracklet = fTrack->GetTracklet(itl)) || !tracklet->IsOK()) continue;
984     sector = static_cast<Int_t>(tracklet->GetDetector()/AliTRDgeometry::kNdets);
985     break;
986   }
987   h->Fill(sector);
988   return h;
989 }
990
991
992 //________________________________________________________
993 void AliTRDcheckDET::SetRecoParam(AliTRDrecoParam *r)
994 {
995
996   fReconstructor->SetRecoParam(r);
997 }
998
999 //________________________________________________________
1000 void AliTRDcheckDET::GetDistanceToTracklet(Double_t *dist, AliTRDseedV1 * const tracklet, AliTRDcluster * const c)
1001 {
1002   Float_t x = c->GetX();
1003   dist[0] = c->GetY() - tracklet->GetYat(x);
1004   dist[1] = c->GetZ() - tracklet->GetZat(x);
1005 }
1006
1007
1008 //_______________________________________________________
1009 TH1* AliTRDcheckDET::MakePlotChi2()
1010 {
1011 // Plot chi2/track normalized to number of degree of freedom 
1012 // (tracklets) and compare with the theoretical distribution.
1013 // 
1014 // Alex Bercuci <A.Bercuci@gsi.de>
1015
1016   TH2S *h2 = (TH2S*)fContainer->At(kChi2);
1017   TF1 f("fChi2", "[0]*pow(x, [1]-1)*exp(-0.5*x)", 0., 50.);
1018   TLegend *leg = new TLegend(.7,.7,.95,.95);
1019   leg->SetBorderSize(1); leg->SetHeader("Tracklets per Track");
1020   TH1D *h1 = 0x0;
1021   Bool_t kFIRST = kTRUE;
1022   for(Int_t il=1; il<=h2->GetNbinsX(); il++){
1023     h1 = h2->ProjectionY(Form("pyChi2%d", il), il, il);
1024     if(h1->Integral()<50) continue;
1025     h1->Scale(1./h1->Integral());
1026     h1->SetMarkerStyle(7);h1->SetMarkerColor(il);
1027     h1->SetLineColor(il);h1->SetLineStyle(2);
1028     f.SetParameter(1, .5*il);f.SetLineColor(il);
1029     h1->Fit(&f, "QW+", kFIRST ? "pc": "pcsame");
1030     leg->AddEntry(h1, Form("%d", il), "l");
1031     if(kFIRST){
1032       h1->GetXaxis()->SetRangeUser(0., 25.);
1033     }
1034     kFIRST = kFALSE;
1035   }
1036   leg->Draw();
1037   gPad->SetLogy();
1038   return h1;
1039 }
1040
1041
1042 //________________________________________________________
1043 TH1* AliTRDcheckDET::MakePlotNTracklets(){
1044   //
1045   // Make nice bar plot of the number of tracklets in each method
1046   //
1047   TH1F *hBAR = (TH1F *)fContainer->FindObject("hNtlsBAR");
1048   TH1F *hSTA = (TH1F *)fContainer->FindObject("hNtlsSTA");
1049   TH1F *hCON = (TH1F *)fContainer->FindObject("hNtls");
1050   TLegend *leg = new TLegend(0.13, 0.75, 0.39, 0.89);
1051   leg->SetBorderSize(1);
1052   leg->SetFillColor(0);
1053
1054   Float_t scale = hCON->Integral();
1055   hCON->Scale(100./scale);
1056   hCON->SetFillColor(kRed);hCON->SetLineColor(kRed);
1057   hCON->SetBarWidth(0.2);
1058   hCON->SetBarOffset(0.6);
1059   hCON->SetStats(kFALSE);
1060   hCON->GetYaxis()->SetRangeUser(0.,40.);
1061   hCON->GetYaxis()->SetTitleOffset(1.2);
1062   hCON->Draw("bar1"); leg->AddEntry(hCON, "Total", "f");
1063   hCON->SetMaximum(55.);
1064
1065   hBAR->Scale(100./scale);
1066   hBAR->SetFillColor(kGreen);hBAR->SetLineColor(kGreen);
1067   hBAR->SetBarWidth(0.2);
1068   hBAR->SetBarOffset(0.2);
1069   hBAR->SetTitle("");
1070   hBAR->SetStats(kFALSE);
1071   hBAR->GetYaxis()->SetRangeUser(0.,40.);
1072   hBAR->GetYaxis()->SetTitleOffset(1.2);
1073   hBAR->Draw("bar1same"); leg->AddEntry(hBAR, "Barrel", "f");
1074
1075   hSTA->Scale(100./scale);
1076   hSTA->SetFillColor(kBlue);hSTA->SetLineColor(kBlue);
1077   hSTA->SetBarWidth(0.2);
1078   hSTA->SetBarOffset(0.4);
1079   hSTA->SetTitle("");
1080   hSTA->SetStats(kFALSE);
1081   hSTA->GetYaxis()->SetRangeUser(0.,40.);
1082   hSTA->GetYaxis()->SetTitleOffset(1.2);
1083   hSTA->Draw("bar1same"); leg->AddEntry(hSTA, "Stand Alone", "f");
1084   leg->Draw();
1085   gPad->Update();
1086   return hCON;
1087 }
1088
1089 //________________________________________________________
1090 TH1* AliTRDcheckDET::MakePlotPulseHeight(){
1091   //
1092   // Create Plot of the Pluse Height Spectrum
1093   //
1094   TH1 *h, *h1, *h2;
1095   TObjArray *arr = (TObjArray*)fContainer->FindObject("<PH>");
1096   h = (TH1F*)arr->At(0);
1097   h->SetMarkerStyle(24);
1098   h->SetMarkerColor(kBlack);
1099   h->SetLineColor(kBlack);
1100   h->Draw("e1");
1101 //   copy the second histogram in a new one with the same x-dimension as the phs with respect to time
1102   h1 = (TH1F *)arr->At(1);
1103   h2 = new TH1F("hphs1","Average PH", 31, -0.5, 30.5);
1104   for(Int_t ibin = h1->GetXaxis()->GetFirst(); ibin < h1->GetNbinsX(); ibin++) 
1105     h2->SetBinContent(ibin, h1->GetBinContent(ibin));
1106   h2->SetMarkerStyle(22);
1107   h2->SetMarkerColor(kBlue);
1108   h2->SetLineColor(kBlue);
1109   h2->Draw("e1same");
1110   gPad->Update();
1111 //   create axis according to the histogram dimensions of the original second histogram
1112   TGaxis *axis = new TGaxis(gPad->GetUxmin(),
1113                     gPad->GetUymax(),
1114                     gPad->GetUxmax(),
1115                     gPad->GetUymax(),
1116                     -0.08, 4.88, 510,"-L");
1117   axis->SetLineColor(kBlue);
1118   axis->SetLabelColor(kBlue);
1119   axis->SetTextColor(kBlue);
1120   axis->SetTitle("x_{0}-x_{c} [cm]");
1121   axis->Draw();
1122   return h1;
1123 }
1124
1125 //________________________________________________________
1126 Bool_t AliTRDcheckDET::MakeBarPlot(TH1 *histo, Int_t color){
1127   //
1128   // Draw nice bar plots
1129   //
1130   if(!histo->GetEntries()) return kFALSE;
1131   histo->Scale(100./histo->Integral());
1132   histo->SetFillColor(color);
1133   histo->SetBarOffset(.2);
1134   histo->SetBarWidth(.6);
1135   histo->Draw("bar1");
1136   return kTRUE;
1137 }