]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSReconstructioner.cxx
Coding Convention Violations
[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,const TString taskName):
91 TTask("AliPHOSReconstructioner",evFoldName)
92 {
93   // Create a PHOS reconstructioner for the tasks defined by taskName
94   // "C" - clusterization
95   // "T" - track segment making
96   // "P" - PID
97
98   AliPHOSGetter::Instance(evFoldName) ; 
99
100   if (taskName.Contains("C")) {
101     fRecPointBranch=branchName ; 
102     fClusterizer = new AliPHOSClusterizerv1(evFoldName, GetTitle());
103     Add(fClusterizer);
104   }
105   
106   if (taskName.Contains("T")) {
107     fTSBranch=branchName ; 
108     fTSMaker     = new AliPHOSTrackSegmentMakerv1(evFoldName, GetTitle());
109     Add(fTSMaker) ;
110   }
111   
112   if (taskName.Contains("P")) {
113     fRecPartBranch=branchName ; 
114     fPID         = new AliPHOSPIDv1(evFoldName, GetTitle());
115     Add(fPID);
116   }
117   
118   fIsInitialized = kTRUE ;
119
120 //____________________________________________________________________________
121 void AliPHOSReconstructioner::Exec(Option_t *opt)
122 {
123   //check, if the names of branches, which should be made coincide with already
124   //existing
125   if (!opt) 
126     return ; 
127   if(!fIsInitialized)
128     Init() ;
129 }
130 //____________________________________________________________________________
131 void AliPHOSReconstructioner:: Clusters2Tracks(Int_t ievent, AliESD *event)
132 {
133   // Convert PHOS reconstructed particles into ESD object for event# ievent.
134   // ESD object is returned as an argument event
135
136   if(!fIsInitialized) Init() ;
137
138   fClusterizer->SetEventRange(ievent,ievent);
139   fClusterizer->ExecuteTask();
140
141   fTSMaker    ->SetEventRange(ievent,ievent);
142   fTSMaker    ->ExecuteTask();
143   
144   fPID        ->SetEventRange(ievent,ievent);
145   fPID        ->ExecuteTask();
146
147   AliPHOSGetter *gime = AliPHOSGetter::Instance();
148   TClonesArray *recParticles = gime->RecParticles();
149   Int_t nOfRecParticles = recParticles->GetEntries();
150   for (Int_t recpart=0; recpart<nOfRecParticles; recpart++) {
151     AliESDCaloTrack *ct = new AliESDCaloTrack((AliPHOSRecParticle*)recParticles->At(recpart));
152     event->AddCaloTrack(ct);
153   }
154   
155 }
156 //____________________________________________________________________________
157  void AliPHOSReconstructioner::Init()
158 {
159   // initiliaze Reconstructioner if necessary: we can not do this in default constructor
160
161   if(!fIsInitialized){
162     
163     fRecPointBranch="Default" ; 
164     fClusterizer = new AliPHOSClusterizerv1(GetTitle(),fRecPointBranch.Data());
165     Add(fClusterizer) ;
166
167     fTSBranch="Default" ; 
168     fTSMaker     = new AliPHOSTrackSegmentMakerv1(GetTitle(),fTSBranch.Data());
169     Add(fTSMaker) ;
170
171
172     fRecPartBranch="Default"; 
173     fPID         = new AliPHOSPIDv1(GetTitle(),fRecPartBranch.Data()) ;
174     Add(fPID) ;
175     
176     fIsInitialized = kTRUE ;
177     
178   }
179
180 //____________________________________________________________________________
181 AliPHOSReconstructioner::~AliPHOSReconstructioner()
182 {
183   // Delete data members if any
184
185
186 void AliPHOSReconstructioner::Print()const {
187   // Print reconstructioner data  
188
189   TString message ; 
190   message  = "-----------------AliPHOSReconstructioner---------------\n" ;
191   message += " Reconstruction of the header file %s\n" ;
192   message += " with the following modules:\n" ;
193
194   if(fClusterizer->IsActive()){
195     message += "   (+)   %s to branch %s\n" ;
196   }
197
198   if(fTSMaker->IsActive()){
199     message += "   (+)   %s to branch %s\n" ; 
200   }
201
202   if(fPID->IsActive()){
203     message += "   (+)   %s to branch %s\n" ;  
204   }
205   Info("Print", message.Data(), 
206        GetTitle(), 
207        fClusterizer->GetName(), fRecPointBranch.Data(), 
208        fTSMaker->GetName(), fTSBranch.Data() , 
209        fPID->GetName(), fRecPartBranch.Data() ) ; 
210 }
211
212 //____________________________________________________________________________
213 void AliPHOSReconstructioner::SetEventRange(Int_t first, Int_t last)
214 {
215   // Set the event range to process
216   fFirstEvent=first; 
217   fLastEvent=last; 
218   fClusterizer->SetEventRange(fFirstEvent, fLastEvent) ; 
219   fTSMaker->SetEventRange(fFirstEvent, fLastEvent) ;
220   fPID->SetEventRange(fFirstEvent, fLastEvent) ;
221 }