]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSPIDv1.cxx
A lot of changes here:
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPIDv1.cxx
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
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 // Implementation version v1 of the PHOS particle identifier 
20 // Particle identification based on the 
21 //     - CPV information, 
22 //     - Preshower information (in MIXT or GPS2 geometries)
23 //     - shower width.
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)  
27 //
28 // One can set desirable ID method by the function SetIdentificationMethod(option).
29 // Presently the following options can be used together or separately :
30 //     - "disp": use dispersion cut on shower width 
31 //               (width can be set by method SetDispersionCut(Float_t cut)
32 //     - "ell" : use cut on the axis of the ellipse, drawn around shower 
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 //
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
45 //                // reading headers from file galice1.root and TrackSegments 
46 //                // with title "ts1"
47 //  root [4] p2->SetRecParticlesBranch("rp1")
48 //                // set file name for the branch RecParticles
49 //  root [5] p2->ExecuteTask("deb all time")
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
58
59 // --- ROOT system ---
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"
69 // --- Standard library ---
70
71 #include <iostream.h>
72 #include <iomanip.h>
73
74 // --- AliRoot header files ---
75
76 #include "AliRun.h"
77 #include "AliGenerator.h"
78 #include "AliPHOS.h"
79 #include "AliPHOSPIDv1.h"
80 #include "AliPHOSClusterizerv1.h"
81 #include "AliPHOSTrackSegment.h"
82 #include "AliPHOSTrackSegmentMakerv1.h"
83 #include "AliPHOSRecParticle.h"
84 #include "AliPHOSGeometry.h"
85 #include "AliPHOSGetter.h"
86
87 ClassImp( AliPHOSPIDv1) 
88
89 //____________________________________________________________________________
90 AliPHOSPIDv1::AliPHOSPIDv1():AliPHOSPID()
91
92   // default ctor
93   fFormula           = 0 ;
94   fDispersion        = 0. ; 
95   fCpvEmcDistance    = 0 ; 
96   fHeaderFileName    = "" ; 
97   fTrackSegmentsTitle= "" ; 
98   fRecPointsTitle    = "" ; 
99   fRecParticlesTitle = "" ; 
100   fIDOptions         = "" ; 
101 }
102
103 //____________________________________________________________________________
104 AliPHOSPIDv1::AliPHOSPIDv1(const char * headerFile,const char * name) : AliPHOSPID(headerFile, name)
105
106   //ctor with the indication on where to look for the track segments
107
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    
122   Init() ;
123
124 }
125
126 //____________________________________________________________________________
127 AliPHOSPIDv1::~AliPHOSPIDv1()
128
129   //dtor 
130 }
131
132 //____________________________________________________________________________
133 Bool_t AliPHOSPIDv1::ReadTrackSegments(Int_t event)
134 {
135   // Reads TrackSegments an extracts the title of the RecPoints 
136   // branch from which TS were made of.
137   // Then reads both TrackSegments and RecPoints.
138
139   //Fist read Track Segment Branch and extract RecPointsBranch from fTSMaker
140
141   gAlice->GetEvent(event) ;
142   gAlice->SetEvent(event) ;
143
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;
148   }
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(), "") ;
160
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 ; 
165   
166     } else if ( (strcmp(branch->GetName(), "AliPHOSTrackSegmentMaker")==0) && (strcmp(branch->GetTitle(), taskName.Data())==0) ) {
167       tsmakerfound  = kTRUE ; 
168       tsmakerbranch = branch ;
169     }
170   }
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   }   
176  
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 ; 
208     }
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 ;
217     }
218   }
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) ;
228   
229   TObjArray * cpvRecPoints = gime->CpvRecPoints() ;
230   cpvRecPoints->Clear() ; 
231   cpvbranch->SetAddress(&cpvRecPoints) ;
232   
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  
245   return kTRUE ;
246   
247 }
248
249 //____________________________________________________________________________
250 Float_t  AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSRecPoint * cpv, Option_t *  Axis)const
251 {
252   // Calculates the distance between the EMC RecPoint and the PPSD RecPoint
253  
254   const AliPHOSGeometry * geom = AliPHOSGetter::GetInstance()->PHOSGeometry() ; 
255   TVector3 vecEmc ;
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
264     Float_t dCPV = geom->GetIPtoOuterCoverDistance();
265     Float_t dEMC = geom->GetIPtoCrystalSurface() ;
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 ;
275 }
276
277 //____________________________________________________________________________
278 void  AliPHOSPIDv1::Exec(Option_t * option) 
279 {
280   //Steering method
281
282  if( strcmp(GetName(), "")== 0 ) 
283     Init() ;
284
285  if(strstr(option,"tim"))
286     gBenchmark->Start("PHOSPID");
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(), "") ;
301
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   }
309
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
321       return ;
322
323     MakeRecParticles() ;
324     cout << "MAKE" << endl ; 
325     WriteRecParticles(ievent);
326
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 " 
335          <<  gBenchmark->GetCpuTime("PHOSPID")/nevents << " seconds per event " << endl ;
336     cout << endl ;
337   }
338
339 }
340 //____________________________________________________________________________
341 void 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 //____________________________________________________________________________
368 void  AliPHOSPIDv1::MakeRecParticles(){
369
370   // Makes a RecParticle out of a TrackSegment
371
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) ; 
379   AliPHOSTrackSegment * ts ; 
380   Int_t index = 0 ; 
381   AliPHOSRecParticle * rp ; 
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()) ) {
387     
388     new( (*recParticles)[index] ) AliPHOSRecParticle() ;
389     rp = (AliPHOSRecParticle *)recParticles->At(index) ; 
390     rp->SetTraskSegment(index) ;
391     
392     AliPHOSEmcRecPoint * emc = 0 ;
393     if(ts->GetEmcIndex()>=0)
394       emc = (AliPHOSEmcRecPoint *) emcRecPoints->At(ts->GetEmcIndex()) ;
395     
396     AliPHOSRecPoint    * cpv = 0 ;
397     if(ts->GetCpvIndex()>=0)
398       cpv = (AliPHOSRecPoint *)   cpvRecPoints->At(ts->GetCpvIndex()) ;
399     
400     AliPHOSRecPoint    * ppsd = 0 ;
401     if(ts->GetPpsdIndex()>=0)
402       ppsd= (AliPHOSRecPoint *)   cpvRecPoints->At(ts->GetPpsdIndex()) ;
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
414     
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
420     }
421     
422     if(disp)
423       if(emc->GetDispersion() > fDispersion )
424         showerprofile = 1 ;  // not narrow
425     
426     
427     // Looking at the photon conversion detector
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 ;
440     rp->SetType(type) ; 
441     index++ ; 
442   }
443   
444 }
445
446 //____________________________________________________________________________
447 void  AliPHOSPIDv1:: Print(Option_t * option) const
448 {
449   // Print the parameters used for the particle type identification
450     cout <<  "=============== AliPHOSPID1 ================" << endl ;
451     cout <<  "Making PID "<< endl ;
452     cout <<  "    Headers file:               " << fHeaderFileName.Data() << endl ;
453     cout <<  "    RecPoints branch title:     " << fRecPointsTitle.Data() << endl ;
454     cout <<  "    TrackSegments Branch title: " << fTrackSegmentsTitle.Data() << endl ;
455     cout <<  "    RecParticles Branch title   " << fRecParticlesTitle.Data() << endl;
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 ;
465 }
466
467 //____________________________________________________________________________
468 void  AliPHOSPIDv1::SetShowerProfileCut(char * formula)
469 {
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; 
474   fFormula = new TFormula("Lambda Cut",formula) ;
475 }
476 //____________________________________________________________________________
477 void  AliPHOSPIDv1::WriteRecParticles(Int_t event)
478 {
479  
480   AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; 
481   TClonesArray * recParticles = gime->RecParticles() ; 
482
483   gAlice->GetEvent(event) ; 
484
485   //Make branch in TreeR for RecParticles 
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 ;    
496   TBranch * rpBranch = gAlice->TreeR()->Branch("PHOSRP",&recParticles,bufferSize);
497   rpBranch->SetTitle(fRecParticlesTitle.Data());
498   if (filename) {
499     rpBranch->SetFile(filename);
500     TIter next( rpBranch->GetListOfBranches());
501     TBranch * sb ;
502     while ((sb=(TBranch*)next())) {
503       sb->SetFile(filename);
504     }   
505     cwd->cd();
506   }
507
508   //second, pid
509   Int_t splitlevel = 0 ; 
510   AliPHOSPIDv1 * pid = this ;
511   TBranch * pidBranch = gAlice->TreeR()->Branch("AliPHOSPID","AliPHOSPIDv1",&pid,bufferSize,splitlevel);
512   pidBranch->SetTitle(fRecParticlesTitle.Data());
513   if (filename) {
514     pidBranch->SetFile(filename);
515     TIter next( pidBranch->GetListOfBranches());
516     TBranch * sb ;
517     while ((sb=(TBranch*)next())) {
518       sb->SetFile(filename);
519     }   
520     cwd->cd();
521   }    
522   
523   rpBranch->Fill() ;
524   pidBranch->Fill() ;
525
526   gAlice->TreeR()->Write(0,kOverwrite) ;  
527   
528 }
529
530 //____________________________________________________________________________
531 void  AliPHOSPIDv1::PlotDispersionCuts()const
532 {
533   // produces a plot of the dispersion cut
534   TCanvas*  lambdas = new TCanvas("lambdas","Cuts on the ellipse axis",200,10,700,500);
535  
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 }
562
563 //____________________________________________________________________________
564 TVector3 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   
581  
582   // The following commented code becomes valid once the PPSD provides 
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 //____________________________________________________________________________
611 void AliPHOSPIDv1::PrintRecParticles(Option_t * option)
612 {
613   // Print table of reconstructed particles
614
615   AliPHOSGetter *gime = AliPHOSGetter::GetInstance() ; 
616   TClonesArray * recParticles = gime->RecParticles() ; 
617
618  
619   cout << "AliPHOSPIDv1: " << endl ;
620   cout << "       found " << recParticles->GetEntriesFast() << " RecParticles " << endl ;
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 ;
633     for (index = 0 ; index < recParticles->GetEntries() ; index++) {
634       AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) recParticles->At(index) ;       
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   
678 }
679
680
681