]>
Commit | Line | Data |
---|---|---|
58005f18 | 1 | void analITSgeom (const char *filename="galice.root",Int_t evNumber=0){ |
2 | ///////////////////////////////////////////////////////////////////////// | |
3 | // This macro is a small example of a ROOT macro | |
4 | // illustrating how to read the output of GALICE | |
5 | // and fill some histograms. | |
6 | // | |
7 | // Root > .L analITSgeom.C //this loads the macro in memory | |
8 | // Root > analITSgeom(); //by default process first event | |
9 | // Root > analITgeomS(2); //process third event | |
10 | //Begin_Html | |
11 | /* | |
12 | <img src="figures/analITSgeom_ref.gif"> | |
13 | </pre> | |
14 | <br clear=left> | |
15 | <font size=+2 color=red> | |
16 | <p>A reference plot produced by analITSgeom.C. | |
17 | </font> | |
18 | <pre> | |
19 | */ | |
20 | //End_Html | |
21 | ///////////////////////////////////////////////////////////////////////// | |
22 | ||
23 | ||
24 | // Dynamically link some shared libs | |
25 | if (gClassTable->GetID("AliRun") < 0) { | |
26 | gROOT->LoadMacro("loadlibs.C"); | |
27 | loadlibs(); | |
28 | } // end if gClassTable... | |
29 | ||
30 | // Connect the Root Galice file containing Geometry, Kine and Hits | |
31 | TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename); | |
32 | if (!file) file = new TFile(filename); | |
33 | ||
34 | // Get AliRun object from file or create it if not on file | |
35 | if (!gAlice) { | |
36 | gAlice = (AliRun*)file->Get("gAlice"); | |
37 | if (gAlice) printf("AliRun object found on file\n"); | |
38 | if (!gAlice) gAlice = new AliRun("gAlice","Alice test program"); | |
39 | } | |
40 | ||
41 | // Import the Kine and Hits Trees for the event evNumber in the file | |
42 | Int_t nparticles = gAlice->GetEvent(evNumber); | |
43 | if (nparticles <= 0) return; | |
44 | Float_t x,y,z,mass,e,r,phi,flad; | |
45 | Int_t nbytes = 0; | |
46 | Int_t j,hit,ipart,lay; | |
47 | Int_t nhits; | |
48 | Int_t sector,plane; | |
49 | TParticle *particle; | |
50 | AliITShit *itsHit; | |
51 | ||
52 | // Get pointers to Alice detectors and Hits containers | |
53 | AliDetector *ITS = gAlice->GetDetector("ITS"); | |
54 | if(!ITS) return; | |
55 | TClonesArray *Particles = gAlice->Particles(); | |
56 | TClonesArray *ITShits = ITS->Hits(); | |
57 | AliITSgeom *gm = ((AliITS *)ITS)->GetITSgeom(); | |
58 | ||
59 | TTree *TH = gAlice->TreeH(); | |
60 | Int_t ntracks = TH->GetEntries(); | |
61 | ||
62 | // Create histograms | |
63 | Float_t pi2 = 2.0*TMath::Pi(); | |
64 | Int_t Nlad = gm->GetNladders(1); | |
65 | TH2F *hITS1 = new TH2F("hITS1","Ladder# vs. angle for Layer 1", | |
66 | Nlad,0.5,(Float_t)Nlad+0.5,100,0.0,pi2); | |
67 | Int_t Nlad = gm->GetNladders(2); | |
68 | TH2F *hITS2 = new TH2F("hITS2","Ladder# vs. angle for Layer 2", | |
69 | Nlad,0.5,(Float_t)Nlad+0.5,100,0.0,pi2); | |
70 | Int_t Nlad = gm->GetNladders(3); | |
71 | TH2F *hITS3 = new TH2F("hITS3","Ladder# vs. angle for Layer 3", | |
72 | Nlad,0.5,(Float_t)Nlad+0.5,100,0.0,pi2); | |
73 | Int_t Nlad = gm->GetNladders(4); | |
74 | TH2F *hITS4 = new TH2F("hITS4","Ladder# vs. angle for Layer 4", | |
75 | Nlad,0.5,(Float_t)Nlad+0.5,100,0.0,pi2); | |
76 | Int_t Nlad = gm->GetNladders(5); | |
77 | TH2F *hITS5 = new TH2F("hITS5","Ladder# vs. angle for Layer 5", | |
78 | Nlad,0.5,(Float_t)Nlad+0.5,100,0.0,pi2); | |
79 | Int_t Nlad = gm->GetNladders(6); | |
80 | TH2F *hITS6 = new TH2F("hITS6","Ladder# vs. angle for Layer 6", | |
81 | Nlad,0.5,(Float_t)Nlad+0.5,100,0.0,pi2); | |
82 | ||
83 | // Start loop on tracks in the hits containers | |
84 | for (Int_t track=0; track<ntracks;track++) { | |
85 | gAlice->ResetHits(); | |
86 | nbytes += TH->GetEvent(track); | |
87 | Int_t i=0; | |
88 | nhits = ITShits->GetEntriesFast(); | |
89 | for (hit=0;hit<nhits;hit++) { | |
90 | itsHit = (AliITShit*)ITShits->UncheckedAt(hit); | |
91 | // With this new version, to be able to do proper detector | |
92 | // simulations, the requirment that a "hit" leave some | |
93 | // energy deposited has been removed. | |
94 | if(itsHit->GetIonization()<=0.0) continue; | |
95 | phi = TMath::ATan2(itsHit->GetYG(),itsHit->GetXG()); | |
96 | if(phi<0.0) phi += pi2; | |
97 | lay = itsHit->GetLayer(); | |
98 | flad = ((Float_t)itsHit->GetLadder()) + 0.5; | |
99 | if(lay==1) hITS1->Fill(flad,phi,1.0); | |
100 | if(lay==2) hITS2->Fill(flad,phi,1.0); | |
101 | if(lay==3) hITS3->Fill(flad,phi,1.0); | |
102 | if(lay==4) hITS4->Fill(flad,phi,1.0); | |
103 | if(lay==5) hITS5->Fill(flad,phi,1.0); | |
104 | if(lay==6) hITS6->Fill(flad,phi,1.0); | |
105 | } // end for hit | |
106 | } // end for track | |
107 | ||
108 | //Create a canvas, set the view range, show histograms | |
109 | TCanvas *c1 = new TCanvas("c1"," ITS geometry test",400,10,600,700); | |
110 | c1->Divide(2,3); | |
111 | c1->cd(1); | |
112 | hITS1->Draw(); | |
113 | c1->cd(2); | |
114 | hITS2->Draw(); | |
115 | c1->cd(3); | |
116 | hITS3->Draw(); | |
117 | c1->cd(4); | |
118 | hITS4->Draw(); | |
119 | c1->cd(5); | |
120 | hITS5->Draw(); | |
121 | c1->cd(6); | |
122 | hITS6->Draw(); | |
123 | c1->Print("analITSgeom.gif"); | |
124 | } |