]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOS.cxx
A default branch name set
[u/mrichter/AliRoot.git] / PHOS / AliPHOS.cxx
index f6398b72652a424e5e1e849c43c879519b05fc4e..015abafa67a5873716844f76ae3f5d75dd06e89c 100644 (file)
@@ -12,7 +12,6 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
 
 //_________________________________________________________________________
@@ -25,6 +24,7 @@
 //*-- Author: Laurent Aphecetche & Yves Schutz (SUBATECH) 
 //////////////////////////////////////////////////////////////////////////////
 
+
 // --- ROOT system ---
 class TFile;
 #include "TROOT.h"
@@ -45,7 +45,25 @@ class TFile;
 
 ClassImp(AliPHOS)
 //____________________________________________________________________________
-AliPHOS:: AliPHOS(const char* name, const char* title=""): AliDetector(name, title) 
+AliPHOS:: AliPHOS() : AliDetector()
+{
+  // Create folder and task hierarchy
+  fName="PHOS";
+  fTreeQA = 0 ;
+  CreatePHOSWhiteBoard();
+
+}
+
+//____________________________________________________________________________
+AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title) 
+{
+  // Create folder and task hierarchy
+  fTreeQA = 0 ; 
+  CreatePHOSWhiteBoard(); 
+}
+
+//____________________________________________________________________________
+void AliPHOS::CreatePHOSWhiteBoard()
 {
   // create the ALICE TFolder
   // create the ALICE TTasks
@@ -53,62 +71,188 @@ AliPHOS:: AliPHOS(const char* name, const char* title=""): AliDetector(name, tit
   // 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() ;
-  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); 
-
+  //==================== BEG TO BE DONE BY AliRUN ===========================
+  if ( ! (gROOT->GetRootFolder()->FindObject("YSAlice")) ) {
+    TFolder *alice = gROOT->GetRootFolder()->AddFolder("YSAlice","Alice Folder") ;  
+    gROOT->GetListOfBrowsables()->Add(alice, "YSAlice") ;
+    
+    TFolder * aliceF  = alice->AddFolder("WhiteBoard", "Alice memory Folder") ; 
+    //  make it the owner of the objects that it contains
+    aliceF->SetOwner() ;
+    // geometry folder 
+    aliceF->AddFolder("Geometry", "Geometry objects") ; 
+    // alarms folder
+    TFolder * alarmsF = aliceF->AddFolder("QAAlarms", "Alarms raised by QA check") ; 
+    // Hits folder
+    TFolder * hitsF = aliceF->AddFolder("Hits", "Hits") ; 
+    // SDigits folder
+    TFolder * sdigitsF = aliceF->AddFolder("SDigits", "Summable Digits") ; 
+    // Digits folder
+    TFolder * digitsF = aliceF->AddFolder("Digits", "Digits") ; 
+    // RecPoints folder
+    TFolder * rpointsF = aliceF->AddFolder("RecPoints", "RecPoints") ; 
+    // TrackSegments folder
+    TFolder * tsF = aliceF->AddFolder("TrackSegments", "TrackSegments") ; 
+    // RecParticles folder
+    TFolder * rparticlesF = aliceF->AddFolder("RecParticles", "RecParticles") ; 
+    //  make it the owner of the objects that it contains
+    alarmsF->SetOwner() ;
+    hitsF->SetOwner() ;
+    sdigitsF->SetOwner() ;
+    digitsF->SetOwner() ;
+    rpointsF->SetOwner() ;
+    tsF->SetOwner() ;
+    rparticlesF->SetOwner() ;
+    
+    // Tasks folder
+    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 * aliceSD = new TTask("SDigitizer", "Alice SDigitizer") ;
+    aliceT->Add(aliceSD); 
+    
+    TTask * aliceDi = new TTask("Digitizer", "Alice Digitizer") ;
+    aliceT->Add(aliceDi); 
+    
+    TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
+    aliceT->Add(aliceRe); 
+    
+  //==================== END TO BE DONE BY AliRUN ===========================
+  }
+  // =================== Creating PHOS related folders
   char * tempo = new char[80] ; 
 
-  // creates the PHOSQA and adds it to alice main QA task
+  // creates the PHOSQA (QAChecker knows how to add itself in the tasks list)
   sprintf(tempo, "%sCheckers container",GetName() ) ; 
-  fQATask = new AliPHOSQAChecker(GetName(), tempo); 
-  aliceQA->Add(fQATask) ; 
+  fQATask = new AliPHOSQAChecker(GetName(), tempo);  
+  
+  // creates the PHOS SDigitizer and adds it to alice main SDigitizer task 
+  sprintf(tempo, "%sSDigitizers container",GetName() ) ; 
+  TTask * sdT = new TTask(GetName(), tempo);   
+  TTask * task = (TTask*)(gROOT->GetRootFolder()->FindObjectAny("SDigitizer")) ; 
+  task->Add(sdT) ; 
 
-  // creates the PHOS(S)Digitizer and adds it to alice main (S)Digitizer task 
+  // creates the PHOS Digitizer and adds it to alice main Digitizer task 
   sprintf(tempo, "%sDigitizers container",GetName() ) ; 
-  fSDTask = new AliPHOSQAChecker(GetName(), tempo);   
-  aliceDi->Add(fSDTask) ; 
+  TTask * dT = new TTask(GetName(), tempo);   
+  task = (TTask*)(gROOT->GetRootFolder()->FindObjectAny("Digitizer")) ; 
+  task->Add(dT) ; 
+
   // creates the PHOS reconstructioner and adds it to alice main Reconstructioner task 
-  sprintf(tempo, "%sReconstructioner container",GetName() ) ; 
-  fReTask = new AliPHOSQAChecker(GetName(), tempo); 
-  aliceRe->Add(fReTask) ; 
+  sprintf(tempo, "%s Reconstructioner container",GetName() ) ; 
+  TTask * reT = new TTask(GetName(), tempo); 
+  task = (TTask*)(gROOT->GetRootFolder()->FindObjectAny("Reconstructioner")) ; 
+  task->Add(reT) ; 
+
+  // creates the PHOS clusterizer, tracksegment maker and PID and adds it to the PHOS Reconstructioner task
 
   delete tempo ;  
 
+  // creates the PHOS geometry  folder
+  TFolder * folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("Geometry")) ; 
+  folder->AddFolder("PHOS", "Geometry for PHOS") ; 
   // creates the PHOSQA alarm folder
-  alarmsF->AddFolder("PHOS", "QA alarms from PHOS") ; 
+  folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("QAAlarms")) ; 
+  folder->AddFolder("PHOS", "QA alarms from PHOS") ; 
+  // creates the PHOS Hits folder
+  folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("Hits")) ;
+  folder->AddFolder("PHOS", "Hits for PHOS") ; 
+  // creates the PHOS Summable Digits folder
+  folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("SDigits")) ;
+  folder->AddFolder("PHOS", "Summable Digits for PHOS") ; 
+  // creates the PHOS Digits folder
+  folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("Digits")) ;
+  folder->AddFolder("PHOS", "Digits for PHOS") ; 
+  // creates the PHOS RecPoints folder
+  folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("RecPoints")) ;
+  TFolder * prpF = folder->AddFolder("PHOS", "RecPoints for PHOS") ;
+  // creates the PHOS EMC RecPoints folder
+  prpF->AddFolder("emc", "EMC RecPoints for PHOS") ;
+  // creates the PHOS CPV RecPoints folder
+  prpF->AddFolder("cpv", "CPV RecPoints for PHOS") ;
+  
+  // creates the PHOS TrackSegments folder
+  folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("TrackSegments")) ;
+  folder->AddFolder("PHOS", "Track Segments for PHOS") ; 
+  // creates the PHOS RecParticles folder
+  folder = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("RecParticles")) ;
+  folder->AddFolder("PHOS", "RecParticles for 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 the PHOS related items in folders
+  // Geometry 
+  TFolder * foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("Geometry")) ; 
+  TFolder * folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+  // QA Alarms
+  foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("QAAlarms")) ;
+  folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+  // Hits
+  foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("Hits")) ;
+  folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+  // SDigits
+  foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("SDigits")) ;
+  folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+  // Digits
+  foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("Digits")) ;
+  folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+  // RecPoints
+  foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("RecPoints")) ;
+  folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+   // TrackSegments
+  foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("TrackSegments")) ;
+  folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+   // RecParticles
+  foldera = (TFolder*)(gROOT->GetRootFolder()->FindObjectAny("RecParticles")) ;
+  folderp = (TFolder*)foldera->FindObject("PHOS") ;
+  folderp->Clear() ; 
+  foldera->Remove(folderp) ; 
+
+  //QA tasks
+  TTask * taska = (TTask*)gROOT->FindObjectAny("QA") ; 
+  TTask * taskp = (TTask*)taska->GetListOfTasks()->FindObject("PHOS") ; 
+  //  taskp->GetListOfTasks()->Delete() ; 
+  taska->GetListOfTasks()->Remove(taskp) ; 
+
+  //SDigitizer tasks
+  taska = (TTask*)gROOT->FindObjectAny("SDigitizer") ; 
+  taskp = (TTask*)taska->GetListOfTasks()->FindObject("PHOS") ; 
+  taskp->GetListOfTasks()->Delete() ; 
+  taska->GetListOfTasks()->Remove(taskp) ; 
+
+  //Digitizer tasks
+  taska = (TTask*)gROOT->FindObjectAny("Digitizer") ; 
+  taskp = (TTask*)taska->GetListOfTasks()->FindObject("PHOS") ; 
+  taskp->GetListOfTasks()->Delete() ; 
+  taska->GetListOfTasks()->Remove(taskp) ; 
+
+  //Reconstructioner tasks
+  taska = (TTask*)gROOT->FindObjectAny("Reconstructioner") ; 
+  taskp = (TTask*)taska->GetListOfTasks()->FindObject("PHOS") ; 
+  taskp->GetListOfTasks()->Delete() ; 
+  taska->GetListOfTasks()->Remove(taskp) ; 
   
   // remove and delete aliceQA (should be done by AliRun) 
 }
@@ -373,6 +517,19 @@ 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 = 0 ; 
+  
+  TString path("YSAlice/WhiteBoard/Geometry/PHOS/") ; 
+  path += GetTitle() ; 
+  rv = (AliPHOSGeometry*)gROOT->FindObjectAny(path) ; 
+  return rv ; 
+}
+
 //____________________________________________________________________________
 void AliPHOS::SetTreeAddress()
 { 
@@ -393,4 +550,24 @@ void AliPHOS::SetTreeAddress()
   }
 }
 
+//____________________________________________________________________________
+void AliPHOS::WriteQA()
+{
+
+  // Make TreeQA in the output file. 
+
+  if(fTreeQA == 0)
+    fTreeQA = new TTree("TreeQA", "QA Alarms") ;    
+  // Create Alarms branches
+  Int_t bufferSize = 32000 ;    
+  Int_t splitlevel = 0 ; 
+  TFolder * alarmsF = (TFolder*)gROOT->FindObjectAny("YSAlice/WhiteBoard/QAAlarms/PHOS") ; 
+  TString branchName(alarmsF->GetName());  
+  TBranch * alarmsBranch = fTreeQA->Branch(branchName,"TFolder", &alarmsF, bufferSize, splitlevel);
+  TString branchTitle = branchName + " QA alarms" ; 
+  alarmsBranch->SetTitle(branchTitle);
+  alarmsBranch->Fill() ; 
+
+  // fTreeQA->Fill() ; 
+}