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