1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //_________________________________________________________________________
17 // Algorythm class to analyze PHOS events
18 //*-- Y. Schutz : SUBATECH
19 //////////////////////////////////////////////////////////////////////////////
21 // --- ROOT system ---
24 #include "TParticle.h"
25 #include "TClonesArray.h"
30 // --- Standard library ---
32 // --- AliRoot header files ---
35 #include "AliPHOSAnalyze.h"
36 #include "AliPHOSClusterizerv1.h"
37 #include "AliPHOSTrackSegmentMakerv1.h"
38 #include "AliPHOSParticleGuesserv1.h"
39 #include "AliPHOSReconstructioner.h"
40 #include "AliPHOSDigit.h"
41 #include "AliPHOSTrackSegment.h"
42 #include "AliPHOSRecParticle.h"
44 ClassImp(AliPHOSAnalyze)
47 //____________________________________________________________________________
48 AliPHOSAnalyze::AliPHOSAnalyze()
55 //____________________________________________________________________________
56 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * name)
60 Bool_t OK = OpenRootFile(name) ;
62 cout << " AliPHOSAnalyze > Error opening " << name << endl ;
65 gAlice = (AliRun*) fRootFile->Get("gAlice");
66 fPHOS = (AliPHOSv0 *)gAlice->GetDetector("PHOS") ;
67 fGeom = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() ) ;
72 //____________________________________________________________________________
73 AliPHOSAnalyze::~AliPHOSAnalyze()
98 //____________________________________________________________________________
99 void AliPHOSAnalyze::AnalyzeOneEvent(Int_t evt)
101 Bool_t OK = Init(evt) ;
104 //=========== Get the number of entries in the Digits array
106 Int_t nId = fPHOS->Digits()->GetEntries();
107 printf("AnalyzeOneEvent > Number of entries in the Digit array is %d \n",nId);
109 //=========== Do the reconstruction
111 cout << "AnalyzeOneEvent > Found " << nId << " digits in PHOS" << endl ;
113 fPHOS->Reconstruction(fRec);
115 // =========== End of reconstruction
117 cout << "AnalyzeOneEvent > event # " << fEvt << " processed" << endl ;
120 cout << "AnalyzeOneEvent > filed to process event # " << evt << endl ;
124 //____________________________________________________________________________
125 Bool_t AliPHOSAnalyze::Init(Int_t evt)
130 //========== Open galice root file
132 if ( fRootFile == 0 ) {
133 Text_t * name = new Text_t[80] ;
134 cout << "AnalyzeOneEvent > Enter file root file name : " ;
136 Bool_t OK = OpenRootFile(name) ;
138 cout << " AliPHOSAnalyze > Error opening " << name << endl ;
140 //========== Get AliRun object from file
142 gAlice = (AliRun*) fRootFile->Get("gAlice") ;
144 //=========== Get the PHOS object and associated geometry from the file
146 fPHOS = (AliPHOSv0 *)gAlice->GetDetector("PHOS") ;
147 fGeom = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() );
153 //========== Create the Clusterizer
155 fClu = new AliPHOSClusterizerv1() ;
156 fClu->SetEmcEnergyThreshold(0.01) ;
157 fClu->SetEmcClusteringThreshold(0.1) ;
158 fClu->SetPpsdEnergyThreshold(0.0000001) ;
159 fClu->SetPpsdClusteringThreshold(0.0000002) ;
160 fClu->SetLocalMaxCut(0.03) ;
161 fClu->SetCalibrationParameters(0., 0.0000001) ;
162 cout << "AnalyzeOneEvent > using clusterizer " << fClu->GetName() << endl ;
163 fClu->PrintParameters() ;
165 //========== Creates the track segment maker
167 fTrs = new AliPHOSTrackSegmentMakerv1() ;
168 cout << "AnalyzeOneEvent > using tack segment maker " << fTrs->GetName() << endl ;
170 //========== Creates the particle guesser
172 fPag = new AliPHOSParticleGuesserv1() ;
173 cout << "AnalyzeOneEvent > using particle guess " << fPag->GetName() << endl ;
175 //========== Creates the Reconstructioner
177 fRec = new AliPHOSReconstructioner(fClu, fTrs, fPag) ;
179 //=========== Connect the various Tree's for evt
182 cout << "AnalyzeOneEvent > Enter event number : " ;
184 cout << evt << endl ;
187 gAlice->GetEvent(evt);
189 //=========== Get the Digit TTree
191 gAlice->TreeD()->GetEvent(0) ;
198 //____________________________________________________________________________
199 void AliPHOSAnalyze:: DisplayKineEvent(Int_t evt)
205 cout << "DisplayKineEvent > which module (1-5, -1: all) ? " ;
206 cin >> Module ; cout << Module << endl ;
209 cout << " 22 : PHOTON " << endl
210 << " (-)11 : (POSITRON)ELECTRON " << endl
211 << " (-)2112 : (ANTI)NEUTRON " << endl
212 << " -999 : Everything else " << endl ;
213 cout << "DisplayKineEvent > enter PDG particle code to display " ;
214 cin >> TestParticle ; cout << TestParticle << endl ;
216 Text_t HistoName[80] ;
217 sprintf(HistoName,"Event %d: Incident particles in module %d", evt, Module) ;
219 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by Module
220 fGeom->EmcModuleCoverage(Module, tm, tM, pm, pM, kDegre) ;
222 Double_t theta, phi ;
223 fGeom->EmcXtalCoverage(theta, phi, kDegre) ;
225 Int_t tdim = (Int_t)( (tM - tm) / theta ) ;
226 Int_t pdim = (Int_t)( (pM - pm) / phi ) ;
233 TH2F * HistoParticle = new TH2F("HistoParticle", HistoName,
234 pdim, pm, pM, tdim, tm, tM) ;
235 HistoParticle->SetStats(kFALSE) ;
237 // Get pointers to Alice Particle TClonesArray
239 TParticle * Particle;
240 TClonesArray * ArrayOfParticles = gAlice->Particles();
242 Text_t CanvasName[80];
243 sprintf(CanvasName,"Particles incident in PHOS/EMC module # %d",Module) ;
244 TCanvas * KineCanvas = new TCanvas("KineCanvas", CanvasName, 650, 500) ;
248 TTree * Kine = gAlice->TreeK() ;
249 Stat_t NumberOfParticles = Kine->GetEntries() ;
250 cout << "DisplayKineEvent > events in Kine " << NumberOfParticles << endl ;
252 // loop over particles
254 Double_t raddeg = 180. / TMath::Pi() ;
256 Int_t nparticlein = 0 ;
257 for (index1 = 0 ; index1 < NumberOfParticles ; index1++){
258 Int_t nparticle = ArrayOfParticles->GetEntriesFast() ;
260 for( index2 = 0 ; index2 < nparticle ; index2++) {
261 Particle = (TParticle*)ArrayOfParticles->UncheckedAt(index2) ;
262 Int_t ParticleType = Particle->GetPdgCode() ;
263 if (TestParticle == -999 || TestParticle == ParticleType) {
264 Double_t Phi = Particle->Phi() ;
265 Double_t Theta = Particle->Theta() ;
268 fGeom->ImpactOnEmc(Theta, Phi, mod, z, x) ;
269 if ( mod == Module ) {
271 HistoParticle->Fill(Phi*raddeg, Theta*raddeg, Particle->Energy() ) ;
277 HistoParticle->Draw("color") ;
278 TPaveText * PaveText = new TPaveText(294, 100, 300, 101);
280 sprintf(text, "Particles: %d ", nparticlein) ;
281 PaveText->AddText(text) ;
283 KineCanvas->Update();
286 //____________________________________________________________________________
287 void AliPHOSAnalyze::DisplayRecParticles()
290 cout << "DisplayRecPoints > Analyze an event first ... (y/n) " ;
292 cin >> answer ; cout << answer ;
299 cout << "DisplayRecPoints > which module (1-5, -1: all) ? " ;
300 cin >> Module ; cout << Module << endl ;
301 Text_t HistoName[80] ;
302 sprintf(HistoName,"Event %d: Reconstructed particles in module %d", fEvt, Module) ;
303 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by Module
304 fGeom->EmcModuleCoverage(Module, tm, tM, pm, pM, kDegre) ;
305 Double_t theta, phi ;
306 fGeom->EmcXtalCoverage(theta, phi, kDegre) ;
307 Int_t tdim = (Int_t)( (tM - tm) / theta ) ;
308 Int_t pdim = (Int_t)( (pM - pm) / phi ) ;
312 TH2F * HistoRParticle = new TH2F("HistoRParticle", HistoName,
313 pdim, pm, pM, tdim, tm, tM) ;
314 HistoRParticle->SetStats(kFALSE) ;
315 Text_t CanvasName[80] ;
316 sprintf(CanvasName, "Reconstructed particles in PHOSmodule # %d", Module) ;
317 TCanvas * RParticleCanvas = new TCanvas("RparticleCanvas", CanvasName, 650, 500) ;
318 RecParticlesList * rpl = fPHOS->RecParticles() ;
319 Int_t NRecParticles = rpl->GetEntries() ;
320 Int_t NRecParticlesInModule = 0 ;
321 TIter nextRecPart(rpl) ;
322 AliPHOSRecParticle * rp ;
323 cout << "DisplayRecParticles > " << NRecParticles << " reconstructed particles " << endl ;
324 Double_t raddeg = 180. / TMath::Pi() ;
325 while ( (rp = (AliPHOSRecParticle *)nextRecPart() ) ) {
326 AliPHOSTrackSegment * ts = rp->GetPHOSTrackSegment() ;
327 if ( ts->GetPHOSMod() == Module ) {
328 NRecParticlesInModule++ ;
329 Double_t theta = rp->Theta() * raddeg ;
330 Double_t phi = rp->Phi() * raddeg ;
331 Double_t energy = rp->Energy() ;
332 HistoRParticle->Fill(phi, theta, energy) ;
335 HistoRParticle->Draw("color") ;
337 sprintf(text, "reconstructed particles: %d", NRecParticlesInModule) ;
338 TPaveText * PaveText = new TPaveText(292, 100, 300, 101);
339 PaveText->AddText(text) ;
341 RParticleCanvas->Update() ;
345 //____________________________________________________________________________
346 void AliPHOSAnalyze::DisplayRecPoints()
349 cout << "DisplayRecPoints > Analyze an event first ... (y/n) " ;
351 cin >> answer ; cout << answer ;
358 cout << "DisplayRecPoints > which module (1-5, -1: all) ? " ;
359 cin >> Module ; cout << Module << endl ;
361 Text_t CanvasName[80];
362 sprintf(CanvasName,"Digits in PHOS/EMC module # %d",Module) ;
363 TCanvas * ModuleCanvas = new TCanvas("Module", CanvasName, 650, 500) ;
364 ModuleCanvas->Draw() ;
366 //=========== Creating 2d-histogram of the PHOS Module
367 // a little bit junkie but is used to test Geom functinalities
369 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by Module
371 fGeom->EmcModuleCoverage(Module, tm, tM, pm, pM);
372 // convert angles into coordinates local to the EMC module of interest
374 Int_t EmcModuleNumber ;
375 Double_t EmcModulexm, EmcModulezm ; // minimum local coordinate in a given EMCA module
376 Double_t EmcModulexM, EmcModulezM ; // maximum local coordinate in a given EMCA module
377 fGeom->ImpactOnEmc(tm, pm, EmcModuleNumber, EmcModulezm, EmcModulexm) ;
378 fGeom->ImpactOnEmc(tM, pM, EmcModuleNumber, EmcModulezM, EmcModulexM) ;
379 Int_t xdim = (Int_t)( ( EmcModulexM - EmcModulexm ) / fGeom->GetCrystalSize(0) ) ;
380 Int_t zdim = (Int_t)( ( EmcModulezM - EmcModulezm ) / fGeom->GetCrystalSize(2) ) ;
381 Float_t xmin = EmcModulexm - fGeom->GetCrystalSize(0) ;
382 Float_t xMax = EmcModulexM + fGeom->GetCrystalSize(0) ;
383 Float_t zmin = EmcModulezm - fGeom->GetCrystalSize(2) ;
384 Float_t zMax = EmcModulezM + fGeom->GetCrystalSize(2) ;
385 Text_t HistoName[80];
386 sprintf(HistoName,"Event %d: Digits and RecPoints in module %d", fEvt, Module) ;
387 TH2F * hModule = new TH2F("HistoReconstructed", HistoName,
388 xdim, xmin, xMax, zdim, zmin, zMax) ;
389 hModule->SetMaximum(2.0);
390 hModule->SetMinimum(0.0);
391 hModule->SetStats(kFALSE);
393 TIter next(fPHOS->Digits()) ;
394 Float_t Energy, y, z;
395 Int_t RelId[4]; Int_t NumberOfDigits = 0 ;
396 AliPHOSDigit * digit ;
398 while((digit = (AliPHOSDigit *)next()))
400 fGeom->AbsToRelNumbering(digit->GetId(), RelId) ;
401 if (RelId[0] == Module)
404 Energy = fClu->Calibrate(digit->GetAmp()) ;
406 fGeom->RelPosInModule(RelId,y,z) ;
408 hModule->Fill(y, z, Energy) ;
411 cout <<"DrawRecPoints > Found in Module "
412 << Module << " " << NumberOfDigits << " digits with total energy " << Etot << endl ;
413 hModule->Draw("col2") ;
415 //=========== Cluster in Module
417 TClonesArray * EmcRP = fPHOS->EmcClusters() ;
419 Int_t TotalNumberOfClusters = 0 ;
420 Int_t NumberOfClusters = 0 ;
421 TIter nextemc(EmcRP) ;
422 AliPHOSEmcRecPoint * emc ;
423 while((emc = (AliPHOSEmcRecPoint *)nextemc()))
425 TotalNumberOfClusters++ ;
426 if ( emc->GetPHOSMod() == Module )
429 Energy = emc->GetTotalEnergy() ;
434 cout << "DrawRecPoints > Found " << TotalNumberOfClusters << " EMC Clusters in PHOS" << endl ;
435 cout << "DrawRecPoints > Found in Module " << Module << " " << NumberOfClusters << " EMC Clusters " << endl ;
436 cout << "DrawRecPoints > Total energy " << Etot << endl ;
438 TPaveText * PaveText = new TPaveText(22, 80, 83, 90);
440 sprintf(text, "digits: %d; clusters: %d", NumberOfDigits, NumberOfClusters) ;
441 PaveText->AddText(text) ;
443 ModuleCanvas->Update();
445 //=========== Cluster in Module PPSD Down
447 TClonesArray * PpsdRP = fPHOS->PpsdClusters() ;
449 TIter nextPpsd(PpsdRP) ;
450 AliPHOSPpsdRecPoint * Ppsd ;
451 while((Ppsd = (AliPHOSPpsdRecPoint *)nextPpsd()))
453 TotalNumberOfClusters++ ;
454 if ( Ppsd->GetPHOSMod() == Module )
457 Energy = Ppsd->GetEnergy() ;
459 if (!Ppsd->GetUp()) Ppsd->Draw("P") ;
462 cout << "DrawRecPoints > Found " << TotalNumberOfClusters << " Ppsd Down Clusters in PHOS" << endl ;
463 cout << "DrawRecPoints > Found in Module " << Module << " " << NumberOfClusters << " Ppsd Down Clusters " << endl ;
464 cout << "DrawRecPoints > Total energy " << Etot << endl ;
466 //=========== Cluster in Module PPSD Up
468 PpsdRP = fPHOS->PpsdClusters() ;
470 TIter nextPpsdUp(PpsdRP) ;
471 while((Ppsd = (AliPHOSPpsdRecPoint *)nextPpsdUp()))
473 TotalNumberOfClusters++ ;
474 if ( Ppsd->GetPHOSMod() == Module )
477 Energy = Ppsd->GetEnergy() ;
479 if (Ppsd->GetUp()) Ppsd->Draw("P") ;
482 cout << "DrawRecPoints > Found " << TotalNumberOfClusters << " Ppsd Up Clusters in PHOS" << endl ;
483 cout << "DrawRecPoints > Found in Module " << Module << " " << NumberOfClusters << " Ppsd Up Clusters " << endl ;
484 cout << "DrawRecPoints > Total energy " << Etot << endl ;
489 //____________________________________________________________________________
490 void AliPHOSAnalyze::DisplayTrackSegments()
493 cout << "DisplayTrackSegments > Analyze an event first ... (y/n) " ;
495 cin >> answer ; cout << answer ;
502 cout << "DisplayTrackSegments > which module (1-5, -1: all) ? " ;
503 cin >> Module ; cout << Module << endl ;
504 //=========== Creating 2d-histogram of the PHOS Module
505 // a little bit junkie but is used to test Geom functinalities
507 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by Module
509 fGeom->EmcModuleCoverage(Module, tm, tM, pm, pM);
510 // convert angles into coordinates local to the EMC module of interest
512 Int_t EmcModuleNumber ;
513 Double_t EmcModulexm, EmcModulezm ; // minimum local coordinate in a given EMCA module
514 Double_t EmcModulexM, EmcModulezM ; // maximum local coordinate in a given EMCA module
515 fGeom->ImpactOnEmc(tm, pm, EmcModuleNumber, EmcModulezm, EmcModulexm) ;
516 fGeom->ImpactOnEmc(tM, pM, EmcModuleNumber, EmcModulezM, EmcModulexM) ;
517 Int_t xdim = (Int_t)( ( EmcModulexM - EmcModulexm ) / fGeom->GetCrystalSize(0) ) ;
518 Int_t zdim = (Int_t)( ( EmcModulezM - EmcModulezm ) / fGeom->GetCrystalSize(2) ) ;
519 Float_t xmin = EmcModulexm - fGeom->GetCrystalSize(0) ;
520 Float_t xMax = EmcModulexM + fGeom->GetCrystalSize(0) ;
521 Float_t zmin = EmcModulezm - fGeom->GetCrystalSize(2) ;
522 Float_t zMax = EmcModulezM + fGeom->GetCrystalSize(2) ;
523 Text_t HistoName[80];
524 sprintf(HistoName,"Event %d: Track Segments in module %d", fEvt, Module) ;
525 TH2F * HistoTrack = new TH2F("HistoTrack", HistoName,
526 xdim, xmin, xMax, zdim, zmin, zMax) ;
527 HistoTrack->SetStats(kFALSE);
528 Text_t CanvasName[80];
529 sprintf(CanvasName,"Track segments in PHOS/EMC-PPSD module # %d", Module) ;
530 TCanvas * TrackCanvas = new TCanvas("TrackSegmentCanvas", CanvasName, 650, 500) ;
533 TrackSegmentsList * trsegl = fPHOS->TrackSegments() ;
534 AliPHOSTrackSegment * trseg ;
536 Int_t NTrackSegments = trsegl->GetEntries() ;
539 Int_t NTrackSegmentsInModule = 0 ;
540 for(index = 0; index < NTrackSegments ; index++){
541 trseg = (AliPHOSTrackSegment * )trsegl->At(index) ;
542 Etot+= trseg->GetEnergy() ;
543 if ( trseg->GetPHOSMod() == Module ) {
544 NTrackSegmentsInModule++ ;
549 sprintf(text, "track segments: %d", NTrackSegmentsInModule) ;
550 TPaveText * PaveText = new TPaveText(22, 80, 83, 90);
551 PaveText->AddText(text) ;
553 TrackCanvas->Update() ;
554 cout << "DisplayTrackSegments > Found " << trsegl->GetEntries() << " Track segments with total energy "<< Etot << endl ;
558 //____________________________________________________________________________
559 Bool_t AliPHOSAnalyze::OpenRootFile(Text_t * name)
561 fRootFile = new TFile(name) ;
562 return fRootFile->IsOpen() ;