]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALClusterizerv1.cxx
Add methods to get access to names of files used in merging.
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALClusterizerv1.cxx
index fbfd5aa6b21c324ac7085bebc6f456a34d016594..883445e2deffb8fb50b2fa18be5277ec7827c8cf 100644 (file)
@@ -12,7 +12,6 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
 
 /* $Log:
@@ -87,23 +86,8 @@ ClassImp(AliEMCALClusterizerv1)
 {
   // default ctor (to be used mainly by Streamer)
   
-  fNumberOfPreShoClusters = fNumberOfTowerClusters = 0 ; 
-  
-  fPreShoClusteringThreshold = 0.0001;
-  fTowerClusteringThreshold  = 0.2;   
-  
-  fTowerLocMaxCut  = 0.03 ;
-  fPreShoLocMaxCut = 0.03 ;
-  
-  fW0     = 4.5 ;
-  fW0CPV  = 4.0 ;
-
-  fTimeGate = 1.e-8 ; 
-
-  fToUnfold = kFALSE ;
-
-  fHeaderFileName = fDigitsBranchTitle  = "" ;
-  fRecPointsInRun          = 0 ;   
+  InitParameters() ; 
+  fDefaultInit = kTRUE ; 
 }
 
 //____________________________________________________________________________
@@ -112,40 +96,44 @@ AliEMCALClusterizerv1::AliEMCALClusterizerv1(const char* headerFile,const char*
 {
   // ctor with the indication of the file where header Tree and digits Tree are stored
   
-
-  fNumberOfPreShoClusters = fNumberOfTowerClusters = 0 ; 
-
-  
-  fPreShoClusteringThreshold  = 0.0001;
-  fTowerClusteringThreshold   = 0.2;   
-  
-  fTowerLocMaxCut  = 0.03 ;
-  fPreShoLocMaxCut = 0.03 ;
-  
-  fW0     = 4.5 ;
-  fW0CPV  = 4.0 ;
-
-  fTimeGate = 1.e-8 ; 
-  
-  fToUnfold = kFALSE ;
-  
-  fHeaderFileName     = GetTitle() ; 
-  fDigitsBranchTitle  = GetName() ;
-  
-  TString clusterizerName( GetName()) ; 
-  clusterizerName.Append(":") ; 
-  clusterizerName.Append(Version()) ; 
-  SetName(clusterizerName) ;
-  fRecPointsInRun          = 0 ; 
-
+  InitParameters() ; 
+  fDefaultInit = kFALSE ; 
   Init() ;
 
 }
 //____________________________________________________________________________
   AliEMCALClusterizerv1::~AliEMCALClusterizerv1()
 {
+  // dtor
+  // fDefaultInit = kTRUE if Clusterizer created by default ctor (to get just the parameters)
+  
+  if (!fDefaultInit) {
+    AliEMCALGetter * gime = AliEMCALGetter::GetInstance() ; 
+    
+    // remove the task from the folder list
+    gime->RemoveTask("C",GetName()) ;
+    
+    // remove the RecPoints from the folder list
+    TString name(GetName()) ; 
+    name.Remove(name.Index(":")) ; 
+    gime->RemoveObjects("D", name) ;  //  Digits
+    gime->RemoveObjects("RT", name) ; // TowerRecPoints
+    gime->RemoveObjects("RP", name) ; // PreShoRecPoints
+    
+    // Delete gAlice
+    gime->CloseFile() ; 
+    
+  }
 }
+
+//____________________________________________________________________________
+const TString AliEMCALClusterizerv1::BranchName() const 
+{  
+  TString branchName(GetName() ) ;
+  branchName.Remove(branchName.Index(Version())-1) ;
+  return branchName ;
+}
+
 //____________________________________________________________________________
 Float_t  AliEMCALClusterizerv1::Calibrate(Int_t amp, Bool_t inpresho) const
 {
@@ -236,7 +224,7 @@ void AliEMCALClusterizerv1::Exec(Option_t * option)
 }
 
 //____________________________________________________________________________
-Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALTowerRecPoint * emcRP, int * maxAt, Float_t * maxAtEnergy,
+Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALTowerRecPoint * emcRP, AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
                                    Int_t nPar, Float_t * fitparameters) const
 { 
   // Calls TMinuit to fit the energy distribution of a cluster with several maxima 
@@ -270,7 +258,7 @@ Bool_t AliEMCALClusterizerv1::FindFit(AliEMCALTowerRecPoint * emcRP, int * maxAt
   AliEMCALGeometry * geom = gime->EMCALGeometry() ; 
 
   for(iDigit = 0; iDigit < nDigits; iDigit++){
-    digit = (AliEMCALDigit *) maxAt[iDigit]; 
+    digit = maxAt[iDigit]; 
 
     Int_t relid[4] ;
     Float_t x = 0.;
@@ -377,6 +365,38 @@ void AliEMCALClusterizerv1::Init()
   
 }
 
+//____________________________________________________________________________
+void AliEMCALClusterizerv1::InitParameters()
+{
+  fNumberOfPreShoClusters = fNumberOfTowerClusters = 0 ; 
+
+  
+  fPreShoClusteringThreshold  = 0.0001;
+  fTowerClusteringThreshold   = 0.2;   
+  
+  fTowerLocMaxCut  = 0.03 ;
+  fPreShoLocMaxCut = 0.03 ;
+  
+  fW0     = 4.5 ;
+  fW0CPV  = 4.0 ;
+
+  fTimeGate = 1.e-8 ; 
+  
+  fToUnfold = kFALSE ;
+  
+  fHeaderFileName     = GetTitle() ; 
+  fDigitsBranchTitle  = GetName() ;
+  
+  TString clusterizerName( GetName()) ; 
+  if (clusterizerName.IsNull() ) 
+    clusterizerName = "Default" ; 
+  clusterizerName.Append(":") ; 
+  clusterizerName.Append(Version()) ; 
+  SetName(clusterizerName) ;
+  fRecPointsInRun          = 0 ; 
+}
+
 //____________________________________________________________________________
 Int_t AliEMCALClusterizerv1::AreNeighbours(AliEMCALDigit * d1, AliEMCALDigit * d2)const
 {
@@ -451,15 +471,17 @@ void AliEMCALClusterizerv1::WriteRecPoints(Int_t event)
   // Creates new branches with given title
   // fills and writes into TreeR.
 
-  TString branchName(GetName() ) ;
-  branchName.Remove(branchName.Index(Version())-1) ;
-
   AliEMCALGetter *gime = AliEMCALGetter::GetInstance() ; 
-  TObjArray * towerRecPoints = gime->TowerRecPoints(branchName) ; 
-  TObjArray * preshoRecPoints = gime->PreShowerRecPoints(branchName) ; 
-  TClonesArray * digits = gime->Digits(branchName) ; 
-
-  Int_t index ;
+  TObjArray * towerRecPoints = gime->TowerRecPoints(BranchName()) ; 
+  TObjArray * preshoRecPoints = gime->PreShowerRecPoints(BranchName()) ; 
+  TClonesArray * digits = gime->Digits(BranchName()) ; 
+  TTree * treeR ; 
+
+  if (!gAlice->TreeR() ) 
+    gAlice->MakeTree("R", fSplitFile);
+  treeR = gAlice->TreeR() ;
+    
+    Int_t index ;
   //Evaluate position, dispersion and other RecPoint properties...
   for(index = 0; index < towerRecPoints->GetEntries(); index++)
     (dynamic_cast<AliEMCALTowerRecPoint *>(towerRecPoints->At(index)))->EvalAll(fW0,digits) ;
@@ -471,7 +493,7 @@ void AliEMCALClusterizerv1::WriteRecPoints(Int_t event)
 
   towerRecPoints->Expand(towerRecPoints->GetEntriesFast()) ; 
 
-  //Now the same for CPV
+  //Now the same for pre shower
   for(index = 0; index < preshoRecPoints->GetEntries(); index++)
     (dynamic_cast<AliEMCALRecPoint *>(preshoRecPoints->At(index)))->EvalAll(fW0CPV,digits)  ;
 
@@ -483,65 +505,32 @@ void AliEMCALClusterizerv1::WriteRecPoints(Int_t event)
   preshoRecPoints->Expand(preshoRecPoints->GetEntriesFast()) ;
   
   //Make branches in TreeR for RecPoints and Clusterizer
-  char * filename = 0;
-  if(gSystem->Getenv("CONFIG_SPLIT_FILE")!=0){   //generating file name
-    filename = new char[strlen(gAlice->GetBaseFile())+20] ;
-    sprintf(filename,"%s/EMCAL.Reco.root",gAlice->GetBaseFile()) ;
-  }
-  
-  //Make new branches
-  TDirectory *cwd = gDirectory;
   
  
   Int_t bufferSize = 32000 ;    
   Int_t splitlevel = 0 ;
 
-  //First EMC
-  TBranch * emcBranch = gAlice->TreeR()->Branch("EMCALTowerRP","TObjArray",&towerRecPoints,bufferSize,splitlevel);
-  emcBranch->SetTitle(branchName);
-  if (filename) {
-    emcBranch->SetFile(filename);
-    TIter next( emcBranch->GetListOfBranches());
-    TBranch * sb ;
-    while ((sb=(TBranch*)next())) {
-      sb->SetFile(filename);
-    }   
-    
-    cwd->cd();
-  }
+  //First Tower branch
+  TBranch * emcBranch = treeR->Branch("EMCALTowerRP","TObjArray",&towerRecPoints,bufferSize,splitlevel);
+  emcBranch->SetTitle(BranchName());
+
     
-  //Now CPV branch
-  TBranch * cpvBranch = gAlice->TreeR()->Branch("EMCALPreShoRP","TObjArray",&preshoRecPoints,bufferSize,splitlevel);
-  cpvBranch->SetTitle(branchName);
-  if (filename) {
-    cpvBranch->SetFile(filename);
-    TIter next( cpvBranch->GetListOfBranches());
-    TBranch * sb;
-    while ((sb=(TBranch*)next())) {
-      sb->SetFile(filename);
-    }   
-    cwd->cd();
-  } 
+  //Now Pre Shower branch 
+  TBranch * cpvBranch = treeR->Branch("EMCALPreShoRP","TObjArray",&preshoRecPoints,bufferSize,splitlevel);
+  cpvBranch->SetTitle(BranchName());
+
     
   //And Finally  clusterizer branch
-  AliEMCALClusterizerv1 * cl = (AliEMCALClusterizerv1*)gime->Clusterizer(branchName) ;
-  TBranch * clusterizerBranch = gAlice->TreeR()->Branch("AliEMCALClusterizer","AliEMCALClusterizerv1",
+  AliEMCALClusterizerv1 * cl = (AliEMCALClusterizerv1*)gime->Clusterizer(BranchName()) ;
+  TBranch * clusterizerBranch = treeR->Branch("AliEMCALClusterizer","AliEMCALClusterizerv1",
                                              &cl,bufferSize,splitlevel);
-  clusterizerBranch->SetTitle(branchName);
-  if (filename) {
-    clusterizerBranch->SetFile(filename);
-    TIter next( clusterizerBranch->GetListOfBranches());
-    TBranch * sb ;
-    while ((sb=(TBranch*)next())) {
-      sb->SetFile(filename);
-    }   
-    cwd->cd();
-  }
+  clusterizerBranch->SetTitle(BranchName());
+
   emcBranch        ->Fill() ;
   cpvBranch        ->Fill() ;
   clusterizerBranch->Fill() ;
 
-  gAlice->TreeR()->Write(0,kOverwrite) ;  
+  treeR->AutoSave() ; //Write(0,kOverwrite) ;  
   
 }
 
@@ -765,7 +754,7 @@ Double_t  AliEMCALClusterizerv1::ShowerShape(Double_t r)
 //____________________________________________________________________________
 void  AliEMCALClusterizerv1::UnfoldCluster(AliEMCALTowerRecPoint * iniTower, 
                                                 Int_t nMax, 
-                                                int * maxAt, 
+                                                AliEMCALDigit ** maxAt, 
                                                 Float_t * maxAtEnergy)
 {
   // Performs the unfolding of a cluster with nMax overlapping showers