]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - START/AliSTART.cxx
Adding comments
[u/mrichter/AliRoot.git] / START / AliSTART.cxx
index f14f3438247ae05ca037bd964cc389518099da4a..efbcba4d9f49537d7467096b827a9e5d3bfb43f0 100755 (executable)
 #include <TRandom.h>
 #include <TTUBE.h>
 #include <TVirtualMC.h>
+#include <AliESD.h>
 
+#include "AliLog.h"
+#include "AliMC.h"
 #include "AliLoader.h"
 #include "AliRun.h"
+#include "TClonesArray.h"
 #include "AliSTART.h"
+#include "AliSTARTLoader.h"
 #include "AliSTARTdigit.h"
 #include "AliSTARThit.h"
-#include "AliSTARThitPhoton.h"
-#include "AliSTARTvertex.h"
-#include "AliSTARTLoader.h"
+#include "AliSTARTDigitizer.h"
+#include "AliSTARTRawData.h"
+#include "AliSTARTRecPoint.h"
+#include "AliLog.h"
 
 ClassImp(AliSTART)
 
@@ -70,7 +76,7 @@ AliSTART::AliSTART()
   fIshunt   = 1;
   fHits     = 0;
   fDigits   = 0;
-  fPhotons  = 0;
+  fRecPoints = 0;
 }
  
 //_____________________________________________________________________________
@@ -85,27 +91,33 @@ AliSTART::AliSTART(const char *name, const char *title)
   //
   // Initialise Hit array
   fHits       = new TClonesArray("AliSTARThit",  405);
-  gAlice->AddHitList(fHits);
-
-  fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
-  gAlice->AddHitList (fPhotons);
-  
+  gAlice->GetMCApp()->AddHitList(fHits);
+  fDigits    = new AliSTARTdigit();
+  fRecPoints = new AliSTARTRecPoint();
   fIshunt     =  1;
   fIdSens   =  0;
-  fNPhotons =  0;
   SetMarkerColor(kRed);
 }
 
 //_____________________________________________________________________________
 AliSTART::~AliSTART() {
+  
   if (fHits) {
     fHits->Delete();
     delete fHits;
   }
-  if (fPhotons) {
-    fPhotons->Delete();
-    delete fPhotons;
+  /*
+  if (fDigits) {
+    fDigits->Delete();
+    delete fDigits;
+    cout<<" delete fDigits; "<<endl;
+  }
+  if (fRecPoints) {
+   fRecPoints ->Delete();
+    delete fRecPoints;
+    cout<<" delete fRecPoints; "<<endl;
   }
+  */ 
 }
  
 //_____________________________________________________________________________
@@ -118,24 +130,32 @@ void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
   new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
 }
 
-//_____________________________________________________________________________
-void AliSTART::AddHitPhoton(Int_t track, Int_t *vol, Float_t *hits)
-{
-  //  Add a START hit of photons
-  
-  TClonesArray &lhits = *fPhotons;
-  new(lhits[fNPhotons++]) AliSTARThitPhoton(fIshunt,track,vol,hits);
-}
 
 //_____________________________________________________________________________
 
-void AliSTART::AddDigit(Int_t  */*tracks*/,Int_t * /*digits*/)
+void AliSTART::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime, 
+                       Int_t timediff, TArrayI *sumMult,
+                       TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp)
 {
   
-  //  Add a START digit to the list. Dummy function.
+  //  Add a START digit to the list.
+ //
   
+  if (!fDigits) {
+    fDigits = new AliSTARTdigit();
+  }
+  fDigits-> SetTimeBestRight(besttimeright);
+  fDigits->SetTimeBestLeft(besttimeleft);
+  fDigits-> SetMeanTime(meantime);
+  fDigits-> SetDiffTime(timediff);
+  fDigits-> SetSumMult(*sumMult);
+  fDigits->SetTime(*time);
+  fDigits->SetTimeAmp(*timeAmp);
+  fDigits->SetADC(*adc);
+  fDigits->SetADCAmp(*adcAmp);
 }
 
+
 //_____________________________________________________________________________
 void AliSTART::BuildGeometry()
 {
@@ -180,7 +200,7 @@ void AliSTART::Init()
   // Initialis the START after it has been built
   Int_t i;
   //
-  if(fDebug) {
+  if(AliLog::GetGlobalDebugLevel()>0) {
     printf("\n%s: ",ClassName());
     for(i=0;i<35;i++) printf("*");
     printf(" START_INIT ");
@@ -197,31 +217,43 @@ void AliSTART::Init()
 void AliSTART::MakeBranch(Option_t* option)
 {
   //
-  // Specific START branches
+// Create Tree branches for the START.
+
+ // Options:
+  //
+  //    H          Make a branch of TClonesArray of AliSTARTHit's
+  //    D          Make a branch of TClonesArray of AliSTARTDigit's
+  //
+  //    R         Make a branch of  AliSTARTRecPoints
   //
-  // Create Tree branches for the START.
   char branchname[20];
   sprintf(branchname,"%s",GetName());
 
-
-  //  const char *cD = strstr(option,"D");
   const char *cH = strstr(option,"H");
-  
-  if (cH && fLoader->TreeH())
+  const char *cD = strstr(option,"D");
+  const char *cR = strstr(option,"R");
+
+    if (cH && fLoader->TreeH())
   {
-     if (fPhotons == 0x0) fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
-     sprintf (branchname, "%shitPhoton", GetName());
-     MakeBranchInTree (fLoader->TreeH(), branchname, &fPhotons, 50000, 0);
      if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
+     AliDetector::MakeBranch(option);
   } 
+    
+    
+  if (cD && fLoader->TreeD())
+    {
+      if (fDigits == 0x0) fDigits  = new AliSTARTdigit();
+      //     MakeBranchInTree(fLoader->TreeD(), branchname,
+      //                      &fDigits, 405, 0);
+      fLoader->TreeD()->Branch(branchname,"AliSTARTdigit",&fDigits,405,1);
+    } 
+  if (cR && fLoader->TreeR())
+    {
+      if (fRecPoints == 0x0) fRecPoints  = new AliSTARTRecPoint();
+      MakeBranchInTree(fLoader->TreeR(), branchname,
+                      &fRecPoints, 405, 0);
+    } 
   
-  AliDetector::MakeBranch(option);
-  /*
-  if (cD) {
-    digits = new AliSTARTdigit();
-    MakeBranchInTree(fLoader->TreeD(), branchname, "AliSTARTdigit", digits, buffersize, 1, 0);
-  } 
-  */
 }    
 
 //_____________________________________________________________________________
@@ -229,39 +261,97 @@ void AliSTART::ResetHits()
 {
   AliDetector::ResetHits();
   
-  fNPhotons = 0;
-  if (fPhotons)  fPhotons->Clear();
+}
+//____________________________________________________________________
+void AliSTART::ResetDigits()
+{
+  //
+  // Reset number of digits and the digits array for this detector
+  //
+  if (fDigits) fDigits->Clear();
 }
 
 //_____________________________________________________________________________
 void AliSTART::SetTreeAddress()
 {
-  TBranch  *branch;
+
   TTree    *treeH;
-  
   treeH = TreeH();
   
   if (treeH)
     {
-      if (fPhotons == 0x0) fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
-      branch = treeH->GetBranch("STARThitPhoton");
-      if (branch)  branch->SetAddress(&fPhotons);
       if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
     }
     
   AliDetector::SetTreeAddress();
-  
+  TTree *treeD = fLoader->TreeD();
+  if (treeD) {
+    if (fDigits == 0x0)  fDigits  = new AliSTARTdigit();
+    TBranch* branch = treeD->GetBranch ("START");
+    if (branch) branch->SetAddress(&fDigits);
+  }
+
+  TTree *treeR = fLoader->TreeR();
+  if (treeR) {
+    if (fRecPoints == 0x0) fRecPoints  = new  AliSTARTRecPoint()  ;
+    TBranch* branch = treeR->GetBranch ("START");
+    if (branch) branch->SetAddress(&fRecPoints);
+  }
 }
 
 
-//______________________________________________________________________
-AliLoader* AliSTART::MakeLoader(const char* topfoldername)
-{ 
-  //builds STARTgetter (AliLoader type)
-  //if detector wants to use castomized getter, it must overload this method
+//_____________________________________________________________________________
+void AliSTART::MakeBranchInTreeD(TTree *treeD, const char *file)
+{
+    //
+    // Create TreeD branches for the FMD
+    //
+    const Int_t kBufferSize = 4000;
+    char branchname[20];
+    sprintf(branchname,"%s",GetName());
+    if(treeD)
+     {
+       MakeBranchInTree(treeD,  branchname,&fDigits, kBufferSize, file);
+     }
+}
 
-  Info("MakeLoader","Creating AliSTARTLoader. Top folder is %s.",topfoldername);
-  fLoader = new AliSTARTLoader(GetName(),topfoldername);
-  return fLoader;
+//_____________________________________________________________________________
+AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
+{
+  return new AliSTARTDigitizer(manager);
+}
+//____________________________________________________________________________
+void AliSTART::Digits2Raw()
+{
+//
+// Starting from the START digits, writes the Raw Data objects
+//
+//  AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader;
+  fLoader ->LoadDigits("read");
+  TTree* treeD = fLoader->TreeD();
+  if (!treeD) {
+    AliError("no digits tree");
+    return;
+  }
+  if (fDigits == 0x0)  fDigits  = new AliSTARTdigit();
+  
+  TBranch *branch = treeD->GetBranch("START");
+  if (branch) {
+    branch->SetAddress(&fDigits);
+  }else{
+    AliError("Branch START DIGIT not found");
+    exit(111);
+  } 
+  AliSTARTRawData rawWriter;
+  rawWriter.SetVerbose(0);
+  
+  AliDebug(2,Form(" Formatting raw data for START "));
+  branch->GetEntry(0);
+  //  rawWriter.RawDataSTART(treeD->GetBranch("START"));
+  rawWriter.RawDataSTART(fDigits);
+  
+  
+  fLoader->UnloadDigits();
+  
 }