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