]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSReconstructioner.cxx
Add method Clusters2Tracks
[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 produced SDigits, Digits etc.
56 //             // deb all - prints in addition list of made SDigits, digits etc.
57 //             // timing  - prints benchmarking results
58 ///////////////////////////////////////////////////////////////////////////////////////////////////
59
60 // --- ROOT system ---
61
62 // --- Standard library ---
63 #include "Riostream.h"
64
65 // --- AliRoot header files ---
66 #include "AliRunLoader.h"
67 #include "AliESD.h"
68 #include "AliESDCaloTrack.h"
69 #include "AliPHOSReconstructioner.h"
70 #include "AliPHOSClusterizerv1.h"
71 #include "AliPHOSDigitizer.h"
72 #include "AliPHOSSDigitizer.h"
73 #include "AliPHOSTrackSegmentMakerv1.h"
74 #include "AliPHOSPIDv1.h"
75 #include "AliPHOSGetter.h"
76
77 #include "AliPHOSLoader.h"
78
79 ClassImp(AliPHOSReconstructioner)
80
81 //____________________________________________________________________________
82   AliPHOSReconstructioner::AliPHOSReconstructioner():TTask("AliPHOSReconstructioner","")
83 {
84   // ctor
85   fDigitizer   = 0 ;
86   fClusterizer = 0 ;
87   fTSMaker     = 0 ;
88   fPID         = 0 ; 
89   fSDigitizer  = 0 ;
90
91   fIsInitialized = kFALSE ;
92
93
94
95 //____________________________________________________________________________
96 AliPHOSReconstructioner::AliPHOSReconstructioner(const char* evFoldName,const char * branchName):
97 TTask("AliPHOSReconstructioner",evFoldName)
98 {
99   // ctor
100   AliRunLoader* rl = AliRunLoader::GetRunLoader(evFoldName);
101   if (rl == 0x0)
102    {
103      Fatal("AliPHOSReconstructioner","Can not get Run Loader from folder %s.",evFoldName);
104    } 
105   if (rl->GetAliRun() == 0x0)
106    {
107      delete gAlice;
108      gAlice = 0x0;
109      rl->LoadgAlice();
110      gAlice = rl->GetAliRun();
111    }
112
113   AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
114   if (gime == 0x0)
115    {
116      Error("AliPHOSReconstructioner","Can not get PHOS Loader");
117      return;  
118    }
119   
120   TString galicefn = rl->GetFileName();
121   TString method("AliPHOSReconstructioner::AliPHOSReconstructioner(");
122   method = (((method + evFoldName)+",")+branchName)+"): ";
123   
124   fSDigitsBranch= branchName; 
125   
126   //P.Skowronski remark
127   // Tasks has default fixed names
128   // other tasks can be added, even runtime
129   // with arbitrary name. See AliDataLoader::
130   cout<<"\n\n\n";
131   cout<<method<<"\n\nCreating SDigitizer\n";
132   fSDigitizer  = new AliPHOSSDigitizer(galicefn,GetTitle());
133   Add(fSDigitizer);
134   gime->PostSDigitizer(fSDigitizer);
135
136   fDigitsBranch=branchName ;
137   cout<<"\n\n\n";
138   cout<<method<<"\n\nCreating Digitizer\n";
139   fDigitizer   = new AliPHOSDigitizer(galicefn,GetTitle()) ;
140   Add(fDigitizer) ;
141   gime->PostDigitizer(fDigitizer);
142
143   fRecPointBranch=branchName ; 
144   cout<<"\n\n\n";
145   cout<<method<<"Creating Clusterizer\n";
146   fClusterizer = new AliPHOSClusterizerv1(galicefn,GetTitle());
147   Add(fClusterizer);
148   gime->PostReconstructioner(fClusterizer);
149   
150   fTSBranch=branchName ; 
151   fTSMaker     = new AliPHOSTrackSegmentMakerv1(galicefn,GetTitle());
152   Add(fTSMaker) ;
153   gime->PostTracker(fTSMaker);
154
155   
156   fRecPartBranch=branchName ; 
157   cout<<"\n\n\n";
158   cout<<method<<"Creating PID\n";
159   fPID         = new AliPHOSPIDv1(galicefn,GetTitle());
160   Add(fPID);
161   cout<<"\nFINISHED \n\n"<<method;
162   
163   fIsInitialized = kTRUE ;
164
165 //____________________________________________________________________________
166 void AliPHOSReconstructioner::Exec(Option_t *opt)
167 {
168   //check, if the names of branches, which should be made conicide with already
169   //existing
170   if (!opt) 
171     return ; 
172   if(!fIsInitialized)
173     Init() ;
174 }
175 //____________________________________________________________________________
176 void AliPHOSReconstructioner:: Clusters2Tracks(Int_t ievent, AliESD *event)
177 {
178   // Convert PHOS reconstructed particles into ESD object for event# ievent.
179   // ESD object is returned as an argument event
180
181   if(!fIsInitialized) Init() ;
182
183   fClusterizer->SetEventRange(ievent,ievent);
184   fClusterizer->ExecuteTask();
185
186   fTSMaker    ->SetEventRange(ievent,ievent);
187   fTSMaker    ->ExecuteTask();
188   
189   fPID        ->SetEventRange(ievent,ievent);
190   fPID        ->ExecuteTask();
191
192   AliPHOSGetter *gime = AliPHOSGetter::Instance();
193   TClonesArray *recParticles = gime->RecParticles();
194   Int_t nOfRecParticles = recParticles->GetEntries();
195   for (Int_t recpart=0; recpart<nOfRecParticles; recpart++) {
196     AliESDCaloTrack *ct = new AliESDCaloTrack((AliPHOSRecParticle*)recParticles->At(recpart));
197     event->AddCaloTrack(ct);
198   }
199   
200 }
201 //____________________________________________________________________________
202  void AliPHOSReconstructioner::Init()
203 {
204   // initiliaze Reconstructioner if necessary: we can not do this in default constructor
205
206   if(!fIsInitialized){
207     // Initialisation
208
209     fSDigitsBranch="Default" ; 
210     fSDigitizer  = new AliPHOSSDigitizer(GetTitle(),fSDigitsBranch.Data()) ; 
211     Add(fSDigitizer) ;
212
213     fDigitsBranch="Default" ; 
214     fDigitizer   = new AliPHOSDigitizer(GetTitle(),fDigitsBranch.Data());
215     Add(fDigitizer) ;
216
217     fRecPointBranch="Default" ; 
218     fClusterizer = new AliPHOSClusterizerv1(GetTitle(),fRecPointBranch.Data());
219     Add(fClusterizer) ;
220
221     fTSBranch="Default" ; 
222     fTSMaker     = new AliPHOSTrackSegmentMakerv1(GetTitle(),fTSBranch.Data());
223     Add(fTSMaker) ;
224
225
226     fRecPartBranch="Default"; 
227     fPID         = new AliPHOSPIDv1(GetTitle(),fRecPartBranch.Data()) ;
228     Add(fPID) ;
229     
230     fIsInitialized = kTRUE ;
231     
232   }
233
234 //____________________________________________________________________________
235 AliPHOSReconstructioner::~AliPHOSReconstructioner()
236 {
237   // Delete data members if any
238
239
240 void AliPHOSReconstructioner::Print()const {
241   // Print reconstructioner data  
242
243   TString message ; 
244   message  = "-----------------AliPHOSReconstructioner---------------\n" ;
245   message += " Reconstruction of the header file %s\n" ;
246   message += " with the following modules:\n" ;
247
248   if(fSDigitizer->IsActive()){
249     message += "   (+)   %s to branch %s\n" ; 
250   }
251   if(fDigitizer->IsActive()){
252     message += "   (+)   %s to branch %s\n" ; 
253   }
254   
255   if(fClusterizer->IsActive()){
256     message += "   (+)   %s to branch %s\n" ;
257   }
258
259   if(fTSMaker->IsActive()){
260     message += "   (+)   %s to branch %s\n" ; 
261   }
262
263   if(fPID->IsActive()){
264     message += "   (+)   %s to branch %s\n" ;  
265   }
266   Info("Print", message.Data(), 
267        GetTitle(), 
268        fSDigitizer->GetName(), fSDigitsBranch.Data(), 
269        fDigitizer->GetName(), fDigitsBranch.Data() , 
270        fClusterizer->GetName(), fRecPointBranch.Data(), 
271        fTSMaker->GetName(), fTSBranch.Data() , 
272        fPID->GetName(), fRecPartBranch.Data() ) ; 
273 }