]>
Commit | Line | Data |
---|---|---|
66c3bd42 | 1 | // Test Macro, shows how to load Hits and Geometry, and how can we get |
2 | // some of the parameters and variables. | |
3 | // Author: Gustavo Conesa | |
4 | ||
5 | void TestEMCALHit() | |
6 | { | |
7 | ||
8 | // Getting EMCAL Detector and Geometry. | |
9 | ||
10 | AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read"); | |
11 | ||
12 | if (rl == 0x0) | |
13 | cout<<"Can not instatiate the Run Loader"<<endl; | |
14 | ||
15 | rl->LoadgAlice();//Needed to get geometry | |
16 | ||
17 | AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*> | |
18 | (rl->GetDetectorLoader("EMCAL")); | |
19 | ||
20 | TGeoManager::Import("geometry.root"); | |
21 | ||
22 | AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry | |
23 | AliEMCALGeometry * geom ; | |
24 | if(alirun){ | |
25 | AliEMCAL * emcal = (AliEMCAL*)alirun->GetDetector("EMCAL"); | |
26 | geom = emcal->GetGeometry(); | |
27 | } | |
28 | ||
29 | if (geom == 0) cout<<"Did not get geometry from EMCALLoader"<<endl; | |
30 | //else geom->PrintGeometry(); | |
31 | ||
32 | //Load Hits | |
33 | rl->LoadHits("EMCAL"); | |
34 | ||
35 | //Get maximum number of events | |
36 | Int_t maxevent = rl->GetNumberOfEvents(); | |
37 | cout<<"Number of events "<<maxevent<<endl; | |
38 | //maxevent = 8000 ; | |
39 | ||
40 | ||
41 | AliEMCALHit * hit; | |
42 | TClonesArray *hits = 0; | |
43 | ||
44 | for (Int_t iEvent=0; iEvent<maxevent; iEvent++) | |
45 | { | |
46 | //cout << " ======> Event " << iEvent <<endl ; | |
47 | //Load Event | |
48 | rl->GetEvent(iEvent); | |
49 | Float_t elos=-1; | |
50 | Float_t time = -1 ; | |
51 | Int_t id = -1 ; | |
52 | Int_t iSupMod = 0 ; | |
53 | Int_t iTower = 0 ; | |
54 | Int_t iIphi = 0 ; | |
55 | Int_t iIeta = 0 ; | |
56 | Int_t iphi = 0 ; | |
57 | Int_t ieta = 0 ; | |
58 | ||
59 | //Fill array of hits | |
60 | cout << " ======> Event " << iEvent << endl; | |
61 | ||
62 | ||
63 | //Get hits from the list | |
64 | ||
65 | //Hits are stored in different branches in the hits Tree, | |
66 | //first get the branch and then access the hits in the branch | |
67 | TTree *treeH = emcalLoader->TreeH(); | |
68 | if (treeH) { | |
69 | // TreeH exists, get the branch | |
70 | Int_t nTrack = treeH->GetEntries(); // TreeH has array of hits for every primary | |
71 | TBranch * branchH = treeH->GetBranch("EMCAL"); | |
72 | branchH->SetAddress(&hits); | |
73 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
74 | branchH->GetEntry(iTrack); | |
75 | //Now get the hits in this branch | |
76 | Int_t nHit = hits->GetEntriesFast(); | |
77 | for(Int_t ihit = 0; ihit< nHit;ihit++){ | |
78 | hit = static_cast<AliEMCALHit *>hits->At(ihit);//(hits->At(ihit)) ; | |
79 | ||
80 | if(hit != 0){ | |
81 | id = hit->GetId() ; //cell (hit) label | |
82 | elos = hit->GetEnergy(); //amplitude in cell (hit) | |
83 | time = hit->GetTime();//time of creation of hit after collision | |
84 | ||
85 | cout<<"Hit ID "<<id<<" ELoss "<<elos; | |
86 | ||
87 | //Geometry methods | |
88 | if(geom){ | |
89 | geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta); | |
90 | //Gives SuperModule and Tower numbers | |
91 | geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower, | |
92 | iIphi, iIeta,iphi,ieta); | |
93 | //Gives label of cell in eta-phi position per each supermodule | |
94 | // cout<< "SModule "<<iSupMod<<"; Tower "<<iTower <<"; Eta "<<iIeta | |
95 | //<<"; Phi "<<iIphi<<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl; | |
96 | cout<< "; SModule "<<iSupMod<<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl; | |
97 | }//geom? | |
98 | }//hit? | |
99 | else | |
100 | cout<<"Hit pointer 0x0"<<endl; | |
101 | }//hit loop | |
102 | }// track loop | |
103 | }//treeH? | |
104 | }//event loop | |
105 | } | |
106 |