ROOT logo
#if !defined(__CINT__) || defined(__MAKECINT__)

#include "../ITS/UPGRADE/AliITSUTrackerGlo.h"
#include "../ITS/UPGRADE/AliITSURecoDet.h"
#include "../ITS/UPGRADE/AliITSURecoLayer.h"
#include "TProfile.h"
#include "TH2.h"
#include "TAxis.h"
#include "TRandom.h"
#include "TFile.h"
#endif

/*
  to run: 
  .x LoadLibs.C 
  .x chkTracker.C 
  .x matBudget.C(trk)
*/

TProfile* histo[20]={0};
TH2F *rphi=0, *rphic=0;

void matBudget(AliITSUTrackerGlo* tracker, int nTest=100000, double phiMin=0,double phiMax=1.5708, int nbins=1000)
{
  AliITSURecoDet* its = tracker->GetITSInterface();
  int nlr = its->GetNLayers();
  double pnt0[3],pnt1[3],par[10];

  for (int ilr=0;ilr<nlr;ilr++) {
    histo[ilr] = new TProfile(Form("lr%d",ilr),
			      Form("lr%d act%d",ilr,its->GetLayer(ilr)->GetActiveID()),
			      nbins,phiMin,phiMax
			      );
  }
  //
  rphi  = new TH2F("rphi" ,"",nbins,phiMin,phiMax,its->GetRMax()*10,0,its->GetRMax());
  rphic = new TH2F("rphic","",nbins,phiMin,phiMax,its->GetRMax()*10,0,its->GetRMax());
  //
  float frac = 0.1;
  int npr=nTest*frac;
  for (int it=0;it<nTest;it++) {
    if ( (it%npr)==0 ) printf("Done %.1f%%\n",100*float(it)/nTest);
    double phi = phiMin + gRandom->Rndm()*(phiMax-phiMin);
    pnt1[0]=pnt1[1]=0;
    pnt1[2]=gRandom->Rndm()*10;
    double rmin=0;
    for (int ilr=0;ilr<nlr;ilr++) {
      double rmax = ilr<nlr-1 ? (its->GetLayer(ilr+1)->GetRMin()+its->GetLayer(ilr)->GetRMax())/2. : its->GetLayer(ilr)->GetRMax();
      if (it==0) {
	printf("Test of Lr%d in %f < R < %f\n",ilr,rmin,rmax);
	histo[ilr]->SetTitle(Form("%s %.3f<R<%.3f",histo[ilr]->GetTitle(),rmin,rmax));
      }
      for (int i=3;i--;) pnt0[i]=pnt1[i];
      pnt1[0] = rmax*TMath::Cos(phi);
      pnt1[1] = rmax*TMath::Sin(phi);
      pnt1[2] += rmax*1e-3; //to avoid strictly normal tracks
      tracker->MeanMaterialBudget(pnt0,pnt1,par);
      histo[ilr]->Fill(phi,par[1]);
      rmin = rmax;
    }   
  }
  //
  for (int ilr=0;ilr<nlr;ilr++) {
    if (!histo[ilr]->GetEntries()) continue;
    histo[ilr]->Scale(100);
    histo[ilr]->Fit("pol0","l");
    double rmsy = histo[ilr]->GetRMS(2);
    if (rmsy<1e-6) {
      double cst = histo[ilr]->GetMean(2)*100;
      histo[ilr]->SetMinimum(cst*0.8);      
      histo[ilr]->SetMaximum(cst*1.2);
    }
  }
  //
  TAxis* xax = rphi->GetXaxis();
  TAxis* yax = rphi->GetYaxis();
  int nbr = yax->GetNbins();
  for (int iphi=1;iphi<=nbins;iphi++) {
    double phi = xax->GetBinCenter(iphi);
    double rmax = 0;
    pnt1[0]=pnt1[1]=0;
    double avCum = 0;
    for (int ir=2;ir<nbr;ir++) {
      rmax = yax->GetBinCenter(ir);
      pnt1[0] = rmax*TMath::Cos(phi);
      pnt1[1] = rmax*TMath::Sin(phi);
      for (int i=2;i--;) pnt0[i]=pnt1[i];
      double av = 0;
      for (int it=0;it<100;it++) {
	pnt1[2] = pnt0[2] = gRandom->Rndm()*10;
	pnt1[2] += rmax*1e-3; //to avoid strictly normal tracks
	tracker->MeanMaterialBudget(pnt0,pnt1,par);
	av += par[1];
      }
      av /= 10;
      avCum += av;
      rphi->SetBinContent(iphi,ir,av);
      rphic->SetBinContent(iphi,ir,avCum);
    }
  }
  //

}
 matBudget.C:1
 matBudget.C:2
 matBudget.C:3
 matBudget.C:4
 matBudget.C:5
 matBudget.C:6
 matBudget.C:7
 matBudget.C:8
 matBudget.C:9
 matBudget.C:10
 matBudget.C:11
 matBudget.C:12
 matBudget.C:13
 matBudget.C:14
 matBudget.C:15
 matBudget.C:16
 matBudget.C:17
 matBudget.C:18
 matBudget.C:19
 matBudget.C:20
 matBudget.C:21
 matBudget.C:22
 matBudget.C:23
 matBudget.C:24
 matBudget.C:25
 matBudget.C:26
 matBudget.C:27
 matBudget.C:28
 matBudget.C:29
 matBudget.C:30
 matBudget.C:31
 matBudget.C:32
 matBudget.C:33
 matBudget.C:34
 matBudget.C:35
 matBudget.C:36
 matBudget.C:37
 matBudget.C:38
 matBudget.C:39
 matBudget.C:40
 matBudget.C:41
 matBudget.C:42
 matBudget.C:43
 matBudget.C:44
 matBudget.C:45
 matBudget.C:46
 matBudget.C:47
 matBudget.C:48
 matBudget.C:49
 matBudget.C:50
 matBudget.C:51
 matBudget.C:52
 matBudget.C:53
 matBudget.C:54
 matBudget.C:55
 matBudget.C:56
 matBudget.C:57
 matBudget.C:58
 matBudget.C:59
 matBudget.C:60
 matBudget.C:61
 matBudget.C:62
 matBudget.C:63
 matBudget.C:64
 matBudget.C:65
 matBudget.C:66
 matBudget.C:67
 matBudget.C:68
 matBudget.C:69
 matBudget.C:70
 matBudget.C:71
 matBudget.C:72
 matBudget.C:73
 matBudget.C:74
 matBudget.C:75
 matBudget.C:76
 matBudget.C:77
 matBudget.C:78
 matBudget.C:79
 matBudget.C:80
 matBudget.C:81
 matBudget.C:82
 matBudget.C:83
 matBudget.C:84
 matBudget.C:85
 matBudget.C:86
 matBudget.C:87
 matBudget.C:88
 matBudget.C:89
 matBudget.C:90
 matBudget.C:91
 matBudget.C:92
 matBudget.C:93
 matBudget.C:94
 matBudget.C:95
 matBudget.C:96
 matBudget.C:97
 matBudget.C:98
 matBudget.C:99
 matBudget.C:100
 matBudget.C:101
 matBudget.C:102
 matBudget.C:103
 matBudget.C:104