Fix for the case of non-existent calibration files
[u/mrichter/AliRoot.git] / ITS / AliITSPrintRecPoints.C
CommitLineData
fe19926a 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
012f0f4c 28void AliITSPrintRecPoints(Int_t outtype=1,TString rfn="galice.root",
29 Int_t mod=-1,Int_t evnt=-1){
d2e7afa1 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) {
fe19926a 34 gInterpreter->ExecuteMacro("loadlibs.C");
35 }
d2e7afa1 36 else {
37 if(gAlice){
33c3c91a 38 delete AliRunLoader::Instance();
d2e7afa1 39 delete gAlice;
40 gAlice=0;
41 }
42 }
43
fe19926a 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");
162637e4 48 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
fe19926a 49 man->SetRun(0);
50 }
51 else {
52 printf("Using deafult storage \n");
53 }
d2e7afa1 54
fe19926a 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();
d2e7afa1 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 }
012f0f4c 79 cout <<"ITSloader ok"<<endl;
d2e7afa1 80
012f0f4c 81 if(!gGeoManager){
fe19926a 82 AliGeomManager::LoadGeometry("geometry.root");
83 }
d2e7afa1 84 ITSloader->LoadHits("read");
85 ITSloader->LoadDigits("read");
86 ITSloader->LoadRecPoints("read");
012f0f4c 87 cout << "loaded hits, digits, and RecPoints"<< endl;
fe19926a 88
012f0f4c 89 AliITSgeom *gm=0;
fe19926a 90 gm = ITSloader->GetITSgeom();
d2e7afa1 91
92 Int_t evNumber1 = 0;
880d6abe 93 Int_t evNumber2 = AliRunLoader::GetNumberOfEvents();
d2e7afa1 94 if(evnt>=0){
95 evNumber1 = evnt;
96 evNumber2 = evnt+1;
97 } // end if evnt>=0
98 Int_t mod1 = 0;
012f0f4c 99 Int_t mod2 = gm->GetIndexMax();
d2e7afa1 100 if(mod>=0){
101 mod1 = mod;
102 mod2 = mod+1;
103 } // end if mod>=0
104 TClonesArray *rpa;
105 AliITSRecPoint *rp = 0;
fe19926a 106 AliITSDetTypeRec* rec = new AliITSDetTypeRec();
107 rec->SetITSgeom(gm);
7d62fb64 108 rec->SetDefaults();
d2e7afa1 109
110 Int_t event,m,i,i2;
012f0f4c 111 Float_t xyz[3];
d2e7afa1 112 for(event = evNumber1; event < evNumber2; event++){
113 rl->GetEvent(event);
fe19926a 114 // rec->SetTreeAddress();
d2e7afa1 115 for(m=mod1;m<mod2;m++){
7d62fb64 116 rec->ResetRecPoints();
d2e7afa1 117 TTree *TR = ITSloader->TreeR();
fe19926a 118 rec->SetTreeAddressR(TR);
d2e7afa1 119 TR->GetEvent(m);
7d62fb64 120 rpa = rec->RecPoints();
d2e7afa1 121 i2 = rpa->GetEntriesFast();
122 cout << "Event=" << event << " module=" << m <<
123 " Number of Recpoints=" << i2 <<endl;
124 for(i=0;i<i2;i++){
012f0f4c 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 << " ";
fe19926a 138 rp->Print();
012f0f4c 139 cout << endl;
140 break;
141 } // end switch
d2e7afa1 142 } // end for i
143 } // end for m
144 } // end for event
c108b570 145
146}