]>
Commit | Line | Data |
---|---|---|
d3da6dc4 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ////////////////////////////////////////////////////////////////////////// | |
17 | // // | |
18 | // AliHMPIDRecon // | |
19 | // // | |
20 | // HMPID class to perfom pattern recognition based on Hough transfrom // | |
21 | // for single chamber // | |
22 | ////////////////////////////////////////////////////////////////////////// | |
23 | ||
a591e55f | 24 | #include "AliHMPIDRecon.h" //class header |
d3da6dc4 | 25 | #include "AliHMPIDCluster.h" //CkovAngle() |
a591e55f | 26 | #include <TRotation.h> //TracePhot() |
27 | #include <TH1D.h> //HoughResponse() | |
28 | #include <TClonesArray.h> //CkovAngle() | |
29 | #include <AliESDtrack.h> //CkovAngle() | |
d3da6dc4 | 30 | |
d3da6dc4 | 31 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
c61a7285 | 32 | AliHMPIDRecon::AliHMPIDRecon(): |
33 | TTask("RichRec","RichPat"), | |
34 | fPhotCnt(-1), | |
cdf0e3d9 | 35 | fPhotFlag(0x0), |
36 | fPhotCkov(0x0), | |
37 | fPhotPhi(0x0), | |
38 | fPhotWei(0x0), | |
c61a7285 | 39 | fCkovSigma2(0), |
40 | fIsWEIGHT(kFALSE), | |
41 | fDTheta(0.001), | |
42 | fWindowWidth(0.045), | |
43 | fRingArea(0), | |
44 | fRingAcc(0), | |
45 | fTrkDir(0,0,1), // Just for test | |
46 | fTrkPos(30,40), // Just for test | |
cdf0e3d9 | 47 | fMipPos(0,0), |
48 | fPc(0,0), | |
c61a7285 | 49 | fParam(AliHMPIDParam::Instance()) |
d3da6dc4 | 50 | { |
ffb1ac19 | 51 | //.. |
52 | //init of data members | |
53 | //.. | |
54 | ||
ffb1ac19 | 55 | fParam->SetRefIdx(fParam->MeanIdxRad()); // initialization of ref index to a default one |
56 | } | |
57 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
58 | void AliHMPIDRecon::InitVars(Int_t n) | |
59 | { | |
60 | //.. | |
61 | //Init some variables | |
62 | //.. | |
63 | if(n<0) return; | |
64 | fPhotFlag = new Int_t[n]; | |
65 | fPhotCkov = new Double_t[n]; | |
66 | fPhotPhi = new Double_t[n]; | |
67 | fPhotWei = new Double_t[n]; | |
68 | // | |
69 | } | |
70 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
606697a8 | 71 | void AliHMPIDRecon::DeleteVars()const |
ffb1ac19 | 72 | { |
73 | //.. | |
74 | //Delete variables | |
75 | //.. | |
76 | delete fPhotFlag; | |
77 | delete fPhotCkov; | |
78 | delete fPhotPhi; | |
79 | delete fPhotWei; | |
d3da6dc4 | 80 | } |
81 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
afe12692 | 82 | void AliHMPIDRecon::CkovAngle(AliESDtrack *pTrk,TClonesArray *pCluLst,Double_t nmean,Double_t qthre) |
d3da6dc4 | 83 | { |
84 | // Pattern recognition method based on Hough transform | |
59280a5a | 85 | // Arguments: pTrk - track for which Ckov angle is to be found |
86 | // pCluLst - list of clusters for this chamber | |
87 | // Returns: - track ckov angle, [rad], | |
a591e55f | 88 | |
39cd22e6 | 89 | |
90 | const Int_t nMinPhotAcc = 3; // Minimum number of photons required to perform the pattern recognition | |
91 | ||
92 | ||
ffb1ac19 | 93 | Int_t nClusTot = pCluLst->GetEntries(); |
94 | if(nClusTot>fParam->MultCut()) fIsWEIGHT = kTRUE; // offset to take into account bkg in reconstruction | |
95 | else fIsWEIGHT = kFALSE; | |
d3da6dc4 | 96 | |
ffb1ac19 | 97 | InitVars(nClusTot); |
98 | ||
611e810d | 99 | Float_t xRa,yRa,th,ph; |
a591e55f | 100 | pTrk->GetHMPIDtrk(xRa,yRa,th,ph); //initialize this track: th and ph angles at middle of RAD |
a591e55f | 101 | SetTrack(xRa,yRa,th,ph); |
611e810d | 102 | |
ffb1ac19 | 103 | fParam->SetRefIdx(nmean); |
d3da6dc4 | 104 | |
43d3333b | 105 | Float_t dMin=999,mipX=-1,mipY=-1;Int_t chId=-1,mipId=-1,mipQ=-1; |
106 | Int_t sizeClu = -1; | |
107 | fPhotCnt=0; | |
d3da6dc4 | 108 | for (Int_t iClu=0; iClu<pCluLst->GetEntriesFast();iClu++){//clusters loop |
109 | AliHMPIDCluster *pClu=(AliHMPIDCluster*)pCluLst->UncheckedAt(iClu); //get pointer to current cluster | |
59280a5a | 110 | chId=pClu->Ch(); |
afe12692 | 111 | if(pClu->Q()>qthre){ //charge compartible with MIP clusters |
a591e55f | 112 | Float_t dX=fPc.X()-pClu->X(),dY=fPc.Y()-pClu->Y(),d =TMath::Sqrt(dX*dX+dY*dY); //distance between current cluster and intersection point |
43d3333b | 113 | if( d < dMin) {mipId=iClu; dMin=d;mipX=pClu->X(); |
114 | mipY=pClu->Y();mipQ=(Int_t)pClu->Q();sizeClu=pClu->Size();} //current cluster is closer, overwrite data for min cluster | |
a591e55f | 115 | }else{ //charge compatible with photon cluster |
116 | Double_t thetaCer,phiCer; | |
117 | if(FindPhotCkov(pClu->X(),pClu->Y(),thetaCer,phiCer)){ //find ckov angle for this photon candidate | |
118 | fPhotCkov[fPhotCnt]=thetaCer; //actual theta Cerenkov (in TRS) | |
b4ad85e9 | 119 | fPhotPhi [fPhotCnt]=phiCer; //actual phi Cerenkov (in TRS): -pi to come back to "unusual" ref system (X,Y,-Z) |
28500fe1 | 120 | //PH Printf("photon n. %i reconstructed theta = %f",fPhotCnt,fPhotCkov[fPhotCnt]); |
a591e55f | 121 | fPhotCnt++; //increment counter of photon candidates |
122 | } | |
59280a5a | 123 | } |
d3da6dc4 | 124 | }//clusters loop |
43d3333b | 125 | |
126 | pTrk->SetHMPIDmip(mipX,mipY,mipQ,fPhotCnt); //store mip info in any case | |
e26c20fa | 127 | |
128 | if(nmean < 0){ //track didn' t pass through the radiator | |
129 | pTrk->SetHMPIDsignal(kNoRad); //set the appropriate flag | |
130 | pTrk->SetHMPIDcluIdx(chId,mipId+1000*sizeClu); //set index of cluster | |
131 | return; | |
132 | } | |
133 | ||
39cd22e6 | 134 | if(fPhotCnt<=nMinPhotAcc) { //no reconstruction with <=3 photon candidates |
135 | pTrk->SetHMPIDsignal(kNoPhotAccept); //set the appropriate flag | |
43d3333b | 136 | pTrk->SetHMPIDcluIdx(chId,mipId+1000*sizeClu); //set index of cluster |
39cd22e6 | 137 | return; |
138 | } | |
139 | ||
f1970e74 | 140 | if(mipId==-1) { |
141 | pTrk->SetHMPIDcluIdx(chId,9999); //set index of cluster | |
142 | pTrk->SetHMPIDsignal(kMipQdcCut); | |
143 | return; | |
144 | } //no clusters with QDC more the threshold at all | |
43d3333b | 145 | pTrk->SetHMPIDcluIdx(chId,mipId+1000*sizeClu); //set chamber, index of cluster + cluster size |
f1970e74 | 146 | if(dMin>fParam->DistCut()) {pTrk->SetHMPIDsignal(kMipDistCut); return;} //closest cluster with enough charge is still too far from intersection |
147 | ||
148 | fMipPos.Set(mipX,mipY); | |
149 | ||
39cd22e6 | 150 | |
151 | //PATTERN RECOGNITION STARTED: | |
152 | ||
2d1a9b21 | 153 | Int_t iNrec=FlagPhot(HoughResponse()); //flag photons according to individual theta ckov with respect to most probable |
154 | pTrk->SetHMPIDmip(mipX,mipY,mipQ,iNrec); //store mip info | |
59280a5a | 155 | |
2d1a9b21 | 156 | if(iNrec<1){ |
157 | pTrk->SetHMPIDsignal(kNoPhotAccept); //no photon candidates are accepted | |
f1970e74 | 158 | return; |
76fd1a96 | 159 | } |
f1970e74 | 160 | Double_t thetaC = FindRingCkov(pCluLst->GetEntries()); //find the best reconstructed theta Cherenkov |
2d1a9b21 | 161 | // FindRingGeom(thetaC,2); |
f1970e74 | 162 | pTrk->SetHMPIDsignal(thetaC); //store theta Cherenkov |
163 | pTrk->SetHMPIDchi2(fCkovSigma2); //store errors squared | |
d3da6dc4 | 164 | |
ffb1ac19 | 165 | DeleteVars(); |
43400d2d | 166 | }//CkovAngle() |
d3da6dc4 | 167 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
a591e55f | 168 | Bool_t AliHMPIDRecon::FindPhotCkov(Double_t cluX,Double_t cluY,Double_t &thetaCer,Double_t &phiCer) |
d3da6dc4 | 169 | { |
170 | // Finds Cerenkov angle for this photon candidate | |
171 | // Arguments: cluX,cluY - position of cadidate's cluster | |
a591e55f | 172 | // Returns: Cerenkov angle |
d3da6dc4 | 173 | |
a591e55f | 174 | TVector3 dirCkov; |
175 | ||
ffb1ac19 | 176 | Double_t zRad= -0.5*fParam->RadThick()-0.5*fParam->WinThick(); //z position of middle of RAD |
67a1c24c | 177 | TVector3 rad(fTrkPos.X(),fTrkPos.Y(),zRad); //impact point at middle of RAD |
ffb1ac19 | 178 | TVector3 pc(cluX,cluY,0.5*fParam->WinThick()+fParam->GapIdx()); //mip at PC |
a591e55f | 179 | Double_t cluR = TMath::Sqrt((cluX-fTrkPos.X())*(cluX-fTrkPos.X())+ |
180 | (cluY-fTrkPos.Y())*(cluY-fTrkPos.Y()));//ref. distance impact RAD-CLUSTER | |
67a1c24c | 181 | Double_t phi=(pc-rad).Phi(); //phi of photon |
a591e55f | 182 | |
b4ad85e9 | 183 | Double_t ckov1=0; |
67a1c24c | 184 | Double_t ckov2=0.75+fTrkDir.Theta(); //start to find theta cerenkov in DRS |
b4ad85e9 | 185 | const Double_t kTol=0.01; |
d3da6dc4 | 186 | Int_t iIterCnt = 0; |
187 | while(1){ | |
a591e55f | 188 | if(iIterCnt>=50) return kFALSE; |
d3da6dc4 | 189 | Double_t ckov=0.5*(ckov1+ckov2); |
67a1c24c | 190 | dirCkov.SetMagThetaPhi(1,ckov,phi); |
a591e55f | 191 | TVector2 posC=TraceForward(dirCkov); //trace photon with actual angles |
192 | Double_t dist=cluR-(posC-fTrkPos).Mod(); //get distance between trial point and cluster position | |
193 | if(posC.X()==-999) dist = - 999; //total reflection problem | |
194 | iIterCnt++; //counter step | |
b4ad85e9 | 195 | if (dist> kTol) ckov1=ckov; //cluster @ larger ckov |
d3da6dc4 | 196 | else if(dist<-kTol) ckov2=ckov; //cluster @ smaller ckov |
a591e55f | 197 | else{ //precision achived: ckov in DRS found |
198 | dirCkov.SetMagThetaPhi(1,ckov,phi); // | |
2d1a9b21 | 199 | Lors2Trs(dirCkov,thetaCer,phiCer); //find ckov (in TRS:the effective Cherenkov angle!) |
a591e55f | 200 | return kTRUE; |
201 | } | |
d3da6dc4 | 202 | } |
203 | }//FindPhotTheta() | |
204 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
a591e55f | 205 | TVector2 AliHMPIDRecon::TraceForward(TVector3 dirCkov)const |
d3da6dc4 | 206 | { |
a591e55f | 207 | //Trace forward a photon from (x,y) up to PC |
208 | // Arguments: dirCkov photon vector in LORS | |
209 | // Returns: pos of traced photon at PC | |
ffb1ac19 | 210 | |
a591e55f | 211 | TVector2 pos(-999,-999); |
67a1c24c | 212 | Double_t thetaCer = dirCkov.Theta(); |
ffb1ac19 | 213 | if(thetaCer > TMath::ASin(1./fParam->GetRefIdx())) return pos; //total refraction on WIN-GAP boundary |
214 | Double_t zRad= -0.5*fParam->RadThick()-0.5*fParam->WinThick(); //z position of middle of RAD | |
215 | TVector3 posCkov(fTrkPos.X(),fTrkPos.Y(),zRad); //RAD: photon position is track position @ middle of RAD | |
216 | Propagate(dirCkov,posCkov, -0.5*fParam->WinThick()); //go to RAD-WIN boundary | |
217 | Refract (dirCkov, fParam->GetRefIdx(),fParam->WinIdx()); //RAD-WIN refraction | |
218 | Propagate(dirCkov,posCkov, 0.5*fParam->WinThick()); //go to WIN-GAP boundary | |
219 | Refract (dirCkov, fParam->WinIdx(),fParam->GapIdx()); //WIN-GAP refraction | |
220 | Propagate(dirCkov,posCkov,0.5*fParam->WinThick()+fParam->GapThick()); //go to PC | |
a591e55f | 221 | pos.Set(posCkov.X(),posCkov.Y()); |
222 | return pos; | |
223 | }//TraceForward() | |
224 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
2d1a9b21 | 225 | void AliHMPIDRecon::Lors2Trs(TVector3 dirCkov,Double_t &thetaCer,Double_t &phiCer)const |
a591e55f | 226 | { |
227 | //Theta Cerenkov reconstruction | |
2d1a9b21 | 228 | // Arguments: dirCkov photon vector in LORS |
229 | // Returns: thetaCer of photon in TRS | |
230 | // phiCer of photon in TRS | |
a591e55f | 231 | // TVector3 dirTrk; |
232 | // dirTrk.SetMagThetaPhi(1,fTrkDir.Theta(),fTrkDir.Phi()); | |
233 | // Double_t thetaCer = TMath::ACos(dirCkov*dirTrk); | |
2d1a9b21 | 234 | TRotation mtheta; mtheta.RotateY(-fTrkDir.Theta()); |
235 | TRotation mphi; mphi.RotateZ(-fTrkDir.Phi()); | |
a591e55f | 236 | TRotation mrot=mtheta*mphi; |
237 | TVector3 dirCkovTRS; | |
238 | dirCkovTRS=mrot*dirCkov; | |
239 | phiCer = dirCkovTRS.Phi(); //actual value of the phi of the photon | |
240 | thetaCer= dirCkovTRS.Theta(); //actual value of thetaCerenkov of the photon | |
d3da6dc4 | 241 | } |
242 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
2d1a9b21 | 243 | void AliHMPIDRecon::Trs2Lors(TVector3 dirCkov,Double_t &thetaCer,Double_t &phiCer)const |
244 | { | |
245 | //Theta Cerenkov reconstruction | |
246 | // Arguments: dirCkov photon vector in TRS | |
247 | // Returns: thetaCer of photon in LORS | |
248 | // phiCer of photon in LORS | |
249 | TRotation mtheta; mtheta.RotateY(fTrkDir.Theta()); | |
250 | TRotation mphi; mphi.RotateZ(fTrkDir.Phi()); | |
251 | TRotation mrot=mphi*mtheta; | |
252 | TVector3 dirCkovLORS; | |
253 | dirCkovLORS=mrot*dirCkov; | |
254 | phiCer = dirCkovLORS.Phi(); //actual value of the phi of the photon | |
255 | thetaCer= dirCkovLORS.Theta(); //actual value of thetaCerenkov of the photon | |
256 | } | |
257 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
258 | void AliHMPIDRecon::FindRingGeom(Double_t ckovAng,Int_t level) | |
d3da6dc4 | 259 | { |
4598109f | 260 | // Find area covered in the PC acceptance |
2d1a9b21 | 261 | // Arguments: ckovAng - cerenkov angle |
262 | // level - precision in finding area and portion of ring accepted (multiple of 50) | |
d3da6dc4 | 263 | // Returns: area of the ring in cm^2 for given theta ckov |
264 | ||
2d1a9b21 | 265 | Int_t kN=50*level; |
266 | Int_t nPoints = 0; | |
afe12692 | 267 | Double_t area=0; |
2d1a9b21 | 268 | |
4598109f | 269 | Bool_t first=kFALSE; |
2d1a9b21 | 270 | TVector2 pos1; |
271 | ||
afe12692 | 272 | for(Int_t i=0;i<kN;i++){ |
4598109f | 273 | if(!first) { |
2d1a9b21 | 274 | pos1=TracePhot(ckovAng,Double_t(TMath::TwoPi()*(i+1)/kN)); //find a good trace for the first photon |
4598109f | 275 | if(pos1.X()==-999) continue; //no area: open ring |
2d1a9b21 | 276 | if(!fParam->IsInside(pos1.X(),pos1.Y(),0)) { |
277 | pos1 = IntWithEdge(fMipPos,pos1); // find the very first intersection... | |
278 | } else { | |
279 | if(!AliHMPIDParam::IsInDead(pos1.X(),pos1.Y())) nPoints++; //photon is accepted if not in dead zone | |
280 | } | |
4598109f | 281 | first=kTRUE; |
282 | continue; | |
283 | } | |
284 | TVector2 pos2=TracePhot(ckovAng,Double_t(TMath::TwoPi()*(i+1)/kN)); //trace the next photon | |
285 | if(pos2.X()==-999) continue; //no area: open ring | |
ffb1ac19 | 286 | if(!fParam->IsInside(pos2.X(),pos2.Y(),0)) { |
4598109f | 287 | pos2 = IntWithEdge(fMipPos,pos2); |
2d1a9b21 | 288 | } else { |
289 | if(!AliHMPIDParam::IsInDead(pos2.X(),pos2.Y())) nPoints++; //photon is accepted if not in dead zone | |
4598109f | 290 | } |
291 | area+=TMath::Abs((pos1-fMipPos).X()*(pos2-fMipPos).Y()-(pos1-fMipPos).Y()*(pos2-fMipPos).X()); //add area of the triangle... | |
292 | pos1 = pos2; | |
d3da6dc4 | 293 | } |
2d1a9b21 | 294 | //--- find area and length of the ring; |
295 | fRingAcc = (Double_t)nPoints/(Double_t)kN; | |
7fc88c5e | 296 | area*=0.5; |
2d1a9b21 | 297 | fRingArea = area; |
298 | }//FindRingGeom() | |
d3da6dc4 | 299 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
4598109f | 300 | TVector2 AliHMPIDRecon::IntWithEdge(TVector2 p1,TVector2 p2)const |
301 | { | |
302 | // It finds the intersection of the line for 2 points traced as photons | |
303 | // and the edge of a given PC | |
304 | // Arguments: 2 points obtained tracing the photons | |
305 | // Returns: intersection point with detector (PC) edges | |
306 | ||
4598109f | 307 | Double_t xmin = (p1.X()<p2.X())? p1.X():p2.X(); |
308 | Double_t xmax = (p1.X()<p2.X())? p2.X():p1.X(); | |
309 | Double_t ymin = (p1.Y()<p2.Y())? p1.Y():p2.Y(); | |
310 | Double_t ymax = (p1.Y()<p2.Y())? p2.Y():p1.Y(); | |
311 | ||
312 | Double_t m = TMath::Tan((p2-p1).Phi()); | |
313 | TVector2 pint; | |
314 | //intersection with low X | |
315 | pint.Set((Double_t)(p1.X() + (0-p1.Y())/m),0.); | |
ffb1ac19 | 316 | if(pint.X()>=0 && pint.X()<=fParam->SizeAllX() && |
4598109f | 317 | pint.X()>=xmin && pint.X()<=xmax && |
318 | pint.Y()>=ymin && pint.Y()<=ymax) return pint; | |
319 | //intersection with high X | |
ffb1ac19 | 320 | pint.Set((Double_t)(p1.X() + (fParam->SizeAllY()-p1.Y())/m),(Double_t)(fParam->SizeAllY())); |
321 | if(pint.X()>=0 && pint.X()<=fParam->SizeAllX() && | |
4598109f | 322 | pint.X()>=xmin && pint.X()<=xmax && |
323 | pint.Y()>=ymin && pint.Y()<=ymax) return pint; | |
324 | //intersection with left Y | |
325 | pint.Set(0.,(Double_t)(p1.Y() + m*(0-p1.X()))); | |
ffb1ac19 | 326 | if(pint.Y()>=0 && pint.Y()<=fParam->SizeAllY() && |
4598109f | 327 | pint.Y()>=ymin && pint.Y()<=ymax && |
328 | pint.X()>=xmin && pint.X()<=xmax) return pint; | |
329 | //intersection with righ Y | |
ffb1ac19 | 330 | pint.Set((Double_t)(fParam->SizeAllX()),(Double_t)(p1.Y() + m*(fParam->SizeAllX()-p1.X()))); |
331 | if(pint.Y()>=0 && pint.Y()<=fParam->SizeAllY() && | |
4598109f | 332 | pint.Y()>=ymin && pint.Y()<=ymax && |
333 | pint.X()>=xmin && pint.X()<=xmax) return pint; | |
334 | return p1; | |
335 | }//IntWithEdge() | |
336 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
d3da6dc4 | 337 | Double_t AliHMPIDRecon::FindRingCkov(Int_t) |
338 | { | |
339 | // Loops on all Ckov candidates and estimates the best Theta Ckov for a ring formed by those candidates. Also estimates an error for that Theat Ckov | |
340 | // collecting errors for all single Ckov candidates thetas. (Assuming they are independent) | |
341 | // Arguments: iNclus- total number of clusters in chamber for background estimation | |
342 | // Return: best estimation of track Theta ckov | |
343 | ||
344 | Double_t wei = 0.; | |
345 | Double_t weightThetaCerenkov = 0.; | |
346 | ||
347 | Double_t ckovMin=9999.,ckovMax=0.; | |
348 | Double_t sigma2 = 0; //to collect error squared for this ring | |
349 | ||
350 | for(Int_t i=0;i<fPhotCnt;i++){//candidates loop | |
351 | if(fPhotFlag[i] == 2){ | |
a591e55f | 352 | if(fPhotCkov[i]<ckovMin) ckovMin=fPhotCkov[i]; //find max and min Theta ckov from all candidates within probable window |
d3da6dc4 | 353 | if(fPhotCkov[i]>ckovMax) ckovMax=fPhotCkov[i]; |
a591e55f | 354 | weightThetaCerenkov += fPhotCkov[i]*fPhotWei[i]; |
355 | wei += fPhotWei[i]; //collect weight as sum of all candidate weghts | |
d3da6dc4 | 356 | |
3278403b | 357 | sigma2 += 1./fParam->Sigma2(fTrkDir.Theta(),fTrkDir.Phi(),fPhotCkov[i],fPhotPhi[i]); |
d3da6dc4 | 358 | } |
359 | }//candidates loop | |
360 | ||
361 | if(sigma2>0) fCkovSigma2=1./sigma2; | |
362 | else fCkovSigma2=1e10; | |
363 | ||
b4ad85e9 | 364 | if(wei != 0.) weightThetaCerenkov /= wei; else weightThetaCerenkov = 0.; |
d3da6dc4 | 365 | return weightThetaCerenkov; |
366 | }//FindCkovRing() | |
367 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
368 | Int_t AliHMPIDRecon::FlagPhot(Double_t ckov) | |
369 | { | |
370 | // Flag photon candidates if their individual ckov angle is inside the window around ckov angle returned by HoughResponse() | |
371 | // Arguments: ckov- value of most probable ckov angle for track as returned by HoughResponse() | |
372 | // Returns: number of photon candidates happened to be inside the window | |
373 | ||
a591e55f | 374 | // Photon Flag: Flag = 0 initial set; |
375 | // Flag = 1 good candidate (charge compatible with photon); | |
376 | // Flag = 2 photon used for the ring; | |
d3da6dc4 | 377 | |
378 | Int_t steps = (Int_t)((ckov )/ fDTheta); //how many times we need to have fDTheta to fill the distance between 0 and thetaCkovHough | |
379 | ||
380 | Double_t tmin = (Double_t)(steps - 1)*fDTheta; | |
381 | Double_t tmax = (Double_t)(steps)*fDTheta; | |
382 | Double_t tavg = 0.5*(tmin+tmax); | |
383 | ||
384 | tmin = tavg - 0.5*fWindowWidth; tmax = tavg + 0.5*fWindowWidth; | |
385 | ||
386 | Int_t iInsideCnt = 0; //count photons which Theta ckov inside the window | |
387 | for(Int_t i=0;i<fPhotCnt;i++){//photon candidates loop | |
afe12692 | 388 | fPhotFlag[i] = 0; |
d3da6dc4 | 389 | if(fPhotCkov[i] >= tmin && fPhotCkov[i] <= tmax) { |
390 | fPhotFlag[i]=2; | |
391 | iInsideCnt++; | |
392 | } | |
393 | } | |
394 | return iInsideCnt; | |
395 | }//FlagPhot() | |
396 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
a591e55f | 397 | TVector2 AliHMPIDRecon::TracePhot(Double_t ckovThe,Double_t ckovPhi)const |
d3da6dc4 | 398 | { |
399 | // Trace a single Ckov photon from emission point somewhere in radiator up to photocathode taking into account ref indexes of materials it travereses | |
ffb1ac19 | 400 | // Arguments: ckovThe,ckovPhi- photon ckov angles in TRS, [rad] |
d3da6dc4 | 401 | // Returns: distance between photon point on PC and track projection |
2d1a9b21 | 402 | |
403 | Double_t theta,phi; | |
404 | TVector3 dirTRS,dirLORS; | |
405 | dirTRS.SetMagThetaPhi(1,ckovThe,ckovPhi); //photon in TRS | |
406 | Trs2Lors(dirTRS,theta,phi); | |
407 | dirLORS.SetMagThetaPhi(1,theta,phi); //photon in LORS | |
408 | return TraceForward(dirLORS); //now foward tracing | |
a591e55f | 409 | }//TracePhot() |
d3da6dc4 | 410 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
a591e55f | 411 | void AliHMPIDRecon::Propagate(const TVector3 dir,TVector3 &pos,Double_t z)const |
d3da6dc4 | 412 | { |
413 | // Finds an intersection point between a line and XY plane shifted along Z. | |
414 | // Arguments: dir,pos - vector along the line and any point of the line | |
415 | // z - z coordinate of plain | |
416 | // Returns: none | |
417 | // On exit: pos is the position if this intesection if any | |
418 | static TVector3 nrm(0,0,1); | |
419 | TVector3 pnt(0,0,z); | |
420 | ||
421 | TVector3 diff=pnt-pos; | |
422 | Double_t sint=(nrm*diff)/(nrm*dir); | |
423 | pos+=sint*dir; | |
424 | }//Propagate() | |
425 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
426 | void AliHMPIDRecon::Refract(TVector3 &dir,Double_t n1,Double_t n2)const | |
427 | { | |
428 | // Refract direction vector according to Snell law | |
429 | // Arguments: | |
430 | // n1 - ref idx of first substance | |
431 | // n2 - ref idx of second substance | |
432 | // Returns: none | |
433 | // On exit: dir is new direction | |
67a1c24c | 434 | Double_t sinref=(n1/n2)*TMath::Sin(dir.Theta()); |
76fd1a96 | 435 | if(TMath::Abs(sinref)>1.) dir.SetXYZ(-999,-999,-999); |
67a1c24c | 436 | else dir.SetTheta(TMath::ASin(sinref)); |
d3da6dc4 | 437 | }//Refract() |
438 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
439 | Double_t AliHMPIDRecon::HoughResponse() | |
440 | { | |
441 | // | |
611e810d | 442 | // fIdxMip = mipId; |
443 | ||
d3da6dc4 | 444 | // |
445 | Double_t kThetaMax=0.75; | |
446 | Int_t nChannels = (Int_t)(kThetaMax/fDTheta+0.5); | |
447 | TH1D *phots = new TH1D("Rphot" ,"phots" ,nChannels,0,kThetaMax); | |
448 | TH1D *photsw = new TH1D("RphotWeighted" ,"photsw" ,nChannels,0,kThetaMax); | |
449 | TH1D *resultw = new TH1D("resultw","resultw" ,nChannels,0,kThetaMax); | |
450 | Int_t nBin = (Int_t)(kThetaMax/fDTheta); | |
451 | Int_t nCorrBand = (Int_t)(fWindowWidth/(2*fDTheta)); | |
452 | ||
453 | for (Int_t i=0; i< fPhotCnt; i++){//photon cadidates loop | |
454 | Double_t angle = fPhotCkov[i]; if(angle<0||angle>kThetaMax) continue; | |
455 | phots->Fill(angle); | |
456 | Int_t bin = (Int_t)(0.5+angle/(fDTheta)); | |
457 | Double_t weight=1.; | |
458 | if(fIsWEIGHT){ | |
afe12692 | 459 | Double_t lowerlimit = ((Double_t)bin)*fDTheta - 0.5*fDTheta; Double_t upperlimit = ((Double_t)bin)*fDTheta + 0.5*fDTheta; |
2d1a9b21 | 460 | FindRingGeom(lowerlimit); |
461 | Double_t areaLow = GetRingArea(); | |
462 | FindRingGeom(upperlimit); | |
463 | Double_t areaHigh = GetRingArea(); | |
464 | Double_t diffArea = areaHigh - areaLow; | |
d3da6dc4 | 465 | if(diffArea>0) weight = 1./diffArea; |
466 | } | |
467 | photsw->Fill(angle,weight); | |
468 | fPhotWei[i]=weight; | |
469 | }//photon candidates loop | |
470 | ||
471 | for (Int_t i=1; i<=nBin;i++){ | |
472 | Int_t bin1= i-nCorrBand; | |
473 | Int_t bin2= i+nCorrBand; | |
474 | if(bin1<1) bin1=1; | |
475 | if(bin2>nBin)bin2=nBin; | |
476 | Double_t sumPhots=phots->Integral(bin1,bin2); | |
477 | if(sumPhots<3) continue; // if less then 3 photons don't trust to this ring | |
478 | Double_t sumPhotsw=photsw->Integral(bin1,bin2); | |
479 | resultw->Fill((Double_t)((i+0.5)*fDTheta),sumPhotsw); | |
480 | } | |
481 | // evaluate the "BEST" theta ckov as the maximum value of histogramm | |
482 | Double_t *pVec = resultw->GetArray(); | |
483 | Int_t locMax = TMath::LocMax(nBin,pVec); | |
3ebd8038 | 484 | delete phots;delete photsw;delete resultw; // Reset and delete objects |
d3da6dc4 | 485 | |
486 | return (Double_t)(locMax*fDTheta+0.5*fDTheta); //final most probable track theta ckov | |
487 | }//HoughResponse() | |
488 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |