]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALReconstructioner.cxx
Added AliEMCALReconstructioner
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructioner.cxx
index 9380eda3fbeb89c313904130ad1c710da10fc798..fef015ecb49fb5b8a75879cbe12805ea3b4f8b2e 100644 (file)
 /////////////////////////////////////////////////////////////////////////////////////
 //  Wrapping class for reconstruction. Allows to produce reconstruction from 
 //  different steps: from previously produced hits,sdigits, etc. Each new reconstruction
-//  flow (e.g. digits, made from them RecPoints, subsequently made TrackSegments, 
+//  flow (e.g. digits, made from them RecPoints,
 //  subsequently made RecParticles) are distinguished by the title of created branches. One can 
 //  use this title as a comment, see use case below. 
 //  Thanks to getters, one can set 
 //  parameters to reconstruction briks. The full set of parameters is saved in the 
 //  corresponding branch: e.g. parameters of clusterizer are stored in branch 
-//  TreeR::AliEMCALClusterizer with the same title as the branch containing the RecPoints. 
-//  TTree does not support overwriting, therefore one can not produce several 
+//  TreeR::AliEMCALClusterizer with the same title as the branch containing the RecPoints. //  TTree does not support overwriting, therefore one can not produce several 
 //  branches with the same names and titles - use different titles.
 //
 //  Use case: 
@@ -49,7 +48,7 @@
 //             // branches produced in this pass
 //  root [4] r->StartFrom("AliEMCALClusterizer","Local max cut 0.02") 
 //             // means that will use already generated Digits and produce only RecPoints, 
-//             // TS and RecParticles 
+//             // and RecParticles 
 //
 //             // And finally one can call ExecuteTask() with the following options
 //  root [5] r->ExecuteTask("debug all timing")
 
 // --- ROOT system ---
 
-#include "TClonesArray.h"
-#include "TROOT.h"
-#include "TTree.h"
-#include "TFile.h"
-
 // --- Standard library ---
-#include <Riostream.h>   
+#include "Riostream.h"
 
 // --- AliRoot header files ---
-#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliESD.h"
+#include "AliESDCaloTrack.h"
 #include "AliEMCALReconstructioner.h"
 #include "AliEMCALClusterizerv1.h"
 #include "AliEMCALDigitizer.h"
 #include "AliEMCALSDigitizer.h"
-//#include "AliEMCALTrackSegmentMakerv1.h"
-//#include "AliEMCALPIDv1.h"
-//#include "AliEMCALFastRecParticle.h"
-//#include "AliEMCALCpvRecPoint.h"
+#include "AliEMCALPIDv1.h"
+#include "AliEMCALGetter.h"
+
+#include "AliEMCALLoader.h"
 
 ClassImp(AliEMCALReconstructioner)
 
@@ -85,61 +81,112 @@ ClassImp(AliEMCALReconstructioner)
   AliEMCALReconstructioner::AliEMCALReconstructioner():TTask("AliEMCALReconstructioner","")
 {
   // ctor
-  fToSplit = kFALSE ;
   fDigitizer   = 0 ;
   fClusterizer = 0 ;
-  //fTSMaker     = 0 ;
-  //fPID         = 0 ; 
+  fPID         = 0 ; 
   fSDigitizer  = 0 ;
-  fHeaderFileName = "galice.root" ;
 
   fIsInitialized = kFALSE ;
 
 } 
 
 //____________________________________________________________________________
-AliEMCALReconstructioner::AliEMCALReconstructioner(const char* headerFile,const char * branchName,Bool_t toSplit):
-TTask("AliEMCALReconstructioner","")
+AliEMCALReconstructioner::AliEMCALReconstructioner(const char* evFoldName,const char * branchName):
+TTask("AliEMCALReconstructioner",evFoldName)
 {
   // ctor
+  AliRunLoader* rl = AliRunLoader::GetRunLoader(evFoldName);
+  if (rl == 0x0)
+   {
+     Fatal("AliEMCALReconstructioner","Can not get Run Loader from folder %s.",evFoldName);
+   } 
+  if (rl->GetAliRun() == 0x0)
+   {
+     delete gAlice;
+     gAlice = 0x0;
+     rl->LoadgAlice();
+     gAlice = rl->GetAliRun();
+   }
+
+  AliEMCALLoader* gime = dynamic_cast<AliEMCALLoader*>(rl->GetLoader("EMCALLoader"));
+  if (gime == 0x0)
+   {
+     Error("AliEMCALReconstructioner","Can not get EMCAL Loader");
+     return;  
+   }
+  
+  TString galicefn = rl->GetFileName();
+  TString method("AliEMCALReconstructioner::AliEMCALReconstructioner(");
+  method = (((method + evFoldName)+",")+branchName)+"): ";
   
-  fHeaderFileName = headerFile ;
-  fToSplit = toSplit ;
   fSDigitsBranch= branchName; 
-  fSDigitizer  = new AliEMCALSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data(),toSplit) ; 
-  Add(fSDigitizer) ;
-
-  fDigitsBranch=branchName ; 
-  fDigitizer   = new AliEMCALDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data(),toSplit) ; 
+  
+  //P.Skowronski remark
+  // Tasks has default fixed names
+  // other tasks can be added, even runtime
+  // with arbitrary name. See AliDataLoader::
+  cout<<"\n\n\n";
+  cout<<method<<"\n\nCreating SDigitizer\n";
+  fSDigitizer  = new AliEMCALSDigitizer(galicefn,GetTitle());
+  Add(fSDigitizer);
+  gime->PostSDigitizer(fSDigitizer);
+
+  fDigitsBranch=branchName ;
+  cout<<"\n\n\n";
+  cout<<method<<"\n\nCreating Digitizer\n";
+  fDigitizer   = new AliEMCALDigitizer(galicefn,GetTitle()) ;
   Add(fDigitizer) ;
-
+  gime->PostDigitizer(fDigitizer);
 
   fRecPointBranch=branchName ; 
-  fClusterizer = new AliEMCALClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data(),toSplit) ; 
-  Add(fClusterizer) ;
-  
-
-//   fTSBranch=branchName ; 
-//   fTSMaker     = new AliEMCALTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data(),toSplit) ;
-//   Add(fTSMaker) ;
-  
+  cout<<"\n\n\n";
+  cout<<method<<"Creating Clusterizer\n";
+  fClusterizer = new AliEMCALClusterizerv1(galicefn,GetTitle());
+  Add(fClusterizer);
+  gime->PostReconstructioner(fClusterizer);
   
-//   fRecPartBranch=branchName ; 
-//   fPID         = new AliEMCALPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data(),toSplit) ;
-//   Add(fPID) ;
+  fRecPartBranch=branchName ; 
+  cout<<"\n\n\n";
+  cout<<method<<"Creating PID\n";
+  fPID         = new AliEMCALPIDv1(galicefn,GetTitle());
+  Add(fPID);
+  cout<<"\nFINISHED \n\n"<<method;
   
   fIsInitialized = kTRUE ;
-  
 } 
 //____________________________________________________________________________
-void AliEMCALReconstructioner::Exec(Option_t *option)
+void AliEMCALReconstructioner::Exec(Option_t *opt)
 {
-  //chesk, if the names of branches, which should be made conicide with already
+  //check, if the names of branches, which should be made conicide with already
   //existing
+  if (!opt) 
+    return ; 
   if(!fIsInitialized)
     Init() ;
 }
+//____________________________________________________________________________
+void AliEMCALReconstructioner:: Clusters2Tracks(Int_t ievent, AliESD *event)
+{
+  // Convert EMCAL reconstructed particles into ESD object for event# ievent.
+  // ESD object is returned as an argument event
+
+  if(!fIsInitialized) Init() ;
 
+  fClusterizer->SetEventRange(ievent,ievent);
+  fClusterizer->ExecuteTask();
+  
+  fPID        ->SetEventRange(ievent,ievent);
+  fPID        ->ExecuteTask();
+
+  AliEMCALGetter *gime = AliEMCALGetter::Instance();
+  TClonesArray *recParticles = gime->RecParticles();
+  Int_t nOfRecParticles = recParticles->GetEntries();
+  for (Int_t recpart=0; recpart<nOfRecParticles; recpart++) {
+    AliESDCaloTrack *ct = new AliESDCaloTrack((AliEMCALRecParticle*)recParticles->At(recpart));
+    event->AddCaloTrack(ct);
+  }
+  
+}
 //____________________________________________________________________________
  void AliEMCALReconstructioner::Init()
 {
@@ -149,69 +196,57 @@ void AliEMCALReconstructioner::Exec(Option_t *option)
     // Initialisation
 
     fSDigitsBranch="Default" ; 
-    fSDigitizer  = new AliEMCALSDigitizer(fHeaderFileName.Data(),fSDigitsBranch.Data(),fToSplit) ; 
+    fSDigitizer  = new AliEMCALSDigitizer(GetTitle(),fSDigitsBranch.Data()) ; 
     Add(fSDigitizer) ;
 
     fDigitsBranch="Default" ; 
-    fDigitizer   = new AliEMCALDigitizer(fHeaderFileName.Data(),fDigitsBranch.Data(),fToSplit) ; 
+    fDigitizer   = new AliEMCALDigitizer(GetTitle(),fDigitsBranch.Data());
     Add(fDigitizer) ;
 
     fRecPointBranch="Default" ; 
-    fClusterizer = new AliEMCALClusterizerv1(fHeaderFileName.Data(),fRecPointBranch.Data(),fToSplit) ; 
+    fClusterizer = new AliEMCALClusterizerv1(GetTitle(),fRecPointBranch.Data());
     Add(fClusterizer) ;
 
-//     fTSBranch="Default" ; 
-//     fTSMaker     = new AliEMCALTrackSegmentMakerv1(fHeaderFileName.Data(),fTSBranch.Data(),fToSplit) ;
-//     Add(fTSMaker) ;
-
-
-//     fRecPartBranch="Default" ; 
-//     fPID         = new AliEMCALPIDv1(fHeaderFileName.Data(),fRecPartBranch.Data(),fToSplit) ;
-//     Add(fPID) ;
+    fRecPartBranch="Default"; 
+    fPID         = new AliEMCALPIDv1(GetTitle(),fRecPartBranch.Data()) ;
+    Add(fPID) ;
     
     fIsInitialized = kTRUE ;
+    
   }
 } 
 //____________________________________________________________________________
 AliEMCALReconstructioner::~AliEMCALReconstructioner()
 {
   // Delete data members if any
-
 } 
 
-//____________________________________________________________________________
-
-void AliEMCALReconstructioner::Print(Option_t * option)const {
+void AliEMCALReconstructioner::Print()const {
   // Print reconstructioner data  
 
-  cout << "-----------------AliEMCALReconstructioner---------------" << endl ;
-  cout << " Reconstruction of the header file " <<fHeaderFileName.Data() << endl ;
-  cout << " with the following modules: " << endl ;
+  TString message ; 
+  message  = "-----------------AliEMCALReconstructioner---------------\n" ;
+  message += " Reconstruction of the header file %s\n" ;
+  message += " with the following modules:\n" ;
 
   if(fSDigitizer->IsActive()){
-    cout << "   (+)   " << fSDigitizer->GetName() << " to branch : " << fSDigitsBranch.Data() << endl ; 
-    cout << endl ;
+    message += "   (+)   %s to branch %s\n" ; 
   }
   if(fDigitizer->IsActive()){
-    cout << "   (+)   " << fDigitizer->GetName() << " to branch : " << fDigitsBranch.Data() << endl ;  
-    cout <<  endl ;
+    message += "   (+)   %s to branch %s\n" ; 
   }
   
   if(fClusterizer->IsActive()){
-    cout << "   (+)   " <<fClusterizer->GetName() << " to branch : " <<fRecPointBranch.Data()  << endl ;  
-    cout <<  endl ;
+    message += "   (+)   %s to branch %s\n" ;
   }
 
-//   if(fTSMaker->IsActive()){
-//     cout << "   (+)   " << fTSMaker->GetName() << " to branch : " << fTSBranch.Data() << endl ;  
-//     cout <<  endl ;
-//   }
-
-
-//   if(fPID->IsActive()){
-//     cout << "   (+)   " << fPID->GetName() << " to branch : " <<fRecPartBranch.Data()  << endl ;  
-//     cout <<  endl ;
-//   }
-
-
+  if(fPID->IsActive()){
+    message += "   (+)   %s to branch %s\n" ;  
+  }
+  Info("Print", message.Data(), 
+       GetTitle(), 
+       fSDigitizer->GetName(), fSDigitsBranch.Data(), 
+       fDigitizer->GetName(), fDigitsBranch.Data() , 
+       fClusterizer->GetName(), fRecPointBranch.Data(), 
+       fPID->GetName(), fRecPartBranch.Data() ) ; 
 }