]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOS.cxx
parameters have been redistributed; Hits2SDigits etc ... introduce
[u/mrichter/AliRoot.git] / PHOS / AliPHOS.cxx
index 33e9918f942b035520e22a90864a53a880731398..af959462ba55d2477ed1717858b53ef2119948c2 100644 (file)
@@ -1,3 +1,4 @@
+
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
 //////////////////////////////////////////////////////////////////////////////
 
 // --- ROOT system ---
+class TFile;
+#include "TTree.h"
 
 // --- Standard library ---
 
+#include <strstream.h>
 // --- AliRoot header files ---
 
 #include "AliPHOS.h"
 #include "AliMC.h"
 #include "AliRun.h"
+#include "AliMagF.h"
 
 ClassImp(AliPHOS)
 
+//____________________________________________________________________________
+AliPHOS::AliPHOS():AliDetector()
+{
+  // ctor 
+  //We do not create objects, because these pointers will be overwritten durin reading from file.
+  fDigits        = 0 ;
+  fEmcRecPoints  = 0 ; 
+  fPpsdRecPoints = 0 ;
+  fTrackSegments = 0 ;
+  fRecParticles  = 0 ;
+
+}
+//____________________________________________________________________________
+AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name,title) 
+{
+  // ctor
+
+  fDigits        = 0 ; 
+  fEmcRecPoints  = 0 ; 
+  fPpsdRecPoints = 0 ;
+  fTrackSegments = 0 ;
+  fRecParticles  = 0 ;
+  
+}
 //____________________________________________________________________________
 AliPHOS::~AliPHOS()
 {
   // dtor
+  if(fEmcRecPoints)
+    fEmcRecPoints->Delete() ;
+  delete fEmcRecPoints ;
+  if(fPpsdRecPoints)
+    fPpsdRecPoints->Delete() ;
+  delete fPpsdRecPoints ;
+  if(fTrackSegments)
+    fTrackSegments->Delete() ;
+  delete fTrackSegments ;
+  if(fRecParticles)
+    fRecParticles->Delete() ;
+  delete fRecParticles ;
   delete fHits ;
   delete fDigits ;
 }
@@ -185,6 +226,8 @@ void AliPHOS::CreateMaterials()
 
   AliMixture(16, "ArCO2$", aGM, zGM, dGM,  2, wGM) ;
 
+  // --- Stainless steel (let it be pure iron) ---
+  AliMaterial(17, "Steel$", 55.845, 26, 7.87, 1.76, 0., 0, 0) ;
  
   // --- Air ---
   AliMaterial(99, "Air$", 14.61, 7.3, 0.001205, 30420., 67500., 0, 0) ;
@@ -261,6 +304,10 @@ void AliPHOS::CreateMaterials()
   AliMedium(16, "ArCo2      $", 16, 1,
             isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.01, 0, 0) ;
  
+  // Stainless steel                                                                -> idtmed[716]
+  AliMedium(17, "Steel     $", 17, 0,
+            isxfld, sxmgmx, 10.0, 0.1, 0.1, 0.1, 0.0001, 0, 0) ;
+
   // Air                                                                            -> idtmed[798] 
   AliMedium(99, "Air          $", 99, 0,
             isxfld, sxmgmx, 10.0, 1.0, 0.1, 0.1, 10.0, 0, 0) ;
@@ -299,78 +346,82 @@ void AliPHOS::CreateMaterials()
   gMC->Gstpar(idtmed[715], "STRA",2.) ;
 
 }
-
 //____________________________________________________________________________
-AliPHOSRecPoint::RecPointsList * AliPHOS::EmcRecPoints(Int_t evt) 
-{
-  // returns the pointer to the EMCA RecPoints list
-  // if the list is empty, get it from TreeR on the disk file
+void AliPHOS::SetTreeAddress()
+{ 
 
-  AliPHOSRecPoint::RecPointsList * rv = 0 ; 
-  
-  if ( fEmcRecPoints ) 
-    rv = fEmcRecPoints ; 
-
-  else {
-    fEmcRecPoints = new TClonesArray("AliPHOSEmcRecPoint", 100) ; 
-    gAlice->GetEvent(evt) ; 
-    TTree * fReconstruct = gAlice->TreeR() ; 
-    fReconstruct->SetBranchAddress( "PHOSEmcRP", &fEmcRecPoints) ;
-    fReconstruct->GetEvent(0) ;
-    fEmcRecPoints->Expand( fEmcRecPoints->GetEntries() ) ; 
-    rv =  fEmcRecPoints ;
-  }
-    
-  return rv ; 
-  
-}
+  // TBranch *branch;
+  AliDetector::SetTreeAddress();
 
-//____________________________________________________________________________
-AliPHOSRecParticle::RecParticlesList * AliPHOS::RecParticles(Int_t evt) 
-{
-  // returns the pointer to the RecParticles list
-  // if the list is empty, get it from TreeR on the disk file
+  TBranch * branch ;
+
+  if(fSDigits)
+    fSDigits->Clear();
+  else
+    fSDigits = new TClonesArray("AliPHOSDigit",1) ;
+
+  if (gAlice->TreeS()  && fSDigits ) {
+    branch = gAlice->TreeS()->GetBranch("PHOS");
+    if (branch) branch->SetAddress(&fSDigits) ;
+  } 
+
+  if(fDigits)
+    fDigits->Clear();
+  else
+    fDigits = new TClonesArray("AliPHOSDigit",1) ;
 
-  AliPHOSRecParticle::RecParticlesList * rv = 0 ; 
+  if (gAlice->TreeD()  && fDigits ) {
+    branch = gAlice->TreeD()->GetBranch("PHOS");
+    if (branch) branch->SetAddress(&fDigits) ;
+  } 
+
+  TTree *treeR = gAlice->TreeR();
+   
+  //Branch address for TreeR: EmcRecPoint
   
-  if ( fRecParticles ) 
-    rv = fRecParticles ; 
-
-  else {
-    fRecParticles = new TClonesArray("AliPHOSRecParticle", 100) ; 
-    gAlice->GetEvent(evt) ; 
-    TTree * fReconstruct = gAlice->TreeR() ; 
-    fReconstruct->SetBranchAddress( "PHOSRP", &fRecParticles) ;
-    fReconstruct->GetEvent(0) ;
-    fRecParticles->Expand( fRecParticles->GetEntries() ) ; 
-    rv =  fRecParticles ;
+  if(fEmcRecPoints)
+    fEmcRecPoints->Delete();
+  else
+    fEmcRecPoints  = new AliPHOSRecPoint::RecPointsList(1) ; 
+
+  if ( treeR && fEmcRecPoints ) {
+    branch = treeR->GetBranch("PHOSEmcRP");
+    if (branch) branch->SetAddress(&fEmcRecPoints) ;
   }
-  return rv ; 
-  
-}
 
-//____________________________________________________________________________
-AliPHOSRecParticle::RecParticlesList * AliPHOS::TrackSegments(Int_t evt) 
-{
-  // returns the pointer to the TrackSegments list
-  // if the list is empty, get it from TreeR on the disk file
+  //Branch address for TreeR: PPSDRecPoint
+  if(fPpsdRecPoints)
+    fPpsdRecPoints->Delete();
+  else
+    fPpsdRecPoints = new AliPHOSRecPoint::RecPointsList(1) ;
 
-  AliPHOSTrackSegment::TrackSegmentsList * rv = 0 ; 
+  if ( treeR && fPpsdRecPoints ) {
+    branch = treeR->GetBranch("PHOSPpsdRP");
+    if (branch) branch->SetAddress(&fPpsdRecPoints) ;
+  }
+
+  //Branch address for TreeR: TrackSegments
+  if(fTrackSegments)
+    fTrackSegments->Clear() ;
+  else
+    fTrackSegments = new AliPHOSTrackSegment::TrackSegmentsList("AliPHOSTrackSegment", 1) ;
   
-  if ( fTrackSegments ) 
-    rv = fTrackSegments ; 
-
-  else {
-    fTrackSegments = new TClonesArray("AliPHOSTrackSegment", 100) ; 
-    gAlice->GetEvent(evt) ; 
-    TTree * fReconstruct = gAlice->TreeR() ; 
-    fReconstruct->SetBranchAddress( "PHOSTS", &fTrackSegments) ;
-    fReconstruct->GetEvent(0) ;
-    fTrackSegments->Expand( fTrackSegments->GetEntries() ) ; 
-    rv =  fTrackSegments ;
+  if ( treeR && fTrackSegments ) {
+    branch = treeR->GetBranch("PHOSTS");
+    if (branch) branch->SetAddress(&fTrackSegments) ;
   }
-  return rv ; 
   
+  //Branch address for TreeR: RecParticles
+  if(fRecParticles)
+    fRecParticles->Clear() ;
+  else
+    fRecParticles  = new AliPHOSRecParticle::RecParticlesList("AliPHOSRecParticle", 1) ;
+
+  if ( treeR && fRecParticles ) {
+    branch = treeR->GetBranch("PHOSRP");
+    if (branch) branch->SetAddress(&fRecParticles) ;
+  }
+
 }
+
+