]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALReconstructioner.cxx
Delete the run loader before creating a new getter
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructioner.cxx
CommitLineData
6ddf6724 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//_________________________________________________________________________
19//*--
20//*-- Author: Gines Martinez & Yves Schutz (SUBATECH)
21//*-- Compleetely redesigned by Dmitri Peressounko (SUBATECH & RRC KI) March 2001
22/////////////////////////////////////////////////////////////////////////////////////
23// Wrapping class for reconstruction. Allows to produce reconstruction from
24// different steps: from previously produced hits,sdigits, etc. Each new reconstruction
d018ba66 25// flow (e.g. digits, made from them RecPoints,
6ddf6724 26// subsequently made RecParticles) are distinguished by the title of created branches. One can
27// use this title as a comment, see use case below.
28// Thanks to getters, one can set
29// parameters to reconstruction briks. The full set of parameters is saved in the
30// corresponding branch: e.g. parameters of clusterizer are stored in branch
d018ba66 31// TreeR::AliEMCALClusterizer with the same title as the branch containing the RecPoints. // TTree does not support overwriting, therefore one can not produce several
6ddf6724 32// branches with the same names and titles - use different titles.
33//
34// Use case:
35//
36// root [0] AliEMCALReconstructioner * r = new AliEMCALReconstructioner("galice.root")
37// // Set the header file
38// root [1] r->ExecuteTask()
39// // Make full chain of reconstruction
40//
41// // One can specify the title for each branch
42// root [2] r->SetBranchFileName("RecPoints","RecPoints1") ;
43//
44// // One can change parameters of reconstruction algorithms
45// root [3] r->GetClusterizer()->SetEmcLocalMaxCut(0.02)
46//
47// // One can specify the starting point of the reconstruction and title of all
48// // branches produced in this pass
49// root [4] r->StartFrom("AliEMCALClusterizer","Local max cut 0.02")
50// // means that will use already generated Digits and produce only RecPoints,
d018ba66 51// // and RecParticles
6ddf6724 52//
53// // And finally one can call ExecuteTask() with the following options
54// root [5] r->ExecuteTask("debug all timing")
85ef0957 55// // deb - prints the numbers of RecPoints and RecParticles
56// // deb all - prints in addition list of RecPoints and RecParticles
6ddf6724 57// // timing - prints benchmarking results
58///////////////////////////////////////////////////////////////////////////////////////////////////
59
60// --- ROOT system ---
61
6ddf6724 62// --- Standard library ---
6ddf6724 63
64// --- AliRoot header files ---
d018ba66 65#include "AliESD.h"
66#include "AliESDCaloTrack.h"
6ddf6724 67#include "AliEMCALReconstructioner.h"
68#include "AliEMCALClusterizerv1.h"
d018ba66 69#include "AliEMCALPIDv1.h"
70#include "AliEMCALGetter.h"
71
6ddf6724 72ClassImp(AliEMCALReconstructioner)
73
74//____________________________________________________________________________
75 AliEMCALReconstructioner::AliEMCALReconstructioner():TTask("AliEMCALReconstructioner","")
76{
77 // ctor
6ddf6724 78 fClusterizer = 0 ;
d018ba66 79 fPID = 0 ;
6ddf6724 80
81 fIsInitialized = kFALSE ;
82
83}
84
85//____________________________________________________________________________
d018ba66 86AliEMCALReconstructioner::AliEMCALReconstructioner(const char* evFoldName,const char * branchName):
87TTask("AliEMCALReconstructioner",evFoldName)
6ddf6724 88{
89 // ctor
d018ba66 90
85ef0957 91 AliEMCALGetter::Instance(evFoldName) ;
6ddf6724 92
93 fRecPointBranch=branchName ;
85ef0957 94 fClusterizer = new AliEMCALClusterizerv1(evFoldName, GetTitle());
d018ba66 95 Add(fClusterizer);
6ddf6724 96
d018ba66 97 fRecPartBranch=branchName ;
85ef0957 98 fPID = new AliEMCALPIDv1(evFoldName, GetTitle());
d018ba66 99 Add(fPID);
6ddf6724 100
101 fIsInitialized = kTRUE ;
6ddf6724 102}
103//____________________________________________________________________________
d018ba66 104void AliEMCALReconstructioner::Exec(Option_t *opt)
6ddf6724 105{
85ef0957 106 //check, if the names of branches, which should be made coincide with already
6ddf6724 107 //existing
d018ba66 108 if (!opt)
109 return ;
6ddf6724 110 if(!fIsInitialized)
111 Init() ;
112}
d018ba66 113//____________________________________________________________________________
114void AliEMCALReconstructioner:: Clusters2Tracks(Int_t ievent, AliESD *event)
115{
116 // Convert EMCAL reconstructed particles into ESD object for event# ievent.
117 // ESD object is returned as an argument event
118
119 if(!fIsInitialized) Init() ;
6ddf6724 120
d018ba66 121 fClusterizer->SetEventRange(ievent,ievent);
122 fClusterizer->ExecuteTask();
123
124 fPID ->SetEventRange(ievent,ievent);
125 fPID ->ExecuteTask();
126
127 AliEMCALGetter *gime = AliEMCALGetter::Instance();
128 TClonesArray *recParticles = gime->RecParticles();
129 Int_t nOfRecParticles = recParticles->GetEntries();
130 for (Int_t recpart=0; recpart<nOfRecParticles; recpart++) {
131 AliESDCaloTrack *ct = new AliESDCaloTrack((AliEMCALRecParticle*)recParticles->At(recpart));
132 event->AddCaloTrack(ct);
133 }
134
135}
6ddf6724 136//____________________________________________________________________________
137 void AliEMCALReconstructioner::Init()
138{
139 // initiliaze Reconstructioner if necessary: we can not do this in default constructor
140
141 if(!fIsInitialized){
6ddf6724 142
143 fRecPointBranch="Default" ;
d018ba66 144 fClusterizer = new AliEMCALClusterizerv1(GetTitle(),fRecPointBranch.Data());
6ddf6724 145 Add(fClusterizer) ;
146
d018ba66 147 fRecPartBranch="Default";
148 fPID = new AliEMCALPIDv1(GetTitle(),fRecPartBranch.Data()) ;
149 Add(fPID) ;
6ddf6724 150
151 fIsInitialized = kTRUE ;
d018ba66 152
6ddf6724 153 }
154}
155//____________________________________________________________________________
156AliEMCALReconstructioner::~AliEMCALReconstructioner()
157{
158 // Delete data members if any
6ddf6724 159}
160
85ef0957 161//____________________________________________________________________________
d018ba66 162void AliEMCALReconstructioner::Print()const {
6ddf6724 163 // Print reconstructioner data
164
d018ba66 165 TString message ;
166 message = "-----------------AliEMCALReconstructioner---------------\n" ;
167 message += " Reconstruction of the header file %s\n" ;
168 message += " with the following modules:\n" ;
6ddf6724 169
170 if(fClusterizer->IsActive()){
d018ba66 171 message += " (+) %s to branch %s\n" ;
172 }
173
174 if(fPID->IsActive()){
175 message += " (+) %s to branch %s\n" ;
176 }
177 Info("Print", message.Data(),
178 GetTitle(),
d018ba66 179 fClusterizer->GetName(), fRecPointBranch.Data(),
180 fPID->GetName(), fRecPartBranch.Data() ) ;
6ddf6724 181}
5082063d 182
183//____________________________________________________________________________
184void AliEMCALReconstructioner::SetEventRange(Int_t first, Int_t last)
185{
186 // Set the event range to process
187 fFirstEvent=first;
188 fLastEvent=last;
189 fClusterizer->SetEventRange(fFirstEvent, fLastEvent) ;
190 fPID->SetEventRange(fFirstEvent, fLastEvent) ;
191}