Transition to NewIO
[u/mrichter/AliRoot.git] / PHOS / AliPHOSReconstructioner.cxx
CommitLineData
d15a28e7 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
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
a3dfe79c 19//*--
7acf6008 20//*-- Author: Gines Martinez & Yves Schutz (SUBATECH)
f1aeaf5d 21//*-- Compleetely redesigned by Dmitri Peressounko (SUBATECH & RRC KI) March 2001
7acf6008 22/////////////////////////////////////////////////////////////////////////////////////
9a6ec61a 23// Wrapping class for reconstruction. Allows to produce reconstruction from
24// different steps: from previously produced hits,sdigits, etc. Each new reconstruction
a4e98857 25// flow (e.g. digits, made from them RecPoints, subsequently made TrackSegments,
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
21cd0c07 31// TreeR::AliPHOSClusterizer with the same title as the branch containing the RecPoints. // TTree does not support overwriting, therefore one can not produce several
9a6ec61a 32// branches with the same names and titles - use different titles.
33//
a4e98857 34// Use case:
7acf6008 35//
36// root [0] AliPHOSReconstructioner * r = new AliPHOSReconstructioner("galice.root")
37// // Set the header file
38// root [1] r->ExecuteTask()
a4e98857 39// // Make full chain of reconstruction
7acf6008 40//
41// // One can specify the title for each branch
42// root [2] r->SetBranchFileName("RecPoints","RecPoints1") ;
7acf6008 43//
9a6ec61a 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("AliPHOSClusterizer","Local max cut 0.02")
50// // means that will use already generated Digits and produce only RecPoints,
51// // TS and RecParticles
7acf6008 52//
53// // And finally one can call ExecuteTask() with the following options
9a6ec61a 54// root [5] r->ExecuteTask("debug all timing")
7acf6008 55// // deb - prints the numbers of produced SDigits, Digits etc.
56// // deb all - prints in addition list of made SDigits, digits etc.
57// // timing - prints benchmarking results
9a6ec61a 58///////////////////////////////////////////////////////////////////////////////////////////////////
d15a28e7 59
60// --- ROOT system ---
61
88cb7938 62#include "TClonesArray.h"
63#include "TROOT.h"
64#include "TTree.h"
65#include "TFile.h"
66
d15a28e7 67// --- Standard library ---
364de5c6 68
d15a28e7 69// --- AliRoot header files ---
88cb7938 70#include "AliRun.h"
71#include "AliRunLoader.h"
d15a28e7 72#include "AliPHOSReconstructioner.h"
7acf6008 73#include "AliPHOSClusterizerv1.h"
74#include "AliPHOSDigitizer.h"
75#include "AliPHOSSDigitizer.h"
76#include "AliPHOSTrackSegmentMakerv1.h"
77#include "AliPHOSPIDv1.h"
88cb7938 78#include "AliPHOSFastRecParticle.h"
79#include "AliPHOSCpvRecPoint.h"
80#include "AliPHOSLoader.h"
d15a28e7 81
82ClassImp(AliPHOSReconstructioner)
83
d15a28e7 84//____________________________________________________________________________
7acf6008 85 AliPHOSReconstructioner::AliPHOSReconstructioner():TTask("AliPHOSReconstructioner","")
d15a28e7 86{
b2a60966 87 // ctor
7acf6008 88 fDigitizer = 0 ;
89 fClusterizer = 0 ;
90 fTSMaker = 0 ;
91 fPID = 0 ;
92 fSDigitizer = 0 ;
d15a28e7 93
7acf6008 94 fIsInitialized = kFALSE ;
d15a28e7 95
6ad0bfa0 96}
97
6ad0bfa0 98//____________________________________________________________________________
88cb7938 99AliPHOSReconstructioner::AliPHOSReconstructioner(const char* evFoldName,const char * branchName):
100TTask("AliPHOSReconstructioner",evFoldName)
d15a28e7 101{
7acf6008 102 // ctor
88cb7938 103 AliRunLoader* rl = AliRunLoader::GetRunLoader(evFoldName);
104 if (rl == 0x0)
105 {
106 Fatal("AliPHOSReconstructioner","Can not get Run Loader from folder %s.",evFoldName);
107 }
108 if (rl->GetAliRun() == 0x0)
109 {
110 delete gAlice;
111 gAlice = 0x0;
112 rl->LoadgAlice();
113 gAlice = rl->GetAliRun();
114 }
115
116 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
117 if (gime == 0x0)
118 {
119 Error("AliPHOSReconstructioner","Can not get PHOS Loader");
120 return;
121 }
122
123 TString galicefn = rl->GetFileName();
124 TString method("AliPHOSReconstructioner::AliPHOSReconstructioner(");
125 method = (((method + evFoldName)+",")+branchName)+"): ";
7acf6008 126
108bc8df 127 fSDigitsBranch= branchName;
88cb7938 128
129 //P.Skowronski remark
130 // Tasks has default fixed names
131 // other tasks can be added, even runtime
132 // with arbitrary name. See AliDataLoader::
133 cout<<"\n\n\n";
134 cout<<method<<"\n\nCreating SDigitizer\n";
135 fSDigitizer = new AliPHOSSDigitizer(galicefn,GetTitle());
136 Add(fSDigitizer);
137 gime->PostSDigitizer(fSDigitizer);
138
139 fDigitsBranch=branchName ;
140 cout<<"\n\n\n";
141 cout<<method<<"\n\nCreating Digitizer\n";
142 fDigitizer = new AliPHOSDigitizer(galicefn,GetTitle()) ;
7acf6008 143 Add(fDigitizer) ;
88cb7938 144 gime->PostDigitizer(fDigitizer);
7acf6008 145
108bc8df 146 fRecPointBranch=branchName ;
88cb7938 147 cout<<"\n\n\n";
148 cout<<method<<"Creating Clusterizer\n";
149 fClusterizer = new AliPHOSClusterizerv1(galicefn,GetTitle());
150 Add(fClusterizer);
151 gime->PostReconstructioner(fClusterizer);
2131115b 152
108bc8df 153 fTSBranch=branchName ;
88cb7938 154 fTSMaker = new AliPHOSTrackSegmentMakerv1(galicefn,GetTitle());
7acf6008 155 Add(fTSMaker) ;
88cb7938 156 gime->PostTracker(fTSMaker);
157
7acf6008 158
108bc8df 159 fRecPartBranch=branchName ;
88cb7938 160 cout<<"\n\n\n";
161 cout<<method<<"Creating PID\n";
162 fPID = new AliPHOSPIDv1(galicefn,GetTitle());
163 Add(fPID);
164 cout<<"\nFINISHED \n\n"<<method;
7acf6008 165
166 fIsInitialized = kTRUE ;
7acf6008 167}
168//____________________________________________________________________________
a4e98857 169void AliPHOSReconstructioner::Exec(Option_t *option)
170{
7acf6008 171 //chesk, if the names of branches, which should be made conicide with already
172 //existing
173 if(!fIsInitialized)
174 Init() ;
7acf6008 175}
176//____________________________________________________________________________
177 void AliPHOSReconstructioner::Init()
178{
a4e98857 179 // initiliaze Reconstructioner if necessary: we can not do this in default constructor
7acf6008 180
181 if(!fIsInitialized){
182 // Initialisation
183
81b0fcd1 184 fSDigitsBranch="Default" ;
88cb7938 185 fSDigitizer = new AliPHOSSDigitizer(GetTitle(),fSDigitsBranch.Data()) ;
7acf6008 186 Add(fSDigitizer) ;
187
81b0fcd1 188 fDigitsBranch="Default" ;
88cb7938 189 fDigitizer = new AliPHOSDigitizer(GetTitle(),fDigitsBranch.Data());
7acf6008 190 Add(fDigitizer) ;
191
81b0fcd1 192 fRecPointBranch="Default" ;
88cb7938 193 fClusterizer = new AliPHOSClusterizerv1(GetTitle(),fRecPointBranch.Data());
7acf6008 194 Add(fClusterizer) ;
195
81b0fcd1 196 fTSBranch="Default" ;
88cb7938 197 fTSMaker = new AliPHOSTrackSegmentMakerv1(GetTitle(),fTSBranch.Data());
7acf6008 198 Add(fTSMaker) ;
199
200
88cb7938 201 fRecPartBranch="Default";
202 fPID = new AliPHOSPIDv1(GetTitle(),fRecPartBranch.Data()) ;
7acf6008 203 Add(fPID) ;
204
205 fIsInitialized = kTRUE ;
88cb7938 206
7acf6008 207 }
208}
209//____________________________________________________________________________
210AliPHOSReconstructioner::~AliPHOSReconstructioner()
211{
baef0810 212 // Delete data members if any
7acf6008 213}
baef0810 214
215void AliPHOSReconstructioner::Print(Option_t * option)const {
216 // Print reconstructioner data
217
21cd0c07 218 TString message ;
219 message = "-----------------AliPHOSReconstructioner---------------\n" ;
220 message += " Reconstruction of the header file %s\n" ;
221 message += " with the following modules:\n" ;
7acf6008 222
223 if(fSDigitizer->IsActive()){
21cd0c07 224 message += " (+) %s to branch %s\n" ;
7acf6008 225 }
226 if(fDigitizer->IsActive()){
21cd0c07 227 message += " (+) %s to branch %s\n" ;
7acf6008 228 }
229
230 if(fClusterizer->IsActive()){
21cd0c07 231 message += " (+) %s to branch %s\n" ;
7acf6008 232 }
233
234 if(fTSMaker->IsActive()){
21cd0c07 235 message += " (+) %s to branch %s\n" ;
7acf6008 236 }
237
7acf6008 238 if(fPID->IsActive()){
21cd0c07 239 message += " (+) %s to branch %s\n" ;
7acf6008 240 }
21cd0c07 241 Info("Print", message.Data(),
88cb7938 242 GetTitle(),
21cd0c07 243 fSDigitizer->GetName(), fSDigitsBranch.Data(),
244 fDigitizer->GetName(), fDigitsBranch.Data() ,
245 fClusterizer->GetName(), fRecPointBranch.Data(),
246 fTSMaker->GetName(), fTSBranch.Data() ,
247 fPID->GetName(), fRecPartBranch.Data() ) ;
51926850 248}