technial fix to suppress the warning
[u/mrichter/AliRoot.git] / ITS / testITSMultReco.C
CommitLineData
ac903f1b 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
3#include <Riostream.h>
4#include <TFile.h>
5#include <TTree.h>
968e8539 6#include <TGeoManager.h>
ac903f1b 7
8#include "AliRunLoader.h"
ac903f1b 9#include "AliRun.h"
ee9b73fc 10#include "AliESDEvent.h"
ac903f1b 11
ac903f1b 12#include "AliITSLoader.h"
13#include "AliITSMultReconstructor.h"
ee9b73fc 14#include "AliGeomManager.h"
ac903f1b 15
16#endif
17
ee9b73fc 18 void testITSMultReco(Char_t* dir = ".") {
ac903f1b 19
ee9b73fc 20 Char_t fileName[256];
ac903f1b 21
ac903f1b 22 // defining pointers
23 AliRunLoader* runLoader;
ac903f1b 24 TTree* esdTree = 0;
ee9b73fc 25 AliESDEvent* esd = new AliESDEvent();
ac903f1b 26
968e8539 27 // get runloader
ac903f1b 28
29 if (gAlice) {
33c3c91a 30 delete AliRunLoader::Instance();
ac903f1b 31 delete gAlice;
32 gAlice=0;
33 }
34
ee9b73fc 35 sprintf(fileName,"%s/galice.root",dir);
36 runLoader = AliRunLoader::Open(fileName);
37/* if (runLoader == 0x0) {
ac903f1b 38 cout << "Can not open session"<<endl;
39 return;
ee9b73fc 40 }*/
41
968e8539 42 // get geometry (here geometry.root is used, change it if needed)
43 if (!gGeoManager) {
ee9b73fc 44 sprintf(fileName,"%s/geometry.root",dir);
45 AliGeomManager::LoadGeometry(fileName);
968e8539 46 }
ac903f1b 47
ee9b73fc 48 // open the ESD file and get the tree
ac903f1b 49
ee9b73fc 50 sprintf(fileName,"%s/AliESDs.root",dir);
51 TFile esdFile(fileName, "READ");
52 esdTree = (TTree*)esdFile.Get("esdTree");
53 esd->ReadFromTree(esdTree);
ac903f1b 54
ee9b73fc 55 // setup ITS stuff
ac903f1b 56
ac903f1b 57 AliITSLoader* itsLoader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
58 if (!itsLoader) {
59 cout << " Can't get the ITS loader!" << endl;
60 return ;
61 }
62 itsLoader->LoadRecPoints("read");
63
ac903f1b 64 AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
ee9b73fc 65// multReco->SetGeometry(itsGeo);
ac903f1b 66
ac903f1b 67 // getting number of events
68
69 Int_t nEvents = (Int_t)runLoader->GetNumberOfEvents();
ee9b73fc 70 Int_t nESDEvents = esdTree->GetEntries();
ac903f1b 71
72 if (nEvents!=nESDEvents) {
73 cout << " Different number of events from runloader and esdtree!!!"
74 << nEvents << " / " << nESDEvents << endl;
75 return;
76 }
77
ac903f1b 78 // loop over number of events
79 cout << nEvents << " event(s) found in the file set" << endl;
ee9b73fc 80 for (Int_t iEv=0; iEv<nEvents; ++iEv) {
ac903f1b 81
ee9b73fc 82 cout << "-------------------------" << endl << " event# " << iEv << endl;
ac903f1b 83
ee9b73fc 84 runLoader->GetEvent(iEv);
85 esdTree->GetEvent(iEv);
86
87 // get the ESD vertex
ac903f1b 88
ac903f1b 89 const AliESDVertex* vtxESD = esd->GetVertex();
90 Double_t vtx[3];
91 vtxESD->GetXYZ(vtx);
92 Float_t esdVtx[3];
93 esdVtx[0] = vtx[0];
94 esdVtx[1] = vtx[1];
95 esdVtx[2] = vtx[2];
ee9b73fc 96// cout<<"vertex Z->"<<esdVtx[2]<<endl;
97
ac903f1b 98 // get ITS clusters
ee9b73fc 99
ac903f1b 100 TTree* itsClusterTree = itsLoader->TreeR();
101 if (!itsClusterTree) {
102 cerr<< " Can't get the ITS cluster tree !\n";
103 return;
104 }
ee9b73fc 105
ac903f1b 106 multReco->SetHistOn(kTRUE);
107 multReco->Reconstruct(itsClusterTree, esdVtx, esdVtx);
108
ee9b73fc 109 cout <<"Number of tracklets: "<<multReco->GetNTracklets()<<endl;
110 for (Int_t itr=0; itr<multReco->GetNTracklets(); itr++) {
ac903f1b 111
ee9b73fc 112 cout << " tracklet " << itr
113 << " , theta = " << multReco->GetTracklet(itr)[0]
114 << " , phi = " << multReco->GetTracklet(itr)[1]
115 << " , DeltaPhi = " << multReco->GetTracklet(itr)[2]<< endl;
116
968e8539 117 }
ee9b73fc 118 cout<<""<<endl;
119 cout <<"Number of single clusters (inner layer): "<<multReco->GetNSingleClusters()<<endl;
120 for (Int_t iscl=0; iscl<multReco->GetNSingleClusters(); iscl++) {
968e8539 121
ee9b73fc 122 cout << " cluster " << iscl
123 << " , theta = " << multReco->GetCluster(iscl)[0]
124 << " , phi = " << multReco->GetCluster(iscl)[1] << endl;
ac903f1b 125 }
126
127 }
128
129 TFile* fout = new TFile("out.root","RECREATE");
130
131 multReco->SaveHists();
132 fout->Write();
133 fout->Close();
134
135
880d6abe 136}