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
8 // Getting EMCAL Detector and Geometry.
10 AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
13 cout<<"Can not instatiate the Run Loader"<<endl;
15 rl->LoadgAlice();//Needed to get geometry
17 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
18 (rl->GetDetectorLoader("EMCAL"));
20 TGeoManager::Import("geometry.root");
22 AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry
23 AliEMCALGeometry * geom ;
25 AliEMCAL * emcal = (AliEMCAL*)alirun->GetDetector("EMCAL");
26 geom = emcal->GetGeometry();
29 if (geom == 0) cout<<"Did not get geometry from EMCALLoader"<<endl;
30 //else geom->PrintGeometry();
33 rl->LoadHits("EMCAL");
35 //Get maximum number of events
36 Int_t maxevent = rl->GetNumberOfEvents();
37 cout<<"Number of events "<<maxevent<<endl;
42 TClonesArray *hits = 0;
44 for (Int_t iEvent=0; iEvent<maxevent; iEvent++)
46 //cout << " ======> Event " << iEvent <<endl ;
60 cout << " ======> Event " << iEvent << endl;
63 //Get hits from the list
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();
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)) ;
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
85 cout<<"Hit ID "<<id<<" ELoss "<<elos;
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;
100 cout<<"Hit pointer 0x0"<<endl;