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