B?\008New version from Gustavo
[u/mrichter/AliRoot.git] / ITS / AliITSVertexerZTest.C
CommitLineData
1621ded2 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TFile.h>
3#include <TH1F.h>
4#include <TH2F.h>
5#include <TTree.h>
6#include <Riostream.h>
7#include <AliRun.h>
8#include <AliHeader.h>
9#include <AliGenEventHeader.h>
10#include <AliITSVertexerPPZ.h>
88cb7938 11#include <AliRunLoader.h>
12#include <AliITSLoader.h>
1621ded2 13
14#endif
15
88cb7938 16void AliITSVertexerZTest(Float_t delphi=0.05,Float_t window=3.,Float_t initx=0., Float_t inity=0.,TString FileIn="galice.root"){
1621ded2 17 // delphi ---> azimuthal range to accept tracklets
18 // window ---> window in Z around the peak of tracklets proj. in mm
88cb7938 19 Int_t kDebug = 50;
1621ded2 20 TH2F *diff2 = new TH2F("diff2","Zfound vs Ztrue",100,-6,6,100,-6,6);
21 TH1F *diff1 = new TH1F("diff1","Zfound - Ztrue(#mu m)",100,-500,500);
22 delete gAlice;
23 gAlice = 0;
88cb7938 24 AliRunLoader *rl = AliRunLoader::Open(FileIn.Data());
25 Int_t retval = rl->LoadgAlice();
26 if(retval){
27 cerr<<"AliITSVertexerZTest.C: AliRun object not found"<<endl;
28 return;
29 }
30 retval = rl->LoadHeader();
31 if (retval){
32 cerr<<"AliITSVertexerZTest.C : LoadHeader returned error"<<endl;
33 return;
34 }
35 retval = rl->LoadKinematics();
36 if (retval){
37 cerr<<"AliITSVertexerZTest.C : LoadKinematics returned error"<<endl;
38 return;
39 }
40 AliITSLoader* ITSloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
41
42 if(!ITSloader){
43 cerr<<"AliITSVertexerZTest.C : ITS loader not found"<<endl;
44 return;
45 }
46 // ITSloader->LoadRecPoints("read");
47 // TFile *fo = new TFile("vertici.root","recreate");
98ca44ad 48 // AliITSVertexerPPZ *dovert = new AliITSVertexerPPZ("default",initx,inity);
49 AliITSVertexerZ *dovert = new AliITSVertexerZ("default",initx,inity);
1621ded2 50 dovert->SetDebug(0);
98ca44ad 51 // dovert->SetDiffPhiMax(delphi);
52 // dovert->SetWindow(window);
1621ded2 53 dovert->PrintStatus();
1621ded2 54 Int_t sigmazero=0;
2e7b4767 55 AliESDVertex *vert = 0;
88cb7938 56 for(Int_t i=0; i<rl->TreeE()->GetEntries(); i++){
57 rl->GetEvent(i);
1621ded2 58 // The true Z coord. is fetched for comparison
88cb7938 59 AliHeader *header = rl->GetHeader();
1621ded2 60 AliGenEventHeader* genEventHeader = header->GenEventHeader();
61 TArrayF primaryVertex(3);
62 genEventHeader->PrimaryVertex(primaryVertex);
63 vert = dovert->FindVertexForCurrentEvent(i);
64 if(kDebug>0){
65 // Prints the results
66 cout <<"========================================================\n";
67 cout << "Event number: "<<i<<") Z Vertex:"<<endl;
68 if(vert){
69 cout<<"FOUND: "<<vert->GetZv()<<"; ";
70 cout<<vert->GetZRes()<<"; "<<vert->GetNContributors()<<endl;
98ca44ad 71 cout <<" True Z position "<<primaryVertex[2]<<", diff= ";
72 cout<<(primaryVertex[2]-vert->GetZv())*10000.<<endl;
73 } else {
74 cout<<"NOT FOUND"<<endl;
1621ded2 75 }
1621ded2 76 }
77 if(vert){
78 Double_t pos[3];
79 for(Int_t kk=0;kk<3;kk++)pos[kk]=(Double_t)primaryVertex[kk];
80 vert->SetTruePos(pos);
81 Float_t found = vert->GetZv();
82 diff2->Fill(primaryVertex[2],found);
83 found = 10000.*(found-primaryVertex[2]);
84 if(vert->GetZRes()!=0){
85 diff1->Fill(found);
98ca44ad 86 } else {
1621ded2 87 sigmazero++;
88 }
89 dovert->WriteCurrentVertex();
90 }
91 }
1621ded2 92 if(kDebug>0){
1621ded2 93 cout<<"Only one tracklet (sigma = 0) "<<sigmazero<<endl;
94 }
98ca44ad 95
1621ded2 96}