]>
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 | ||
9a1398dd | 18 | //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (SUBATECH & Kurchatov Institute) |
d15a28e7 | 19 | ////////////////////////////////////////////////////////////////////////////// |
9a1398dd | 20 | // Clusterization class. Performs clusterization (collects neighbouring active cells) and |
a4e98857 | 21 | // unfolds the clusters having several local maxima. |
22 | // Results are stored in TreeR#, branches PHOSEmcRP (EMC recPoints), | |
9a1398dd | 23 | // PHOSCpvRP (CPV RecPoints) and AliPHOSClusterizer (Clusterizer with all |
f035f6ce | 24 | // parameters including input digits branch title, thresholds etc.) |
a4e98857 | 25 | // This TTask is normally called from Reconstructioner, but can as well be used in |
26 | // standalone mode. | |
27 | // Use Case: | |
fc12304f | 28 | // root [0] AliPHOSClusterizerv1 * cl = new AliPHOSClusterizerv1("galice.root", "recpointsname", "digitsname") |
a4e98857 | 29 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
fc12304f | 30 | // // reads gAlice from header file "galice.root", uses digits stored in the branch names "digitsname" (default = "Default") |
31 | // // and saves recpoints in branch named "recpointsname" (default = "digitsname") | |
a4e98857 | 32 | // root [1] cl->ExecuteTask() |
9a1398dd | 33 | // //finds RecPoints in all events stored in galice.root |
a4e98857 | 34 | // root [2] cl->SetDigitsBranch("digits2") |
f035f6ce | 35 | // //sets another title for Digitis (input) branch |
a4e98857 | 36 | // root [3] cl->SetRecPointsBranch("recp2") |
f035f6ce | 37 | // //sets another title four output branches |
a4e98857 | 38 | // root [4] cl->SetEmcLocalMaxCut(0.03) |
9a1398dd | 39 | // //set clusterization parameters |
a4e98857 | 40 | // root [5] cl->ExecuteTask("deb all time") |
9a1398dd | 41 | // //once more finds RecPoints options are |
42 | // // deb - print number of found rec points | |
43 | // // deb all - print number of found RecPoints and some their characteristics | |
44 | // // time - print benchmarking results | |
ed4205d8 | 45 | |
d15a28e7 | 46 | // --- ROOT system --- |
47 | ||
9a1398dd | 48 | #include "TROOT.h" |
49 | #include "TFile.h" | |
50 | #include "TFolder.h" | |
d15a28e7 | 51 | #include "TMath.h" |
9a1398dd | 52 | #include "TMinuit.h" |
53 | #include "TTree.h" | |
54 | #include "TSystem.h" | |
55 | #include "TBenchmark.h" | |
d15a28e7 | 56 | |
57 | // --- Standard library --- | |
88cb7938 | 58 | //#include <iostream.h> |
d15a28e7 | 59 | |
d15a28e7 | 60 | // --- AliRoot header files --- |
88cb7938 | 61 | #include "AliPHOSGetter.h" |
d15a28e7 | 62 | #include "AliPHOSClusterizerv1.h" |
88cb7938 | 63 | #include "AliPHOSEmcRecPoint.h" |
9a1398dd | 64 | #include "AliPHOSCpvRecPoint.h" |
d15a28e7 | 65 | #include "AliPHOSDigit.h" |
9a1398dd | 66 | #include "AliPHOSDigitizer.h" |
9a1398dd | 67 | #include "AliPHOS.h" |
88cb7938 | 68 | #include "AliPHOSCalibrationDB.h" |
d15a28e7 | 69 | |
70 | ClassImp(AliPHOSClusterizerv1) | |
f035f6ce | 71 | |
d15a28e7 | 72 | //____________________________________________________________________________ |
7b7c1533 | 73 | AliPHOSClusterizerv1::AliPHOSClusterizerv1() : AliPHOSClusterizer() |
d15a28e7 | 74 | { |
f035f6ce | 75 | // default ctor (to be used mainly by Streamer) |
f035f6ce | 76 | |
8d0f3f77 | 77 | InitParameters() ; |
92f521a9 | 78 | fDefaultInit = kTRUE ; |
9a1398dd | 79 | } |
7b7c1533 | 80 | |
9a1398dd | 81 | //____________________________________________________________________________ |
88cb7938 | 82 | AliPHOSClusterizerv1::AliPHOSClusterizerv1(const TString alirunFileName, const TString eventFolderName) |
83 | :AliPHOSClusterizer(alirunFileName, eventFolderName) | |
9a1398dd | 84 | { |
a4e98857 | 85 | // ctor with the indication of the file where header Tree and digits Tree are stored |
9a1398dd | 86 | |
8d0f3f77 | 87 | InitParameters() ; |
2bd5457f | 88 | Init() ; |
92f521a9 | 89 | fDefaultInit = kFALSE ; |
9a1398dd | 90 | } |
fc12304f | 91 | |
9688c1dd | 92 | //____________________________________________________________________________ |
93 | AliPHOSClusterizerv1::~AliPHOSClusterizerv1() | |
94 | { | |
0bc3b8ed | 95 | // dtor |
96 | ||
88cb7938 | 97 | // delete fPedestals ; |
98 | // delete fGains ; | |
9688c1dd | 99 | } |
fc12304f | 100 | |
88cb7938 | 101 | |
fc12304f | 102 | //____________________________________________________________________________ |
103 | const TString AliPHOSClusterizerv1::BranchName() const | |
104 | { | |
88cb7938 | 105 | return GetName(); |
fc12304f | 106 | } |
107 | ||
9a1398dd | 108 | //____________________________________________________________________________ |
3758d9fc | 109 | Float_t AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId) const |
88cb7938 | 110 | { |
111 | //To be replaced later by the method, reading individual parameters from the database | |
112 | // if(fCalibrationDB) | |
113 | // return fCalibrationDB->Calibrate(amp,absId) ; | |
114 | // else{ //simulation | |
115 | if(absId <= fEmcCrystals) //calibrate as EMC | |
116 | return fADCpedestalEmc + amp*fADCchanelEmc ; | |
117 | else //calibrate as CPV | |
118 | return fADCpedestalCpv+ amp*fADCchanelCpv ; | |
119 | // } | |
3758d9fc | 120 | } |
548f0134 | 121 | |
3758d9fc | 122 | //____________________________________________________________________________ |
a4e98857 | 123 | void AliPHOSClusterizerv1::Exec(Option_t * option) |
124 | { | |
7b7c1533 | 125 | // Steering method |
9a1398dd | 126 | |
127 | if(strstr(option,"tim")) | |
7d493c2c | 128 | gBenchmark->Start("PHOSClusterizer"); |
9a1398dd | 129 | |
7b7c1533 | 130 | if(strstr(option,"print")) |
88cb7938 | 131 | Print() ; |
bed9e3fb | 132 | |
88cb7938 | 133 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
134 | ||
135 | ||
fbf811ec | 136 | Int_t nevents = gime->MaxEvent() ; |
7b7c1533 | 137 | Int_t ievent ; |
fbf811ec | 138 | |
88cb7938 | 139 | for(ievent = 0; ievent < nevents; ievent++) |
140 | { | |
141 | gime->Event(ievent, "D"); | |
142 | ||
143 | GetCalibrationParameters() ; | |
bed9e3fb | 144 | |
548f0134 | 145 | fNumberOfEmcClusters = fNumberOfCpvClusters = 0 ; |
9a1398dd | 146 | |
88cb7938 | 147 | MakeClusters() ; |
148 | ||
fc12304f | 149 | if(fToUnfold) |
150 | MakeUnfolding() ; | |
7b7c1533 | 151 | |
88cb7938 | 152 | WriteRecPoints(); |
7b7c1533 | 153 | |
94de8339 | 154 | if(strstr(option,"deb")) |
155 | PrintRecPoints(option) ; | |
156 | ||
88cb7938 | 157 | //increment the total number of recpoints per run |
fbf811ec | 158 | fRecPointsInRun += gime->EmcRecPoints()->GetEntriesFast() ; |
159 | fRecPointsInRun += gime->CpvRecPoints()->GetEntriesFast() ; | |
88cb7938 | 160 | } |
161 | ||
162 | Unload(); | |
9a1398dd | 163 | |
164 | if(strstr(option,"tim")){ | |
165 | gBenchmark->Stop("PHOSClusterizer"); | |
21cd0c07 | 166 | Info("Exec", " took %f seconds for Clusterizing %f seconds per event \n", |
167 | gBenchmark->GetCpuTime("PHOSClusterizer"), | |
168 | gBenchmark->GetCpuTime("PHOSClusterizer")/nevents ) ; | |
88cb7938 | 169 | } |
9a1398dd | 170 | } |
171 | ||
172 | //____________________________________________________________________________ | |
a0636361 | 173 | Bool_t AliPHOSClusterizerv1::FindFit(AliPHOSEmcRecPoint * emcRP, AliPHOSDigit ** maxAt, Float_t * maxAtEnergy, |
d1de15f5 | 174 | Int_t nPar, Float_t * fitparameters) const |
9a1398dd | 175 | { |
176 | // Calls TMinuit to fit the energy distribution of a cluster with several maxima | |
a4e98857 | 177 | // The initial values for fitting procedure are set equal to the positions of local maxima. |
f035f6ce | 178 | // Cluster will be fitted as a superposition of nPar/3 electromagnetic showers |
9a1398dd | 179 | |
88cb7938 | 180 | |
181 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); | |
182 | TClonesArray * digits = gime->Digits(); | |
7b7c1533 | 183 | |
184 | ||
9a1398dd | 185 | gMinuit->mncler(); // Reset Minuit's list of paramters |
186 | gMinuit->SetPrintLevel(-1) ; // No Printout | |
187 | gMinuit->SetFCN(AliPHOSClusterizerv1::UnfoldingChiSquare) ; | |
188 | // To set the address of the minimization function | |
189 | ||
190 | TList * toMinuit = new TList(); | |
191 | toMinuit->AddAt(emcRP,0) ; | |
7b7c1533 | 192 | toMinuit->AddAt(digits,1) ; |
9a1398dd | 193 | |
194 | gMinuit->SetObjectFit(toMinuit) ; // To tranfer pointer to UnfoldingChiSquare | |
195 | ||
196 | // filling initial values for fit parameters | |
197 | AliPHOSDigit * digit ; | |
198 | ||
199 | Int_t ierflg = 0; | |
200 | Int_t index = 0 ; | |
201 | Int_t nDigits = (Int_t) nPar / 3 ; | |
202 | ||
203 | Int_t iDigit ; | |
204 | ||
7b7c1533 | 205 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
9a1398dd | 206 | |
207 | for(iDigit = 0; iDigit < nDigits; iDigit++){ | |
a0636361 | 208 | digit = maxAt[iDigit]; |
9a1398dd | 209 | |
210 | Int_t relid[4] ; | |
7b7c1533 | 211 | Float_t x = 0.; |
212 | Float_t z = 0.; | |
213 | geom->AbsToRelNumbering(digit->GetId(), relid) ; | |
214 | geom->RelPosInModule(relid, x, z) ; | |
9a1398dd | 215 | |
216 | Float_t energy = maxAtEnergy[iDigit] ; | |
217 | ||
218 | gMinuit->mnparm(index, "x", x, 0.1, 0, 0, ierflg) ; | |
219 | index++ ; | |
220 | if(ierflg != 0){ | |
21cd0c07 | 221 | Warning("FindFit", "PHOS Unfolding unable to set initial value for fit procedure : x = %f\n", x ) ; |
9a1398dd | 222 | return kFALSE; |
223 | } | |
224 | gMinuit->mnparm(index, "z", z, 0.1, 0, 0, ierflg) ; | |
225 | index++ ; | |
226 | if(ierflg != 0){ | |
21cd0c07 | 227 | Warning("FindFit", "PHOS Unfolding unable to set initial value for fit procedure : z =%f\n", z ) ; |
9a1398dd | 228 | return kFALSE; |
229 | } | |
230 | gMinuit->mnparm(index, "Energy", energy , 0.05*energy, 0., 4.*energy, ierflg) ; | |
231 | index++ ; | |
232 | if(ierflg != 0){ | |
21cd0c07 | 233 | Warning("FindFit", "PHOS Unfolding unable to set initial value for fit procedure : energy = %f\n", energy ) ; |
9a1398dd | 234 | return kFALSE; |
235 | } | |
236 | } | |
237 | ||
238 | Double_t p0 = 0.1 ; // "Tolerance" Evaluation stops when EDM = 0.0001*p0 ; The number of function call slightly | |
239 | // depends on it. | |
240 | Double_t p1 = 1.0 ; | |
241 | Double_t p2 = 0.0 ; | |
242 | ||
243 | gMinuit->mnexcm("SET STR", &p2, 0, ierflg) ; // force TMinuit to reduce function calls | |
244 | gMinuit->mnexcm("SET GRA", &p1, 1, ierflg) ; // force TMinuit to use my gradient | |
245 | gMinuit->SetMaxIterations(5); | |
246 | gMinuit->mnexcm("SET NOW", &p2 , 0, ierflg) ; // No Warnings | |
247 | ||
248 | gMinuit->mnexcm("MIGRAD", &p0, 0, ierflg) ; // minimize | |
249 | ||
250 | if(ierflg == 4){ // Minimum not found | |
21cd0c07 | 251 | Warning("FindFit", "PHOS Unfolding fit not converged, cluster abandoned\n" ); |
9a1398dd | 252 | return kFALSE ; |
253 | } | |
254 | for(index = 0; index < nPar; index++){ | |
255 | Double_t err ; | |
256 | Double_t val ; | |
257 | gMinuit->GetParameter(index, val, err) ; // Returns value and error of parameter index | |
258 | fitparameters[index] = val ; | |
259 | } | |
260 | ||
261 | delete toMinuit ; | |
262 | return kTRUE; | |
c3c187e5 | 263 | |
d15a28e7 | 264 | } |
265 | ||
3758d9fc | 266 | //____________________________________________________________________________ |
267 | void AliPHOSClusterizerv1::GetCalibrationParameters() | |
268 | { | |
fbf811ec | 269 | |
88cb7938 | 270 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
c2cd5471 | 271 | |
88cb7938 | 272 | if ( !gime->Digitizer() ) |
273 | gime->LoadDigitizer(); | |
274 | AliPHOSDigitizer * dig = gime->Digitizer(); | |
275 | ||
276 | fADCchanelEmc = dig->GetEMCchannel() ; | |
277 | fADCpedestalEmc = dig->GetEMCpedestal(); | |
278 | ||
279 | fADCchanelCpv = dig->GetCPVchannel() ; | |
280 | fADCpedestalCpv = dig->GetCPVpedestal() ; | |
281 | ||
282 | // fCalibrationDB = gime->CalibrationDB(); | |
3758d9fc | 283 | } |
548f0134 | 284 | |
d15a28e7 | 285 | //____________________________________________________________________________ |
a4e98857 | 286 | void AliPHOSClusterizerv1::Init() |
287 | { | |
2bd5457f | 288 | // Make all memory allocations which can not be done in default constructor. |
289 | // Attach the Clusterizer task to the list of PHOS tasks | |
88cb7938 | 290 | |
291 | AliPHOSGetter* gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()); | |
fbf811ec | 292 | |
88cb7938 | 293 | AliPHOSGeometry * geom = gime->PHOSGeometry(); |
294 | ||
3758d9fc | 295 | fEmcCrystals = geom->GetNModules() * geom->GetNCristalsInModule() ; |
296 | ||
7b7c1533 | 297 | if(!gMinuit) |
88cb7938 | 298 | gMinuit = new TMinuit(100); |
fbf811ec | 299 | |
88cb7938 | 300 | if ( !gime->Clusterizer() ) |
301 | gime->PostClusterizer(this); | |
9a1398dd | 302 | } |
7b7c1533 | 303 | |
8d0f3f77 | 304 | //____________________________________________________________________________ |
305 | void AliPHOSClusterizerv1::InitParameters() | |
306 | { | |
307 | ||
308 | fNumberOfCpvClusters = 0 ; | |
309 | fNumberOfEmcClusters = 0 ; | |
310 | ||
311 | fCpvClusteringThreshold = 0.0; | |
312 | fEmcClusteringThreshold = 0.2; | |
313 | ||
314 | fEmcLocMaxCut = 0.03 ; | |
315 | fCpvLocMaxCut = 0.03 ; | |
316 | ||
317 | fW0 = 4.5 ; | |
318 | fW0CPV = 4.0 ; | |
319 | ||
320 | fEmcTimeGate = 1.e-8 ; | |
321 | ||
322 | fToUnfold = kTRUE ; | |
88cb7938 | 323 | |
8d0f3f77 | 324 | fRecPointsInRun = 0 ; |
c2cd5471 | 325 | |
8d0f3f77 | 326 | } |
327 | ||
9a1398dd | 328 | //____________________________________________________________________________ |
329 | Int_t AliPHOSClusterizerv1::AreNeighbours(AliPHOSDigit * d1, AliPHOSDigit * d2)const | |
d15a28e7 | 330 | { |
b2a60966 | 331 | // Gives the neighbourness of two digits = 0 are not neighbour but continue searching |
332 | // = 1 are neighbour | |
333 | // = 2 are not neighbour but do not continue searching | |
a4e98857 | 334 | // neighbours are defined as digits having at least a common vertex |
b2a60966 | 335 | // The order of d1 and d2 is important: first (d1) should be a digit already in a cluster |
336 | // which is compared to a digit (d2) not yet in a cluster | |
337 | ||
88cb7938 | 338 | AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; |
7b7c1533 | 339 | |
d15a28e7 | 340 | Int_t rv = 0 ; |
341 | ||
d15a28e7 | 342 | Int_t relid1[4] ; |
7b7c1533 | 343 | geom->AbsToRelNumbering(d1->GetId(), relid1) ; |
d15a28e7 | 344 | |
345 | Int_t relid2[4] ; | |
7b7c1533 | 346 | geom->AbsToRelNumbering(d2->GetId(), relid2) ; |
d15a28e7 | 347 | |
9688c1dd | 348 | if ( (relid1[0] == relid2[0]) && (relid1[1]==relid2[1]) ) { // inside the same PHOS module |
92862013 | 349 | Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ; |
350 | Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ; | |
d15a28e7 | 351 | |
92862013 | 352 | if (( coldiff <= 1 ) && ( rowdiff <= 1 )){ |
9688c1dd | 353 | if((relid1[1] != 0) || (TMath::Abs(d1->GetTime() - d2->GetTime() ) < fEmcTimeGate)) |
d15a28e7 | 354 | rv = 1 ; |
355 | } | |
356 | else { | |
357 | if((relid2[2] > relid1[2]) && (relid2[3] > relid1[3]+1)) | |
88cb7938 | 358 | rv = 2; // Difference in row numbers is too large to look further |
d15a28e7 | 359 | } |
360 | ||
361 | } | |
362 | else { | |
363 | ||
9688c1dd | 364 | if( (relid1[0] < relid2[0]) || (relid1[1] != relid2[1]) ) |
d15a28e7 | 365 | rv=2 ; |
366 | ||
367 | } | |
d72dfbc3 | 368 | |
d15a28e7 | 369 | return rv ; |
370 | } | |
371 | ||
d15a28e7 | 372 | |
373 | //____________________________________________________________________________ | |
9a1398dd | 374 | Bool_t AliPHOSClusterizerv1::IsInEmc(AliPHOSDigit * digit) const |
d15a28e7 | 375 | { |
b2a60966 | 376 | // Tells if (true) or not (false) the digit is in a PHOS-EMC module |
377 | ||
9f616d61 | 378 | Bool_t rv = kFALSE ; |
88cb7938 | 379 | AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; |
d15a28e7 | 380 | |
2b629790 | 381 | Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); |
d15a28e7 | 382 | |
2b629790 | 383 | if(digit->GetId() <= nEMC ) rv = kTRUE; |
ed4205d8 | 384 | |
385 | return rv ; | |
386 | } | |
387 | ||
ed4205d8 | 388 | //____________________________________________________________________________ |
9a1398dd | 389 | Bool_t AliPHOSClusterizerv1::IsInCpv(AliPHOSDigit * digit) const |
ed4205d8 | 390 | { |
fad3e5b9 | 391 | // Tells if (true) or not (false) the digit is in a PHOS-CPV module |
ed4205d8 | 392 | |
393 | Bool_t rv = kFALSE ; | |
88cb7938 | 394 | |
395 | AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; | |
ed4205d8 | 396 | |
2b629790 | 397 | Int_t nEMC = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ(); |
ed4205d8 | 398 | |
2b629790 | 399 | if(digit->GetId() > nEMC ) rv = kTRUE; |
d15a28e7 | 400 | |
401 | return rv ; | |
402 | } | |
9a1398dd | 403 | |
404 | //____________________________________________________________________________ | |
88cb7938 | 405 | void AliPHOSClusterizerv1::Unload() |
406 | { | |
407 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; | |
408 | gime->PhosLoader()->UnloadDigits() ; | |
409 | gime->PhosLoader()->UnloadRecPoints() ; | |
410 | } | |
411 | ||
412 | //____________________________________________________________________________ | |
413 | void AliPHOSClusterizerv1::WriteRecPoints() | |
a4e98857 | 414 | { |
7b7c1533 | 415 | |
416 | // Creates new branches with given title | |
a4e98857 | 417 | // fills and writes into TreeR. |
88cb7938 | 418 | |
419 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); | |
420 | ||
fbf811ec | 421 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; |
422 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
423 | TClonesArray * digits = gime->Digits() ; | |
fbf811ec | 424 | |
88cb7938 | 425 | TTree * treeR = gime->TreeR(); |
fbf811ec | 426 | |
9a1398dd | 427 | Int_t index ; |
01a599c9 | 428 | //Evaluate position, dispersion and other RecPoint properties... |
88cb7938 | 429 | for(index = 0; index < emcRecPoints->GetEntries(); index++) |
430 | dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(index) )->EvalAll(fW0,digits) ; | |
431 | ||
7b7c1533 | 432 | emcRecPoints->Sort() ; |
7b7c1533 | 433 | for(index = 0; index < emcRecPoints->GetEntries(); index++) |
88cb7938 | 434 | dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(index) )->SetIndexInList(index) ; |
fbf811ec | 435 | |
7b7c1533 | 436 | emcRecPoints->Expand(emcRecPoints->GetEntriesFast()) ; |
fbf811ec | 437 | |
9a1398dd | 438 | //Now the same for CPV |
7b7c1533 | 439 | for(index = 0; index < cpvRecPoints->GetEntries(); index++) |
88cb7938 | 440 | dynamic_cast<AliPHOSRecPoint *>( cpvRecPoints->At(index) )->EvalAll(fW0CPV,digits) ; |
fbf811ec | 441 | |
7b7c1533 | 442 | cpvRecPoints->Sort() ; |
fbf811ec | 443 | |
7b7c1533 | 444 | for(index = 0; index < cpvRecPoints->GetEntries(); index++) |
88cb7938 | 445 | dynamic_cast<AliPHOSRecPoint *>( cpvRecPoints->At(index) )->SetIndexInList(index) ; |
fbf811ec | 446 | |
7b7c1533 | 447 | cpvRecPoints->Expand(cpvRecPoints->GetEntriesFast()) ; |
9a1398dd | 448 | |
9a1398dd | 449 | Int_t bufferSize = 32000 ; |
450 | Int_t splitlevel = 0 ; | |
8d0f3f77 | 451 | |
01a599c9 | 452 | //First EMC |
8d0f3f77 | 453 | TBranch * emcBranch = treeR->Branch("PHOSEmcRP","TObjArray",&emcRecPoints,bufferSize,splitlevel); |
fc12304f | 454 | emcBranch->SetTitle(BranchName()); |
9a1398dd | 455 | |
456 | //Now CPV branch | |
8d0f3f77 | 457 | TBranch * cpvBranch = treeR->Branch("PHOSCpvRP","TObjArray",&cpvRecPoints,bufferSize,splitlevel); |
fc12304f | 458 | cpvBranch->SetTitle(BranchName()); |
9a1398dd | 459 | |
01a599c9 | 460 | emcBranch ->Fill() ; |
461 | cpvBranch ->Fill() ; | |
88cb7938 | 462 | |
463 | gime->WriteRecPoints("OVERWRITE"); | |
464 | gime->WriteClusterizer("OVERWRITE"); | |
9a1398dd | 465 | } |
466 | ||
467 | //____________________________________________________________________________ | |
468 | void AliPHOSClusterizerv1::MakeClusters() | |
469 | { | |
470 | // Steering method to construct the clusters stored in a list of Reconstructed Points | |
471 | // A cluster is defined as a list of neighbour digits | |
d15a28e7 | 472 | |
88cb7938 | 473 | |
474 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); | |
475 | ||
476 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
477 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
7b7c1533 | 478 | |
7d493c2c | 479 | emcRecPoints->Delete() ; |
480 | cpvRecPoints->Delete() ; | |
7b7c1533 | 481 | |
fbf811ec | 482 | TClonesArray * digits = gime->Digits() ; |
88cb7938 | 483 | |
484 | TClonesArray * digitsC = static_cast<TClonesArray*>( digits->Clone() ) ; | |
7b7c1533 | 485 | |
486 | ||
d15a28e7 | 487 | // Clusterization starts |
9a1398dd | 488 | |
7b7c1533 | 489 | TIter nextdigit(digitsC) ; |
d15a28e7 | 490 | AliPHOSDigit * digit ; |
92862013 | 491 | Bool_t notremoved = kTRUE ; |
6ad0bfa0 | 492 | |
88cb7938 | 493 | while ( (digit = dynamic_cast<AliPHOSDigit *>( nextdigit()) ) ) { // scan over the list of digitsC |
494 | ||
495 | ||
9a1398dd | 496 | AliPHOSRecPoint * clu = 0 ; |
c161df70 | 497 | |
d1de15f5 | 498 | TArrayI clusterdigitslist(1500) ; |
d15a28e7 | 499 | Int_t index ; |
f2bc1b87 | 500 | |
3758d9fc | 501 | if (( IsInEmc (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fEmcClusteringThreshold ) || |
502 | ( IsInCpv (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fCpvClusteringThreshold ) ) { | |
d15a28e7 | 503 | Int_t iDigitInCluster = 0 ; |
7b7c1533 | 504 | |
6ad0bfa0 | 505 | if ( IsInEmc(digit) ) { |
88cb7938 | 506 | // start a new EMC RecPoint |
507 | if(fNumberOfEmcClusters >= emcRecPoints->GetSize()) | |
508 | emcRecPoints->Expand(2*fNumberOfEmcClusters+1) ; | |
509 | ||
510 | emcRecPoints->AddAt(new AliPHOSEmcRecPoint(""), fNumberOfEmcClusters) ; | |
511 | clu = dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(fNumberOfEmcClusters) ) ; | |
512 | fNumberOfEmcClusters++ ; | |
513 | clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->GetId())) ; | |
514 | clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ; | |
515 | iDigitInCluster++ ; | |
516 | digitsC->Remove(digit) ; | |
ca77b032 | 517 | |
d72dfbc3 | 518 | } else { |
88cb7938 | 519 | |
520 | // start a new CPV cluster | |
521 | if(fNumberOfCpvClusters >= cpvRecPoints->GetSize()) | |
522 | cpvRecPoints->Expand(2*fNumberOfCpvClusters+1); | |
523 | ||
524 | cpvRecPoints->AddAt(new AliPHOSCpvRecPoint(""), fNumberOfCpvClusters) ; | |
525 | ||
526 | clu = dynamic_cast<AliPHOSCpvRecPoint *>( cpvRecPoints->At(fNumberOfCpvClusters) ) ; | |
527 | fNumberOfCpvClusters++ ; | |
528 | clu->AddDigit(*digit, Calibrate(digit->GetAmp(),digit->GetId()) ) ; | |
529 | clusterdigitslist[iDigitInCluster] = digit->GetIndexInList() ; | |
530 | iDigitInCluster++ ; | |
531 | digitsC->Remove(digit) ; | |
d15a28e7 | 532 | nextdigit.Reset() ; |
88cb7938 | 533 | |
534 | // Here we remove remaining EMC digits, which cannot make a cluster | |
535 | ||
92862013 | 536 | if( notremoved ) { |
88cb7938 | 537 | while( ( digit = dynamic_cast<AliPHOSDigit *>( nextdigit() ) ) ) { |
9f616d61 | 538 | if( IsInEmc(digit) ) |
88cb7938 | 539 | digitsC->Remove(digit) ; |
d15a28e7 | 540 | else |
88cb7938 | 541 | break ; |
542 | } | |
543 | notremoved = kFALSE ; | |
544 | } | |
545 | ||
d15a28e7 | 546 | } // else |
547 | ||
548 | nextdigit.Reset() ; | |
fad3e5b9 | 549 | |
d15a28e7 | 550 | AliPHOSDigit * digitN ; |
551 | index = 0 ; | |
9f616d61 | 552 | while (index < iDigitInCluster){ // scan over digits already in cluster |
88cb7938 | 553 | digit = dynamic_cast<AliPHOSDigit*>( digits->At(clusterdigitslist[index]) ) ; |
554 | index++ ; | |
555 | while ( (digitN = dynamic_cast<AliPHOSDigit *>( nextdigit() ) ) ) { // scan over the reduced list of digits | |
556 | Int_t ineb = AreNeighbours(digit, digitN); // call (digit,digitN) in THAT oder !!!!! | |
d15a28e7 | 557 | switch (ineb ) { |
9f616d61 | 558 | case 0 : // not a neighbour |
88cb7938 | 559 | break ; |
560 | case 1 : // are neighbours | |
561 | clu->AddDigit(*digitN, Calibrate( digitN->GetAmp(), digitN->GetId() ) ) ; | |
562 | clusterdigitslist[iDigitInCluster] = digitN->GetIndexInList() ; | |
563 | iDigitInCluster++ ; | |
564 | digitsC->Remove(digitN) ; | |
565 | break ; | |
9f616d61 | 566 | case 2 : // too far from each other |
88cb7938 | 567 | goto endofloop; |
568 | } // switch | |
569 | ||
570 | } // while digitN | |
571 | ||
d15a28e7 | 572 | endofloop: ; |
88cb7938 | 573 | nextdigit.Reset() ; |
574 | ||
d15a28e7 | 575 | } // loop over cluster |
ad8cfaf4 | 576 | |
ad8cfaf4 | 577 | } // energy theshold |
ad8cfaf4 | 578 | |
31aa6d6c | 579 | |
d15a28e7 | 580 | } // while digit |
581 | ||
7b7c1533 | 582 | delete digitsC ; |
9688c1dd | 583 | |
9a1398dd | 584 | } |
585 | ||
586 | //____________________________________________________________________________ | |
a4e98857 | 587 | void AliPHOSClusterizerv1::MakeUnfolding() |
588 | { | |
589 | // Unfolds clusters using the shape of an ElectroMagnetic shower | |
9688c1dd | 590 | // Performs unfolding of all EMC/CPV clusters |
9a1398dd | 591 | |
88cb7938 | 592 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
fc12304f | 593 | |
7b7c1533 | 594 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
88cb7938 | 595 | |
596 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
597 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
fbf811ec | 598 | TClonesArray * digits = gime->Digits() ; |
7b7c1533 | 599 | |
a4e98857 | 600 | // Unfold first EMC clusters |
9a1398dd | 601 | if(fNumberOfEmcClusters > 0){ |
602 | ||
7b7c1533 | 603 | Int_t nModulesToUnfold = geom->GetNModules() ; |
9a1398dd | 604 | |
605 | Int_t numberofNotUnfolded = fNumberOfEmcClusters ; | |
606 | Int_t index ; | |
607 | for(index = 0 ; index < numberofNotUnfolded ; index++){ | |
608 | ||
88cb7938 | 609 | AliPHOSEmcRecPoint * emcRecPoint = dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(index) ) ; |
9a1398dd | 610 | if(emcRecPoint->GetPHOSMod()> nModulesToUnfold) |
88cb7938 | 611 | break ; |
9a1398dd | 612 | |
613 | Int_t nMultipl = emcRecPoint->GetMultiplicity() ; | |
a0636361 | 614 | AliPHOSDigit ** maxAt = new AliPHOSDigit*[nMultipl] ; |
9a1398dd | 615 | Float_t * maxAtEnergy = new Float_t[nMultipl] ; |
7b7c1533 | 616 | Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fEmcLocMaxCut,digits) ; |
9a1398dd | 617 | |
618 | if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 | |
88cb7938 | 619 | UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ; |
620 | emcRecPoints->Remove(emcRecPoint); | |
621 | emcRecPoints->Compress() ; | |
622 | index-- ; | |
623 | fNumberOfEmcClusters -- ; | |
624 | numberofNotUnfolded-- ; | |
9a1398dd | 625 | } |
626 | ||
627 | delete[] maxAt ; | |
628 | delete[] maxAtEnergy ; | |
629 | } | |
630 | } | |
a4e98857 | 631 | // Unfolding of EMC clusters finished |
9a1398dd | 632 | |
633 | ||
a4e98857 | 634 | // Unfold now CPV clusters |
9a1398dd | 635 | if(fNumberOfCpvClusters > 0){ |
636 | ||
9688c1dd | 637 | Int_t nModulesToUnfold = geom->GetNModules() ; |
9a1398dd | 638 | |
639 | Int_t numberofCpvNotUnfolded = fNumberOfCpvClusters ; | |
640 | Int_t index ; | |
641 | for(index = 0 ; index < numberofCpvNotUnfolded ; index++){ | |
642 | ||
88cb7938 | 643 | AliPHOSRecPoint * recPoint = dynamic_cast<AliPHOSRecPoint *>( cpvRecPoints->At(index) ) ; |
9a1398dd | 644 | |
645 | if(recPoint->GetPHOSMod()> nModulesToUnfold) | |
88cb7938 | 646 | break ; |
9a1398dd | 647 | |
88cb7938 | 648 | AliPHOSEmcRecPoint * emcRecPoint = dynamic_cast<AliPHOSEmcRecPoint*>(recPoint) ; |
9a1398dd | 649 | |
650 | Int_t nMultipl = emcRecPoint->GetMultiplicity() ; | |
a0636361 | 651 | AliPHOSDigit ** maxAt = new AliPHOSDigit*[nMultipl] ; |
9a1398dd | 652 | Float_t * maxAtEnergy = new Float_t[nMultipl] ; |
7b7c1533 | 653 | Int_t nMax = emcRecPoint->GetNumberOfLocalMax(maxAt, maxAtEnergy,fCpvLocMaxCut,digits) ; |
9a1398dd | 654 | |
655 | if( nMax > 1 ) { // if cluster is very flat (no pronounced maximum) then nMax = 0 | |
88cb7938 | 656 | UnfoldCluster(emcRecPoint, nMax, maxAt, maxAtEnergy) ; |
657 | cpvRecPoints->Remove(emcRecPoint); | |
658 | cpvRecPoints->Compress() ; | |
659 | index-- ; | |
660 | numberofCpvNotUnfolded-- ; | |
661 | fNumberOfCpvClusters-- ; | |
9a1398dd | 662 | } |
663 | ||
664 | delete[] maxAt ; | |
665 | delete[] maxAtEnergy ; | |
666 | } | |
667 | } | |
668 | //Unfolding of Cpv clusters finished | |
669 | ||
670 | } | |
671 | ||
9a1398dd | 672 | //____________________________________________________________________________ |
673 | Double_t AliPHOSClusterizerv1::ShowerShape(Double_t r) | |
674 | { | |
675 | // Shape of the shower (see PHOS TDR) | |
a4e98857 | 676 | // If you change this function, change also the gradient evaluation in ChiSquare() |
9a1398dd | 677 | |
678 | Double_t r4 = r*r*r*r ; | |
679 | Double_t r295 = TMath::Power(r, 2.95) ; | |
680 | Double_t shape = TMath::Exp( -r4 * (1. / (2.32 + 0.26 * r4) + 0.0316 / (1 + 0.0652 * r295) ) ) ; | |
681 | return shape ; | |
682 | } | |
683 | ||
684 | //____________________________________________________________________________ | |
685 | void AliPHOSClusterizerv1::UnfoldCluster(AliPHOSEmcRecPoint * iniEmc, | |
88cb7938 | 686 | Int_t nMax, |
687 | AliPHOSDigit ** maxAt, | |
688 | Float_t * maxAtEnergy) | |
9a1398dd | 689 | { |
690 | // Performs the unfolding of a cluster with nMax overlapping showers | |
691 | ||
88cb7938 | 692 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
fc12304f | 693 | |
7b7c1533 | 694 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
88cb7938 | 695 | |
fbf811ec | 696 | const TClonesArray * digits = gime->Digits() ; |
697 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
698 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
7b7c1533 | 699 | |
9a1398dd | 700 | Int_t nPar = 3 * nMax ; |
701 | Float_t * fitparameters = new Float_t[nPar] ; | |
702 | ||
703 | Bool_t rv = FindFit(iniEmc, maxAt, maxAtEnergy, nPar, fitparameters) ; | |
704 | if( !rv ) { | |
88cb7938 | 705 | // Fit failed, return and remove cluster |
9a1398dd | 706 | delete[] fitparameters ; |
707 | return ; | |
708 | } | |
709 | ||
710 | // create ufolded rec points and fill them with new energy lists | |
711 | // First calculate energy deposited in each sell in accordance with fit (without fluctuations): efit[] | |
712 | // and later correct this number in acordance with actual energy deposition | |
713 | ||
714 | Int_t nDigits = iniEmc->GetMultiplicity() ; | |
715 | Float_t * efit = new Float_t[nDigits] ; | |
7b7c1533 | 716 | Float_t xDigit=0.,zDigit=0.,distance=0. ; |
717 | Float_t xpar=0.,zpar=0.,epar=0. ; | |
9a1398dd | 718 | Int_t relid[4] ; |
7b7c1533 | 719 | AliPHOSDigit * digit = 0 ; |
9a1398dd | 720 | Int_t * emcDigits = iniEmc->GetDigitsList() ; |
721 | ||
722 | Int_t iparam ; | |
723 | Int_t iDigit ; | |
724 | for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ | |
88cb7938 | 725 | digit = dynamic_cast<AliPHOSDigit*>( digits->At(emcDigits[iDigit] ) ) ; |
7b7c1533 | 726 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
727 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
9a1398dd | 728 | efit[iDigit] = 0; |
729 | ||
730 | iparam = 0 ; | |
731 | while(iparam < nPar ){ | |
732 | xpar = fitparameters[iparam] ; | |
733 | zpar = fitparameters[iparam+1] ; | |
734 | epar = fitparameters[iparam+2] ; | |
735 | iparam += 3 ; | |
736 | distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; | |
737 | distance = TMath::Sqrt(distance) ; | |
738 | efit[iDigit] += epar * ShowerShape(distance) ; | |
739 | } | |
740 | } | |
741 | ||
742 | ||
743 | // Now create new RecPoints and fill energy lists with efit corrected to fluctuations | |
744 | // so that energy deposited in each cell is distributed betwin new clusters proportionally | |
745 | // to its contribution to efit | |
746 | ||
747 | Float_t * emcEnergies = iniEmc->GetEnergiesList() ; | |
748 | Float_t ratio ; | |
749 | ||
750 | iparam = 0 ; | |
751 | while(iparam < nPar ){ | |
752 | xpar = fitparameters[iparam] ; | |
753 | zpar = fitparameters[iparam+1] ; | |
754 | epar = fitparameters[iparam+2] ; | |
755 | iparam += 3 ; | |
756 | ||
7b7c1533 | 757 | AliPHOSEmcRecPoint * emcRP = 0 ; |
9a1398dd | 758 | |
759 | if(iniEmc->IsEmc()){ //create new entries in fEmcRecPoints... | |
760 | ||
7b7c1533 | 761 | if(fNumberOfEmcClusters >= emcRecPoints->GetSize()) |
88cb7938 | 762 | emcRecPoints->Expand(2*fNumberOfEmcClusters) ; |
9a1398dd | 763 | |
73a68ccb | 764 | (*emcRecPoints)[fNumberOfEmcClusters] = new AliPHOSEmcRecPoint("") ; |
88cb7938 | 765 | emcRP = dynamic_cast<AliPHOSEmcRecPoint *>( emcRecPoints->At(fNumberOfEmcClusters) ) ; |
9a1398dd | 766 | fNumberOfEmcClusters++ ; |
767 | } | |
768 | else{//create new entries in fCpvRecPoints | |
7b7c1533 | 769 | if(fNumberOfCpvClusters >= cpvRecPoints->GetSize()) |
88cb7938 | 770 | cpvRecPoints->Expand(2*fNumberOfCpvClusters) ; |
9a1398dd | 771 | |
73a68ccb | 772 | (*cpvRecPoints)[fNumberOfCpvClusters] = new AliPHOSCpvRecPoint("") ; |
88cb7938 | 773 | emcRP = dynamic_cast<AliPHOSEmcRecPoint *>( cpvRecPoints->At(fNumberOfCpvClusters) ) ; |
9a1398dd | 774 | fNumberOfCpvClusters++ ; |
775 | } | |
776 | ||
777 | Float_t eDigit ; | |
778 | for(iDigit = 0 ; iDigit < nDigits ; iDigit ++){ | |
88cb7938 | 779 | digit = dynamic_cast<AliPHOSDigit*>( digits->At( emcDigits[iDigit] ) ) ; |
7b7c1533 | 780 | geom->AbsToRelNumbering(digit->GetId(), relid) ; |
781 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
9a1398dd | 782 | distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; |
783 | distance = TMath::Sqrt(distance) ; | |
784 | ratio = epar * ShowerShape(distance) / efit[iDigit] ; | |
785 | eDigit = emcEnergies[iDigit] * ratio ; | |
786 | emcRP->AddDigit( *digit, eDigit ) ; | |
88cb7938 | 787 | } |
9a1398dd | 788 | } |
789 | ||
790 | delete[] fitparameters ; | |
791 | delete[] efit ; | |
792 | ||
793 | } | |
794 | ||
795 | //_____________________________________________________________________________ | |
796 | void AliPHOSClusterizerv1::UnfoldingChiSquare(Int_t & nPar, Double_t * Grad, Double_t & fret, Double_t * x, Int_t iflag) | |
797 | { | |
a4e98857 | 798 | // Calculates the Chi square for the cluster unfolding minimization |
9a1398dd | 799 | // Number of parameters, Gradient, Chi squared, parameters, what to do |
800 | ||
88cb7938 | 801 | TList * toMinuit = dynamic_cast<TList*>( gMinuit->GetObjectFit() ) ; |
9a1398dd | 802 | |
88cb7938 | 803 | AliPHOSEmcRecPoint * emcRP = dynamic_cast<AliPHOSEmcRecPoint*>( toMinuit->At(0) ) ; |
804 | TClonesArray * digits = dynamic_cast<TClonesArray*>( toMinuit->At(1) ) ; | |
9a1398dd | 805 | |
806 | ||
807 | ||
88cb7938 | 808 | // AliPHOSEmcRecPoint * emcRP = dynamic_cast<AliPHOSEmcRecPoint *>( gMinuit->GetObjectFit() ) ; // EmcRecPoint to fit |
9a1398dd | 809 | |
810 | Int_t * emcDigits = emcRP->GetDigitsList() ; | |
811 | ||
7b7c1533 | 812 | Int_t nOdigits = emcRP->GetDigitsMultiplicity() ; |
9a1398dd | 813 | |
814 | Float_t * emcEnergies = emcRP->GetEnergiesList() ; | |
88cb7938 | 815 | |
816 | const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; | |
9a1398dd | 817 | fret = 0. ; |
818 | Int_t iparam ; | |
819 | ||
820 | if(iflag == 2) | |
821 | for(iparam = 0 ; iparam < nPar ; iparam++) | |
822 | Grad[iparam] = 0 ; // Will evaluate gradient | |
823 | ||
824 | Double_t efit ; | |
825 | ||
826 | AliPHOSDigit * digit ; | |
827 | Int_t iDigit ; | |
828 | ||
7b7c1533 | 829 | for( iDigit = 0 ; iDigit < nOdigits ; iDigit++) { |
9a1398dd | 830 | |
88cb7938 | 831 | digit = dynamic_cast<AliPHOSDigit*>( digits->At( emcDigits[iDigit] ) ); |
9a1398dd | 832 | |
833 | Int_t relid[4] ; | |
834 | Float_t xDigit ; | |
835 | Float_t zDigit ; | |
836 | ||
837 | geom->AbsToRelNumbering(digit->GetId(), relid) ; | |
838 | ||
839 | geom->RelPosInModule(relid, xDigit, zDigit) ; | |
840 | ||
841 | if(iflag == 2){ // calculate gradient | |
842 | Int_t iParam = 0 ; | |
843 | efit = 0 ; | |
844 | while(iParam < nPar ){ | |
88cb7938 | 845 | Double_t distance = (xDigit - x[iParam]) * (xDigit - x[iParam]) ; |
846 | iParam++ ; | |
847 | distance += (zDigit - x[iParam]) * (zDigit - x[iParam]) ; | |
848 | distance = TMath::Sqrt( distance ) ; | |
849 | iParam++ ; | |
850 | efit += x[iParam] * ShowerShape(distance) ; | |
851 | iParam++ ; | |
9a1398dd | 852 | } |
88cb7938 | 853 | Double_t sum = 2. * (efit - emcEnergies[iDigit]) / emcEnergies[iDigit] ; // Here we assume, that sigma = sqrt(E) |
9a1398dd | 854 | iParam = 0 ; |
855 | while(iParam < nPar ){ | |
88cb7938 | 856 | Double_t xpar = x[iParam] ; |
857 | Double_t zpar = x[iParam+1] ; | |
858 | Double_t epar = x[iParam+2] ; | |
859 | Double_t dr = TMath::Sqrt( (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ); | |
860 | Double_t shape = sum * ShowerShape(dr) ; | |
861 | Double_t r4 = dr*dr*dr*dr ; | |
862 | Double_t r295 = TMath::Power(dr,2.95) ; | |
863 | Double_t deriv =-4. * dr*dr * ( 2.32 / ( (2.32 + 0.26 * r4) * (2.32 + 0.26 * r4) ) + | |
864 | 0.0316 * (1. + 0.0171 * r295) / ( ( 1. + 0.0652 * r295) * (1. + 0.0652 * r295) ) ) ; | |
865 | ||
866 | Grad[iParam] += epar * shape * deriv * (xpar - xDigit) ; // Derivative over x | |
867 | iParam++ ; | |
868 | Grad[iParam] += epar * shape * deriv * (zpar - zDigit) ; // Derivative over z | |
869 | iParam++ ; | |
870 | Grad[iParam] += shape ; // Derivative over energy | |
871 | iParam++ ; | |
9a1398dd | 872 | } |
873 | } | |
874 | efit = 0; | |
875 | iparam = 0 ; | |
876 | ||
877 | while(iparam < nPar ){ | |
878 | Double_t xpar = x[iparam] ; | |
879 | Double_t zpar = x[iparam+1] ; | |
880 | Double_t epar = x[iparam+2] ; | |
881 | iparam += 3 ; | |
882 | Double_t distance = (xDigit - xpar) * (xDigit - xpar) + (zDigit - zpar) * (zDigit - zpar) ; | |
883 | distance = TMath::Sqrt(distance) ; | |
884 | efit += epar * ShowerShape(distance) ; | |
885 | } | |
886 | ||
88cb7938 | 887 | fret += (efit-emcEnergies[iDigit])*(efit-emcEnergies[iDigit])/emcEnergies[iDigit] ; |
9a1398dd | 888 | // Here we assume, that sigma = sqrt(E) |
889 | } | |
83974468 | 890 | |
d15a28e7 | 891 | } |
892 | ||
893 | //____________________________________________________________________________ | |
88cb7938 | 894 | void AliPHOSClusterizerv1::Print()const |
d15a28e7 | 895 | { |
d1de15f5 | 896 | // Print clusterizer parameters |
897 | ||
21cd0c07 | 898 | TString message ; |
899 | TString taskName(GetName()) ; | |
900 | taskName.ReplaceAll(Version(), "") ; | |
901 | ||
902 | if( strcmp(GetName(), "") !=0 ) { | |
9a1398dd | 903 | // Print parameters |
21cd0c07 | 904 | message = "\n--------------- %s %s -----------\n" ; |
905 | message += "Clusterizing digits from the file: %s\n" ; | |
906 | message += " Branch: %s\n" ; | |
907 | message += " EMC Clustering threshold = %f\n" ; | |
908 | message += " EMC Local Maximum cut = %f\n" ; | |
909 | message += " EMC Logarothmic weight = %f\n" ; | |
910 | message += " CPV Clustering threshold = %f\n" ; | |
911 | message += " CPV Local Maximum cut = %f\n" ; | |
912 | message += " CPV Logarothmic weight = %f\n" ; | |
9a1398dd | 913 | if(fToUnfold) |
21cd0c07 | 914 | message += " Unfolding on\n" ; |
9a1398dd | 915 | else |
21cd0c07 | 916 | message += " Unfolding off\n" ; |
9a1398dd | 917 | |
21cd0c07 | 918 | message += "------------------------------------------------------------------" ; |
9a1398dd | 919 | } |
21cd0c07 | 920 | else |
921 | message = " AliPHOSClusterizerv1 not initialized " ; | |
922 | ||
923 | Info("Print", message.Data(), | |
924 | taskName.Data(), | |
925 | GetTitle(), | |
926 | taskName.Data(), | |
927 | GetName(), | |
928 | fEmcClusteringThreshold, | |
929 | fEmcLocMaxCut, | |
930 | fW0, | |
931 | fCpvClusteringThreshold, | |
932 | fCpvLocMaxCut, | |
933 | fW0CPV ) ; | |
9a1398dd | 934 | } |
21cd0c07 | 935 | |
936 | ||
9a1398dd | 937 | //____________________________________________________________________________ |
a4e98857 | 938 | void AliPHOSClusterizerv1::PrintRecPoints(Option_t * option) |
939 | { | |
940 | // Prints list of RecPoints produced at the current pass of AliPHOSClusterizer | |
9a1398dd | 941 | |
88cb7938 | 942 | AliPHOSGetter * gime = AliPHOSGetter::Instance(); |
943 | ||
944 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; | |
945 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
7b7c1533 | 946 | |
88cb7938 | 947 | |
948 | TString message ; | |
949 | message = "\nevent " ; | |
950 | message += gAlice->GetEvNumber() ; | |
951 | message += "\n Found " ; | |
952 | message += emcRecPoints->GetEntriesFast() ; | |
953 | message += " EMC RecPoints and " ; | |
954 | message += cpvRecPoints->GetEntriesFast() ; | |
955 | message += " CPV RecPoints \n" ; | |
956 | ||
957 | fRecPointsInRun += emcRecPoints->GetEntriesFast() ; | |
958 | fRecPointsInRun += cpvRecPoints->GetEntriesFast() ; | |
959 | ||
960 | char * tempo = new char[8192]; | |
11f9c5ff | 961 | |
9a1398dd | 962 | if(strstr(option,"all")) { |
88cb7938 | 963 | message += "\nEMC clusters\n" ; |
964 | message += "Index Ene(MeV) Multi Module X Y Z Lambda 1 Lambda 2 # of prim Primaries list\n" ; | |
9a1398dd | 965 | Int_t index ; |
7b7c1533 | 966 | for (index = 0 ; index < emcRecPoints->GetEntries() ; index++) { |
967 | AliPHOSEmcRecPoint * rp = (AliPHOSEmcRecPoint * )emcRecPoints->At(index) ; | |
9a1398dd | 968 | TVector3 locpos; |
969 | rp->GetLocalPosition(locpos); | |
9a1398dd | 970 | Float_t lambda[2]; |
971 | rp->GetElipsAxis(lambda); | |
9a1398dd | 972 | Int_t * primaries; |
973 | Int_t nprimaries; | |
974 | primaries = rp->GetPrimaries(nprimaries); | |
88cb7938 | 975 | sprintf(tempo, "\n%6d %8.2f %3d %2d %4.1f %4.1f %4.1f %4f %4f %2d : ", |
11f9c5ff | 976 | rp->GetIndexInList(), rp->GetEnergy(), rp->GetMultiplicity(), rp->GetPHOSMod(), |
977 | locpos.X(), locpos.Y(), locpos.Z(), lambda[0], lambda[1], nprimaries) ; | |
88cb7938 | 978 | message += tempo ; |
3bf72d32 | 979 | |
21cd0c07 | 980 | for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) { |
88cb7938 | 981 | sprintf(tempo, "%d ", primaries[iprimary] ) ; |
982 | message += tempo ; | |
21cd0c07 | 983 | } |
88cb7938 | 984 | |
985 | //Now plot CPV recPoints | |
986 | message += "Index Ene(MeV) Module X Y Z # of prim Primaries list\n" ; | |
987 | for (index = 0 ; index < cpvRecPoints->GetEntries() ; index++) { | |
988 | AliPHOSRecPoint * rp = (AliPHOSRecPoint * )cpvRecPoints->At(index) ; | |
11f9c5ff | 989 | |
990 | TVector3 locpos; | |
991 | rp->GetLocalPosition(locpos); | |
992 | ||
993 | Int_t * primaries; | |
994 | Int_t nprimaries ; | |
995 | primaries = rp->GetPrimaries(nprimaries); | |
88cb7938 | 996 | sprintf(tempo, "\n%6d %8.2f %2d %4.1f %4.1f %4.1f %2d : ", |
11f9c5ff | 997 | rp->GetIndexInList(), rp->GetEnergy(), rp->GetPHOSMod(), |
998 | locpos.X(), locpos.Y(), locpos.Z(), nprimaries) ; | |
88cb7938 | 999 | message += tempo ; |
11f9c5ff | 1000 | primaries = rp->GetPrimaries(nprimaries); |
1001 | for (Int_t iprimary=0; iprimary<nprimaries; iprimary++) { | |
88cb7938 | 1002 | sprintf(tempo, "%d ", primaries[iprimary] ) ; |
1003 | message += tempo ; | |
11f9c5ff | 1004 | } |
21cd0c07 | 1005 | } |
88cb7938 | 1006 | } |
9a1398dd | 1007 | } |
88cb7938 | 1008 | delete tempo ; |
1009 | Info("Print", message.Data() ) ; | |
d15a28e7 | 1010 | } |
9a1398dd | 1011 |