Coding convention rules obeyed
[u/mrichter/AliRoot.git] / PHOS / AliPHOSReconstructioner.cxx
CommitLineData
d15a28e7 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
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// Algorithm class for the reconstruction: clusterizer
20// track segment maker
21// particle identifier
a3dfe79c 22//*--
b2a60966 23//*-- Author: Gines Martinez & Yves Schutz (SUBATECH)
24
d15a28e7 25
26// --- ROOT system ---
27
28#include "TClonesArray.h"
29
30// --- Standard library ---
31
e126816e 32#include <iomanip.h>
364de5c6 33
d15a28e7 34// --- AliRoot header files ---
35
36#include "AliPHOSReconstructioner.h"
37#include "AliPHOSClusterizer.h"
9ec91567 38#include "AliPHOSFastRecParticle.h"
d15a28e7 39
40ClassImp(AliPHOSReconstructioner)
41
d15a28e7 42//____________________________________________________________________________
6ad0bfa0 43AliPHOSReconstructioner::AliPHOSReconstructioner(AliPHOSClusterizer * Clusterizer,
44 AliPHOSTrackSegmentMaker * Tracker,
908558fc 45 AliPHOSPID * Pid)
d15a28e7 46{
b2a60966 47 // ctor
48
6ad0bfa0 49 fClusterizer = Clusterizer ;
50 fTrackSegmentMaker = Tracker ;
908558fc 51 fPID = Pid ;
364de5c6 52 fDebugReconstruction = kFALSE ;
d15a28e7 53}
54
d15a28e7 55
56//____________________________________________________________________________
6ad0bfa0 57 void AliPHOSReconstructioner::Init(AliPHOSClusterizer * Clusterizer,
58 AliPHOSTrackSegmentMaker * Tracker,
908558fc 59 AliPHOSPID * Pid)
6ad0bfa0 60{
839ffcb3 61 // Initialisation
62
6ad0bfa0 63 fClusterizer = Clusterizer ;
64 fTrackSegmentMaker = Tracker ;
908558fc 65 fPID = Pid ;
364de5c6 66 fDebugReconstruction = kFALSE ;
6ad0bfa0 67}
68
6ad0bfa0 69//____________________________________________________________________________
88714635 70 void AliPHOSReconstructioner::Make(DigitsList * dl,
71 AliPHOSRecPoint::RecPointsList * emccl,
72 AliPHOSRecPoint::RecPointsList * ppsdl,
73 AliPHOSTrackSegment::TrackSegmentsList * trsl,
74 AliPHOSRecParticle::RecParticlesList * rpl)
d15a28e7 75{
b2a60966 76 // Launches the Reconstruction process in the sequence: Make the reconstructed poins (clusterize)
77 // Make the track segments
78 // Make the reconstructed particles
59cd4405 79 Int_t index ;
2131115b 80 if (fDebugReconstruction)
51926850 81 cout << "\n\nDebugReconstruction>>> " << "Start making reconstructed points (clusterizing!!)" << endl;
2131115b 82
59cd4405 83 fClusterizer->MakeClusters(dl, emccl, ppsdl);
2131115b 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 }
59cd4405 90
364de5c6 91 // Digit Debuging
2aad621e 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 " <<
51926850 99 " Ene(MeV, KeV) " <<
100 " Index " <<
101 " Nprim " <<
102 " Primaries list " << endl;
2aad621e 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>>> " <<
51926850 108 setw(8) << digit->GetId() << " " <<
109 setw(3) << (Int_t) calorimeter <<
110 setw(10) << factor*fClusterizer->Calibrate(digit->GetAmp()) << " " <<
2aad621e 111 setw(6) << digit->GetIndexInList() << " " <<
51926850 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;
364de5c6 116 }
2aad621e 117
118 }
364de5c6 119
120
2885696f 121
122 // Making Clusters
031f0861 123 if (fDebugReconstruction) cout << "DebugReconstruction>>> Start making reconstructed points (clusterizing)" << endl;
6ad0bfa0 124
031f0861 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 }
2aad621e 136
51926850 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 }
2aad621e 175
51926850 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 }
2aad621e 214
215
031f0861 216 if (fDebugReconstruction) cout << "DebugReconstruction>>>> Start making track segments(unfolding+tracksegments)" << endl;
83974468 217 fTrackSegmentMaker->MakeTrackSegments(dl, emccl, ppsdl, trsl) ;
2aad621e 218
83974468 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 }
031f0861 225 if (fDebugReconstruction){
226 cout << "DebugReconstruction>>> Track segment list entries is " << trsl->GetEntries() << endl ;
227 cout << "DebugReconstruction>>> Module " <<
228 "Ene(KeV) " <<
51926850 229 "Index " <<
230 " X " <<
231 " Y " <<
232 " Z " <<
233 " rX " <<
234 " rY " <<
235 " rZ " <<
236 "Nprim " <<
237 " Primaries list " << endl;
2aad621e 238
031f0861 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() << " " <<
51926850 255 setw(4) << nprimaries << " ";
256 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
257 cout << setw(4) << primaries[iprimary] << " ";
258 cout << endl;
2aad621e 259 }
260
031f0861 261 }
2aad621e 262 if (fDebugReconstruction) cout << "DebugReconstruction>>>> Start making reconstructed particles" << endl;
83974468 263
0dd37dda 264 fPID->MakeParticles(trsl, rpl) ;
83974468 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 }
2aad621e 272 //Debugger of RecParticles
51926850 273 if (fDebugReconstruction){
2aad621e 274 cout << "DebugReconstruction>>> Reconstructed particle list entries is " << rpl->GetEntries() << endl ;
275 cout << "DebugReconstruction>>> Module " <<
276 " PARTICLE " <<
51926850 277 "Ene(KeV) " <<
278 "Index " <<
279 " X " <<
280 " Y " <<
281 " Z " <<
282 "Nprim " <<
283 " Primaries list " << endl;
2aad621e 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 {
9ec91567 293 case AliPHOSFastRecParticle::kNEUTRALEM:
e126816e 294 strcpy( particle, "NEUTRAL_EM");
2aad621e 295 break;
9ec91567 296 case AliPHOSFastRecParticle::kNEUTRALHA:
e126816e 297 strcpy(particle, "NEUTRAL_HA");
2aad621e 298 break;
9ec91567 299 case AliPHOSFastRecParticle::kGAMMA:
e126816e 300 strcpy(particle, "GAMMA");
2aad621e 301 break ;
9ec91567 302 case AliPHOSFastRecParticle::kGAMMAHA:
e126816e 303 strcpy(particle, "GAMMA_H");
2aad621e 304 break ;
9ec91567 305 case AliPHOSFastRecParticle::kABSURDEM:
e126816e 306 strcpy(particle, "ABSURD_EM") ;
2aad621e 307 break ;
9ec91567 308 case AliPHOSFastRecParticle::kABSURDHA:
e126816e 309 strcpy(particle, "ABSURD_HA") ;
2aad621e 310 break ;
9ec91567 311 case AliPHOSFastRecParticle::kELECTRON:
e126816e 312 strcpy(particle, "ELECTRON") ;
2aad621e 313 break ;
9ec91567 314 case AliPHOSFastRecParticle::kCHARGEDHA:
e126816e 315 strcpy(particle, "CHARGED_HA") ;
2aad621e 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() << " " <<
51926850 327 setw(4) << nprimaries << " ";
328 for (Int_t iprimary=0; iprimary<nprimaries; iprimary++)
329 cout << setw(4) << primaries[iprimary] << " ";
330 cout << endl;
2aad621e 331 }
332
333 }
334
335
d15a28e7 336}
51926850 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 ;
a3dfe79c 393 Int_t currentPHOSModule;
51926850 394 for (index = 0 ; index < emccl->GetEntries() ; index++) {
395 emcrp = (AliPHOSEmcRecPoint * )emccl->At(index) ;
396 emcrp ->SetIndexInList(index) ;
397 TVector3 locpos; emcrp->GetLocalPosition(locpos);
a3dfe79c 398 currentPHOSModule = emcrp->GetPHOSMod();
51926850 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);
a3dfe79c 405 currentPHOSModule = cpvrp->GetPHOSMod();
51926850 406 }
407
408 if (fDebugReconstruction)
409 cout << "DebugReconstruction>>>> Start unfolding reconstructed points" << endl;
410 fTrackSegmentMaker->MakeTrackSegmentsCPV(dl, emccl, cpvcl) ;
411}