1 ////////////////////////////////////////////////////////////////////////////
4 // Basic checks for tracking and detector performance //
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
13 // - Chi2 distribution for tracks
14 // - Charge distribution per cluster and tracklet
15 // - Number of events and tracks per trigger source
17 // - Track and Tracklet propagation status
20 // Anton Andronic <A.Andronic@gsi.de> //
21 // Alexandru Bercuci <A.Bercuci@gsi.de> //
22 // Markus Fasel <M.Fasel@gsi.de> //
24 ////////////////////////////////////////////////////////////////////////////
37 #include <TObjArray.h>
39 #include <TObjString.h>
43 #include <TProfile2D.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"
63 #include "info/AliTRDtrackInfo.h"
64 #include "info/AliTRDeventInfo.h"
65 #include "AliTRDcheckDET.h"
70 ClassImp(AliTRDcheckDET)
72 //_______________________________________________________
73 AliTRDcheckDET::AliTRDcheckDET():
74 AliTRDrecoTask("checkDET", "Basic TRD data checker")
81 // Default constructor
83 DefineInput(1,AliTRDeventInfo::Class());
84 fReconstructor = new AliTRDReconstructor;
85 fReconstructor->SetRecoParam(AliTRDrecoParam::GetLowFluxParam());
86 fGeo = new AliTRDgeometry;
90 //_______________________________________________________
91 AliTRDcheckDET::~AliTRDcheckDET(){
95 if(fTriggerNames) delete fTriggerNames;
96 delete fReconstructor;
100 //_______________________________________________________
101 void AliTRDcheckDET::ConnectInputData(Option_t *opt){
103 // Connect the Input data with the task
105 AliTRDrecoTask::ConnectInputData(opt);
106 fEventInfo = dynamic_cast<AliTRDeventInfo *>(GetInputData(1));
109 //_______________________________________________________
110 void AliTRDcheckDET::CreateOutputObjects(){
112 // Create Output Objects
114 OpenFile(0,"RECREATE");
115 fContainer = Histos();
116 if(!fTriggerNames) fTriggerNames = new TMap();
119 //_______________________________________________________
120 void AliTRDcheckDET::Exec(Option_t *opt){
122 // Execution function
123 // Filling TRD quality histos
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;
139 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNeventsTriggerTracks))->Fill(triggermask);
140 dynamic_cast<TH1F *>(fContainer->UncheckedAt(kNtracksEvent))->Fill(nTracks);
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);
150 PostData(0, fContainer);
153 //_______________________________________________________
154 void AliTRDcheckDET::Terminate(Option_t *){
156 // Terminate function
160 //_______________________________________________________
161 Bool_t AliTRDcheckDET::PostProcess(){
163 // Do Postprocessing (for the moment set the number of Reference histograms)
168 // Calculate of the trigger clusters purity
169 h = dynamic_cast<TH1F *>(fContainer->FindObject("hEventsTrigger"));
170 TH1F *h1 = dynamic_cast<TH1F *>(fContainer->FindObject("hEventsTriggerTracks"));
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);
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());
188 ax->SetRangeUser(-0.5, nTriggerClasses+.5);
189 h->GetYaxis()->SetRangeUser(0,1);
196 //_______________________________________________________
197 Bool_t AliTRDcheckDET::GetRefFigure(Int_t ifig){
199 // Setting Reference Figures
205 case kNclustersTrack:
206 (h=(TH1F*)fContainer->FindObject("hNcls"))->Draw("pl");
207 PutTrendValue("NClustersTrack", h->GetMean(), h->GetRMS());
209 case kNclustersTracklet:
210 (h =(TH1F*)fContainer->FindObject("hNclTls"))->Draw("pc");
211 PutTrendValue("NClustersTracklet", h->GetMean(), h->GetRMS());
213 case kNtrackletsTrack:
214 h=MakePlotNTracklets();
215 PutTrendValue("NTrackletsTrack", h->GetMean(), h->GetRMS());
217 case kNtrackletsCross:
218 h = (TH1F*)fContainer->FindObject("hNtlsCross");
219 if(!MakeBarPlot(h, kRed)) break;
220 PutTrendValue("NTrackletsCross", h->GetMean(), h->GetRMS());
222 case kNtrackletsFindable:
223 h = (TH1F*)fContainer->FindObject("hNtlsFindable");
224 if(!MakeBarPlot(h, kGreen)) break;
225 PutTrendValue("NTrackletsFindable", h->GetMean(), h->GetRMS());
228 (h = (TH1F*)fContainer->FindObject("hNtrks"))->Draw("pl");
229 PutTrendValue("NTracksEvent", h->GetMean(), h->GetRMS());
232 h = (TH1F*)fContainer->FindObject("hNtrksSector");
233 if(!MakeBarPlot(h, kGreen)) break;
234 PutTrendValue("NTracksSector", h->GetMean(2), h->GetRMS(2));
237 ((TH1I *)fContainer->FindObject("hTrackStatus"))->Draw("c");
240 case kTrackletStatus:
241 ((TH2S *)fContainer->FindObject("hTrackletStatus"))->Draw("colz");
248 MakePlotPulseHeight();
252 (h = (TH1F*)fContainer->FindObject("hQcl"))->Draw("c");
254 PutTrendValue("ChargeCluster", h->GetMaximumBin(), h->GetRMS());
256 case kChargeTracklet:
257 (h=(TH1F*)fContainer->FindObject("hQtrklt"))->Draw("c");
258 PutTrendValue("ChargeTracklet", h->GetMaximumBin(), h->GetRMS());
260 case kNeventsTrigger:
261 ((TH1F*)fContainer->FindObject("hEventsTrigger"))->Draw("");
263 case kNeventsTriggerTracks:
264 ((TH1F*)fContainer->FindObject("hEventsTriggerTracks"))->Draw("");
267 if(!MakeBarPlot((TH1F*)fContainer->FindObject("hTriggerPurity"), kGreen)) break;
272 AliInfo(Form("Reference plot [%d] missing result", ifig));
276 //_______________________________________________________
277 TObjArray *AliTRDcheckDET::Histos(){
279 // Create QA histograms
281 if(fContainer) return fContainer;
283 fContainer = new TObjArray(20);
284 //fContainer->SetOwner(kTRUE);
286 // Register Histograms
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");
294 fContainer->AddAt(h, kNclustersTrack);
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");
301 fContainer->AddAt(h, kNclustersTracklet);
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. [%]");
308 fContainer->AddAt(h, kNtrackletsTrack);
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. [%]");
315 fContainer->AddAt(h, kNtrackletsSTA);
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. [%]");
322 fContainer->AddAt(h, kNtrackletsBAR);
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. [%]");
330 fContainer->AddAt(h, kNtrackletsCross);
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");
337 fContainer->AddAt(h, kNtrackletsFindable);
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");
344 fContainer->AddAt(h, kNtracksEvent);
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. [%]");
351 fContainer->AddAt(h, kNtracksSector);
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");
364 fContainer->AddAt(h, kTrackStatus);
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");
379 fContainer->AddAt(h, kTrackletStatus);
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]");
391 if(!(h = (TH1F *)gROOT->FindObject("hPHx")))
392 h = new TProfile("hPHx", "<PH>", 31, -0.08, 4.88);
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);
400 h->SetYTitle("#chi^{2}/ndf");
401 h->SetZTitle("entries");
403 fContainer->AddAt(h, kChi2);
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");
410 fContainer->AddAt(h, kChargeCluster);
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");
417 fContainer->AddAt(h, kChargeTracklet);
420 if(!(h = (TH1F *)gROOT->FindObject("hEventsTrigger")))
421 h = new TH1F("hEventsTrigger", "Trigger Class", 100, 0, 100);
423 fContainer->AddAt(h, kNeventsTrigger);
425 if(!(h = (TH1F *)gROOT->FindObject("hEventsTriggerTracks")))
426 h = new TH1F("hEventsTriggerTracks", "Trigger Class (Tracks)", 100, 0, 100);
428 fContainer->AddAt(h, kNeventsTriggerTracks);
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.");
435 fContainer->AddAt(h, kTriggerPurity);
444 //_______________________________________________________
445 TH1 *AliTRDcheckDET::PlotTrackStatus(const AliTRDtrackV1 *track){
447 // Plot the track status
449 if(track) fTrack = track;
451 AliWarning("No Track defined.");
455 if(!(h = dynamic_cast<TH1I *>(fContainer->At(kTrackStatus)))){
456 AliWarning("No Histogram defined.");
459 h->Fill(fTrack->GetStatusTRD());
463 //_______________________________________________________
464 TH1 *AliTRDcheckDET::PlotTrackletStatus(const AliTRDtrackV1 *track){
466 // Plot the track status
468 if(track) fTrack = track;
470 AliWarning("No Track defined.");
474 if(!(h = dynamic_cast<TH2S *>(fContainer->At(kTrackletStatus)))){
475 AliWarning("No Histogram defined.");
479 for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
480 status = fTrack->GetStatusTRD(il);
486 //_______________________________________________________
487 TH1 *AliTRDcheckDET::PlotNClustersTracklet(const AliTRDtrackV1 *track){
489 // Plot the mean number of clusters per tracklet
491 if(track) fTrack = track;
493 AliWarning("No Track defined.");
497 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersTracklet)))){
498 AliWarning("No Histogram defined.");
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());
509 //_______________________________________________________
510 TH1 *AliTRDcheckDET::PlotNClustersTrack(const AliTRDtrackV1 *track){
512 // Plot the number of clusters in one track
514 if(track) fTrack = track;
516 AliWarning("No Track defined.");
520 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNclustersTrack)))){
521 AliWarning("No Histogram defined.");
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();
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.;
537 Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
538 UShort_t nclsTPC = fESD ? fESD->GetTPCncls() : 0;
540 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
543 (*fDebugStream) << "NClustersTrack"
544 << "Detector=" << detector
545 << "crossing=" << crossing
546 << "momentum=" << momentum
550 << "kinkIndex=" << kinkIndex
551 << "TPCncls=" << nclsTPC
552 << "nclusters=" << nclusters
561 //_______________________________________________________
562 TH1 *AliTRDcheckDET::PlotNTrackletsTrack(const AliTRDtrackV1 *track){
564 // Plot the number of tracklets
566 if(track) fTrack = track;
568 AliWarning("No Track defined.");
571 TH1 *h = 0x0, *hMethod = 0x0;
572 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsTrack)))){
573 AliWarning("No Histogram defined.");
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){
580 if(!(hMethod = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsBAR))))
581 AliWarning("Method: Barrel. Histogram not processed!");
584 if(!(hMethod = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsSTA))))
585 AliWarning("Method: StandAlone. Histogram not processed!");
587 Int_t nTracklets = fTrack->GetNumberOfTracklets();
589 hMethod->Fill(nTracklets);
592 // If we have one Tracklet, check in which layer this happens
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;}
598 (*fDebugStream) << "NTrackletsTrack"
607 //_______________________________________________________
608 TH1 *AliTRDcheckDET::PlotNTrackletsRowCross(const AliTRDtrackV1 *track){
610 // Plot the number of tracklets
612 if(track) fTrack = track;
614 AliWarning("No Track defined.");
618 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsCross)))){
619 AliWarning("No Histogram defined.");
624 AliTRDseedV1 *tracklet = 0x0;
625 for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
626 if(!(tracklet = fTrack->GetTracklet(il)) || !tracklet->IsOK()) continue;
628 if(tracklet->IsRowCross()) ncross++;
634 //_______________________________________________________
635 TH1 *AliTRDcheckDET::PlotFindableTracklets(const AliTRDtrackV1 *track){
637 // Plots the ratio of number of tracklets vs.
638 // number of findable tracklets
640 // Findable tracklets are defined as track prolongation
641 // to layer i does not hit the dead area +- epsilon
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
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
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
664 if(track) fTrack = track;
666 AliWarning("No Track defined.");
670 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtrackletsFindable)))){
671 AliWarning("No Histogram defined.");
674 Int_t nFound = 0, nFindable = 0;
676 Double_t ymin = 0., ymax = 0., zmin = 0., zmax = 0.;
677 Double_t y = 0., z = 0.;
678 AliTRDseedV1 *tracklet = 0x0;
680 for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
681 if((tracklet = fTrack->GetTracklet(il)) && tracklet->IsOK()){
682 tracklet->SetReconstructor(fReconstructor);
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];
691 memset(xyz, 0, sizeof(Float_t) * 3);
692 if(((fESD->GetStatus() & AliESDtrack::kTRDout) > 0) && !((fESD->GetStatus() & AliESDtrack::kTRDin) > 0)){
694 for(Int_t il = 0; il < AliTRDgeometry::kNlayer; il++){
696 points[il].SetXYZ(xyz);
698 AliTRDtrackerV1::FitRiemanTilt(const_cast<AliTRDtrackV1 *>(fTrack), 0x0, kTRUE, 6, points);
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);
717 /*for(Int_t ipt = 0; ipt < AliTRDgeometry::kNlayer; ipt++)
718 printf("%d. X = %f\n", ipt, points[ipt].GetX());*/
720 AliTRDtrackerV1::FitKalman(©Track, 0x0, kFALSE, 6, pointsInward);
721 memcpy(points, pointsInward, sizeof(AliTrackPoint) * 6); // Preliminary store the inward results in the Array points
723 AliTRDtrackerV1::FitKalman(©Track, 0x0, kTRUE, 6, pointsInward);
724 memcpy(points, pointsOutward, sizeof(AliTrackPoint) * AliTRDgeometry::kNlayer);
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++;
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"
742 << "ytracklet=" << posTracklet[0]
744 << "ztracklet=" << posTracklet[1]
746 << "tracklet=" << hasTracklet
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)));
757 //_______________________________________________________
758 TH1 *AliTRDcheckDET::PlotChi2(const AliTRDtrackV1 *track){
760 // Plot the chi2 of the track
762 if(track) fTrack = track;
764 AliWarning("No Track defined.");
768 if(!(h = dynamic_cast<TH2S*>(fContainer->At(kChi2)))) {
769 AliWarning("No Histogram defined.");
772 Int_t n = fTrack->GetNumberOfTracklets();
775 h->Fill(n, fTrack->GetChi2()/n);
780 //_______________________________________________________
781 TH1 *AliTRDcheckDET::PlotPHt(const AliTRDtrackV1 *track){
783 // Plot the average pulse height
785 if(track) fTrack = track;
787 AliWarning("No Track defined.");
791 if(!(h = dynamic_cast<TProfile *>(((TObjArray*)(fContainer->At(kPH)))->At(0)))){
792 AliWarning("No Histogram defined.");
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);
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.;
814 Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
815 UShort_t TPCncls = fESD ? fESD->GetTPCncls() : 0;
817 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
820 (*fDebugStream) << "PHt"
821 << "Detector=" << detector
822 << "crossing=" << crossing
823 << "Timebin=" << localtime
824 << "Charge=" << absoluteCharge
825 << "momentum=" << momentum
829 << "kinkIndex=" << kinkIndex
830 << "TPCncls=" << TPCncls
831 << "dy=" << distance[0]
832 << "dz=" << distance[1]
841 //_______________________________________________________
842 TH1 *AliTRDcheckDET::PlotPHx(const AliTRDtrackV1 *track){
844 // Plots the average pulse height vs the distance from the anode wire
845 // (plus const anode wire offset)
847 if(track) fTrack = track;
849 AliWarning("No Track defined.");
853 if(!(h = dynamic_cast<TProfile *>(((TObjArray*)(fContainer->At(kPH)))->At(1)))){
854 AliWarning("No Histogram defined.");
857 Float_t offset = .5*AliTRDgeometry::CamHght();
858 AliTRDseedV1 *tracklet = 0x0;
859 AliTRDcluster *c = 0x0;
860 Double_t distance = 0;
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());
870 distance = tracklet->GetX0() - (c->GetX() + 0.3) + offset;
871 h->Fill(distance, TMath::Abs(c->GetQ()));
877 //_______________________________________________________
878 TH1 *AliTRDcheckDET::PlotChargeCluster(const AliTRDtrackV1 *track){
880 // Plot the cluster charge
882 if(track) fTrack = track;
884 AliWarning("No Track defined.");
888 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeCluster)))){
889 AliWarning("No Histogram defined.");
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;
904 //_______________________________________________________
905 TH1 *AliTRDcheckDET::PlotChargeTracklet(const AliTRDtrackV1 *track){
907 // Plot the charge deposit per chamber
909 if(track) fTrack = track;
911 AliWarning("No Track defined.");
915 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kChargeTracklet)))){
916 AliWarning("No Histogram defined.");
919 AliTRDseedV1 *tracklet = 0x0;
920 AliTRDcluster *c = 0x0;
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;
926 for(Int_t ic = AliTRDseedV1::kNclusters; ic--;){
927 if(!(c = tracklet->GetClusters(ic))) continue;
928 qTot += TMath::Abs(c->GetQ());
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.;
938 Int_t kinkIndex = fESD ? fESD->GetKinkIndex() : 0;
939 UShort_t nclsTPC = fESD ? fESD->GetTPCncls() : 0;
941 if(fMC->GetTrackRef()) momentum = fMC->GetTrackRef()->P();
944 (*fDebugStream) << "ChargeTracklet"
945 << "Detector=" << detector
946 << "crossing=" << crossing
947 << "momentum=" << momentum
948 << "nTracklets="<< nTracklets
952 << "kinkIndex=" << kinkIndex
953 << "TPCncls=" << nclsTPC
961 //_______________________________________________________
962 TH1 *AliTRDcheckDET::PlotNTracksSector(const AliTRDtrackV1 *track){
964 // Plot the number of tracks per Sector
966 if(track) fTrack = track;
968 AliWarning("No Track defined.");
972 if(!(h = dynamic_cast<TH1F *>(fContainer->At(kNtracksSector)))){
973 AliWarning("No Histogram defined.");
977 // TODO we should compare with
978 // sector = Int_t(track->GetAlpha() / AliTRDgeometry::GetAlpha());
980 AliTRDseedV1 *tracklet = 0x0;
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);
992 //________________________________________________________
993 void AliTRDcheckDET::SetRecoParam(AliTRDrecoParam *r)
996 fReconstructor->SetRecoParam(r);
999 //________________________________________________________
1000 void AliTRDcheckDET::GetDistanceToTracklet(Double_t *dist, AliTRDseedV1 * const tracklet, AliTRDcluster * const c)
1002 Float_t x = c->GetX();
1003 dist[0] = c->GetY() - tracklet->GetYat(x);
1004 dist[1] = c->GetZ() - tracklet->GetZat(x);
1008 //_______________________________________________________
1009 TH1* AliTRDcheckDET::MakePlotChi2()
1011 // Plot chi2/track normalized to number of degree of freedom
1012 // (tracklets) and compare with the theoretical distribution.
1014 // Alex Bercuci <A.Bercuci@gsi.de>
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");
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");
1032 h1->GetXaxis()->SetRangeUser(0., 25.);
1042 //________________________________________________________
1043 TH1* AliTRDcheckDET::MakePlotNTracklets(){
1045 // Make nice bar plot of the number of tracklets in each method
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);
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.);
1065 hBAR->Scale(100./scale);
1066 hBAR->SetFillColor(kGreen);hBAR->SetLineColor(kGreen);
1067 hBAR->SetBarWidth(0.2);
1068 hBAR->SetBarOffset(0.2);
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");
1075 hSTA->Scale(100./scale);
1076 hSTA->SetFillColor(kBlue);hSTA->SetLineColor(kBlue);
1077 hSTA->SetBarWidth(0.2);
1078 hSTA->SetBarOffset(0.4);
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");
1089 //________________________________________________________
1090 TH1* AliTRDcheckDET::MakePlotPulseHeight(){
1092 // Create Plot of the Pluse Height Spectrum
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);
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);
1111 // create axis according to the histogram dimensions of the original second histogram
1112 TGaxis *axis = new TGaxis(gPad->GetUxmin(),
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]");
1125 //________________________________________________________
1126 Bool_t AliTRDcheckDET::MakeBarPlot(TH1 *histo, Int_t color){
1128 // Draw nice bar plots
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");