]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/macros/BadModules/scanESD.C
In AliMUONTriggerTrack: fixing memory leak
[u/mrichter/AliRoot.git] / PHOS / macros / BadModules / scanESD.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include "TH3.h"
3 #include "TChain.h"
4 #include "TFile.h"
5 #include "TTree.h"
6 #include "AliCDBManager.h"
7 #include "AliGeomManager.h"
8 #include "AliRunLoader.h"
9 #include "AliESDEvent.h"
10 #include "AliESDCaloCluster.h"
11 #include "AliPHOSGeometry.h"
12 #endif
13 void scanESD(Int_t irun=7727)
14 {
15   //This macro scans ESD and fills 3D histogram:
16   //spectrum of clusters with center in each cristall
17   //this histogram can be used e.g. in bad modules selection
18   //Author: D.Peressounko Dmitri.Peressounko@cern.ch
19
20   //Uncomment the following if misalignement should be applied
21   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
22   //   AliCDBManager::Instance()->SetDefaultStorage("local://./");
23   //   AliCDBManager::Instance()->SetSpecificStorage("PHOS/*","local:///data/prsnko/");
24   AliCDBManager::Instance()->SetRun(irun) ;
25
26   //The final histo
27   TH3D * hEsd = new TH3D("hEsd","Energy of all clusters",64,0.,64.,56,0.,56.,2000,0.,10.) ;
28
29   //Reading/creation of Geometry
30   AliGeomManager::LoadGeometry("geometry.root");
31   AliPHOSGeometry *phosgeom = AliPHOSGeometry::GetInstance("IHEP","") ;
32
33   //Create list of ESD files
34   TChain * chain = new TChain("esdTree") ;
35   char filename[255] ;
36   for(Int_t sec=1; sec<=17; sec++){
37     sprintf(filename,"Seq_%d0/AliESDs.root/esdTree",sec) ;
38     chain->AddFile(filename);
39   }
40   
41   AliESDEvent *event = new AliESDEvent();
42   event->ReadFromTree(chain);
43   
44   for(Int_t iEvent=1; iEvent<chain->GetEntries(); iEvent++){
45      if(iEvent%10000==0){
46        printf("Event %d \n",iEvent) ;
47      }
48     chain->GetEvent(iEvent);
49     Int_t multClu = event->GetNumberOfCaloClusters();
50     for (Int_t i0=0; i0<multClu; i0++) {
51       AliESDCaloCluster * clu1 = event->GetCaloCluster(i0);
52       Float_t xyz[3] = {0,0,0};
53       clu1->GetPosition(xyz);   //Gloabal position in ALICE system
54       Int_t absId ;
55       phosgeom->RelPosToAbsId(3,xyz[0],xyz[2],absId) ; //Here we assume that data taken with 3 module
56       Int_t relid[4] ;
57       phosgeom->AbsToRelNumbering(absId,relid) ;
58       hEsd->Fill(relid[2]*1.-0.5, relid[3]*1.-0.5,clu1->E()) ;
59     }   
60   }
61   
62   TFile *ff = new TFile("scan.root","recreate") ;
63   hEsd->Write() ;
64   ff->Close() ;
65
66 }