17d3b06930f36703f99ca7f944c4053c2690bee1
[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 //  Algorithm class for the reconstruction: clusterizer
20 //                                          track segment maker
21 //                                          particle identifier   
22 //                  
23 //*-- Author: Gines Martinez & Yves Schutz (SUBATECH)
24
25
26 // --- ROOT system ---
27
28 #include "TClonesArray.h"
29
30 // --- Standard library ---
31
32 #include <iomanip>
33
34 // --- AliRoot header files ---
35
36 #include "AliPHOSReconstructioner.h"
37 #include "AliPHOSClusterizer.h"
38
39 ClassImp(AliPHOSReconstructioner)
40
41 //____________________________________________________________________________
42 AliPHOSReconstructioner::AliPHOSReconstructioner(AliPHOSClusterizer * Clusterizer, 
43                                                  AliPHOSTrackSegmentMaker * Tracker,
44                                                  AliPHOSPID * Pid)
45 {
46   // ctor
47   
48   fClusterizer        = Clusterizer ;
49   fTrackSegmentMaker  = Tracker ;
50   fPID                = Pid ; 
51   fDebugReconstruction = kFALSE ;
52
53
54
55 //____________________________________________________________________________
56  void AliPHOSReconstructioner::Init(AliPHOSClusterizer * Clusterizer, 
57                                                  AliPHOSTrackSegmentMaker * Tracker,
58                                                  AliPHOSPID * Pid)
59 {
60   fClusterizer        = Clusterizer ;
61   fTrackSegmentMaker  = Tracker ;
62   fPID                = Pid ; 
63   fDebugReconstruction = kFALSE ;
64
65
66 //____________________________________________________________________________
67  void AliPHOSReconstructioner::Make(DigitsList * dl, RecPointsList * emccl, RecPointsList * ppsdl, 
68                                      TrackSegmentsList * trsl, RecParticlesList * rpl)
69 {
70   // Launches the Reconstruction process in the sequence: Make the reconstructed poins (clusterize)
71   //                                                      Make the track segments 
72   //                                                      Make the reconstructed particles
73
74   Int_t index ; 
75   // Digit Debuging
76
77
78   if  (fDebugReconstruction) 
79     {
80       cout << ">>>>>>>>>>>>>>>>>>>>>> DebugReconstruction  <<<<<<<<<<<<<<<<<<<<<<<<<<"  << endl ;
81       cout << "DebugReconstruction>>> Digit list entries is " <<    dl->GetEntries() << endl ;
82       AliPHOSDigit * digit;
83       Bool_t calorimeter ;
84       Float_t factor;
85       cout << "DebugReconstruction>>>    Vol Id " << 
86           " Ene(MeV, KeV) "             <<                         
87           " Index "                    << 
88           " Nprim "                     << 
89           " Prim1 "                      << 
90           " Prim2 "                      << 
91           " Prim3 "                      <<  endl;  
92
93       for (index = 0 ; index < dl->GetEntries() ; index++) {
94         digit = (AliPHOSDigit * )  dl->At(index) ;
95         calorimeter = fClusterizer->IsInEmc(digit);
96         if (calorimeter) factor =1000. ; else factor=1000000.;
97         cout << "DebugReconstruction>>>  " << 
98           setw(8)  <<  digit->GetId() << " "  <<
99           setw(3)  <<  calorimeter <<  
100           setw(10) <<  factor*fClusterizer->Calibrate(digit->GetAmp()) <<       "  "  <<                   
101           setw(6)  <<  digit->GetIndexInList() << "  "  << 
102           setw(5)  <<  digit->GetNprimary() <<"  "  << 
103           setw(5)  <<  digit->GetPrimary(1) <<"  "  << 
104           setw(5)  <<  digit->GetPrimary(2) <<"  "  << 
105           setw(5)  <<  digit->GetPrimary(3) << endl;     
106       }
107
108     }
109
110
111
112   // Making Clusters
113   if  (fDebugReconstruction)  cout << "DebugReconstruction>>> Start making reconstructed points (clusterizing)" << endl;
114   fClusterizer->MakeClusters(dl, emccl, ppsdl);
115
116   // mark the position of the RecPoints in the array
117   AliPHOSEmcRecPoint * emcrp ; 
118   for (index = 0 ; index < emccl->GetEntries() ; index++) {
119     emcrp = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
120     emcrp->SetIndexInList(index) ; 
121   }
122   AliPHOSPpsdRecPoint * ppsdrp ; 
123   for (index = 0 ; index < ppsdl->GetEntries() ; index++) {
124     ppsdrp = (AliPHOSPpsdRecPoint * )ppsdl->At(index) ; 
125     ppsdrp->SetIndexInList(index) ; 
126   }
127
128   if  (fDebugReconstruction) 
129     {
130       cout << "DebugReconstruction>>> Cluster emc list entries is " <<    emccl->GetEntries() << endl ;
131       AliPHOSEmcRecPoint * recpoint;
132       cout << "DebugReconstruction>>> Module "  << 
133           "Ene(MeV) "             <<                         
134           "Index "                    << 
135           "Multi "                    << 
136           "   X     "                      << 
137           "   Y     "                      << 
138           "   Z    "                      << 
139           " Lambda 1   "                     <<  
140           " Lambda 2   "                     <<
141           "MaxEnergy(MeV) "                 <<
142         "Nprim "                 <<
143         "Prim1 "                 <<
144         "Prim2 "                 <<
145         "Prim3 "                 << endl;  
146       for (index = 0 ; index < emccl->GetEntries() ; index++) {
147         recpoint = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
148         TVector3  locpos;  recpoint->GetLocalPosition(locpos);
149         Float_t lambda[2]; recpoint->GetElipsAxis(lambda);
150         Int_t * primaries; 
151         Int_t nprimaries;
152         primaries = recpoint->GetPrimaries(nprimaries);
153         cout << "DebugReconstruction>>>  " << 
154           setw(2) <<recpoint->GetPHOSMod() << " "  << 
155           setw(9) << 1000.*recpoint->GetTotalEnergy() <<       " "  <<                   
156           setw(6) <<  recpoint->GetIndexInList() << " "  << 
157           setw(5) <<  recpoint->GetMultiplicity() <<" "  << 
158           setw(8) <<  locpos.X() <<" "  << 
159           setw(8) <<  locpos.Y() <<" "  << 
160           setw(8) <<  locpos.Z() << " " <<
161           setw(10) << lambda[0] << "  " <<
162           setw(10) << lambda[1] << "  " <<
163           setw(9) << 1000*recpoint->GetMaximalEnergy() << "  " << 
164           setw(9) << nprimaries << "  "  <<
165           setw(4) << primaries[0] << "  "  <<
166           setw(4) << primaries[1] << "  "  <<
167           setw(4) << primaries[2] << "  "  << endl;              
168       }
169
170       cout << "DebugReconstruction>>> Cluster ppsd list entries is " <<    ppsdl->GetEntries() << endl ;
171       AliPHOSPpsdRecPoint * ppsdrecpoint;
172       Text_t detector[4];
173       cout << "DebugReconstruction>>> Module "  << 
174           "Det     "             <<      
175           "Ene(KeV) "             <<                         
176           "Index "                    << 
177           "Multi "                    << 
178           "   X     "                      << 
179           "   Y     "                      << 
180           "   Z         "                      << 
181         "Nprim "                 <<
182         "Prim1 "                 <<
183         "Prim2 "                 <<
184         "Prim3 "                 << endl;  
185       for (index = 0 ; index < ppsdl->GetEntries() ; index++) {
186         ppsdrecpoint = (AliPHOSPpsdRecPoint * ) ppsdl->At(index) ; 
187         TVector3  locpos; ppsdrecpoint->GetLocalPosition(locpos);
188         Int_t * primaries; 
189         Int_t nprimaries;
190         if (ppsdrecpoint->GetUp()) detector="CPV"; else detector="PC ";
191         primaries = ppsdrecpoint->GetPrimaries(nprimaries);
192         cout << "DebugReconstruction>>> " << 
193           setw(4) << ppsdrecpoint->GetPHOSMod() << "  "  << 
194           setw(4)  << detector << " "      <<
195           setw(9) << 1000000.*ppsdrecpoint->GetTotalEnergy() <<       " "  <<             
196           setw(6) <<  ppsdrecpoint->GetIndexInList() << " "  << 
197           setw(5) <<  ppsdrecpoint->GetMultiplicity() <<" "  << 
198           setw(8) <<  locpos.X() <<" "  << 
199           setw(8) <<  locpos.Y() <<" "  << 
200           setw(8) <<  locpos.Z() << " " <<
201           setw(9) << nprimaries << "  "  <<
202           setw(4) << primaries[0] << "  "  <<
203           setw(4) << primaries[1] << "  "  <<
204           setw(4) << primaries[2] << "  "  << endl;              
205       }
206     }  
207
208
209   if  (fDebugReconstruction)  cout << "DebugReconstruction>>>> Start making track segments(unfolding+tracksegments)" << endl;
210   fTrackSegmentMaker->MakeTrackSegments(dl, emccl, ppsdl, trsl) ;   
211
212   // mark the position of the TrackSegments in the array
213   AliPHOSTrackSegment * trs ; 
214   for (index = 0 ; index < trsl->GetEntries() ; index++) {
215     trs = (AliPHOSTrackSegment * )trsl->At(index) ; 
216     trs->SetIndexInList(index) ; 
217   }
218   if  (fDebugReconstruction){
219     cout << "DebugReconstruction>>> Track segment list entries is " <<    trsl->GetEntries() << endl ;
220     cout << "DebugReconstruction>>> Module "  << 
221       "Ene(KeV) "             <<                         
222       "Index "                    << 
223       "   X      "                      << 
224       "   Y      "                      << 
225       "   Z       "                      <<
226       " rX        "                      << 
227       " rY        "                      << 
228       " rZ      "                               << 
229       "Nprim "                 <<
230       "Prim1 "                 <<
231       "Prim2 "                 <<
232       "Prim3 "                 << endl;  
233
234     for (index = 0 ; index < trsl->GetEntries() ; index++) {
235       trs = (AliPHOSTrackSegment * )trsl->At(index) ; 
236       TVector3 locpos; trs->GetPosition(locpos);
237       Int_t * primaries; 
238       Int_t nprimaries;
239       primaries = trs->GetPrimariesEmc(nprimaries);
240       cout << "DebugReconstruction>>> " << 
241         setw(4) << trs->GetPHOSMod() << "  "  << 
242         setw(9) << 1000.*trs->GetEnergy() <<       " "  <<             
243         setw(3) <<  trs->GetIndexInList() << " "  <<  
244         setw(9) <<  locpos.X() <<" "  << 
245         setw(9) <<  locpos.Y() <<" "  << 
246         setw(9) <<  locpos.Z() << " " <<
247         setw(10) <<  (trs->GetMomentumDirection()).X() << " " <<
248         setw(10) <<  (trs->GetMomentumDirection()).Y() << " " <<
249         setw(10) <<  (trs->GetMomentumDirection()).Z() << " " <<
250         setw(4) << nprimaries << "  "  <<
251         setw(4) << primaries[0] << "  "  <<
252         setw(4) << primaries[1] << "  "  <<
253         setw(4) << primaries[2] << "  "  << endl;
254       }
255
256   }
257   if  (fDebugReconstruction)  cout << "DebugReconstruction>>>> Start making particles" << endl;
258   
259   fPID->MakeParticles(trsl, rpl) ; 
260   
261   // mark the position of the RecParticles in the array
262   AliPHOSRecParticle * rp ; 
263   for (index = 0 ; index < rpl->GetEntries() ; index++) {
264     rp = (AliPHOSRecParticle * )rpl->At(index) ; 
265     rp->SetIndexInList(index) ; 
266   }
267 }