]>
Commit | Line | Data |
---|---|---|
d15a28e7 | 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 | ||
b2a60966 | 16 | /* $Id$ */ |
17 | ||
d15a28e7 | 18 | //_________________________________________________________________________ |
b2a60966 | 19 | // Implementation version 1 of algorithm class to construct PHOS track segments |
20 | // Associates EMC and PPSD clusters | |
21 | // Unfolds the EMC cluster | |
22 | // | |
23 | //*-- Author: Dmitri Peressounko (RRC Ki & SUBATECH) | |
24 | // | |
d15a28e7 | 25 | |
26 | // --- ROOT system --- | |
27 | ||
28 | #include "TObjArray.h" | |
29 | #include "TClonesArray.h" | |
9f616d61 | 30 | #include "TObjectTable.h" |
d15a28e7 | 31 | |
32 | // --- Standard library --- | |
33 | ||
de9ec31b | 34 | #include <iostream.h> |
d15a28e7 | 35 | |
36 | // --- AliRoot header files --- | |
37 | ||
38 | #include "AliPHOSTrackSegmentMakerv1.h" | |
39 | #include "AliPHOSTrackSegment.h" | |
40 | #include "AliPHOSLink.h" | |
41 | #include "AliPHOSv0.h" | |
42 | #include "AliRun.h" | |
43 | ||
92862013 | 44 | extern void UnfoldingChiSquare(Int_t &nPar, Double_t *Grad, Double_t & fret, Double_t *x, Int_t iflag) ; |
9f616d61 | 45 | |
d15a28e7 | 46 | ClassImp( AliPHOSTrackSegmentMakerv1) |
47 | ||
48 | ||
49 | //____________________________________________________________________________ | |
b2a60966 | 50 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : AliPHOSTrackSegmentMaker() |
d15a28e7 | 51 | { |
9f616d61 | 52 | // ctor |
b2a60966 | 53 | |
d15a28e7 | 54 | fR0 = 4. ; |
55 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; | |
56 | //clusters are sorted in "rows" and "columns" of width geom->GetCrystalSize(0), | |
57 | fDelta = fR0 + geom->GetCrystalSize(0) ; | |
6727be7e | 58 | fMinuit = new TMinuit(100) ; |
59 | fUnfoldFlag = kTRUE ; | |
d15a28e7 | 60 | } |
61 | ||
9f616d61 | 62 | //____________________________________________________________________________ |
63 | AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1() | |
64 | { | |
65 | // dtor | |
b2a60966 | 66 | |
67 | delete fMinuit ; | |
9f616d61 | 68 | } |
b2a60966 | 69 | |
d15a28e7 | 70 | //____________________________________________________________________________ |
71 | Bool_t AliPHOSTrackSegmentMakerv1::FindFit(AliPHOSEmcRecPoint * emcRP, int * maxAt, Float_t * maxAtEnergy, | |
92862013 | 72 | Int_t nPar, Float_t * fitparameters) |
9f616d61 | 73 | { |
b2a60966 | 74 | // Calls TMinuit to fit the energy distribution of a cluster with several maxima |
6ad0bfa0 | 75 | |
d15a28e7 | 76 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; |
d15a28e7 | 77 | |
9f616d61 | 78 | gMinuit->SetPrintLevel(-1) ; // No Printout |
79 | gMinuit->SetFCN(UnfoldingChiSquare) ; // To set the address of the minimization function | |
80 | gMinuit->SetObjectFit(emcRP) ; // To tranfer pointer to UnfoldingChiSquare | |
81 | ||
82 | // filling initial values for fit parameters | |
d15a28e7 | 83 | AliPHOSDigit * digit ; |
9f616d61 | 84 | |
85 | Int_t ierflg = 0; | |
86 | Int_t index = 0 ; | |
92862013 | 87 | Int_t nDigits = (Int_t) nPar / 3 ; |
9f616d61 | 88 | |
d15a28e7 | 89 | Int_t iDigit ; |
9f616d61 | 90 | |
91 | ||
92862013 | 92 | for(iDigit = 0; iDigit < nDigits; iDigit++){ |
d15a28e7 | 93 | digit = (AliPHOSDigit *) maxAt[iDigit]; |
94 | ||
92862013 | 95 | Int_t relid[4] ; |
d15a28e7 | 96 | Float_t x ; |
97 | Float_t z ; | |
92862013 | 98 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
99 | geom->RelPosInModule(relid, x, z) ; | |
d15a28e7 | 100 | |
92862013 | 101 | Float_t energy = maxAtEnergy[iDigit] ; |
d15a28e7 | 102 | |
9f616d61 | 103 | gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ; |
104 | index++ ; | |
d15a28e7 | 105 | if(ierflg != 0){ |
106 | cout << "PHOS Unfolding> Unable to set initial value for fit procedure : x = " << x << endl ; | |
107 | return kFALSE; | |
108 | } | |
9f616d61 | 109 | gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ; |
110 | index++ ; | |
d15a28e7 | 111 | if(ierflg != 0){ |
112 | cout << "PHOS Unfolding> Unable to set initial value for fit procedure : z = " << z << endl ; | |
113 | return kFALSE; | |
114 | } | |
92862013 | 115 | gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ; |
9f616d61 | 116 | index++ ; |
d15a28e7 | 117 | if(ierflg != 0){ |
92862013 | 118 | cout << "PHOS Unfolding> Unable to set initial value for fit procedure : energy = " << energy << endl ; |
d15a28e7 | 119 | return kFALSE; |
6ad0bfa0 | 120 | } |
d15a28e7 | 121 | } |
122 | ||
9f616d61 | 123 | Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly |
124 | // depends on it. | |
125 | Double_t p1 = 1.0 ; | |
126 | Double_t p2 = 0.0 ; | |
127 | ||
128 | gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TgMinuit to reduce function calls | |
129 | gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient | |
d15a28e7 | 130 | gMinuit->SetMaxIterations(5); |
9f616d61 | 131 | gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings |
132 | gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize | |
133 | if(ierflg == 4){ // Minimum not found | |
134 | cout << "PHOS Unfolding> Fit not converged, cluster abandoned "<< endl ; | |
d15a28e7 | 135 | return kFALSE ; |
136 | } | |
92862013 | 137 | for(index = 0; index < nPar; index++){ |
d15a28e7 | 138 | Double_t err ; |
139 | Double_t val ; | |
9f616d61 | 140 | gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index |
92862013 | 141 | fitparameters[index] = val ; |
d15a28e7 | 142 | } |
d15a28e7 | 143 | return kTRUE; |
9f616d61 | 144 | |
d15a28e7 | 145 | } |
9f616d61 | 146 | |
d15a28e7 | 147 | //____________________________________________________________________________ |
88714635 | 148 | void AliPHOSTrackSegmentMakerv1::FillOneModule(DigitsList * dl, |
149 | AliPHOSRecPoint::RecPointsList * emcIn, | |
150 | TObjArray * emcOut, | |
151 | AliPHOSRecPoint::RecPointsList * ppsdIn, | |
152 | TObjArray * ppsdOutUp, | |
153 | TObjArray * ppsdOutLow, | |
154 | Int_t & phosmod, | |
155 | Int_t & emcStopedAt, | |
156 | Int_t & ppsdStopedAt) | |
9f616d61 | 157 | { |
158 | // Unfold clusters and fill xxxOut arrays with clusters from one PHOS module | |
159 | ||
160 | AliPHOSEmcRecPoint * emcRecPoint ; | |
d15a28e7 | 161 | AliPHOSPpsdRecPoint * ppsdRecPoint ; |
162 | Int_t index ; | |
6ad0bfa0 | 163 | |
92862013 | 164 | Int_t nEmcUnfolded = emcIn->GetEntries() ; |
165 | for(index = emcStopedAt; index < nEmcUnfolded; index++){ | |
83974468 | 166 | emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ; |
6ad0bfa0 | 167 | |
92862013 | 168 | if(emcRecPoint->GetPHOSMod() != phosmod ) |
9f616d61 | 169 | break ; |
170 | ||
92862013 | 171 | Int_t nMultipl = emcRecPoint->GetMultiplicity() ; |
31aa6d6c | 172 | Int_t * maxAt = new Int_t[nMultipl] ; |
173 | Float_t * maxAtEnergy = new Float_t[nMultipl] ; | |
92862013 | 174 | Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy) ; |
6a3f1304 | 175 | |
6727be7e | 176 | if(nMax <= 1 ) // if cluster is very flat (no pronounced maximum) then nMax = 0 |
d15a28e7 | 177 | emcOut->Add(emcRecPoint) ; |
6727be7e | 178 | else if (fUnfoldFlag) { |
b2a60966 | 179 | UnfoldClusters(dl, emcIn, emcRecPoint, nMax, maxAt, maxAtEnergy, emcOut) ; |
d15a28e7 | 180 | emcIn->Remove(emcRecPoint); |
181 | emcIn->Compress() ; | |
92862013 | 182 | nEmcUnfolded-- ; |
d15a28e7 | 183 | index-- ; |
184 | } | |
31aa6d6c | 185 | |
186 | delete[] maxAt ; | |
187 | delete[] maxAtEnergy ; | |
d15a28e7 | 188 | } |
189 | emcStopedAt = index ; | |
190 | ||
191 | for(index = ppsdStopedAt; index < ppsdIn->GetEntries(); index++){ | |
83974468 | 192 | ppsdRecPoint = (AliPHOSPpsdRecPoint *) ppsdIn->At(index) ; |
92862013 | 193 | if(ppsdRecPoint->GetPHOSMod() != phosmod ) |
9f616d61 | 194 | break ; |
d15a28e7 | 195 | if(ppsdRecPoint->GetUp() ) |
196 | ppsdOutUp->Add(ppsdRecPoint) ; | |
197 | else | |
198 | ppsdOutLow->Add(ppsdRecPoint) ; | |
199 | } | |
200 | ppsdStopedAt = index ; | |
6ad0bfa0 | 201 | |
d15a28e7 | 202 | emcOut->Sort() ; |
203 | ppsdOutUp->Sort() ; | |
6ad0bfa0 | 204 | ppsdOutLow->Sort() ; |
d15a28e7 | 205 | } |
206 | //____________________________________________________________________________ | |
92862013 | 207 | Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcclu,AliPHOSPpsdRecPoint * PpsdClu, Bool_t &toofar) |
d15a28e7 | 208 | { |
b2a60966 | 209 | // Calculates the distance between the EMC RecPoint and the PPSD RecPoint |
210 | ||
92862013 | 211 | Float_t r = fR0 ; |
d15a28e7 | 212 | |
213 | TVector3 vecEmc ; | |
214 | TVector3 vecPpsd ; | |
215 | ||
92862013 | 216 | emcclu->GetLocalPosition(vecEmc) ; |
d15a28e7 | 217 | PpsdClu->GetLocalPosition(vecPpsd) ; |
92862013 | 218 | if(emcclu->GetPHOSMod() == PpsdClu->GetPHOSMod()){ |
d15a28e7 | 219 | if(vecPpsd.X() >= vecEmc.X() - fDelta ){ |
220 | if(vecPpsd.Z() >= vecEmc.Z() - fDelta ){ | |
221 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; | |
6ad0bfa0 | 222 | // Correct to difference in CPV and EMC position due to different distance to center. |
223 | // we assume, that particle moves from center | |
92862013 | 224 | Float_t dCPV = geom->GetIPtoOuterCoverDistance(); |
225 | Float_t dEMC = geom->GetIPtoCrystalSurface() ; | |
226 | dEMC = dEMC / dCPV ; | |
227 | vecPpsd = dEMC * vecPpsd - vecEmc ; | |
228 | r = vecPpsd.Mag() ; | |
d15a28e7 | 229 | } // if zPpsd >= zEmc - fDelta |
92862013 | 230 | toofar = kFALSE ; |
d15a28e7 | 231 | } // if xPpsd >= xEmc - fDelta |
232 | else | |
92862013 | 233 | toofar = kTRUE ; |
d15a28e7 | 234 | } |
235 | else | |
92862013 | 236 | toofar = kTRUE ; |
d15a28e7 | 237 | |
92862013 | 238 | return r ; |
d15a28e7 | 239 | } |
240 | ||
241 | //____________________________________________________________________________ | |
92862013 | 242 | void AliPHOSTrackSegmentMakerv1::MakeLinks(TObjArray * emcRecPoints, TObjArray * ppsdRecPointsUp, |
243 | TObjArray * ppsdRecPointsLow, TClonesArray * linklowArray, | |
244 | TClonesArray *linkupArray) | |
d15a28e7 | 245 | { |
b2a60966 | 246 | // Finds distances (links) between all EMC and PPSD clusters, which are not further apart from each other than fR0 |
247 | ||
92862013 | 248 | TIter nextEmc(emcRecPoints) ; |
d15a28e7 | 249 | Int_t iEmcClu = 0 ; |
250 | ||
92862013 | 251 | AliPHOSPpsdRecPoint * ppsdlow ; |
252 | AliPHOSPpsdRecPoint * ppsdup ; | |
253 | AliPHOSEmcRecPoint * emcclu ; | |
d15a28e7 | 254 | |
255 | Int_t iLinkLow = 0 ; | |
256 | Int_t iLinkUp = 0 ; | |
257 | ||
92862013 | 258 | while( (emcclu = (AliPHOSEmcRecPoint*)nextEmc() ) ) { |
259 | Bool_t toofar ; | |
260 | TIter nextPpsdLow(ppsdRecPointsLow ) ; | |
d15a28e7 | 261 | Int_t iPpsdLow = 0 ; |
262 | ||
92862013 | 263 | while( (ppsdlow = (AliPHOSPpsdRecPoint*)nextPpsdLow() ) ) { |
264 | Float_t r = GetDistanceInPHOSPlane(emcclu, ppsdlow, toofar) ; | |
d15a28e7 | 265 | |
92862013 | 266 | if(toofar) |
d15a28e7 | 267 | break ; |
83974468 | 268 | if(r < fR0){ |
92862013 | 269 | new( (*linklowArray)[iLinkLow++]) AliPHOSLink(r, iEmcClu, iPpsdLow) ; |
83974468 | 270 | } |
d15a28e7 | 271 | iPpsdLow++ ; |
272 | ||
273 | } | |
274 | ||
92862013 | 275 | TIter nextPpsdUp(ppsdRecPointsUp ) ; |
d15a28e7 | 276 | Int_t iPpsdUp = 0 ; |
277 | ||
92862013 | 278 | while( (ppsdup = (AliPHOSPpsdRecPoint*)nextPpsdUp() ) ) { |
279 | Float_t r = GetDistanceInPHOSPlane(emcclu, ppsdup, toofar) ; | |
d15a28e7 | 280 | |
92862013 | 281 | if(toofar) |
d15a28e7 | 282 | break ; |
83974468 | 283 | if(r < fR0) { |
92862013 | 284 | new( (*linkupArray)[iLinkUp++]) AliPHOSLink(r, iEmcClu, iPpsdUp) ; |
83974468 | 285 | } |
d15a28e7 | 286 | iPpsdUp++ ; |
287 | ||
288 | } | |
289 | ||
290 | iEmcClu++ ; | |
291 | ||
292 | } // while nextEmC | |
293 | ||
92862013 | 294 | linklowArray->Sort() ; //first links with smallest distances |
295 | linkupArray->Sort() ; | |
d15a28e7 | 296 | } |
297 | ||
298 | //____________________________________________________________________________ | |
88714635 | 299 | void AliPHOSTrackSegmentMakerv1::MakePairs(TObjArray * emcRecPoints, |
300 | TObjArray * ppsdRecPointsUp, | |
301 | TObjArray * ppsdRecPointsLow, | |
302 | TClonesArray * linklowArray, | |
303 | TClonesArray * linkupArray, | |
304 | AliPHOSTrackSegment::TrackSegmentsList * trsl) | |
6ad0bfa0 | 305 | { |
306 | ||
307 | // Finds the smallest links and makes pairs of PPSD and EMC clusters with smallest distance | |
308 | ||
92862013 | 309 | TIter nextLow(linklowArray) ; |
310 | TIter nextUp(linkupArray) ; | |
d15a28e7 | 311 | |
312 | AliPHOSLink * linkLow ; | |
313 | AliPHOSLink * linkUp ; | |
314 | ||
315 | AliPHOSEmcRecPoint * emc ; | |
316 | AliPHOSPpsdRecPoint * ppsdLow ; | |
317 | AliPHOSPpsdRecPoint * ppsdUp ; | |
318 | ||
92862013 | 319 | AliPHOSRecPoint * nullpointer = 0 ; |
9f616d61 | 320 | |
d15a28e7 | 321 | while ( (linkLow = (AliPHOSLink *)nextLow() ) ){ |
92862013 | 322 | emc = (AliPHOSEmcRecPoint *) emcRecPoints->At(linkLow->GetEmc()) ; |
323 | ppsdLow = (AliPHOSPpsdRecPoint *) ppsdRecPointsLow->At(linkLow->GetPpsd()) ; | |
6ad0bfa0 | 324 | if( (emc) && (ppsdLow) ){ // RecPoints not removed yet |
d15a28e7 | 325 | ppsdUp = 0 ; |
326 | ||
327 | while ( (linkUp = (AliPHOSLink *)nextUp() ) ){ | |
328 | if(linkLow->GetEmc() == linkUp->GetEmc() ){ | |
92862013 | 329 | ppsdUp = (AliPHOSPpsdRecPoint *) ppsdRecPointsUp->At(linkUp->GetPpsd()) ; |
d15a28e7 | 330 | break ; |
331 | } | |
332 | ||
333 | } // while nextUp | |
334 | ||
335 | nextUp.Reset(); | |
b2a60966 | 336 | // AliPHOSTrackSegment * subtr = new AliPHOSTrackSegment(emc, ppsdUp, ppsdLow ) ; |
337 | // trsl->Add(subtr) ; | |
338 | new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment(emc, ppsdUp, ppsdLow ) ; | |
339 | fNTrackSegments++ ; | |
92862013 | 340 | emcRecPoints->AddAt(nullpointer,linkLow->GetEmc()) ; |
341 | ppsdRecPointsLow->AddAt(nullpointer,linkLow->GetPpsd()) ; | |
d15a28e7 | 342 | |
343 | if(ppsdUp) | |
92862013 | 344 | ppsdRecPointsUp->AddAt(nullpointer,linkUp->GetPpsd()) ; |
d15a28e7 | 345 | |
6ad0bfa0 | 346 | } |
d15a28e7 | 347 | } |
348 | ||
92862013 | 349 | TIter nextEmc(emcRecPoints) ; |
d15a28e7 | 350 | nextEmc.Reset() ; |
351 | ||
92862013 | 352 | while( (emc = (AliPHOSEmcRecPoint*)nextEmc()) ){ //to create pairs if no ppsdlow |
9f616d61 | 353 | ppsdLow = 0 ; |
354 | ppsdUp = 0 ; | |
d15a28e7 | 355 | |
356 | while ( (linkUp = (AliPHOSLink *)nextUp() ) ){ | |
357 | ||
92862013 | 358 | if(emcRecPoints->IndexOf(emc) == linkUp->GetEmc() ){ |
359 | ppsdUp = (AliPHOSPpsdRecPoint *) ppsdRecPointsUp->At(linkUp->GetPpsd()) ; | |
d15a28e7 | 360 | break ; |
361 | } | |
362 | ||
363 | } | |
b2a60966 | 364 | // AliPHOSTrackSegment * subtr = new AliPHOSTrackSegment(emc, ppsdUp, ppsdLow ) ; |
365 | // trsl->Add(subtr) ; | |
366 | new( (*trsl)[fNTrackSegments] ) AliPHOSTrackSegment(emc, ppsdUp, ppsdLow ) ; | |
367 | fNTrackSegments++ ; | |
368 | ||
369 | ||
d15a28e7 | 370 | if(ppsdUp) |
92862013 | 371 | ppsdRecPointsUp->AddAt(nullpointer,linkUp->GetPpsd()) ; |
d15a28e7 | 372 | } |
373 | ||
374 | } | |
375 | ||
376 | //____________________________________________________________________________ | |
88714635 | 377 | void AliPHOSTrackSegmentMakerv1::MakeTrackSegments(DigitsList * dl, |
378 | AliPHOSRecPoint::RecPointsList * emcl, | |
379 | AliPHOSRecPoint::RecPointsList * ppsdl, | |
380 | AliPHOSTrackSegment::TrackSegmentsList * trsl) | |
d15a28e7 | 381 | { |
b2a60966 | 382 | // Makes the track segments out of the list of EMC and PPSD Recpoints and stores them in a list |
d15a28e7 | 383 | |
92862013 | 384 | Int_t phosmod = 1 ; |
9f616d61 | 385 | Int_t emcStopedAt = 0 ; |
d15a28e7 | 386 | Int_t ppsdStopedAt = 0 ; |
387 | ||
92862013 | 388 | TObjArray * emcRecPoints = new TObjArray(100) ; // these arrays keep pointers |
389 | TObjArray * ppsdRecPointsUp = new TObjArray(100) ; // to RecPoints, which are | |
390 | TObjArray * ppsdRecPointsLow = new TObjArray(100) ; // kept in TClonesArray's emcl and ppsdl | |
d15a28e7 | 391 | |
392 | ||
92862013 | 393 | TClonesArray * linklowArray = new TClonesArray("AliPHOSLink", 100); |
394 | TClonesArray * linkupArray = new TClonesArray("AliPHOSLink", 100); | |
d15a28e7 | 395 | |
396 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; | |
397 | ||
92862013 | 398 | while(phosmod <= geom->GetNModules() ){ |
d15a28e7 | 399 | |
b2a60966 | 400 | FillOneModule(dl, emcl, emcRecPoints, ppsdl, ppsdRecPointsUp, ppsdRecPointsLow, phosmod, emcStopedAt, ppsdStopedAt) ; |
6ad0bfa0 | 401 | |
92862013 | 402 | MakeLinks(emcRecPoints, ppsdRecPointsUp, ppsdRecPointsLow, linklowArray, linkupArray) ; |
d15a28e7 | 403 | |
92862013 | 404 | MakePairs(emcRecPoints, ppsdRecPointsUp, ppsdRecPointsLow, linklowArray, linkupArray, trsl) ; |
d15a28e7 | 405 | |
92862013 | 406 | emcRecPoints->Clear() ; |
9f616d61 | 407 | |
92862013 | 408 | ppsdRecPointsUp->Clear() ; |
9f616d61 | 409 | |
92862013 | 410 | ppsdRecPointsLow->Clear() ; |
9f616d61 | 411 | |
92862013 | 412 | linkupArray->Clear() ; |
9f616d61 | 413 | |
92862013 | 414 | linklowArray->Clear() ; |
9f616d61 | 415 | |
92862013 | 416 | phosmod++ ; |
d15a28e7 | 417 | } |
92862013 | 418 | delete emcRecPoints ; |
419 | emcRecPoints = 0 ; | |
9f616d61 | 420 | |
92862013 | 421 | delete ppsdRecPointsUp ; |
422 | ppsdRecPointsUp = 0 ; | |
9f616d61 | 423 | |
92862013 | 424 | delete ppsdRecPointsLow ; |
425 | ppsdRecPointsLow = 0 ; | |
9f616d61 | 426 | |
92862013 | 427 | delete linkupArray ; |
428 | linkupArray = 0 ; | |
9f616d61 | 429 | |
92862013 | 430 | delete linklowArray ; |
431 | linklowArray = 0 ; | |
d15a28e7 | 432 | } |
433 | ||
434 | //____________________________________________________________________________ | |
9f616d61 | 435 | Double_t AliPHOSTrackSegmentMakerv1::ShowerShape(Double_t r) |
436 | { | |
b2a60966 | 437 | // Shape of the shower (see PHOS TDR) |
438 | // If you change this function, change also the gradien evaluation in ChiSquare() | |
439 | ||
6ad0bfa0 | 440 | Double_t r4 = r*r*r*r ; |
441 | Double_t r295 = TMath::Power(r, 2.95) ; | |
d15a28e7 | 442 | Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ; |
443 | return shape ; | |
444 | } | |
445 | ||
446 | //____________________________________________________________________________ | |
88714635 | 447 | void AliPHOSTrackSegmentMakerv1::UnfoldClusters(DigitsList * dl, |
448 | AliPHOSRecPoint::RecPointsList * emcIn, | |
449 | AliPHOSEmcRecPoint * iniEmc, | |
450 | Int_t nMax, | |
451 | int * maxAt, | |
452 | Float_t * maxAtEnergy, | |
453 | TObjArray * emcList) | |
d15a28e7 | 454 | { |
b2a60966 | 455 | // Performs the unfolding of a cluster with nMax overlapping showers |
456 | // This is time consuming (use the (Un)SetUnfolFlag() ) | |
457 | ||
92862013 | 458 | Int_t nPar = 3 * nMax ; |
31aa6d6c | 459 | Float_t * fitparameters = new Float_t[nPar] ; |
d15a28e7 | 460 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; |
9f616d61 | 461 | |
92862013 | 462 | Bool_t rv = FindFit(iniEmc, maxAt, maxAtEnergy, nPar, fitparameters) ; |
31aa6d6c | 463 | if( !rv ) { |
464 | // Fit failed, return and remove cluster | |
465 | delete[] fitparameters ; | |
d15a28e7 | 466 | return ; |
31aa6d6c | 467 | } |
d15a28e7 | 468 | |
469 | Float_t xDigit ; | |
470 | Float_t zDigit ; | |
92862013 | 471 | Int_t relid[4] ; |
d15a28e7 | 472 | |
92862013 | 473 | Int_t nDigits = iniEmc->GetMultiplicity() ; |
d15a28e7 | 474 | Float_t xpar ; |
475 | Float_t zpar ; | |
92862013 | 476 | Float_t epar ; |
477 | Float_t distance ; | |
478 | Float_t ratio ; | |
31aa6d6c | 479 | Float_t * efit = new Float_t[nDigits] ; |
d15a28e7 | 480 | Int_t iparam ; |
481 | Int_t iDigit ; | |
482 | ||
483 | AliPHOSDigit * digit ; | |
484 | AliPHOSEmcRecPoint * emcRP ; | |
6ad0bfa0 | 485 | Int_t * emcDigits = iniEmc->GetDigitsList() ; |
d15a28e7 | 486 | Float_t * emcEnergies = iniEmc->GetEnergiesList() ; |
487 | ||
488 | Int_t iRecPoint = emcIn->GetEntries() ; | |
489 | ||
92862013 | 490 | for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ |
d15a28e7 | 491 | digit = (AliPHOSDigit *) emcDigits[iDigit]; |
92862013 | 492 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
493 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
494 | efit[iDigit] = 0; | |
d15a28e7 | 495 | iparam = 0 ; |
496 | ||
92862013 | 497 | while(iparam < nPar ){ |
498 | xpar = fitparameters[iparam] ; | |
499 | zpar = fitparameters[iparam+1] ; | |
500 | epar = fitparameters[iparam+2] ; | |
d15a28e7 | 501 | iparam += 3 ; |
92862013 | 502 | distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; |
503 | distance = TMath::Sqrt(distance) ; | |
b2a60966 | 504 | efit[iDigit] += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ; |
d15a28e7 | 505 | } |
d15a28e7 | 506 | } |
507 | ||
508 | iparam = 0 ; | |
509 | Float_t eDigit ; | |
510 | ||
92862013 | 511 | while(iparam < nPar ){ |
512 | xpar = fitparameters[iparam] ; | |
513 | zpar = fitparameters[iparam+1] ; | |
514 | epar = fitparameters[iparam+2] ; | |
d15a28e7 | 515 | iparam += 3 ; |
516 | new ((*emcIn)[iRecPoint]) AliPHOSEmcRecPoint( iniEmc->GetLogWeightCut(), iniEmc->GetLocMaxCut() ) ; | |
517 | emcRP = (AliPHOSEmcRecPoint *) emcIn->At(iRecPoint++); | |
518 | ||
92862013 | 519 | for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ |
d15a28e7 | 520 | digit = (AliPHOSDigit *) emcDigits[iDigit]; |
92862013 | 521 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
522 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
523 | distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; | |
524 | distance = TMath::Sqrt(distance) ; | |
b2a60966 | 525 | ratio = epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) / efit[iDigit] ; |
92862013 | 526 | eDigit = emcEnergies[iDigit] * ratio ; |
9f616d61 | 527 | emcRP->AddDigit( *digit, eDigit ) ; |
d15a28e7 | 528 | } |
529 | ||
530 | emcList->Add(emcRP) ; | |
531 | ||
532 | } | |
31aa6d6c | 533 | |
534 | delete[] fitparameters ; | |
535 | delete[] efit ; | |
536 | ||
d15a28e7 | 537 | } |
6ad0bfa0 | 538 | |
d15a28e7 | 539 | //______________________________________________________________________________ |
92862013 | 540 | void UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag) |
d15a28e7 | 541 | { |
b2a60966 | 542 | // Calculates th Chi square for the cluster unfolding minimization |
543 | // Number of parameters, Gradient, Chi squared, parameters, what to do | |
9f616d61 | 544 | |
d15a28e7 | 545 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; |
d15a28e7 | 546 | |
9f616d61 | 547 | AliPHOSEmcRecPoint * emcRP = (AliPHOSEmcRecPoint *) gMinuit->GetObjectFit() ; // EmcRecPoint to fit |
6ad0bfa0 | 548 | Int_t * emcDigits = emcRP->GetDigitsList() ; |
d15a28e7 | 549 | Float_t * emcEnergies = emcRP->GetEnergiesList() ; |
550 | fret = 0. ; | |
551 | Int_t iparam ; | |
552 | ||
9f616d61 | 553 | if(iflag == 2) |
92862013 | 554 | for(iparam = 0 ; iparam < nPar ; iparam++) |
9f616d61 | 555 | Grad[iparam] = 0 ; // Will evaluate gradient |
556 | ||
92862013 | 557 | Double_t efit ; |
9f616d61 | 558 | |
d15a28e7 | 559 | AliPHOSDigit * digit ; |
560 | Int_t iDigit = 0 ; | |
9f616d61 | 561 | |
d15a28e7 | 562 | while ( (digit = (AliPHOSDigit *)emcDigits[iDigit] )){ |
92862013 | 563 | Int_t relid[4] ; |
d15a28e7 | 564 | Float_t xDigit ; |
565 | Float_t zDigit ; | |
92862013 | 566 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
567 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
d15a28e7 | 568 | |
9f616d61 | 569 | if(iflag == 2){ // calculate gradient |
570 | Int_t iParam = 0 ; | |
92862013 | 571 | efit = 0 ; |
572 | while(iParam < nPar ){ | |
573 | Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ; | |
9f616d61 | 574 | iParam++ ; |
92862013 | 575 | distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ; |
576 | distance = TMath::Sqrt( distance ) ; | |
9f616d61 | 577 | iParam++ ; |
92862013 | 578 | efit += x[iParam] * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ; |
9f616d61 | 579 | iParam++ ; |
580 | } | |
92862013 | 581 | Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E) |
9f616d61 | 582 | iParam = 0 ; |
92862013 | 583 | while(iParam < nPar ){ |
9f616d61 | 584 | Double_t xpar = x[iParam] ; |
585 | Double_t zpar = x[iParam+1] ; | |
92862013 | 586 | Double_t epar = x[iParam+2] ; |
9f616d61 | 587 | Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ); |
588 | Double_t shape = sum * AliPHOSTrackSegmentMakerv1::ShowerShape(dr) ; | |
589 | Double_t r4 = dr*dr*dr*dr ; | |
590 | Double_t r295 = TMath::Power(dr,2.95) ; | |
591 | Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) + | |
592 | 0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ; | |
593 | ||
92862013 | 594 | Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x |
9f616d61 | 595 | iParam++ ; |
92862013 | 596 | Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z |
9f616d61 | 597 | iParam++ ; |
598 | Grad[iParam] += shape ; // Derivative over energy | |
599 | iParam++ ; | |
600 | } | |
601 | } | |
92862013 | 602 | efit = 0; |
9f616d61 | 603 | iparam = 0 ; |
92862013 | 604 | while(iparam < nPar ){ |
9f616d61 | 605 | Double_t xpar = x[iparam] ; |
606 | Double_t zpar = x[iparam+1] ; | |
92862013 | 607 | Double_t epar = x[iparam+2] ; |
9f616d61 | 608 | iparam += 3 ; |
92862013 | 609 | Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; |
610 | distance = TMath::Sqrt(distance) ; | |
611 | efit += epar * AliPHOSTrackSegmentMakerv1::ShowerShape(distance) ; | |
9f616d61 | 612 | } |
92862013 | 613 | fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ; |
9f616d61 | 614 | // Here we assume, that sigma = sqrt(E) |
615 | iDigit++ ; | |
d15a28e7 | 616 | } |
617 | } |