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