]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSAnalyze.cxx
Changes imposed by HP-UX which ignores the new C++ standart
[u/mrichter/AliRoot.git] / PHOS / AliPHOSAnalyze.cxx
CommitLineData
6ad0bfa0 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
6ad0bfa0 18//_________________________________________________________________________
b2a60966 19// Algorythm class to analyze PHOSv0 events:
20// Construct histograms and displays them.
21// Use the macro EditorBar.C for best access to the functionnalities
22//
23//*-- Author: Y. Schutz (SUBATECH)
6ad0bfa0 24//////////////////////////////////////////////////////////////////////////////
25
26// --- ROOT system ---
27
92862013 28#include "TFile.h"
29#include "TH1.h"
30#include "TPad.h"
6ad0bfa0 31#include "TH2.h"
32#include "TParticle.h"
33#include "TClonesArray.h"
34#include "TTree.h"
35#include "TMath.h"
36#include "TCanvas.h"
37
38// --- Standard library ---
39
de9ec31b 40#include <iostream.h>
41#include <stdio.h>
92862013 42
6ad0bfa0 43// --- AliRoot header files ---
44
45#include "AliRun.h"
46#include "AliPHOSAnalyze.h"
47#include "AliPHOSClusterizerv1.h"
48#include "AliPHOSTrackSegmentMakerv1.h"
26d4b141 49#include "AliPHOSPIDv1.h"
6ad0bfa0 50#include "AliPHOSReconstructioner.h"
51#include "AliPHOSDigit.h"
52#include "AliPHOSTrackSegment.h"
53#include "AliPHOSRecParticle.h"
54
55ClassImp(AliPHOSAnalyze)
56
57
58//____________________________________________________________________________
59 AliPHOSAnalyze::AliPHOSAnalyze()
60{
b2a60966 61 // default ctor (useless)
6ad0bfa0 62
63 fRootFile = 0 ;
64}
65
66//____________________________________________________________________________
67AliPHOSAnalyze::AliPHOSAnalyze(Text_t * name)
68{
b2a60966 69 // ctor: analyze events from root file: name
6ad0bfa0 70
92862013 71 Bool_t ok = OpenRootFile(name) ;
72 if ( !ok ) {
6ad0bfa0 73 cout << " AliPHOSAnalyze > Error opening " << name << endl ;
74 }
75 else {
76 gAlice = (AliRun*) fRootFile->Get("gAlice");
77 fPHOS = (AliPHOSv0 *)gAlice->GetDetector("PHOS") ;
78 fGeom = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() ) ;
79 fEvt = -999 ;
80 }
81}
82
83//____________________________________________________________________________
84AliPHOSAnalyze::~AliPHOSAnalyze()
85{
86 // dtor
87
88 fRootFile->Close() ;
89 delete fRootFile ;
90 fRootFile = 0 ;
91
92 delete fPHOS ;
93 fPHOS = 0 ;
94
95 delete fClu ;
96 fClu = 0 ;
97
26d4b141 98 delete fPID ;
99 fPID = 0 ;
6ad0bfa0 100
101 delete fRec ;
102 fRec = 0 ;
103
104 delete fTrs ;
105 fTrs = 0 ;
106
107}
108
109//____________________________________________________________________________
110void AliPHOSAnalyze::AnalyzeOneEvent(Int_t evt)
111{
b2a60966 112 // analyze one single event with id=evt
113
114 TStopwatch ts ;
115 ts.Start() ;
92862013 116 Bool_t ok = Init(evt) ;
6ad0bfa0 117
92862013 118 if ( ok ) {
6ad0bfa0 119 //=========== Get the number of entries in the Digits array
120
121 Int_t nId = fPHOS->Digits()->GetEntries();
122 printf("AnalyzeOneEvent > Number of entries in the Digit array is %d \n",nId);
123
124 //=========== Do the reconstruction
125
126 cout << "AnalyzeOneEvent > Found " << nId << " digits in PHOS" << endl ;
127
774e78c2 128
6ad0bfa0 129 fPHOS->Reconstruction(fRec);
130
131 // =========== End of reconstruction
b2a60966 132
133 // =========== Write the root file
134
135 fRootFile->Write() ;
6ad0bfa0 136
b2a60966 137 // =========== Finish
138
6ad0bfa0 139 cout << "AnalyzeOneEvent > event # " << fEvt << " processed" << endl ;
92862013 140 } // ok
6ad0bfa0 141 else
142 cout << "AnalyzeOneEvent > filed to process event # " << evt << endl ;
b2a60966 143
144 ts.Stop() ; cout << "CPU time = " << ts.CpuTime() << endl ;
145 cout << "Real time = " << ts.RealTime() << endl ;
6ad0bfa0 146}
147
92862013 148//____________________________________________________________________________
b2a60966 149 void AliPHOSAnalyze::AnalyzeManyEvents(Int_t Nevents, Int_t module)
92862013 150{
b2a60966 151 // analyzes Nevents events in a single PHOS module
92862013 152
153 if ( fRootFile == 0 )
154 cout << "AnalyzeManyEvents > " << "Root File not openned" << endl ;
155 else
156 {
157 //========== Get AliRun object from file
158 gAlice = (AliRun*) fRootFile->Get("gAlice") ;
159 //=========== Get the PHOS object and associated geometry from the file
160 fPHOS = (AliPHOSv0 *)gAlice->GetDetector("PHOS") ;
161 fGeom = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() );
162 //========== Booking Histograms
163 cout << "AnalyzeManyEvents > " << "Booking Histograms" << endl ;
164 BookingHistograms();
165 Int_t ievent;
6a3f1304 166 Int_t relid[4] ;
92862013 167 AliPHOSDigit * digit ;
168 AliPHOSEmcRecPoint * emc ;
169 AliPHOSPpsdRecPoint * ppsd ;
38f8ae6d 170 // AliPHOSTrackSegment * tracksegment ;
171 AliPHOSRecParticle * recparticle;
92862013 172 for ( ievent=0; ievent<Nevents; ievent++)
173 {
174 if (ievent==0) cout << "AnalyzeManyEvents > " << "Starting Analyzing " << endl ;
175 //========== Create the Clusterizer
176 fClu = new AliPHOSClusterizerv1() ;
177 fClu->SetEmcEnergyThreshold(0.025) ;
3fc07a80 178 fClu->SetEmcClusteringThreshold(0.50) ;
92862013 179 fClu->SetPpsdEnergyThreshold (0.0000002) ;
180 fClu->SetPpsdClusteringThreshold(0.0000001) ;
181 fClu->SetLocalMaxCut(0.03) ;
182 fClu->SetCalibrationParameters(0., 0.00000001) ;
183 //========== Creates the track segment maker
6727be7e 184 fTrs = new AliPHOSTrackSegmentMakerv1() ;
3fc07a80 185 fTrs->UnsetUnfoldFlag() ;
26d4b141 186 //========== Creates the particle identifier
187 fPID = new AliPHOSPIDv1() ;
6a3f1304 188 fPID->SetShowerProfileCuts(0.3, 1.8, 0.3, 1.8 ) ;
09fc14a0 189 fPID->Print() ;
92862013 190 //========== Creates the Reconstructioner
26d4b141 191 fRec = new AliPHOSReconstructioner(fClu, fTrs, fPID) ;
de9ec31b 192 //========== Event Number>
193 if ( ( log10((Float_t)(ievent+1)) - (Int_t)(log10((Float_t)(ievent+1))) ) == 0. )
194 cout << "AnalyzeManyEvents > " << "Event is " << ievent << endl ;
92862013 195 //=========== Connects the various Tree's for evt
196 gAlice->GetEvent(ievent);
197 //=========== Gets the Digit TTree
198 gAlice->TreeD()->GetEvent(0) ;
199 //=========== Gets the number of entries in the Digits array
200 TIter nextdigit(fPHOS->Digits()) ;
201 while( ( digit = (AliPHOSDigit *)nextdigit() ) )
202 {
203 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
204 if (fClu->IsInEmc(digit)) fhEmcDigit->Fill(fClu->Calibrate(digit->GetAmp())) ;
205 else
206 {
207 if (relid[1]<17) fhVetoDigit->Fill(fClu->Calibrate(digit->GetAmp()));
208 if (relid[1]>16) fhConvertorDigit->Fill(fClu->Calibrate(digit->GetAmp()));
209 }
210 }
211 //=========== Do the reconstruction
212 fPHOS->Reconstruction(fRec);
213 //=========== Cluster in module
214 TIter nextEmc(fPHOS->EmcClusters() ) ;
215 while((emc = (AliPHOSEmcRecPoint *)nextEmc()))
216 {
217 if ( emc->GetPHOSMod() == module )
218 {
219 fhEmcCluster->Fill( emc->GetTotalEnergy() );
220 TIter nextPpsd( fPHOS->PpsdClusters()) ;
221 while((ppsd = (AliPHOSPpsdRecPoint *)nextPpsd()))
222 {
223 if ( ppsd->GetPHOSMod() == module )
224 {
225 if (!ppsd->GetUp()) fhConvertorEmc->Fill(emc->GetTotalEnergy(),ppsd->GetTotalEnergy()) ;
226 }
227 }
228 }
229 }
230 //=========== Cluster in module PPSD Down
231 TIter nextPpsd(fPHOS->PpsdClusters() ) ;
232 while((ppsd = (AliPHOSPpsdRecPoint *)nextPpsd()))
233 {
234 if ( ppsd->GetPHOSMod() == module )
235 {
236 if (!ppsd->GetUp()) fhConvertorCluster->Fill(ppsd->GetTotalEnergy()) ;
237 if (ppsd->GetUp()) fhVetoCluster ->Fill(ppsd->GetTotalEnergy()) ;
238 }
239 }
240 //========== TRackSegments in the event
38f8ae6d 241 TIter nextRecParticle(fPHOS->RecParticles() ) ;
242 while((recparticle = (AliPHOSRecParticle *)nextRecParticle()))
92862013 243 {
38f8ae6d 244 if ( recparticle->GetPHOSTrackSegment()->GetPHOSMod() == module )
92862013 245 {
b2a60966 246 cout << "Particle type is " << recparticle->GetType() << endl ;
247 Int_t numberofprimaries = 0 ;
248 Int_t * listofprimaries = recparticle->GetPrimaries(numberofprimaries) ;
249 cout << "Number of primaries = " << numberofprimaries << endl ;
250 Int_t index ;
251 for ( index = 0 ; index < numberofprimaries ; index++)
252 cout << " primary # " << index << " = " << listofprimaries[index] << endl ;
38f8ae6d 253 switch(recparticle->GetType())
92862013 254 {
09fc14a0 255 case kGAMMA:
38f8ae6d 256 fhPhotonEnergy->Fill(recparticle->Energy() ) ;
09fc14a0 257 //fhPhotonPositionX->Fill(recpart. ) ;
258 //fhPhotonPositionY->Fill(recpart. ) ;
38f8ae6d 259 cout << "PHOTON" << endl;
92862013 260 break;
09fc14a0 261 case kELECTRON:
38f8ae6d 262 fhElectronEnergy->Fill(recparticle->Energy() ) ;
09fc14a0 263 //fhElectronPositionX->Fill(recpart. ) ;
264 //fhElectronPositionY->Fill(recpart. ) ;
38f8ae6d 265 cout << "ELECTRON" << endl;
92862013 266 break;
b9bbdad1 267 case kNEUTRALHADRON:
38f8ae6d 268 fhNeutralHadronEnergy->Fill(recparticle->Energy() ) ;
b9bbdad1 269 //fhNeutralHadronPositionX->Fill(recpart. ) ;
270 //fhNeutralHadronPositionY->Fill(recpart. ) ;
38f8ae6d 271 cout << "NEUTRAl HADRON" << endl;
b9bbdad1 272 break ;
273 case kNEUTRALEM:
38f8ae6d 274 fhNeutralEMEnergy->Fill(recparticle->Energy() ) ;
b9bbdad1 275 //fhNeutralEMPositionX->Fill(recpart. ) ;
276 //fhNeutralEMPositionY->Fill(recpart. ) ;
277 //cout << "NEUTRAL EM" << endl;
92862013 278 break ;
0dd37dda 279 case kCHARGEDHADRON:
38f8ae6d 280 fhChargedHadronEnergy->Fill(recparticle->Energy() ) ;
09fc14a0 281 //fhChargedHadronPositionX->Fill(recpart. ) ;
282 //fhChargedHadronPositionY->Fill(recpart. ) ;
38f8ae6d 283 cout << "CHARGED HADRON" << endl;
92862013 284 break ;
c1d256cb 285 case kGAMMAHADRON:
286 fhPhotonHadronEnergy->Fill(recparticle->Energy() ) ;
287 //fhPhotonHadronPositionX->Fill(recpart. ) ;
288 //fhPhotonHadronPositionY->Fill(recpart. ) ;
289 cout << "PHOTON HADRON" << endl;
290 break ;
92862013 291 }
292 }
293 }
26d4b141 294 // Deleting fClu, fTrs, fPID et fRec
92862013 295 fClu->Delete();
296 fTrs->Delete();
26d4b141 297 fPID->Delete();
92862013 298 fRec->Delete();
299
300 } // endfor
301 SavingHistograms();
302 } // endif
303} // endfunction
304
305
306//____________________________________________________________________________
307void AliPHOSAnalyze::BookingHistograms()
308{
b2a60966 309 // Books the histograms where the results of the analysis are stored (to be changed)
310
b9bbdad1 311 if (fhEmcDigit )
312 delete fhEmcDigit ;
313 if (fhVetoDigit )
314 delete fhVetoDigit ;
315 if (fhConvertorDigit )
316 delete fhConvertorDigit ;
317 if (fhEmcCluster )
318 delete fhEmcCluster ;
319 if (fhVetoCluster )
320 delete fhVetoCluster ;
321 if (fhConvertorCluster )
322 delete fhConvertorCluster ;
323 if (fhConvertorEmc )
324 delete fhConvertorEmc ;
325
326 fhEmcDigit = new TH1F("hEmcDigit", "hEmcDigit", 1000, 0. , 25.);
327 fhVetoDigit = new TH1F("hVetoDigit", "hVetoDigit", 500, 0. , 3.e-5);
328 fhConvertorDigit = new TH1F("hConvertorDigit","hConvertorDigit", 500, 0. , 3.e-5);
329 fhEmcCluster = new TH1F("hEmcCluster", "hEmcCluster", 1000, 0. , 30.);
330 fhVetoCluster = new TH1F("hVetoCluster", "hVetoCluster", 500, 0. , 3.e-5);
331 fhConvertorCluster = new TH1F("hConvertorCluster","hConvertorCluster",500, 0. , 3.e-5);
332 fhConvertorEmc = new TH2F("hConvertorEmc", "hConvertorEmc", 200, 1. , 3., 200, 0., 3.e-5);
333 fhPhotonEnergy = new TH1F("hPhotonEnergy", "hPhotonEnergy", 1000, 0. , 30.);
334 fhElectronEnergy = new TH1F("hElectronEnergy","hElectronEnergy", 1000, 0. , 30.);
335 fhNeutralHadronEnergy = new TH1F("hNeutralHadronEnergy", "hNeutralHadronEnergy", 1000, 0. , 30.);
336 fhNeutralEMEnergy = new TH1F("hNeutralEMEnergy", "hNeutralEMEnergy", 1000, 0. , 30.);
337 fhChargedHadronEnergy = new TH1F("hChargedHadronEnergy", "hChargedHadronEnergy", 1000, 0. , 30.);
c1d256cb 338 fhPhotonHadronEnergy = new TH1F("hPhotonHadronEnergy","hPhotonHadronEnergy",500,-80. , 80.);
b9bbdad1 339 fhPhotonPositionX = new TH1F("hPhotonPositionX","hPhotonPositionX", 500,-80. , 80.);
340 fhElectronPositionX = new TH1F("hElectronPositionX","hElectronPositionX",500,-80. , 80.);
341 fhNeutralHadronPositionX = new TH1F("hNeutralHadronPositionX","hNeutralHadronPositionX",500,-80. , 80.);
342 fhNeutralEMPositionX = new TH1F("hNeutralEMPositionX","hNeutralEMPositionX",500,-80. , 80.);
09fc14a0 343 fhChargedHadronPositionX = new TH1F("hChargedHadronPositionX","hChargedHadronPositionX",500,-80. , 80.);
c1d256cb 344 fhPhotonHadronPositionX = new TH1F("hPhotonHadronPositionX","hPhotonHadronPositionX",500,-80. , 80.);
b9bbdad1 345 fhPhotonPositionY = new TH1F("hPhotonPositionY","hPhotonPositionY", 500,-80. , 80.);
346 fhElectronPositionY = new TH1F("hElectronPositionY","hElectronPositionY",500,-80. , 80.);
347 fhNeutralHadronPositionY = new TH1F("hNeutralHadronPositionY","hNeutralHadronPositionY",500,-80. , 80.);
348 fhNeutralEMPositionY = new TH1F("hNeutralEMPositionY","hNeutralEMPositionY",500,-80. , 80.);
09fc14a0 349 fhChargedHadronPositionY = new TH1F("hChargedHadronPositionY","hChargedHadronPositionY",500,-80. , 80.);
c1d256cb 350 fhPhotonHadronPositionY = new TH1F("hPhotonHadronPositionY","hPhotonHadronPositionY",500,-80. , 80.);
92862013 351
3fc07a80 352
92862013 353}
6ad0bfa0 354//____________________________________________________________________________
355Bool_t AliPHOSAnalyze::Init(Int_t evt)
356{
b2a60966 357 // Do a few initializations: open the root file
358 // get the AliRun object
359 // defines the clusterizer, tracksegment maker and particle identifier
360 // sets the associated parameters
6ad0bfa0 361
92862013 362 Bool_t ok = kTRUE ;
6ad0bfa0 363
364 //========== Open galice root file
365
366 if ( fRootFile == 0 ) {
367 Text_t * name = new Text_t[80] ;
368 cout << "AnalyzeOneEvent > Enter file root file name : " ;
369 cin >> name ;
92862013 370 Bool_t ok = OpenRootFile(name) ;
371 if ( !ok )
6ad0bfa0 372 cout << " AliPHOSAnalyze > Error opening " << name << endl ;
373 else {
374 //========== Get AliRun object from file
375
376 gAlice = (AliRun*) fRootFile->Get("gAlice") ;
377
378 //=========== Get the PHOS object and associated geometry from the file
379
380 fPHOS = (AliPHOSv0 *)gAlice->GetDetector("PHOS") ;
381 fGeom = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() );
92862013 382 } // else !ok
6ad0bfa0 383 } // if fRootFile
384
92862013 385 if ( ok ) {
6ad0bfa0 386
387 //========== Create the Clusterizer
388
774e78c2 389 fClu = new AliPHOSClusterizerv1() ;
390 fClu->SetEmcEnergyThreshold(0.030) ;
b2a60966 391 fClu->SetEmcClusteringThreshold(1.0) ;
92862013 392 fClu->SetPpsdEnergyThreshold (0.0000002) ;
393 fClu->SetPpsdClusteringThreshold(0.0000001) ;
6ad0bfa0 394 fClu->SetLocalMaxCut(0.03) ;
92862013 395 fClu->SetCalibrationParameters(0., 0.00000001) ;
6ad0bfa0 396 cout << "AnalyzeOneEvent > using clusterizer " << fClu->GetName() << endl ;
397 fClu->PrintParameters() ;
398
399 //========== Creates the track segment maker
400
401 fTrs = new AliPHOSTrackSegmentMakerv1() ;
402 cout << "AnalyzeOneEvent > using tack segment maker " << fTrs->GetName() << endl ;
774e78c2 403 fTrs->UnsetUnfoldFlag() ;
6ad0bfa0 404
26d4b141 405 //========== Creates the particle identifier
6ad0bfa0 406
26d4b141 407 fPID = new AliPHOSPIDv1() ;
408 cout << "AnalyzeOneEvent > using particle identifier " << fPID->GetName() << endl ;
6ad0bfa0 409
410 //========== Creates the Reconstructioner
411
26d4b141 412 fRec = new AliPHOSReconstructioner(fClu, fTrs, fPID) ;
6ad0bfa0 413
414 //=========== Connect the various Tree's for evt
415
416 if ( evt == -999 ) {
417 cout << "AnalyzeOneEvent > Enter event number : " ;
418 cin >> evt ;
419 cout << evt << endl ;
420 }
421 fEvt = evt ;
422 gAlice->GetEvent(evt);
423
424 //=========== Get the Digit TTree
425
426 gAlice->TreeD()->GetEvent(0) ;
427
92862013 428 } // ok
6ad0bfa0 429
92862013 430 return ok ;
6ad0bfa0 431}
432
92862013 433
6ad0bfa0 434//____________________________________________________________________________
92862013 435void AliPHOSAnalyze::DisplayKineEvent(Int_t evt)
6ad0bfa0 436{
b2a60966 437 // Display particles from the Kine Tree in global Alice (theta, phi) coordinates.
438 // One PHOS module at the time.
439 // The particle type can be selected.
440
6ad0bfa0 441 if (evt == -999)
442 evt = fEvt ;
443
92862013 444 Int_t module ;
6ad0bfa0 445 cout << "DisplayKineEvent > which module (1-5, -1: all) ? " ;
92862013 446 cin >> module ; cout << module << endl ;
6ad0bfa0 447
92862013 448 Int_t testparticle ;
6ad0bfa0 449 cout << " 22 : PHOTON " << endl
450 << " (-)11 : (POSITRON)ELECTRON " << endl
451 << " (-)2112 : (ANTI)NEUTRON " << endl
452 << " -999 : Everything else " << endl ;
453 cout << "DisplayKineEvent > enter PDG particle code to display " ;
92862013 454 cin >> testparticle ; cout << testparticle << endl ;
6ad0bfa0 455
92862013 456 Text_t histoname[80] ;
457 sprintf(histoname,"Event %d: Incident particles in module %d", evt, module) ;
6ad0bfa0 458
92862013 459 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by module
460 fGeom->EmcModuleCoverage(module, tm, tM, pm, pM, kDegre) ;
6ad0bfa0 461
462 Double_t theta, phi ;
463 fGeom->EmcXtalCoverage(theta, phi, kDegre) ;
464
465 Int_t tdim = (Int_t)( (tM - tm) / theta ) ;
466 Int_t pdim = (Int_t)( (pM - pm) / phi ) ;
467
468 tm -= theta ;
469 tM += theta ;
470 pm -= phi ;
471 pM += phi ;
472
92862013 473 TH2F * histoparticle = new TH2F("histoparticle", histoname,
6ad0bfa0 474 pdim, pm, pM, tdim, tm, tM) ;
92862013 475 histoparticle->SetStats(kFALSE) ;
6ad0bfa0 476
477 // Get pointers to Alice Particle TClonesArray
478
92862013 479 TParticle * particle;
480 TClonesArray * particlearray = gAlice->Particles();
6ad0bfa0 481
92862013 482 Text_t canvasname[80];
483 sprintf(canvasname,"Particles incident in PHOS/EMC module # %d",module) ;
484 TCanvas * kinecanvas = new TCanvas("kinecanvas", canvasname, 650, 500) ;
6ad0bfa0 485
486 // get the KINE Tree
487
92862013 488 TTree * kine = gAlice->TreeK() ;
489 Stat_t nParticles = kine->GetEntries() ;
490 cout << "DisplayKineEvent > events in kine " << nParticles << endl ;
6ad0bfa0 491
492 // loop over particles
493
92862013 494 Double_t kRADDEG = 180. / TMath::Pi() ;
6ad0bfa0 495 Int_t index1 ;
496 Int_t nparticlein = 0 ;
92862013 497 for (index1 = 0 ; index1 < nParticles ; index1++){
498 Int_t nparticle = particlearray->GetEntriesFast() ;
6ad0bfa0 499 Int_t index2 ;
500 for( index2 = 0 ; index2 < nparticle ; index2++) {
92862013 501 particle = (TParticle*)particlearray->UncheckedAt(index2) ;
502 Int_t particletype = particle->GetPdgCode() ;
503 if (testparticle == -999 || testparticle == particletype) {
504 Double_t phi = particle->Phi() ;
505 Double_t theta = particle->Theta() ;
6ad0bfa0 506 Int_t mod ;
507 Double_t x, z ;
92862013 508 fGeom->ImpactOnEmc(theta, phi, mod, z, x) ;
509 if ( mod == module ) {
6ad0bfa0 510 nparticlein++ ;
b2a60966 511 if (particle->Energy() > fClu->GetEmcClusteringThreshold() )
512 histoparticle->Fill(phi*kRADDEG, theta*kRADDEG, particle->Energy() ) ;
6ad0bfa0 513 }
514 }
515 }
516 }
92862013 517 kinecanvas->Draw() ;
518 histoparticle->Draw("color") ;
519 TPaveText * pavetext = new TPaveText(294, 100, 300, 101);
6ad0bfa0 520 Text_t text[40] ;
521 sprintf(text, "Particles: %d ", nparticlein) ;
92862013 522 pavetext->AddText(text) ;
523 pavetext->Draw() ;
524 kinecanvas->Update();
6ad0bfa0 525
526}
527//____________________________________________________________________________
528void AliPHOSAnalyze::DisplayRecParticles()
529{
b2a60966 530 // Display reconstructed particles in global Alice(theta, phi) coordinates.
531 // One PHOS module at the time.
532 // Click on symbols indicate the reconstructed particle type.
533
6ad0bfa0 534 if (fEvt == -999) {
15605d3c 535 cout << "DisplayRecParticles > Analyze an event first ... (y/n) " ;
6ad0bfa0 536 Text_t answer[1] ;
537 cin >> answer ; cout << answer ;
538 if ( answer == "y" )
539 AnalyzeOneEvent() ;
540 }
541 if (fEvt != -999) {
542
92862013 543 Int_t module ;
15605d3c 544 cout << "DisplayRecParticles > which module (1-5, -1: all) ? " ;
92862013 545 cin >> module ; cout << module << endl ;
546 Text_t histoname[80] ;
547 sprintf(histoname,"Event %d: Reconstructed particles in module %d", fEvt, module) ;
548 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by module
549 fGeom->EmcModuleCoverage(module, tm, tM, pm, pM, kDegre) ;
6ad0bfa0 550 Double_t theta, phi ;
551 fGeom->EmcXtalCoverage(theta, phi, kDegre) ;
552 Int_t tdim = (Int_t)( (tM - tm) / theta ) ;
553 Int_t pdim = (Int_t)( (pM - pm) / phi ) ;
554 tm -= theta ;
555 tM += theta ;
556 pm -= phi ;
92862013 557 TH2F * histoRparticle = new TH2F("histoRparticle", histoname,
6ad0bfa0 558 pdim, pm, pM, tdim, tm, tM) ;
92862013 559 histoRparticle->SetStats(kFALSE) ;
560 Text_t canvasname[80] ;
561 sprintf(canvasname, "Reconstructed particles in PHOSmodule # %d", module) ;
562 TCanvas * rparticlecanvas = new TCanvas("RparticleCanvas", canvasname, 650, 500) ;
6ad0bfa0 563 RecParticlesList * rpl = fPHOS->RecParticles() ;
92862013 564 Int_t nRecParticles = rpl->GetEntries() ;
565 Int_t nRecParticlesInModule = 0 ;
6ad0bfa0 566 TIter nextRecPart(rpl) ;
567 AliPHOSRecParticle * rp ;
92862013 568 cout << "DisplayRecParticles > " << nRecParticles << " reconstructed particles " << endl ;
569 Double_t kRADDEG = 180. / TMath::Pi() ;
6ad0bfa0 570 while ( (rp = (AliPHOSRecParticle *)nextRecPart() ) ) {
571 AliPHOSTrackSegment * ts = rp->GetPHOSTrackSegment() ;
b2a60966 572 if ( ts->GetPHOSMod() == module ) {
573 Int_t numberofprimaries = 0 ;
574 Int_t * listofprimaries = rp->GetPrimaries(numberofprimaries) ;
575 cout << "Number of primaries = " << numberofprimaries << endl ;
576 Int_t index ;
577 for ( index = 0 ; index < numberofprimaries ; index++)
578 cout << " primary # " << index << " = " << listofprimaries[index] << endl ;
579
92862013 580 nRecParticlesInModule++ ;
581 Double_t theta = rp->Theta() * kRADDEG ;
582 Double_t phi = rp->Phi() * kRADDEG ;
6ad0bfa0 583 Double_t energy = rp->Energy() ;
92862013 584 histoRparticle->Fill(phi, theta, energy) ;
6ad0bfa0 585 }
586 }
92862013 587 histoRparticle->Draw("color") ;
15605d3c 588
589 nextRecPart.Reset() ;
590 while ( (rp = (AliPHOSRecParticle *)nextRecPart() ) ) {
591 AliPHOSTrackSegment * ts = rp->GetPHOSTrackSegment() ;
592 if ( ts->GetPHOSMod() == module )
593 rp->Draw("P") ;
594 }
595
6ad0bfa0 596 Text_t text[80] ;
92862013 597 sprintf(text, "reconstructed particles: %d", nRecParticlesInModule) ;
598 TPaveText * pavetext = new TPaveText(292, 100, 300, 101);
599 pavetext->AddText(text) ;
600 pavetext->Draw() ;
601 rparticlecanvas->Update() ;
6ad0bfa0 602 }
603}
604
605//____________________________________________________________________________
606void AliPHOSAnalyze::DisplayRecPoints()
607{
b2a60966 608 // Display reconstructed points in local PHOS-module (x, z) coordinates.
609 // One PHOS module at the time.
610 // Click on symbols displays the EMC cluster, or PPSD information.
611
6ad0bfa0 612 if (fEvt == -999) {
613 cout << "DisplayRecPoints > Analyze an event first ... (y/n) " ;
614 Text_t answer[1] ;
615 cin >> answer ; cout << answer ;
616 if ( answer == "y" )
617 AnalyzeOneEvent() ;
618 }
619 if (fEvt != -999) {
620
92862013 621 Int_t module ;
6ad0bfa0 622 cout << "DisplayRecPoints > which module (1-5, -1: all) ? " ;
92862013 623 cin >> module ; cout << module << endl ;
6ad0bfa0 624
92862013 625 Text_t canvasname[80];
626 sprintf(canvasname,"Digits in PHOS/EMC module # %d",module) ;
627 TCanvas * modulecanvas = new TCanvas("module", canvasname, 650, 500) ;
628 modulecanvas->Draw() ;
6ad0bfa0 629
92862013 630 //=========== Creating 2d-histogram of the PHOS module
6ad0bfa0 631 // a little bit junkie but is used to test Geom functinalities
632
92862013 633 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by module
6ad0bfa0 634
92862013 635 fGeom->EmcModuleCoverage(module, tm, tM, pm, pM);
6ad0bfa0 636 // convert angles into coordinates local to the EMC module of interest
637
92862013 638 Int_t emcModuleNumber ;
639 Double_t emcModulexm, emcModulezm ; // minimum local coordinate in a given EMCA module
640 Double_t emcModulexM, emcModulezM ; // maximum local coordinate in a given EMCA module
641 fGeom->ImpactOnEmc(tm, pm, emcModuleNumber, emcModulezm, emcModulexm) ;
642 fGeom->ImpactOnEmc(tM, pM, emcModuleNumber, emcModulezM, emcModulexM) ;
643 Int_t xdim = (Int_t)( ( emcModulexM - emcModulexm ) / fGeom->GetCrystalSize(0) ) ;
644 Int_t zdim = (Int_t)( ( emcModulezM - emcModulezm ) / fGeom->GetCrystalSize(2) ) ;
645 Float_t xmin = emcModulexm - fGeom->GetCrystalSize(0) ;
646 Float_t xMax = emcModulexM + fGeom->GetCrystalSize(0) ;
647 Float_t zmin = emcModulezm - fGeom->GetCrystalSize(2) ;
648 Float_t zMax = emcModulezM + fGeom->GetCrystalSize(2) ;
649 Text_t histoname[80];
650 sprintf(histoname,"Event %d: Digits and RecPoints in module %d", fEvt, module) ;
651 TH2F * hModule = new TH2F("HistoReconstructed", histoname,
6ad0bfa0 652 xdim, xmin, xMax, zdim, zmin, zMax) ;
653 hModule->SetMaximum(2.0);
654 hModule->SetMinimum(0.0);
655 hModule->SetStats(kFALSE);
656
657 TIter next(fPHOS->Digits()) ;
92862013 658 Float_t energy, y, z;
659 Float_t etot=0.;
660 Int_t relid[4]; Int_t nDigits = 0 ;
6ad0bfa0 661 AliPHOSDigit * digit ;
78ccc411 662
663 // Making 2D histogram of the EMC module
6ad0bfa0 664 while((digit = (AliPHOSDigit *)next()))
665 {
92862013 666 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
78ccc411 667 if (relid[0] == module && relid[1] == 0)
5959e315 668 {
92862013 669 energy = fClu->Calibrate(digit->GetAmp()) ;
774e78c2 670 cout << "Energy is " << energy << " and threshold is " << fClu->GetEmcEnergyThreshold() << endl;
78ccc411 671 if (energy > fClu->GetEmcEnergyThreshold() ){
5959e315 672 nDigits++ ;
673 etot += energy ;
674 fGeom->RelPosInModule(relid,y,z) ;
675 hModule->Fill(y, z, energy) ;
3fc07a80 676 }
6ad0bfa0 677 }
678 }
92862013 679 cout <<"DrawRecPoints > Found in module "
680 << module << " " << nDigits << " digits with total energy " << etot << endl ;
6ad0bfa0 681 hModule->Draw("col2") ;
682
92862013 683 //=========== Cluster in module
6ad0bfa0 684
92862013 685 TClonesArray * emcRP = fPHOS->EmcClusters() ;
686 etot = 0.;
687 Int_t totalnClusters = 0 ;
688 Int_t nClusters = 0 ;
689 TIter nextemc(emcRP) ;
6ad0bfa0 690 AliPHOSEmcRecPoint * emc ;
691 while((emc = (AliPHOSEmcRecPoint *)nextemc()))
692 {
3fc07a80 693 // Int_t numberofprimaries ;
694 // Int_t * primariesarray = new Int_t[10] ;
695 // emc->GetPrimaries(numberofprimaries, primariesarray) ;
92862013 696 totalnClusters++ ;
697 if ( emc->GetPHOSMod() == module )
6ad0bfa0 698 {
92862013 699 nClusters++ ;
700 energy = emc->GetTotalEnergy() ;
701 etot+= energy ;
26d4b141 702 emc->Draw("M") ;
6ad0bfa0 703 }
704 }
92862013 705 cout << "DrawRecPoints > Found " << totalnClusters << " EMC Clusters in PHOS" << endl ;
706 cout << "DrawRecPoints > Found in module " << module << " " << nClusters << " EMC Clusters " << endl ;
707 cout << "DrawRecPoints > total energy " << etot << endl ;
6ad0bfa0 708
92862013 709 TPaveText * pavetext = new TPaveText(22, 80, 83, 90);
6ad0bfa0 710 Text_t text[40] ;
92862013 711 sprintf(text, "digits: %d; clusters: %d", nDigits, nClusters) ;
712 pavetext->AddText(text) ;
713 pavetext->Draw() ;
714 modulecanvas->Update();
6ad0bfa0 715
92862013 716 //=========== Cluster in module PPSD Down
6ad0bfa0 717
92862013 718 TClonesArray * ppsdRP = fPHOS->PpsdClusters() ;
719 etot = 0.;
720 TIter nextPpsd(ppsdRP) ;
721 AliPHOSPpsdRecPoint * ppsd ;
722 while((ppsd = (AliPHOSPpsdRecPoint *)nextPpsd()))
6ad0bfa0 723 {
92862013 724 totalnClusters++ ;
725 if ( ppsd->GetPHOSMod() == module )
6ad0bfa0 726 {
92862013 727 nClusters++ ;
728 energy = ppsd->GetEnergy() ;
729 etot+=energy ;
730 if (!ppsd->GetUp()) ppsd->Draw("P") ;
6ad0bfa0 731 }
732 }
92862013 733 cout << "DrawRecPoints > Found " << totalnClusters << " Ppsd Down Clusters in PHOS" << endl ;
734 cout << "DrawRecPoints > Found in module " << module << " " << nClusters << " Ppsd Down Clusters " << endl ;
735 cout << "DrawRecPoints > total energy " << etot << endl ;
6ad0bfa0 736
92862013 737 //=========== Cluster in module PPSD Up
6ad0bfa0 738
92862013 739 ppsdRP = fPHOS->PpsdClusters() ;
740 etot = 0.;
741 TIter nextPpsdUp(ppsdRP) ;
742 while((ppsd = (AliPHOSPpsdRecPoint *)nextPpsdUp()))
6ad0bfa0 743 {
92862013 744 totalnClusters++ ;
745 if ( ppsd->GetPHOSMod() == module )
6ad0bfa0 746 {
92862013 747 nClusters++ ;
748 energy = ppsd->GetEnergy() ;
749 etot+=energy ;
750 if (ppsd->GetUp()) ppsd->Draw("P") ;
6ad0bfa0 751 }
752 }
92862013 753 cout << "DrawRecPoints > Found " << totalnClusters << " Ppsd Up Clusters in PHOS" << endl ;
754 cout << "DrawRecPoints > Found in module " << module << " " << nClusters << " Ppsd Up Clusters " << endl ;
755 cout << "DrawRecPoints > total energy " << etot << endl ;
6ad0bfa0 756
757 } // if !-999
758}
759
760//____________________________________________________________________________
761void AliPHOSAnalyze::DisplayTrackSegments()
762{
b2a60966 763 // Display track segments in local PHOS-module (x, z) coordinates.
764 // One PHOS module at the time.
765 // One symbol per PHOS subsystem: EMC, upper PPSD, lower PPSD.
766
6ad0bfa0 767 if (fEvt == -999) {
768 cout << "DisplayTrackSegments > Analyze an event first ... (y/n) " ;
769 Text_t answer[1] ;
770 cin >> answer ; cout << answer ;
771 if ( answer == "y" )
772 AnalyzeOneEvent() ;
773 }
774 if (fEvt != -999) {
775
92862013 776 Int_t module ;
6ad0bfa0 777 cout << "DisplayTrackSegments > which module (1-5, -1: all) ? " ;
92862013 778 cin >> module ; cout << module << endl ;
779 //=========== Creating 2d-histogram of the PHOS module
6ad0bfa0 780 // a little bit junkie but is used to test Geom functinalities
781
92862013 782 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by module
6ad0bfa0 783
92862013 784 fGeom->EmcModuleCoverage(module, tm, tM, pm, pM);
6ad0bfa0 785 // convert angles into coordinates local to the EMC module of interest
786
92862013 787 Int_t emcModuleNumber ;
788 Double_t emcModulexm, emcModulezm ; // minimum local coordinate in a given EMCA module
789 Double_t emcModulexM, emcModulezM ; // maximum local coordinate in a given EMCA module
790 fGeom->ImpactOnEmc(tm, pm, emcModuleNumber, emcModulezm, emcModulexm) ;
791 fGeom->ImpactOnEmc(tM, pM, emcModuleNumber, emcModulezM, emcModulexM) ;
792 Int_t xdim = (Int_t)( ( emcModulexM - emcModulexm ) / fGeom->GetCrystalSize(0) ) ;
793 Int_t zdim = (Int_t)( ( emcModulezM - emcModulezm ) / fGeom->GetCrystalSize(2) ) ;
794 Float_t xmin = emcModulexm - fGeom->GetCrystalSize(0) ;
795 Float_t xMax = emcModulexM + fGeom->GetCrystalSize(0) ;
796 Float_t zmin = emcModulezm - fGeom->GetCrystalSize(2) ;
797 Float_t zMax = emcModulezM + fGeom->GetCrystalSize(2) ;
798 Text_t histoname[80];
799 sprintf(histoname,"Event %d: Track Segments in module %d", fEvt, module) ;
800 TH2F * histotrack = new TH2F("histotrack", histoname,
6ad0bfa0 801 xdim, xmin, xMax, zdim, zmin, zMax) ;
92862013 802 histotrack->SetStats(kFALSE);
803 Text_t canvasname[80];
804 sprintf(canvasname,"Track segments in PHOS/EMC-PPSD module # %d", module) ;
805 TCanvas * trackcanvas = new TCanvas("TrackSegmentCanvas", canvasname, 650, 500) ;
806 histotrack->Draw() ;
6ad0bfa0 807
808 TrackSegmentsList * trsegl = fPHOS->TrackSegments() ;
809 AliPHOSTrackSegment * trseg ;
810
92862013 811 Int_t nTrackSegments = trsegl->GetEntries() ;
6ad0bfa0 812 Int_t index ;
92862013 813 Float_t etot = 0 ;
814 Int_t nTrackSegmentsInModule = 0 ;
815 for(index = 0; index < nTrackSegments ; index++){
6ad0bfa0 816 trseg = (AliPHOSTrackSegment * )trsegl->At(index) ;
92862013 817 etot+= trseg->GetEnergy() ;
818 if ( trseg->GetPHOSMod() == module ) {
819 nTrackSegmentsInModule++ ;
6ad0bfa0 820 trseg->Draw("P");
821 }
822 }
823 Text_t text[80] ;
92862013 824 sprintf(text, "track segments: %d", nTrackSegmentsInModule) ;
825 TPaveText * pavetext = new TPaveText(22, 80, 83, 90);
826 pavetext->AddText(text) ;
827 pavetext->Draw() ;
828 trackcanvas->Update() ;
829 cout << "DisplayTrackSegments > Found " << trsegl->GetEntries() << " Track segments with total energy "<< etot << endl ;
6ad0bfa0 830
831 }
832}
833//____________________________________________________________________________
834Bool_t AliPHOSAnalyze::OpenRootFile(Text_t * name)
835{
b2a60966 836 // Open the root file named "name"
837
838 fRootFile = new TFile(name, "update") ;
6ad0bfa0 839 return fRootFile->IsOpen() ;
840}
92862013 841//____________________________________________________________________________
842void AliPHOSAnalyze::SavingHistograms()
843{
b2a60966 844 // Saves the histograms in a root file named "name.analyzed"
845
846 Text_t outputname[80] ;
3862b681 847 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
848 TFile output(outputname,"RECREATE");
92862013 849 output.cd();
b9bbdad1 850 if (fhEmcDigit )
851 fhEmcDigit->Write() ;
852 if (fhVetoDigit )
853 fhVetoDigit->Write() ;
854 if (fhConvertorDigit )
855 fhConvertorDigit->Write() ;
856 if (fhEmcCluster )
857 fhEmcCluster->Write() ;
858 if (fhVetoCluster )
859 fhVetoCluster->Write() ;
860 if (fhConvertorCluster )
861 fhConvertorCluster->Write() ;
862 if (fhConvertorEmc )
863 fhConvertorEmc->Write() ;
864 if (fhPhotonEnergy)
865 fhPhotonEnergy->Write() ;
866 if (fhPhotonPositionX)
867 fhPhotonPositionX->Write() ;
868 if (fhPhotonPositionY)
869 fhPhotonPositionX->Write() ;
870 if (fhElectronEnergy)
871 fhElectronEnergy->Write() ;
872 if (fhElectronPositionX)
873 fhElectronPositionX->Write() ;
874 if (fhElectronPositionY)
875 fhElectronPositionX->Write() ;
876 if (fhNeutralHadronEnergy)
877 fhNeutralHadronEnergy->Write() ;
878 if (fhNeutralHadronPositionX)
879 fhNeutralHadronPositionX->Write() ;
880 if (fhNeutralHadronPositionY)
881 fhNeutralHadronPositionX->Write() ;
882 if (fhNeutralEMEnergy)
883 fhNeutralEMEnergy->Write() ;
884 if (fhNeutralEMPositionX)
885 fhNeutralEMPositionX->Write() ;
886 if (fhNeutralEMPositionY)
887 fhNeutralEMPositionX->Write() ;
888 if (fhChargedHadronEnergy)
889 fhChargedHadronEnergy->Write() ;
890 if (fhChargedHadronPositionX)
891 fhChargedHadronPositionX->Write() ;
892 if (fhChargedHadronPositionY)
893 fhChargedHadronPositionX->Write() ;
c1d256cb 894 if (fhPhotonHadronEnergy)
895 fhPhotonHadronEnergy->Write() ;
896 if (fhPhotonHadronPositionX)
897 fhPhotonHadronPositionX->Write() ;
898 if (fhPhotonHadronPositionY)
899 fhPhotonHadronPositionX->Write() ;
92862013 900
901 output.Write();
902 output.Close();
903}