]> 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 45c7442b7cdfb31f4097fbb138963929c0a93793..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()
+AliPHOS:: AliPHOS() : AliDetector()
 {
-  // ctor 
-  //We do not create objects, because these pointers will be overwritten durin reading from file.
-  fEmcRecPoints  = 0 ; 
-  fPpsdRecPoints = 0 ;
-  fTrackSegments = 0 ;
-  fRecParticles  = 0 ;
-
+  // Create folder and task hierarchy
+  fName="PHOS";
+  CreatePHOSFolders();
 }
+
 //____________________________________________________________________________
-AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name,title) 
+AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title) 
 {
-  // ctor
-  
-  fEmcRecPoints  = new AliPHOSRecPoint::RecPointsList(10) ; 
-  fPpsdRecPoints = new AliPHOSRecPoint::RecPointsList(10) ;
-  fTrackSegments = new AliPHOSTrackSegment::TrackSegmentsList("AliPHOSTrackSegment", 10) ;
-  fRecParticles  = new AliPHOSRecParticle::RecParticlesList("AliPHOSRecParticle", 10) ;
-  fDebugLevel    = 0;
-  
+  // Create folder and task hierarchy
+  CreatePHOSFolders();
 }
+
 //____________________________________________________________________________
-AliPHOS::~AliPHOS()
+void AliPHOS::CreatePHOSFolders()
 {
-  // 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 ;
+  // 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) 
 }
 
 //____________________________________________________________________________
@@ -221,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) ;
@@ -297,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) ;
@@ -335,29 +394,40 @@ void AliPHOS::CreateMaterials()
   gMC->Gstpar(idtmed[715], "STRA",2.) ;
 
 }
+//____________________________________________________________________________
+AliPHOSGeometry * AliPHOS::GetGeometry() const 
+{  
+  // gets the pointer to the AliPHOSGeometry unique instance from the folder
+  
+  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 ; 
+}
 
 //____________________________________________________________________________
 void AliPHOS::SetTreeAddress()
 { 
+
+
   // TBranch *branch;
-  AliDetector::SetTreeAddress();
-
- //  //Branch address for TreeR: RecParticles
-//   TTree *treeR = gAlice->TreeR();
-//   if ( treeR && fRecParticles ) {
-//     branch = treeR->GetBranch("PHOSRP");
-//     if (branch) branch->SetAddress(&fRecParticles) ;
-//   }
-//    //Branch address for TreeR: TrackSegments
-//   if ( treeR && fTrackSegments ) {
-//     branch = treeR->GetBranch("PHOSTS");
-//     if (branch) branch->SetAddress(&fTrackSegments) ;
-//   }
-//   //Branch address for TreeR: EmcRecPoint
-//  if ( treeR && fEmcRecPoints ) {
-//     branch = treeR->GetBranch("PHOSEmcRP");
-//     if (branch) branch->SetAddress(&fEmcRecPoints) ;
-  // }
+  //  AliDetector::SetTreeAddress();
+
+  TBranch *branch;
+  char branchname[20];
+  sprintf(branchname,"%s",GetName());
+  
+  // Branch address for hit tree
+  TTree *treeH = gAlice->TreeH();
+  if (treeH && fHits) {
+    branch = treeH->GetBranch(branchname);
+    if (branch) branch->SetAddress(&fHits);
+  }
 }