]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSReconstructioner.cxx
oops
[u/mrichter/AliRoot.git] / PHOS / AliPHOSReconstructioner.cxx
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
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 
31 //  TreeR::AliPHOSClusterizer with the same title as the branch containing the RecPoints. //  TTree does not support overwriting, therefore one can not produce several 
32 //  branches with the same names and titles - use different titles.
33 //
34 //  Use case: 
35 //
36 //  root [0] AliPHOSReconstructioner * r = new AliPHOSReconstructioner("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("AliPHOSClusterizer","Local max cut 0.02") 
50 //             // means that will use already generated Digits and produce only RecPoints, 
51 //             // TS and RecParticles 
52 //
53 //             // And finally one can call ExecuteTask() with the following options
54 //  root [5] r->ExecuteTask("debug all timing")
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
58 ///////////////////////////////////////////////////////////////////////////////////////////////////
59
60 // --- ROOT system ---
61
62 // --- Standard library ---
63
64 // --- AliRoot header files ---
65 #include "AliESD.h"
66 #include "AliESDCaloTrack.h"
67 #include "AliPHOSReconstructioner.h"
68 #include "AliPHOSClusterizerv1.h"
69 #include "AliPHOSTrackSegmentMakerv1.h"
70 #include "AliPHOSPIDv1.h"
71 #include "AliPHOSGetter.h"
72
73
74 ClassImp(AliPHOSReconstructioner)
75
76 //____________________________________________________________________________
77   AliPHOSReconstructioner::AliPHOSReconstructioner():TTask("AliPHOSReconstructioner","")
78 {
79   // ctor
80   fClusterizer = 0 ;
81   fTSMaker     = 0 ;
82   fPID         = 0 ; 
83   fFirstEvent  = 0 ; 
84   fLastEvent   = -1 ; 
85   fIsInitialized = kFALSE ;
86
87
88
89 //____________________________________________________________________________
90 AliPHOSReconstructioner::AliPHOSReconstructioner(const char* evFoldName,const char * branchName):
91 TTask("AliPHOSReconstructioner",evFoldName)
92 {
93   // ctor
94
95   AliPHOSGetter::Instance(evFoldName) ; 
96
97   fRecPointBranch=branchName ; 
98   fClusterizer = new AliPHOSClusterizerv1(evFoldName, GetTitle());
99   Add(fClusterizer);
100   
101   fTSBranch=branchName ; 
102   fTSMaker     = new AliPHOSTrackSegmentMakerv1(evFoldName, GetTitle());
103   Add(fTSMaker) ;
104   
105   fRecPartBranch=branchName ; 
106   fPID         = new AliPHOSPIDv1(evFoldName, GetTitle());
107   Add(fPID);
108   
109   fIsInitialized = kTRUE ;
110
111 //____________________________________________________________________________
112 void AliPHOSReconstructioner::Exec(Option_t *opt)
113 {
114   //check, if the names of branches, which should be made coincide with already
115   //existing
116   if (!opt) 
117     return ; 
118   if(!fIsInitialized)
119     Init() ;
120 }
121 //____________________________________________________________________________
122 void 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 //____________________________________________________________________________
148  void AliPHOSReconstructioner::Init()
149 {
150   // initiliaze Reconstructioner if necessary: we can not do this in default constructor
151
152   if(!fIsInitialized){
153     
154     fRecPointBranch="Default" ; 
155     fClusterizer = new AliPHOSClusterizerv1(GetTitle(),fRecPointBranch.Data());
156     Add(fClusterizer) ;
157
158     fTSBranch="Default" ; 
159     fTSMaker     = new AliPHOSTrackSegmentMakerv1(GetTitle(),fTSBranch.Data());
160     Add(fTSMaker) ;
161
162
163     fRecPartBranch="Default"; 
164     fPID         = new AliPHOSPIDv1(GetTitle(),fRecPartBranch.Data()) ;
165     Add(fPID) ;
166     
167     fIsInitialized = kTRUE ;
168     
169   }
170
171 //____________________________________________________________________________
172 AliPHOSReconstructioner::~AliPHOSReconstructioner()
173 {
174   // Delete data members if any
175
176
177 void AliPHOSReconstructioner::Print()const {
178   // Print reconstructioner data  
179
180   TString message ; 
181   message  = "-----------------AliPHOSReconstructioner---------------\n" ;
182   message += " Reconstruction of the header file %s\n" ;
183   message += " with the following modules:\n" ;
184
185   if(fClusterizer->IsActive()){
186     message += "   (+)   %s to branch %s\n" ;
187   }
188
189   if(fTSMaker->IsActive()){
190     message += "   (+)   %s to branch %s\n" ; 
191   }
192
193   if(fPID->IsActive()){
194     message += "   (+)   %s to branch %s\n" ;  
195   }
196   Info("Print", message.Data(), 
197        GetTitle(), 
198        fClusterizer->GetName(), fRecPointBranch.Data(), 
199        fTSMaker->GetName(), fTSBranch.Data() , 
200        fPID->GetName(), fRecPartBranch.Data() ) ; 
201 }
202
203 //____________________________________________________________________________
204 void 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 }