ROOT logo
#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TCanvas.h>
#include <TClassTable.h>
#include <TGraph.h>
#include <TGraph2D.h>
#include <TGeoManager.h>
#include <TH1.h>
#include <TH2.h>
#include <TLatex.h>
#include <TStyle.h>
#include <TInterpreter.h>
#include "AliGeomManager.h"
#include "AliHeader.h"
#include "AliITS.h"
#include "AliITSRecPointContainer.h"
#include "AliITSgeomTGeo.h"
#include "AliITSRecPoint.h"
#include "AliRun.h"
#endif

Int_t ShowITSRecPoints(Int_t nevfordisp=0){
  ///////////////////////////////////////////////////////////////////////
  // Macro to check clusters in the 6 ITS layers                       //
  // Provides:                                                         //
  //  6 canvases with 9 plots each (1 canvas for each layer)           //
  //  3 canvases with cluster XY coordinates for the first 3 events    //
  ///////////////////////////////////////////////////////////////////////

  if (gClassTable->GetID("AliRun") < 0) {
    gInterpreter->ExecuteMacro("loadlibs.C");
  }
 
  // retrieves geometry 
  if(!gGeoManager){
    AliGeomManager::LoadGeometry("geometry.root");
  }

  AliRunLoader* rl = AliRunLoader::Open("galice.root");
  if (rl == 0x0){
    cerr<<"Can not open session RL=NULL"<< endl;
    return -1;
  }

  AliITSLoader* ITSloader =  (AliITSLoader*) rl->GetLoader("ITSLoader");
  if(!ITSloader){
    cerr<<"ITS loader not found"<<endl;
    return -1;
  }
  ITSloader->LoadRecPoints("read");

  AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();

  Float_t cluglo[3]={0.,0.,0.}; 

  Int_t totmod=AliITSgeomTGeo::GetNModules();
  Int_t modmin=AliITSgeomTGeo::GetModuleIndex(1,1,1);
  Int_t modmax=AliITSgeomTGeo::GetNModules()-1;

  Float_t xlim[6]={4.5,7.5,16.,26.,40.,45.};
  Float_t zlim[6]={15.,15.,22.,30.,45.,55.};

  TH1F* hlayer=new TH1F("hlayer","",6,-0.5,5.5);
  TH1F** hmod=new TH1F*[6];
  TH1F** hxl=new TH1F*[6];
  TH1F** hzl=new TH1F*[6];
  TH1F** hxg=new TH1F*[6];
  TH1F** hyg=new TH1F*[6];
  TH1F** hzg=new TH1F*[6];
  TH1F** hr=new TH1F*[6];
  TH1F** hphi=new TH1F*[6];
  TH2F** hzphi=new TH2F*[6];
  TH1F** hq=new TH1F*[6];
  TH1F** hdrtime=new TH1F*[6];
  
  Char_t name[10];
  for(Int_t iLay=0;iLay<6;iLay++){
    sprintf(name,"hmod%d",iLay+1);
    hmod[iLay]=new TH1F(name,"",totmod,modmin-0.5,modmax+0.5);
    hmod[iLay]->GetXaxis()->SetTitle("Module");
    hmod[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hxloc%d",iLay+1);
    hxl[iLay]=new TH1F(name,"",100,-4.,4.);
    hxl[iLay]->GetXaxis()->SetTitle("Xloc (cm)");
    hxl[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hzloc%d",iLay+1);
    hzl[iLay]=new TH1F(name,"",100,-4.,4.);
    hzl[iLay]->GetXaxis()->SetTitle("Zloc (cm)");
    hzl[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hxgl%d",iLay+1);
    hxg[iLay]=new TH1F(name,"",100,-xlim[iLay],xlim[iLay]);
    hxg[iLay]->GetXaxis()->SetTitle("Xglob (cm)");
    hxg[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hygl%d",iLay+1);
    hyg[iLay]=new TH1F(name,"",100,-xlim[iLay],xlim[iLay]);
    hyg[iLay]->GetXaxis()->SetTitle("Yglob (cm)");
    hyg[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hzgl%d",iLay+1);
    hzg[iLay]=new TH1F(name,"",100,-zlim[iLay],zlim[iLay]);
    hzg[iLay]->GetXaxis()->SetTitle("Zglob (cm)");
    hzg[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hr%d",iLay+1);
    hr[iLay]=new TH1F(name,"",100,0.,50.);
    hr[iLay]->GetXaxis()->SetTitle("r (cm)");
    hr[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hphi%d",iLay+1);
    hphi[iLay]=new TH1F(name,"",100,-TMath::Pi(),TMath::Pi());    
    hphi[iLay]->GetXaxis()->SetTitle("#varphi (rad)");
    hphi[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hq%d",iLay+1);
    hq[iLay]=new TH1F(name,"",100,0.,300.);    
    hq[iLay]->GetXaxis()->SetTitle("Charge (keV)");
    hq[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hdtim%d",iLay+1);
    hdrtime[iLay]=new TH1F(name,"",100,0.,7000.);    
    hdrtime[iLay]->GetXaxis()->SetTitle("Drift Time (ns)");
    hdrtime[iLay]->GetXaxis()->CenterTitle();
    sprintf(name,"hzphi%d",iLay+1);
    hzphi[iLay]=new TH2F(name,Form("Layer %d",iLay+1),50,-TMath::Pi(),TMath::Pi(),50,-zlim[iLay],zlim[iLay]);
    hzphi[iLay]->GetXaxis()->SetTitle("#varphi (rad)");
    hzphi[iLay]->GetYaxis()->SetTitle("Zglob (cm)");
    hzphi[iLay]->SetStats(0);
  }

  TGraph *gptsXY=new TGraph(0);
  TGraph *gptsRZ=new TGraph(0);

  Int_t totev=rl->GetNumberOfEvents();
  printf("Total Number of events = %d\n",totev);

  for(Int_t iev=0;iev<totev;iev++){
    rl->GetEvent(iev);
    TTree *TR = ITSloader->TreeR();
    rpcont->FetchClusters(0,TR);
    TClonesArray *ITSrec  = NULL;
    if(iev%100==0) printf("Event #%d\n",iev);


    Int_t ipt=0;
    for (Int_t mod=modmin; mod<=modmax; mod++){
      ITSrec = rpcont->UncheckedGetClusters(mod);
      Int_t nrecp = ITSrec->GetEntries();
      if(nrecp>0){
	for(Int_t irec=0;irec<nrecp;irec++) {
	  AliITSRecPoint *recp = (AliITSRecPoint*)ITSrec->At(irec);
	  Int_t lay=recp->GetLayer();
	  hlayer->Fill(lay);
	  recp->GetGlobalXYZ(cluglo);
	  Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
	  Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
	  if(iev==nevfordisp){
	    gptsXY->SetPoint(ipt,cluglo[0],cluglo[1]);
	    if(cluglo[1]>0) gptsRZ->SetPoint(ipt,cluglo[2],rad);
	    else gptsRZ->SetPoint(ipt,cluglo[2],-rad);
	    ipt++;
	  }
	  hmod[lay]->Fill(mod);
	  hzl[lay]->Fill(recp->GetDetLocalZ());
	  hxl[lay]->Fill(recp->GetDetLocalX());
	  hzg[lay]->Fill(cluglo[2]);
	  hyg[lay]->Fill(cluglo[1]);
	  hxg[lay]->Fill(cluglo[0]);
	  hr[lay]->Fill(rad);
	  hphi[lay]->Fill(phi);
	  hq[lay]->Fill(recp->GetQ());
	  hdrtime[lay]->Fill(recp->GetDriftTime());
	  hzphi[lay]->Fill(phi,cluglo[2]);
	}
      }
    }
  }
  
  TCanvas **c=new TCanvas*[6];
  Char_t ctit[30];
  for(Int_t iLay=0;iLay<6;iLay++){
    sprintf(name,"can%d",iLay+1);
    sprintf(ctit,"Layer %d",iLay+1);
    c[iLay]=new TCanvas(name,ctit,1200,900);
    c[iLay]->Divide(3,3,0.001,0.001);
    c[iLay]->cd(1);
    hmod[iLay]->Draw();
    c[iLay]->cd(2);
    hxl[iLay]->Draw();
    c[iLay]->cd(3);
    hzl[iLay]->Draw();
    c[iLay]->cd(4);
    hxg[iLay]->Draw();
    c[iLay]->cd(5);
    hyg[iLay]->Draw();
    c[iLay]->cd(6);
    hzg[iLay]->Draw();
    c[iLay]->cd(7);
    hr[iLay]->Draw();
    c[iLay]->cd(8);
    hphi[iLay]->Draw();    
    c[iLay]->cd(9);
    hq[iLay]->Draw();    
  }

  TCanvas* cdrtim=new TCanvas("cdrtim","SDD drift time",1000,600);
  cdrtim->Divide(2,1);
  cdrtim->cd(1);
  hdrtime[2]->Draw();
  cdrtim->cd(2);
  hdrtime[3]->Draw();

  gStyle->SetPalette(1);
  TLatex* tstat=new TLatex();
  tstat->SetNDC();
  TCanvas* cspd=new TCanvas("cspd","SPD",1000,600);
  cspd->Divide(2,1);
  cspd->cd(1);
  hzphi[0]->Draw("colz");
  tstat->DrawLatex(0.6,0.92,Form("# Clusters = %d",int(hzphi[0]->GetEntries())));
  cspd->cd(2);
  hzphi[1]->Draw("colz");
  tstat->DrawLatex(0.6,0.92,Form("# Clusters = %d",int(hzphi[1]->GetEntries())));

  TCanvas* csdd=new TCanvas("csdd","SDD",1000,600);
  csdd->Divide(2,1);
  csdd->cd(1);
  hzphi[2]->Draw("colz");
  tstat->DrawLatex(0.6,0.92,Form("# Clusters = %d",int(hzphi[2]->GetEntries())));  
  csdd->cd(2);
  hzphi[3]->Draw("colz");
  tstat->DrawLatex(0.6,0.92,Form("# Clusters = %d",int(hzphi[3]->GetEntries())));  

  TCanvas* cssd=new TCanvas("cssd","SSD",1000,600);
  cssd->Divide(2,1);
  cssd->cd(1);
  hzphi[4]->Draw("colz");
  tstat->DrawLatex(0.6,0.92,Form("# Clusters = %d",int(hzphi[4]->GetEntries())));  
  cssd->cd(2);
  hzphi[5]->Draw("colz");
  tstat->DrawLatex(0.6,0.92,Form("# Clusters = %d",int(hzphi[5]->GetEntries())));  

  TCanvas *cev0;
  sprintf(ctit,"Event %d XY",nevfordisp);
  cev0=new TCanvas("cev0",ctit,600,600);
  if(gptsXY->GetN()>0){
    gptsXY->SetMarkerStyle(7);
    gptsXY->SetTitle(0);
    gptsXY->Draw("AP");
    gptsXY->GetXaxis()->SetTitle("Xglob");
    gptsXY->GetYaxis()->SetTitle("Yglob");
   }

  TCanvas *cev1;
  sprintf(ctit,"Event %d Zr",nevfordisp);
  cev1=new TCanvas("cev1",ctit,600,600);
  if(gptsRZ->GetN()>0){
    gptsRZ->SetMarkerStyle(7);
    gptsRZ->SetTitle(0);
    gptsRZ->Draw("AP");
    gptsRZ->GetXaxis()->SetTitle("Zglob");
    gptsRZ->GetYaxis()->SetTitle("Radius");
  }

  return 0;
}


 ShowITSRecPoints.C:1
 ShowITSRecPoints.C:2
 ShowITSRecPoints.C:3
 ShowITSRecPoints.C:4
 ShowITSRecPoints.C:5
 ShowITSRecPoints.C:6
 ShowITSRecPoints.C:7
 ShowITSRecPoints.C:8
 ShowITSRecPoints.C:9
 ShowITSRecPoints.C:10
 ShowITSRecPoints.C:11
 ShowITSRecPoints.C:12
 ShowITSRecPoints.C:13
 ShowITSRecPoints.C:14
 ShowITSRecPoints.C:15
 ShowITSRecPoints.C:16
 ShowITSRecPoints.C:17
 ShowITSRecPoints.C:18
 ShowITSRecPoints.C:19
 ShowITSRecPoints.C:20
 ShowITSRecPoints.C:21
 ShowITSRecPoints.C:22
 ShowITSRecPoints.C:23
 ShowITSRecPoints.C:24
 ShowITSRecPoints.C:25
 ShowITSRecPoints.C:26
 ShowITSRecPoints.C:27
 ShowITSRecPoints.C:28
 ShowITSRecPoints.C:29
 ShowITSRecPoints.C:30
 ShowITSRecPoints.C:31
 ShowITSRecPoints.C:32
 ShowITSRecPoints.C:33
 ShowITSRecPoints.C:34
 ShowITSRecPoints.C:35
 ShowITSRecPoints.C:36
 ShowITSRecPoints.C:37
 ShowITSRecPoints.C:38
 ShowITSRecPoints.C:39
 ShowITSRecPoints.C:40
 ShowITSRecPoints.C:41
 ShowITSRecPoints.C:42
 ShowITSRecPoints.C:43
 ShowITSRecPoints.C:44
 ShowITSRecPoints.C:45
 ShowITSRecPoints.C:46
 ShowITSRecPoints.C:47
 ShowITSRecPoints.C:48
 ShowITSRecPoints.C:49
 ShowITSRecPoints.C:50
 ShowITSRecPoints.C:51
 ShowITSRecPoints.C:52
 ShowITSRecPoints.C:53
 ShowITSRecPoints.C:54
 ShowITSRecPoints.C:55
 ShowITSRecPoints.C:56
 ShowITSRecPoints.C:57
 ShowITSRecPoints.C:58
 ShowITSRecPoints.C:59
 ShowITSRecPoints.C:60
 ShowITSRecPoints.C:61
 ShowITSRecPoints.C:62
 ShowITSRecPoints.C:63
 ShowITSRecPoints.C:64
 ShowITSRecPoints.C:65
 ShowITSRecPoints.C:66
 ShowITSRecPoints.C:67
 ShowITSRecPoints.C:68
 ShowITSRecPoints.C:69
 ShowITSRecPoints.C:70
 ShowITSRecPoints.C:71
 ShowITSRecPoints.C:72
 ShowITSRecPoints.C:73
 ShowITSRecPoints.C:74
 ShowITSRecPoints.C:75
 ShowITSRecPoints.C:76
 ShowITSRecPoints.C:77
 ShowITSRecPoints.C:78
 ShowITSRecPoints.C:79
 ShowITSRecPoints.C:80
 ShowITSRecPoints.C:81
 ShowITSRecPoints.C:82
 ShowITSRecPoints.C:83
 ShowITSRecPoints.C:84
 ShowITSRecPoints.C:85
 ShowITSRecPoints.C:86
 ShowITSRecPoints.C:87
 ShowITSRecPoints.C:88
 ShowITSRecPoints.C:89
 ShowITSRecPoints.C:90
 ShowITSRecPoints.C:91
 ShowITSRecPoints.C:92
 ShowITSRecPoints.C:93
 ShowITSRecPoints.C:94
 ShowITSRecPoints.C:95
 ShowITSRecPoints.C:96
 ShowITSRecPoints.C:97
 ShowITSRecPoints.C:98
 ShowITSRecPoints.C:99
 ShowITSRecPoints.C:100
 ShowITSRecPoints.C:101
 ShowITSRecPoints.C:102
 ShowITSRecPoints.C:103
 ShowITSRecPoints.C:104
 ShowITSRecPoints.C:105
 ShowITSRecPoints.C:106
 ShowITSRecPoints.C:107
 ShowITSRecPoints.C:108
 ShowITSRecPoints.C:109
 ShowITSRecPoints.C:110
 ShowITSRecPoints.C:111
 ShowITSRecPoints.C:112
 ShowITSRecPoints.C:113
 ShowITSRecPoints.C:114
 ShowITSRecPoints.C:115
 ShowITSRecPoints.C:116
 ShowITSRecPoints.C:117
 ShowITSRecPoints.C:118
 ShowITSRecPoints.C:119
 ShowITSRecPoints.C:120
 ShowITSRecPoints.C:121
 ShowITSRecPoints.C:122
 ShowITSRecPoints.C:123
 ShowITSRecPoints.C:124
 ShowITSRecPoints.C:125
 ShowITSRecPoints.C:126
 ShowITSRecPoints.C:127
 ShowITSRecPoints.C:128
 ShowITSRecPoints.C:129
 ShowITSRecPoints.C:130
 ShowITSRecPoints.C:131
 ShowITSRecPoints.C:132
 ShowITSRecPoints.C:133
 ShowITSRecPoints.C:134
 ShowITSRecPoints.C:135
 ShowITSRecPoints.C:136
 ShowITSRecPoints.C:137
 ShowITSRecPoints.C:138
 ShowITSRecPoints.C:139
 ShowITSRecPoints.C:140
 ShowITSRecPoints.C:141
 ShowITSRecPoints.C:142
 ShowITSRecPoints.C:143
 ShowITSRecPoints.C:144
 ShowITSRecPoints.C:145
 ShowITSRecPoints.C:146
 ShowITSRecPoints.C:147
 ShowITSRecPoints.C:148
 ShowITSRecPoints.C:149
 ShowITSRecPoints.C:150
 ShowITSRecPoints.C:151
 ShowITSRecPoints.C:152
 ShowITSRecPoints.C:153
 ShowITSRecPoints.C:154
 ShowITSRecPoints.C:155
 ShowITSRecPoints.C:156
 ShowITSRecPoints.C:157
 ShowITSRecPoints.C:158
 ShowITSRecPoints.C:159
 ShowITSRecPoints.C:160
 ShowITSRecPoints.C:161
 ShowITSRecPoints.C:162
 ShowITSRecPoints.C:163
 ShowITSRecPoints.C:164
 ShowITSRecPoints.C:165
 ShowITSRecPoints.C:166
 ShowITSRecPoints.C:167
 ShowITSRecPoints.C:168
 ShowITSRecPoints.C:169
 ShowITSRecPoints.C:170
 ShowITSRecPoints.C:171
 ShowITSRecPoints.C:172
 ShowITSRecPoints.C:173
 ShowITSRecPoints.C:174
 ShowITSRecPoints.C:175
 ShowITSRecPoints.C:176
 ShowITSRecPoints.C:177
 ShowITSRecPoints.C:178
 ShowITSRecPoints.C:179
 ShowITSRecPoints.C:180
 ShowITSRecPoints.C:181
 ShowITSRecPoints.C:182
 ShowITSRecPoints.C:183
 ShowITSRecPoints.C:184
 ShowITSRecPoints.C:185
 ShowITSRecPoints.C:186
 ShowITSRecPoints.C:187
 ShowITSRecPoints.C:188
 ShowITSRecPoints.C:189
 ShowITSRecPoints.C:190
 ShowITSRecPoints.C:191
 ShowITSRecPoints.C:192
 ShowITSRecPoints.C:193
 ShowITSRecPoints.C:194
 ShowITSRecPoints.C:195
 ShowITSRecPoints.C:196
 ShowITSRecPoints.C:197
 ShowITSRecPoints.C:198
 ShowITSRecPoints.C:199
 ShowITSRecPoints.C:200
 ShowITSRecPoints.C:201
 ShowITSRecPoints.C:202
 ShowITSRecPoints.C:203
 ShowITSRecPoints.C:204
 ShowITSRecPoints.C:205
 ShowITSRecPoints.C:206
 ShowITSRecPoints.C:207
 ShowITSRecPoints.C:208
 ShowITSRecPoints.C:209
 ShowITSRecPoints.C:210
 ShowITSRecPoints.C:211
 ShowITSRecPoints.C:212
 ShowITSRecPoints.C:213
 ShowITSRecPoints.C:214
 ShowITSRecPoints.C:215
 ShowITSRecPoints.C:216
 ShowITSRecPoints.C:217
 ShowITSRecPoints.C:218
 ShowITSRecPoints.C:219
 ShowITSRecPoints.C:220
 ShowITSRecPoints.C:221
 ShowITSRecPoints.C:222
 ShowITSRecPoints.C:223
 ShowITSRecPoints.C:224
 ShowITSRecPoints.C:225
 ShowITSRecPoints.C:226
 ShowITSRecPoints.C:227
 ShowITSRecPoints.C:228
 ShowITSRecPoints.C:229
 ShowITSRecPoints.C:230
 ShowITSRecPoints.C:231
 ShowITSRecPoints.C:232
 ShowITSRecPoints.C:233
 ShowITSRecPoints.C:234
 ShowITSRecPoints.C:235
 ShowITSRecPoints.C:236
 ShowITSRecPoints.C:237
 ShowITSRecPoints.C:238
 ShowITSRecPoints.C:239
 ShowITSRecPoints.C:240
 ShowITSRecPoints.C:241
 ShowITSRecPoints.C:242
 ShowITSRecPoints.C:243
 ShowITSRecPoints.C:244
 ShowITSRecPoints.C:245
 ShowITSRecPoints.C:246
 ShowITSRecPoints.C:247
 ShowITSRecPoints.C:248
 ShowITSRecPoints.C:249
 ShowITSRecPoints.C:250
 ShowITSRecPoints.C:251
 ShowITSRecPoints.C:252
 ShowITSRecPoints.C:253
 ShowITSRecPoints.C:254
 ShowITSRecPoints.C:255
 ShowITSRecPoints.C:256
 ShowITSRecPoints.C:257
 ShowITSRecPoints.C:258
 ShowITSRecPoints.C:259
 ShowITSRecPoints.C:260
 ShowITSRecPoints.C:261
 ShowITSRecPoints.C:262