]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSPrintRecPoints.C
Improved treatment of dead areas in track chi2 calculation (A. Dainese)
[u/mrichter/AliRoot.git] / ITS / AliITSPrintRecPoints.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include<Riostream.h>
3 #include<TROOT.h>
4 #include<TClassTable.h>
5 #include<TClonesArray.h>
6 #include<TGeoManager.h>
7 #include <TInterpreter.h>
8 #include<TTree.h>
9 #include "AliRun.h"
10 #include "AliITSgeom.h"
11 #include "AliGeomManager.h"
12 #include "AliITSDetTypeRec.h"
13 #include "AliITSRecPoint.h"
14 #include "AliITSdigit.h"
15 #include "AliITSdigitSSD.h"
16 #include "AliITShit.h"
17 #include "AliITSmodule.h" 
18 #include "AliITSsegmentation.h"
19 #include "AliITSsegmentationSPD.h" 
20 #include "AliITSsegmentationSDD.h"
21 #include "AliITSsegmentationSSD.h"
22 #include "AliRunLoader.h"
23 #include "AliITSLoader.h"
24 #include "AliHeader.h"
25 #include "AliCDBManager.h"
26 #include "AliCDBStorage.h"
27 #endif
28 void AliITSPrintRecPoints(Int_t outtype=1,TString rfn="galice.root",
29                           Int_t mod=-1,Int_t evnt=-1){
30   // Macro to print out the recpoints for all or a specific module
31
32   // Dynamically link some shared libs
33   if (gClassTable->GetID("AliRun") < 0) {
34     gInterpreter->ExecuteMacro("loadlibs.C");
35   }
36   else {
37     if(gAlice){
38       delete AliRunLoader::Instance();
39       delete gAlice;
40       gAlice=0;
41     }
42   }
43
44   // Set OCDB if needed
45   AliCDBManager* man = AliCDBManager::Instance();
46   if (!man->IsDefaultStorageSet()) {
47     printf("Setting a local default storage and run number 0\n");
48     man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
49     man->SetRun(0);
50   }
51   else {
52     printf("Using deafult storage \n");
53   }
54
55   AliRunLoader* rl = AliRunLoader::Open(rfn.Data());
56   if (rl == 0x0){
57     cerr<<"AliITSPrintRecPoints.C : Can not open session RL=NULL"<< endl;
58     return;
59   }
60   Int_t retval = rl->LoadgAlice();
61   if (retval){
62     cerr<<"AliITSPrintRecPoints.C : LoadgAlice returned error"<<endl;
63     return;
64   }
65   gAlice=rl->GetAliRun();
66
67   retval = rl->LoadHeader();
68   if (retval){
69     cerr<<"AliITSPrintRecPoints.C : LoadHeader returned error"<<endl;
70     return;
71   }
72
73   AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
74
75   if(!ITSloader){
76     cerr<<"AliITSPrintRecPoints.C :  ITS loader not found"<<endl;
77     return;
78   }
79   cout <<"ITSloader ok"<<endl;
80
81   if(!gGeoManager){
82     AliGeomManager::LoadGeometry("geometry.root");
83   } 
84   ITSloader->LoadHits("read");
85   ITSloader->LoadDigits("read");
86   ITSloader->LoadRecPoints("read");
87   cout << "loaded hits, digits, and RecPoints"<< endl;
88  
89   AliITSgeom *gm=0;
90   gm = ITSloader->GetITSgeom();
91
92   Int_t evNumber1 = 0;
93   Int_t evNumber2 = AliRunLoader::GetNumberOfEvents();
94   if(evnt>=0){
95     evNumber1 = evnt;
96     evNumber2 = evnt+1;
97   } // end if evnt>=0
98   Int_t mod1 = 0;
99   Int_t mod2 = gm->GetIndexMax();
100   if(mod>=0){
101     mod1 = mod;
102     mod2 = mod+1;
103   } // end if mod>=0
104   TClonesArray *rpa;
105   AliITSRecPoint *rp = 0;
106   AliITSDetTypeRec* rec = new AliITSDetTypeRec();
107   rec->SetITSgeom(gm);
108   rec->SetDefaults();
109
110   Int_t event,m,i,i2;
111   Float_t xyz[3];
112   for(event = evNumber1; event < evNumber2; event++){
113     rl->GetEvent(event);
114     //    rec->SetTreeAddress();
115     for(m=mod1;m<mod2;m++){
116       rec->ResetRecPoints();
117       TTree *TR = ITSloader->TreeR();
118       rec->SetTreeAddressR(TR);
119       TR->GetEvent(m);
120       rpa = rec->RecPoints();
121       i2 = rpa->GetEntriesFast();
122       cout <<  "Event=" << event << " module=" << m <<
123         " Number of Recpoints=" << i2 <<endl;
124       for(i=0;i<i2;i++){
125           rp = (AliITSRecPoint*)(rpa->At(i));
126           switch(outtype){
127           case 1:
128               rp->GetGlobalXYZ(xyz);
129               cout << i << " lx=" << rp->GetDetLocalX() 
130                         << " lz=" << rp->GetDetLocalZ() 
131                    << " x=" << rp->GetX() 
132                    << " y=" << rp->GetY()<< " z=" << rp->GetZ() 
133                    <<" gx=" << xyz[0] << " gy="<< xyz[1] <<" gz="<<xyz[2]
134                    << endl;
135               break;
136           default:
137               cout << i << " ";
138               rp->Print();
139               cout << endl;
140               break;
141           } // end switch
142       } // end for i
143     } // end for m
144   } // end for event
145
146 }