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