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