]>
Commit | Line | Data |
---|---|---|
54af1add | 1 | /************************************************************************** |
2 | * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Implementation of the base class for SDD map corrections // | |
21 | // Origin: F.Prino, Torino, prino@to.infn.it // | |
22 | // // | |
23 | /////////////////////////////////////////////////////////////////// | |
24 | ||
25 | #include "TH1F.h" | |
26 | #include "TH2F.h" | |
27 | #include "AliITSCorrMapSDD.h" | |
28 | ||
29 | const Int_t AliITSCorrMapSDD::fgkNAnodePtsDefault = 1; | |
30 | const Int_t AliITSCorrMapSDD::fgkNDriftPtsDefault = 72; | |
31 | ||
32 | ClassImp(AliITSCorrMapSDD) | |
33 | //______________________________________________________________________ | |
374200ee | 34 | AliITSCorrMapSDD::AliITSCorrMapSDD():TNamed("defaultmap",""), |
35 | fNAnodePts(fgkNAnodePtsDefault), | |
36 | fNDriftPts(fgkNDriftPtsDefault), | |
37 | fXt1(0.), | |
38 | fXt2(0.), | |
39 | fXm1(0.), | |
40 | fXm2(0.), | |
41 | fDrLen(0.) | |
54af1add | 42 | { |
43 | // default constructor | |
44 | } | |
45 | //______________________________________________________________________ | |
46 | AliITSCorrMapSDD::AliITSCorrMapSDD(Char_t *mapname): | |
374200ee | 47 | TNamed(mapname,""), |
48 | fNAnodePts(fgkNAnodePtsDefault), | |
49 | fNDriftPts(fgkNDriftPtsDefault), | |
50 | fXt1(0.), | |
51 | fXt2(0.), | |
52 | fXm1(0.), | |
53 | fXm2(0.), | |
54 | fDrLen(0.) | |
54af1add | 55 | { |
56 | // standard constructor | |
57 | } | |
58 | //______________________________________________________________________ | |
374200ee | 59 | void AliITSCorrMapSDD::ComputeGridPoints(Float_t z, Float_t x, AliITSsegmentationSDD *seg, Bool_t isReco){ |
60 | // extracts points from the discrete grid with the correction map | |
61 | ||
54af1add | 62 | const Double_t kMicronTocm = 1.0e-4; |
63 | Int_t nAnodes=seg->Npz(); | |
64 | Int_t nAnodesHybrid=seg->NpzHalf(); | |
65 | Int_t bina =(Int_t) seg->GetAnodeFromLocal(x,z); | |
66 | if(bina>nAnodes) AliError("Wrong anode anumber!"); | |
67 | if(bina>=nAnodesHybrid) bina-=nAnodesHybrid; | |
68 | Float_t stept = seg->Dx()*kMicronTocm/(Float_t)fNDriftPts; | |
374200ee | 69 | fDrLen= seg->Dx()*kMicronTocm-TMath::Abs(x); |
70 | Int_t bint = TMath::Abs((Int_t)(fDrLen/stept)); | |
54af1add | 71 | if(bint==fNDriftPts) bint-=1; |
374200ee | 72 | if(bint>=fNDriftPts){ |
73 | AliError("Wrong bin number along drift direction!"); | |
74 | bint=fNDriftPts-1; | |
75 | } | |
76 | fXt1=stept*bint; | |
77 | fXm1=fXt1-GetCellContent(bina,bint)*kMicronTocm; | |
78 | if((bint+1)<fNDriftPts){ | |
79 | fXt2=stept*(bint+1); | |
80 | fXm2=fXt2-GetCellContent(bina,bint+1)*kMicronTocm; | |
81 | }else{ | |
82 | fXt2=stept*(bint-1); | |
83 | fXm2=fXt2-GetCellContent(bina,bint-1)*kMicronTocm; | |
84 | } | |
85 | if(isReco){ | |
86 | if(fXm1<fDrLen && fXm2>fDrLen) return; | |
87 | if(bint==0 || bint==(fNDriftPts-1)) return; | |
88 | if(fXm1>fDrLen){ | |
89 | for(Int_t itry=1; itry<=10; itry++){ | |
90 | Float_t xmtest=(bint-itry)*stept-GetCellContent(bina,bint-itry)*kMicronTocm; | |
91 | if(xmtest<fDrLen){ | |
92 | fXt1=stept*(bint-itry); | |
93 | fXt2=fXt1+stept; | |
94 | fXm1=fXt1-GetCellContent(bina,bint-itry)*kMicronTocm; | |
95 | fXm2=fXt2-GetCellContent(bina,bint+1-itry)*kMicronTocm; | |
96 | return; | |
97 | } | |
98 | } | |
99 | } | |
100 | if(fXm2<fDrLen){ | |
101 | for(Int_t itry=1; itry<=10; itry++){ | |
102 | Float_t xmtest=(bint+1+itry)*stept-GetCellContent(bina,bint+1+itry)*kMicronTocm; | |
103 | if(xmtest>fDrLen){ | |
104 | fXt1=stept*(bint+itry); | |
105 | fXt2=fXt1+stept; | |
106 | fXm1=fXt1-GetCellContent(bina,bint+itry)*kMicronTocm; | |
107 | fXm2=fXt2-GetCellContent(bina,bint+1+itry)*kMicronTocm; | |
108 | return; | |
109 | } | |
110 | } | |
111 | } | |
112 | } | |
113 | } | |
114 | //______________________________________________________________________ | |
115 | Float_t AliITSCorrMapSDD::GetCorrection(Float_t z, Float_t x, AliITSsegmentationSDD *seg){ | |
116 | // returns correction in cm starting from local coordinates on the module | |
117 | ComputeGridPoints(z,x,seg,kTRUE); | |
118 | Float_t m=(fXt2-fXt1)/(fXm2-fXm1); | |
119 | Float_t q=fXt1-m*fXm1; | |
120 | Float_t xcorr=m*fDrLen+q; | |
121 | // fDrLen is the measured drift distance, xcorr is the corresponding true | |
122 | return (xcorr-fDrLen); | |
123 | } | |
124 | //______________________________________________________________________ | |
125 | Float_t AliITSCorrMapSDD::GetShiftForSimulation(Float_t z, Float_t x, AliITSsegmentationSDD *seg){ | |
126 | // returns shift to be appiled in digitizarion (in cm) starting from local coordinates on the module | |
127 | ComputeGridPoints(z,x,seg,kFALSE); | |
128 | Float_t m=(fXm2-fXm1)/(fXt2-fXt1); | |
129 | Float_t q=fXm1-m*fXt1; | |
130 | Float_t xshifted=m*fDrLen+q; | |
131 | // fDrLen is the true drift distance, xshifted is the one with map shift | |
132 | return (fDrLen-xshifted); | |
54af1add | 133 | } |
134 | //______________________________________________________________________ | |
135 | TH2F* AliITSCorrMapSDD::GetMapHisto() const{ | |
136 | // Returns a TH2F histogram with map of residuals | |
2c4e6a6a | 137 | TString hname; |
138 | hname.Form("h%s",GetName()); | |
139 | TH2F* hmap=new TH2F(hname.Data(),"",fNAnodePts,-0.5,255.5,fNDriftPts,0.,35.); | |
54af1add | 140 | for(Int_t iAn=0;iAn<fNAnodePts; iAn++){ |
141 | for(Int_t iDr=0;iDr<fNDriftPts; iDr++){ | |
142 | hmap->SetBinContent(iAn+1,iDr+1,GetCellContent(iAn,iDr)); | |
143 | } | |
144 | } | |
145 | return hmap; | |
146 | } | |
147 | //______________________________________________________________________ | |
6c790b32 | 148 | TH1F* AliITSCorrMapSDD::GetMapProfile() const{ |
149 | // Returns a TH1F with the projection of the map along drift coordinate | |
2c4e6a6a | 150 | TString hname; |
151 | hname.Form("p%s",GetName()); | |
152 | TH1F* hprof=new TH1F(hname.Data(),"",fNDriftPts,0.,35.); | |
6c790b32 | 153 | for(Int_t iDr=0;iDr<fNDriftPts; iDr++){ |
154 | Float_t meanval=0.; | |
155 | for(Int_t iAn=0;iAn<fNAnodePts; iAn++){ | |
156 | meanval+=GetCellContent(iAn,iDr); | |
157 | } | |
158 | hprof->SetBinContent(iDr+1,meanval/fNAnodePts); | |
159 | } | |
160 | return hprof; | |
161 | ||
162 | } | |
163 | //______________________________________________________________________ | |
54af1add | 164 | TH1F* AliITSCorrMapSDD::GetResidualDistr(Float_t dmin, Float_t dmax) const{ |
165 | // Returns a TH1F histogram with distribution of residual | |
2c4e6a6a | 166 | TString hname; |
167 | hname.Form("hd%s",GetName()); | |
168 | TH1F* hd=new TH1F(hname.Data(),"",100,dmin,dmax); | |
54af1add | 169 | for(Int_t iAn=0;iAn<fNAnodePts; iAn++){ |
170 | for(Int_t iDr=0;iDr<fNDriftPts; iDr++){ | |
171 | hd->Fill(GetCellContent(iAn,iDr)); | |
172 | } | |
173 | } | |
174 | return hd; | |
175 | } |