]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOS.cxx
Code for simulation, sdigitization and digitization moved from macros to compiled...
[u/mrichter/AliRoot.git] / PHOS / AliPHOS.cxx
index 24e6cee706b9c98094225f7ab65d97e58b653808..bf731239b82d03cbe56c8ab15caf9bba8dfba211 100644 (file)
 
 // --- ROOT system ---
 class TFile;
-#include "TROOT.h"
-#include "TTree.h"
-#include "TFolder.h" 
+#include <TFolder.h> 
+#include <TTree.h>
+#include <TVirtualMC.h> 
 
 // --- Standard library ---
 
-#include <strstream.h>
 // --- AliRoot header files ---
-
-#include "AliPHOS.h"
-#include "AliMC.h"
-#include "AliRun.h"
 #include "AliMagF.h"
+#include "AliPHOS.h"
 #include "AliPHOSGeometry.h"
-#include "AliPHOSQAChecker.h" 
+#include "AliPHOSLoader.h"
+#include "AliPHOSQAChecker.h"
+#include "AliRun.h"
+#include "AliPHOSDigitizer.h"
+#include "AliPHOSSDigitizer.h"
 
 ClassImp(AliPHOS)
 //____________________________________________________________________________
 AliPHOS:: AliPHOS() : AliDetector()
 {
-  // Create folder and task hierarchy
+  // Default ctor
   fName="PHOS";
   fQATask = 0;
   fTreeQA = 0;
@@ -56,15 +56,15 @@ AliPHOS:: AliPHOS() : AliDetector()
 //____________________________________________________________________________
 AliPHOS::AliPHOS(const char* name, const char* title): AliDetector(name, title) 
 {
+  //   ctor : title is used to identify the layout
+  
   fQATask = 0;
   fTreeQA = 0;
 }
 
-
 //____________________________________________________________________________
 AliPHOS::~AliPHOS() 
 {  
-  // remove the alice folder and alice QA task that PHOS creates instead of AliRun
   
 }
 
@@ -184,7 +184,7 @@ void AliPHOS::CreateMaterials()
   AliMaterial(15, "Ar$", 39.948, 18.0, dAr, 14.0, 0., 0, 0) ;   
  
  // ArCo2
-  Char_t namate[21];
+  Char_t namate[21]="";
   Float_t aGM[2] ; 
   Float_t zGM[2] ; 
   Float_t wGM[2] ; 
@@ -358,6 +358,7 @@ void AliPHOS::CreateMaterials()
   gMC->Gstpar(idtmed[715], "STRA",2.) ;
 
 }
+
 //____________________________________________________________________________
 AliPHOSGeometry * AliPHOS::GetGeometry() const 
 {  
@@ -370,20 +371,21 @@ AliPHOSGeometry * AliPHOS::GetGeometry() const
 //____________________________________________________________________________
 void AliPHOS::SetTreeAddress()
 { 
-
-
-  // TBranch *branch;
-  //  AliDetector::SetTreeAddress();
-
+  // Links Hits in the Tree to Hits array
   TBranch *branch;
   char branchname[20];
   sprintf(branchname,"%s",GetName());
   
   // Branch address for hit tree
-  TTree *treeH = gAlice->TreeH();
-  if (treeH && fHits) {
+  TTree *treeH = TreeH();
+  if (treeH) {
     branch = treeH->GetBranch(branchname);
-    if (branch) branch->SetAddress(&fHits);
+    if (branch) 
+     { 
+       if (fHits == 0x0) fHits= new TClonesArray("AliPHOSHit",1000);
+       //Info("SetTreeAddress","<%s> Setting Hits Address",GetName());
+       branch->SetAddress(&fHits);
+     }
   }
 }
 
@@ -398,8 +400,18 @@ void AliPHOS::WriteQA()
   // Create Alarms branches
   Int_t bufferSize = 32000 ;    
   Int_t splitlevel = 0 ; 
-  TFolder * alarmsF = (TFolder*)gROOT->FindObjectAny("Folders/Run/Conditions/QA/PHOS") ; 
-  TString branchName(alarmsF->GetName());  
+
+  TFolder* topfold = GetLoader()->GetTopFolder(); //get top aliroot folder; skowron
+  TString phosqafn(AliConfig::Instance()->GetQAFolderName()+"/"); //get name of QAaut folder relative to top event; skowron
+  phosqafn+=GetName(); //hard wired string!!! add the detector name to the pathname; skowron 
+  TFolder * alarmsF = (TFolder*)topfold->FindObjectAny(phosqafn); //get the folder
+  if (alarmsF == 0x0)
+   {
+     Error("WriteQA","Can not find folder with qa alarms");
+     return;
+   }
+  TString branchName(alarmsF->GetName());
   TBranch * alarmsBranch = fTreeQA->Branch(branchName,"TFolder", &alarmsF, bufferSize, splitlevel);
   TString branchTitle = branchName + " QA alarms" ; 
   alarmsBranch->SetTitle(branchTitle);
@@ -408,3 +420,28 @@ void AliPHOS::WriteQA()
   //fTreeQA->Fill() ; 
 }
 
+//____________________________________________________________________________
+AliLoader* AliPHOS::MakeLoader(const char* topfoldername)
+{
+//different behaviour than standard (singleton getter)
+// --> to be discussed and made eventually coherent
+ fLoader = new AliPHOSLoader(GetName(),topfoldername);
+ return fLoader;
+}
+
+
+//____________________________________________________________________________
+void AliPHOS::Hits2SDigits()  
+{ 
+// create summable digits
+
+  AliPHOSSDigitizer* phosDigitizer = 
+    new AliPHOSSDigitizer(fLoader->GetRunLoader()->GetFileName().Data());
+  phosDigitizer->ExecuteTask("all");
+}
+
+//____________________________________________________________________________
+AliDigitizer* AliPHOS::CreateDigitizer(AliRunDigitizer* manager)
+{
+  return new AliPHOSDigitizer(manager);
+}