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