Removed global's to comply with Coding Conventions
[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.h>
33
34 // --- AliRoot header files ---
35
36 #include "AliPHOSReconstructioner.h"
37 #include "AliPHOSClusterizer.h"
38 #include "AliPHOSFastRecParticle.h"
39
40 ClassImp(AliPHOSReconstructioner)
41
42 //____________________________________________________________________________
43 AliPHOSReconstructioner::AliPHOSReconstructioner(AliPHOSClusterizer * Clusterizer, 
44                                                  AliPHOSTrackSegmentMaker * Tracker,
45                                                  AliPHOSPID * Pid)
46 {
47   // ctor
48   
49   fClusterizer        = Clusterizer ;
50   fTrackSegmentMaker  = Tracker ;
51   fPID                = Pid ; 
52   fDebugReconstruction = kFALSE ;
53
54
55
56 //____________________________________________________________________________
57  void AliPHOSReconstructioner::Init(AliPHOSClusterizer * Clusterizer, 
58                                                  AliPHOSTrackSegmentMaker * Tracker,
59                                                  AliPHOSPID * Pid)
60 {
61   fClusterizer        = Clusterizer ;
62   fTrackSegmentMaker  = Tracker ;
63   fPID                = Pid ; 
64   fDebugReconstruction = kFALSE ;
65
66
67 //____________________________________________________________________________
68  void AliPHOSReconstructioner::Make(DigitsList * dl, 
69                                     AliPHOSRecPoint::RecPointsList * emccl, 
70                                     AliPHOSRecPoint::RecPointsList * ppsdl, 
71                                     AliPHOSTrackSegment::TrackSegmentsList * trsl, 
72                                     AliPHOSRecParticle::RecParticlesList * rpl)
73 {
74   // Launches the Reconstruction process in the sequence: Make the reconstructed poins (clusterize)
75   //                                                      Make the track segments 
76   //                                                      Make the reconstructed particles
77   Int_t index ; 
78   // Digit Debuging
79   if  (fDebugReconstruction)     {
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     for (index = 0 ; index < dl->GetEntries() ; index++) {
93       digit = (AliPHOSDigit * )  dl->At(index) ;
94       calorimeter = fClusterizer->IsInEmc(digit);
95       if (calorimeter) factor =1000. ; else factor=1000000.;
96       cout << "DebugReconstruction>>>  " << 
97         setw(8)  <<  digit->GetId() << " "  <<
98         setw(3)  <<  calorimeter <<  
99         setw(10) <<  factor*fClusterizer->Calibrate(digit->GetAmp()) <<       "  "  <<                   
100         setw(6)  <<  digit->GetIndexInList() << "  "  << 
101         setw(5)  <<  digit->GetNprimary() <<"  "  << 
102         setw(5)  <<  digit->GetPrimary(1) <<"  "  << 
103         setw(5)  <<  digit->GetPrimary(2) <<"  "  << 
104         setw(5)  <<  digit->GetPrimary(3) << endl;       
105     }
106     
107   }
108
109
110
111   // Making Clusters
112   if  (fDebugReconstruction)  cout << "DebugReconstruction>>> Start making reconstructed points (clusterizing)" << endl;
113   fClusterizer->MakeClusters(dl, emccl, ppsdl);
114
115   // mark the position of the RecPoints in the array
116   AliPHOSEmcRecPoint * emcrp ; 
117   for (index = 0 ; index < emccl->GetEntries() ; index++) {
118     emcrp = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
119     emcrp->SetIndexInList(index) ; 
120   }
121   AliPHOSPpsdRecPoint * ppsdrp ; 
122   for (index = 0 ; index < ppsdl->GetEntries() ; index++) {
123     ppsdrp = (AliPHOSPpsdRecPoint * )ppsdl->At(index) ; 
124     ppsdrp->SetIndexInList(index) ; 
125   }
126   
127   if  (fDebugReconstruction) 
128     {
129       cout << "DebugReconstruction>>> Cluster emc list entries is " <<    emccl->GetEntries() << endl ;
130       AliPHOSEmcRecPoint * recpoint;
131       cout << "DebugReconstruction>>> Module "  << 
132         "Ene(MeV) "             <<                         
133         "Index "                    << 
134         "Multi "                    << 
135         "   X     "                      << 
136         "   Y     "                      << 
137         "   Z    "                      << 
138         " Lambda 1   "                     <<  
139         " Lambda 2   "                     <<
140         "MaxEnergy(MeV) "                 <<
141         "Nprim "                 <<
142         "Prim1 "                 <<
143         "Prim2 "                 <<
144         "Prim3 "                 << endl;  
145       for (index = 0 ; index < emccl->GetEntries() ; index++) {
146         recpoint = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
147         TVector3  locpos;  recpoint->GetLocalPosition(locpos);
148         Float_t lambda[2]; recpoint->GetElipsAxis(lambda);
149         Int_t * primaries; 
150         Int_t nprimaries;
151         primaries = recpoint->GetPrimaries(nprimaries);
152         cout << "DebugReconstruction>>>  " << 
153           setw(2) <<recpoint->GetPHOSMod() << " "  << 
154           setw(9) << 1000.*recpoint->GetTotalEnergy() <<       " "  <<                   
155           setw(6) <<  recpoint->GetIndexInList() << " "  << 
156           setw(5) <<  recpoint->GetMultiplicity() <<" "  << 
157           setw(8) <<  locpos.X() <<" "  << 
158           setw(8) <<  locpos.Y() <<" "  << 
159           setw(8) <<  locpos.Z() << " " <<
160           setw(10) << lambda[0] << "  " <<
161           setw(10) << lambda[1] << "  " <<
162           setw(9) << 1000*recpoint->GetMaximalEnergy() << "  " << 
163           setw(9) << nprimaries << "  "  <<
164           setw(4) << primaries[0] << "  "  <<
165           setw(4) << primaries[1] << "  "  <<
166           setw(4) << primaries[2] << "  "  << endl;              
167       }
168       
169       cout << "DebugReconstruction>>> Cluster ppsd list entries is " <<    ppsdl->GetEntries() << endl ;
170       AliPHOSPpsdRecPoint * ppsdrecpoint;
171       Text_t detector[4];
172       cout << "DebugReconstruction>>> Module "  << 
173         "Det     "             <<      
174         "Ene(KeV) "             <<                         
175         "Index "                    << 
176         "Multi "                    << 
177         "   X     "                      << 
178         "   Y     "                      << 
179         "   Z         "                      << 
180         "Nprim "                 <<
181         "Prim1 "                 <<
182         "Prim2 "                 <<
183         "Prim3 "                 << endl;  
184       for (index = 0 ; index < ppsdl->GetEntries() ; index++) {
185         ppsdrecpoint = (AliPHOSPpsdRecPoint * ) ppsdl->At(index) ; 
186         TVector3  locpos; ppsdrecpoint->GetLocalPosition(locpos);
187         Int_t * primaries; 
188         Int_t nprimaries;
189         if (ppsdrecpoint->GetUp()) 
190           strcpy(detector, "CPV"); 
191         else 
192           strcpy(detector, "PC ");
193         primaries = ppsdrecpoint->GetPrimaries(nprimaries);
194         cout << "DebugReconstruction>>> " << 
195           setw(4) << ppsdrecpoint->GetPHOSMod() << "  "  << 
196           setw(4)  << detector << " "      <<
197           setw(9) << 1000000.*ppsdrecpoint->GetTotalEnergy() <<       " "  <<             
198           setw(6) <<  ppsdrecpoint->GetIndexInList() << " "  << 
199           setw(5) <<  ppsdrecpoint->GetMultiplicity() <<" "  << 
200           setw(8) <<  locpos.X() <<" "  << 
201           setw(8) <<  locpos.Y() <<" "  << 
202           setw(8) <<  locpos.Z() << " " <<
203           setw(9) << nprimaries << "  "  <<
204           setw(4) << primaries[0] << "  "  <<
205           setw(4) << primaries[1] << "  "  <<
206           setw(4) << primaries[2] << "  "  << endl;              
207       }
208     }  
209   
210   
211   if  (fDebugReconstruction)  cout << "DebugReconstruction>>>> Start making track segments(unfolding+tracksegments)" << endl;
212   fTrackSegmentMaker->MakeTrackSegments(dl, emccl, ppsdl, trsl) ;   
213   
214   // mark the position of the TrackSegments in the array
215   AliPHOSTrackSegment * trs ; 
216   for (index = 0 ; index < trsl->GetEntries() ; index++) {
217     trs = (AliPHOSTrackSegment * )trsl->At(index) ; 
218     trs->SetIndexInList(index) ; 
219   }
220   if  (fDebugReconstruction){
221     cout << "DebugReconstruction>>> Track segment list entries is " <<    trsl->GetEntries() << endl ;
222     cout << "DebugReconstruction>>> Module "  << 
223       "Ene(KeV) "             <<                         
224       "Index "                    << 
225       "   X      "                      << 
226       "   Y      "                      << 
227       "   Z       "                      <<
228       " rX        "                      << 
229       " rY        "                      << 
230       " rZ      "                               << 
231       "Nprim "                 <<
232       "Prim1 "                 <<
233       "Prim2 "                 <<
234       "Prim3 "                 << endl;  
235     
236     for (index = 0 ; index < trsl->GetEntries() ; index++) {
237       trs = (AliPHOSTrackSegment * )trsl->At(index) ; 
238       TVector3 locpos; trs->GetPosition(locpos);
239       Int_t * primaries; 
240       Int_t nprimaries;
241       primaries = trs->GetPrimariesEmc(nprimaries);
242       cout << "DebugReconstruction>>> " << 
243         setw(4) << trs->GetPHOSMod() << "  "  << 
244         setw(9) << 1000.*trs->GetEnergy() <<       " "  <<             
245         setw(3) <<  trs->GetIndexInList() << " "  <<  
246         setw(9) <<  locpos.X() <<" "  << 
247         setw(9) <<  locpos.Y() <<" "  << 
248         setw(9) <<  locpos.Z() << " " <<
249         setw(10) <<  (trs->GetMomentumDirection()).X() << " " <<
250         setw(10) <<  (trs->GetMomentumDirection()).Y() << " " <<
251         setw(10) <<  (trs->GetMomentumDirection()).Z() << " " <<
252         setw(4) << nprimaries << "  "  <<
253         setw(4) << primaries[0] << "  "  <<
254         setw(4) << primaries[1] << "  "  <<
255         setw(4) << primaries[2] << "  "  << endl;
256     }
257     
258   }
259   if  (fDebugReconstruction)  cout << "DebugReconstruction>>>> Start making reconstructed particles" << endl;
260   
261   fPID->MakeParticles(trsl, rpl) ; 
262   
263   // mark the position of the RecParticles in the array
264   AliPHOSRecParticle * rp ; 
265   for (index = 0 ; index < rpl->GetEntries() ; index++) {
266     rp = (AliPHOSRecParticle * )rpl->At(index) ; 
267     rp->SetIndexInList(index) ; 
268   }
269   //Debugger of RecParticles
270  if  (fDebugReconstruction){
271     cout << "DebugReconstruction>>>  Reconstructed particle list entries is " <<    rpl->GetEntries() << endl ;
272     cout << "DebugReconstruction>>> Module "  << 
273       "    PARTICLE     "   <<
274       "Ene(KeV) "             <<                         
275       "Index "                    << 
276       "   X      "                      << 
277       "   Y      "                      << 
278       "   Z       "                      <<
279       "Nprim "                 <<
280       "Prim1 "                 <<
281       "Prim2 "                 <<
282       "Prim3 "                 << endl;  
283     for (index = 0 ; index < rpl->GetEntries() ; index++) {
284       rp = (AliPHOSRecParticle * ) rpl->At(index) ;       
285       TVector3 locpos; (rp->GetPHOSTrackSegment())->GetPosition(locpos);
286       Int_t * primaries; 
287       Int_t nprimaries;
288       Text_t particle[11];
289       primaries = (rp->GetPHOSTrackSegment())->GetPrimariesEmc(nprimaries);
290       switch(rp->GetType())
291         {
292         case  AliPHOSFastRecParticle::kNEUTRALEM:
293           strcpy( particle, "NEUTRAL_EM");
294           break;
295         case  AliPHOSFastRecParticle::kNEUTRALHA:
296           strcpy(particle, "NEUTRAL_HA");
297           break;
298         case  AliPHOSFastRecParticle::kGAMMA:
299           strcpy(particle, "GAMMA");
300           break ;
301         case  AliPHOSFastRecParticle::kGAMMAHA: 
302           strcpy(particle, "GAMMA_H");
303           break ;
304         case  AliPHOSFastRecParticle::kABSURDEM:
305           strcpy(particle, "ABSURD_EM") ;
306           break ;
307         case  AliPHOSFastRecParticle::kABSURDHA:
308           strcpy(particle, "ABSURD_HA") ;
309           break ;       
310         case  AliPHOSFastRecParticle::kELECTRON:
311           strcpy(particle, "ELECTRON") ;
312           break ;
313         case  AliPHOSFastRecParticle::kCHARGEDHA:
314           strcpy(particle, "CHARGED_HA") ;
315           break ; 
316         }
317       
318       cout << "DebugReconstruction>>> " << 
319         setw(4) << (rp->GetPHOSTrackSegment())->GetPHOSMod() << "  "  <<
320         setw(15) << particle << "  " <<
321         setw(9) << 1000.*(rp->GetPHOSTrackSegment())->GetEnergy() <<       " "  <<             
322         setw(3) <<  rp->GetIndexInList() << " "  <<  
323         setw(9) <<  locpos.X() <<" "  << 
324         setw(9) <<  locpos.Y() <<" "  << 
325         setw(9) <<  locpos.Z() << " " <<
326         setw(4) << nprimaries << "  "  <<
327         setw(4) << primaries[0] << "  "  <<
328         setw(4) << primaries[1] << "  "  <<
329         setw(4) << primaries[2] << "  "  << endl;
330     }
331     
332   }
333
334
335 }