ROOT logo
#if !defined(__CINT__) || defined(__MAKECINT__)
#include "TH3.h"
#include "TChain.h"
#include "TFile.h"
#include "TTree.h"
#include "AliCDBManager.h"
#include "AliGeomManager.h"
#include "AliRunLoader.h"
#include "AliESDEvent.h"
#include "AliESDCaloCluster.h"
#include "AliPHOSGeometry.h"
#endif
void scanESD(Int_t irun=7727)
{
  //This macro scans ESD and fills 3D histogram:
  //spectrum of clusters with center in each cristall
  //this histogram can be used e.g. in bad modules selection
  //Author: D.Peressounko Dmitri.Peressounko@cern.ch

  //Uncomment the following if misalignement should be applied
  AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
  //   AliCDBManager::Instance()->SetDefaultStorage("local://./");
  //   AliCDBManager::Instance()->SetSpecificStorage("PHOS/*","local:///data/prsnko/");
  AliCDBManager::Instance()->SetRun(irun) ;

  //The final histo
  TH3D * hEsd = new TH3D("hEsd","Energy of all clusters",64,0.,64.,56,0.,56.,2000,0.,10.) ;

  //Reading/creation of Geometry
  AliGeomManager::LoadGeometry("geometry.root");
  AliPHOSGeometry *phosgeom = AliPHOSGeometry::GetInstance("IHEP","") ;

  //Create list of ESD files
  TChain * chain = new TChain("esdTree") ;
  char filename[255] ;
  for(Int_t sec=1; sec<=17; sec++){
    sprintf(filename,"Seq_%d0/AliESDs.root/esdTree",sec) ;
    chain->AddFile(filename);
  }
  
  AliESDEvent *event = new AliESDEvent();
  event->ReadFromTree(chain);
  
  for(Int_t iEvent=1; iEvent<chain->GetEntries(); iEvent++){
     if(iEvent%10000==0){
       printf("Event %d \n",iEvent) ;
     }
    chain->GetEvent(iEvent);
    Int_t multClu = event->GetNumberOfCaloClusters();
    for (Int_t i0=0; i0<multClu; i0++) {
      AliESDCaloCluster * clu1 = event->GetCaloCluster(i0);
      Float_t xyz[3] = {0,0,0};
      clu1->GetPosition(xyz);   //Gloabal position in ALICE system
      Int_t absId ;
      phosgeom->RelPosToAbsId(3,xyz[0],xyz[2],absId) ; //Here we assume that data taken with 3 module
      Int_t relid[4] ;
      phosgeom->AbsToRelNumbering(absId,relid) ;
      hEsd->Fill(relid[2]*1.-0.5, relid[3]*1.-0.5,clu1->E()) ;
    }   
  }
  
  TFile *ff = new TFile("scan.root","recreate") ;
  hEsd->Write() ;
  ff->Close() ;

}
 scanESD.C:1
 scanESD.C:2
 scanESD.C:3
 scanESD.C:4
 scanESD.C:5
 scanESD.C:6
 scanESD.C:7
 scanESD.C:8
 scanESD.C:9
 scanESD.C:10
 scanESD.C:11
 scanESD.C:12
 scanESD.C:13
 scanESD.C:14
 scanESD.C:15
 scanESD.C:16
 scanESD.C:17
 scanESD.C:18
 scanESD.C:19
 scanESD.C:20
 scanESD.C:21
 scanESD.C:22
 scanESD.C:23
 scanESD.C:24
 scanESD.C:25
 scanESD.C:26
 scanESD.C:27
 scanESD.C:28
 scanESD.C:29
 scanESD.C:30
 scanESD.C:31
 scanESD.C:32
 scanESD.C:33
 scanESD.C:34
 scanESD.C:35
 scanESD.C:36
 scanESD.C:37
 scanESD.C:38
 scanESD.C:39
 scanESD.C:40
 scanESD.C:41
 scanESD.C:42
 scanESD.C:43
 scanESD.C:44
 scanESD.C:45
 scanESD.C:46
 scanESD.C:47
 scanESD.C:48
 scanESD.C:49
 scanESD.C:50
 scanESD.C:51
 scanESD.C:52
 scanESD.C:53
 scanESD.C:54
 scanESD.C:55
 scanESD.C:56
 scanESD.C:57
 scanESD.C:58
 scanESD.C:59
 scanESD.C:60
 scanESD.C:61
 scanESD.C:62
 scanESD.C:63
 scanESD.C:64
 scanESD.C:65
 scanESD.C:66
 scanESD.C:67