]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOS.cxx
First attempt to use systemtically TFolders: the geometry object posts itself to...
[u/mrichter/AliRoot.git] / PHOS / AliPHOS.cxx
index 33e9918f942b035520e22a90864a53a880731398..6e09cddf14f8abf0f997a2d102b30c4b54d542c8 100644 (file)
 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) 
 //////////////////////////////////////////////////////////////////////////////
 
+
 // --- ROOT system ---
+class TFile;
+#include "TROOT.h"
+#include "TTree.h"
+#include "TFolder.h" 
 
 // --- Standard library ---
 
+#include <strstream.h>
 // --- AliRoot header files ---
 
 #include "AliPHOS.h"
 #include "AliMC.h"
 #include "AliRun.h"
+#include "AliMagF.h"
+#include "AliPHOSGeometry.h"
+#include "AliPHOSQAChecker.h" 
 
 ClassImp(AliPHOS)
+//____________________________________________________________________________
+AliPHOS:: AliPHOS() : AliDetector()
+{
+  // Create folder and task hierarchy
+  fName="PHOS";
+  CreatePHOSFolders();
+}
 
 //____________________________________________________________________________
-AliPHOS::~AliPHOS()
+AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title) 
 {
-  // dtor
-  delete fHits ;
-  delete fDigits ;
+  // Create folder and task hierarchy
+  CreatePHOSFolders();
+}
+
+//____________________________________________________________________________
+void AliPHOS::CreatePHOSFolders()
+{
+  // create the ALICE TFolder
+  // create the ALICE TTasks
+  //  add the Alice QA TTAsks 
+  // create the ALICE main TFolder
+  //  add the Alice QA Alarms
+  // this should be done of course by AliRun
+
+  TFolder * alice = new TFolder(); 
+  alice->SetNameTitle("YSAlice", "Alice Folder") ; 
+  gROOT->GetListOfBrowsables()->Add(alice) ;
+
+  TFolder * aliceF  = alice->AddFolder("folders", "Alice memory Folder") ; 
+  //  make it the owner of the objects that it contains
+  aliceF->SetOwner() ;
+  // geometry folder 
+  TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ; 
+  // alarms folder
+  TFolder * alarmsF = aliceF->AddFolder("QAAlarms", "Alarms raised by QA check") ; 
+  //  make it the owner of the objects that it contains
+  alarmsF->SetOwner() ;
+  TFolder * aliceT  = alice->AddFolder("tasks", "Alice tasks Folder") ; 
+  //  make it the owner of the objects that it contains
+  aliceT->SetOwner() ;
+
+  TTask * aliceQA = new TTask("QA", "Alice QA tasks") ;
+  aliceT->Add(aliceQA); 
+  TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
+  aliceT->Add(aliceDi); 
+
+  TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
+  aliceT->Add(aliceRe); 
+
+  char * tempo = new char[80] ; 
+
+  // creates the PHOSQA (QAChecker knows how to add itself in the tasks list)
+  sprintf(tempo, "%sCheckers container",GetName() ) ; 
+  fQATask = new AliPHOSQAChecker(GetName(), tempo);  
+
+  // creates the PHOS(S)Digitizer and adds it to alice main (S)Digitizer task 
+  sprintf(tempo, "%sDigitizers container",GetName() ) ; 
+  fSDTask = new TTask(GetName(), tempo);   
+  aliceDi->Add(fSDTask) ; 
+
+  // creates the PHOS reconstructioner and adds it to alice main Reconstructioner task 
+  sprintf(tempo, "%sReconstructioner container",GetName() ) ; 
+  fReTask = new TTask(GetName(), tempo); 
+  aliceRe->Add(fReTask) ; 
+
+  delete tempo ;  
+
+  // creates the PHOS geometry  folder
+  geomF->AddFolder("PHOS", "Geometry for PHOS") ; 
+  // creates the PHOSQA alarm folder
+  alarmsF->AddFolder("PHOS", "QA alarms from PHOS") ; 
+}
+//____________________________________________________________________________
+AliPHOS::~AliPHOS() 
+{  
+  // remove the alice folder and alice QA task that PHOS creates instead of AliRun
+  
+  // remove and delete the PHOS QA tasks
+  TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ; 
+  TTask * aliceQA = (TTask*)alice->FindObject("tasks/QA") ; 
+  fQATask->GetListOfTasks()->Delete() ;
+  aliceQA->GetListOfTasks()->Remove(fQATask) ; 
+  delete fQATask ;  
+  
+  // remove and delete aliceQA (should be done by AliRun) 
 }
 
 //____________________________________________________________________________
@@ -185,6 +274,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 +352,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 +394,40 @@ 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
-
-  AliPHOSRecPoint::RecPointsList * rv = 0 ; 
+AliPHOSGeometry * AliPHOS::GetGeometry() const 
+{  
+  // gets the pointer to the AliPHOSGeometry unique instance from the folder
   
-  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 ; 
+  AliPHOSGeometry * rv ; 
   
+  TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("YSAlice") ;
+  TString path("folders/Geometry/PHOS/") ; 
+  path += GetTitle() ; 
+  rv = (AliPHOSGeometry*)alice->FindObject(path) ; 
+  if ( !rv )
+    rv = fGeom ; 
+  return rv ; 
 }
 
 //____________________________________________________________________________
-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
+void AliPHOS::SetTreeAddress()
+{ 
 
-  AliPHOSRecParticle::RecParticlesList * rv = 0 ; 
-  
-  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 ;
-  }
-  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
+  // TBranch *branch;
+  //  AliDetector::SetTreeAddress();
 
-  AliPHOSTrackSegment::TrackSegmentsList * rv = 0 ; 
+  TBranch *branch;
+  char branchname[20];
+  sprintf(branchname,"%s",GetName());
   
-  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 ;
+  // Branch address for hit tree
+  TTree *treeH = gAlice->TreeH();
+  if (treeH && fHits) {
+    branch = treeH->GetBranch(branchname);
+    if (branch) branch->SetAddress(&fHits);
   }
-  return rv ; 
-  
 }
+
+