]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/macros/TestEMCALSDigit.C
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / EMCAL / macros / TestEMCALSDigit.C
1 // Test Macro, shows how to load Digits and Geometry, and how can we get 
2 // some of the parameters and variables.
3 // Author: Gustavo Conesa
4
5 void TestEMCALSDigit()
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 Digits
33   rl->LoadSDigits("EMCAL");
34   
35   //Get maximum number of events
36   Int_t maxevent =  rl->GetNumberOfEvents();
37   cout<<"Number of events "<<maxevent<<endl;
38   //maxevent = 10 ;
39   
40   Int_t iEvent  = -1 ;
41   Float_t amp   = -1 ;
42   Float_t time  = -1 ;
43   Int_t id      = -1 ;
44   Int_t iSupMod =  0 ;
45   Int_t iTower  =  0 ;
46   Int_t iIphi   =  0 ;
47   Int_t iIeta   =  0 ;
48   Int_t iphi    =  0 ;
49   Int_t ieta    =  0 ;
50   
51   AliEMCALDigit * dig;
52   
53   for ( iEvent=0; iEvent<maxevent; iEvent++)
54     {
55       cout <<  " ======> Event " << iEvent << endl ;
56       //Load Event
57       rl->GetEvent(iEvent);
58       
59       //Fill array of digits
60       TClonesArray *digits = emcalLoader->SDigits();
61       
62       //Get digits from the list      
63       for(Int_t idig = 0; idig< digits->GetEntries();idig++){
64         //cout<<">> idig "<<idig<<endl;
65         dig = static_cast<AliEMCALDigit *>(digits->At(idig)) ;
66         
67         if(dig != 0){
68           id   = dig->GetId() ; //cell (digit) label
69           amp  = dig->GetAmplitude(); //amplitude in cell (digit)
70           time = dig->GetTime();//time of creation of digit after collision
71           
72           cout<<"Cell ID "<<id<<" Amp "<<amp<<endl;//" time "<<time<<endl;
73           
74           //Geometry methods  
75           if(geom){
76             geom->GetCellIndex(id,iSupMod,iTower,iIphi,iIeta); 
77             //Gives SuperModule and Tower numbers
78             geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,
79                                               iIphi, iIeta,iphi,ieta);
80             //Gives label of cell in eta-phi position per each supermodule
81             cout<< "SModule "<<iSupMod<<"; Tower "<<iTower <<"; Eta "<<iIeta
82                 <<"; Phi "<<iIphi<<"; Cell Eta "<<ieta<<"; Cell Phi "<<iphi<<endl;
83           }
84         }
85         else
86           cout<<"Digit pointer 0x0"<<endl;
87       }
88       
89     }
90
91
92 }
93