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