A lot of changes here:
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPIDv1.cxx
CommitLineData
6ad0bfa0 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
6ad0bfa0 18//_________________________________________________________________________
b2a60966 19// Implementation version v1 of the PHOS particle identifier
7acf6008 20// Particle identification based on the
21// - CPV information,
a4e98857 22// - Preshower information (in MIXT or GPS2 geometries)
7acf6008 23// - shower width.
a4e98857 24//
25// CPV or Preshower clusters should be closer in PHOS plane than fCpvEmcDistance (in cm).
26// This parameter can be set by method SetCpvtoEmcDistanceCut(Float_t cut)
7acf6008 27//
28// One can set desirable ID method by the function SetIdentificationMethod(option).
a4e98857 29// Presently the following options can be used together or separately :
7acf6008 30// - "disp": use dispersion cut on shower width
31// (width can be set by method SetDispersionCut(Float_t cut)
a4e98857 32// - "ell" : use cut on the axis of the ellipse, drawn around shower
7acf6008 33// (this cut can be changed by SetShowerProfileCut(char* formula),
34// where formula - any function of two variables f(lambda[0],lambda[1]).
35// Shower is considered as EM if f() > 0 )
36// One can visualize current cuts calling method PlotDispersionCuts().
37//
a4e98857 38// use case:
39// root [0] AliPHOSPIDv1 * p1 = new AliPHOSPIDv1("galice.root")
40// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
41// root [1] p1->SetIdentificationMethod("disp ellipse")
42// root [2] p1->ExecuteTask()
43// root [3] AliPHOSPIDv1 * p2 = new AliPHOSPIDv1("galice1.root","ts1")
44// Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated
7acf6008 45// // reading headers from file galice1.root and TrackSegments
46// // with title "ts1"
a4e98857 47// root [4] p2->SetRecParticlesBranch("rp1")
7acf6008 48// // set file name for the branch RecParticles
a4e98857 49// root [5] p2->ExecuteTask("deb all time")
7acf6008 50// // available options
51// // "deb" - prints # of reconstructed particles
52// // "deb all" - prints # and list of RecParticles
53// // "time" - prints benchmarking results
54//
55//*-- Author: Yves Schutz (SUBATECH) & Gines Martinez (SUBATECH) &
56// Dmitri Peressounko (SUBATECH & Kurchatov Institute)
57// Complitely redesined by Dmitri Peressounko, March 2001
6ad0bfa0 58
59// --- ROOT system ---
7acf6008 60#include "TROOT.h"
61#include "TTree.h"
62#include "TFile.h"
63#include "TF2.h"
64#include "TFormula.h"
65#include "TCanvas.h"
66#include "TFolder.h"
67#include "TSystem.h"
68#include "TBenchmark.h"
6ad0bfa0 69// --- Standard library ---
70
de9ec31b 71#include <iostream.h>
7acf6008 72#include <iomanip.h>
6ad0bfa0 73
74// --- AliRoot header files ---
75
7acf6008 76#include "AliRun.h"
77#include "AliGenerator.h"
78#include "AliPHOS.h"
26d4b141 79#include "AliPHOSPIDv1.h"
7acf6008 80#include "AliPHOSClusterizerv1.h"
6ad0bfa0 81#include "AliPHOSTrackSegment.h"
7acf6008 82#include "AliPHOSTrackSegmentMakerv1.h"
6ad0bfa0 83#include "AliPHOSRecParticle.h"
7b7c1533 84#include "AliPHOSGeometry.h"
85#include "AliPHOSGetter.h"
6ad0bfa0 86
26d4b141 87ClassImp( AliPHOSPIDv1)
6ad0bfa0 88
6ad0bfa0 89//____________________________________________________________________________
1cb7c1ee 90AliPHOSPIDv1::AliPHOSPIDv1():AliPHOSPID()
91{
a4e98857 92 // default ctor
7b7c1533 93 fFormula = 0 ;
94 fDispersion = 0. ;
95 fCpvEmcDistance = 0 ;
96 fHeaderFileName = "" ;
97 fTrackSegmentsTitle= "" ;
98 fRecPointsTitle = "" ;
99 fRecParticlesTitle = "" ;
100 fIDOptions = "" ;
7acf6008 101}
102
103//____________________________________________________________________________
7b7c1533 104AliPHOSPIDv1::AliPHOSPIDv1(const char * headerFile,const char * name) : AliPHOSPID(headerFile, name)
7acf6008 105{
a4e98857 106 //ctor with the indication on where to look for the track segments
dd5c4038 107
7b7c1533 108 fFormula = new TFormula("LambdaCuts","(x>1)*(x<2.5)*(y>0)*(y<x)") ;
109 fDispersion = 2.0 ;
110 fCpvEmcDistance = 3.0 ;
111
112 fHeaderFileName = GetTitle() ;
113 fTrackSegmentsTitle = GetName() ;
114 fRecPointsTitle = GetName() ;
115 fRecParticlesTitle = GetName() ;
116 fIDOptions = "" ;
117
118 TString tempo(GetName()) ;
119 tempo.Append(Version()) ;
120 SetName(tempo.Data()) ;
121
2bd5457f 122 Init() ;
7acf6008 123
124}
7b7c1533 125
7acf6008 126//____________________________________________________________________________
127AliPHOSPIDv1::~AliPHOSPIDv1()
128{
a4e98857 129 //dtor
7acf6008 130}
2bd5457f 131
7acf6008 132//____________________________________________________________________________
7b7c1533 133Bool_t AliPHOSPIDv1::ReadTrackSegments(Int_t event)
7acf6008 134{
f035f6ce 135 // Reads TrackSegments an extracts the title of the RecPoints
a4e98857 136 // branch from which TS were made of.
f035f6ce 137 // Then reads both TrackSegments and RecPoints.
7acf6008 138
f035f6ce 139 //Fist read Track Segment Branch and extract RecPointsBranch from fTSMaker
7acf6008 140
7b7c1533 141 gAlice->GetEvent(event) ;
142 gAlice->SetEvent(event) ;
7acf6008 143
7b7c1533 144 // Get TreeR header from file
145 if(gAlice->TreeR()==0){
146 cerr << "ERROR: AliPHOSPIDv1::ReadTrackSegments -> There is no Reconstruction Tree" << endl;
147 return kFALSE;
7acf6008 148 }
7b7c1533 149
150 // Find TrackSegments
151 TBranch * tsbranch = 0;
152 TBranch * tsmakerbranch = 0;
153 TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
154 TIter next(lob) ;
155 TBranch * branch = 0 ;
156 Bool_t phostsfound = kFALSE, tsmakerfound = kFALSE ;
157
158 TString taskName(GetName()) ;
159 taskName.ReplaceAll(Version(), "") ;
7acf6008 160
7b7c1533 161 while ( (branch = (TBranch*)next()) && (!phostsfound || !tsmakerfound) ) {
162 if ( (strcmp(branch->GetName(), "PHOSTS")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) {
163 phostsfound = kTRUE ;
164 tsbranch = branch ;
7acf6008 165
7b7c1533 166 } else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) {
167 tsmakerfound = kTRUE ;
168 tsmakerbranch = branch ;
7acf6008 169 }
170 }
7b7c1533 171 if ( !phostsfound || !tsmakerfound ) {
172 cerr << "WARNING: AliPHOSPIDv1::ReadTrackSegments -> TrackSegments and/or TrackSegmentMaker branch with name " << taskName.Data()
173 << " not found" << endl ;
174 return kFALSE ;
175 }
7acf6008 176
7b7c1533 177 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
178
179 TClonesArray * trackSegments = gime->TrackSegments() ;
180 trackSegments->Clear() ;
181 tsbranch->SetAddress(&trackSegments) ;
182
183 AliPHOSTrackSegmentMaker * tsmaker = 0 ;
184 tsmakerbranch->SetAddress(&tsmaker) ;
185 tsmakerbranch->GetEntry(0) ;
186 TString tsmakerName( fRecParticlesTitle ) ;
187 tsmakerName.Append(tsmaker->Version()) ;
188 tsmaker = gime->TrackSegmentMaker(tsmakerName) ;
189
190 tsbranch->GetEntry(0) ;
191 tsmakerbranch->GetEntry(0) ;
192
193 fRecPointsTitle = tsmaker->GetRecPointsBranch() ;
194
195 // Find RecPoints
196 TBranch * emcbranch = 0;
197 TBranch * cpvbranch = 0;
198 TBranch * clusterizerbranch = 0;
199 lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
200 TIter next2(lob) ;
201 branch = 0 ;
202 Bool_t phosemcfound = kFALSE, phoscpvfound = kFALSE, clusterizerfound = kFALSE ;
203
204 while ( (branch = (TBranch*)next2()) && (!phosemcfound || !phoscpvfound || !clusterizerfound) ) {
205 if ( (strcmp(branch->GetName(), "PHOSEmcRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) {
206 phosemcfound = kTRUE ;
207 emcbranch = branch ;
7acf6008 208 }
7b7c1533 209
210 else if ( (strcmp(branch->GetName(), "PHOSCpvRP")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) {
211 phoscpvfound = kTRUE ;
212 cpvbranch = branch ;
213
214 } else if ( (strcmp(branch->GetName(), "AliPHOSClusterizer")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) {
215 clusterizerfound = kTRUE ;
216 clusterizerbranch = branch ;
7acf6008 217 }
218 }
7b7c1533 219 if ( !phosemcfound || !phoscpvfound || !clusterizerfound ) {
220 cerr << "WARNING: AliPHOSTrackPIDv1::ReadTrackSegments -> emc(cpv)RecPoints and/or Clusterizer branch with name " << taskName.Data()
221 << " not found" << endl ;
222 return kFALSE ;
223 }
224
225 TObjArray * emcRecPoints = gime->EmcRecPoints() ;
226 emcRecPoints->Clear() ;
227 emcbranch->SetAddress(&emcRecPoints) ;
7acf6008 228
7b7c1533 229 TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
230 cpvRecPoints->Clear() ;
231 cpvbranch->SetAddress(&cpvRecPoints) ;
7acf6008 232
7b7c1533 233
234 AliPHOSClusterizer * clusterizer = 0 ;
235 clusterizerbranch->SetAddress(&clusterizer) ;
236 clusterizerbranch->GetEntry(0) ;
237 TString clusterizerName( fTrackSegmentsTitle ) ;
238 clusterizerName.Append(clusterizer->Version()) ;
239 clusterizer = gime->Clusterizer(clusterizerName) ;
240
241 emcbranch->GetEntry(0) ;
242 cpvbranch->GetEntry(0) ;
243 clusterizerbranch->GetEntry(0) ;
244
7acf6008 245 return kTRUE ;
7b7c1533 246
7acf6008 247}
7b7c1533 248
1cb7c1ee 249//____________________________________________________________________________
7acf6008 250Float_t AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSRecPoint * cpv, Option_t * Axis)const
69183710 251{
252 // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
253
7b7c1533 254 const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ;
69183710 255 TVector3 vecEmc ;
7acf6008 256 TVector3 vecCpv ;
257
258 emc->GetLocalPosition(vecEmc) ;
259 cpv->GetLocalPosition(vecCpv) ;
260 if(emc->GetPHOSMod() == cpv->GetPHOSMod()){
261
262 // Correct to difference in CPV and EMC position due to different distance to center.
263 // we assume, that particle moves from center
7b7c1533 264 Float_t dCPV = geom->GetIPtoOuterCoverDistance();
265 Float_t dEMC = geom->GetIPtoCrystalSurface() ;
7acf6008 266 dEMC = dEMC / dCPV ;
267 vecCpv = dEMC * vecCpv - vecEmc ;
268 if (Axis == "X") return vecCpv.X();
269 if (Axis == "Y") return vecCpv.Y();
270 if (Axis == "Z") return vecCpv.Z();
271 if (Axis == "R") return vecCpv.Mag();
272 }
273
274 return 100000000 ;
69183710 275}
276
69183710 277//____________________________________________________________________________
7acf6008 278void AliPHOSPIDv1::Exec(Option_t * option)
6ad0bfa0 279{
f035f6ce 280 //Steering method
281
7b7c1533 282 if( strcmp(GetName(), "")== 0 )
7acf6008 283 Init() ;
284
7b7c1533 285 if(strstr(option,"tim"))
7acf6008 286 gBenchmark->Start("PHOSPID");
7b7c1533 287
288 if(strstr(option,"print")) {
289 Print("") ;
290 return ;
291 }
292
293 //check, if the branch with name of this" already exits?
294 TObjArray * lob = (TObjArray*)gAlice->TreeR()->GetListOfBranches() ;
295 TIter next(lob) ;
296 TBranch * branch = 0 ;
297 Bool_t phospidfound = kFALSE, pidfound = kFALSE ;
298
299 TString taskName(GetName()) ;
300 taskName.ReplaceAll(Version(), "") ;
7acf6008 301
7b7c1533 302 while ( (branch = (TBranch*)next()) && (!phospidfound || !pidfound) ) {
303 if ( (strcmp(branch->GetName(), "PHOSPID")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) )
304 phospidfound = kTRUE ;
305
306 else if ( (strcmp(branch->GetName(), "AliPHOSPID")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) )
307 pidfound = kTRUE ;
308 }
7acf6008 309
7b7c1533 310 if ( phospidfound || pidfound ) {
311 cerr << "WARNING: AliPHOSPIDv1::Exec -> RecParticles and/or PIDtMaker branch with name "
312 << taskName.Data() << " already exits" << endl ;
313 return ;
314 }
315
316 Int_t nevents = (Int_t) gAlice->TreeE()->GetEntries() ;
317 Int_t ievent ;
318
319 for(ievent = 0; ievent < nevents; ievent++){
320 if(!ReadTrackSegments(ievent)) //reads TrackSegments for event ievent
7acf6008 321 return ;
7b7c1533 322
7acf6008 323 MakeRecParticles() ;
7b7c1533 324 cout << "MAKE" << endl ;
325 WriteRecParticles(ievent);
326
7acf6008 327 if(strstr(option,"deb"))
328 PrintRecParticles(option) ;
329 }
330
331 if(strstr(option,"tim")){
332 gBenchmark->Stop("PHOSPID");
333 cout << "AliPHOSPID:" << endl ;
334 cout << " took " << gBenchmark->GetCpuTime("PHOSPID") << " seconds for PID "
7b7c1533 335 << gBenchmark->GetCpuTime("PHOSPID")/nevents << " seconds per event " << endl ;
7acf6008 336 cout << endl ;
337 }
338
339}
340//____________________________________________________________________________
7b7c1533 341void AliPHOSPIDv1::Init()
342{
343 // Make all memory allocations that are not possible in default constructor
344 // Add the PID task to the list of PHOS tasks
345
346 if ( strcmp(GetTitle(), "") == 0 )
347 SetTitle("galice.root") ;
348
349 TString taskName(GetName()) ;
350 taskName.ReplaceAll(Version(), "") ;
351
352 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(GetTitle(), taskName.Data()) ;
353 if ( gime == 0 ) {
354 cerr << "ERROR: AliPHOSPIDv1::Init -> Could not obtain the Getter object !" << endl ;
355 return ;
356 }
357
358 //add Task to //YSAlice/tasks/Reconstructioner/PHOS
359 TTask * aliceRe = (TTask*)gROOT->FindObjectAny("YSAlice/tasks/Reconstructioner") ;
360 TTask * phosRe = (TTask*)aliceRe->GetListOfTasks()->FindObject("PHOS") ;
361 phosRe->Add(this) ;
362 // create a folder on the white board //YSAlice/WhiteBoard/RecParticles/PHOS/recparticlesName
363 gime->Post(GetTitle(), "P", taskName.Data() ) ;
364
365}
366
367//____________________________________________________________________________
7acf6008 368void AliPHOSPIDv1::MakeRecParticles(){
369
b2a60966 370 // Makes a RecParticle out of a TrackSegment
6ad0bfa0 371
7b7c1533 372 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
373 TObjArray * emcRecPoints = gime->EmcRecPoints() ;
374 TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
375 TClonesArray * trackSegments = gime->TrackSegments() ;
376 TClonesArray * recParticles = gime->RecParticles() ;
377
378 TIter next(trackSegments) ;
7acf6008 379 AliPHOSTrackSegment * ts ;
6ad0bfa0 380 Int_t index = 0 ;
09fc14a0 381 AliPHOSRecParticle * rp ;
7acf6008 382
383 Bool_t ellips = fIDOptions.Contains("ell",TString::kIgnoreCase ) ;
384 Bool_t disp = fIDOptions.Contains("dis",TString::kIgnoreCase ) ;
385
386 while ( (ts = (AliPHOSTrackSegment *)next()) ) {
fad3e5b9 387
7b7c1533 388 new( (*recParticles)[index] ) AliPHOSRecParticle() ;
389 rp = (AliPHOSRecParticle *)recParticles->At(index) ;
7acf6008 390 rp->SetTraskSegment(index) ;
f035f6ce 391
7acf6008 392 AliPHOSEmcRecPoint * emc = 0 ;
393 if(ts->GetEmcIndex()>=0)
7b7c1533 394 emc = (AliPHOSEmcRecPoint *) emcRecPoints->At(ts->GetEmcIndex()) ;
fad3e5b9 395
7acf6008 396 AliPHOSRecPoint * cpv = 0 ;
397 if(ts->GetCpvIndex()>=0)
7b7c1533 398 cpv = (AliPHOSRecPoint *) cpvRecPoints->At(ts->GetCpvIndex()) ;
fad3e5b9 399
7acf6008 400 AliPHOSRecPoint * ppsd = 0 ;
401 if(ts->GetPpsdIndex()>=0)
7b7c1533 402 ppsd= (AliPHOSRecPoint *) cpvRecPoints->At(ts->GetPpsdIndex()) ;
7acf6008 403
404 //set momentum and energy first
405 Float_t e = emc->GetEnergy() ;
406 TVector3 dir = GetMomentumDirection(emc,cpv,ppsd) ;
407 dir.SetMag(e) ;
408
409 rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),e) ;
410 rp->SetCalcMass(0);
411
412 //now set type (reconstructed) of the particle
413 Int_t showerprofile = 0; // 0 narrow and 1 wide
fad3e5b9 414
7acf6008 415 if(ellips){
416 Float_t lambda[2] ;
417 emc->GetElipsAxis(lambda) ;
418 if(fFormula->Eval(lambda[0],lambda[1]) <= 0 )
419 showerprofile = 1 ; // not narrow
1cb7c1ee 420 }
fad3e5b9 421
7acf6008 422 if(disp)
423 if(emc->GetDispersion() > fDispersion )
424 showerprofile = 1 ; // not narrow
425
426
2aad621e 427 // Looking at the photon conversion detector
7acf6008 428 Int_t pcdetector= 0 ; //1 hit and 0 no hit
429 if(ppsd)
430 if(GetDistance(emc, ppsd, "R") < fCpvEmcDistance)
431 pcdetector = 1 ;
432
433 // Looking at the CPV detector
434 Int_t cpvdetector= 0 ; //1 hit and 0 no hit
435 if(cpv)
436 if(GetDistance(emc, cpv, "R") < fCpvEmcDistance)
437 cpvdetector = 1 ;
438
439 Int_t type = showerprofile + 2 * pcdetector + 4 * cpvdetector ;
09fc14a0 440 rp->SetType(type) ;
6ad0bfa0 441 index++ ;
442 }
7acf6008 443
6ad0bfa0 444}
445
09fc14a0 446//____________________________________________________________________________
7acf6008 447void AliPHOSPIDv1:: Print(Option_t * option) const
09fc14a0 448{
b2a60966 449 // Print the parameters used for the particle type identification
f035f6ce 450 cout << "=============== AliPHOSPID1 ================" << endl ;
451 cout << "Making PID "<< endl ;
452 cout << " Headers file: " << fHeaderFileName.Data() << endl ;
453 cout << " RecPoints branch title: " << fRecPointsTitle.Data() << endl ;
7b7c1533 454 cout << " TrackSegments Branch title: " << fTrackSegmentsTitle.Data() << endl ;
455 cout << " RecParticles Branch title " << fRecParticlesTitle.Data() << endl;
f035f6ce 456 cout << "with parameters: " << endl ;
457 cout << " Maximal EMC - CPV (PPSD) distance (cm) " << fCpvEmcDistance << endl ;
458 if(fIDOptions.Contains("dis",TString::kIgnoreCase ))
459 cout << " dispersion cut " << fDispersion << endl ;
460 if(fIDOptions.Contains("ell",TString::kIgnoreCase )){
461 cout << "Eliptic cuts function: " << endl ;
462 cout << fFormula->GetTitle() << endl ;
463 }
464 cout << "============================================" << endl ;
09fc14a0 465}
466
467//____________________________________________________________________________
a4e98857 468void AliPHOSPIDv1::SetShowerProfileCut(char * formula)
469{
7acf6008 470 //set shape of the cut on the axis of ellipce, drown around shouer
471 //shower considered "narrow" if Formula(lambda[0],lambda[1]) > 0.
472 if(fFormula)
473 delete fFormula;
f035f6ce 474 fFormula = new TFormula("Lambda Cut",formula) ;
7acf6008 475}
476//____________________________________________________________________________
7b7c1533 477void AliPHOSPIDv1::WriteRecParticles(Int_t event)
09fc14a0 478{
7b7c1533 479
480 AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ;
481 TClonesArray * recParticles = gime->RecParticles() ;
482
483 gAlice->GetEvent(event) ;
69183710 484
7b7c1533 485 //Make branch in TreeR for RecParticles
7acf6008 486 char * filename = 0;
487 if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){ //generating file name
488 filename = new char[strlen(gAlice->GetBaseFile())+20] ;
489 sprintf(filename,"%s/PHOS.Reco.root",gAlice->GetBaseFile()) ;
490 }
491
492 TDirectory *cwd = gDirectory;
493
494 //First rp
495 Int_t bufferSize = 32000 ;
7b7c1533 496 TBranch * rpBranch = gAlice->TreeR()->Branch("PHOSRP",&recParticles,bufferSize);
497 rpBranch->SetTitle(fRecParticlesTitle.Data());
7acf6008 498 if (filename) {
499 rpBranch->SetFile(filename);
500 TIter next( rpBranch->GetListOfBranches());
761e34c0 501 TBranch * sb ;
502 while ((sb=(TBranch*)next())) {
503 sb->SetFile(filename);
7acf6008 504 }
505 cwd->cd();
506 }
507
508 //second, pid
509 Int_t splitlevel = 0 ;
510 AliPHOSPIDv1 * pid = this ;
7b7c1533 511 TBranch * pidBranch = gAlice->TreeR()->Branch("AliPHOSPID","AliPHOSPIDv1",&pid,bufferSize,splitlevel);
512 pidBranch->SetTitle(fRecParticlesTitle.Data());
7acf6008 513 if (filename) {
514 pidBranch->SetFile(filename);
515 TIter next( pidBranch->GetListOfBranches());
761e34c0 516 TBranch * sb ;
517 while ((sb=(TBranch*)next())) {
518 sb->SetFile(filename);
7acf6008 519 }
520 cwd->cd();
521 }
522
761e34c0 523 rpBranch->Fill() ;
524 pidBranch->Fill() ;
eec3ac52 525
7acf6008 526 gAlice->TreeR()->Write(0,kOverwrite) ;
527
528}
7b7c1533 529
69183710 530//____________________________________________________________________________
7acf6008 531void AliPHOSPIDv1::PlotDispersionCuts()const
69183710 532{
a4e98857 533 // produces a plot of the dispersion cut
534 TCanvas* lambdas = new TCanvas("lambdas","Cuts on the ellipse axis",200,10,700,500);
dd5c4038 535
7acf6008 536 if(fIDOptions.Contains("ell",TString::kIgnoreCase ) ){
537 TF2 * ell = new TF2("Elliptic Cuts",fFormula->GetName(),0,3,0,3) ;
538 ell->SetMinimum(0.0000001) ;
539 ell->SetMaximum(0.001) ;
540 ell->SetLineStyle(1) ;
541 ell->SetLineWidth(2) ;
542 ell->Draw() ;
543 }
544
545 if( fIDOptions.Contains("dis",TString::kIgnoreCase ) ){
546 TF2 * dsp = new TF2("dispersion","(y<x)*(x*x+y*y < [0]*[0])",0,3,0,3) ;
547 dsp->SetParameter(0,fDispersion) ;
548 dsp->SetMinimum(0.0000001) ;
549 dsp->SetMaximum(0.001) ;
550 dsp->SetLineStyle(1) ;
551 dsp->SetLineColor(2) ;
552 dsp->SetLineWidth(2) ;
553 dsp->SetNpx(200) ;
554 dsp->SetNpy(200) ;
555 if(fIDOptions.Contains("ell",TString::kIgnoreCase ) )
556 dsp->Draw("same") ;
557 else
558 dsp->Draw() ;
559 }
560 lambdas->Update();
561}
69183710 562
7acf6008 563//____________________________________________________________________________
564TVector3 AliPHOSPIDv1::GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSRecPoint * cpv,AliPHOSRecPoint * ppsd)const
565{
566 // Calculates the momentum direction:
567 // 1. if only a EMC RecPoint, direction is given by IP and this RecPoint
568 // 2. if a EMC RecPoint and one PPSD RecPoint, direction is given by the line through the 2 recpoints
569 // 3. if a EMC RecPoint and two PPSD RecPoints, dirrection is given by the average line through
570 // the 2 pairs of recpoints
571 // However because of the poor position resolution of PPSD the direction is always taken as if we were
572 // in case 1.
573
574 TVector3 dir(0,0,0) ;
575
576 TVector3 emcglobalpos ;
577 TMatrix dummy ;
578
579 emc->GetGlobalPosition(emcglobalpos, dummy) ;
580
69183710 581
a4e98857 582 // The following commented code becomes valid once the PPSD provides
7acf6008 583 // a reasonable position resolution, at least as good as EMC !
584 // TVector3 ppsdlglobalpos ;
585 // TVector3 ppsduglobalpos ;
586 // if( fPpsdLowRecPoint ){ // certainly a photon that has concerted
587 // fPpsdLowRecPoint->GetGlobalPosition(ppsdlglobalpos, mdummy) ;
588 // dir = emcglobalpos - ppsdlglobalpos ;
589 // if( fPpsdUpRecPoint ){ // not looks like a charged
590 // fPpsdUpRecPoint->GetGlobalPosition(ppsduglobalpos, mdummy) ;
591 // dir = ( dir + emcglobalpos - ppsduglobalpos ) * 0.5 ;
592 // }
593 // }
594 // else { // looks like a neutral
595 // dir = emcglobalpos ;
596 // }
597
598 dir = emcglobalpos ;
599 dir.SetZ( -dir.Z() ) ; // why ?
600 dir.SetMag(1.) ;
601
602 //account correction to the position of IP
603 Float_t xo,yo,zo ; //Coordinates of the origin
604 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
605 TVector3 origin(xo,yo,zo);
606 dir = dir - origin ;
607
608 return dir ;
609}
610//____________________________________________________________________________
a4e98857 611void AliPHOSPIDv1::PrintRecParticles(Option_t * option)
612{
dd5c4038 613 // Print table of reconstructed particles
614
7b7c1533 615 AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ;
616 TClonesArray * recParticles = gime->RecParticles() ;
617
618
7acf6008 619 cout << "AliPHOSPIDv1: " << endl ;
7b7c1533 620 cout << " found " << recParticles->GetEntriesFast() << " RecParticles " << endl ;
7acf6008 621
622 if(strstr(option,"all")) { // printing found TS
623
624 cout << " PARTICLE "
625 << " Index " << endl ;
626 // << " X "
627 // << " Y "
628 // << " Z "
629 // << " # of primaries "
630 // << " Primaries list " << endl;
631
632 Int_t index ;
7b7c1533 633 for (index = 0 ; index < recParticles->GetEntries() ; index++) {
634 AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) recParticles->At(index) ;
7acf6008 635
636 Text_t particle[11];
637 switch(rp->GetType()) {
638 case AliPHOSFastRecParticle::kNEUTRALEM:
639 strcpy( particle, "NEUTRAL_EM");
640 break;
641 case AliPHOSFastRecParticle::kNEUTRALHA:
642 strcpy(particle, "NEUTRAL_HA");
643 break;
644 case AliPHOSFastRecParticle::kGAMMA:
645 strcpy(particle, "GAMMA");
646 break ;
647 case AliPHOSFastRecParticle::kGAMMAHA:
648 strcpy(particle, "GAMMA_H");
649 break ;
650 case AliPHOSFastRecParticle::kABSURDEM:
651 strcpy(particle, "ABSURD_EM") ;
652 break ;
653 case AliPHOSFastRecParticle::kABSURDHA:
654 strcpy(particle, "ABSURD_HA") ;
655 break ;
656 case AliPHOSFastRecParticle::kELECTRON:
657 strcpy(particle, "ELECTRON") ;
658 break ;
659 case AliPHOSFastRecParticle::kCHARGEDHA:
660 strcpy(particle, "CHARGED_HA") ;
661 break ;
662 }
663
664 // Int_t * primaries;
665 // Int_t nprimaries;
666 // primaries = rp->GetPrimaries(nprimaries);
667
668 cout << setw(15) << particle << " "
669 << setw(3) << rp->GetIndexInList() << " " ;
670 // << setw(4) << nprimaries << " ";
671 // for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
672 // cout << setw(4) << primaries[iprimary] << " ";
673 cout << endl;
674 }
675 cout << "-------------------------------------------" << endl ;
676 }
677
69183710 678}
679
7acf6008 680
681