]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/macros/matBudget.C
Update master to aliroot
[u/mrichter/AliRoot.git] / ITS / UPGRADE / macros / matBudget.C
CommitLineData
5365567c 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
3#include "../ITS/UPGRADE/AliITSUTrackerGlo.h"
4#include "../ITS/UPGRADE/AliITSURecoDet.h"
5#include "../ITS/UPGRADE/AliITSURecoLayer.h"
6#include "TProfile.h"
7#include "TH2.h"
8#include "TAxis.h"
9#include "TRandom.h"
10#include "TFile.h"
11#endif
12
13/*
14 to run:
15 .x LoadLibs.C
16 .x chkTracker.C
17 .x matBudget.C(trk)
18*/
19
20TProfile* histo[20]={0};
21TH2F *rphi=0, *rphic=0;
22
23void matBudget(AliITSUTrackerGlo* tracker, int nTest=100000, double phiMin=0,double phiMax=1.5708, int nbins=1000)
24{
25 AliITSURecoDet* its = tracker->GetITSInterface();
26 int nlr = its->GetNLayers();
27 double pnt0[3],pnt1[3],par[10];
28
29 for (int ilr=0;ilr<nlr;ilr++) {
30 histo[ilr] = new TProfile(Form("lr%d",ilr),
31 Form("lr%d act%d",ilr,its->GetLayer(ilr)->GetActiveID()),
32 nbins,phiMin,phiMax
33 );
34 }
35 //
36 rphi = new TH2F("rphi" ,"",nbins,phiMin,phiMax,its->GetRMax()*10,0,its->GetRMax());
37 rphic = new TH2F("rphic","",nbins,phiMin,phiMax,its->GetRMax()*10,0,its->GetRMax());
38 //
39 float frac = 0.1;
40 int npr=nTest*frac;
41 for (int it=0;it<nTest;it++) {
42 if ( (it%npr)==0 ) printf("Done %.1f%%\n",100*float(it)/nTest);
43 double phi = phiMin + gRandom->Rndm()*(phiMax-phiMin);
44 pnt1[0]=pnt1[1]=0;
45 pnt1[2]=gRandom->Rndm()*10;
46 double rmin=0;
47 for (int ilr=0;ilr<nlr;ilr++) {
48 double rmax = ilr<nlr-1 ? (its->GetLayer(ilr+1)->GetRMin()+its->GetLayer(ilr)->GetRMax())/2. : its->GetLayer(ilr)->GetRMax();
49 if (it==0) {
50 printf("Test of Lr%d in %f < R < %f\n",ilr,rmin,rmax);
51 histo[ilr]->SetTitle(Form("%s %.3f<R<%.3f",histo[ilr]->GetTitle(),rmin,rmax));
52 }
53 for (int i=3;i--;) pnt0[i]=pnt1[i];
54 pnt1[0] = rmax*TMath::Cos(phi);
55 pnt1[1] = rmax*TMath::Sin(phi);
56 pnt1[2] += rmax*1e-3; //to avoid strictly normal tracks
57 tracker->MeanMaterialBudget(pnt0,pnt1,par);
58 histo[ilr]->Fill(phi,par[1]);
59 rmin = rmax;
60 }
61 }
62 //
63 for (int ilr=0;ilr<nlr;ilr++) {
64 if (!histo[ilr]->GetEntries()) continue;
65 histo[ilr]->Scale(100);
66 histo[ilr]->Fit("pol0","l");
67 double rmsy = histo[ilr]->GetRMS(2);
68 if (rmsy<1e-6) {
69 double cst = histo[ilr]->GetMean(2)*100;
70 histo[ilr]->SetMinimum(cst*0.8);
71 histo[ilr]->SetMaximum(cst*1.2);
72 }
73 }
74 //
75 TAxis* xax = rphi->GetXaxis();
76 TAxis* yax = rphi->GetYaxis();
77 int nbr = yax->GetNbins();
78 for (int iphi=1;iphi<=nbins;iphi++) {
79 double phi = xax->GetBinCenter(iphi);
80 double rmax = 0;
81 pnt1[0]=pnt1[1]=0;
82 double avCum = 0;
83 for (int ir=2;ir<nbr;ir++) {
84 rmax = yax->GetBinCenter(ir);
85 pnt1[0] = rmax*TMath::Cos(phi);
86 pnt1[1] = rmax*TMath::Sin(phi);
87 for (int i=2;i--;) pnt0[i]=pnt1[i];
88 double av = 0;
89 for (int it=0;it<100;it++) {
90 pnt1[2] = pnt0[2] = gRandom->Rndm()*10;
91 pnt1[2] += rmax*1e-3; //to avoid strictly normal tracks
92 tracker->MeanMaterialBudget(pnt0,pnt1,par);
93 av += par[1];
94 }
95 av /= 10;
96 avCum += av;
97 rphi->SetBinContent(iphi,ir,av);
98 rphic->SetBinContent(iphi,ir,avCum);
99 }
100 }
101 //
102
103}