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