]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSReconstructioner.cxx
772abdb3ed68fb285f779d9fef1a98f72aabde07
[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 #include "AliPHOSCpvRecPoint.h"
40
41 ClassImp(AliPHOSReconstructioner)
42
43 //____________________________________________________________________________
44 AliPHOSReconstructioner::AliPHOSReconstructioner(AliPHOSClusterizer * Clusterizer, 
45                                                  AliPHOSTrackSegmentMaker * Tracker,
46                                                  AliPHOSPID * Pid)
47 {
48   // ctor
49   
50   fClusterizer        = Clusterizer ;
51   fTrackSegmentMaker  = Tracker ;
52   fPID                = Pid ; 
53   fDebugReconstruction = kFALSE ;
54
55
56
57 //____________________________________________________________________________
58  void AliPHOSReconstructioner::Init(AliPHOSClusterizer * Clusterizer, 
59                                                  AliPHOSTrackSegmentMaker * Tracker,
60                                                  AliPHOSPID * Pid)
61 {
62   // Initialisation
63
64   fClusterizer        = Clusterizer ;
65   fTrackSegmentMaker  = Tracker ;
66   fPID                = Pid ; 
67   fDebugReconstruction = kFALSE ;
68
69
70 //____________________________________________________________________________
71  void AliPHOSReconstructioner::Make(DigitsList * dl, 
72                                     AliPHOSRecPoint::RecPointsList * emccl, 
73                                     AliPHOSRecPoint::RecPointsList * ppsdl, 
74                                     AliPHOSTrackSegment::TrackSegmentsList * trsl, 
75                                     AliPHOSRecParticle::RecParticlesList * rpl)
76 {
77   // Launches the Reconstruction process in the sequence: Make the reconstructed poins (clusterize)
78   //                                                      Make the track segments 
79   //                                                      Make the reconstructed particles
80   Int_t index ;   
81   if  (fDebugReconstruction)
82     cout << "\n\nDebugReconstruction>>> " << "Start making reconstructed points (clusterizing!!)" << endl;
83   
84   fClusterizer->MakeClusters(dl, emccl, ppsdl);
85   
86   if  (fDebugReconstruction){
87     cout << "DebugReconstruction>>> " << "AliPHOSReconstructioner: Digit list entries is " << dl->GetEntries() << endl ;
88     cout << "AliPHOSReconstructioner: Emc  list entries is " << emccl->GetEntries() << endl ;
89     cout << "AliPHOSReconstructioner: Ppsd list entries is " << ppsdl->GetEntries() << endl ;
90   }
91
92   // Digit Debuging
93   if  (fDebugReconstruction)     {
94     cout << ">>>>>>>>>>>>>>>>>>>>>> DebugReconstruction  <<<<<<<<<<<<<<<<<<<<<<<<<<"  << endl ;
95     cout << "DebugReconstruction>>> Digit list entries is " <<    dl->GetEntries() << endl ;
96     AliPHOSDigit * digit;
97     Bool_t calorimeter ;
98     Float_t factor;
99     cout << "DebugReconstruction>>>    Vol Id " << 
100       " Ene(MeV, KeV) "              <<                         
101       " Index "                      << 
102       " Nprim "                      << 
103       " Primaries list "             <<  endl;      
104     for (index = 0 ; index < dl->GetEntries() ; index++) {
105       digit = (AliPHOSDigit * )  dl->At(index) ;
106       calorimeter = fClusterizer->IsInEmc(digit);
107       if (calorimeter) factor =1000. ; else factor=1000000.;
108       cout << "DebugReconstruction>>>  " << 
109         setw(8)  <<  digit->GetId() << " "  <<
110         setw(3)  <<  (Int_t) calorimeter <<  
111         setw(10) <<  factor*fClusterizer->Calibrate(digit->GetAmp()) << "  "  <<                   
112         setw(6)  <<  digit->GetIndexInList() << "  "  << 
113         setw(5)  <<  digit->GetNprimary() <<"  ";
114       for (Int_t iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
115         cout << setw(5)  <<  digit->GetPrimary(iprimary+1) << " ";
116       cout << endl;      
117     }
118     
119   }
120
121
122
123   // Making Clusters
124   if  (fDebugReconstruction)  cout << "DebugReconstruction>>> Start making reconstructed points (clusterizing)" << endl;
125
126   // mark the position of the RecPoints in the array
127   AliPHOSEmcRecPoint * emcrp ; 
128   for (index = 0 ; index < emccl->GetEntries() ; index++) {
129     emcrp = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
130     emcrp->SetIndexInList(index) ; 
131   }
132   AliPHOSPpsdRecPoint * ppsdrp ; 
133   for (index = 0 ; index < ppsdl->GetEntries() ; index++) {
134     ppsdrp = (AliPHOSPpsdRecPoint * )ppsdl->At(index) ; 
135     ppsdrp->SetIndexInList(index) ; 
136   }
137   
138   if  (fDebugReconstruction) {
139     cout << "DebugReconstruction>>> Cluster emc list entries is " <<    emccl->GetEntries() << endl ;
140     AliPHOSEmcRecPoint * recpoint;
141     cout << "DebugReconstruction>>> Module "  << 
142       "Ene(MeV) "             <<                         
143       "Index "                << 
144       "Multi "                << 
145       "   X     "             << 
146       "   Y     "             << 
147       "   Z    "              << 
148       " Lambda 1   "          <<  
149       " Lambda 2   "          <<
150       "MaxEnergy(MeV) "       <<
151       "Nprim "                <<
152       " Primaries list "      <<  endl;      
153     for (index = 0 ; index < emccl->GetEntries() ; index++) {
154       recpoint = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
155       TVector3  locpos;  recpoint->GetLocalPosition(locpos);
156       Float_t lambda[2]; recpoint->GetElipsAxis(lambda);
157       Int_t * primaries; 
158       Int_t nprimaries;
159       primaries = recpoint->GetPrimaries(nprimaries);
160       cout << "DebugReconstruction>>>  " << 
161         setw(2) <<recpoint->GetPHOSMod() << " "  << 
162         setw(9) << 1000.*recpoint->GetTotalEnergy() <<       " "  <<                   
163         setw(6) <<  recpoint->GetIndexInList() << " "  << 
164         setw(5) <<  recpoint->GetMultiplicity() <<" "  << 
165         setw(8) <<  locpos.X() <<" "  << 
166         setw(8) <<  locpos.Y() <<" "  << 
167         setw(8) <<  locpos.Z() << " " <<
168         setw(10) << lambda[0] << "  " <<
169         setw(10) << lambda[1] << "  " <<
170         setw(9) << 1000*recpoint->GetMaximalEnergy() << "  " << 
171         setw(9) << nprimaries << "  ";
172       for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
173         cout << setw(4)  <<  primaries[iprimary] << " ";
174       cout << endl;      
175     }
176       
177     cout << "DebugReconstruction>>> Cluster ppsd list entries is " <<    ppsdl->GetEntries() << endl ;
178     AliPHOSPpsdRecPoint * ppsdrecpoint;
179     Text_t detector[4];
180     cout << "DebugReconstruction>>> Module "  << 
181       "Det     "             <<      
182       "Ene(KeV) "            <<                         
183       "Index "               << 
184       "Multi "               << 
185       "   X     "            << 
186       "   Y     "            << 
187       "   Z         "        << 
188       "Nprim "               <<
189       " Primaries list "     <<  endl;      
190     for (index = 0 ; index < ppsdl->GetEntries() ; index++) {
191       ppsdrecpoint = (AliPHOSPpsdRecPoint * ) ppsdl->At(index) ; 
192       TVector3  locpos; ppsdrecpoint->GetLocalPosition(locpos);
193       Int_t * primaries; 
194       Int_t nprimaries;
195       if (ppsdrecpoint->GetUp()) 
196         strcpy(detector, "CPV"); 
197       else 
198         strcpy(detector, "PC ");
199       primaries = ppsdrecpoint->GetPrimaries(nprimaries);
200       cout << "DebugReconstruction>>> " << 
201         setw(4) << ppsdrecpoint->GetPHOSMod() << "  "  << 
202         setw(4)  << detector << " "      <<
203         setw(9) << 1000000.*ppsdrecpoint->GetTotalEnergy() <<       " "  <<             
204         setw(6) <<  ppsdrecpoint->GetIndexInList() << " "  << 
205         setw(5) <<  ppsdrecpoint->GetMultiplicity() <<" "  << 
206         setw(8) <<  locpos.X() <<" "  << 
207         setw(8) <<  locpos.Y() <<" "  << 
208         setw(8) <<  locpos.Z() << " " <<
209         setw(9) <<  nprimaries << "  ";
210       for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
211         cout << setw(4)  <<  primaries[iprimary] << " ";
212       cout << endl;      
213     }
214   }  
215   
216   
217   if  (fDebugReconstruction)  cout << "DebugReconstruction>>>> Start making track segments(unfolding+tracksegments)" << endl;
218   fTrackSegmentMaker->MakeTrackSegments(dl, emccl, ppsdl, trsl) ;   
219   
220   // mark the position of the TrackSegments in the array
221   AliPHOSTrackSegment * trs ; 
222   for (index = 0 ; index < trsl->GetEntries() ; index++) {
223     trs = (AliPHOSTrackSegment * )trsl->At(index) ; 
224     trs->SetIndexInList(index) ; 
225   }
226   if  (fDebugReconstruction){
227     cout << "DebugReconstruction>>> Track segment list entries is " <<    trsl->GetEntries() << endl ;
228     cout << "DebugReconstruction>>> Module "  << 
229       "Ene(KeV) "             <<                         
230       "Index "                << 
231       "   X      "            << 
232       "   Y      "            << 
233       "   Z       "           <<
234       " rX        "           << 
235       " rY        "           << 
236       " rZ      "             << 
237       "Nprim "                <<
238       " Primaries list "      <<  endl;      
239     
240     for (index = 0 ; index < trsl->GetEntries() ; index++) {
241       trs = (AliPHOSTrackSegment * )trsl->At(index) ; 
242       TVector3 locpos; trs->GetPosition(locpos);
243       Int_t * primaries; 
244       Int_t nprimaries;
245       primaries = trs->GetPrimariesEmc(nprimaries);
246       cout << "DebugReconstruction>>> " << 
247         setw(4) << trs->GetPHOSMod() << "  "  << 
248         setw(9) << 1000.*trs->GetEnergy() <<       " "  <<             
249         setw(3) <<  trs->GetIndexInList() << " "  <<  
250         setw(9) <<  locpos.X() <<" "  << 
251         setw(9) <<  locpos.Y() <<" "  << 
252         setw(9) <<  locpos.Z() << " " <<
253         setw(10) <<  (trs->GetMomentumDirection()).X() << " " <<
254         setw(10) <<  (trs->GetMomentumDirection()).Y() << " " <<
255         setw(10) <<  (trs->GetMomentumDirection()).Z() << " " <<
256         setw(4) << nprimaries << "  ";
257       for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
258         cout << setw(4)  <<  primaries[iprimary] << " ";
259       cout << endl;      
260     }
261     
262   }
263   if  (fDebugReconstruction)  cout << "DebugReconstruction>>>> Start making reconstructed particles" << endl;
264   
265   fPID->MakeParticles(trsl, rpl) ; 
266   
267   // mark the position of the RecParticles in the array
268   AliPHOSRecParticle * rp ; 
269   for (index = 0 ; index < rpl->GetEntries() ; index++) {
270     rp = (AliPHOSRecParticle * )rpl->At(index) ; 
271     rp->SetIndexInList(index) ; 
272   }
273   //Debugger of RecParticles
274   if  (fDebugReconstruction){
275     cout << "DebugReconstruction>>>  Reconstructed particle list entries is " <<    rpl->GetEntries() << endl ;
276     cout << "DebugReconstruction>>> Module "  << 
277       "    PARTICLE     "   <<
278       "Ene(KeV) "           <<                         
279       "Index "              << 
280       "   X      "          << 
281       "   Y      "          << 
282       "   Z       "         <<
283       "Nprim "              <<
284       " Primaries list "    <<  endl;      
285     for (index = 0 ; index < rpl->GetEntries() ; index++) {
286       rp = (AliPHOSRecParticle * ) rpl->At(index) ;       
287       TVector3 locpos; (rp->GetPHOSTrackSegment())->GetPosition(locpos);
288       Int_t * primaries; 
289       Int_t nprimaries;
290       Text_t particle[11];
291       primaries = (rp->GetPHOSTrackSegment())->GetPrimariesEmc(nprimaries);
292       switch(rp->GetType())
293         {
294         case  AliPHOSFastRecParticle::kNEUTRALEM:
295           strcpy( particle, "NEUTRAL_EM");
296           break;
297         case  AliPHOSFastRecParticle::kNEUTRALHA:
298           strcpy(particle, "NEUTRAL_HA");
299           break;
300         case  AliPHOSFastRecParticle::kGAMMA:
301           strcpy(particle, "GAMMA");
302           break ;
303         case  AliPHOSFastRecParticle::kGAMMAHA: 
304           strcpy(particle, "GAMMA_H");
305           break ;
306         case  AliPHOSFastRecParticle::kABSURDEM:
307           strcpy(particle, "ABSURD_EM") ;
308           break ;
309         case  AliPHOSFastRecParticle::kABSURDHA:
310           strcpy(particle, "ABSURD_HA") ;
311           break ;       
312         case  AliPHOSFastRecParticle::kELECTRON:
313           strcpy(particle, "ELECTRON") ;
314           break ;
315         case  AliPHOSFastRecParticle::kCHARGEDHA:
316           strcpy(particle, "CHARGED_HA") ;
317           break ; 
318         }
319       
320       cout << "DebugReconstruction>>> " << 
321         setw(4) << (rp->GetPHOSTrackSegment())->GetPHOSMod() << "  "  <<
322         setw(15) << particle << "  " <<
323         setw(9) << 1000.*(rp->GetPHOSTrackSegment())->GetEnergy() <<       " "  <<             
324         setw(3) <<  rp->GetIndexInList() << " "  <<  
325         setw(9) <<  locpos.X() <<" "  << 
326         setw(9) <<  locpos.Y() <<" "  << 
327         setw(9) <<  locpos.Z() << " " <<
328         setw(4) << nprimaries << "  ";
329       for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
330         cout << setw(4)  <<  primaries[iprimary] << " ";
331       cout << endl;      
332     }
333     
334   }
335
336
337 }
338
339 //____________________________________________________________________________
340  void AliPHOSReconstructioner::Make(DigitsList * dl, 
341                                     AliPHOSRecPoint::RecPointsList * emccl,
342                                     AliPHOSRecPoint::RecPointsList * cpvcl)
343 {
344
345   // Launches the Reconstruction process of EMC and CPV in the sequence:
346   //       Make the reconstructed poins (clusterize)
347   //       Make the track segments 
348   // Particle identification is not made here
349   // EMC and CPV rec.points are the same yet
350   //
351   // Yuri Kharlov. 20 October 2000
352
353   Int_t index ;   
354
355   // Making Clusters
356   if  (fDebugReconstruction)
357     cout << "DebugReconstruction>>> Start clusterizing reconstructed points" << endl;
358   fClusterizer->MakeClusters(dl, emccl, cpvcl);
359   
360   if  (fDebugReconstruction){
361   // Digit Debuging
362     cout << "AliPHOSReconstructioner: Digit list entries are " << dl->GetEntries()    << endl ;
363     cout << "AliPHOSReconstructioner: EMC   list entries are " << emccl->GetEntries() << endl ;
364     cout << "AliPHOSReconstructioner: CPV   list entries are " << cpvcl->GetEntries() << endl ;
365     cout << ">>>>>>>>>>>>>>>>>>>>>> DebugReconstruction  <<<<<<<<<<<<<<<<<<<<<<<<<<"  << endl ;
366     cout << "DebugReconstruction>>> Digit list entries is " <<    dl->GetEntries() << endl ;
367     AliPHOSDigit * digit;
368     Bool_t calorimeter ;
369     Float_t factor;
370     cout << "DebugReconstruction>>>    Vol Id " << 
371       " Ene(MeV, KeV) "              <<                         
372       " Index "                      << 
373       " Nprim "                      << 
374       " Primaries list "             <<  endl;      
375     for (index = 0 ; index < dl->GetEntries() ; index++) {
376       digit = (AliPHOSDigit * )  dl->At(index) ;
377       calorimeter = fClusterizer->IsInEmc(digit);
378       if (calorimeter) factor =1000. ; else factor=1000000.;
379       cout << "DebugReconstruction>>>  " << 
380         setw(8)  <<  digit->GetId() << " "  <<
381         setw(3)  <<  (Int_t) calorimeter <<  
382         setw(10) <<  factor*fClusterizer->Calibrate(digit->GetAmp()) << "  "  <<                   
383         setw(6)  <<  digit->GetIndexInList() << "  "  << 
384         setw(5)  <<  digit->GetNprimary() <<"  ";
385       for (Int_t iprimary=0; iprimary<digit->GetNprimary(); iprimary++)
386         cout << setw(5)  <<  digit->GetPrimary(iprimary+1) << " ";
387       cout << endl;      
388     }
389     
390   }
391
392   // mark the position of the RecPoints in the array
393   AliPHOSEmcRecPoint * emcrp ; 
394   Int_t currentPHOSModule;
395   for (index = 0 ; index < emccl->GetEntries() ; index++) {
396     emcrp = (AliPHOSEmcRecPoint * )emccl->At(index) ; 
397     emcrp ->SetIndexInList(index) ; 
398     TVector3  locpos;  emcrp->GetLocalPosition(locpos);
399     currentPHOSModule = emcrp->GetPHOSMod();
400   }
401   AliPHOSCpvRecPoint * cpvrp ; 
402   for (index = 0 ; index < cpvcl->GetEntries() ; index++) {
403     cpvrp = (AliPHOSCpvRecPoint * )cpvcl->At(index) ; 
404     cpvrp ->SetIndexInList(index) ; 
405     TVector3  locpos;   cpvrp->GetLocalPosition(locpos);
406     Int_t lengX,lengZ;  cpvrp->GetClusterLengths(lengX,lengZ);
407     currentPHOSModule = cpvrp->GetPHOSMod();
408   }
409     
410   if  (fDebugReconstruction)
411     cout << "DebugReconstruction>>>> Start unfolding reconstructed points" << endl;
412   fTrackSegmentMaker->MakeTrackSegmentsCPV(dl, emccl, cpvcl) ;
413 }