Buffer an avarage distance in the pair
[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")
85ef0957 55// // deb - prints the numbers of RecPoints, TrackSegments, RecParticles
56// // deb all - prints in addition list of RecPoints, TrackSegments, RecParticles
57// // timing - prints benchmarking results
9a6ec61a 58///////////////////////////////////////////////////////////////////////////////////////////////////
d15a28e7 59
60// --- ROOT system ---
61
d15a28e7 62// --- Standard library ---
364de5c6 63
d15a28e7 64// --- AliRoot header files ---
35293055 65#include "AliESD.h"
66#include "AliESDCaloTrack.h"
d15a28e7 67#include "AliPHOSReconstructioner.h"
7acf6008 68#include "AliPHOSClusterizerv1.h"
7acf6008 69#include "AliPHOSTrackSegmentMakerv1.h"
70#include "AliPHOSPIDv1.h"
35293055 71#include "AliPHOSGetter.h"
e957fea8 72
d15a28e7 73
74ClassImp(AliPHOSReconstructioner)
75
d15a28e7 76//____________________________________________________________________________
7acf6008 77 AliPHOSReconstructioner::AliPHOSReconstructioner():TTask("AliPHOSReconstructioner","")
d15a28e7 78{
b2a60966 79 // ctor
7acf6008 80 fClusterizer = 0 ;
81 fTSMaker = 0 ;
82 fPID = 0 ;
d7d3b67b 83 fFirstEvent = 0 ;
84 fLastEvent = -1 ;
7acf6008 85 fIsInitialized = kFALSE ;
d15a28e7 86
6ad0bfa0 87}
88
6ad0bfa0 89//____________________________________________________________________________
88cb7938 90AliPHOSReconstructioner::AliPHOSReconstructioner(const char* evFoldName,const char * branchName):
91TTask("AliPHOSReconstructioner",evFoldName)
d15a28e7 92{
7acf6008 93 // ctor
88cb7938 94
85ef0957 95 AliPHOSGetter::Instance(evFoldName) ;
7acf6008 96
108bc8df 97 fRecPointBranch=branchName ;
85ef0957 98 fClusterizer = new AliPHOSClusterizerv1(evFoldName, GetTitle());
88cb7938 99 Add(fClusterizer);
2131115b 100
108bc8df 101 fTSBranch=branchName ;
85ef0957 102 fTSMaker = new AliPHOSTrackSegmentMakerv1(evFoldName, GetTitle());
7acf6008 103 Add(fTSMaker) ;
7acf6008 104
108bc8df 105 fRecPartBranch=branchName ;
85ef0957 106 fPID = new AliPHOSPIDv1(evFoldName, GetTitle());
88cb7938 107 Add(fPID);
7acf6008 108
109 fIsInitialized = kTRUE ;
7acf6008 110}
111//____________________________________________________________________________
35293055 112void AliPHOSReconstructioner::Exec(Option_t *opt)
a4e98857 113{
85ef0957 114 //check, if the names of branches, which should be made coincide with already
7acf6008 115 //existing
e957fea8 116 if (!opt)
117 return ;
7acf6008 118 if(!fIsInitialized)
119 Init() ;
7acf6008 120}
121//____________________________________________________________________________
35293055 122void AliPHOSReconstructioner:: Clusters2Tracks(Int_t ievent, AliESD *event)
123{
124 // Convert PHOS reconstructed particles into ESD object for event# ievent.
125 // ESD object is returned as an argument event
126
127 if(!fIsInitialized) Init() ;
128
129 fClusterizer->SetEventRange(ievent,ievent);
130 fClusterizer->ExecuteTask();
131
132 fTSMaker ->SetEventRange(ievent,ievent);
133 fTSMaker ->ExecuteTask();
134
135 fPID ->SetEventRange(ievent,ievent);
136 fPID ->ExecuteTask();
137
138 AliPHOSGetter *gime = AliPHOSGetter::Instance();
139 TClonesArray *recParticles = gime->RecParticles();
140 Int_t nOfRecParticles = recParticles->GetEntries();
141 for (Int_t recpart=0; recpart<nOfRecParticles; recpart++) {
142 AliESDCaloTrack *ct = new AliESDCaloTrack((AliPHOSRecParticle*)recParticles->At(recpart));
143 event->AddCaloTrack(ct);
144 }
145
146}
147//____________________________________________________________________________
7acf6008 148 void AliPHOSReconstructioner::Init()
149{
a4e98857 150 // initiliaze Reconstructioner if necessary: we can not do this in default constructor
7acf6008 151
152 if(!fIsInitialized){
85ef0957 153
81b0fcd1 154 fRecPointBranch="Default" ;
88cb7938 155 fClusterizer = new AliPHOSClusterizerv1(GetTitle(),fRecPointBranch.Data());
7acf6008 156 Add(fClusterizer) ;
157
81b0fcd1 158 fTSBranch="Default" ;
88cb7938 159 fTSMaker = new AliPHOSTrackSegmentMakerv1(GetTitle(),fTSBranch.Data());
7acf6008 160 Add(fTSMaker) ;
161
162
88cb7938 163 fRecPartBranch="Default";
164 fPID = new AliPHOSPIDv1(GetTitle(),fRecPartBranch.Data()) ;
7acf6008 165 Add(fPID) ;
166
167 fIsInitialized = kTRUE ;
88cb7938 168
7acf6008 169 }
170}
171//____________________________________________________________________________
172AliPHOSReconstructioner::~AliPHOSReconstructioner()
173{
baef0810 174 // Delete data members if any
7acf6008 175}
baef0810 176
90cceaf6 177void AliPHOSReconstructioner::Print()const {
baef0810 178 // Print reconstructioner data
179
21cd0c07 180 TString message ;
181 message = "-----------------AliPHOSReconstructioner---------------\n" ;
182 message += " Reconstruction of the header file %s\n" ;
183 message += " with the following modules:\n" ;
7acf6008 184
7acf6008 185 if(fClusterizer->IsActive()){
21cd0c07 186 message += " (+) %s to branch %s\n" ;
7acf6008 187 }
188
189 if(fTSMaker->IsActive()){
21cd0c07 190 message += " (+) %s to branch %s\n" ;
7acf6008 191 }
192
7acf6008 193 if(fPID->IsActive()){
21cd0c07 194 message += " (+) %s to branch %s\n" ;
7acf6008 195 }
21cd0c07 196 Info("Print", message.Data(),
88cb7938 197 GetTitle(),
21cd0c07 198 fClusterizer->GetName(), fRecPointBranch.Data(),
199 fTSMaker->GetName(), fTSBranch.Data() ,
200 fPID->GetName(), fRecPartBranch.Data() ) ;
51926850 201}
d7d3b67b 202
203//____________________________________________________________________________
204void AliPHOSReconstructioner::SetEventRange(Int_t first, Int_t last)
205{
206 // Set the event range to process
207 fFirstEvent=first;
208 fLastEvent=last;
209 fClusterizer->SetEventRange(fFirstEvent, fLastEvent) ;
210 fTSMaker->SetEventRange(fFirstEvent, fLastEvent) ;
211 fPID->SetEventRange(fFirstEvent, fLastEvent) ;
212}