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