]> 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 3f377132c550a86be59ff8c07fd1c1d815c20cd1..015abafa67a5873716844f76ae3f5d75dd06e89c 100644 (file)
@@ -1,4 +1,3 @@
-
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
@@ -13,7 +12,6 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
 
 //_________________________________________________________________________
 //*-- 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.
-  fDigits        = 0 ;
-  fEmcRecPoints  = 0 ; 
-  fPpsdRecPoints = 0 ;
-  fCpvRecPoints  = 0 ;
-  fTrackSegments = 0 ;
-  fRecParticles  = 0 ;
+  // Create folder and task hierarchy
+  fName="PHOS";
+  fTreeQA = 0 ;
+  CreatePHOSWhiteBoard();
 
 }
+
 //____________________________________________________________________________
-AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name,title) 
+AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title) 
 {
-  // ctor
-
-  fDigits        = 0 ; 
-  fEmcRecPoints  = 0 ; 
-  fPpsdRecPoints = 0 ;
-  fCpvRecPoints  = 0 ;
-  fTrackSegments = 0 ;
-  fRecParticles  = 0 ;
-  
+  // Create folder and task hierarchy
+  fTreeQA = 0 ; 
+  CreatePHOSWhiteBoard(); 
 }
+
 //____________________________________________________________________________
-AliPHOS::~AliPHOS()
+void AliPHOS::CreatePHOSWhiteBoard()
 {
-  // dtor
-  if(fEmcRecPoints)
-    fEmcRecPoints->Delete() ;
-  delete fEmcRecPoints ;
-  if(fPpsdRecPoints)
-    fPpsdRecPoints->Delete() ;
-  delete fPpsdRecPoints ;
-  if(fCpvRecPoints)
-    fCpvRecPoints->Delete() ;
-  delete fCpvRecPoints ;
-  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
+  //==================== 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 (QAChecker knows how to add itself in the tasks list)
+  sprintf(tempo, "%sCheckers container",GetName() ) ; 
+  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 Digitizer and adds it to alice main Digitizer task 
+  sprintf(tempo, "%sDigitizers container",GetName() ) ; 
+  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, "%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
+  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 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) 
 }
 
 //____________________________________________________________________________
@@ -349,82 +517,57 @@ 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()
 { 
-  // TBranch *branch;
-  AliDetector::SetTreeAddress();
 
-  TBranch * branch ;
 
-  if(fDigits)
-    fDigits->Clear();
-  else
-    fDigits = new TClonesArray("AliPHOSDigit",1) ;
-
-  if (gAlice->TreeD()  && fDigits ) {
-    branch = gAlice->TreeD()->GetBranch("PHOS");
-    if (branch) branch->SetAddress(&fDigits) ;
-  } 
+  // TBranch *branch;
+  //  AliDetector::SetTreeAddress();
 
-  TTree *treeR = gAlice->TreeR();
-   
-  //Branch address for TreeR: EmcRecPoint
+  TBranch *branch;
+  char branchname[20];
+  sprintf(branchname,"%s",GetName());
   
-  if(fEmcRecPoints)
-    fEmcRecPoints->Delete();
-  else
-    fEmcRecPoints  = new AliPHOSRecPoint::RecPointsList(1) ; 
-
-  if ( treeR && fEmcRecPoints ) {
-    branch = treeR->GetBranch("PHOSEmcRP");
-    if (branch) branch->SetAddress(&fEmcRecPoints) ;
-  }
-
-  //Branch address for TreeR: PPSDRecPoint
-  if(fPpsdRecPoints)
-    fPpsdRecPoints->Delete();
-  else
-    fPpsdRecPoints = new AliPHOSRecPoint::RecPointsList(1) ;
-
-  if ( treeR && fPpsdRecPoints ) {
-    branch = treeR->GetBranch("PHOSPpsdRP");
-    if (branch) branch->SetAddress(&fPpsdRecPoints) ;
-  }
-
-  //Branch address for TreeR: CPVRecPoint
-  if(fCpvRecPoints)
-    fCpvRecPoints->Delete();
-  else
-    fCpvRecPoints = new AliPHOSRecPoint::RecPointsList(1) ;
-
-  if ( treeR && fCpvRecPoints ) {
-    branch = treeR->GetBranch("PHOSCpvRP");
-    if (branch) branch->SetAddress(&fCpvRecPoints) ;
+  // Branch address for hit tree
+  TTree *treeH = gAlice->TreeH();
+  if (treeH && fHits) {
+    branch = treeH->GetBranch(branchname);
+    if (branch) branch->SetAddress(&fHits);
   }
+}
 
-  //Branch address for TreeR: TrackSegments
-  if(fTrackSegments)
-    fTrackSegments->Clear() ;
-  else
-    fTrackSegments = new AliPHOSTrackSegment::TrackSegmentsList("AliPHOSTrackSegment", 1) ;
-  
-  if ( treeR && fTrackSegments ) {
-    branch = treeR->GetBranch("PHOSTS");
-    if (branch) branch->SetAddress(&fTrackSegments) ;
-  }
-  
-  //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) ;
-  }
+//____________________________________________________________________________
+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() ; 
 }
 
-