This is a MAJOR modification:
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Mar 2000 12:05:33 +0000 (12:05 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Mar 2000 12:05:33 +0000 (12:05 +0000)
1. The cumulative hits in one cell are stored as a TClonesArray in TreeD/PHOSCH
2. The reconstructed objects are stored in TreeR :
     a. EmcRecPoints in TreeR/PHOSEmcRP   (TObjectArray)
     b. PpsdRecPoints in TreeR/PHOSPpsdRP (TClonesArray)
     c. TrackSegments in TreeR/PHOSTS   (TClonesArray)
     d. RecParticles in TreeR/PHOSRP (TClonesArray)
3. The various reconstructed objects are linked together :
        RecParticle->TrackSegment->RecPoint->PrimaryParticle
    The mechanism to access the relation is provided by the AliPHOSIndexToObject algorithmic class
4. PetiteMacrodeNuit.C is a macro using the RecAna class that shows how to analyse TreeR

32 files changed:
PHOS/AliPHOS.h
PHOS/AliPHOSAnalyze.cxx
PHOS/AliPHOSAnalyze.h
PHOS/AliPHOSClusterizer.h
PHOS/AliPHOSClusterizerv1.cxx
PHOS/AliPHOSDigit.cxx
PHOS/AliPHOSDigit.h
PHOS/AliPHOSEmcRecPoint.cxx
PHOS/AliPHOSEmcRecPoint.h
PHOS/AliPHOSFastRecParticle.h
PHOS/AliPHOSIndexToObject.cxx [new file with mode: 0644]
PHOS/AliPHOSIndexToObject.h [new file with mode: 0644]
PHOS/AliPHOSPID.h
PHOS/AliPHOSPIDv1.cxx
PHOS/AliPHOSPpsdRecPoint.cxx
PHOS/AliPHOSPpsdRecPoint.h
PHOS/AliPHOSRecParticle.cxx
PHOS/AliPHOSRecParticle.h
PHOS/AliPHOSRecPoint.cxx
PHOS/AliPHOSRecPoint.h
PHOS/AliPHOSReconstructioner.cxx
PHOS/AliPHOSTrackSegment.cxx
PHOS/AliPHOSTrackSegment.h
PHOS/AliPHOSTrackSegmentMaker.h
PHOS/AliPHOSTrackSegmentMakerv1.cxx
PHOS/AliPHOSv0.cxx
PHOS/AliPHOSv0.h
PHOS/Makefile
PHOS/PHOSLinkDef.h
PHOS/PetiteMacrodeNuit.C [new file with mode: 0644]
PHOS/RecAna.C [new file with mode: 0644]
PHOS/RecAna.h [new file with mode: 0644]

index eed560c7592a37c8aaa447eb9275118a4b14894e..25b53000dba9e9dafaff5ea29da799b3b682c2ee 100644 (file)
@@ -16,7 +16,9 @@
 
 #include "AliDetector.h"
 #include "AliPHOSGeometry.h" 
-
+#include "AliRecPoint.h"
+#include "AliPHOSTrackSegment.h"
+#include "AliPHOSRecParticle.h"
 
 class AliPHOS : public AliDetector {
 
@@ -27,7 +29,18 @@ class AliPHOS : public AliDetector {
   virtual ~AliPHOS() ; 
  
   virtual void CreateMaterials() ;               // defines the material of the detector
-  virtual AliPHOSGeometry *  GetGeometry() = 0 ; // hands the pointer to the unique geometry object
+  virtual AliPHOSGeometry * GetGeometry() = 0 ;  
+  RecPointsList* EmcRecPoints() {return fEmcClusters;}               // gets Array of cluster in the crystals 
+  RecParticlesList * RecParticles() { return fRecParticles ; }      // gets Array of reconstructed particles
+  TrackSegmentsList *    TrackSegments(){return fTrackSegments ;} // gets Array of track segments
+  virtual RecPointsList* PpsdRecPoints() = 0 ;        // gets Array of clusters in the PPSD 
+
+ protected:
+  
+  RecPointsList * fEmcClusters ;                  // The RecPoints (clusters) list in EMC 
+  TrackSegmentsList * fTrackSegments ;            // The TrackSegment list in PHOS
+  RecParticlesList * fRecParticles ;              // The reconstructed particles list in PHOS
+
 
   ClassDef(AliPHOS,2) // Photon Spectrometer Detector (base class)
 
index c220e3dd5d7fd2b8d82b4ea02e7e7e5a1709dd42..023b6904295f123dfd3759cfacb1caed8d9d8824 100644 (file)
@@ -51,6 +51,7 @@
 #include "AliPHOSDigit.h"
 #include "AliPHOSTrackSegment.h"
 #include "AliPHOSRecParticle.h"
+#include "AliPHOSIndexToObject.h"
 
 ClassImp(AliPHOSAnalyze)
 
@@ -66,7 +67,7 @@ ClassImp(AliPHOSAnalyze)
 //____________________________________________________________________________
 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * name)
 {
-  // ctor: analyze events from root file: name
+  // ctor: analyze events from root file "name"
   
   Bool_t ok = OpenRootFile(name)  ; 
   if ( !ok ) {
@@ -85,7 +86,8 @@ AliPHOSAnalyze::~AliPHOSAnalyze()
 {
   // dtor
 
-  fRootFile->Close() ; 
+  if (fRootFile->IsOpen() ) 
+    fRootFile->Close() ; 
   delete fRootFile ; 
   fRootFile = 0 ; 
 
@@ -132,8 +134,8 @@ void AliPHOSAnalyze::AnalyzeOneEvent(Int_t evt)
 
     // =========== Write the root file
 
-    fRootFile->Write() ;
-    
+    fRootFile->Close() ; 
+  
     // =========== Finish
 
     cout << "AnalyzeOneEvent > event # " << fEvt << " processed" << endl ;   
@@ -211,13 +213,13 @@ void AliPHOSAnalyze::AnalyzeOneEvent(Int_t evt)
          //=========== Do the reconstruction
          fPHOS->Reconstruction(fRec);
          //=========== Cluster in module
-         TIter nextEmc(fPHOS->EmcClusters()  ) ;
+         TIter nextEmc(fPHOS->EmcRecPoints()  ) ;
          while((emc = (AliPHOSEmcRecPoint *)nextEmc())) 
            {
              if ( emc->GetPHOSMod() == module )
                {  
                  fhEmcCluster->Fill(  emc->GetTotalEnergy()  ); 
-                 TIter nextPpsd( fPHOS->PpsdClusters()) ;
+                 TIter nextPpsd( fPHOS->PpsdRecPoints()) ;
                  while((ppsd = (AliPHOSPpsdRecPoint *)nextPpsd())) 
                    {
                      if ( ppsd->GetPHOSMod() == module )
@@ -228,7 +230,7 @@ void AliPHOSAnalyze::AnalyzeOneEvent(Int_t evt)
                }
            }
          //=========== Cluster in module PPSD Down
-         TIter nextPpsd(fPHOS->PpsdClusters() ) ;
+         TIter nextPpsd(fPHOS->PpsdRecPoints() ) ;
          while((ppsd = (AliPHOSPpsdRecPoint *)nextPpsd())) 
            {
              if ( ppsd->GetPHOSMod() == module )
@@ -379,11 +381,17 @@ Bool_t AliPHOSAnalyze::Init(Int_t evt)
       
       fPHOS  = (AliPHOSv0 *)gAlice->GetDetector("PHOS") ;
       fGeom  = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() );
+
     } // else !ok
   } // if fRootFile
   
   if ( ok ) {
     
+
+    //========== Initializes the Index to Object converter
+
+    fObjGetter = AliPHOSIndexToObject::GetInstance(fPHOS) ; 
+
     //========== Create the Clusterizer
 
     fClu =  new AliPHOSClusterizerv1() ; 
@@ -682,7 +690,9 @@ void AliPHOSAnalyze::DisplayRecPoints()
 
       //=========== Cluster in module
 
-      TClonesArray * emcRP = fPHOS->EmcClusters() ;
+      //      TClonesArray * emcRP = fPHOS->EmcClusters() ; 
+      TObjArray * emcRP = fPHOS->EmcRecPoints() ; 
+      
       etot = 0.; 
       Int_t totalnClusters = 0 ; 
       Int_t nClusters = 0 ;
@@ -715,7 +725,9 @@ void AliPHOSAnalyze::DisplayRecPoints()
  
       //=========== Cluster in module PPSD Down
 
-      TClonesArray * ppsdRP = fPHOS->PpsdClusters() ;
+      //      TClonesArray * ppsdRP = fPHOS->PpsdClusters() ;
+      TObjArray * ppsdRP = fPHOS->PpsdRecPoints() ;
       etot = 0.; 
       TIter nextPpsd(ppsdRP) ;
       AliPHOSPpsdRecPoint * ppsd ;
@@ -736,7 +748,8 @@ void AliPHOSAnalyze::DisplayRecPoints()
 
       //=========== Cluster in module PPSD Up
   
-      ppsdRP = fPHOS->PpsdClusters() ;
+      ppsdRP = fPHOS->PpsdRecPoints() ;
+     
       etot = 0.; 
       TIter nextPpsdUp(ppsdRP) ;
       while((ppsd = (AliPHOSPpsdRecPoint *)nextPpsdUp())) 
index 2d5b8aac62f2a646915e886017cbdb910b190fac..2d4e9cd29334fc9f35ef9d24aed01a15ceee2b9d 100644 (file)
@@ -22,6 +22,7 @@
 #include "AliPHOSv0.h"
 #include "AliPHOSGeometry.h"
 #include "AliPHOSPID.h"
+#include "AliPHOSIndexToObject.h"
 
 class AliPHOSAnalyze : public TObject {
 
@@ -44,14 +45,15 @@ public:
  
 private:
   
-  AliPHOSClusterizer * fClu ;       // a clusterizer 
-  Int_t fEvt ;                      // the evt number being processed 
-  AliPHOSGeometry * fGeom ;         // the PHOS Geometry object
-  AliPHOSv0 * fPHOS ;               // the PHOS object from the root file 
-  AliPHOSPID * fPID ;               // a particle identifier
-  AliPHOSReconstructioner * fRec ;  // a reconstructioner  
-  TFile * fRootFile ;               // the root file that contains the data
-  AliPHOSTrackSegmentMaker * fTrs ; // a tracksegmentmaker ;
+  AliPHOSClusterizer * fClu ;         // a clusterizer 
+  Int_t fEvt ;                        // the evt number being processed 
+  AliPHOSGeometry * fGeom ;           // the PHOS Geometry object
+  AliPHOSIndexToObject * fObjGetter ; // provides methods to retrieve objects from their index in a list
+  AliPHOSv0 * fPHOS ;                 // the PHOS object from the root file 
+  AliPHOSPID * fPID ;                 // a particle identifier
+  AliPHOSReconstructioner * fRec ;    // a reconstructioner  
+  TFile * fRootFile ;                 // the root file that contains the data
+  AliPHOSTrackSegmentMaker * fTrs ;   // a tracksegmentmaker ;
   TH1F * fhEmcDigit ;               // Histo of digit energies in the Emc 
   TH1F * fhVetoDigit ;              // Histo of digit energies in the Veto 
   TH1F * fhConvertorDigit ;         // Histo of digit energies in the Convertor
index 8cfeaca06d7a7976b00e95da662179b6695df877..afab8f95c82dc1234fe99a97ade3c4532d7d00d3 100644 (file)
@@ -19,9 +19,7 @@
 // --- AliRoot header files ---
 
 #include "AliPHOSDigit.h"
-
-typedef TClonesArray    RecPointsList ; 
-typedef TClonesArray    DigitsList ;   
+#include "AliPHOSRecPoint.h"
 
 class AliPHOSClusterizer : public TObject {
 
index c2293c855de6b068ce02815e27f96fb58d1ad574..ef3338a74b815ef0bb1401cb63080ef5293d54ff 100644 (file)
@@ -183,11 +183,10 @@ void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl, RecPointsList * e
   AliPHOSDigit * digit ; 
   Bool_t notremoved = kTRUE ;
 
-
   while ( (digit = (AliPHOSDigit *)nextdigit()) ) { // scan over the list of digits
     AliPHOSRecPoint * clu ; 
    
-    int ** clusterdigitslist = new int * [dl->GetEntries()] ;   
+    AliPHOSDigit ** clusterdigitslist = new AliPHOSDigit*[dl->GetEntries()] ;   
     Int_t index ;
     if (( ( IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fEmcClusteringThreshold ) ) || 
         ( ( !IsInEmc(digit) ) && ( Calibrate(digit->GetAmp() ) > fPpsdClusteringThreshold ) ) ) {
@@ -195,12 +194,15 @@ void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl, RecPointsList * e
       Int_t iDigitInCluster = 0 ; 
 
       if  ( IsInEmc(digit) ) {   
-        new ((*emcl)[fNumberOfEmcClusters]) AliPHOSEmcRecPoint(fW0, fLocMaxCut) ; // start a new EMC RecPoint
+       // start a new EMC RecPoint
+       //        new ((*emcl)[fNumberOfEmcClusters]) AliPHOSEmcRecPoint(fW0, fLocMaxCut) ; if TClonesArray
+       (*emcl)[fNumberOfEmcClusters] = new  AliPHOSEmcRecPoint(fW0, fLocMaxCut) ;
+
        clu = (AliPHOSEmcRecPoint *) (*emcl)[fNumberOfEmcClusters] ; 
        fNumberOfEmcClusters++ ; 
        clu->AddDigit(*digit, Calibrate(digit->GetAmp())) ; 
 
-       clusterdigitslist[iDigitInCluster] = (int* ) digit ;    
+       clusterdigitslist[iDigitInCluster] = digit ;    
        iDigitInCluster++ ; 
        tempodigitslist.Remove(digit) ; 
 
@@ -208,11 +210,15 @@ void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl, RecPointsList * e
       }
 
       else { 
-       new ((*ppsdl)[fNumberOfPpsdClusters]) AliPHOSPpsdRecPoint() ; // start a new PPSD cluster
+       
+       // start a new PPSD cluster
+       // new ((*ppsdl)[fNumberOfPpsdClusters]) AliPHOSPpsdRecPoint() ;  if TClonesArray
+       (*ppsdl)[fNumberOfPpsdClusters] = new AliPHOSPpsdRecPoint() ;
+       
        clu =  (AliPHOSPpsdRecPoint *) ppsdl->At(fNumberOfPpsdClusters)  ;  
        fNumberOfPpsdClusters++ ; 
        clu->AddDigit(*digit, Calibrate(digit->GetAmp()) ) ;    
-       clusterdigitslist[iDigitInCluster] = (int* ) digit ;    
+       clusterdigitslist[iDigitInCluster] = digit  ;   
        iDigitInCluster++ ; 
        tempodigitslist.Remove(digit) ; 
         nextdigit.Reset() ;
@@ -239,7 +245,7 @@ void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl, RecPointsList * e
       AliPHOSDigit * digitN ; 
       index = 0 ;
       while (index < iDigitInCluster){ // scan over digits already in cluster 
-       digit = (AliPHOSDigit *) clusterdigitslist[index]  ;      
+       digit =  clusterdigitslist[index]  ;      
        index++ ; 
         while ( (digitN = (AliPHOSDigit *)nextdigit()) ) { // scan over the reduced list of digits 
          Int_t ineb = AreNeighbours(digit, digitN);   //  call (digit,digitN) in THAT oder !!!!!
@@ -247,8 +253,8 @@ void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl, RecPointsList * e
           case 0 :   // not a neighbour
            break ;      
          case 1 :   // are neighbours 
-           clu->AddDigit( *digitN, Calibrate( digitN->GetAmp() ) ) ;
-           clusterdigitslist[iDigitInCluster] =(int*) digitN ; 
+           clu->AddDigit(*digitN, Calibrate( digitN->GetAmp() ) ) ;
+           clusterdigitslist[iDigitInCluster] = digitN ; 
            iDigitInCluster++ ; 
            tempodigitslist.Remove(digitN) ;
            break ;
@@ -270,6 +276,7 @@ void AliPHOSClusterizerv1::MakeClusters(const DigitsList * dl, RecPointsList * e
   } // while digit
 
   tempodigitslist.Clear() ; 
+
 }
 
 //____________________________________________________________________________
index 1b3aeac89e58ef8e8f2e22b72ceb35004a037b67..376dbbc3d78464771ce8fbc590250192c0d8337d 100644 (file)
@@ -44,21 +44,23 @@ ClassImp(AliPHOSDigit)
 {
   // default ctor 
 
-  fNprimary = 0 ;  
-  fPrimary1 = -1 ; 
-  fPrimary2 = -1 ; 
-  fPrimary3 = -1 ;
+  fIndexInList = -1 ; 
+  fNprimary    = 0 ;  
+  fPrimary1    = -1 ; 
+  fPrimary2    = -1 ; 
+  fPrimary3    = -1 ;
 }
 
 //____________________________________________________________________________
-AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy) 
+AliPHOSDigit::AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index
 {  
   // ctor with all data 
 
-  fId         = id ;
-  fAmp        = DigEnergy ;
-  fPrimary1   = primary ;
-  fNprimary   = 1 ; 
+  fAmp         = DigEnergy ;
+  fId          = id ;
+  fIndexInList = index ; 
+  fPrimary1    = primary ;
+  fNprimary    = 1 ; 
 }
 
 //____________________________________________________________________________
@@ -66,12 +68,13 @@ AliPHOSDigit::AliPHOSDigit(const AliPHOSDigit & digit)
 {
   // copy ctor
   
-  fId       = digit.fId;
-  fAmp      = digit.fAmp ;
-  fNprimary = digit.fNprimary ;
-  fPrimary1 = digit.fPrimary1 ;
-  fPrimary2 = digit.fPrimary2 ;
-  fPrimary3 = digit.fPrimary3 ;
+  fAmp         = digit.fAmp ;
+  fId          = digit.fId;
+  fIndexInList = digit.fIndexInList ; 
+  fNprimary    = digit.fNprimary ;
+  fPrimary1    = digit.fPrimary1 ;
+  fPrimary2    = digit.fPrimary2 ;
+  fPrimary3    = digit.fPrimary3 ;
 }
 
 //____________________________________________________________________________
@@ -196,8 +199,8 @@ ostream& operator << ( ostream& out , const AliPHOSDigit & digit)
   out << "ID " << digit.fId << " Energy = " << digit.fAmp << endl 
       << "Primary 1 = " << digit.fPrimary1 << endl 
       << "Primary 2 = " << digit.fPrimary2 << endl 
-      << "Primary 3 = " << digit.fPrimary3 << endl ;
-
+      << "Primary 3 = " << digit.fPrimary3 << endl 
+      << "Position in list = " << digit.fIndexInList << endl ; 
   return out ;
 }
 
index 22b02dfb47ebeea6bc59ba0176203f3d0b83a5c2..04f84268b9a35fa1b25f63c5fef0dab3955cdbd9 100644 (file)
@@ -30,7 +30,7 @@ class AliPHOSDigit : public AliDigitNew {
 public:
  
   AliPHOSDigit() ;
-  AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy) ;
+  AliPHOSDigit(Int_t primary, Int_t id, Int_t DigEnergy, Int_t index = -1) ;
   AliPHOSDigit(const AliPHOSDigit & digit) ;
   virtual ~AliPHOSDigit(){} 
 
@@ -47,11 +47,11 @@ public:
 
 private:
 
-  Int_t fPrimary1 ;          // first primary (because I do not know how to stream *fPrimary
-  Int_t fPrimary2 ;          // second primary (because I do not know how to stream *fPrimary
-  Int_t fPrimary3 ;          // third primary (because I do not know how to stream *fPrimary
+  Int_t fPrimary1 ;          // first primary (because objects in a TClonesArray bust have constant length
+  Int_t fPrimary2 ;          // second primary (because objects in a TClonesArray bust have constant lengt
+  Int_t fPrimary3 ;          // third primary (because objects in a TClonesArray bust have constant lengt
   Int_t fNprimary ;          // Number of primaries
-  
+    
   ClassDef(AliPHOSDigit,1)   // Digit in PHOS 
 
 } ;
index 0daf2d5401cb747d2e1869f1df35fd117156d3c0..18742f87408f3a8d5d4386e358f51d98344f2041 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliPHOSGeometry.h"
 #include "AliPHOSEmcRecPoint.h"
 #include "AliRun.h"
+#include "AliPHOSIndexToObject.h"
 
 ClassImp(AliPHOSEmcRecPoint)
 
@@ -54,27 +55,35 @@ AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(Float_t W0, Float_t LocMaxCut)
   fW0        = W0 ;          
   fLocMaxCut = LocMaxCut ; 
   fLocPos.SetX(1000000.)  ;      //Local position should be evaluated
+  
+}
+
+//____________________________________________________________________________
+AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
+{
+  if ( fEnergyList )
+    delete[] fEnergyList ; 
 }
 
 //____________________________________________________________________________
-void AliPHOSEmcRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
+void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
 {
   // Adds a digit to the RecPoint
   //  and accumulates the total amplitude and the multiplicity 
   
   if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists 
     fMaxDigit*=2 ; 
-    int * tempo = new ( int[fMaxDigit] ) ; 
+    Int_t * tempo = new ( Int_t[fMaxDigit] ) ; 
     Float_t * tempoE =  new ( Float_t[fMaxDigit] ) ;
 
     Int_t index ;     
     for ( index = 0 ; index < fMulDigit ; index++ ){
-      tempo[index] = fDigitsList[index] ;
+      tempo[index]  = fDigitsList[index] ;
       tempoE[index] = fEnergyList[index] ; 
     }
     
     delete [] fDigitsList ; 
-    fDigitsList =  new ( int[fMaxDigit] ) ;
+    fDigitsList =  new ( Int_t[fMaxDigit] ) ;
  
     delete [] fEnergyList ;
     fEnergyList =  new ( Float_t[fMaxDigit] ) ;
@@ -88,8 +97,9 @@ void AliPHOSEmcRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
     delete [] tempoE ; 
   } // if
   
-  fDigitsList[fMulDigit]   =  (int) &digit  ; 
-  fEnergyList[fMulDigit++] = Energy ;
+  fDigitsList[fMulDigit]   = digit.GetIndexInList()  ; 
+  fEnergyList[fMulDigit]   = Energy ;
+  fMulDigit++ ; 
   fAmp += Energy ; 
 }
 
@@ -168,96 +178,98 @@ void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
 
   //   static Int_t pxold, pyold;
 
-   static TGraph *  digitgraph = 0 ;
-
-   if (!gPad->IsEditable()) return;
-
-   TH2F * histo = 0 ;
-   TCanvas * histocanvas ; 
-   
-   switch (event) {
-   
-   case kButton1Down: {
-     AliPHOSDigit * digit ;
-     AliPHOSGeometry * phosgeom =  (AliPHOSGeometry *) fGeom ;
-     Int_t iDigit;
-     Int_t relid[4] ;
-     
-     const Int_t fMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ; 
-     Float_t * xi = new Float_t[fMulDigit] ; 
-     Float_t * zi = new Float_t[fMulDigit] ; 
-
-     // create the histogram for the single cluster 
-     // 1. gets histogram boundaries
-     Float_t ximax = -999. ; 
-     Float_t zimax = -999. ; 
-     Float_t ximin = 999. ; 
-     Float_t zimin = 999. ;
-     for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-       digit = (AliPHOSDigit *) fDigitsList[iDigit];
-       phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-       phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
-       if ( xi[iDigit] > ximax )
-        ximax = xi[iDigit] ; 
-       if ( xi[iDigit] < ximin )
-        ximin = xi[iDigit] ; 
-       if ( zi[iDigit] > zimax )
-        zimax = zi[iDigit] ; 
-       if ( zi[iDigit] < zimin )
-        zimin = zi[iDigit] ;     
-     }
-     ximax += phosgeom->GetCrystalSize(0) / 2. ;
-     zimax += phosgeom->GetCrystalSize(2) / 2. ;
-     ximin -= phosgeom->GetCrystalSize(0) / 2. ;
-     zimin -= phosgeom->GetCrystalSize(2) / 2. ;
-     Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5  ) ; 
-     Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
-     // 2. gets the histogram title
-
-     Text_t title[100] ; 
-     sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
   
-     if (!histo) {
-       delete histo ; 
-       histo = 0 ; 
-     }
-     histo = new TH2F("cluster3D", title,  xdim, ximin, ximax, zdim, zimin, zimax)  ;
-
-     Float_t x, z ; 
-     for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-       digit = (AliPHOSDigit *) fDigitsList[iDigit];
-       phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-       phosgeom->RelPosInModule(relid, x, z);
-       histo->Fill(x, z, fEnergyList[iDigit] ) ;
-     }
-
-     if (!digitgraph) {
-       digitgraph = new TGraph(fMulDigit,xi,zi);
-       digitgraph-> SetMarkerStyle(5) ; 
-       digitgraph-> SetMarkerSize(1.) ;
-       digitgraph-> SetMarkerColor(1) ;
-       digitgraph-> Paint("P") ;
-     }
-
-     Print() ;
-     histocanvas = new TCanvas("cluser", "a single cluster", 600, 500) ; 
-     histocanvas->Draw() ; 
-     histo->Draw("lego1") ; 
-
-     delete[] xi ; 
-     delete[] zi ; 
-     
-     break;
-   }
-
-   case kButton1Up: 
-     if (digitgraph) {
-       delete digitgraph  ;
-       digitgraph = 0 ;
-     }
-     break;
+  static TGraph *  digitgraph = 0 ;
+  
+  if (!gPad->IsEditable()) return;
+  
+  TH2F * histo = 0 ;
+  TCanvas * histocanvas ; 
+  
+  switch (event) {
+    
+  case kButton1Down: {
+    AliPHOSDigit * digit ;
+    AliPHOSGeometry * phosgeom =  (AliPHOSGeometry *) fGeom ;
+    Int_t iDigit;
+    Int_t relid[4] ;
+    
+    const Int_t fMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ; 
+    Float_t * xi = new Float_t[fMulDigit] ; 
+    Float_t * zi = new Float_t[fMulDigit] ; 
+    
+    // create the histogram for the single cluster 
+    // 1. gets histogram boundaries
+    Float_t ximax = -999. ; 
+    Float_t zimax = -999. ; 
+    Float_t ximin = 999. ; 
+    Float_t zimin = 999. ;
+    
+    for(iDigit=0; iDigit<fMulDigit; iDigit++) {
+      digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
+      phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
+      phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
+      if ( xi[iDigit] > ximax )
+       ximax = xi[iDigit] ; 
+      if ( xi[iDigit] < ximin )
+       ximin = xi[iDigit] ; 
+      if ( zi[iDigit] > zimax )
+       zimax = zi[iDigit] ; 
+      if ( zi[iDigit] < zimin )
+       zimin = zi[iDigit] ;     
+    }
+    ximax += phosgeom->GetCrystalSize(0) / 2. ;
+    zimax += phosgeom->GetCrystalSize(2) / 2. ;
+    ximin -= phosgeom->GetCrystalSize(0) / 2. ;
+    zimin -= phosgeom->GetCrystalSize(2) / 2. ;
+    Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5  ) ; 
+    Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
+    
+    // 2. gets the histogram title
+    
+    Text_t title[100] ; 
+    sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
+    
+    if (!histo) {
+      delete histo ; 
+      histo = 0 ; 
+    }
+    histo = new TH2F("cluster3D", title,  xdim, ximin, ximax, zdim, zimin, zimax)  ;
+    
+    Float_t x, z ; 
+    for(iDigit=0; iDigit<fMulDigit; iDigit++) {
+      digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
+      phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
+      phosgeom->RelPosInModule(relid, x, z);
+      histo->Fill(x, z, fEnergyList[iDigit] ) ;
+    }
+    
+    if (!digitgraph) {
+      digitgraph = new TGraph(fMulDigit,xi,zi);
+      digitgraph-> SetMarkerStyle(5) ; 
+      digitgraph-> SetMarkerSize(1.) ;
+      digitgraph-> SetMarkerColor(1) ;
+      digitgraph-> Paint("P") ;
+    }
+    
+    Print() ;
+    histocanvas = new TCanvas("cluser", "a single cluster", 600, 500) ; 
+    histocanvas->Draw() ; 
+    histo->Draw("lego1") ; 
+    
+    delete[] xi ; 
+    delete[] zi ; 
+    
+    break;
+  }
+  
+  case kButton1Up: 
+    if (digitgraph) {
+      delete digitgraph  ;
+      digitgraph = 0 ;
+    }
+    break;
   
    }
 }
@@ -267,6 +279,8 @@ Float_t  AliPHOSEmcRecPoint::GetDispersion()
 {
   // Calculates the dispersion of the shower at the origine of the RecPoint
 
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   Float_t d    = 0 ;
   Float_t wtot = 0 ;
 
@@ -280,7 +294,7 @@ Float_t  AliPHOSEmcRecPoint::GetDispersion()
   
   Int_t iDigit;
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit];
+    digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
     Int_t relid[4] ;
     Float_t xi ;
     Float_t zi ;
@@ -300,7 +314,9 @@ Float_t  AliPHOSEmcRecPoint::GetDispersion()
 void  AliPHOSEmcRecPoint::GetElipsAxis(Float_t * lambda)
 {
   // Calculates the axis of the shower ellipsoid
-  
+
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   Float_t wtot = 0. ;
   Float_t x    = 0.;
   Float_t z    = 0.;
@@ -313,7 +329,7 @@ void  AliPHOSEmcRecPoint::GetElipsAxis(Float_t * lambda)
   Int_t iDigit;
 
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit];
+    digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
     Int_t relid[4] ;
     Float_t xi ;
     Float_t zi ;
@@ -345,7 +361,9 @@ void  AliPHOSEmcRecPoint::GetElipsAxis(Float_t * lambda)
 void AliPHOSEmcRecPoint::GetLocalPosition(TVector3 &LPos)
 {
   // Calculates the center of gravity in the local PHOS-module coordinates 
-  
+
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   if( fLocPos.X() < 1000000.) { // already evaluated
    LPos = fLocPos ;
    return ;
@@ -366,7 +384,7 @@ void AliPHOSEmcRecPoint::GetLocalPosition(TVector3 &LPos)
 
 
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit];
+    digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) );
 
     Float_t xi ;
     Float_t zi ;
@@ -426,6 +444,8 @@ Int_t  AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t *  maxAt, Float_t * maxAtEn
   // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
   //  energy difference between two local maxima
 
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   AliPHOSDigit * digit ;
   AliPHOSDigit * digitN ;
   
@@ -434,15 +454,15 @@ Int_t  AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t *  maxAt, Float_t * maxAtEn
   Int_t iDigit ;
 
   for(iDigit = 0; iDigit < fMulDigit; iDigit++){
-    maxAt[iDigit] = fDigitsList[iDigit] ;
+    maxAt[iDigit] = (Int_t) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
   }
   
   for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {   
     if(maxAt[iDigit] != -1) {
       digit = (AliPHOSDigit *) maxAt[iDigit] ;
-         
+          
       for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {       
-       digitN = (AliPHOSDigit *) fDigitsList[iDigitN] ; 
+       digitN = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigitN]) ) ; 
        
        if ( AreNeighbours(digit, digitN) ) {
          if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {    
@@ -522,9 +542,11 @@ void AliPHOSEmcRecPoint::Print(Option_t * option)
   Float_t xi ;
   Float_t zi ;
   Int_t relid[4] ; 
+  
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit];
+    digit = please->GimeDigit( fDigitsList[iDigit] ) ; 
     phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
     phosgeom->RelPosInModule(relid, xi, zi);
     cout << " Id = " << digit->GetId() ;  
@@ -535,30 +557,28 @@ void AliPHOSEmcRecPoint::Print(Option_t * option)
   }
   cout << "       Multiplicity    = " << fMulDigit  << endl ;
   cout << "       Cluster Energy  = " << fAmp << endl ;
-  
+  cout << "       Stored at position " << GetIndexInList() << endl ; 
 }
-
 //______________________________________________________________________________
 void AliPHOSEmcRecPoint::Streamer(TBuffer &R__b)
 {
-  // Stream an object of class AliPHOSEmcRecPoint.
-  // Needed because of the array fEnergyList
-  
+   // Stream an object of class AliPHOSEmcRecPoint.
+
    if (R__b.IsReading()) {
       Version_t R__v = R__b.ReadVersion(); if (R__v) { }
       AliPHOSRecPoint::Streamer(R__b);
       R__b >> fDelta;
+      fEnergyList = new Float_t[fMulDigit] ; 
+      R__b.ReadFastArray(fEnergyList, fMulDigit);
       R__b >> fLocMaxCut;
-      R__b.ReadArray(fEnergyList);
       R__b >> fW0;
    } else {
       R__b.WriteVersion(AliPHOSEmcRecPoint::IsA());
       AliPHOSRecPoint::Streamer(R__b);
       R__b << fDelta;
+      R__b.WriteFastArray(fEnergyList, fMulDigit);
       R__b << fLocMaxCut;
-      R__b.WriteArray(fEnergyList, GetMaximumDigitMultiplicity() );
       R__b << fW0;
    }
 }
-
-
index 6f77dfee9a56a02dc074bea8fc920937102c03d9..6a727b13ff153b319b733982ada769db45322624 100644 (file)
@@ -29,9 +29,9 @@ public:
 
   AliPHOSEmcRecPoint(){} ;                    
   AliPHOSEmcRecPoint(Float_t W0, Float_t LocMaxCut) ;
-  virtual ~AliPHOSEmcRecPoint(){} 
+  virtual ~AliPHOSEmcRecPoint() ;  
 
-  void        AddDigit(AliDigitNew & digit, Float_t Energy) ;  // add a digit to the digits list  
+  virtual void  AddDigit(AliPHOSDigit & digit, Float_t Energy) ;  // add a digit to the digits list  
   Int_t       Compare(TObject * obj) ;                         // method for sorting  
   
   Float_t     GetDelta (){ return fDelta ; }    
@@ -57,12 +57,11 @@ private:
 
   Bool_t AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) ;
 
-  Float_t  fDelta ;        // parameter used to sort the clusters    
-  Float_t  fLocMaxCut ;    // minimum energy difference to distinguish two maxima 
-  Float_t  *fEnergyList ;  // energy of digits
-  Float_t  fW0 ;           // logarithmic weight factor for center of gravity calculation
-  TArrayI *fTest ; 
-
+  Float_t  fDelta ;          // parameter used to sort the clusters    
+  Float_t  *fEnergyList ;    // energy of digits
+  Float_t  fLocMaxCut ;      // minimum energy difference to distinguish two maxima 
+  Float_t  fW0 ;             // logarithmic weight factor for center of gravity calculation
+  
   ClassDef(AliPHOSEmcRecPoint,1)  // EMC RecPoint (cluster)
 
 };
index 1a5aa93a45c158b79934769f45cc395842d7700a..9ddbdaf24f12f9db3a7151d879e7d714f43c6e66 100644 (file)
@@ -45,6 +45,7 @@ public:
   virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) ; 
   virtual void Draw(Option_t *option) ;  
   virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py) ;
+  Int_t GetIndexInList() const { return fIndexInList ; } 
   virtual Int_t * GetPrimaries(Int_t & number) ;
   Int_t GetType() { return fType ; } 
   TString Name() ; 
@@ -52,11 +53,13 @@ public:
   void Print() ; 
   void SetPrimary(Int_t index) { fPrimary = index ; }
   void SetType(Int_t type) { fType = type ; } 
+  void SetIndexInList(Int_t val) { fIndexInList = val ; } 
 
 protected:
 
-  Int_t fType ;    // particle type obtained by "virtual" reconstruction
-  Int_t fPrimary ; // (unique) primary particle index 
+  Int_t fIndexInList ; // the index of this RecParticle in the list stored in TreeR (to be set by analysis)
+  Int_t fPrimary ;     // (unique) primary particle index 
+  Int_t fType ;        // particle type obtained by "virtual" reconstruction
 
   ClassDef(AliPHOSFastRecParticle,1)  // Reconstructed Particle produced by the fast simulation 
 
diff --git a/PHOS/AliPHOSIndexToObject.cxx b/PHOS/AliPHOSIndexToObject.cxx
new file mode 100644 (file)
index 0000000..4da34d8
--- /dev/null
@@ -0,0 +1,226 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id:  */
+
+//_________________________________________________________________________
+//  A singleton that retrieves objets from an array stored in a Tree on a disk file
+//    1. AliPHOSDigit from TreeD     
+//                  
+//*-- Author: Yves Schutz (SUBATECH)
+//////////////////////////////////////////////////////////////////////////////
+
+// --- ROOT system ---
+
+// --- Standard library ---
+
+// --- AliRoot header files ---
+
+#include "AliPHOSIndexToObject.h"
+
+ClassImp(AliPHOSIndexToObject)
+  
+  AliPHOSIndexToObject * AliPHOSIndexToObject::fObjGetter = 0 ; 
+
+//____________________________________________________________________________ 
+AliPHOSIndexToObject::AliPHOSIndexToObject(AliPHOS * det)
+{
+  // ctor called once to initialize the detector in use
+
+  fDetector = det ; 
+}
+
+//____________________________________________________________________________ 
+AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance()
+{
+  // Returns the pointer of the unique instance already defined
+  
+  AliPHOSIndexToObject * rv = 0 ;
+  if ( fObjGetter )
+    rv = fObjGetter ;
+  else
+    cout << "AliPHOSIndexToObject::GetInstance ERROR: not yet initialized" << endl ;
+  
+  return rv ;
+}
+
+//____________________________________________________________________________ 
+AliPHOSIndexToObject * AliPHOSIndexToObject::GetInstance(AliPHOS * det)
+{
+  // Creates and returns the pointer of the unique instance
+  // Must be called only when the environment has changed (a new event for exemple)
+
+  if ( fObjGetter )      // delete it if already exists
+    delete fObjGetter ; 
+
+  fObjGetter = new AliPHOSIndexToObject(det) ; 
+  
+  return fObjGetter ; 
+  
+}
+
+//____________________________________________________________________________ 
+AliPHOSDigit * AliPHOSIndexToObject::GimeDigit(Int_t index)
+{
+  // returns the object AliPHOSDigit stored at array position index in TreeD
+
+  AliPHOSDigit * rv = 0 ; 
+
+  if ( index >= fDetector->Digits()->GetEntries() ) 
+    cout << "AliPHOSIndexToObject::GimeDigit: index " << index << " larger than available entries " 
+        <<  fDetector->Digits()->GetEntries() << endl ; 
+  else if ( index != -1) 
+    rv =  (AliPHOSDigit *) (fDetector->Digits()->At(index) ) ; 
+
+  return rv ;
+  
+}
+//____________________________________________________________________________ 
+TParticle * AliPHOSIndexToObject::GimePrimaryParticle(Int_t index)
+{
+  // returns the object TParticle stored at array position index in TreeK
+
+  TParticle * rv = 0 ; 
+     
+  if ( index >= gAlice->Particles()->GetEntries() ) 
+    cout << "AliPHOSIndexToObject::GimePrimaryParticles: index " << index << " larger than available entries " 
+        <<  gAlice->Particles()->GetEntries() << endl ; 
+  else 
+    rv =  (TParticle *) (gAlice->Particles()->At(index) ) ; 
+
+  return rv ;
+  
+}
+
+//____________________________________________________________________________ 
+AliPHOSRecParticle * AliPHOSIndexToObject::GimeRecParticle(Int_t index)
+{
+  // returns the object AliPHOSRecParticle stored at array position index in TreeR/PHOSRP
+  // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
+  // therefore the links are lost
+
+  AliPHOSRecParticle * rv = 0 ; 
+
+  RecParticlesList * rplist = fDetector->RecParticles() ; 
+
+  Int_t rpentries  = 0 ; 
+
+  if (rplist) 
+    rpentries = rplist->GetEntries() ;
+  
+  fReconstruct = gAlice->TreeR() ; 
+  
+  if (!rpentries) {
+    fReconstruct->SetBranchAddress( "PHOSRP", &rplist ) ;
+    fReconstruct->GetEvent(0) ;
+    rpentries = rplist->GetEntries() ;  
+  }     
+  
+  if ( index >= rpentries )  // ERROR 
+    cout << "AliPHOSIndexToObject::GimeRecParticle: index " << index << " larger than available entries " 
+          <<  rpentries << endl ; 
+  else 
+    rv =  (AliPHOSRecParticle *) (fDetector->RecParticles()->At(index) ) ; 
+  
+  return rv ;
+  
+}
+
+//____________________________________________________________________________ 
+AliRecPoint * AliPHOSIndexToObject::GimeRecPoint(Int_t index, TString type)
+{
+  // returns the object AliPHOSRecPoint stored at array position index in TreeR/PHOSEmcRP or TreeR/PHOSPpsdRP
+  // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
+  // therefore the links are lost
+
+  AliPHOSRecPoint * rv = 0 ; 
+  
+  RecPointsList * emclist = fDetector->EmcRecPoints() ; 
+  RecPointsList * ppsdlist = fDetector->PpsdRecPoints() ; 
+
+  Int_t emcentries  = 0 ; 
+  Int_t ppsdentries = 0 ; 
+
+  if (emclist) 
+    emcentries = emclist->GetEntries() ;
+
+  if (ppsdlist)
+    ppsdentries= ppsdlist->GetEntries() ;
+
+  fReconstruct = gAlice->TreeR() ; 
+  
+  if (!emcentries || !ppsdentries) {
+    fReconstruct->SetBranchAddress("PHOSEmcRP",&emclist);
+    fReconstruct->SetBranchAddress("PHOSPpsdRP",&ppsdlist);
+    fReconstruct->GetEvent(0) ;
+    emcentries = emclist->GetEntries() ;
+    ppsdentries= ppsdlist->GetEntries() ;
+  }     
+
+  if ( type == "emc" ) {
+    if ( index >= emcentries ) 
+      cout << "AliPHOSIndexToObject::GimeRecPoint emc: index " << index << " larger than available entries " 
+          <<  emcentries << endl ; 
+    else 
+      rv =  (AliPHOSEmcRecPoint *) ( emclist->At(index) ) ;
+  } 
+  else if ( type == "ppsd" ) {  
+    if ( index >= ppsdentries ) 
+      cout << "AliPHOSIndexToObject::GimeRecPoint ppsd: index " << index << " larger than available entries " 
+          <<  ppsdentries << endl ; 
+    else if (index != -1) 
+      rv =  (AliPHOSPpsdRecPoint *) (ppsdlist->At(index) ) ;
+  } else
+    cout << "AliPHOSIndexToObject::GimeRecPoint: " << type << " is an unknown type " << endl
+        << " valid types are : emc " << endl 
+        << "                   ppsd " << endl ;
+  
+  return rv ;
+  
+}
+
+//____________________________________________________________________________ 
+AliPHOSTrackSegment * AliPHOSIndexToObject::GimeTrackSegment(Int_t index)
+{
+  // returns the object AliPHOSTrackSegment stored at array position index in TreeR/PHOSTS
+  // this one takes more work because the detetor object and the objects in TreeR are not saved at the same time
+  // therefore the links are lost
+
+  AliPHOSTrackSegment * rv = 0 ; 
+
+  TrackSegmentsList * tslist = fDetector->TrackSegments() ; 
+
+  Int_t tsentries  = 0 ; 
+
+  if (tslist) 
+    tsentries = tslist->GetEntries() ;
+  
+  fReconstruct = gAlice->TreeR() ; 
+  
+  if (!tsentries) {
+    fReconstruct->SetBranchAddress( "PHOSTS", &tslist ) ;
+    fReconstruct->GetEvent(0) ;
+    tsentries = tslist->GetEntries() ;  
+  }     
+  
+  if ( index >= tsentries )  // ERROR 
+      cout << "AliPHOSIndexToObject::GimeTrackSegment: index " << index << " larger than available entries " 
+          <<  tsentries << endl ; 
+  else 
+    rv =  (AliPHOSTrackSegment *) (fTrackSegmentsList->At(index) ) ; 
+  
+  return rv ;
+  
+}
diff --git a/PHOS/AliPHOSIndexToObject.h b/PHOS/AliPHOSIndexToObject.h
new file mode 100644 (file)
index 0000000..170e0cd
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef ALIPHOSINDEXTOOBJECT_H
+#define ALIPHOSINDEXTOOBJECT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//_________________________________________________________________________
+//  A singleton that retrieves objets from an array stored in a Tree on a disk file
+//    1. AliPHOSDigit from TreeD     
+//                  
+//*-- Author: Yves Schutz (SUBATECH)
+
+
+// --- ROOT system ---
+
+#include "TFile.h"
+#include "TString.h"
+#include "TParticle.h"
+
+// --- Standard library ---
+
+#include "assert.h"
+
+// --- AliRoot header files ---
+
+#include "AliPHOS.h" 
+#include "AliRun.h" 
+#include "AliPHOSDigit.h" 
+#include "AliPHOSEmcRecPoint.h"
+#include "AliPHOSPpsdRecPoint.h"
+#include "AliPHOSTrackSegment.h"
+#include "AliPHOSRecParticle.h"
+
+class AliPHOSIndexToObject : public TObject {
+
+public:
+
+  AliPHOSIndexToObject(){ assert(0==1) ; } // should be never called
+  virtual ~AliPHOSIndexToObject(){} ; // dtor
+
+  static AliPHOSIndexToObject * GetInstance(AliPHOS * det) ; 
+  static AliPHOSIndexToObject * GetInstance() ; 
+  
+  AliPHOSDigit *        GimeDigit(Int_t index) ; 
+  TParticle *           GimePrimaryParticle(Int_t index) ;
+  AliPHOSRecParticle *  GimeRecParticle(Int_t index) ; 
+  AliRecPoint *         GimeRecPoint(Int_t index, TString s) ; 
+  AliPHOSTrackSegment * GimeTrackSegment(Int_t index) ;
+  
+ private:
+  
+  AliPHOSIndexToObject(AliPHOS * det) ; 
+
+  AliPHOS * fDetector ;                    // the detector 
+  TTree * fDigits     ;                    // the digits tree
+  //  RecPointsList * fEmcList ;               // array od EMC RecPoints 
+  TTree * fKine ;                          // the kine tree that contains primary particles
+  //  RecPointsList * fPpsdList ;              // array od PPSD reconstructed points 
+  RecParticlesList * fRecParticlesList ;   // array of reconstructed particles 
+  TTree * fReconstruct ;                   // the reconstruction tree  
+  TrackSegmentsList * fTrackSegmentsList ; // array of track segments
+
+  static AliPHOSIndexToObject * fObjGetter ; // pointer to the unique instance of the singleton 
+
+  ClassDef(AliPHOSIndexToObject,1)  // Algorithm class that provides methods to retrieve objects from a list knowing the index 
+
+};
+
+#endif // AliPHOSINDEXTOOBJECT_H
index 480e6f2577dc924246805cae9953dcba0eb8a48b..e8efc91459e49621f9af784cf968f2dcc3275780 100644 (file)
 
 // --- AliRoot header files ---
 
-#include "AliPHOSTrackSegmentMaker.h"
+#include "AliPHOSTrackSegment.h"
+#include "AliPHOSRecParticle.h"
 
 
-typedef TClonesArray RecParticlesList ; 
 
 class AliPHOSPID : public TObject {
 
index 732a12a67b695bbe6ad964fe9c02b1e343f37ab4..055cdf916432c10f15fa3de71f94633500a500f2 100644 (file)
@@ -33,6 +33,7 @@
 #include "AliPHOSPIDv1.h"
 #include "AliPHOSTrackSegment.h"
 #include "AliPHOSRecParticle.h"
+#include "AliPHOSIndexToObject.h"
 
 ClassImp( AliPHOSPIDv1) 
 
@@ -49,13 +50,14 @@ void  AliPHOSPIDv1::MakeParticles(TrackSegmentsList * trsl, RecParticlesList * r
 
   while ( (tracksegment = (AliPHOSTrackSegment *)next()) ) {
     new( (*rpl)[index] ) AliPHOSRecParticle(tracksegment) ;
-    rp = (AliPHOSRecParticle *)(*rpl)[index] ; 
+    rp = (AliPHOSRecParticle *)rpl->At(index) ; 
 
     // try to figure out the type of particle:
     //    1. just looking at the PPSD information 
-    if( tracksegment->GetPpsdUp() == 0 ) {     // Neutral
+    
+    if( tracksegment->GetPpsdUpRecPoint() == 0 ) {     // Neutral
       
-      if( tracksegment->GetPpsdLow() == 0 )    // Neutral  
+      if( tracksegment->GetPpsdLowRecPoint() == 0 )    // Neutral  
        type = kNEUTRAL ;   
       else {    // check the shower profile       
        AliPHOSEmcRecPoint * recp = tracksegment->GetEmcRecPoint() ; 
@@ -70,7 +72,7 @@ void  AliPHOSPIDv1::MakeParticles(TrackSegmentsList * trsl, RecParticlesList * r
     } // Neutral
     else                            // Charged           
       type = kCHARGED ;   
-
+    
     //   2. from the shower profile analysis
     if ( type == kNEUTRAL ) { 
       AliPHOSEmcRecPoint * recp = tracksegment->GetEmcRecPoint() ; 
@@ -86,10 +88,11 @@ void  AliPHOSPIDv1::MakeParticles(TrackSegmentsList * trsl, RecParticlesList * r
 
     //   3. from the shower dispersion 
     if (type == kCHARGED) { 
+      
       if( tracksegment->GetEmcRecPoint()->GetDispersion() > fCutOnDispersion)  // shower dispersion cut
        type = kCHARGEDHADRON ;
-      else  
-       type = kELECTRON ; 
+       //     else  
+       //      type = kELECTRON ; 
     } 
     rp->SetType(type) ; 
     index++ ; 
index 31f6e377cd4eb90d6e3bdd012fbf29a838ea42d2..27536638a02b7d94583149926386d305a67c544d 100644 (file)
@@ -34,6 +34,7 @@
 #include "AliPHOSGeometry.h"
 #include "AliPHOSPpsdRecPoint.h"
 #include "AliRun.h"
+#include "AliPHOSIndexToObject.h"
 
 ClassImp(AliPHOSPpsdRecPoint)
 
@@ -49,7 +50,7 @@ AliPHOSPpsdRecPoint::AliPHOSPpsdRecPoint(void)
 }
 
 //____________________________________________________________________________
-void AliPHOSPpsdRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
+void AliPHOSPpsdRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
 {
   // adds a digit to the digits list
   // and accumulates the total amplitude and the multiplicity 
@@ -72,7 +73,7 @@ void AliPHOSPpsdRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
     delete [] tempo ;
   }
 
-  fDigitsList[fMulDigit++]  =  (int) &digit  ; 
+  fDigitsList[fMulDigit++]  =  digit.GetIndexInList() ; 
   fAmp += Energy ; 
 }
 
@@ -157,6 +158,8 @@ void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
 {
   // Calculates the local position in the PHOS-PPSD-module corrdinates
   
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   if( fLocPos.X() < 1000000.) { //allready evaluated
    LPos = fLocPos ;
    return ;
@@ -173,7 +176,7 @@ void AliPHOSPpsdRecPoint::GetLocalPosition(TVector3 &LPos)
   Int_t iDigit;
 
   for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit]
+    digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) )
  
     Float_t xi ;
     Float_t zi ;
@@ -199,9 +202,12 @@ Bool_t AliPHOSPpsdRecPoint::GetUp()
 {
   Int_t relid[4] ;
   
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
   
-  AliPHOSDigit *digit = (AliPHOSDigit *)fDigitsList[0] ; 
+  
+  AliPHOSDigit *digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[0]) ) ; 
   
   phosgeom->AbsToRelNumbering(digit->GetId(),relid);
   Bool_t up ;
@@ -256,18 +262,22 @@ void AliPHOSPpsdRecPoint::Print(Option_t * option)
   Float_t zi ;
   Int_t relid[4] ; 
 
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
   for(iDigit=0; iDigit<fMulDigit; iDigit++) {
-    digit = (AliPHOSDigit *) fDigitsList[iDigit];
-    phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
-    phosgeom->RelPosInModule(relid, xi, zi);
-    cout << " Id = " << digit->GetId() ;  
-    cout << "  Phos mod = " << relid[0] ;  
-    cout << "  PPSD mod = " << relid[1] ;  
-    cout << "  x = " << xi ;  
-    cout << "  z = " << zi ;  
-    cout << "   Energy = " << digit->GetAmp() << endl ;
+    digit = please->GimeDigit( fDigitsList[iDigit] ) ; 
+    if (digit) {
+      phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
+      phosgeom->RelPosInModule(relid, xi, zi);
+      cout << " Id = " << digit->GetId() ;  
+      cout << "  Phos mod = " << relid[0] ;  
+      cout << "  PPSD mod = " << relid[1] ;  
+      cout << "  x = " << xi ;  
+      cout << "  z = " << zi ;  
+      cout << "   Energy = " << digit->GetAmp() << endl ;
+    }
   }
   cout << "       Multiplicity    = " << fMulDigit  << endl ;
+  cout << "       Stored at position " << fIndexInList << endl ; 
 }
 
 
index c069b011489d024ae3c74d1e0e8e352a84dc8e0d..9e8b916cf7768d82b71433d67e787bbf6eefff50 100644 (file)
@@ -27,7 +27,7 @@ public:
   AliPHOSPpsdRecPoint() ;           // ctor   
   virtual ~AliPHOSPpsdRecPoint(){}  // dtor
 
-  void AddDigit(AliDigitNew & digit, Float_t Energy) ;
+  virtual void AddDigit(AliPHOSDigit & digit, Float_t Energy) ;
   Int_t   Compare(TObject * obj) ;                    // method to sort clusters
 
   Float_t GetDelta(void) {return fDelta ;}
index 77ca26ad1905d103b5c727b5aadebae3a7ef641e..43211abf430f791a87f39ad4012a97bc3d3375db 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "AliPHOSRecParticle.h"
 #include "TPad.h"
+#include "AliPHOSIndexToObject.h"
 
 ClassImp(AliPHOSRecParticle)
 
@@ -39,7 +40,8 @@ ClassImp(AliPHOSRecParticle)
 {
   // ctor
  
-  fPHOSTrackSegment = new AliPHOSTrackSegment(*ts) ; 
+  fPHOSTrackSegment = ts->GetIndexInList() ;
+  fIndexInList      = -1 ;
   Float_t kenergy   = ts->GetEnergy() ; 
   TVector3 momdir   = ts->GetMomentumDirection() ;
   fPx               = kenergy * momdir.X() ; 
@@ -54,8 +56,9 @@ ClassImp(AliPHOSRecParticle)
 {
   // copy ctor
 
-  fPHOSTrackSegment = new AliPHOSTrackSegment( *( rp.GetPHOSTrackSegment()) ) ; 
+  fPHOSTrackSegment = rp.fPHOSTrackSegment ; 
   fType             = rp.fType ; 
+  fIndexInList      = rp.fIndexInList ;
 
   fPdgCode     = rp.fPdgCode;
   fStatusCode  = rp.fStatusCode;
@@ -78,30 +81,21 @@ ClassImp(AliPHOSRecParticle)
   fParticlePDG = rp.fParticlePDG; 
 }
 
-//____________________________________________________________________________
- AliPHOSRecParticle::~AliPHOSRecParticle()
-{
-  // dtor
-
-  if(!fPHOSTrackSegment) {
-    delete fPHOSTrackSegment ;
-    fPHOSTrackSegment = 0 ; 
-  } 
-}
-
 //____________________________________________________________________________
 Int_t * AliPHOSRecParticle::GetPrimaries(Int_t & number) 
 {
   // Retrieves all the primary particles at the origine of this reconstructed particle
 
+  AliPHOSTrackSegment * ts = GetPHOSTrackSegment() ;
+
   Int_t emcnumber = 0 ; 
-  Int_t * emclist = fPHOSTrackSegment->GetPrimariesEmc(emcnumber) ;
+  Int_t * emclist = ts->GetPrimariesEmc(emcnumber) ;
   
-  Int_t ppsdlnumber = 0 ; 
-  Int_t * ppsdllist = fPHOSTrackSegment->GetPrimariesPpsdLow(ppsdlnumber) ;
+  Int_t ppsdlnumber = 0 ;
+  Int_t * ppsdllist = ts->GetPrimariesPpsdLow(ppsdlnumber) ;
  
   Int_t ppsdunumber = 0 ; 
-  Int_t * ppsdulist = fPHOSTrackSegment->GetPrimariesPpsdUp(ppsdunumber) ;
+  Int_t * ppsdulist = ts->GetPrimariesPpsdUp(ppsdunumber) ;
 
   number = emcnumber + ppsdlnumber + ppsdunumber ;
   Int_t * list   = new Int_t[number] ;
@@ -123,11 +117,22 @@ Int_t * AliPHOSRecParticle::GetPrimaries(Int_t & number)
     index++ ; 
   }
 
-  cout << "passed 6 " << endl;
-
   delete emclist ;
   delete ppsdllist ;
   delete ppsdulist ;
 
   return list ; 
 }
+
+//____________________________________________________________________________
+AliPHOSTrackSegment * AliPHOSRecParticle::GetPHOSTrackSegment() const 
+{
+  // Retrieves the PHOS track segment at the origine of this reconstructed particle
+
+  AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
+  return please->GimeTrackSegment( fPHOSTrackSegment ) ;
+
+}
+
+
+
index ab35b5a6e6bfffe090013ba3911b8233ccaddb19..f22a3f5b0f7c861922dc1096299473e642ed8f36 100644 (file)
@@ -23,6 +23,8 @@
 #include "AliPHOSTrackSegment.h"
 #include "AliPHOSFastRecParticle.h"
 
+typedef TClonesArray RecParticlesList ; 
+
 class AliPHOSRecParticle : public AliPHOSFastRecParticle {
 
 public:
@@ -30,14 +32,14 @@ public:
   AliPHOSRecParticle() {};          // ctor
   AliPHOSRecParticle(AliPHOSTrackSegment * ts) ;  // ctor
   AliPHOSRecParticle(const AliPHOSRecParticle & rp) ;  // ctor
-  virtual ~AliPHOSRecParticle() ; // dtor
+  virtual ~AliPHOSRecParticle(){} ; // dtor
 
-  AliPHOSTrackSegment * GetPHOSTrackSegment() const { return fPHOSTrackSegment ; } 
-  virtual Int_t * GetPrimaries(Int_t & number) ;
+  AliPHOSTrackSegment * GetPHOSTrackSegment() const ; 
+  Int_t *               GetPrimaries(Int_t & number) ;
 
 private:
 
-  AliPHOSTrackSegment * fPHOSTrackSegment ; // pointer to the associated track segment in PHOS  
+  Int_t fPHOSTrackSegment ; // pointer to the associated track segment in PHOS  
 
   ClassDef(AliPHOSRecParticle,1)  // Reconstructed Particle
 };
index 7b0ee9e9f48c2760fb39287243d33e1df1f99a36..af0f6a7b7417f27694b8134c715c76de0490daeb 100644 (file)
@@ -32,8 +32,7 @@
 #include "AliPHOSGeometry.h"
 #include "AliPHOSDigit.h"
 #include "AliPHOSRecPoint.h"
-
-
+#include "AliPHOSIndexToObject.h"
 
 ClassImp(AliPHOSRecPoint)
 
@@ -162,10 +161,13 @@ Int_t AliPHOSRecPoint::GetPHOSMod()
   if(fPHOSMod > 0) 
     return fPHOSMod ;
 
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ; 
+
   Int_t relid[4] ;
   
+  
   AliPHOSDigit * digit   ;
-  digit = (AliPHOSDigit *) fDigitsList[0] ;
+  digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[0]) ) ;
   AliPHOSGeometry * phosgeom =  (AliPHOSGeometry *) fGeom ;
 
   phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
index 2c061e748eae8b265788abde123d82bf5c1df87a..7c33b2a4e61829e5d6f491bafd6adf70296625a3 100644 (file)
@@ -19,6 +19,9 @@
 // --- AliRoot header files ---
 
 #include "AliRecPoint.h"
+#include "AliPHOSDigit.h"
+
+typedef TObjArray       RecPointsList ; 
 
 class AliPHOSRecPoint : public AliRecPoint {
 
@@ -26,22 +29,21 @@ public:
 
   AliPHOSRecPoint() ;                   // ctor         
   virtual ~AliPHOSRecPoint(){}          // dtor
-  virtual  void   AddDigit(AliDigitNew & digit, Float_t Energy) = 0 ; 
+  virtual  void   AddDigit(AliPHOSDigit & digit, Float_t Energy) = 0 ; 
+  virtual Int_t   Compare(TObject * obj) {  assert(0==1) ; }   
   virtual Int_t   DistancetoPrimitive(Int_t px, Int_t py);
   virtual void    Draw(Option_t * option="") ;
   virtual void    ExecuteEvent(Int_t event, Int_t px, Int_t py) ;
   virtual Int_t   GetPHOSMod(void) ;
   virtual Int_t * GetPrimaries(Int_t & number) ;
   virtual Bool_t  IsEmc(void){return kTRUE ;} 
+  virtual Bool_t  IsSortable() const { return kTRUE ; }  
   virtual void    Paint(Option_t * option="");
   virtual void    Print(Option_t * opt = "void") {} 
 
-  virtual Int_t   Compare(TObject * obj) {  assert(0==1) ; }   
-  virtual Bool_t  IsSortable() const { return kTRUE ; }  
-
 protected:
   
-  Int_t      fPHOSMod ; // PHOS Module number in which the RecPoint is found
+  Int_t fPHOSMod ;      // PHOS Module number in which the RecPoint is found
 
   ClassDef(AliPHOSRecPoint,1) // RecPoint for PHOS (Base Class)
  
index b12b1c84790fe6d29f944b30f33c96c4211bee9b..08ff29f14f40d447acfa954eb232846b09aa77d0 100644 (file)
@@ -60,19 +60,48 @@ AliPHOSReconstructioner::AliPHOSReconstructioner(AliPHOSClusterizer * Clusterize
 } 
 
 //____________________________________________________________________________
- void AliPHOSReconstructioner::Make(TClonesArray * dl, RecPointsList * emccl, RecPointsList * ppsdl, 
+ void AliPHOSReconstructioner::Make(DigitsList * dl, RecPointsList * emccl, RecPointsList * ppsdl, 
                                     TrackSegmentsList * trsl, RecParticlesList * rpl)
 {
   // Launches the Reconstruction process in the sequence: Make the reconstructed poins (clusterize)
   //                                                      Make the track segments 
   //                                                      Make the reconstructed particles
 
+  Int_t index ; 
+  
   cout << "Start making reconstructed points (clusterizing)" << endl;
   fClusterizer->MakeClusters(dl, emccl, ppsdl);
 
-  cout << "Start making track segments" << endl;
-  fTrackSegmentMaker->MakeTrackSegments(dl, emccl, ppsdl, trsl) ;
+  // mark the position of the RecPoints in the array
+  AliPHOSEmcRecPoint * emcrp ; 
+  for (index = 0 ; index < emccl->GetEntries() ; index++) {
+    emcrp = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
+    emcrp->SetIndexInList(index) ; 
+  }
+
+  AliPHOSPpsdRecPoint * ppsdrp ; 
+  for (index = 0 ; index < ppsdl->GetEntries() ; index++) {
+    ppsdrp = (AliPHOSPpsdRecPoint * )ppsdl->At(index) ; 
+    ppsdrp->SetIndexInList(index) ; 
+  }
 
+  cout << "Start making track segments" << endl;
+  fTrackSegmentMaker->MakeTrackSegments(dl, emccl, ppsdl, trsl) ;   
+
+  // mark the position of the TrackSegments in the array
+  AliPHOSTrackSegment * trs ; 
+  for (index = 0 ; index < trsl->GetEntries() ; index++) {
+    trs = (AliPHOSTrackSegment * )trsl->At(index) ; 
+    trs->SetIndexInList(index) ; 
+  }
+  
   cout << "Start making reconstructed particles" << endl;
   fPID->MakeParticles(trsl, rpl) ; 
+  
+  // mark the position of the RecParticles in the array
+  AliPHOSRecParticle * rp ; 
+  for (index = 0 ; index < rpl->GetEntries() ; index++) {
+    rp = (AliPHOSRecParticle * )rpl->At(index) ; 
+    rp->SetIndexInList(index) ; 
+  }
 }
index 58045d235b034f6f5d2abf6308178fd1b6aacf36..bcd81935738a74e51f1dc420db5ea8e92ddcdf8e 100644 (file)
 
 #include "AliPHOSTrackSegment.h" 
 #include "AliPHOSv0.h"
+#include "AliPHOSIndexToObject.h"
 
 ClassImp(AliPHOSTrackSegment)
 
 //____________________________________________________________________________
-AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdRP1,
-                  AliPHOSPpsdRecPoint * ppsdRP2  ) 
+AliPHOSTrackSegment::AliPHOSTrackSegment( AliPHOSEmcRecPoint * emc , AliPHOSPpsdRecPoint * ppsdrp1,
+                  AliPHOSPpsdRecPoint * ppsdrp2  ) 
 {
   // ctor
 
   if( emc )   
-    fEmcRecPoint =  emc ;
+    fEmcRecPoint =  emc->GetIndexInList() ;
+  else 
+    fEmcRecPoint = -1 ;
 
-  if( ppsdRP1 )  
-    fPpsdUp = ppsdRP1 ;
+  if( ppsdrp1 )  
+    fPpsdUpRecPoint = ppsdrp1->GetIndexInList() ;
+ else 
+    fPpsdUpRecPoint = -1 ;
 
-  if( ppsdRP2  ) 
-    fPpsdLow = ppsdRP2 ;
+  if( ppsdrp2  ) 
+    fPpsdLowRecPoint = ppsdrp2->GetIndexInList() ;
+  else 
+    fPpsdLowRecPoint = -1 ;
 
+  fIndexInList = -1 ;
 }
 
 //____________________________________________________________________________
@@ -71,9 +79,10 @@ void AliPHOSTrackSegment::Copy(TObject & obj)
   // Copy of a track segment into another track segment
 
    TObject::Copy(obj) ;
-   ( (AliPHOSTrackSegment &)obj ).fEmcRecPointId = fEmcRecPointId ; 
-   ( (AliPHOSTrackSegment &)obj ).fPpsdLowId     = fPpsdLowId ; 
-   ( (AliPHOSTrackSegment &)obj ).fPpsdUpId      = fPpsdUpId ; 
+   ( (AliPHOSTrackSegment &)obj ).fEmcRecPoint     = fEmcRecPoint ; 
+   ( (AliPHOSTrackSegment &)obj ).fPpsdLowRecPoint = fPpsdLowRecPoint ; 
+   ( (AliPHOSTrackSegment &)obj ).fPpsdUpRecPoint  = fPpsdUpRecPoint ; 
+   ( (AliPHOSTrackSegment &)obj ).fIndexInList     = fIndexInList ; 
 }
 //____________________________________________________________________________
 Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
@@ -83,33 +92,41 @@ Int_t AliPHOSTrackSegment::DistancetoPrimitive(Int_t px, Int_t py)
   // The distance is computed in pixels units.
   
   Int_t div = 1 ;  
+  Int_t dist = 9999 ; 
+  
   TVector3 pos(0.,0.,0.) ;
   
-  fEmcRecPoint->GetLocalPosition( pos) ;
-  Float_t x =  pos.X() ;
-  Float_t y =  pos.Z() ;
-  if ( fPpsdLow ) {
-    fPpsdLow->GetLocalPosition( pos ) ;
-    x +=  pos.X() ;
-    y +=  pos.Z() ;
-    div++ ; 
-  }
-  if ( fPpsdUp ) {
-    fPpsdUp->GetLocalPosition( pos ) ;
-    x +=  pos.X() ;
-    y +=  pos.Z() ;
-    div++ ; 
-  }
-  x /= div ; 
-  y /= div ; 
-
-   const Int_t kMaxDiff = 10;
-   Int_t pxm  = gPad->XtoAbsPixel(x);
-   Int_t pym  = gPad->YtoAbsPixel(y);
-   Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+  AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
+  AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
+  
+  if ( emcrp != 0 ) {
+    emcrp->GetLocalPosition( pos) ;
+    Float_t x =  pos.X() ;
+    Float_t y =  pos.Z() ;
+    if ( ppsdlrp != 0 ) {
+      ppsdlrp->GetLocalPosition( pos ) ;
+      x +=  pos.X() ;
+      y +=  pos.Z() ;
+      div++ ; 
+    }
+    if ( ppsdurp != 0 ) {
+      ppsdurp->GetLocalPosition( pos ) ;
+      x +=  pos.X() ;
+      y +=  pos.Z() ;
+      div++ ; 
+    }
+    x /= div ; 
+    y /= div ; 
 
-   if (dist > kMaxDiff) return 9999;
-   return dist;
+    const Int_t kMaxDiff = 10;
+    Int_t pxm  = gPad->XtoAbsPixel(x);
+    Int_t pym  = gPad->YtoAbsPixel(y);
+    dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
+    
+    if (dist > kMaxDiff) return 9999;
+  }
+  return dist;
 }
 
 //___________________________________________________________________________
@@ -131,6 +148,8 @@ void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
  
   static TPaveText* textTS = 0 ;
   
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+
   if (!gPad->IsEditable()) 
     return;
   
@@ -141,7 +160,7 @@ void AliPHOSTrackSegment::ExecuteEvent(Int_t event, Int_t px, Int_t py)
     if (!textTS) {
       
       TVector3 pos(0.,0.,0.) ;
-      fEmcRecPoint->GetLocalPosition(pos) ;
+      emcrp->GetLocalPosition(pos) ;
       textTS = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+5,pos.Z()+15,"") ;
       Text_t  line1[40] ;
       sprintf(line1,"See RecParticle for ID") ;
@@ -167,22 +186,48 @@ Float_t AliPHOSTrackSegment::GetDistanceInPHOSPlane()
 {
   // Calculates the distance between the EMC RecPoint and PPSD RecPoint
   
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+  AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
+
   TVector3 vecEmc ;
-  fEmcRecPoint->GetLocalPosition(vecEmc) ;
+  emcrp->GetLocalPosition(vecEmc) ;
   
   TVector3 vecPpsd ;
-  if( fPpsdLow->GetMultiplicity() )  
-    fPpsdLow->GetLocalPosition(vecPpsd)  ; 
-  else { 
-    vecPpsd.SetX(10000.) ;
-  } 
-  vecEmc -= vecPpsd ;
-
+  if ( ppsdlrp !=0 ) {
+    if( ppsdlrp->GetMultiplicity() )  
+      ppsdlrp->GetLocalPosition(vecPpsd)  ; 
+    else { 
+      vecPpsd.SetX(10000.) ;
+    } 
+    vecEmc -= vecPpsd ;
+  }
   Float_t r = vecEmc.Mag();;
 
   return r ;
 }
 
+//____________________________________________________________________________
+AliPHOSEmcRecPoint * AliPHOSTrackSegment::GetEmcRecPoint() const 
+{
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ;
+  AliPHOSEmcRecPoint * rv = 0 ;
+  if (  fEmcRecPoint > -1 )
+    rv = (AliPHOSEmcRecPoint *)please->GimeRecPoint( fEmcRecPoint, TString("emc") );
+  
+  return rv ;
+
+}
+  
+//____________________________________________________________________________
+ Float_t AliPHOSTrackSegment::GetEnergy()
+{ 
+  // Returns energy in EMC
+  
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+  
+  return emcrp->GetTotalEnergy() ;
+}   
+
 //____________________________________________________________________________
 TVector3 AliPHOSTrackSegment::GetMomentumDirection() 
 { 
@@ -194,20 +239,25 @@ TVector3 AliPHOSTrackSegment::GetMomentumDirection()
   // However because of the poor position resolution of PPSD the direction is always taken as if we were 
   //  in case 1.
 
+
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+  // AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
+  // AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
+
   TVector3 dir(0,0,0) ; 
   TMatrix mdummy ;
 
   TVector3 posEmc ;
-  fEmcRecPoint->GetGlobalPosition(posEmc, mdummy) ;
+  emcrp->GetGlobalPosition(posEmc, mdummy) ;
 
   // Correction for the depth of the shower starting point (TDR p 127) 
 
-  Float_t energy = fEmcRecPoint->GetEnergy() ; 
+  Float_t energy = emcrp->GetEnergy() ; 
   Float_t para = 0.925 ; 
   Float_t parb = 6.52 ; 
 
   TVector3 localpos ; 
-  fEmcRecPoint->GetLocalPosition(localpos) ; 
+  emcrp->GetLocalPosition(localpos) ; 
 
   AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ; 
   Float_t radius = geom->GetIPtoOuterCoverDistance() + geom->GetOuterBoxSize(1) ; 
@@ -223,7 +273,7 @@ TVector3 AliPHOSTrackSegment::GetMomentumDirection()
   TVector3 emcglobalpos ;
   TMatrix  dummy ;
 
-  fEmcRecPoint->GetGlobalPosition(emcglobalpos, dummy) ;
+  emcrp->GetGlobalPosition(emcglobalpos, dummy) ;
 
   emcglobalpos.SetX( emcglobalpos.X() - depthx ) ;  
   emcglobalpos.SetZ( emcglobalpos.Z() - depthz ) ;   
@@ -234,14 +284,14 @@ TVector3 AliPHOSTrackSegment::GetMomentumDirection()
 //   TVector3 ppsdlglobalpos ;
 //   TVector3 ppsduglobalpos ;
 
-//   if( fPpsdLow ){ // certainly a photon that has concerted
+//   if( fPpsdLowRecPoint ){ // certainly a photon that has concerted
         
-//     fPpsdLow->GetGlobalPosition(ppsdlglobalpos, mdummy) ; 
+//     fPpsdLowRecPoint->GetGlobalPosition(ppsdlglobalpos, mdummy) ; 
 //     dir = emcglobalpos -  ppsdlglobalpos ; 
      
-//     if( fPpsdUp ){ // nop looks like a charged
+//     if( fPpsdUpRecPoint ){ // nop looks like a charged
        
-//        fPpsdUp->GetGlobalPosition(ppsduglobalpos, mdummy) ; 
+//        fPpsdUpRecPoint->GetGlobalPosition(ppsduglobalpos, mdummy) ; 
 //        dir = ( dir +  emcglobalpos -  ppsduglobalpos ) * 0.5 ; 
 //      }
 //   }
@@ -257,15 +307,50 @@ TVector3 AliPHOSTrackSegment::GetMomentumDirection()
   return dir ;  
 }
 
+//____________________________________________________________________________
+Int_t AliPHOSTrackSegment:: GetPHOSMod(void) 
+{
+  
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+  
+  return emcrp->GetPHOSMod();  
+}
+
+//____________________________________________________________________________
+AliPHOSPpsdRecPoint * AliPHOSTrackSegment::GetPpsdLowRecPoint() const 
+{
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ;
+  AliPHOSPpsdRecPoint * rv = 0 ;
+
+  if ( fPpsdLowRecPoint > -1 )
+    rv = (AliPHOSPpsdRecPoint *)please->GimeRecPoint( fPpsdLowRecPoint, TString("ppsd") ) ;
+  
+  return rv ; 
+}
+
+//____________________________________________________________________________
+AliPHOSPpsdRecPoint * AliPHOSTrackSegment::GetPpsdUpRecPoint() const 
+{
+  AliPHOSIndexToObject * please =  AliPHOSIndexToObject::GetInstance() ;
+  AliPHOSPpsdRecPoint * rv = 0 ;
+  if ( fPpsdUpRecPoint > -1 )
+    rv =  (AliPHOSPpsdRecPoint *)please->GimeRecPoint( fPpsdUpRecPoint, TString("ppsd") ) ;
+
+  return rv ;
+}
+
 //____________________________________________________________________________
 Int_t *  AliPHOSTrackSegment::GetPrimariesEmc(Int_t & number) 
 { 
   // Retrieves the primary particle(s) at the origin of the EMC RecPoint
-  
+    
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+
   Int_t * rv = 0 ; 
   number = 0 ;
-  if ( fEmcRecPoint )
-    rv =  fEmcRecPoint->GetPrimaries(number) ; 
+  if ( emcrp )
+    rv =  emcrp->GetPrimaries(number) ; 
 
   return rv ; 
 }
@@ -275,10 +360,12 @@ Int_t *  AliPHOSTrackSegment::GetPrimariesPpsdLow(Int_t & number)
 { 
   // Retrieves the primary particle(s) at the origin of the lower PPSD RecPoint
   
+  AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
+
   Int_t * rv = 0 ; 
   number = 0 ;
-  if ( fPpsdLow )
-    rv =  fPpsdLow->GetPrimaries(number) ; 
+  if ( ppsdlrp )
+    rv =  ppsdlrp->GetPrimaries(number) ; 
 
   return rv ; 
 }
@@ -288,10 +375,12 @@ Int_t *  AliPHOSTrackSegment::GetPrimariesPpsdUp(Int_t & number)
 { 
   // Retrieves the primary particle(s) at the origin of the upper PPSD  RecPoint
   
+  AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
+
   Int_t * rv = 0 ; 
   number = 0 ;
-  if ( fPpsdUp )
-    rv =  fPpsdUp->GetPrimaries(number) ; 
+  if ( ppsdurp )
+    rv =  ppsdurp->GetPrimaries(number) ; 
 
   return rv ; 
 }
@@ -300,26 +389,32 @@ Int_t *  AliPHOSTrackSegment::GetPrimariesPpsdUp(Int_t & number)
 void AliPHOSTrackSegment::GetPosition( TVector3 & pos ) 
 {  
   // Returns position of the EMC RecPoint
-
+  
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
   TMatrix dummy ;
-  fEmcRecPoint->GetGlobalPosition(pos, dummy) ;
+  emcrp->GetGlobalPosition(pos, dummy) ;
 }
 
 
 //______________________________________________________________________________
 void AliPHOSTrackSegment::Paint(Option_t *)
 {
-  // Paint this ALiPHOSTrackSegment as a TMarker  with its current attributes
+  // Paint this AliPHOSTrackSegment as a TMarker  with its current attributes
+
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+  AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
+  AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
 
   TVector3 posemc(999., 999., 999.) ;
   TVector3 posppsdl(999., 999., 999.) ;
   TVector3 posppsdu(999., 999., 999.) ;
   
-  fEmcRecPoint->GetLocalPosition(posemc) ;
-  if (fPpsdLow !=0 ) 
-    fPpsdLow->GetLocalPosition(posppsdl) ;
-  if (fPpsdUp !=0 ) 
-    fPpsdUp->GetLocalPosition(posppsdu) ;
+  emcrp->GetLocalPosition(posemc) ;
+  if (ppsdlrp !=0 ) 
+    ppsdlrp->GetLocalPosition(posppsdl) ;
+  if (ppsdurp !=0 ) 
+    ppsdurp->GetLocalPosition(posppsdu) ;
   
   Coord_t xemc   = posemc.X() ;
   Coord_t yemc   = posemc.Z() ;
@@ -378,28 +473,39 @@ void AliPHOSTrackSegment::Print()
 {
   // Print all information on this track Segment
   
-  cout << "--------AliPHOSTrackSegment-------- "<<endl ;
-  cout << "EMC Reconstructed Point: " << fEmcRecPoint << endl;
+  AliPHOSEmcRecPoint  * emcrp   = GetEmcRecPoint() ; 
+  AliPHOSPpsdRecPoint * ppsdlrp = GetPpsdLowRecPoint() ; 
+  AliPHOSPpsdRecPoint * ppsdurp = GetPpsdUpRecPoint() ; 
   
   TVector3 pos ;
   TMatrix dummy ;  
 
-  fEmcRecPoint->GetGlobalPosition( pos, dummy ) ;
-  cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << "      Energy " << fEmcRecPoint->GetTotalEnergy() << endl ;
-  cout << "PPSD Low Reconstructed Point: " << endl;
-  
-  if(fPpsdLow){
-    fPpsdLow->GetGlobalPosition( pos , dummy ) ;
-    cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << endl ;
-  }
+  cout << "--------AliPHOSTrackSegment-------- "<<endl ;
 
-  cout << "PPSD Up Reconstructed Point: " << endl;
+  if ( emcrp != 0 ) {
+    cout << "******** EMC Reconstructed Point: " << endl;
+    emcrp->Print() ; 
+    
+    emcrp->GetGlobalPosition( pos, dummy ) ;
+    
+    cout << " Global position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << "      Energy " << emcrp->GetTotalEnergy() << endl ;
+  }
   
-  if(fPpsdUp ){
-    fPpsdUp->GetGlobalPosition( pos, dummy ) ;
-    cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z()  << endl ;
+  if ( ppsdlrp != 0 ) {
+    cout << "******** PPSD Low Reconstructed Point: " << endl;
+    
+    ppsdlrp->Print() ; 
+    ppsdlrp->GetGlobalPosition( pos , dummy ) ;
+    cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z() << endl ;
   }
 
+   if( ppsdurp != 0 ) {
+     cout << "******** PPSD Up Reconstructed Point: " << endl;
+     
+     ppsdurp->Print() ; 
+     ppsdurp->GetGlobalPosition( pos, dummy ) ;
+     cout << "    position " << pos.X() << "   " << pos.Y() << "  " << pos.Z()  << endl ;
+   }
+   
 }
 
index 42acd2f2e4a3bf143840134454d0a38acb5dc8d0..7e2cba133c9b1b29cbcadcc58c982d72eeded766 100644 (file)
@@ -25,6 +25,8 @@
 #include "AliPHOSEmcRecPoint.h"
 #include "AliPHOSPpsdRecPoint.h"
 
+typedef TClonesArray TrackSegmentsList ; 
+
 class AliPHOSTrackSegment : public TObject  {
 
 public:
@@ -39,30 +41,30 @@ public:
   virtual Int_t  DistancetoPrimitive(Int_t px, Int_t py);
   virtual void   Draw(Option_t * option="") ;
   virtual void   ExecuteEvent(Int_t event, Int_t px, Int_t py);
-  Float_t GetEnergy(){ return fEmcRecPoint->GetTotalEnergy() ;}   // Returns energy in EMC
+  Float_t GetEnergy() ;   // Returns energy in EMC
   
   Float_t GetDistanceInPHOSPlane(void) ;   // Computes in PHOS plane the relative position between EMC and PPSD clusters 
-  virtual Int_t  GetPHOSMod(void) {return fEmcRecPoint->GetPHOSMod();  }
+  virtual Int_t  GetPHOSMod(void) 
   TVector3 GetMomentumDirection() ;        // Returns the momentum direction
-  void GetPosition( TVector3 & pos ) ;     // Returns positions of hit
+  void    GetPosition( TVector3 & pos ) ;  // Returns positions of hit
   Int_t * GetPrimariesEmc(Int_t & number) ;
   Int_t * GetPrimariesPpsdLow(Int_t & number) ;
   Int_t * GetPrimariesPpsdUp(Int_t & number) ;
-  AliPHOSEmcRecPoint * GetEmcRecPoint() const { return fEmcRecPoint ; } 
-  AliPHOSPpsdRecPoint * GetPpsdLow() const { return fPpsdLow ; } 
-  AliPHOSPpsdRecPoint * GetPpsdUp() const { return fPpsdUp ; } 
-  virtual  void  Paint(Option_t * option="");
-  void Print() ;
-  
+  AliPHOSEmcRecPoint *   GetEmcRecPoint() const ;  
+  Int_t   GetIndexInList() const { return fIndexInList ; } 
+  AliPHOSPpsdRecPoint *   GetPpsdLowRecPoint() const ;
+  AliPHOSPpsdRecPoint *   GetPpsdUpRecPoint() const ; 
+  virtual void  Paint(Option_t * option="");
+  void    Print() ;
+  void    SetIndexInList(Int_t val) { fIndexInList = val ; } 
   
 private:
   
-  AliPHOSEmcRecPoint  * fEmcRecPoint ; //! The EMC reconstructed point
-  AliPHOSPpsdRecPoint * fPpsdLow ;     //! The PPSD reconstructed point from the lower layer
-  AliPHOSPpsdRecPoint * fPpsdUp ;      //! The PPSD reconstructed point from the upper layer
-  Int_t fEmcRecPointId ; // The EMC reconstructed point Id in the list
-  Int_t fPpsdLowId ;     // The PPSD reconstructed point from the lower layer Id in the list
-  Int_t fPpsdUpId ;      // The PPSD reconstructed point from the upper layer Id in the list
+  Int_t fEmcRecPoint ;     // The EMC reconstructed point index in array stored in TreeR/PHOSEmcRP
+  Int_t fIndexInList ;     // the index of this TrackSegment in the list stored in TreeR (to be set by analysis)
+  Int_t fPpsdLowRecPoint ; // The PPSD reconstructed point from the lower layer index in array stored in TreeR/PHOSPpsdRP
+  Int_t fPpsdUpRecPoint ;  // The PPSD reconstructed point from the upper layer index in array stored in TreeR/PHOSPpsdRP
 
   ClassDef(AliPHOSTrackSegment,1)  // Track segment in PHOS
 
index ef10a124bf8b123026c28d26512e5e8474592a22..651daa6fe33a05eb3c176ee029f6709e6a3a3963 100644 (file)
 // --- AliRoot header files ---
 
 #include "TObjArray.h"
-#include "AliPHOSClusterizer.h"
-#include "AliPHOSEmcRecPoint.h"
-#include "AliPHOSPpsdRecPoint.h"
-
-typedef TClonesArray TrackSegmentsList ;
+#include "AliPHOSDigit.h"
+#include "AliPHOSRecPoint.h"
+#include "AliPHOSTrackSegment.h"
 
 class  AliPHOSTrackSegmentMaker : public TObject {
 
index dc15d4501742f62c5e14a8f9ff78104b93f20000..d44419959e84c20a8e9bcf457b64300d6c8a611b 100644 (file)
@@ -158,7 +158,7 @@ void  AliPHOSTrackSegmentMakerv1::FillOneModule(DigitsList * dl, RecPointsList *
   
   Int_t nEmcUnfolded = emcIn->GetEntries() ;
   for(index = emcStopedAt; index < nEmcUnfolded; index++){
-    emcRecPoint = (AliPHOSEmcRecPoint *) (*emcIn)[index] ;
+    emcRecPoint = (AliPHOSEmcRecPoint *) emcIn->At(index) ;
 
     if(emcRecPoint->GetPHOSMod() != phosmod )  
        break ;
@@ -184,7 +184,7 @@ void  AliPHOSTrackSegmentMakerv1::FillOneModule(DigitsList * dl, RecPointsList *
   emcStopedAt = index ;
 
   for(index = ppsdStopedAt; index < ppsdIn->GetEntries(); index++){
-    ppsdRecPoint = (AliPHOSPpsdRecPoint *) (*ppsdIn)[index] ;
+    ppsdRecPoint = (AliPHOSPpsdRecPoint *) ppsdIn->At(index) ;
     if(ppsdRecPoint->GetPHOSMod() != phosmod )   
       break ;
     if(ppsdRecPoint->GetUp() ) 
@@ -260,9 +260,9 @@ void  AliPHOSTrackSegmentMakerv1::MakeLinks(TObjArray * emcRecPoints, TObjArray
       
       if(toofar) 
        break ;  
-      if(r < fR0) 
+      if(r < fR0){
        new( (*linklowArray)[iLinkLow++]) AliPHOSLink(r, iEmcClu, iPpsdLow) ;
-      
+     }
       iPpsdLow++ ;
       
     }
@@ -275,9 +275,9 @@ void  AliPHOSTrackSegmentMakerv1::MakeLinks(TObjArray * emcRecPoints, TObjArray
       
       if(toofar)
        break ;  
-      if(r < fR0) 
+      if(r < fR0) 
        new( (*linkupArray)[iLinkUp++]) AliPHOSLink(r, iEmcClu, iPpsdUp) ;
-      
+      }
       iPpsdUp++ ;
       
     }
index 6ca5c7eec39e9dfd70f401bcea95c79bb63138af..25160638b0bd08cb3d528c3cdc60ef58898fc463 100644 (file)
@@ -72,9 +72,14 @@ AliPHOSv0::AliPHOSv0(const char *name, const char *title):
   fPinElectronicNoise = 0.010 ;
   fDigitThreshold      = 1. ;   // 1 GeV 
 
-  fHits   = new TClonesArray("AliPHOSHit",100) ;
-  gAlice->AddHitList(fHits) ; 
+  // We do not want to save in TreeH the raw hits
+  // fHits   = new TClonesArray("AliPHOSHit",100) ;
+  // gAlice->AddHitList(fHits) ; 
 
+  // But save the cumulated hits instead (need to create the branch myself)
+  // It is put in the Digit Tree because the TreeH is filled after each primary
+  // and the TreeD at the end of the event (branch is set in FinishEvent() ).
+  
   fTmpHits= new TClonesArray("AliPHOSHit",100) ;
 
   fNTmpHits = fNhits = 0 ;
@@ -109,7 +114,10 @@ AliPHOSv0::AliPHOSv0(AliPHOSReconstructioner * Reconstructioner, const char *nam
   //     is used for the digitization part.
 
   fPinElectronicNoise = 0.010 ;
-  fHits   = new TClonesArray("AliPHOSHit",100) ;
+
+  // We do not want to save in TreeH the raw hits
+  //fHits   = new TClonesArray("AliPHOSHit",100) ;
+
   fDigits = new TClonesArray("AliPHOSDigit",100) ;
   fTmpHits= new TClonesArray("AliPHOSHit",100) ;
 
@@ -169,14 +177,14 @@ void AliPHOSv0::AddHit(Int_t primary, Int_t Id, Float_t * hits)
   // In any case, fills the fTmpHit TClonesArray (with "accumulated hits")
 
   newHit = new AliPHOSHit(primary, Id, hits) ;
-  TClonesArray &lhits = *fHits;
+
+  // We do not want to save in TreeH the raw hits 
+  //  TClonesArray &lhits = *fHits;
 
   for ( hitCounter = 0 ; hitCounter < fNTmpHits && !deja ; hitCounter++ ) {
     curHit = (AliPHOSHit*) ltmphits[hitCounter] ;
-    //    curHit2 = (AliPHOSHit*) lhits[hitCounter] ;  // ca plante dans PurifyKine !?
   if( *curHit == *newHit ) {
     *curHit = *curHit + *newHit ;
-    //    *curHit2 = *curHit2 + *newHit ;
     deja = kTRUE ;
     }
   }
@@ -184,10 +192,12 @@ void AliPHOSv0::AddHit(Int_t primary, Int_t Id, Float_t * hits)
   if ( !deja ) {
     new(ltmphits[fNTmpHits]) AliPHOSHit(*newHit) ;
     fNTmpHits++ ;
-    new(lhits[fNhits]) AliPHOSHit(*newHit) ;    // will be saved on disk
-    fNhits++ ;
   }
 
+  // We do not want to save in TreeH the raw hits 
+  //   new(lhits[fNhits]) AliPHOSHit(*newHit) ;    
+  //   fNhits++ ;
+
   // Please note that the fTmpHits array must survive up to the
   // end of the events, so it does not appear e.g. in ResetHits() (
   // which is called at the end of each primary).  
@@ -1129,7 +1139,7 @@ Int_t AliPHOSv0::Digitize(Float_t Energy)
 {
   // Applies the energy calibration
   
-  Float_t fB = 100. ; // ; 100000000. ;
+  Float_t fB = 100000000. ;
   Float_t fA = 0. ;
   Int_t chan = Int_t(fA + Energy*fB ) ;
   return chan ;
@@ -1142,6 +1152,16 @@ void AliPHOSv0::FinishEvent()
   // Adds to the energy the electronic noise
   // Keeps digits with energy above fDigitThreshold
 
+  // Save the cumulated hits instead of raw hits (need to create the branch myself)
+  // It is put in the Digit Tree because the TreeH is filled after each primary
+  // and the TreeD at the end of the event.
+  if ( fTmpHits && gAlice->TreeD() ) {
+    char branchname[10] ;
+    sprintf(branchname, "%sCH", GetName()) ;
+    gAlice->TreeD()->Branch(branchname, &fTmpHits, fBufferSize) ; 
+  } else 
+    cout << "AliPHOSv0::AliPHOSv0: Failed to create branch PHOSCH in TreeD " << endl ;  
+  
   Int_t i ;
   Int_t relid[4];
   Int_t j ; 
@@ -1188,11 +1208,14 @@ void AliPHOSv0::FinishEvent()
     }
   }
   
+  fDigits->Compress() ;  
+
+  fNdigits =  fDigits->GetEntries() ; 
+  for (i = 0 ; i < fNdigits ; i++) { 
+    newdigit = (AliPHOSDigit *) fDigits->At(i) ; 
+    newdigit->SetIndexInList(i) ; 
+  }
 
-  fDigits->Compress() ; 
-  fNTmpHits = 0 ;
-  fTmpHits->Delete();
-  
 }
 
 //____________________________________________________________________________
@@ -1235,7 +1258,7 @@ void AliPHOSv0::MakeBranch(Option_t* opt)
 void AliPHOSv0::Reconstruction(AliPHOSReconstructioner * Reconstructioner)
 { 
   // 1. Reinitializes the existing RecPoint, TrackSegment, and RecParticles Lists and 
-  // 2. Creates a branch in TreeR for each list
+  // 2. Creates TreeR wit a branch for each list
   // 3. Steers the reconstruction processes
   // 4. Saves the 3 lists in TreeR
   // 5. Write the Tree to File
@@ -1245,16 +1268,24 @@ void AliPHOSv0::Reconstruction(AliPHOSReconstructioner * Reconstructioner)
   char branchname[10] ;
 
   // 1.
+
+  gAlice->MakeTree("R") ; 
+  Int_t splitlevel = 0 ; 
   
   if (fEmcClusters) { 
     fEmcClusters->Delete() ; 
     delete fEmcClusters ;
     fEmcClusters = 0 ; 
   }
-  fEmcClusters= new RecPointsList("AliPHOSEmcRecPoint", 100) ;
+
+  //  fEmcClusters= new RecPointsList("AliPHOSEmcRecPoint", 100) ; if TClonesArray
+  fEmcClusters= new RecPointsList(100) ; 
+
   if ( fEmcClusters && gAlice->TreeR() ) {
-    sprintf(branchname,"%sERP",GetName()) ;
-    gAlice->TreeR()->Branch(branchname, &fEmcClusters, fBufferSize);
+    sprintf(branchname,"%sEmcRP",GetName()) ;
+    
+    // gAlice->TreeR()->Branch(branchname, &fEmcClusters, fBufferSize); if TClonesArray
+    gAlice->TreeR()->Branch(branchname, "TObjArray", &fEmcClusters, fBufferSize, splitlevel) ; 
   }
 
   if (fPpsdClusters) { 
@@ -1262,48 +1293,79 @@ void AliPHOSv0::Reconstruction(AliPHOSReconstructioner * Reconstructioner)
     delete fPpsdClusters ; 
     fPpsdClusters = 0 ; 
   }
-  fPpsdClusters = new RecPointsList("AliPHOSPpsdRecPoint", 100) ;
+
+  //  fPpsdClusters = new RecPointsList("AliPHOSPpsdRecPoint", 100) ; if TClonesArray
+  fPpsdClusters = new RecPointsList(100) ;
+
   if ( fPpsdClusters && gAlice->TreeR() ) {
-     sprintf(branchname,"%sPRP",GetName()) ;
-     gAlice->TreeR()->Branch(branchname, &fPpsdClusters, fBufferSize);
- }
+    sprintf(branchname,"%sPpsdRP",GetName()) ;
+     
+     // gAlice->TreeR()->Branch(branchname, &fPpsdClusters, fBufferSize); if TClonesArray
+    gAlice->TreeR()->Branch(branchname, "TObjArray", &fPpsdClusters, fBufferSize, splitlevel);
+  }
 
   if (fTrackSegments) { 
    fTrackSegments->Delete() ; 
     delete fTrackSegments ; 
     fTrackSegments = 0 ; 
   }
+
   fTrackSegments = new TrackSegmentsList("AliPHOSTrackSegment", 100) ;
   if ( fTrackSegments && gAlice->TreeR() ) { 
     sprintf(branchname,"%sTS",GetName()) ;
     gAlice->TreeR()->Branch(branchname, &fTrackSegments, fBufferSize);
   }
 
- if (fRecParticles) {  
-   fRecParticles->Delete() ; 
 if (fRecParticles) {  
+    fRecParticles->Delete() ; 
     delete fRecParticles ; 
     fRecParticles = 0 ; 
   }
   fRecParticles = new RecParticlesList("AliPHOSRecParticle", 100) ;
   if ( fRecParticles && gAlice->TreeR() ) { 
-    sprintf(branchname,"%sRP",GetName()) ;
-    gAlice->TreeR()->Branch(branchname, &fRecParticles, fBufferSize);
+     sprintf(branchname,"%sRP",GetName()) ;
+     gAlice->TreeR()->Branch(branchname, &fRecParticles, fBufferSize);
   }
   
   // 3.
 
   fReconstructioner->Make(fDigits, fEmcClusters, fPpsdClusters, fTrackSegments, fRecParticles);
 
-  // 4.
+  // 4. Expand or Shrink the arrays to the proper size
+  
+  Int_t size ;
+  
+  size = fEmcClusters->GetEntries() ;
+  fEmcClusters->Expand(size) ;
+  size = fPpsdClusters->GetEntries() ;
+  fPpsdClusters->Expand(size) ;
+
+  size = fTrackSegments->GetEntries() ;
+  fTrackSegments->Expand(size) ;
+
+  size = fRecParticles->GetEntries() ;
+  fRecParticles->Expand(size) ;
 
   gAlice->TreeR()->Fill() ;
  
   // 5.
 
   gAlice->TreeR()->Write() ;
-  
+   
 }
 
+//____________________________________________________________________________
+void AliPHOSv0::ResetDigits()
+{
+  // May sound strange, but cumulative hits are store in digits Tree
+
+  if(  fTmpHits ) {
+    fTmpHits->Delete();
+    fNTmpHits = 0 ;
+  }
+}
+  
 //____________________________________________________________________________
 void AliPHOSv0::StepManager(void)
 {
index f41c243c07206406515a5699a4e42ee25f3d2d78..23f9accd6eb0411d7ed2688799bb3ec60248f9ef 100644 (file)
@@ -36,25 +36,22 @@ public:
   void           CreateGeometryforPHOS(void) ;                      // creates the PHOS geometry for GEANT
   void           CreateGeometryforPPSD(void) ;                      // creates the PPSD geometry for GEANT
   Int_t          Digitize(Float_t Energy);
-  RecPointsList* EmcClusters() {return fEmcClusters;}               // gets TClonesArray of cluster in the crystals 
   void           FinishEvent(void) ;                                // makes the digits from the hits 
   virtual AliPHOSGeometry * GetGeometry() { return fGeom ; }  
   virtual void   Init(void) ;                                       // does nothing
   Int_t IsVersion(void) const { return 0 ; }
   void           MakeBranch(Option_t* opt) ;
-  RecPointsList* PpsdClusters() { return fPpsdClusters ; }          // gets TClonesArray of clusters in the PPSD 
+  virtual RecPointsList* PpsdRecPoints() { return fPpsdClusters ; }          // gets Array of clusters in the PPSD 
   void           Reconstruction(AliPHOSReconstructioner * Reconstructioner) ;
-  RecParticlesList * RecParticles() { return fRecParticles ; }      // gets TClonesArray of reconstructed particles
   void           ResetClusters(){} ;
+  virtual void   ResetDigits() ; 
   void           SetReconstructioner(AliPHOSReconstructioner& Reconstructioner) {fReconstructioner = &Reconstructioner ;} 
   void           SetDigitThreshold(Float_t th) { fDigitThreshold = th ; } 
   virtual void   StepManager(void) ;                                // does the tracking through PHOS and a preliminary digitalization
-  TrackSegmentsList *    TrackSegments(){return fTrackSegments ;}
   
 protected:
 
   Float_t fDigitThreshold ;                       // Threshold for the digit registration 
-  RecPointsList * fEmcClusters ;                  // The RecPoints (clusters) list in EMC 
   AliPHOSGeometry * fGeom ;                       // Geometry definition
   Int_t fNTmpHits ;                               //!  Used internally for digitalization
   Float_t fPinElectronicNoise  ;                  // Electronic Noise in the PIN
@@ -62,8 +59,6 @@ protected:
   AliPHOSReconstructioner * fReconstructioner ;   // Reconstrutioner of the PHOS event: Clusterization and subtracking procedures
   TClonesArray * fTmpHits ;                       //!  Used internally for digitalization 
   AliPHOSTrackSegmentMaker * fTrackSegmentMaker ; // Reconstructioner of the PHOS track segment: 2 x PPSD + 1 x EMC
-  TrackSegmentsList * fTrackSegments ;            // The TrackSegment list in PHOS
-  RecParticlesList * fRecParticles ;              // The reconstructed particles list in PHOS
 
   ClassDef(AliPHOSv0,1)  // Implementation of PHOS manager class for layout EMC+PPSD
 
index 24a07a96bcf9a7419aba050df65ebc62ed72fffc..4a0fa94a03da0be6500c8859d0af3e6a0365cc2d 100644 (file)
@@ -17,7 +17,8 @@ SRCS          =    AliPHOS.cxx AliPHOSv0.cxx AliPHOSv1.cxx AliPHOSHit.cxx \
                   AliPHOSReconstructioner.cxx  AliPHOSTrackSegment.cxx \
                    AliPHOSTrackSegmentMaker.cxx AliPHOSTrackSegmentMakerv1.cxx \
                    AliPHOSRecParticle.cxx AliPHOSPID.cxx AliPHOSPIDv1.cxx \
-                   AliPHOSAnalyze.cxx  AliPHOSvFast.cxx AliPHOSFastRecParticle.cxx 
+                   AliPHOSAnalyze.cxx  AliPHOSvFast.cxx AliPHOSFastRecParticle.cxx \
+                   AliPHOSIndexToObject.cxx \
 
 # C++ Headers
 
index e87de223bae7e630660c4aeb76dd97ad37e76791..90706b3c3758c7950f714a756fe2065e816ef340 100644 (file)
@@ -5,7 +5,6 @@
 #pragma link off all functions;
 
 #pragma link C++ class AliPHOS ;
-#pragma link C++ class AliPHOSArray ;
 #pragma link C++ class AliPHOSClusterizer ;
 #pragma link C++ class AliPHOSClusterizerv1 ;
 #pragma link C++ class AliPHOSDigit ;
@@ -13,6 +12,7 @@
 #pragma link C++ class AliPHOSFastRecParticle ;
 #pragma link C++ class AliPHOSGeometry ;
 #pragma link C++ class AliPHOSHit ;
+#pragma link C++ class AliPHOSIndexToObject ;
 #pragma link C++ class AliPHOSLink ;
 #pragma link C++ class AliPHOSPpsdRecPoint ;
 #pragma link C++ class AliPHOSReconstructioner ;
diff --git a/PHOS/PetiteMacrodeNuit.C b/PHOS/PetiteMacrodeNuit.C
new file mode 100644 (file)
index 0000000..5112440
--- /dev/null
@@ -0,0 +1,40 @@
+{
+Int_t evt = 0 ; 
+RecAna * t = new RecAna("junk.root"); 
+t->GetEvent(evt);   
+TObjArray * lp = t->PHOSPpsdRP ; 
+ cout << "Tree macro = " << lp << endl ; 
+for (int i = 0 ; i < lp->GetEntries() ; i++ ) {
+  AliPHOSPpsdRecPoint * rpp = (AliPHOSPpsdRecPoint *)lp->At(i)   ; 
+  rpp.Print(); 
+}
+TObjArray * le = t->PHOSEmcRP ; 
+for (int i = 0 ; i < le->GetEntries() ; i++ ) {
+  AliPHOSEmcRecPoint * rp = (AliPHOSEmcRecPoint *)le->At(i)   ; 
+  rp->Print(); 
+}
+
+AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
+
+for (int i = 0 ; i < (t->PHOSTS_-1) ; i++) {
+  cout << "TrackSegment # " << i << endl 
+       << "====================" << endl ; 
+  int index = t->PHOSTS_fEmcRecPoint[i] ;
+  AliPHOSEmcRecPoint * emrp = (AliPHOSEmcRecPoint *) ( please->GimeRecPoint(index, TString("emc") ) ) ; 
+  emrp->Print() ; 
+  index = t->PHOSTS_fPpsdLowRecPoint[i] ;
+  AliPHOSPpsdRecPoint * ppsdl = (AliPHOSPpsdRecPoint *) ( please->GimeRecPoint(index, TString("ppsd") ) ) ; 
+  if (ppsdl)
+    ppsdl->Print() ; 
+  index = t->PHOSTS_fPpsdUpRecPoint[i] ;
+  AliPHOSPpsdRecPoint * ppsdu = (AliPHOSPpsdRecPoint *) ( please->GimeRecPoint(index, TString("ppsd") ) ) ; 
+  if (ppsdu)
+    ppsdu->Print() ; 
+}
+for (int i = 0 ; i < (t->PHOSRP_-1) ; i++) {
+  cout << "RecParticles # " << i << endl 
+       << "====================" << endl ; 
+  cout << "type = " << t->PHOSRP_fType[i] << " energy = " << t->PHOSRP_fE[i] << endl ;
+}  
+delete t ; 
+}
diff --git a/PHOS/RecAna.C b/PHOS/RecAna.C
new file mode 100644 (file)
index 0000000..f6e73b4
--- /dev/null
@@ -0,0 +1,32 @@
+#define RecAna_cxx
+#include "RecAna.h"
+
+void RecAna::Loop()
+{
+  //   In a Root session, you can do:
+  //      Root > .L RecAna.C
+  //      Root > RecAna t(filename)
+  //      Root > t.GetEvent(evt); // Fill t data members with event number evt
+  //      Root > t.Show();       // Show values of current event e
+  //      Root > t.Show(evt);     // Read and show values of entry evt
+  //      Root > t.Loop();       // Loop on all entries
+  //
+  
+  //     This is the loop skeleton
+  //       To read only selected branches, Insert statements like:
+  // METHOD1:
+  //    fTree->SetBranchStatus("*",0);  // disable all branches
+  //    fTree->SetBranchStatus("branchname",1);  // activate branchname
+  // METHOD2: replace line
+  //    fTree->GetEntry(i);  // read all branches
+  //by  b_branchname->GetEntry(i); //read only this branch
+  if (fTree == 0) return;
+  
+  Int_t nentries = Int_t(fTree->GetEntries());
+  
+   Int_t nbytes = 0, nb = 0;
+   for (Int_t i=0; i<nentries;i++) {
+      if (LoadTree(i) < 0) break;
+      nb = fTree->GetEntry(i);   nbytes += nb;
+   }
+}
diff --git a/PHOS/RecAna.h b/PHOS/RecAna.h
new file mode 100644 (file)
index 0000000..0456f9d
--- /dev/null
@@ -0,0 +1,269 @@
+//////////////////////////////////////////////////////////
+//  A Demo Macro that shows how to analyze the 
+//  reconstructed Tree
+//
+//  Y. Schutz (SUBATECH)
+//////////////////////////////////////////////////////////
+
+
+#ifndef RecAna_h
+#define RecAna_h
+
+#if !defined(__CINT__) || defined(__MAKECINT__)
+#include <TTree.h>
+#include <TFile.h>
+#endif
+
+const Int_t kMaxPHOSTS = 9;
+const Int_t kMaxPHOSRP = 9;
+
+class RecAna {
+  public:
+  AliPHOSv0 * fPHOS ; 
+  TTree          *fTree;    //pointer to the analyzed TTree or TChain
+  TTree          *fCurrent; //pointer to the current TTree
+  //Declaration of leaves types
+  TObjArray       *PHOSEmcRP;
+  TObjArray       *PHOSPpsdRP;
+  Int_t           PHOSTS_;
+  Int_t           PHOSTS_fEmcRecPoint[kMaxPHOSTS];
+  Int_t           PHOSTS_fPpsdLowRecPoint[kMaxPHOSTS];
+  Int_t           PHOSTS_fPpsdUpRecPoint[kMaxPHOSTS];
+  UInt_t          PHOSTS_fUniqueID[kMaxPHOSTS];
+  UInt_t          PHOSTS_fBits[kMaxPHOSTS];
+  Int_t           PHOSRP_;
+  Int_t           PHOSRP_fPHOSTrackSegment[kMaxPHOSRP];
+  Int_t           PHOSRP_fIndexInList[kMaxPHOSRP];
+  Int_t           PHOSRP_fPrimary[kMaxPHOSRP];
+  Int_t           PHOSRP_fType[kMaxPHOSRP];
+  Int_t           PHOSRP_fPdgCode[kMaxPHOSRP];
+  Int_t           PHOSRP_fStatusCode[kMaxPHOSRP];
+  Int_t           PHOSRP_fMother[2][kMaxPHOSRP];
+  Int_t           PHOSRP_fDaughter[2][kMaxPHOSRP];
+  Float_t         PHOSRP_fWeight[kMaxPHOSRP];
+  Double_t        PHOSRP_fCalcMass[kMaxPHOSRP];
+  Double_t        PHOSRP_fPx[kMaxPHOSRP];
+  Double_t        PHOSRP_fPy[kMaxPHOSRP];
+  Double_t        PHOSRP_fPz[kMaxPHOSRP];
+  Double_t        PHOSRP_fE[kMaxPHOSRP];
+  Double_t        PHOSRP_fVx[kMaxPHOSRP];
+  Double_t        PHOSRP_fVy[kMaxPHOSRP];
+  Double_t        PHOSRP_fVz[kMaxPHOSRP];
+  Double_t        PHOSRP_fVt[kMaxPHOSRP];
+  Double_t        PHOSRP_fPolarTheta[kMaxPHOSRP];
+  Double_t        PHOSRP_fPolarPhi[kMaxPHOSRP];
+  UInt_t          PHOSRP_fUniqueID[kMaxPHOSRP];
+  UInt_t          PHOSRP_fBits[kMaxPHOSRP];
+  Short_t         PHOSRP_fLineColor[kMaxPHOSRP];
+  Short_t         PHOSRP_fLineStyle[kMaxPHOSRP];
+  Short_t         PHOSRP_fLineWidth[kMaxPHOSRP];
+  
+  //List of branches
+  TBranch        *b_PHOSEmcRP;
+  TBranch        *b_PHOSPpsdRP;
+  TBranch        *b_PHOSTS_;
+  TBranch        *b_PHOSTS_fEmcRecPoint;
+  TBranch        *b_PHOSTS_fPpsdLowRecPoint;
+  TBranch        *b_PHOSTS_fPpsdUpRecPoint;
+  TBranch        *b_PHOSTS_fUniqueID;
+  TBranch        *b_PHOSTS_fBits;
+  TBranch        *b_PHOSRP_;
+  TBranch        *b_PHOSRP_fPHOSTrackSegment;
+  TBranch        *b_PHOSRP_fIndexInList;
+  TBranch        *b_PHOSRP_fPrimary;
+  TBranch        *b_PHOSRP_fType;
+  TBranch        *b_PHOSRP_fPdgCode;
+  TBranch        *b_PHOSRP_fStatusCode;
+  TBranch        *b_PHOSRP_fMother;
+  TBranch        *b_PHOSRP_fDaughter;
+  TBranch        *b_PHOSRP_fWeight;
+  TBranch        *b_PHOSRP_fCalcMass;
+  TBranch        *b_PHOSRP_fPx;
+  TBranch        *b_PHOSRP_fPy;
+  TBranch        *b_PHOSRP_fPz;
+  TBranch        *b_PHOSRP_fE;
+  TBranch        *b_PHOSRP_fVx;
+  TBranch        *b_PHOSRP_fVy;
+  TBranch        *b_PHOSRP_fVz;
+  TBranch        *b_PHOSRP_fVt;
+  TBranch        *b_PHOSRP_fPolarTheta;
+  TBranch        *b_PHOSRP_fPolarPhi;
+  TBranch        *b_PHOSRP_fUniqueID;
+  TBranch        *b_PHOSRP_fBits;
+  TBranch        *b_PHOSRP_fLineColor;
+  TBranch        *b_PHOSRP_fLineStyle;
+  TBranch        *b_PHOSRP_fLineWidth;
+  
+  RecAna() {};
+  RecAna(TString filename);
+  RecAna(TTree *tree) {};
+  ~RecAna() {;}
+  Int_t GetEntry(Int_t entry = 0);
+  Int_t GetEvent(Int_t evt);
+  Int_t LoadTree(Int_t entry = 0);
+  void  Init(TTree *tree);
+  void  Loop();
+  void  Notify();
+  void  Show(Int_t entry = -1);
+};
+
+#endif
+
+#ifdef RecAna_cxx
+RecAna::RecAna(TString filename)
+{
+  // connect the file used to generate this class and read the Tree.
+  
+  TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
+  if (!f) 
+    f = new TFile(filename);
+  
+  // setup the gAlice evironment
+  
+  gAlice = (AliRun*) f->Get("gAlice") ;   
+  
+  // get the PHOS detectector, the geometry instance and the index to object converter instance
+  
+  fPHOS  = (AliPHOSv0 *)gAlice->GetDetector("PHOS") ;     
+  AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() );
+  AliPHOSIndexToObject::GetInstance(fPHOS) ;
+}
+
+Int_t RecAna::GetEntry(Int_t entry)
+{
+  // Read contents of entry, always = 0.
+  
+  if (!fTree) 
+    return 0;
+  
+  return fTree->GetEntry(entry);
+}
+
+Int_t RecAna::GetEvent(Int_t evt)
+{
+  // get the selected event
+  
+  gAlice->GetEvent(evt);
+  
+  // connect to the Reconstruction tree
+  
+  fTree = gAlice->TreeR();     
+  
+  // set the branches 
+  
+  Init(fTree);
+  
+  // gets the data
+  
+  GetEntry(0); 
+  cout << "macro EmcRecpoints = " << fPHOS->EmcRecPoints() << endl ; 
+}
+
+Int_t RecAna::LoadTree(Int_t entry)
+{
+  // Set the environment to read one entry, always = 0.
+  
+  if (!fTree) 
+    return -5;
+  Int_t centry = fTree->LoadTree(entry);
+  if (centry < 0) 
+    return centry;
+  if (fTree->GetTree() != fCurrent) {
+    fCurrent = fTree->GetTree();
+    Notify();
+  }
+  return centry;
+}
+
+void RecAna::Init(TTree *tree)
+{
+  //   Set branch addresses
+  if (tree == 0) return;
+  fTree    = tree;
+  fCurrent = 0;
+  
+  fTree->SetBranchAddress("PHOSEmcRP",&PHOSEmcRP);
+  fTree->SetBranchAddress("PHOSPpsdRP",&PHOSPpsdRP);
+  fTree->SetBranchAddress("PHOSTS_",&PHOSTS_);
+  fTree->SetBranchAddress("PHOSTS.fEmcRecPoint",PHOSTS_fEmcRecPoint);
+  fTree->SetBranchAddress("PHOSTS.fPpsdLowRecPoint",PHOSTS_fPpsdLowRecPoint);
+  fTree->SetBranchAddress("PHOSTS.fPpsdUpRecPoint",PHOSTS_fPpsdUpRecPoint);
+  fTree->SetBranchAddress("PHOSTS.fUniqueID",PHOSTS_fUniqueID);
+  fTree->SetBranchAddress("PHOSTS.fBits",PHOSTS_fBits);
+  fTree->SetBranchAddress("PHOSRP_",&PHOSRP_);
+  fTree->SetBranchAddress("PHOSRP.fPHOSTrackSegment",PHOSRP_fPHOSTrackSegment);
+  fTree->SetBranchAddress("PHOSRP.fIndexInList",PHOSRP_fIndexInList);
+  fTree->SetBranchAddress("PHOSRP.fPrimary",PHOSRP_fPrimary);
+  fTree->SetBranchAddress("PHOSRP.fType",PHOSRP_fType);
+  fTree->SetBranchAddress("PHOSRP.fPdgCode",PHOSRP_fPdgCode);
+  fTree->SetBranchAddress("PHOSRP.fStatusCode",PHOSRP_fStatusCode);
+  fTree->SetBranchAddress("PHOSRP.fMother[2]",PHOSRP_fMother);
+  fTree->SetBranchAddress("PHOSRP.fDaughter[2]",PHOSRP_fDaughter);
+  fTree->SetBranchAddress("PHOSRP.fWeight",PHOSRP_fWeight);
+  fTree->SetBranchAddress("PHOSRP.fCalcMass",PHOSRP_fCalcMass);
+  fTree->SetBranchAddress("PHOSRP.fPx",PHOSRP_fPx);
+  fTree->SetBranchAddress("PHOSRP.fPy",PHOSRP_fPy);
+  fTree->SetBranchAddress("PHOSRP.fPz",PHOSRP_fPz);
+  fTree->SetBranchAddress("PHOSRP.fE",PHOSRP_fE);
+  fTree->SetBranchAddress("PHOSRP.fVx",PHOSRP_fVx);
+  fTree->SetBranchAddress("PHOSRP.fVy",PHOSRP_fVy);
+  fTree->SetBranchAddress("PHOSRP.fVz",PHOSRP_fVz);
+  fTree->SetBranchAddress("PHOSRP.fVt",PHOSRP_fVt);
+  fTree->SetBranchAddress("PHOSRP.fPolarTheta",PHOSRP_fPolarTheta);
+  fTree->SetBranchAddress("PHOSRP.fPolarPhi",PHOSRP_fPolarPhi);
+  fTree->SetBranchAddress("PHOSRP.fUniqueID",PHOSRP_fUniqueID);
+  fTree->SetBranchAddress("PHOSRP.fBits",PHOSRP_fBits);
+  fTree->SetBranchAddress("PHOSRP.fLineColor",PHOSRP_fLineColor);
+  fTree->SetBranchAddress("PHOSRP.fLineStyle",PHOSRP_fLineStyle);
+  fTree->SetBranchAddress("PHOSRP.fLineWidth",PHOSRP_fLineWidth);
+}
+
+void RecAna::Notify()
+{
+  //   called by LoadTree when loading a new file
+  //   get branch pointers
+  b_PHOSEmcRP = fTree->GetBranch("PHOSEmcRP");
+  b_PHOSPpsdRP = fTree->GetBranch("PHOSPpsdRP");
+  b_PHOSTS_ = fTree->GetBranch("PHOSTS_");
+  b_PHOSTS_fEmcRecPoint = fTree->GetBranch("PHOSTS.fEmcRecPoint");
+  b_PHOSTS_fPpsdLowRecPoint = fTree->GetBranch("PHOSTS.fPpsdLowRecPoint");
+  b_PHOSTS_fPpsdUpRecPoint = fTree->GetBranch("PHOSTS.fPpsdUpRecPoint");
+  b_PHOSTS_fUniqueID = fTree->GetBranch("PHOSTS.fUniqueID");
+  b_PHOSTS_fBits = fTree->GetBranch("PHOSTS.fBits");
+  b_PHOSRP_ = fTree->GetBranch("PHOSRP_");
+  b_PHOSRP_fPHOSTrackSegment = fTree->GetBranch("PHOSRP.fPHOSTrackSegment");
+  b_PHOSRP_fIndexInList = fTree->GetBranch("PHOSRP.fIndexInList");
+  b_PHOSRP_fPrimary = fTree->GetBranch("PHOSRP.fPrimary");
+  b_PHOSRP_fType = fTree->GetBranch("PHOSRP.fType");
+  b_PHOSRP_fPdgCode = fTree->GetBranch("PHOSRP.fPdgCode");
+  b_PHOSRP_fStatusCode = fTree->GetBranch("PHOSRP.fStatusCode");
+  b_PHOSRP_fMother = fTree->GetBranch("PHOSRP.fMother[2]");
+  b_PHOSRP_fDaughter = fTree->GetBranch("PHOSRP.fDaughter[2]");
+  b_PHOSRP_fWeight = fTree->GetBranch("PHOSRP.fWeight");
+  b_PHOSRP_fCalcMass = fTree->GetBranch("PHOSRP.fCalcMass");
+  b_PHOSRP_fPx = fTree->GetBranch("PHOSRP.fPx");
+  b_PHOSRP_fPy = fTree->GetBranch("PHOSRP.fPy");
+  b_PHOSRP_fPz = fTree->GetBranch("PHOSRP.fPz");
+  b_PHOSRP_fE = fTree->GetBranch("PHOSRP.fE");
+  b_PHOSRP_fVx = fTree->GetBranch("PHOSRP.fVx");
+  b_PHOSRP_fVy = fTree->GetBranch("PHOSRP.fVy");
+  b_PHOSRP_fVz = fTree->GetBranch("PHOSRP.fVz");
+  b_PHOSRP_fVt = fTree->GetBranch("PHOSRP.fVt");
+  b_PHOSRP_fPolarTheta = fTree->GetBranch("PHOSRP.fPolarTheta");
+  b_PHOSRP_fPolarPhi = fTree->GetBranch("PHOSRP.fPolarPhi");
+  b_PHOSRP_fUniqueID = fTree->GetBranch("PHOSRP.fUniqueID");
+  b_PHOSRP_fBits = fTree->GetBranch("PHOSRP.fBits");
+  b_PHOSRP_fLineColor = fTree->GetBranch("PHOSRP.fLineColor");
+  b_PHOSRP_fLineStyle = fTree->GetBranch("PHOSRP.fLineStyle");
+  b_PHOSRP_fLineWidth = fTree->GetBranch("PHOSRP.fLineWidth");
+}
+
+void RecAna::Show(Int_t entry)
+{
+  // Print contents of entry.
+  // If entry is not specified, print current entry
+  if (!fTree) return;
+  fTree->Show(entry);
+}
+#endif // #ifdef RecAna_cxx
+