fill the fraction of cell energy in cluster in case of unfolding ON
[u/mrichter/AliRoot.git] / EMCAL / macros / TestEMCALDigit.C
CommitLineData
79107cce 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
5void TestEMCALDigit()
6{
5de968cc 7
79107cce 8 // Getting EMCAL Detector and Geometry.
9
5de968cc 10 AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
11
79107cce 12 if (rl == 0x0)
5de968cc 13 cout<<"Can not instatiate the Run Loader"<<endl;
14
79107cce 15 rl->LoadgAlice();//Needed to get geometry
5de968cc 16
79107cce 17 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
18 (rl->GetDetectorLoader("EMCAL"));
5de968cc 19
1210e23f 20 TGeoManager::Import("geometry.root");
5de968cc 21
79107cce 22 AliRun * alirun = rl->GetAliRun(); // Needed to get Geometry
5de968cc 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();
79107cce 31
79107cce 32 //Load Digits
33 rl->LoadDigits("EMCAL");
5de968cc 34
79107cce 35 //Get maximum number of events
36 Int_t maxevent = rl->GetNumberOfEvents();
37 cout<<"Number of events "<<maxevent<<endl;
5de968cc 38 //maxevent = 10 ;
39
79107cce 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 ;
5de968cc 50
79107cce 51 AliEMCALDigit * dig;
52
53 for ( iEvent=0; iEvent<maxevent; iEvent++)
54 {
55 cout << " ======> Event " << iEvent << endl ;
56 //Load Event
57 rl->GetEvent(iEvent);
5de968cc 58
79107cce 59 //Fill array of digits
60 TClonesArray *digits = emcalLoader->Digits();
5de968cc 61
79107cce 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)) ;
5de968cc 66
79107cce 67 if(dig != 0){
68 id = dig->GetId() ; //cell (digit) label
829ba234 69 amp = dig->GetAmplitude(); //amplitude in cell (digit)
79107cce 70 time = dig->GetTime();//time of creation of digit after collision
5de968cc 71
79107cce 72 cout<<"Cell ID "<<id<<" Amp "<<amp<<endl;//" time "<<time<<endl;
5de968cc 73
79107cce 74 //Geometry methods
5de968cc 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 }
79107cce 84 }
85 else
86 cout<<"Digit pointer 0x0"<<endl;
87 }
88
89 }
1210e23f 90
91
79107cce 92}
93