1 #if !defined(__CINT__) || defined(__MAKECINT__)
10 #include <TObjArray.h>
15 #include <TParticle.h>
17 //AliRoot include files
19 #include "AliESDEvent.h"
20 #include "AliEMCALLoader.h"
21 #include "AliESDCaloCluster.h"
22 #include "AliEMCALRecPoint.h"
30 TChain * AliReadESDfromdisk(const UInt_t eventsToRead,
31 const TString dirName,
32 const TString esdTreeName,
35 // Reads ESDs from Disk
38 // create a TChain of all the files
39 TChain * cESDTree = new TChain(esdTreeName) ;
41 // read from the directory file until the require number of events are collected
42 void * from = gSystem->OpenDirectory(dirName) ;
45 else{ // reading file names from directory
47 // search all subdirectories witch matching pattern
48 while( (subdir = gSystem->GetDirEntry(from)) &&
49 (cESDTree->GetEntries() < eventsToRead)) {
50 if ( strstr(subdir, pattern) != 0 ) {
52 sprintf(file, "%s%s/AliESDs.root", dirName.Data(), subdir);
59 } // reading file names from directory
63 //======================================================================
64 TChain * AliReadESD(const UInt_t eventsToRead,
65 const TString dirName,
66 const TString esdTreeName,
69 // Read AliESDs files and return a Chain of events
73 if ( esdTreeName == "" )
74 return AliReadESDfromdisk(eventsToRead, dirName,"","") ;//Last 2 arguments are not necessary but pdsf compiler complains "","'
75 else if ( strcmp(pattern, "") == 0 )
76 return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName,"") ;//Last argument is not necessary but pdsf compiler complains "","'
78 return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName, pattern) ;
81 //=====================================================================
83 // .L TestESDCaloCluster.C++
84 // TestESDCaloCluster(number of events to process)
85 //=====================================================================
86 void TestESDCaloCluster(const UInt_t eventsToProcess = 5,
87 TString dirName = "./",
88 const TString esdTreeName = "esdTree",
89 const char * pattern = ".")
92 //Create chain of esd trees
93 //AliReadESD(eventsToProcess, directoryName,esdTreeName,patternOfDirectory) ;
94 //By default the root files are in the same directory
95 TChain * t = AliReadESD(eventsToProcess, dirName,esdTreeName,pattern) ;
99 AliESDEvent * esd = new AliESDEvent();
100 esd->ReadFromTree(t);
102 //Define few variables to be used in macro
103 TString alirunName = "" ;
105 //Define example histograms
106 TH1F * hEnergy = new TH1F("hEnergy","Energy Distribution",100,0.,100.);
107 TH1F * hEta = new TH1F("hEta","Eta Distribution",100,-0.7,0.7);
108 TH1F * hPhi = new TH1F("hPhi","Phi Distribution",100,0,2*TMath::Pi());
114 for (event = 0; event < eventsToProcess; event++) {//event loop
115 //AliInfo( Form("Event %d \n",event) );
116 Int_t nbytes = t->GetEntry(event); // store event in esd
117 //cout<<"nbytes "<<nbytes<<endl;
118 if ( nbytes == 0 ) //If nothing in ESD
121 // Check that name of file is correct
122 if (alirunName != t->GetFile()->GetName()) {
123 alirunName = t->GetFile()->GetName() ;
124 alirunName.ReplaceAll("galice.root", "AliESDs.root") ;
127 //get reconstructed vertex position
129 //Double_t vertex_position[3] ;
130 // esd->GetVertex()->GetXYZ(vertex_position) ;
132 cout<<"Event >>>>>>>>>>> "<<event<<endl;
135 //select EMCAL tracks only
136 end = esd->GetNumberOfCaloClusters() ;
139 //cout<<"begin "<<beg<<" end "<<end<<endl;
141 for (nphP = beg; nphP < end; nphP++) {//////////////EMCAL cluster loop
142 AliESDCaloCluster * clus = esd->GetCaloCluster(nphP) ; // retrieve cluster from esd
144 //Get the cluster parameters
145 Float_t energy = clus->E() ;
146 cout << "Cluster " << nphP << " energy = " << energy << endl;
148 // Int_t mult = clus->GetNumberOfDigits() ;
149 // Float_t disp = clus->GetClusterDisp() ;
150 // UShort_t * amp = clus->GetDigitAmplitude() ;
151 // UShort_t * time = clus->GetDigitTime() ;
152 // UShort_t * index = clus->GetDigitIndex() ;
153 // Int_t iprim = clus->GetPrimaryIndex();
156 clus->GetPosition(pos) ;
157 TVector3 vpos(pos[0],pos[1],pos[2]) ;
158 //Print values on screen
159 cout<<"ESD cluster "<<iclus <<"; Energy "<<energy
160 <<"; Phi "<<vpos.Phi()*180/TMath::Pi()<<"; Eta "<<vpos.Eta()<<endl;
161 //cout<<"Dispersion "<<disp<<"; multiplicity "<<mult<<endl;
162 //Get the parent main values
165 hEnergy->Fill(energy) ;
166 // hEta->Fill(vpos.Eta()) ;
167 //hPhi->Fill(vpos.Phi()) ;
170 }//////////////////////////////////////////event loop
171 hEnergy->Draw();//Draw histogram on screen
172 //Write histograms in Root file
173 TFile outf("histo.root","recreate") ;