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