update for the NUA
[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>
53ae21ce 11#include <AliGeomManager.h>
7299b7a8 12#include <AliITSVertexerZ.h>
88cb7938 13#include <AliRunLoader.h>
14#include <AliITSLoader.h>
1621ded2 15
16#endif
17
88cb7938 18void AliITSVertexerZTest(Float_t delphi=0.05,Float_t window=3.,Float_t initx=0., Float_t inity=0.,TString FileIn="galice.root"){
1621ded2 19 // delphi ---> azimuthal range to accept tracklets
20 // window ---> window in Z around the peak of tracklets proj. in mm
88cb7938 21 Int_t kDebug = 50;
1621ded2 22 TH2F *diff2 = new TH2F("diff2","Zfound vs Ztrue",100,-6,6,100,-6,6);
23 TH1F *diff1 = new TH1F("diff1","Zfound - Ztrue(#mu m)",100,-500,500);
24 delete gAlice;
25 gAlice = 0;
88cb7938 26 AliRunLoader *rl = AliRunLoader::Open(FileIn.Data());
27 Int_t retval = rl->LoadgAlice();
28 if(retval){
29 cerr<<"AliITSVertexerZTest.C: AliRun object not found"<<endl;
30 return;
31 }
32 retval = rl->LoadHeader();
33 if (retval){
34 cerr<<"AliITSVertexerZTest.C : LoadHeader returned error"<<endl;
35 return;
36 }
37 retval = rl->LoadKinematics();
38 if (retval){
39 cerr<<"AliITSVertexerZTest.C : LoadKinematics returned error"<<endl;
40 return;
41 }
7f9c356a 42
43 AliGeomManager::LoadGeometry("geometry.root");
88cb7938 44
308c2f7c 45 AliITSVertexerZ *dovert = new AliITSVertexerZ(initx,inity);
46 dovert->Init("default");
7f9c356a 47 //dovert->SetDebug(0);
98ca44ad 48 // dovert->SetDiffPhiMax(delphi);
49 // dovert->SetWindow(window);
1621ded2 50 dovert->PrintStatus();
1621ded2 51 Int_t sigmazero=0;
2e7b4767 52 AliESDVertex *vert = 0;
308c2f7c 53 AliITSLoader* itsloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
54 itsloader->LoadRecPoints("read");
88cb7938 55 for(Int_t i=0; i<rl->TreeE()->GetEntries(); i++){
56 rl->GetEvent(i);
1621ded2 57 // The true Z coord. is fetched for comparison
88cb7938 58 AliHeader *header = rl->GetHeader();
1621ded2 59 AliGenEventHeader* genEventHeader = header->GenEventHeader();
60 TArrayF primaryVertex(3);
61 genEventHeader->PrimaryVertex(primaryVertex);
308c2f7c 62 TTree* cltree = itsloader->TreeR();
63 vert = dovert->FindVertexForCurrentEvent(cltree);
1621ded2 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){
1621ded2 78 Float_t found = vert->GetZv();
79 diff2->Fill(primaryVertex[2],found);
80 found = 10000.*(found-primaryVertex[2]);
81 if(vert->GetZRes()!=0){
82 diff1->Fill(found);
98ca44ad 83 } else {
1621ded2 84 sigmazero++;
85 }
86 dovert->WriteCurrentVertex();
87 }
88 }
1621ded2 89 if(kDebug>0){
1621ded2 90 cout<<"Only one tracklet (sigma = 0) "<<sigmazero<<endl;
91 }
98ca44ad 92
1621ded2 93}