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