]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONData.cxx
get tables from the aliroot directory if they are not in the current one
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
index eda640e5dbe8f89d06522ce2ef79af0b599a5247..c466dcd4fd616df2eb1df2e1be60921ae146cf1f 100644 (file)
 ClassImp(AliMUONData)
  
 //_____________________________________________________________________________
-AliMUONData::AliMUONData():TNamed()
+  AliMUONData::AliMUONData():
+    TNamed(),
+    fLoader(0x0),
+    fHits(0x0),
+    fDigits(0x0),
+    fSDigits(0x0),
+    fRawClusters(0x0),
+    fGlobalTrigger(0x0),
+    fLocalTrigger(0x0),
+    fRecTracks(0x0),
+    fRecTriggerTracks(0x0),
+    fNhits(0),
+    fNdigits(0x0),
+    fNSdigits(0x0),
+    fNrawclusters(0x0),
+    fNglobaltrigger(0),
+    fNlocaltrigger(0),
+    fNrectracks(0),
+    fNrectriggertracks(0),
+    fSplitLevel(0)
 {
   // Default constructor
-  fLoader        = 0x0;
-  fHits          = 0x0;    // One event in treeH per primary track
-  fDigits        = 0x0;  // One event in treeH per detection plane
-  fNdigits       = 0x0;
-  fRawClusters   = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
-  fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
-  fLocalTrigger  = 0x0;  //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
-  fRecTracks     = 0x0;       
-  fRecTriggerTracks     = 0x0;       
-  fSplitLevel    = 0;
-//default constructor
 }
 //_____________________________________________________________________________
 AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title):
-  TNamed(name,title)
+  TNamed(name,title),
+    fLoader(loader),
+    fHits(0x0),
+    fDigits(0x0),
+    fSDigits(0x0),
+    fRawClusters(0x0),
+    fGlobalTrigger(0x0),
+    fLocalTrigger(0x0),
+    fRecTracks(0x0),
+    fRecTriggerTracks(0x0),
+    fNhits(0),
+    fNdigits(0x0),
+    fNSdigits(0x0),
+    fNrawclusters(0x0),
+    fNglobaltrigger(0),
+    fNlocaltrigger(0),
+    fNrectracks(0),
+    fNrectriggertracks(0),
+    fSplitLevel(0)
 {
   // Constructor for AliMUONData
-  fLoader        = loader;
-  fHits          = 0x0;    // One event in treeH per primary track
-  fDigits        = 0x0;  // One event in treeH per detection plane
-  fNdigits       = 0x0;
-  fRawClusters   = 0x0; //One event in TreeR/RawclusterBranch per tracking detection plane
-  fGlobalTrigger = 0x0; //! List of Global Trigger 1st event in TreeR/GlobalTriggerBranch
-  fLocalTrigger  = 0x0;  //! List of Local Trigger, 1st event in TreeR/LocalTriggerBranch
-  fRecTracks     = 0x0;    
-  fRecTriggerTracks     = 0x0;    
-  fNhits         = 0;
-  fNglobaltrigger =0;
-  fNlocaltrigger = 0;
-  fNrectracks    = 0;  
-  fNrectriggertracks    = 0;  
-  fSplitLevel    = 0;
+
 //   fHits          = new TClonesArray("AliMUONHit",1000);
 //   fNhits         = 0;
 //   fDigits        = new TObjArray(AliMUONConstants::NCh());
@@ -95,7 +107,6 @@ AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title
 //   fNrectracks    = 0; // really needed or GetEntriesFast sufficient ????
 
 
-  //default constructor
 }
 //_____________________________________________________________________________
 AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
@@ -115,6 +126,10 @@ AliMUONData::~AliMUONData()
     fDigits->Delete();
     delete fDigits;
   }
+  if (fSDigits) {
+    fSDigits->Delete();
+    delete fSDigits;
+  }
   if (fRawClusters) {
     fRawClusters->Delete();
     delete fRawClusters;
@@ -156,6 +171,24 @@ void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
   new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
 }
 //_____________________________________________________________________________
+void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *Sdigits)
+{
+  //
+  // Add a MUON Sdigit to the list of SDigits of the detection plane id
+  //
+  TClonesArray &lSdigits = * SDigits(id) ; 
+  new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,Sdigits);
+}
+//_____________________________________________________________________________
+void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
+{
+  //
+  // Add a MUON Sdigit to the list of SDigits of the detection plane id
+  //
+  TClonesArray &lSdigits = * SDigits(id) ; 
+  new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
+}
+//_____________________________________________________________________________
 void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
                                   Int_t *singleUndef,
                                   Int_t *pairUnlike, Int_t *pairLike)
@@ -179,7 +212,6 @@ void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber,
                         Float_t phi, Float_t length, Float_t destep)
 {
   // Add new hit to the hit list
-    
   TClonesArray &lhits = *fHits;
   new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber, 
                                  idpart, X, Y, Z, 
@@ -261,6 +293,15 @@ TClonesArray*  AliMUONData::Digits(Int_t DetectionPlane)
     return NULL;
 }
 //____________________________________________________________________________
+TClonesArray*  AliMUONData::SDigits(Int_t DetectionPlane) 
+{
+  //Getting List of SDigits
+  if (fSDigits)
+    return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
+  else
+    return NULL;
+}
+//____________________________________________________________________________
 Bool_t   AliMUONData::IsRawClusterBranchesInTree()
 {
   // Checking if there are RawCluster Branches In TreeR
@@ -334,6 +375,7 @@ void AliMUONData::Fill(Option_t* option)
   // Method to fill the trees
   const char *cH   = strstr(option,"H");
   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
+  const char *cS   = strstr(option,"S");   // SDigits branches in TreeS
   const char *cRC  = strstr(option,"RC");  // RawCluster branches in TreeR
   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
   const char *cRT  = strstr(option,"RT");  // Reconstructed Track in TreeT
@@ -354,6 +396,10 @@ void AliMUONData::Fill(Option_t* option)
   if ( TreeD() && cD) {
     TreeD()->Fill();
   }
+  // Filling TreeS
+  if ( TreeS() && cS) {
+    TreeS()->Fill();
+  }
 
   //
   // filling rawclusters
@@ -419,6 +465,7 @@ void AliMUONData::MakeBranch(Option_t* option)
 
   const char *cH   = strstr(option,"H");
   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
+  const char *cS   = strstr(option,"S");   // Digits branches in TreeS
   const char *cRC  = strstr(option,"RC");  // RawCluster branches in TreeR
   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
   const char *cRT  = strstr(option,"RT");  // Reconstructed Track in TreeT
@@ -432,7 +479,8 @@ void AliMUONData::MakeBranch(Option_t* option)
 
     if (fHits == 0x0)  {
        fHits = new TClonesArray("AliMUONHit",1000);
-       gAlice->GetMCApp()->AddHitList (fHits);
+//     if (gAlice->GetMCApp())
+//       gAlice->GetMCApp()->AddHitList (fHits);
     }
            
     fNhits = 0;
@@ -452,7 +500,9 @@ void AliMUONData::MakeBranch(Option_t* option)
     if (fDigits  == 0x0) {
       fDigits  = new TObjArray(AliMUONConstants::NCh());
       for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
-       fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),iDetectionPlane); 
+       TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
+       tca->SetOwner();
+       fDigits->AddAt(tca,iDetectionPlane); 
       }
     }
     if (fNdigits == 0x0) {
@@ -475,6 +525,37 @@ void AliMUONData::MakeBranch(Option_t* option)
       }
   }
   
+  //Creating Branches for SDigits
+  if (TreeS() && cS ) {
+    // one branch for Sdigits per chamber
+    if (fSDigits  == 0x0) {
+      fSDigits  = new TObjArray(AliMUONConstants::NCh());
+      for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
+       TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
+       tca->SetOwner();
+       fSDigits->AddAt(tca,iDetectionPlane); 
+      }
+    }
+    if (fNSdigits == 0x0) {
+      fNSdigits = new Int_t[AliMUONConstants::NCh()];
+      for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
+       fNSdigits[iDetectionPlane]=0;
+      }
+    }
+    for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
+      sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
+      branch = 0x0;
+      branch = TreeS()->GetBranch(branchname);
+      if (branch) {  
+       Info("MakeBranch","Branch %s is already in tree.",GetName());
+       return;
+      }
+      TClonesArray * Sdigits = SDigits(iDetectionPlane); 
+      branch = TreeS()->Branch(branchname, &Sdigits, kBufferSize,1);
+      //Info("MakeBranch","Making Branch %s for Sdigits in detection plane %d\n",branchname,iDetectionPlane+1);
+      }
+  }
+
   if (TreeR() && cRC ) {
     //  one branch for raw clusters per tracking detection plane
     //        
@@ -482,7 +563,9 @@ void AliMUONData::MakeBranch(Option_t* option)
     if (fRawClusters == 0x0) {
       fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
       for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
-       fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",1000),i); 
+       TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
+       tca->SetOwner();
+       fRawClusters->AddAt(tca,i); 
       }
     }
 
@@ -609,6 +692,18 @@ void AliMUONData::ResetDigits()
       if (fNdigits)  fNdigits[i]=0;
     }
 }
+//____________________________________________________________________________
+void AliMUONData::ResetSDigits()
+{
+    //
+    // Reset number of Sdigits and the Sdigits array for this detector
+    //
+    if (fSDigits == 0x0) return;
+    for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
+      if ((*fSDigits)[i])    ((TClonesArray*)fSDigits->At(i))->Clear();
+      if (fNSdigits)  fNSdigits[i]=0;
+    }
+}
 //______________________________________________________________________________
 void AliMUONData::ResetHits()
 {
@@ -655,6 +750,7 @@ void AliMUONData::SetTreeAddress(Option_t* option)
   //Setting Addresses to the events trees
   const char *cH   = strstr(option,"H");
   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
+  const char *cS   = strstr(option,"S");   // SDigits branches in TreeS
   const char *cRC  = strstr(option,"RC");  // RawCluster branches in TreeR
   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeR
   const char *cRT  = strstr(option,"RT");  // Reconstructed Track in TreeT
@@ -668,7 +764,11 @@ void AliMUONData::SetTreeAddress(Option_t* option)
   //
   // Branch address for hit tree
   if ( TreeH() && cH ) {
-    if (fHits == 0x0) fHits     = new TClonesArray("AliMUONHit",1000);
+      if (fHits == 0x0) {
+       fHits     = new TClonesArray("AliMUONHit",1000);
+       //      if (gAlice->GetMCApp())
+       //  gAlice->GetMCApp()->AddHitList (fHits);  Moved to AliMUON
+    }
     fNhits =0;
   } 
   if (TreeH() && fHits && cH) {
@@ -702,11 +802,37 @@ void AliMUONData::SetTreeAddress(Option_t* option)
       if (fDigits) {
        branch = TreeD()->GetBranch(branchname);
        TClonesArray * digits = Digits(i);
-       if (branch) branch->SetAddress( &digits );
+       if (branch) {
+         branch->SetAddress( &digits );
+       }
        else Warning("SetTreeAddress","(%s) Failed for Digits Detection plane %d. Can not find branch in tree.",GetName(),i);
       }
     }
   }
+  //
+  // Branch address for Sdigit tree
+  if ( TreeS() && cS) {
+    if (fSDigits == 0x0) { 
+      fSDigits = new TObjArray(AliMUONConstants::NCh());
+      fNSdigits= new Int_t[AliMUONConstants::NCh()];
+      for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
+       fSDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i); 
+       fNSdigits[i]=0;
+      }
+    }
+  }
+
+  if (TreeS() && fSDigits && cS) {
+    for (int i=0; i<AliMUONConstants::NCh(); i++) {
+      sprintf(branchname,"%sSDigits%d",GetName(),i+1);
+      if (fSDigits) {
+       branch = TreeS()->GetBranch(branchname);
+       TClonesArray * Sdigits = SDigits(i);
+       if (branch) branch->SetAddress( &Sdigits );
+       else Warning("SetTreeAddress","(%s) Failed for SDigits Detection plane %d. Can not find branch in tree.",GetName(),i);
+      }
+    }
+  }
   
   //
   // Branch address for rawclusters, globaltrigger and local trigger tree