]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/TPC/AliTPCPerformanceSummary.cxx
revert changes
[u/mrichter/AliRoot.git] / PWG1 / TPC / AliTPCPerformanceSummary.cxx
1 //------------------------------------------------------------------------------
2 // Implementation of AliTPCPerformanceSummary class. 
3 // It has only static member functions to extract some TPC Performance
4 // parameters and produce trend graphs.
5 // The function MakeReport is to be called for every run. It reads AliPerformanceTPC
6 // and AliPerformanceDEdx objects from file and produces a
7 // rootfile with the results stored in a TTree.
8 // The function MakeReport needs a list of these rootfiles as input
9 // and writes the output (tree and histograms) to another rootfile.
10 //
11 // by M.Knichel 15/10/2010
12 //------------------------------------------------------------------------------
13
14 #include <fstream>
15
16 #include "TSystem.h"
17 #include "TMath.h"
18 #include "TVectorD.h"
19 #include "TList.h"
20 #include "TFile.h"
21 #include "TGrid.h"
22 #include "TF1.h"
23 #include "TH1.h"
24 #include "TH2.h"
25 #include "TH3.h"
26 #include "TProfile.h"
27 #include "THnSparse.h"
28 #include "TTree.h"
29 #include "TChain.h"
30 #include "TGraph.h"
31 #include "TPad.h"
32 #include "TCanvas.h"
33
34 #include "AliGRPObject.h"
35 #include "AliTPCcalibDB.h"
36 #include "AliTPCcalibDButil.h"
37 #include "TTreeStream.h"
38 #include "AliPerformanceTPC.h"
39 #include "AliPerformanceDEdx.h"
40 #include "AliPerformanceDCA.h"
41 #include "AliPerformanceMatch.h"
42
43 #include "AliTPCPerformanceSummary.h"
44
45 ClassImp(AliTPCPerformanceSummary)
46
47 Bool_t AliTPCPerformanceSummary::fgForceTHnSparse = kFALSE;
48
49
50 //_____________________________________________________________________________
51 void AliTPCPerformanceSummary::WriteToTTreeSRedirector(const AliPerformanceTPC* pTPC, const AliPerformanceDEdx* pTPCgain, const AliPerformanceMatch* pTPCMatch, TTreeSRedirector* const pcstream, Int_t run)
52 {
53    // 
54     // Extracts performance parameters from pTPC and pTPCgain.
55     // Output is written to pcstream.
56     // The run number must be provided since it is not stored in 
57     // AliPerformanceTPC or AliPerformanceDEdx.
58     //
59     if (run <= 0 ) {
60         if (pTPCMatch) {run = pTPCMatch->GetRunNumber(); }
61         if (pTPCgain) {run = pTPCgain->GetRunNumber(); }
62         if (pTPC) { run = pTPC->GetRunNumber(); }
63     }
64     TObjString runType;
65     AliTPCcalibDB     *calibDB=0;
66 //     AliTPCcalibDButil *dbutil =0;
67     Int_t startTimeGRP=0;
68     Int_t stopTimeGRP=0;   
69     Int_t time=0;
70     Int_t duration=0;
71     Float_t currentL3 =0;
72     Int_t polarityL3 = 0;
73     Float_t bz = 0;
74     calibDB = AliTPCcalibDB::Instance();
75 //     dbutil= new AliTPCcalibDButil;   
76         
77     printf("Processing run %d ...\n",run);
78     if (calibDB) { 
79         AliTPCcalibDB::Instance()->SetRun(run); 
80 //     dbutil->UpdateFromCalibDB();
81 //     dbutil->SetReferenceRun(run);
82 //     dbutil->UpdateRefDataFromOCDB();     
83      
84   if (calibDB->GetGRP(run)){
85     startTimeGRP = AliTPCcalibDB::GetGRP(run)->GetTimeStart();
86     stopTimeGRP  = AliTPCcalibDB::GetGRP(run)->GetTimeEnd();
87     currentL3 = AliTPCcalibDB::GetL3Current(run);
88     polarityL3 = AliTPCcalibDB::GetL3Polarity(run);
89     bz = AliTPCcalibDB::GetBz(run);
90     
91   }    
92   runType = AliTPCcalibDB::GetRunType(run).Data();  
93 }  
94   time = (startTimeGRP+stopTimeGRP)/2;
95   duration = (stopTimeGRP-startTimeGRP);
96     
97     if (!pcstream) return;
98     (*pcstream)<<"tpcQA"<<      
99       "run="<<run<<
100       "time="<<time<<
101       "startTimeGRP="<<startTimeGRP<<
102       "stopTimeGRP="<<stopTimeGRP<<
103       "duration="<<
104       "runType.="<<&runType;
105     if (pTPC) {
106         pTPC->GetTPCTrackHisto()->GetAxis(9)->SetRangeUser(0.5,1.5);
107         pTPC->GetTPCTrackHisto()->GetAxis(7)->SetRangeUser(0.25,10);
108         pTPC->GetTPCTrackHisto()->GetAxis(5)->SetRangeUser(-1,1);    
109         AnalyzeNCL(pTPC, pcstream);    
110         AnalyzeDrift(pTPC, pcstream);
111         AnalyzeDriftPos(pTPC, pcstream);
112         AnalyzeDriftNeg(pTPC, pcstream);    
113         AnalyzeDCARPhi(pTPC, pcstream);
114         AnalyzeDCARPhiPos(pTPC, pcstream);
115         AnalyzeDCARPhiNeg(pTPC, pcstream);
116         AnalyzeEvent(pTPC, pcstream);         
117
118         AnalyzePt(pTPC,pcstream);
119         AnalyzeChargeOverPt(pTPC,pcstream); 
120         
121
122         pTPC->GetTPCTrackHisto()->GetAxis(9)->SetRangeUser(-10,10);
123         pTPC->GetTPCTrackHisto()->GetAxis(7)->SetRangeUser(0,100);
124         pTPC->GetTPCTrackHisto()->GetAxis(5)->SetRangeUser(-10,10); 
125     }
126     AnalyzeGain(pTPCgain, pcstream);
127     AnalyzeMatch(pTPCMatch, pcstream);
128     (*pcstream)<<"tpcQA"<<"\n";
129 }
130
131 //_____________________________________________________________________________
132 void AliTPCPerformanceSummary::WriteToFile(const AliPerformanceTPC* pTPC, const AliPerformanceDEdx* pTPCgain, const AliPerformanceMatch* pMatch, const Char_t* outfile, Int_t run)
133 {
134     //
135     // Extracts performance parameters from pTPC and pTPCgain.
136     // Output is written to a TTree saved in outfile.
137     // The run number must be provided since it is not stored in 
138     // AliPerformanceTPC or AliPerformanceDEdx.
139     //
140     // The function creates a TTreeSRedirector and calls the 
141     // function WriteToTTreeSRedirector.
142     //
143     
144     if (!outfile) return;
145     TTreeSRedirector* pcstream = 0;
146     pcstream = new TTreeSRedirector(outfile);
147     if (!pcstream) return;
148     WriteToTTreeSRedirector(pTPC, pTPCgain, pMatch, pcstream, run);
149     if (pcstream) { delete pcstream; pcstream = 0; }    
150     
151 }
152
153 //_____________________________________________________________________________
154 Int_t AliTPCPerformanceSummary::MakeReport(const Char_t* infile, const Char_t* outfile, Int_t run)
155 {
156     //
157     // Reads QA information (AliPerformanceTPC and AliPerformanceDEdx) from
158     // infile (this must be a rootfile) and writes the output to a TTree
159     // stored in outfile.
160     // The run number must be provided since it is not stored in 
161     // AliPerformanceTPC or AliPerformanceDEdx.
162     // 
163     // The input objects must be named "AliPerformanceTPC" and 
164     // "AliPerformanceDEdxTPCInner" and stored in a TList which name must
165     // be one of the following: "TPC", "TPCQA", "TPC_PerformanceQA"
166     // or "TPC_PerformanceQA/TPC" (with directory)
167     //
168     
169     if (!infile) return -1;
170     if (!outfile) return -1;
171     TFile *f =0;
172     f=TFile::Open(infile,"read");
173     if (!f) {
174         printf("File %s not available\n", infile);
175         return -1;
176     } 
177     TList* list = 0;
178     list = dynamic_cast<TList*>(f->Get("TPC")); 
179     if (!list) { list = dynamic_cast<TList*>(f->Get("TPCQA")); }
180     if (!list) { list = dynamic_cast<TList*>(f->Get("TPC_PerformanceQA/TPCQA")); }
181     if (!list) { list = dynamic_cast<TList*>(f->Get("TPC_PerformanceQA")); }
182     if (!list) {
183             printf("QA %s not available\n", infile);
184             return -1;
185     } 
186     AliPerformanceTPC* pTPC = 0;
187     AliPerformanceDEdx* pTPCgain = 0; 
188     AliPerformanceMatch* pTPCmatch = 0; 
189     if (list) {  pTPC = dynamic_cast<AliPerformanceTPC*>(list->FindObject("AliPerformanceTPC")); }
190     if (list) {  pTPCgain = dynamic_cast<AliPerformanceDEdx*>(list->FindObject("AliPerformanceDEdxTPCInner")); }
191     if (list) {  pTPCmatch = dynamic_cast<AliPerformanceMatch*>(list->FindObject("AliPerformanceMatchTPCITS")); }
192     
193     Int_t returncode = 0;
194     WriteToFile(pTPC, pTPCgain, pTPCmatch ,outfile, run);
195     if (f) { delete f; f=0; }
196     return returncode;
197 }
198
199 //_____________________________________________________________________________
200 Int_t AliTPCPerformanceSummary::ProduceTrends(const Char_t* infilelist, const Char_t* outfile)
201 {
202     //
203     // Produces trend graphs.
204     //
205     // Input: infilelist is a textfile with one rootfile per line.
206     // There should be one rootfile for each run, the rootfile must
207     // contain the output of the MakeReport function
208     // Output: the information for all runs is merged into a TTree
209     // that is saved in outfile along with the trend graphs.
210     // Trend graphs are stored as TCanvas objects to include axis labels etc.
211     //
212     
213     if (!infilelist) return -1;
214     if (!outfile) return -1;
215      
216     TChain* chain = new TChain("tpcQA");
217     if(!chain) return -1;
218
219     ifstream in;
220     in.open(infilelist);
221
222     TString currentFile;    
223     while(in.good()) {
224         in >> currentFile;
225
226         if (!currentFile.Contains("root")) continue; // protection            
227         chain->Add(currentFile.Data());
228     }
229     in.close();
230     //TTree *tree = chain;
231     TTree *tree = chain->CopyTree("1");
232     if(!tree) return -1;
233     if (chain) { delete chain; chain=0; }
234     //TGraph* graph = dynamic_cast<TGraph*>(tree->DrawClone("run:run"));
235     //TGraph *graph = (TGraph*)gPad->GetPrimitive("Graph");
236     
237     TFile* out = new TFile(outfile,"RECREATE");
238     if(!out) return -1;
239
240     out->cd();
241     const Char_t* condition = "meanTPCncl>0";
242     SaveGraph(tree,"meanTPCnclF","run",condition);
243     SaveGraph(tree,"rmsTPCnclF","run",condition);
244     SaveGraph(tree,"meanTPCChi2","run",condition);
245     SaveGraph(tree,"rmsTPCChi2","run",condition);
246     SaveGraph(tree,"slopeATPCnclF","run",condition);
247     SaveGraph(tree,"slopeCTPCnclF","run",condition);
248     SaveGraph(tree,"slopeATPCnclFErr","run",condition);
249     SaveGraph(tree,"slopeCTPCnclFErr","run",condition);
250     SaveGraph(tree,"meanTPCncl","run",condition);
251     SaveGraph(tree,"rmsTPCncl","run",condition);
252     SaveGraph(tree,"slopeATPCncl","run",condition);
253     SaveGraph(tree,"slopeCTPCncl","run",condition);
254     SaveGraph(tree,"slopeATPCnclErr","run",condition);
255     SaveGraph(tree,"slopeCTPCnclErr","run",condition);
256     
257     SaveGraph(tree,"offsetdRA","run",condition);
258     SaveGraph(tree,"slopedRA","run",condition);
259     SaveGraph(tree,"offsetdRC","run",condition);
260     SaveGraph(tree,"slopedRC","run",condition);
261     SaveGraph(tree,"offsetdRAErr","run",condition);
262     SaveGraph(tree,"slopedRAErr","run",condition);    
263     SaveGraph(tree,"offsetdRCErr","run",condition);
264     SaveGraph(tree,"slopedRCErr","run",condition);
265     SaveGraph(tree,"offsetdRAchi2","run",condition);
266     SaveGraph(tree,"slopedRAchi2","run",condition);
267     SaveGraph(tree,"offsetdRCchi2","run",condition);    
268     SaveGraph(tree,"slopedRCchi2","run",condition);    
269     
270     SaveGraph(tree,"offsetdRAPos","run",condition);
271       
272     SaveGraph(tree,"slopedRAPos","run",condition);
273     SaveGraph(tree,"offsetdRCPos","run",condition);
274     SaveGraph(tree,"slopedRCPos","run",condition);
275     SaveGraph(tree,"offsetdRAErrPos","run",condition);
276     SaveGraph(tree,"slopedRAErrPos","run",condition);
277     SaveGraph(tree,"offsetdRCErrPos","run",condition); 
278     SaveGraph(tree,"slopedRCErrPos","run",condition);
279     SaveGraph(tree,"offsetdRAchi2Pos","run",condition);
280     SaveGraph(tree,"slopedRAchi2Pos","run",condition);
281     SaveGraph(tree,"offsetdRCchi2Pos","run",condition);
282     SaveGraph(tree,"slopedRCchi2Pos","run",condition);
283         
284     SaveGraph(tree,"offsetdRANeg","run",condition);
285     SaveGraph(tree,"slopedRANeg","run",condition);
286     SaveGraph(tree,"offsetdRCNeg","run",condition);
287     SaveGraph(tree,"slopedRCNeg","run",condition);
288     SaveGraph(tree,"offsetdRAErrNeg","run",condition);
289     SaveGraph(tree,"slopedRAErrNeg","run",condition);
290     SaveGraph(tree,"offsetdRCErrNeg","run",condition);
291     SaveGraph(tree,"slopedRCErrNeg","run",condition);
292     SaveGraph(tree,"offsetdRAchi2Neg","run",condition);
293     SaveGraph(tree,"slopedRAchi2Neg","run",condition);
294     SaveGraph(tree,"offsetdRCchi2Neg","run",condition);
295     SaveGraph(tree,"slopedRCchi2Neg","run",condition);
296         
297     SaveGraph(tree,"offsetdZAPos","run",condition);
298     SaveGraph(tree,"slopedZAPos","run",condition);
299     SaveGraph(tree,"offsetdZCPos","run",condition);
300     SaveGraph(tree,"slopedZCPos","run",condition);
301     SaveGraph(tree,"offsetdZAErrPos","run",condition);
302     SaveGraph(tree,"slopedZAErrPos","run",condition);
303     SaveGraph(tree,"offsetdZCErrPos","run",condition);
304     SaveGraph(tree,"slopedZCErrPos","run",condition);
305     SaveGraph(tree,"offsetdZAchi2Pos","run",condition);
306     SaveGraph(tree,"slopedZAchi2Pos","run",condition);
307     SaveGraph(tree,"offsetdZCchi2Pos","run",condition);
308     SaveGraph(tree,"slopedZCchi2Pos","run",condition);
309     
310     SaveGraph(tree,"offsetdZANeg","run",condition);
311     SaveGraph(tree,"slopedZANeg","run",condition);
312     SaveGraph(tree,"offsetdZCNeg","run",condition);
313     SaveGraph(tree,"slopedZCNeg","run",condition);
314     SaveGraph(tree,"offsetdZAErrNeg","run",condition);
315     SaveGraph(tree,"slopedZAErrNeg","run",condition);
316     SaveGraph(tree,"offsetdZCErrNeg","run",condition);
317     SaveGraph(tree,"slopedZCErrNeg","run",condition);
318     SaveGraph(tree,"offsetdZAchi2Neg","run",condition);
319     SaveGraph(tree,"slopedZAchi2Neg","run",condition);
320     SaveGraph(tree,"offsetdZCchi2Neg","run",condition);
321     SaveGraph(tree,"slopedZCchi2Neg","run",condition);    
322     
323     SaveGraph(tree,"offsetdZA","run",condition);
324     SaveGraph(tree,"slopedZA","run",condition);
325     SaveGraph(tree,"offsetdZC","run",condition);
326     SaveGraph(tree,"slopedZC","run",condition);
327     SaveGraph(tree,"offsetdZAErr","run",condition);
328     SaveGraph(tree,"slopedZAErr","run",condition);
329     SaveGraph(tree,"offsetdZCErr","run",condition);
330     SaveGraph(tree,"slopedZCErr","run",condition);
331     SaveGraph(tree,"offsetdZAchi2","run",condition);
332     SaveGraph(tree,"slopedZAchi2","run",condition);
333     SaveGraph(tree,"offsetdZCchi2","run",condition);
334     SaveGraph(tree,"slopedZCchi2","run",condition);        
335
336     SaveGraph(tree,"meanVertX","run",condition);
337     SaveGraph(tree,"rmsVertX","run",condition);
338     SaveGraph(tree,"meanVertY","run",condition);
339     SaveGraph(tree,"rmsVertY","run",condition);
340     SaveGraph(tree,"meanVertZ","run",condition);
341     SaveGraph(tree,"rmsVertZ","run",condition);
342     SaveGraph(tree,"vertStatus","run",condition);
343     SaveGraph(tree,"meanMult","run",condition);
344     SaveGraph(tree,"rmsMult","run",condition);
345     SaveGraph(tree,"meanMultPos","run",condition);
346     SaveGraph(tree,"rmsMultPos","run",condition);
347     SaveGraph(tree,"meanMultNeg","run",condition);
348     SaveGraph(tree,"rmsMultNeg","run",condition);
349     SaveGraph(tree,"vertAll","run",condition);
350     SaveGraph(tree,"vertOK","run",condition);
351
352
353     SaveGraph(tree,"meanPtAPos","run",condition);
354     SaveGraph(tree,"mediumPtAPos","run",condition);
355     SaveGraph(tree,"highPtAPos","run",condition);
356     SaveGraph(tree,"meanPtCPos","run",condition);
357     SaveGraph(tree,"mediumPtCPos","run",condition);
358     SaveGraph(tree,"highPtCPos","run",condition);
359     SaveGraph(tree,"meanPtANeg","run",condition);
360     SaveGraph(tree,"mediumPtANeg","run",condition);
361     SaveGraph(tree,"highPtANeg","run",condition);
362     SaveGraph(tree,"meanPtCNeg","run",condition);
363     SaveGraph(tree,"mediumPtCNeg","run",condition);
364     SaveGraph(tree,"highPtCNeg","run",condition);
365  
366     SaveGraph(tree,"qOverPt","run",condition);
367     SaveGraph(tree,"qOverPtA","run",condition);
368     SaveGraph(tree,"qOverPtC","run",condition);
369     
370     tree->Write();
371     
372     out->Close();   
373     if (tree) { delete tree; tree=0; }
374     if (out) { delete out; out=0; }
375 return 0;
376 }
377
378 //_____________________________________________________________________________
379 Int_t AliTPCPerformanceSummary::SaveGraph(TTree* tree, const Char_t* y, const Char_t* x, const Char_t* condition)
380 {    
381     //
382     // Creates a Graph and writes the canvas to the current directory
383     // called by ProduceTrends function.
384     //
385     
386     TString s(y);
387     s += ':';
388     s += x;
389     tree->Draw(s.Data(),condition,"goff");
390     TCanvas* c = new TCanvas(s.Data(),s.Data());
391     c->cd();
392     TPad* p = new TPad("pad0","pad0",0,0,1,1);
393     p->Draw();
394     p->cd();
395     if (tree->GetSelectedRows() > 0) {
396       TGraph* graph = new TGraph(tree->GetSelectedRows(), tree->GetV2(), tree->GetV1());
397       graph->Draw("AP");
398       graph->GetXaxis()->SetTitle(x);
399       graph->GetYaxis()->SetTitle(y);
400       c->Write(s.Data());
401       delete graph;
402     }
403     //graph->Write(s.Data());
404     delete c;
405     
406 return 0;
407 }
408
409 //_____________________________________________________________________________
410 Int_t AliTPCPerformanceSummary::AnalyzeDCARPhi(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
411 {
412     //
413     // Analyse DCA R imperfections
414     //
415     
416     if (!pcstream) return 8;
417     if (!pTPC) return 8;
418         
419     // variables:
420     static Double_t offsetdRA=0;
421     static Double_t slopedRA=0;
422     static Double_t offsetdRC=0;
423     static Double_t slopedRC=0;
424     static Double_t offsetdRAErr=0;
425     static Double_t slopedRAErr=0;
426     static Double_t offsetdRCErr=0;
427     static Double_t slopedRCErr=0;
428     static Double_t offsetdRAchi2=0;
429     static Double_t slopedRAchi2=0;
430     static Double_t offsetdRCchi2=0;
431     static Double_t slopedRCchi2=0;
432
433     //AliPerformanceTPC* pTPC =  dynamic_cast<AliPerformanceTPC*>(pTPCObject);    
434     
435     TH1* his1D=0;
436     TH2* his2D=0;
437     TH3* his3D=0;
438     
439     if (pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_3_5_7")) {    
440         his3D = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_3_5_7"));
441         if(!his3D) return 8;
442         his3D->GetYaxis()->SetRangeUser(-1,1);
443         his3D->GetZaxis()->SetRangeUser(0.25,10);
444     }
445     
446     static TF1 *fpol1 = new TF1("fpol1","pol1");
447     TObjArray arrayFit;
448     if (his3D && !fgForceTHnSparse) { 
449         his2D = dynamic_cast<TH2*>(his3D->Project3D("xy")); 
450     } else {    
451         his2D = pTPC->GetTPCTrackHisto()->Projection(3,5);
452     }            
453     if(!his2D) return 8;
454
455     
456     his2D->FitSlicesY(0,0,-1,10,"QNR",&arrayFit);
457     delete his2D;
458     his1D = (TH1*) arrayFit.At(1);
459     his1D->Fit(fpol1,"QNRROB=0.8","QNR",-0.8,-0.1);
460     offsetdRC=fpol1->GetParameter(0);
461     slopedRC=fpol1->GetParameter(1);
462     offsetdRCchi2=fpol1->GetChisquare();
463     slopedRCchi2=fpol1->GetChisquare();
464     //
465     his1D->Fit(fpol1,"QNRROB=0.8","QNR",0.1,0.8);
466     offsetdRA=fpol1->GetParameter(0);
467     slopedRA=fpol1->GetParameter(1);
468     offsetdRAErr=fpol1->GetParError(0);
469     slopedRAErr=fpol1->GetParError(1);
470     offsetdRAchi2=fpol1->GetChisquare();
471     slopedRAchi2=fpol1->GetChisquare();
472     //
473     printf("DCA R QA report\n");
474     printf("offsetdRA\t%f\n",offsetdRA);
475     printf("slopedRA\t%f\n",slopedRA);
476     printf("offsetdRC\t%f\n",offsetdRC);
477     printf("slopedRC\t%f\n",slopedRC);
478     //
479     // dump values
480     //
481     (*pcstream)<<"tpcQA"<<
482         "offsetdRA="<< offsetdRA<<
483         "slopedRA="<< slopedRA<<
484         "offsetdRC="<< offsetdRC<<
485         "slopedRC="<<slopedRC<<
486         //
487         "offsetdRAErr="<< offsetdRAErr<<
488         "slopedRAErr="<< slopedRAErr<<
489         "offsetdRCErr="<< offsetdRCErr<<
490         "slopedRCErr="<<slopedRCErr<<
491         //
492         "offsetdRAchi2="<< offsetdRAchi2<<
493         "slopedRAchi2="<< slopedRAchi2<<
494         "offsetdRCchi2="<< offsetdRCchi2<<
495         "slopedRCchi2="<<slopedRCchi2;
496         
497     return 0;
498 }
499
500 //_____________________________________________________________________________
501 Int_t AliTPCPerformanceSummary::AnalyzeDCARPhiPos(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
502 {
503     //
504     // Analyse DCA R imperfections for positive particles
505     //
506     
507     if (!pcstream) return 16;
508     if (!pTPC) return 16;
509
510     // variables:
511     static Double_t offsetdRAPos=0;
512     static Double_t slopedRAPos=0;
513     static Double_t offsetdRCPos=0;
514     static Double_t slopedRCPos=0;
515     static Double_t offsetdRAErrPos=0;
516     static Double_t slopedRAErrPos=0;
517     static Double_t offsetdRCErrPos=0;
518     static Double_t slopedRCErrPos=0;
519     static Double_t offsetdRAchi2Pos=0;
520     static Double_t slopedRAchi2Pos=0;
521     static Double_t offsetdRCchi2Pos=0;
522     static Double_t slopedRCchi2Pos=0;
523
524     //AliPerformanceTPC* pTPC =  dynamic_cast<AliPerformanceTPC*>(pTPCObject);    
525     TH1* his1D=0;
526     TH2* his2D=0;
527     TH3* his3D=0;
528     
529     if (pTPC->GetHistos()->FindObject("h_tpc_track_pos_recvertex_3_5_7")) {    
530         his3D = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_pos_recvertex_3_5_7"));
531         if(!his3D) return 16;
532         his3D->GetYaxis()->SetRangeUser(-1,1);
533         his3D->GetZaxis()->SetRangeUser(0.25,10);
534     }
535     
536     static TF1 *fpol1 = new TF1("fpol1","pol1");
537     TObjArray arrayFit;
538     if (his3D && !fgForceTHnSparse) { 
539         his2D = dynamic_cast<TH2*>(his3D->Project3D("xy")); 
540     } else {    
541         pTPC->GetTPCTrackHisto()->GetAxis(8)->SetRangeUser(0,1.5);        
542         his2D = pTPC->GetTPCTrackHisto()->Projection(3,5);
543         pTPC->GetTPCTrackHisto()->GetAxis(8)->SetRangeUser(-1.5,1.5);
544     }            
545     if(!his2D) return 16;
546     
547     his2D->FitSlicesY(0,0,-1,10,"QNR",&arrayFit);
548     delete his2D;    
549     his1D = (TH1*) arrayFit.At(1);
550     his1D->Fit(fpol1,"QNRROB=0.8","QNR",-0.8,-0.1);
551     offsetdRCPos=fpol1->GetParameter(0);
552     slopedRCPos=fpol1->GetParameter(1);
553     offsetdRCchi2Pos=fpol1->GetChisquare();
554     slopedRCchi2Pos=fpol1->GetChisquare();
555     //
556     his1D->Fit(fpol1,"QNRROB=0.8","QNR",0.1,0.8);
557     offsetdRAPos=fpol1->GetParameter(0);
558     slopedRAPos=fpol1->GetParameter(1);
559     offsetdRAErrPos=fpol1->GetParError(0);
560     slopedRAErrPos=fpol1->GetParError(1);
561     offsetdRAchi2Pos=fpol1->GetChisquare();
562     slopedRAchi2Pos=fpol1->GetChisquare();
563     //
564     printf("DCA R QA Pos report\n");
565     printf("offsetdRAPos\t%f\n",offsetdRAPos);
566     printf("slopedRAPos\t%f\n",slopedRAPos);
567     printf("offsetdRCPos\t%f\n",offsetdRCPos);
568     printf("slopedRCPos\t%f\n",slopedRCPos);
569     //
570     // dump values
571     //
572     (*pcstream)<<"tpcQA"<<
573         "offsetdRAPos="<< offsetdRAPos<<
574         "slopedRAPos="<< slopedRAPos<<
575         "offsetdRCPos="<< offsetdRCPos<<
576         "slopedRCPos="<<slopedRCPos<<
577         //
578         "offsetdRAErrPos="<< offsetdRAErrPos<<
579         "slopedRAErrPos="<< slopedRAErrPos<<
580         "offsetdRCErrPos="<< offsetdRCErrPos<<
581         "slopedRCErrPos="<<slopedRCErrPos<<
582         //
583         "offsetdRAchi2Pos="<< offsetdRAchi2Pos<<
584         "slopedRAchi2Pos="<< slopedRAchi2Pos<<
585         "offsetdRCchi2Pos="<< offsetdRCchi2Pos<<
586         "slopedRCchi2Pos="<<slopedRCchi2Pos;
587         
588     return 0;
589 }
590
591 //_____________________________________________________________________________
592 Int_t AliTPCPerformanceSummary::AnalyzeDCARPhiNeg(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
593 {
594     //
595     // Analyse DCA R imperfections for negative particles
596     //
597     if (!pcstream) return 32;
598     if (!pTPC) return 32;
599
600     // variables:
601     static Double_t offsetdRANeg=0;
602     static Double_t slopedRANeg=0;
603     static Double_t offsetdRCNeg=0;
604     static Double_t slopedRCNeg=0;
605     static Double_t offsetdRAErrNeg=0;
606     static Double_t slopedRAErrNeg=0;
607     static Double_t offsetdRCErrNeg=0;
608     static Double_t slopedRCErrNeg=0;
609     static Double_t offsetdRAchi2Neg=0;
610     static Double_t slopedRAchi2Neg=0;
611     static Double_t offsetdRCchi2Neg=0;
612     static Double_t slopedRCchi2Neg=0;
613
614     //AliPerformanceTPC* pTPC =  dynamic_cast<AliPerformanceTPC*>(pTPCObject);    
615     TH1* his1D=0;
616     TH2* his2D=0;
617     TH3* his3D=0;
618     
619     if (pTPC->GetHistos()->FindObject("h_tpc_track_neg_recvertex_3_5_7")) {    
620         his3D = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_neg_recvertex_3_5_7"));
621         if(!his3D) return 32;
622         his3D->GetYaxis()->SetRangeUser(-1,1);
623         his3D->GetZaxis()->SetRangeUser(0.25,10);
624     }
625     
626     static TF1 *fpol1 = new TF1("fpol1","pol1");
627     TObjArray arrayFit;
628     if (his3D && !fgForceTHnSparse) {
629         his2D = dynamic_cast<TH2*>(his3D->Project3D("xy")); 
630     } else {    
631         pTPC->GetTPCTrackHisto()->GetAxis(8)->SetRangeUser(-1.5,0);        
632         his2D = pTPC->GetTPCTrackHisto()->Projection(3,5);
633         pTPC->GetTPCTrackHisto()->GetAxis(8)->SetRangeUser(-1.5,1.5);
634     }            
635     if(!his2D) return 32;
636
637     his2D->FitSlicesY(0,0,-1,10,"QNR",&arrayFit);
638     delete his2D;    
639     his1D = (TH1*) arrayFit.At(1);
640     his1D->Fit(fpol1,"QNRROB=0.8","QNR",-0.8,-0.1);
641     offsetdRCNeg=fpol1->GetParameter(0);
642     slopedRCNeg=fpol1->GetParameter(1);
643     offsetdRCchi2Neg=fpol1->GetChisquare();
644     slopedRCchi2Neg=fpol1->GetChisquare();
645     //
646     his1D->Fit(fpol1,"QNRROB=0.8","QNR",0.1,0.8);
647     offsetdRANeg=fpol1->GetParameter(0);
648     slopedRANeg=fpol1->GetParameter(1);
649     offsetdRAErrNeg=fpol1->GetParError(0);
650     slopedRAErrNeg=fpol1->GetParError(1);
651     offsetdRAchi2Neg=fpol1->GetChisquare();
652     slopedRAchi2Neg=fpol1->GetChisquare();
653     //
654     printf("DCA R QA Neg report\n");
655     printf("offsetdRANeg\t%f\n",offsetdRANeg);
656     printf("slopedRANeg\t%f\n",slopedRANeg);
657     printf("offsetdRCNeg\t%f\n",offsetdRCNeg);
658     printf("slopedRCNeg\t%f\n",slopedRCNeg);
659     //
660     // dump drift QA values
661     //
662     (*pcstream)<<"tpcQA"<<
663         "offsetdRANeg="<< offsetdRANeg<<
664         "slopedRANeg="<< slopedRANeg<<
665         "offsetdRCNeg="<< offsetdRCNeg<<
666         "slopedRCNeg="<<slopedRCNeg<<
667         //
668         "offsetdRAErrNeg="<< offsetdRAErrNeg<<
669         "slopedRAErrNeg="<< slopedRAErrNeg<<
670         "offsetdRCErrNeg="<< offsetdRCErrNeg<<
671         "slopedRCErrNeg="<<slopedRCErrNeg<<
672         //
673         "offsetdRAchi2Neg="<< offsetdRAchi2Neg<<
674         "slopedRAchi2Neg="<< slopedRAchi2Neg<<
675         "offsetdRCchi2Neg="<< offsetdRCchi2Neg<<
676         "slopedRCchi2Neg="<<slopedRCchi2Neg;
677         
678     return 0;
679 }
680
681 //_____________________________________________________________________________
682 Int_t AliTPCPerformanceSummary::AnalyzeNCL(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
683 {
684     //
685     // Analyse number of TPC clusters 
686     //
687     
688     if (!pcstream) return 1;
689     if (!pTPC) return 1;
690  
691     // variables:
692     static Double_t meanTPCnclF=0;
693     static Double_t rmsTPCnclF=0;
694     static Double_t meanTPCChi2=0;
695     static Double_t rmsTPCChi2=0;  
696     static Double_t slopeATPCnclF=0;
697     static Double_t slopeCTPCnclF=0;
698     static Double_t slopeATPCnclFErr=0;
699     static Double_t slopeCTPCnclFErr=0;
700     static Double_t meanTPCncl=0;
701     static Double_t rmsTPCncl=0;
702     static Double_t slopeATPCncl=0;
703     static Double_t slopeCTPCncl=0;
704     static Double_t slopeATPCnclErr=0;
705     static Double_t slopeCTPCnclErr=0;  
706     //
707     TH1* his1D=0;
708     TH3* his3D0=0;
709     TH3* his3D1=0;
710     TH3* his3D2=0;
711     TProfile* hprof=0;
712     static TF1 *fpol1 = new TF1("fpol1","pol1");
713     //
714     // all clusters
715     // only events with rec. vertex
716     // eta cut - +-1
717     // pt cut  - 0.250 GeV
718     pTPC->GetTPCTrackHisto()->GetAxis(5)->SetRangeUser(-1.,1.);
719     pTPC->GetTPCTrackHisto()->GetAxis(7)->SetRangeUser(0.25,10);
720     
721     if (pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_0_5_7")) {    
722         his3D0 = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_0_5_7"));
723         if(!his3D0) return 1;
724         his3D0->GetYaxis()->SetRangeUser(-1,1);
725         his3D0->GetZaxis()->SetRangeUser(0.25,10);
726     }
727     if (pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_1_5_7")) {    
728         his3D1 = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_1_5_7"));
729         if(!his3D1) return 1;
730         his3D1->GetYaxis()->SetRangeUser(-1,1);
731         his3D1->GetZaxis()->SetRangeUser(0.25,10);
732     }
733     if (pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_2_5_7")) {    
734         his3D2 = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_2_5_7"));
735         if(!his3D2) return 1;
736         his3D2->GetYaxis()->SetRangeUser(-1,1);
737         his3D2->GetZaxis()->SetRangeUser(0.25,10);
738         his3D2->GetXaxis()->SetRangeUser(0.4,1.1);        
739     }    
740     
741
742     if (his3D0 && !fgForceTHnSparse) { 
743          his1D = his3D0->Project3D("x"); 
744     } else {
745          his1D = pTPC->GetTPCTrackHisto()->Projection(0);
746     }
747  
748     meanTPCncl= his1D->GetMean();
749     rmsTPCncl= his1D->GetRMS();
750     delete his1D;
751     
752     if (his3D1 && !fgForceTHnSparse) {
753          his1D = his3D1->Project3D("x"); 
754     } else {
755          his1D = pTPC->GetTPCTrackHisto()->Projection(1);
756     }
757           
758     meanTPCChi2= his1D->GetMean();
759     rmsTPCChi2= his1D->GetRMS();
760     delete his1D;  
761     
762    if (his3D0 && !fgForceTHnSparse) {
763         hprof = (dynamic_cast<TH2*>(his3D0->Project3D("xy")))->ProfileX(); 
764     } else {
765         hprof = pTPC->GetTPCTrackHisto()->Projection(0,5)->ProfileX();
766     }
767     if(!hprof) return 1;
768     
769     hprof->Fit(fpol1,"QNR","QNR",0.1,0.8);
770     slopeATPCncl= fpol1->GetParameter(1);
771     slopeATPCnclErr= fpol1->GetParError(1);
772     hprof->Fit(fpol1,"QNR","QNR",-0.8,-0.1);
773     slopeCTPCncl= fpol1->GetParameter(1);
774     slopeCTPCnclErr= fpol1->GetParameter(1);
775     delete hprof;
776     
777     //
778     // findable clusters
779     //
780     
781    if (his3D2 && !fgForceTHnSparse) {
782         his1D = his3D2->Project3D("x"); 
783     } else {    
784         pTPC->GetTPCTrackHisto()->GetAxis(2)->SetRangeUser(0.4,1.1);
785         his1D = pTPC->GetTPCTrackHisto()->Projection(2);
786     }    
787         
788     meanTPCnclF= his1D->GetMean();
789     rmsTPCnclF= his1D->GetRMS();
790     delete his1D;
791     
792    if (his3D2 && !fgForceTHnSparse) { 
793          his1D = (dynamic_cast<TH2*>(his3D2->Project3D("xy")))->ProfileX(); 
794     } else {    
795         pTPC->GetTPCTrackHisto()->GetAxis(2)->SetRangeUser(0.4,1.1);
796         his1D = pTPC->GetTPCTrackHisto()->Projection(2,5)->ProfileX();
797     }      
798     if(!his1D) return 1;
799     
800     his1D->Fit(fpol1,"QNR","QNR",0.1,0.8);
801     slopeATPCnclF= fpol1->GetParameter(1);
802     slopeATPCnclFErr= fpol1->GetParError(1);
803     his1D->Fit(fpol1,"QNR","QNR",-0.8,-0.1);
804     slopeCTPCnclF= fpol1->GetParameter(1);
805     slopeCTPCnclFErr= fpol1->GetParameter(1);
806     delete his1D;
807         
808     pTPC->GetTPCTrackHisto()->GetAxis(2)->SetRangeUser(0,10);
809     
810     printf("Cluster QA report\n");
811     printf("meanTPCnclF=\t%f\n",meanTPCnclF);
812     printf("rmsTPCnclF=\t%f\n",rmsTPCnclF);
813     printf("slopeATPCnclF=\t%f\n",slopeATPCnclF);
814     printf("slopeCTPCnclF=\t%f\n",slopeCTPCnclF);
815     printf("meanTPCncl=\t%f\n",meanTPCncl);
816     printf("rmsTPCncl=\t%f\n",rmsTPCncl);
817     printf("slopeATPCncl=\t%f\n",slopeATPCncl);
818     printf("slopeCTPCncl=\t%f\n",slopeCTPCncl);
819     printf("meanTPCChi2=\t%f\n",meanTPCChi2);
820     printf("rmsTPCChi2=\t%f\n",rmsTPCChi2);
821     //
822     // dump results to the tree
823     //
824     (*pcstream)<<"tpcQA"<<
825       "meanTPCnclF="<<meanTPCnclF <<   
826       "rmsTPCnclF="<<rmsTPCnclF <<
827       "meanTPCChi2="<<meanTPCChi2 <<
828       "rmsTPCChi2="<<rmsTPCChi2 <<
829       "slopeATPCnclF="<< slopeATPCnclF<<
830       "slopeCTPCnclF="<< slopeCTPCnclF<<
831       "slopeATPCnclFErr="<< slopeATPCnclFErr<<
832       "slopeCTPCnclFErr="<< slopeCTPCnclFErr<<
833       "meanTPCncl="<<meanTPCncl <<
834       "rmsTPCncl="<< rmsTPCncl<<
835       "slopeATPCncl="<< slopeATPCncl<<
836       "slopeCTPCncl="<< slopeCTPCncl<<
837       "slopeATPCnclErr="<< slopeATPCnclErr<<
838       "slopeCTPCnclErr="<< slopeCTPCnclErr;
839     
840     return 0;
841 }
842
843 //_____________________________________________________________________________
844 Int_t AliTPCPerformanceSummary::AnalyzeDrift(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
845 {
846     //
847     // Analyse DCA Z imperferctions (drift velocity)
848     //
849     
850     if (!pcstream) return 2;
851     if (!pTPC) return 2;
852
853     // variables:
854     static Double_t offsetdZA=0;
855     static Double_t slopedZA=0;
856     static Double_t offsetdZC=0;
857     static Double_t slopedZC=0;
858     static Double_t offsetdZAErr=0;
859     static Double_t slopedZAErr=0;
860     static Double_t offsetdZCErr=0;
861     static Double_t slopedZCErr=0;
862     static Double_t offsetdZAchi2=0;
863     static Double_t slopedZAchi2=0;
864     static Double_t offsetdZCchi2=0;
865     static Double_t slopedZCchi2=0;
866     TH1* his1D=0;
867     TH2* his2D=0;
868     TH3* his3D=0;
869     
870    if (pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_4_5_7")) {    
871         his3D = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_4_5_7"));
872         if(!his3D) return 2;
873         his3D->GetYaxis()->SetRangeUser(-1,1);
874         his3D->GetZaxis()->SetRangeUser(0.25,10);
875    }
876
877    if (his3D && !fgForceTHnSparse) { 
878         his2D = dynamic_cast<TH2*>(his3D->Project3D("xy")); 
879     } else {    
880         his2D = pTPC->GetTPCTrackHisto()->Projection(4,5);
881     }        
882     if(!his2D) return 2;
883     
884     static TF1 *fpol1 = new TF1("fpol1","pol1");
885     TObjArray arrayFit;
886     his2D->FitSlicesY(0,0,-1,10,"QNR",&arrayFit);
887     delete his2D;
888     his1D = (TH1*) arrayFit.At(1);
889     his1D->Fit(fpol1,"QNRROB=0.8","QNR",-0.8,-0.1);
890     offsetdZC=fpol1->GetParameter(0);
891     slopedZC=fpol1->GetParameter(1);
892     offsetdZCErr=fpol1->GetParError(0);
893     slopedZCErr=fpol1->GetParError(1);        
894     offsetdZCchi2=fpol1->GetChisquare();
895     slopedZCchi2=fpol1->GetChisquare();
896     //
897     his1D->Fit(fpol1,"QNRROB=0.8","QNR",0.1,0.8);
898     offsetdZA=fpol1->GetParameter(0);
899     slopedZA=fpol1->GetParameter(1);
900     offsetdZAErr=fpol1->GetParError(0);
901     slopedZAErr=fpol1->GetParError(1);
902     offsetdZAchi2=fpol1->GetChisquare();
903     slopedZAchi2=fpol1->GetChisquare();
904     //
905     printf("Drift velocity QA report\n");
906     printf("offsetdZA\t%f\n",offsetdZA);
907     printf("slopedZA\t%f\n",slopedZA);
908     printf("offsetdZC\t%f\n",offsetdZC);
909     printf("slopedZC\t%f\n",slopedZC);
910     //
911     // dump drift QA values
912     //
913     (*pcstream)<<"tpcQA"<<
914         "offsetdZA="<< offsetdZA<<
915         "slopedZA="<< slopedZA<<
916         "offsetdZC="<< offsetdZC<<
917         "slopedZC="<<slopedZC<<
918         //
919         "offsetdZAErr="<< offsetdZAErr<<
920         "slopedZAErr="<< slopedZAErr<<
921         "offsetdZCErr="<< offsetdZCErr<<
922         "slopedZCErr="<<slopedZCErr<<
923         //
924         "offsetdZAchi2="<< offsetdZAchi2<<
925         "slopedZAchi2="<< slopedZAchi2<<
926         "offsetdZCchi2="<< offsetdZCchi2<<
927         "slopedZCchi2="<<slopedZCchi2;
928     
929     return 0;
930 }
931
932 //_____________________________________________________________________________
933 Int_t AliTPCPerformanceSummary::AnalyzeDriftPos(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
934 {
935     //
936     // Analyse DCA Z imperferctions (drift velocity)
937     // for positive particles
938     //
939     if (!pcstream) return 64;
940     if (!pTPC) return 64;
941         
942     // variables:
943     static Double_t offsetdZAPos=0;
944     static Double_t slopedZAPos=0;
945     static Double_t offsetdZCPos=0;
946     static Double_t slopedZCPos=0;
947     static Double_t offsetdZAErrPos=0;
948     static Double_t slopedZAErrPos=0;
949     static Double_t offsetdZCErrPos=0;
950     static Double_t slopedZCErrPos=0;
951     static Double_t offsetdZAchi2Pos=0;
952     static Double_t slopedZAchi2Pos=0;
953     static Double_t offsetdZCchi2Pos=0;
954     static Double_t slopedZCchi2Pos=0;
955     TH1* his1D=0;
956     TH2* his2D=0;
957     TH3* his3D=0;
958     
959    if (pTPC->GetHistos()->FindObject("h_tpc_track_pos_recvertex_4_5_7")) {    
960         his3D = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_pos_recvertex_4_5_7"));
961         if(!his3D) return 64;
962         his3D->GetYaxis()->SetRangeUser(-1,1);
963         his3D->GetZaxis()->SetRangeUser(0.25,10);
964     } 
965
966     if (his3D && !fgForceTHnSparse) { 
967         his2D = dynamic_cast<TH2*>(his3D->Project3D("xy")); 
968     } else {    
969         his2D = pTPC->GetTPCTrackHisto()->Projection(4,5);
970     }            
971     if(!his2D) return 64;
972     
973     static TF1 *fpol1 = new TF1("fpol1","pol1");
974     TObjArray arrayFit;
975     his2D->FitSlicesY(0,0,-1,10,"QNR",&arrayFit);
976     delete his2D;
977     
978     his1D = (TH1*) arrayFit.At(1);
979     his1D->Fit(fpol1,"QNRROB=0.8","QNR",-0.8,-0.1);
980     offsetdZCPos=fpol1->GetParameter(0);
981     slopedZCPos=fpol1->GetParameter(1);
982     offsetdZCErrPos=fpol1->GetParError(0);
983     slopedZCErrPos=fpol1->GetParError(1);        
984     offsetdZCchi2Pos=fpol1->GetChisquare();
985     slopedZCchi2Pos=fpol1->GetChisquare();
986     //
987     his1D->Fit(fpol1,"QNRROB=0.8","QNR",0.1,0.8);
988     offsetdZAPos=fpol1->GetParameter(0);
989     slopedZAPos=fpol1->GetParameter(1);
990     offsetdZAErrPos=fpol1->GetParError(0);
991     slopedZAErrPos=fpol1->GetParError(1);
992     offsetdZAchi2Pos=fpol1->GetChisquare();
993     slopedZAchi2Pos=fpol1->GetChisquare();
994     //
995     printf("Drift velocity QA report\n");
996     printf("offsetdZAPos\t%f\n",offsetdZAPos);
997     printf("slopedZAPos\t%f\n",slopedZAPos);
998     printf("offsetdZCPos\t%f\n",offsetdZCPos);
999     printf("slopedZCPos\t%f\n",slopedZCPos);
1000     //
1001     // dump drift QA values
1002     //
1003     (*pcstream)<<"tpcQA"<<
1004         "offsetdZAPos="<< offsetdZAPos<<
1005         "slopedZAPos="<< slopedZAPos<<
1006         "offsetdZCPos="<< offsetdZCPos<<
1007         "slopedZCPos="<<slopedZCPos<<
1008         //
1009         "offsetdZAErrPos="<< offsetdZAErrPos<<
1010         "slopedZAErrPos="<< slopedZAErrPos<<
1011         "offsetdZCErrPos="<< offsetdZCErrPos<<
1012         "slopedZCErrPos="<<slopedZCErrPos<<
1013         //
1014         "offsetdZAchi2Pos="<< offsetdZAchi2Pos<<
1015         "slopedZAchi2Pos="<< slopedZAchi2Pos<<
1016         "offsetdZCchi2Pos="<< offsetdZCchi2Pos<<
1017         "slopedZCchi2Pos="<<slopedZCchi2Pos;
1018         
1019     return 0;
1020 }
1021
1022 //_____________________________________________________________________________
1023 Int_t AliTPCPerformanceSummary::AnalyzeDriftNeg(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
1024 {
1025     //
1026     // Analyse DCA Z imperferctions (drift velocity)
1027     // for negative particles
1028     //
1029     if (!pcstream) return 128;
1030     if (!pTPC) return 128;
1031             
1032     // variables:
1033     static Double_t offsetdZANeg=0;
1034     static Double_t slopedZANeg=0;
1035     static Double_t offsetdZCNeg=0;
1036     static Double_t slopedZCNeg=0;
1037     static Double_t offsetdZAErrNeg=0;
1038     static Double_t slopedZAErrNeg=0;
1039     static Double_t offsetdZCErrNeg=0;
1040     static Double_t slopedZCErrNeg=0;
1041     static Double_t offsetdZAchi2Neg=0;
1042     static Double_t slopedZAchi2Neg=0;
1043     static Double_t offsetdZCchi2Neg=0;
1044     static Double_t slopedZCchi2Neg=0;
1045     TH1* his1D=0;
1046     TH2* his2D=0;
1047     TH3* his3D=0;
1048     
1049     
1050    if (pTPC->GetHistos()->FindObject("h_tpc_track_neg_recvertex_4_5_7")) {    
1051         his3D = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_neg_recvertex_4_5_7"));
1052         if(!his3D) return 128;
1053         his3D->GetYaxis()->SetRangeUser(-1,1);
1054         his3D->GetZaxis()->SetRangeUser(0.25,10);
1055     }
1056     if (his3D && !fgForceTHnSparse) { 
1057         his2D = dynamic_cast<TH2*>(his3D->Project3D("xy")); 
1058     } else {    
1059         his2D = pTPC->GetTPCTrackHisto()->Projection(4,5);
1060     }                
1061     if(!his2D) return 128;
1062     
1063     static TF1 *fpol1 = new TF1("fpol1","pol1");
1064     TObjArray arrayFit;
1065     his2D->FitSlicesY(0,0,-1,10,"QNR",&arrayFit);
1066     delete his2D;
1067     
1068     his1D = (TH1*) arrayFit.At(1);
1069     his1D->Fit(fpol1,"QNRROB=0.8","QNR",-0.8,-0.1);
1070     offsetdZCNeg=fpol1->GetParameter(0);
1071     slopedZCNeg=fpol1->GetParameter(1);
1072     offsetdZCErrNeg=fpol1->GetParError(0);
1073     slopedZCErrNeg=fpol1->GetParError(1);        
1074     offsetdZCchi2Neg=fpol1->GetChisquare();
1075     slopedZCchi2Neg=fpol1->GetChisquare();
1076     //
1077     his1D->Fit(fpol1,"QNRROB=0.8","QNR",0.1,0.8);
1078     offsetdZANeg=fpol1->GetParameter(0);
1079     slopedZANeg=fpol1->GetParameter(1);
1080     offsetdZAErrNeg=fpol1->GetParError(0);
1081     slopedZAErrNeg=fpol1->GetParError(1);
1082     offsetdZAchi2Neg=fpol1->GetChisquare();
1083     slopedZAchi2Neg=fpol1->GetChisquare();
1084     //
1085     printf("Drift velocity QA report\n");
1086     printf("offsetdZANeg\t%f\n",offsetdZANeg);
1087     printf("slopedZANeg\t%f\n",slopedZANeg);
1088     printf("offsetdZCNeg\t%f\n",offsetdZCNeg);
1089     printf("slopedZCNeg\t%f\n",slopedZCNeg);
1090     //
1091     // dump drift QA values
1092     //
1093     (*pcstream)<<"tpcQA"<<
1094         "offsetdZANeg="<< offsetdZANeg<<
1095         "slopedZANeg="<< slopedZANeg<<
1096         "offsetdZCNeg="<< offsetdZCNeg<<
1097         "slopedZCNeg="<<slopedZCNeg<<
1098         //
1099         "offsetdZAErrNeg="<< offsetdZAErrNeg<<
1100         "slopedZAErrNeg="<< slopedZAErrNeg<<
1101         "offsetdZCErrNeg="<< offsetdZCErrNeg<<
1102         "slopedZCErrNeg="<<slopedZCErrNeg<<
1103         //
1104         "offsetdZAchi2Neg="<< offsetdZAchi2Neg<<
1105         "slopedZAchi2Neg="<< slopedZAchi2Neg<<
1106         "offsetdZCchi2Neg="<< offsetdZCchi2Neg<<
1107         "slopedZCchi2Neg="<<slopedZCchi2Neg;
1108     
1109     return 0;
1110 }
1111
1112 //_____________________________________________________________________________
1113 Int_t AliTPCPerformanceSummary::AnalyzeGain(const AliPerformanceDEdx* pTPCgain, TTreeSRedirector* const pcstream)
1114 {
1115     //
1116     // Analyse Gain
1117     //
1118     
1119     if (!pcstream) return 4;
1120     if (!pTPCgain) return 4;
1121
1122     static TVectorD meanMIPvsSector(36);
1123     static TVectorD sector(36);
1124     static Float_t meanMIP = 0;
1125     static Float_t resolutionMIP = 0;
1126     static Float_t attachSlopeC = 0;
1127     static Float_t attachSlopeA = 0;
1128
1129     TH1 * his1D = 0;
1130     //TH1 * hisProj1D=0;
1131     TH2* his2D=0;
1132      
1133
1134     meanMIPvsSector.Zero();
1135     //
1136     // select MIP particles
1137     //
1138     pTPCgain->GetDeDxHisto()->GetAxis(7)->SetRangeUser(0.4,0.55);
1139     pTPCgain->GetDeDxHisto()->GetAxis(0)->SetRangeUser(35,60);
1140     pTPCgain->GetDeDxHisto()->GetAxis(6)->SetRangeUser(80,160);
1141     pTPCgain->GetDeDxHisto()->GetAxis(5)->SetRangeUser(-1,1);
1142     //
1143     // MIP position and resolution
1144     //    
1145     TF1 gausFit("gausFit","gaus");
1146    
1147     if (pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_0") && !fgForceTHnSparse) {    
1148         his1D = dynamic_cast<TH1*>(pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_0")->Clone());
1149     } else {
1150        his1D =  pTPCgain->GetDeDxHisto()->Projection(0);
1151     }
1152     if(!his1D) return 4;
1153     his1D->Fit(&gausFit,"QN","QN");
1154
1155     meanMIP = gausFit.GetParameter(1);
1156     resolutionMIP = 0;
1157     if (meanMIP!=0) resolutionMIP = gausFit.GetParameter(2)/meanMIP;
1158     //removedtotest// delete his1D;
1159     //
1160     // MIP position vs. dip angle (attachment)
1161     //    
1162     pTPCgain->GetDeDxHisto()->GetAxis(5)->SetRangeUser(-3,0); // C side
1163     if (pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_c_0_5") && !fgForceTHnSparse) {    
1164         his2D = dynamic_cast<TH2*>(pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_c_0_5")->Clone());
1165     } else {
1166         his2D =  pTPCgain->GetDeDxHisto()->Projection(0,5);
1167     }        
1168     if(!his2D) return 4;
1169
1170     TF1 * fpol = new TF1("fpol","pol1");
1171     TObjArray arrayFit;
1172     his2D->FitSlicesY(0,0,-1,10,"QN",&arrayFit);    
1173     his1D = (TH1*) arrayFit.At(1);
1174     his1D->Fit(fpol,"QNROB=0.8","QNR",-1,0);
1175     attachSlopeC = fpol->GetParameter(1);
1176      //removedtotest// delete his2D;
1177      //removedtotest// delete his1D;
1178     //
1179     pTPCgain->GetDeDxHisto()->GetAxis(5)->SetRangeUser(0,3); // A side
1180     if (pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_a_0_5") && !fgForceTHnSparse) {    
1181         his2D = dynamic_cast<TH2*>(pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_a_0_5")->Clone());
1182     } else {
1183         his2D =  pTPCgain->GetDeDxHisto()->Projection(0,5);
1184     }         
1185     if(!his2D) return 4;
1186
1187     TF1 * fpolA = new TF1("fpolA","pol1");
1188     TObjArray arrayFitA;
1189     his2D->FitSlicesY(0,0,-1,10,"QN",&arrayFit);    
1190     his1D = (TH1*) arrayFit.At(1);
1191     his1D->Fit(fpolA,"QNROB=0.8","QN",0,1);
1192     attachSlopeA = fpolA->GetParameter(1);
1193      //removedtotest// delete his2D;
1194      //removedtotest// delete his1D;
1195     //
1196     // MIP position vs. sector
1197     //
1198     pTPCgain->GetDeDxHisto()->GetAxis(5)->SetRangeUser(-3,0); // C side
1199     if (pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_c_0_1") && !fgForceTHnSparse) {    
1200         his2D = dynamic_cast<TH2*>(pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_c_0_1")->Clone());
1201     } else {
1202         his2D =  pTPCgain->GetDeDxHisto()->Projection(0,1);
1203     }
1204     if(!his2D) return 4;
1205
1206     for(Int_t i = 0; i < 18; i++) { // loop over sectors; correct mapping to be checked!
1207         //TH1* his1D=0;
1208         Float_t phiLow = -TMath::Pi() + i*(20./360.)*(2*TMath::Pi());
1209         Float_t phiUp    = -TMath::Pi() + (i+1)*(20./360.)*(2*TMath::Pi());
1210         //pTPCgain->GetDeDxHisto()->GetAxis(1)->SetRangeUser(phiLow,phiUp);
1211         his2D->GetXaxis()->SetRangeUser(phiLow,phiUp);
1212         //his1D = pTPCgain->GetDeDxHisto()->Projection(0); 
1213         his1D = his2D->ProjectionY(); 
1214         TF1 gausFunc("gausFunc","gaus");
1215         his1D->Fit(&gausFunc, "QN");
1216         meanMIPvsSector(i) = gausFunc.GetParameter(1);
1217         sector(i)=i;
1218         //removedtotest// delete his1D;
1219     }
1220      //removedtotest// delete his2D;
1221     //
1222     pTPCgain->GetDeDxHisto()->GetAxis(5)->SetRangeUser(0,3); // A side
1223     if (pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_a_0_1") && !fgForceTHnSparse) {    
1224         his2D = dynamic_cast<TH2*>(pTPCgain->GetHistos()->FindObject("h_tpc_dedx_mips_a_0_1")->Clone());
1225     } else {
1226         his2D =  pTPCgain->GetDeDxHisto()->Projection(0,1);
1227     }    
1228     if(!his2D) return 4; 
1229
1230     for(Int_t i = 0; i < 18; i++) { // loop over sectors; correct mapping to be checked!
1231         //TH1* his1D=0;
1232         Float_t phiLow = -TMath::Pi() + i*(20./360.)*(2*TMath::Pi());
1233         Float_t phiUp    = -TMath::Pi() + (i+1)*(20./360.)*(2*TMath::Pi());
1234         //pTPCgain->GetDeDxHisto()->GetAxis(1)->SetRangeUser(phiLow,phiUp);
1235         his2D->GetXaxis()->SetRangeUser(phiLow,phiUp);
1236         //his1D = pTPCgain->GetDeDxHisto()->Projection(0);
1237         his1D = his2D->ProjectionY();
1238         TF1 gausFunc("gausFunc","gaus");
1239         his1D->Fit(&gausFunc, "QN");
1240         meanMIPvsSector(i+18) = gausFunc.GetParameter(1);
1241         sector(i+18)=i+18;
1242         //removedtotest// delete his1D;
1243     }
1244      //removedtotest// delete his2D;
1245     //
1246     printf("Gain QA report\n");
1247     printf("MIP mean\t%f\n",meanMIP);
1248     printf("MIP resolution\t%f\n",resolutionMIP);
1249     printf("MIPslopeA\t%f\n",attachSlopeA);
1250     printf("MIPslopeC\t%f\n",attachSlopeC);
1251     // 
1252     
1253     (*pcstream)<<"tpcQA"<<
1254         "MIPattachSlopeC="<<attachSlopeC<<
1255         "MIPattachSlopeA="<<attachSlopeA<<
1256         "resolutionMIP="<<resolutionMIP<<
1257         "meanMIPvsSector.="<<&meanMIPvsSector<<
1258         "sector.="<<&sector<<
1259         "meanMIP="<<meanMIP;
1260
1261     return 0;
1262 }
1263
1264 //_____________________________________________________________________________
1265 Int_t AliTPCPerformanceSummary::AnalyzeEvent(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
1266 {
1267     //
1268     // Analyse Primary Vertex Distribution and Multiplicities
1269     //
1270   if (!pcstream) return 1;
1271     if (!pTPC) return 1;
1272     //
1273     // 
1274     //
1275     static Double_t meanVertX=0;
1276     static Double_t rmsVertX=0;
1277     static Double_t meanVertY=0;
1278     static Double_t rmsVertY=0;
1279     static Double_t meanVertZ=0;
1280     static Double_t rmsVertZ=0;
1281     static Double_t vertStatus=0;
1282     static Double_t meanMult=0;
1283     static Double_t rmsMult=0;
1284     static Double_t meanMultPos=0;
1285     static Double_t rmsMultPos=0;
1286     static Double_t meanMultNeg=0;
1287     static Double_t rmsMultNeg=0;
1288     static Double_t vertAll = 0;
1289     static Double_t vertOK = 0;
1290     
1291     TH1* his1D=0;
1292     if (pTPC->GetHistos()->FindObject("h_tpc_event_6") && !fgForceTHnSparse) {    
1293         his1D = dynamic_cast<TH1*>(pTPC->GetHistos()->FindObject("h_tpc_event_6")->Clone());
1294     } else {
1295        his1D = pTPC->GetTPCEventHisto()->Projection(6);
1296     }
1297     if(!his1D) return 1;
1298
1299     vertAll = his1D->GetEntries();
1300     vertOK  = his1D->GetBinContent(2);
1301     if (vertAll>=1) {
1302             vertStatus = vertOK / vertAll;
1303     }
1304     
1305     delete his1D;
1306     
1307     pTPC->GetTPCEventHisto()->GetAxis(6)->SetRange(2,2);
1308    
1309     if (pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_0") && !fgForceTHnSparse) {    
1310         his1D = dynamic_cast<TH1*>(pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_0")->Clone());
1311     } else {
1312        his1D = pTPC->GetTPCEventHisto()->Projection(0);
1313     }
1314     if(!his1D) return 1;
1315
1316     meanVertX = his1D->GetMean();    
1317     rmsVertX    = his1D->GetRMS();
1318     delete his1D;
1319     
1320     
1321     
1322     
1323     if (pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_1") && !fgForceTHnSparse) {    
1324         his1D = dynamic_cast<TH1*>(pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_1")->Clone());
1325     } else {
1326        his1D = pTPC->GetTPCEventHisto()->Projection(1);
1327     }
1328     if(!his1D) return 1;
1329
1330     meanVertY = his1D->GetMean();
1331     rmsVertY    = his1D->GetRMS();
1332     delete his1D;
1333     
1334     
1335     if (pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_2") && !fgForceTHnSparse) {    
1336         his1D = dynamic_cast<TH1*>(pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_2")->Clone());
1337     } else {
1338        his1D = pTPC->GetTPCEventHisto()->Projection(2);
1339     }    meanVertZ = his1D->GetMean();
1340     if(!his1D) return 1;
1341
1342     rmsVertZ    = his1D->GetRMS();
1343     delete his1D;
1344     
1345     
1346     if (pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_3") && !fgForceTHnSparse) {    
1347         his1D = dynamic_cast<TH1*>(pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_3")->Clone());
1348     } else {
1349        his1D = pTPC->GetTPCEventHisto()->Projection(3);
1350     }
1351     if(!his1D) return 1;
1352
1353     meanMult    = his1D->GetMean();
1354     rmsMult     = his1D->GetRMS();
1355     delete his1D;
1356     
1357     
1358     if (pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_4") && !fgForceTHnSparse) {    
1359         his1D = dynamic_cast<TH1*>(pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_4")->Clone());
1360     } else {
1361        his1D = pTPC->GetTPCEventHisto()->Projection(4);
1362     }
1363     if(!his1D) return 1;
1364
1365     meanMultPos    = his1D->GetMean();
1366     rmsMultPos     = his1D->GetRMS();
1367     delete his1D;
1368     
1369     if (pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_5") && !fgForceTHnSparse) {    
1370         his1D = dynamic_cast<TH1*>(pTPC->GetHistos()->FindObject("h_tpc_event_recvertex_5")->Clone());
1371     } else {
1372        his1D = pTPC->GetTPCEventHisto()->Projection(5);
1373     }
1374     if(!his1D) return 1;
1375
1376     meanMultNeg    = his1D->GetMean();
1377     rmsMultNeg     = his1D->GetRMS();
1378     delete his1D;
1379     
1380     pTPC->GetTPCEventHisto()->GetAxis(6)->SetRange(1,2);
1381     //
1382     (*pcstream)<<"tpcQA"<<
1383         "meanVertX="<<meanVertX<<
1384         "rmsVertX="<<rmsVertX<<
1385         "meanVertY="<<meanVertY<<
1386         "rmsVertY="<<rmsVertY<<
1387         "meanVertZ="<<meanVertZ<<
1388         "rmsVertZ="<<rmsVertZ<<
1389         "vertStatus="<<vertStatus<<
1390         "vertAll="<<vertAll<<
1391         "vertOK="<<vertOK<<
1392         "meanMult="<<meanMult<<
1393         "rmsMult="<<rmsMult<<
1394         "meanMultPos="<<meanMultPos<<
1395         "rmsMultPos="<<rmsMultPos<<
1396         "meanMultNeg="<<meanMultNeg<<
1397         "rmsMultNeg="<<rmsMultNeg;     
1398      
1399     return 0;
1400 }
1401
1402 //_____________________________________________________________________________
1403 Int_t AliTPCPerformanceSummary::AnalyzePt(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream)
1404 {
1405     //
1406     // Analyse DCA R imperfections for positive particles
1407     //
1408     
1409     if (!pcstream) return 256;
1410     if (!pTPC) return 256;
1411
1412     // variables:
1413     static Double_t meanPtAPos = 0;
1414     static Double_t mediumPtAPos = 0;
1415     static Double_t highPtAPos = 0;
1416     static Double_t meanPtCPos = 0;
1417     static Double_t mediumPtCPos = 0;
1418     static Double_t highPtCPos = 0;
1419
1420     static Double_t meanPtANeg = 0;
1421     static Double_t mediumPtANeg = 0;
1422     static Double_t highPtANeg = 0;
1423     static Double_t meanPtCNeg = 0;
1424     static Double_t mediumPtCNeg = 0;
1425     static Double_t highPtCNeg = 0;
1426
1427     TH3* his3D1=0;
1428     TH3* his3D2=0;
1429     
1430     if (pTPC->GetHistos()->FindObject("h_tpc_track_pos_recvertex_3_5_7")) {    
1431
1432       his3D1 = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_pos_recvertex_3_5_7"));
1433       if(!his3D1) return 256;
1434         
1435       his3D1->GetYaxis()->SetRangeUser(0.1,0.8);
1436       
1437       his3D1->GetZaxis()->SetRangeUser(0.25,10);
1438       meanPtAPos = his3D1->GetMean(3);
1439       his3D1->GetZaxis()->SetRangeUser(2,5);
1440       mediumPtAPos = his3D1->GetMean(3);
1441       his3D1->GetZaxis()->SetRangeUser(5,10);
1442       highPtAPos = his3D1->GetMean(3);
1443       
1444       his3D1->GetYaxis()->SetRangeUser(-0.8,-0.1);
1445
1446       his3D1->GetZaxis()->SetRangeUser(0.25,10);
1447       meanPtCPos = his3D1->GetMean(3);
1448       his3D1->GetZaxis()->SetRangeUser(2,5);
1449       mediumPtCPos = his3D1->GetMean(3);
1450       his3D1->GetZaxis()->SetRangeUser(5,10);
1451       highPtCPos = his3D1->GetMean(3);
1452
1453       his3D1->GetYaxis()->SetRangeUser(-1,1);
1454       his3D1->GetZaxis()->SetRangeUser(0.25,10);
1455     }
1456
1457
1458     if (pTPC->GetHistos()->FindObject("h_tpc_track_neg_recvertex_3_5_7")) {    
1459
1460       his3D2 = dynamic_cast<TH3*>(pTPC->GetHistos()->FindObject("h_tpc_track_neg_recvertex_3_5_7"));
1461       if(!his3D2) return 256;
1462         
1463       his3D2->GetYaxis()->SetRangeUser(0.1,0.8);
1464
1465       his3D2->GetZaxis()->SetRangeUser(0.25,10);
1466       meanPtANeg = his3D2->GetMean(3);
1467       his3D2->GetZaxis()->SetRangeUser(2,5);
1468       mediumPtANeg = his3D2->GetMean(3);
1469       his3D2->GetZaxis()->SetRangeUser(5,10);
1470       highPtANeg = his3D2->GetMean(3);
1471       
1472       his3D2->GetYaxis()->SetRangeUser(-0.8,-0.1);
1473
1474       his3D2->GetZaxis()->SetRangeUser(0.25,10);
1475       meanPtCNeg = his3D2->GetMean(3);
1476       his3D2->GetZaxis()->SetRangeUser(2,5);
1477       mediumPtCNeg = his3D2->GetMean(3);
1478       his3D2->GetZaxis()->SetRangeUser(5,10);
1479       highPtCNeg = his3D2->GetMean(3);
1480       
1481       his3D2->GetYaxis()->SetRangeUser(-1,1);
1482       his3D2->GetZaxis()->SetRangeUser(0.25,10);
1483     }
1484
1485
1486
1487     // dump values
1488     //
1489     (*pcstream)<<"tpcQA"<<
1490       "meanPtAPos="<< meanPtAPos<<
1491       "mediumPtAPos="<< mediumPtAPos<<
1492       "highPtAPos="<< highPtAPos<<
1493       //
1494       "meanPtCPos="<< meanPtCPos<<
1495       "mediumPtCPos="<< mediumPtCPos<<
1496       "highPtCPos="<< highPtCPos<<
1497       //
1498       "meanPtANeg="<< meanPtANeg<<
1499       "mediumPtANeg="<< mediumPtANeg<<
1500       "highPtANeg="<< highPtANeg<<
1501         //
1502       "meanPtCNeg="<< meanPtCNeg<<
1503       "mediumPtCNeg="<< mediumPtCNeg<<
1504       "highPtCNeg="<< highPtCNeg;
1505
1506         
1507     return 0;
1508 }
1509
1510 //_____________________________________________________________________________
1511
1512 Int_t AliTPCPerformanceSummary::AnalyzeChargeOverPt(const AliPerformanceTPC* pTPC, TTreeSRedirector* const pcstream){
1513     //
1514     // Analyse DCA R imperfections for positive particles
1515     //
1516     
1517     if (!pcstream) return 512;
1518     if (!pTPC) return 512;
1519
1520     // variables:
1521     static Double_t qOverPt = 0;
1522     static Double_t qOverPtA = 0;
1523     static Double_t qOverPtC = 0;
1524
1525     TH2* his2D=0;
1526     TH1* his1D1=0;
1527     TH1* his1D2=0;
1528     TH1* his1D3=0;
1529     TF1 *fp1 = new TF1("fp1","pol2",-1.0,1.0);
1530     TF1 *fp2 = new TF1("fp2","pol2",-1.0,1.0);
1531     TF1 *fp3 = new TF1("fp3","pol2",-1.0,1.0);
1532     
1533     if (pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_5_8")) {
1534
1535       his2D = dynamic_cast<TH2*>(pTPC->GetHistos()->FindObject("h_tpc_track_all_recvertex_5_8"));
1536       if(!his2D) return 512;
1537
1538       his1D1 = his2D->ProjectionX();
1539       his1D1->Fit(fp1,"R");
1540       if(fp1->GetParameter(2)!=0){
1541         qOverPt = (-1.0)*(fp1->GetParameter(1)/(2.0*fp1->GetParameter(2)));
1542        }
1543       delete fp1;
1544       delete his1D1;
1545
1546        his2D->GetYaxis()->SetRangeUser(0.1,0.8);
1547        his1D2 = his2D->ProjectionX();
1548        his1D2->Fit(fp2,"R");
1549        if(fp2->GetParameter(2)!=0)
1550          qOverPtA = (-1.0)*(fp2->GetParameter(1)/(2.0*fp2->GetParameter(2)));
1551        delete fp2;
1552        delete his1D2;
1553      
1554        his2D->GetYaxis()->SetRangeUser(-0.8,-0.1);       
1555        his1D3 = his2D->ProjectionX();
1556        his1D3->Fit(fp3,"R");
1557        if(fp3->GetParameter(2)!=0)
1558          qOverPtC = (-1.0)*(fp3->GetParameter(1)/(2.0*fp3->GetParameter(2)));
1559        delete fp3;
1560        delete his1D3;
1561        
1562       his2D->GetYaxis()->SetRangeUser(-1.0,1.0);
1563     }
1564     
1565     
1566     (*pcstream)<<"tpcQA"<<
1567       "qOverPt="<< qOverPt<<
1568       "qOverPtA="<< qOverPtA<<
1569       "qOverPtC="<< qOverPtC;
1570     
1571     return 0;
1572 }
1573
1574 void AliTPCPerformanceSummary::AnalyzeMatch(const AliPerformanceMatch* pMatch, TTreeSRedirector* const pcstream)
1575 {
1576  if ((pMatch == 0) or (0 == pcstream)) { printf("this will not work anyway..."); }
1577  printf("funtion not implemented");
1578 }