T0 DAs + enable optimization for ITS
[u/mrichter/AliRoot.git] / ITS / AliITSspdLayer1Coverage.C
CommitLineData
16c4c064 1void AliITSspdLayer1Coverage(TString hfn="galice.root",Int_t mod=-1,
2 Int_t evnt=-1){
3 // Macro to show the coverage of each spd layer 1 module
4
5 // Dynamically link some shared libs
6 if (gClassTable->GetID("AliRun") < 0) {
7 gROOT->LoadMacro("loadlibs.C");
8 loadlibs();
9 } else {
10 if(gAlice){
33c3c91a 11 delete AliRunLoader::Instance();
16c4c064 12 delete gAlice;
13 gAlice=0;
14 }
15 }
16 gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSstandard.C");
17 // Set OCDB if needed
18 AliCDBManager* man = AliCDBManager::Instance();
19 if (!man->IsDefaultStorageSet()) {
20 printf("Setting a local default storage and run number 0\n");
162637e4 21 man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
16c4c064 22 man->SetRun(0);
23 }else {
24 printf("Using deafult storage \n");
25 }
26 // retrives geometry
27 TString geof(gSystem->DirName(hfn));
28 geof += "/geometry.root";
29 TGeoManager::Import(geof.Data());
30 if (!gGeoManager) {
31 cout<<"geometry not found\n";
32 return -1;
33 }
34
35
36 AliRunLoader *rl = AccessFile(hfn); // Set up to read in Data
37 Int_t retval = rl->LoadHeader();
38 if (retval){
39 cerr<<"AliITSPrintHits.C : LoadHeader returned error"<<endl;
40 return;
41 }
42
43 AliITSLoader* ITSloader = (AliITSLoader*) rl->GetLoader("ITSLoader");
44
45 if(!ITSloader){
46 cerr<<"AliITSPrintHits.C : ITS loader not found"<<endl;
47 return;
48 }
49
50 ITSloader->LoadHits("read");
51 AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
52 if(!ITS || ITS==0){
53 cout << "Error: no ITS found. Aborting"<<endl;
54 return;
55 } // end if !ITS
56 //cout << ITS << endl;
57 AliITSInitGeometry *initgeom = new AliITSInitGeometry(ITS->GetMajorVersion(),ITS->GetMinorVersion());
58 //cout << initgeom << endl;
59 AliITSgeom *geom = initgeom->CreateAliITSgeom();
60 if(!geom){
61 cout << "Error: not AliITSgeom object found."<<endl;
62 return;
63 } // end if geom
64 ITSloader->SetITSgeom(geom);
65
66 Int_t evNumber1 = 0;
880d6abe 67 Int_t evNumber2 = AliRunLoader::GetNumberOfEvents();
16c4c064 68 if(evnt>=0){
69 evNumber1 = evnt;
70 evNumber2 = evnt+1;
71 } // end if evnt>=0
72 Int_t mod1 = 0;
73 Int_t mod2 = geom->GetIndexMax();
74 if(mod>=0){
75 mod1 = mod;
76 mod2 = mod+1;
77 } // end if mod>=0
78 AliITShit *hp = 0;
79
80 Int_t i;
81 Double_t zbin[161];
82 for(i=0;i<161;i++) zbin[i] = 425.0E-4;
83 zbin[32] = zbin[64] = zbin[96] = zbin[128] = 625.0E-4;
84 zbin[0] = -3.536;
85 for(i=1;i<161;i++) zbin[i] += zbin[i-1];
86 Char_t name[20],title[40];
87 TH2I *detCoverage[4*2*10];
88 for(i=0;i<4*2*10;i++){
89 sprintf(name,"detCoverage[%d]",i);
90 sprintf(title,"Cell coverage for SPD module %d",i);
91 detCoverage[i] = new TH2I(name,title,160,(Double_t *)zbin,256,-0.64,+0.64);
92 } // end for i
93 Double_t xg,yg,zg,xl,yl,zl,phi;
94 Int_t nmodules,size=-1;
95 Int_t event,m,i,i2,hit,trk,lay,lad,det;
96 for(event = evNumber1; event < evNumber2; event++){
97 //cout<<"Processing event "<<event<<endl;
98 rl->GetEvent(event);
99 ITS->InitModules(size,nmodules);
100 ITS->FillModules(event,0,-1," "," ");
101 for(m=mod1;m<mod2;m++)if(geom->GetModuleType(m)==(AliITSDetector)(0)){
102 i2 = (ITS->GetModule(m))->GetNhits();
103 //cout << "Event=" << event << " module=" << m <<
104 // " Number of Hits=" << i2 <<endl;
105 for(i=0;i<i2;i++){
106 trk = (ITS->GetModule(m))->GetHitTrackIndex(i);
107 hit = (ITS->GetModule(m))->GetHitHitIndex(i);
108 hp = (ITS->GetModule(m))->GetHit(i);
109 hp->GetPositionG(xg,yg,zg);
110 hp->GetPositionL(xl,yl,zl);
111 geom->GetModuleId(m,lay,lad,det);
112 phi = TMath::ATan2(yg,xg)*TMath::RadToDeg();
113 if(phi<0.0) phi+=360.0;
114 switch(lay){
115 case 1:
116 detCoverage[m]->Fill(zl,xl,1.0);
117 break;
118 case 2:
119 break;
120 default:
121 } // end switch
122 } // end for i
123 } // end for m
124 ITS->ClearModules();
125 } // end for event
126 //
127 cout << "Creating pad"<<endl;
128 TVirtualPad *pad=0;
129 TCanvas *c0 = new TCanvas("c0","SPD Hits Tests",262,50,700,534);
130 c0->Divide(4,20,.0,0.0);
131 //
132 for(i=0;i<4*2*10;i++){
133 c0->cd(i+1);
134 detCoverage[i]->Draw();
135 } // end for i
136 c0->Update();
880d6abe 137}