]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Major upgrades for AliTOFMerger
authorvicinanz <vicinanz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 3 Oct 2001 14:46:30 +0000 (14:46 +0000)
committervicinanz <vicinanz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 3 Oct 2001 14:46:30 +0000 (14:46 +0000)
TOF/AliTOFMerger.cxx
TOF/AliTOFMerger.h

index 14f8c74230fdf5355d4af2ac86f7974a4202ec6d..ec789c67f65c148c88fd8faf4160fe277ae6cb07 100644 (file)
@@ -13,7 +13,6 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-
 #include <TTree.h> 
 #include <TVector.h>
 #include <TObjArray.h>
@@ -39,7 +38,8 @@ ClassImp(AliTOFMerger)
 //___________________________________________
   AliTOFMerger::AliTOFMerger() 
 {
-// Default constructor    
+// Default ctor    
+    fNDigits = 0;
     fEvNrSig = 0;
     fEvNrBgr = 0;
     fMerge =kDigitize;
@@ -49,7 +49,7 @@ ClassImp(AliTOFMerger)
 //------------------------------------------------------------------------
 AliTOFMerger::~AliTOFMerger()
 {
-// Destructor
+// Dtor
   if(fSDigits)  {
     fSDigits->Delete();
     delete fSDigits ;
@@ -81,8 +81,103 @@ TFile* AliTOFMerger::InitBgr()
 //------------------------------------------------------------------------
 void AliTOFMerger::Digitise()
 {
+// as in FMD
+// keep galice.root for signal and name differently the file for 
+// background when add! otherwise the track info for signal will be lost !
+
+
 
 #ifdef DEBUG
   cout<<"ALiTOFMerger::>SDigits2Digits start...\n";
 #endif
+
+  AliTOF* TOF = (AliTOF *) gAlice->GetDetector("TOF") ;
+
+
+  TFile *f1 =0;
+  TTree *TK = gAlice->TreeK();
+  if (TK) f1 = TK->GetCurrentFile();
+
+  gAlice->GetEvent(fEvNrSig) ;
+  
+  if(gAlice->TreeD() == 0)     
+    gAlice->MakeTree("D") ;
+  gAlice->TreeD()->Reset();
+
+  // read and write digits for signal
+   ReadWriteDigit(fEvNrSig);
+
+   if(fMerge){ 
+     // bgr file
+    fBgrFile->cd();
+    // gAlice->TreeS()->Reset();
+    gAlice = (AliRun*)fBgrFile->Get("gAlice");
+    ReadWriteDigit(fEvNrBgr);
+   } //if merge
+
+
+  f1->cd();
+   
+  //Make branch for digits
+  TOF->MakeBranch("D");
+
+  gAlice->TreeD()->Reset();
+  gAlice->TreeD()->Fill();
+  
+  fDigits   = TOF->Digits();
+  
+  gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
+  
+  gAlice->ResetDigits();
+
+}
+
+//---------------------------------------------------------------------
+
+void AliTOFMerger::ReadWriteDigit(Int_t iEvNum)
+{
+//
+// Read Sdigits from the current file and write them in the TreeD
+//
+  AliTOFdigit* tofsdigit;
+  
+  AliTOF * tofinfile = (AliTOF *) gAlice->GetDetector("TOF") ;
+  
+  gAlice->GetEvent(iEvNum) ;
+  if(gAlice->TreeS()==0) {
+    cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl; 
+    return ;}
+  
+  Int_t ndig, k;
+  Int_t    tracks[3];    // track info
+  Int_t    vol[5];       // location for a digit
+  Float_t  digit[2];     // TOF digit variables
+
+  gAlice->ResetDigits();
+  gAlice->TreeS()->GetEvent(iEvNum);
+  TClonesArray * TOFdigits   = tofinfile->SDigits();
+  
+  ndig=TOFdigits->GetEntries();
+
+  for (k=0; k<ndig; k++) {
+    tofsdigit= (AliTOFdigit*) TOFdigits->UncheckedAt(k);
+
+       tracks[0] = tofsdigit->GetTrack(0);
+       tracks[1] = tofsdigit->GetTrack(1);
+       tracks[2] = tofsdigit->GetTrack(2);
+
+       vol[0] = tofsdigit->GetSector();
+       vol[1] = tofsdigit->GetPlate();
+       vol[2] = tofsdigit->GetPadx();
+       vol[3] = tofsdigit->GetPadz();
+       vol[4] = tofsdigit->GetStrip();
+
+       digit[0] = tofsdigit->GetTdc();
+       digit[1] = tofsdigit->GetAdc();
+
+       new ((*fDigits)[fNDigits++]) AliTOFdigit(tracks, vol, digit);
+  } // end loop on sdigits in the current file
 }
+
+
+
index 5114908a45ff7fa69bf4ebb9a2bc8fe9a8815eed..7649cdbe5af6d04d825d580e952107c059e13b6f 100644 (file)
@@ -7,6 +7,7 @@
 // #include "AliMergable.h"
 #include "TRandom.h"
 #include "AliDetector.h"
+#include "AliTOF.h"
 
 typedef enum {kDigitize=0, kMerge = 1} MergeMode_t;
 
@@ -22,10 +23,9 @@ class AliTOFMerger {
   
   // Do the main work
   void Digitise() ;
-  //  Int_t PutEdgeEffect(Int_t charge){return (Int_t)(gRandom->Gaus(charge,500));}
   TClonesArray *SDigits() const {return fSDigits;}
  
-  //  void ReadDigit(Int_t a[][30][150], Int_t);
+  void ReadWriteDigit(Int_t);
   
   // Setters -> Later Communication with gAlice 
   void SetSignalEventNumber(Int_t i)     {fEvNrSig = i;}
@@ -34,7 +34,6 @@ class AliTOFMerger {
   void SetSignalFileName(char* file)     {fFnSig = file;}        
   void SetMode(MergeMode_t mode) {fMerge = mode;}
 
-       
     enum {kBgTag = -1};
       
  private:    
@@ -45,6 +44,7 @@ class AliTOFMerger {
  private:
     TClonesArray *fDigits;               // ! array with digits
     TClonesArray *fSDigits      ; // List of summable digits
+    Int_t fNDigits;                 // number of digits
     Int_t fEvNrSig;                 // signal     event number
     Int_t fEvNrBgr;                 // background event number    
     MergeMode_t fMerge;             // merging type kDigitize, kMerge
@@ -56,5 +56,3 @@ class AliTOFMerger {
 };    
 #endif
 
-
-