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 **************************************************************************/
18 //_________________________________________________________________________
19 // Algorythm class to analyze PHOS events. In this class we demostrate,
20 // how to handle reconstructed objects with AliPHSOIndexToObject.
21 // As an example we propose sulotions for four most frequently used tasks:
22 // DrawRecon(...) - to draw reconstructed objects in the PHOS plane,
23 // very usefull in the debuging
24 // InvarianMass(...) - to calculate "REAL" and "MIXED" photon pairs
25 // invariant mass distributions
26 // EnergyResoluition(...) -\ Energy and position resolutions of the
27 // PositionResolution(...)-/ reconstructed photons
28 // Contamination(...) - calculates contamination of the photon spectrum and
29 // pobability of reconstruction of several primaries as
30 // kGAMMA,kELECTRON etc.
33 // root [0] AliPHOSAnalyze * a = new AliPHOSAnalyze("galice.root")
34 // // set the file you want to analyse
35 // root [1] a->DrawRecon(1,3)
36 // // plot RecObjects, made in event 1, PHOS module 3
37 // root [2] a->DrawRecon(1,3,"PHOSRP","another PID")
38 // // plot RecObjets made in the event 1, PHOS module 3,
39 // // produced in the another reconstruction pass,
40 // // which produced PHOS RecParticles ("PHOSRP") with
41 // // title "another PID".
42 // root [3] a->InvariantMass()
43 // // Calculates "REAL" and "MIXED" invariant mass
44 // // distributions of kGAMMA and (kGAMMA+kNEUTRALEM)
45 // // and APPENDS this to the file "invmass.root"
46 // root [4] a->PositionResolution()
47 // // calculates two dimentional histos: energy of the primary
48 // // photon vs distance betwin incedence point and reconstructed
49 // // poisition. One can analyse the produced file position.root
50 // // with macro PhotonPosition.C
51 // root [5] a->EnergyResolution()
52 // // calculates two dimentional histos: energy of the primary
53 // // photon vs energy of the reconstructed particle. One can
54 // // analyse the produced file energy.root
55 // // with macro PhotonEnergy.C
56 // root [6] a->Contamination()
57 // // fills spectra of primary photons and several kinds of
58 // // reconstructed particles, so that analyzing them one can
59 // // estimate conatmination, efficiency of registration etc.
61 //*-- Author: Dmitri Peressounko (SUBATECH & RRC Kurchatov Institute)
62 //////////////////////////////////////////////////////////////////////////////
65 // --- ROOT system ---
71 #include "TParticle.h"
72 #include "TClonesArray.h"
78 // --- Standard library ---
82 // --- AliRoot header files ---
85 #include "AliPHOSv1.h"
86 #include "AliPHOSAnalyze.h"
87 #include "AliPHOSDigit.h"
88 #include "AliPHOSSDigitizer.h"
89 #include "AliPHOSTrackSegment.h"
90 #include "AliPHOSRecParticle.h"
91 #include "AliPHOSCpvRecPoint.h"
92 #include "AliPHOSGetter.h"
95 ClassImp(AliPHOSAnalyze)
97 //____________________________________________________________________________
98 AliPHOSAnalyze::AliPHOSAnalyze()
100 // default ctor (useless)
101 fCorrection = 1.2 ; //Value calculated for default parameters of reconstruction
104 //____________________________________________________________________________
105 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName)
107 // ctor: analyze events from root file "name"
108 ffileName = fileName ;
109 fCorrection = 1.05 ; //Value calculated for default parameters of reconstruction
112 //____________________________________________________________________________
113 AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana)
116 ( (AliPHOSAnalyze &)ana ).Copy(*this) ;
119 //____________________________________________________________________________
120 AliPHOSAnalyze::~AliPHOSAnalyze()
125 //____________________________________________________________________________
126 void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,const char* branchTitle){
127 //Draws pimary particles and reconstructed
128 //digits, RecPoints, RecPartices etc
129 //for event Nevent in the module Nmod.
131 //========== Create ObjectGetter
132 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
133 if(Nevent >= gAlice->TreeE()->GetEntries() ) {
134 cout << "There is no event " << Nevent << ", only " << gAlice->TreeE()->GetEntries() << "events available " <<endl ;
137 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
140 Int_t nx = phosgeom->GetNPhi() ;
141 Int_t nz = phosgeom->GetNZ() ;
142 Float_t * cri= phosgeom->GetEMCAGeometry()->GetCrystalHalfSize() ;
143 Float_t x = nx*cri[0] ;
144 Float_t z = nz*cri[2] ;
145 Int_t nxCPV = (Int_t) (nx*phosgeom->GetPadSizePhi()/(2.*cri[0])) ;
146 Int_t nzCPV = (Int_t) (nz*phosgeom->GetPadSizeZ()/(2.*cri[2])) ;
148 TH2F * emcDigits = (TH2F*) gROOT->FindObject("emcDigits") ;
150 emcDigits->Delete() ;
151 emcDigits = new TH2F("emcDigits","EMC digits", nx,-x,x,nz,-z,z);
152 TH2F * emcSdigits =(TH2F*) gROOT->FindObject("emcSdigits") ;
154 emcSdigits->Delete() ;
155 emcSdigits = new TH2F("emcSdigits","EMC sdigits", nx,-x,x,nz,-z,z);
156 TH2F * emcRecPoints = (TH2F*)gROOT->FindObject("emcRecPoints") ;
158 emcRecPoints->Delete() ;
159 emcRecPoints = new TH2F("emcRecPoints","EMC RecPoints",nx,-x,x,nz,-z,z);
160 TH2F * cpvSdigits =(TH2F*) gROOT->FindObject("cpvSdigits") ;
162 cpvSdigits->Delete() ;
163 cpvSdigits = new TH2F("cpvSdigits","CPV sdigits", nx,-x,x,nz,-z,z);
164 TH2F * cpvDigits = (TH2F*)gROOT->FindObject("cpvDigits") ;
166 cpvDigits->Delete() ;
167 cpvDigits = new TH2F("cpvDigits","CPV digits", nxCPV,-x,x,nzCPV,-z,z) ;
168 TH2F * cpvRecPoints= (TH2F*)gROOT->FindObject("cpvRecPoints") ;
170 cpvRecPoints->Delete() ;
171 cpvRecPoints = new TH2F("cpvRecPoints","CPV RecPoints", nxCPV,-x,x,nzCPV,-z,z) ;
173 TH2F * phot = (TH2F*)gROOT->FindObject("phot") ;
176 phot = new TH2F("phot","Primary Photon", nx,-x,x,nz,-z,z);
177 TH2F * recPhot = (TH2F*)gROOT->FindObject("recPhot") ;
180 recPhot = new TH2F("recPhot","RecParticles with primary Photon",nx,-x,x,nz,-z,z);
183 //Plot Primary Particles
184 const TParticle * primary ;
186 for ( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++)
188 primary = gime->Primary(iPrimary) ;
189 Int_t primaryType = primary->GetPdgCode() ;
190 // if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212)
191 // ||(primaryType == 11)||(primaryType == -11) ) {
192 // Int_t moduleNumber ;
193 // Double_t primX, primZ ;
194 // phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
195 // if(moduleNumber==Nmod)
196 // charg->Fill(primZ,primX,primary->Energy()) ;
198 if( primaryType == 22 ) {
200 Double_t primX, primZ ;
201 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
202 if(moduleNumber==Nmod)
203 phot->Fill(primZ,primX,primary->Energy()) ;
206 // if( primaryType == -2112 ) {
207 // Int_t moduleNumber ;
208 // Double_t primX, primZ ;
209 // phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
210 // if(moduleNumber==Nmod)
211 // nbar->Fill(primZ,primX,primary->Energy()) ;
218 AliPHOSDigit * sdigit ;
219 const TClonesArray * sdigits = gime->SDigits() ;
220 Int_t nsdig[5] = {0,0,0,0,0} ;
222 for(iSDigit = 0; iSDigit < sdigits->GetEntriesFast() ; iSDigit++)
224 sdigit = (AliPHOSDigit *) sdigits->At(iSDigit) ;
226 phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
228 phosgeom->RelPosInModule(relid,x,z) ;
229 Float_t e = gime->SDigitizer()->Calibrate(sdigit->GetAmp()) ;
230 nsdig[relid[0]-1]++ ;
232 if(relid[1]==0) //EMC
233 emcSdigits->Fill(x,z,e) ;
235 cpvSdigits->Fill(x,z,e) ;
239 cout << "Number of EMC + CPV SDigits per module: " <<endl ;
240 cout << nsdig[0] << " " << nsdig[1] << " " << nsdig[2] << " " << nsdig[3]<< " " << nsdig[4] << endl ;
246 AliPHOSDigit * digit ;
247 const TClonesArray * digits = gime->Digits();
249 for(iDigit = 0; iDigit < digits->GetEntriesFast(); iDigit++)
251 digit = (AliPHOSDigit *) digits->At(iDigit) ;
253 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
255 phosgeom->RelPosInModule(relid,x,z) ;
256 Float_t e = gime->SDigitizer()->Calibrate(digit->GetAmp()) ;
258 if(relid[1]==0) //EMC
259 emcDigits->Fill(x,z,e) ;
261 cpvDigits->Fill(x,z,e) ;
270 TObjArray * emcrp = gime->EmcRecPoints() ;
272 for(irecp = 0; irecp < emcrp->GetEntriesFast() ; irecp ++){
273 AliPHOSEmcRecPoint * emc = (AliPHOSEmcRecPoint *) emcrp->At(irecp) ;
274 if(emc->GetPHOSMod()==Nmod){
275 emc->GetLocalPosition(pos) ;
276 emcRecPoints->Fill(pos.X(),pos.Z(),emc->GetEnergy());
281 TObjArray * cpvrp = gime->CpvRecPoints() ;
283 for(irecp = 0; irecp < cpvrp->GetEntriesFast() ; irecp ++){
284 AliPHOSRecPoint * cpv = (AliPHOSCpvRecPoint *) cpvrp->At(irecp) ;
285 if(cpv->GetPHOSMod()==Nmod){
286 cpv->GetLocalPosition(pos) ;
287 cpvRecPoints->Fill(pos.X(),pos.Z(),cpv->GetEnergy());
293 AliPHOSRecParticle * recParticle ;
295 TClonesArray * rp = gime->RecParticles() ;
296 TClonesArray * ts = gime->TrackSegments() ;
297 if(rp && ts && emcrp) {
298 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast() ; iRecParticle++ )
300 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
301 Int_t moduleNumberRec ;
302 Double_t recX, recZ ;
303 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
304 if(moduleNumberRec == Nmod){
306 Double_t minDistance = 5. ;
307 Int_t closestPrimary = -1 ;
309 //extract list of primaries: it is stored at EMC RecPoints
310 Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
311 Int_t numberofprimaries ;
312 Int_t * listofprimaries = ((AliPHOSRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
314 const TParticle * primary ;
315 Double_t distance = minDistance ;
317 for ( index = 0 ; index < numberofprimaries ; index++){
318 primary = gime->Primary(listofprimaries[index]) ;
320 Double_t primX, primZ ;
321 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
322 if(moduleNumberRec == moduleNumber)
323 distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ;
324 if(minDistance > distance)
326 minDistance = distance ;
327 closestPrimary = listofprimaries[index] ;
331 if(closestPrimary >=0 ){
333 Int_t primaryType = gime->Primary(closestPrimary)->GetPdgCode() ;
336 recPhot->Fill(recZ,recX,recParticle->Energy()) ;
338 // if(primaryType==-2112)
339 // recNbar->Fill(recZ,recX,recParticle->Energy()) ;
346 //Plot made histograms
347 emcSdigits->Draw("box") ;
348 emcDigits->SetLineColor(5) ;
349 emcDigits->Draw("boxsame") ;
350 emcRecPoints->SetLineColor(2) ;
351 emcRecPoints->Draw("boxsame") ;
352 cpvSdigits->SetLineColor(1) ;
353 cpvSdigits->Draw("boxsame") ;
356 //____________________________________________________________________________
357 void AliPHOSAnalyze::Ls(){
358 //lists branches and titles of PHOS-related branches of TreeR, TreeD, TreeS
360 AliPHOSGetter::GetInstance(ffileName.Data()) ;
363 TObjArray * branches;
365 branches = gAlice->TreeS()->GetListOfBranches() ;
367 cout << "TreeS: " << endl ;
368 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
369 TBranch * branch=(TBranch *) branches->At(ibranch) ;
370 if(strstr(branch->GetName(),"PHOS") )
371 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
375 branches = gAlice->TreeD()->GetListOfBranches() ;
377 cout << "TreeD: " << endl ;
378 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
379 TBranch * branch=(TBranch *) branches->At(ibranch) ;
380 if(strstr(branch->GetName(),"PHOS") )
381 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
386 branches = gAlice->TreeR()->GetListOfBranches() ;
388 cout << "TreeR: " << endl ;
389 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
390 TBranch * branch=(TBranch *) branches->At(ibranch) ;
391 if(strstr(branch->GetName(),"PHOS") )
392 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
398 //____________________________________________________________________________
399 void AliPHOSAnalyze::InvariantMass(const char* branchTitle)
401 // Calculates Real and Mixed invariant mass distributions
402 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
404 Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
407 TFile * mfile = new TFile("invmass.root","update");
409 //========== Reading /Booking Histograms
411 hRealEM = (TH2D*) mfile->Get("hRealEM") ;
413 hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
414 TH2D * hRealPhot = 0 ;
416 hRealPhot = (TH2D*)mfile->Get("hRealPhot");
418 hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
420 TH2D * hMixedEM = 0 ;
421 hMixedEM = (TH2D*) mfile->Get("hMixedEM") ;
423 hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
425 TH2D * hMixedPhot = 0 ;
426 hMixedPhot = (TH2D*) mfile->Get("hMixedPhot") ;
428 hMixedPhot = new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
431 //reading event and copyng it to TConesArray of all photons
433 TClonesArray * allRecParticleList = new TClonesArray("AliPHOSRecParticle", 1000) ;
434 Int_t * nRecParticles = new Int_t[nMixedEvents] ; // to mark boundaries of each event in the total list
435 for(Int_t index = 0; index < nMixedEvents; index ++)
436 nRecParticles[index] = 0 ;
437 Int_t iRecPhot = 0 ; // number of EM particles in total list
439 //scan over all events
441 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
442 // for(event = 0; event < gime->MaxEvent(); event++ ){
443 for(event = 0; event < maxevent; event++ ){
444 gime->Event(event,"R"); //will read only TreeR
446 //copy EM RecParticles to the "total" list
447 const AliPHOSRecParticle * recParticle ;
449 TClonesArray * rp = gime->RecParticles() ;
451 cout << "AliPHOSAnalyze::InvariantMass --> Can't find RecParticles " << endl ;
455 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ )
457 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
458 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
459 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW))
460 new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ;
463 Int_t mevent = event%nMixedEvents ; //event number in the "mixed" cicle
464 nRecParticles[mevent] = iRecPhot-1 ;
466 //check, if it is time to calculate invariant mass?
467 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
468 if((mevent == 0) && (event +1 == maxevent)){
470 // if((mevent == 0) && (event +1 == gime->MaxEvent())){
472 //calculate invariant mass:
474 Int_t nCurEvent = 0 ;
476 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
477 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
479 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
480 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
483 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
484 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
485 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
486 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
489 invMass = TMath::Sqrt(invMass);
492 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +
493 (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) );
495 if(irp1 > nRecParticles[nCurEvent])
498 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
499 hRealEM->Fill(invMass,pt);
500 if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&&
501 (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) )
502 hRealPhot->Fill(invMass,pt);
505 hMixedEM->Fill(invMass,pt);
506 if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&&
507 (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) )
508 hMixedPhot->Fill(invMass,pt);
511 } //loop over second rp
512 }//loop over first rp
514 //Make some cleanings
515 for(Int_t index = 0; index < nMixedEvents; index ++)
516 nRecParticles[index] = 0 ;
518 allRecParticleList->Clear() ;
522 delete allRecParticleList ;
527 hRealEM->Write(0,kOverwrite) ;
528 hRealPhot->Write(0,kOverwrite) ;
529 hMixedEM->Write(0,kOverwrite) ;
530 hMixedPhot->Write(0,kOverwrite) ;
535 delete nRecParticles;
539 //____________________________________________________________________________
540 void AliPHOSAnalyze::EnergyResolution(const char * branchTitle)
542 //fills two dimentional histo: energy of primary vs. energy of reconstructed
544 TH2F * hAllEnergy = 0 ; //all reconstructed with primary photon
545 TH2F * hPhotEnergy= 0 ; //kGamma with primary photon
546 TH2F * hEMEnergy = 0 ; //electromagnetic with primary photon
548 //opening file and reading histograms if any
549 TFile * efile = new TFile("energy.root","update");
551 hAllEnergy = (TH2F*)efile->Get("hAllEnergy") ;
553 hAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
555 hPhotEnergy =(TH2F*) efile->Get("hPhotEnergy") ;
557 hPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
559 hEMEnergy =(TH2F*) efile->Get("hEMEnergy");
561 hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
564 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
565 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
568 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
569 for ( ievent=0; ievent < maxevent ; ievent++){
571 //read the current event
572 gime->Event(ievent) ;
574 const AliPHOSRecParticle * recParticle ;
576 TClonesArray * rp = gime->RecParticles() ;
578 cout << "AliPHOSAnalyze::EnergyResolution --> Event " <<ievent
579 << ", Can't find RecParticles " << endl ;
582 TClonesArray * ts = gime->TrackSegments() ;
584 cout << "AliPHOSAnalyze::EnergyResolution --> Event " <<ievent
585 << ", Can't find TrackSegments " << endl ;
588 TObjArray * emcrp = gime->EmcRecPoints() ;
590 cout << "AliPHOSAnalyze::EnergyResolution --> Event " <<ievent
591 << ", Can't find EmcRecPoints " << endl ;
595 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast() ;iRecParticle++ ){
596 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
598 //find the closest primary
599 Int_t moduleNumberRec ;
600 Double_t recX, recZ ;
601 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
603 Double_t minDistance = 100. ;
604 Int_t closestPrimary = -1 ;
606 //extract list of primaries: it is stored at EMC RecPoints
607 Int_t emcIndex = ((AliPHOSTrackSegment*) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
608 Int_t numberofprimaries ;
609 Int_t * listofprimaries = ((AliPHOSEmcRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
612 const TParticle * primary ;
613 Double_t distance = minDistance ;
616 Double_t dZmin = 0. ;
617 for ( index = 0 ; index < numberofprimaries ; index++){
618 primary = gime->Primary(listofprimaries[index]) ;
620 Double_t primX, primZ ;
621 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
622 if(moduleNumberRec == moduleNumber) {
625 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
626 if(minDistance > distance) {
627 minDistance = distance ;
630 closestPrimary = listofprimaries[index] ;
635 //if found primary, fill histograms
636 if(closestPrimary >=0 ){
637 const TParticle * primary = gime->Primary(closestPrimary) ;
638 if(primary->GetPdgCode() == 22){
639 hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ;
640 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
641 hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
642 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
645 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)
646 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
652 //write filled histograms
654 hAllEnergy->Write(0,kOverwrite) ;
655 hPhotEnergy->Write(0,kOverwrite) ;
656 hEMEnergy->Write(0,kOverwrite) ;
662 //____________________________________________________________________________
663 void AliPHOSAnalyze::PositionResolution(const char * branchTitle)
665 //fills two dimentional histo: energy vs. primary - reconstructed distance
669 TH2F * hAllPosition = 0; // Position of any RP with primary photon
670 TH2F * hPhotPosition = 0; // Position of kGAMMA with primary photon
671 TH2F * hEMPosition = 0; // Position of EM with primary photon
673 TH1F * hAllPositionX = 0; // X-Position Resolution of photons with photon primary
674 TH1F * hAllPositionZ = 0; // Z-Position Resolution of photons with photon primary
677 //opening file and reading histograms if any
678 TFile * pfile = new TFile("position.root","update");
680 hAllPosition = (TH2F*)pfile->Get("hAllPosition");
681 if(hAllPosition == 0)
682 hAllPosition = new TH2F("hAllPosition",
683 "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
684 hPhotPosition= (TH2F*)pfile->Get("hPhotPosition");
685 if(hPhotPosition == 0)
686 hPhotPosition = new TH2F("hPhotPosition",
687 "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
688 hEMPosition= (TH2F*)pfile->Get("hEMPosition") ;
690 hEMPosition = new TH2F("hEMPosition",
691 "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
692 hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ;
693 if(hAllPositionX == 0)
694 hAllPositionX = new TH1F("hAllPositionX",
695 "Delta X of any RP with primary photon",100, -2., 2.);
696 hAllPositionZ =(TH1F*) pfile->Get("hAllPositionZ") ;
697 if(hAllPositionZ == 0)
698 hAllPositionZ = new TH1F("hAllPositionZ",
699 "Delta X of any RP with primary photon",100, -2., 2.);
702 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
703 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
706 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
707 for ( ievent=0; ievent < maxevent ; ievent++){
709 //read the current event
710 gime->Event(ievent) ;
711 TClonesArray * rp = gime->RecParticles() ;
713 cout << "AliPHOSAnalyze::PositionResolution --> Event " <<ievent
714 << ", Can't find RecParticles " << endl ;
717 TClonesArray * ts = gime->TrackSegments() ;
719 cout << "AliPHOSAnalyze::PositionResolution --> Event " <<ievent
720 << ", Can't find TrackSegments " << endl ;
723 TObjArray * emcrp = gime->EmcRecPoints() ;
725 cout << "AliPHOSAnalyze::PositionResolution --> Event " <<ievent
726 << ", Can't find EmcRecPoints " << endl ;
731 const AliPHOSRecParticle * recParticle ;
733 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ ){
734 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
736 //find the closest primary
737 Int_t moduleNumberRec ;
738 Double_t recX, recZ ;
739 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
741 Double_t minDistance = 100. ;
742 Int_t closestPrimary = -1 ;
744 //extract list of primaries: it is stored at EMC RecPoints
745 Int_t emcIndex = ((AliPHOSTrackSegment*) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
746 Int_t numberofprimaries ;
747 Int_t * listofprimaries = ((AliPHOSEmcRecPoint *) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
750 const TParticle * primary ;
751 Double_t distance = minDistance ;
752 Double_t dX = 1000; // incredible number
753 Double_t dZ = 1000; // for the case if no primary will be found
755 Double_t dZmin = 0. ;
756 for ( index = 0 ; index < numberofprimaries ; index++){
757 primary = gime->Primary(listofprimaries[index]) ;
759 Double_t primX, primZ ;
760 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
761 if(moduleNumberRec == moduleNumber) {
764 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
765 if(minDistance > distance) {
766 minDistance = distance ;
769 closestPrimary = listofprimaries[index] ;
774 //if found primary, fill histograms
775 if(closestPrimary >=0 ){
776 const TParticle * primary = gime->Primary(closestPrimary) ;
777 if(primary->GetPdgCode() == 22){
778 hAllPosition->Fill(primary->Energy(), minDistance) ;
779 hAllPositionX->Fill(primary->Energy(), dX) ;
780 hAllPositionZ->Fill(primary->Energy(), dZ) ;
781 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
782 hPhotPosition->Fill(primary->Energy(), minDistance ) ;
783 hEMPosition->Fill(primary->Energy(), minDistance ) ;
786 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)
787 hEMPosition->Fill(primary->Energy(), minDistance ) ;
793 //Write output histgrams
795 hAllPosition->Write(0,kOverwrite) ;
796 hAllPositionX->Write(0,kOverwrite) ;
797 hAllPositionZ->Write(0,kOverwrite) ;
798 hPhotPosition->Write(0,kOverwrite) ;
799 hEMPosition->Write(0,kOverwrite) ;
806 //____________________________________________________________________________
807 void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){
808 // fills spectra of primary photons and several kinds of
809 // reconstructed particles, so that analyzing them one can
810 // estimate conatmination, efficiency of registration etc.
812 //define several general histograms
813 TH1F * hPrimary = 0; //spectrum (P_t distribution) of primary photons
814 TH1F * hAllRP = 0; //spectrum of all RecParticles in PHOS
815 TH1F * hPhot = 0; //spectrum of kGAMMA RecParticles
816 TH1F * hShape = 0; //spectrum of all EM RecParticles
817 TH1F * hVeto = 0; //spectrum of all neutral RecParticles
819 //Now separate histograms in accoradance with primary
821 TH1F * hPhotReg = 0; //Registeres as photon
822 TH1F * hPhotEM = 0; //Registered as EM
825 TH1F * hNReg = 0; //Registeres as photon
826 TH1F * hNEM = 0; //Registered as EM
829 TH1F * hNBarReg = 0; //Registeres as photon
830 TH1F * hNBarEM = 0; //Registered as EM
832 //primary - charged hadron (pBar excluded)
833 TH1F * hChargedReg = 0; //Registeres as photon
834 TH1F * hChargedEM = 0; //Registered as EM
837 TH1F * hPbarReg = 0; //Registeres as photon
838 TH1F * hPbarEM = 0; //Registered as EM
841 //Reading histograms from the file
842 TFile * cfile = new TFile("contamination.root","update") ;
844 //read general histograms
845 hPrimary = (TH1F*) cfile->Get("hPrimary") ;
847 hPrimary= new TH1F("hPrimary", "Primary photon spectrum", 100, 0., 5.);
848 hAllRP = (TH1F*)cfile->Get("hAllRP") ;
850 hAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
851 hPhot = (TH1F*)cfile->Get("hPhot") ;
853 hPhot = new TH1F("hPhot","All kGAMMA RecParticles",100, 0., 5.);
854 hShape = (TH1F*) cfile->Get("hShape") ;
856 hShape = new TH1F("hShape","All particles with EM shower",100, 0., 5.);
857 hVeto= (TH1F*)cfile->Get("hVeto") ;
859 hVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
863 hPhotReg = (TH1F*)cfile->Get("hPhotReg");
865 hPhotReg = new TH1F("hPhotReg","Photon registered as photon",100, 0., 5.);
866 hPhotEM =(TH1F*)cfile->Get("hPhotEM");
868 hPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
871 hNReg = (TH1F*)cfile->Get("hNReg");
873 hNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
874 hNEM = (TH1F*)cfile->Get("hNEM");
876 hNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
879 hNBarReg =(TH1F*)cfile->Get("hNBarReg");
881 hNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
882 hNBarEM =(TH1F*)cfile->Get("hNBarEM");
884 hNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
886 //primary - charged hadron (pBar excluded)
887 hChargedReg = (TH1F*)cfile->Get("hChargedReg");
889 hChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
890 hChargedEM = (TH1F*)cfile->Get("hChargedEM");
892 hChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
895 hPbarReg = (TH1F*)cfile->Get("hPbarReg");
897 hPbarReg= new TH1F("hPbarReg", "pBar registered as photon",100, 0., 5.);
898 hPbarEM = (TH1F*)cfile->Get("hPbarEM");
900 hPbarEM= new TH1F("hPbarEM","Pbar registered as EM",100, 0., 5.);
903 //Now make some initializations
905 Int_t counter[8][5] ; //# of registered particles
907 for(i1 = 0; i1<8; i1++)
908 for(i2 = 0; i2<5; i2++)
909 counter[i1][i2] = 0 ;
913 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),RecPointsTitle) ;
914 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
917 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
918 for ( ievent=0; ievent < maxevent ; ievent++){
920 gime->Event(ievent) ;
922 TClonesArray * rp = gime->RecParticles() ;
924 cout << "AliPHOSAnalyze::Contamination --> Event " <<ievent
925 << ", Can't find RecParticles " << endl ;
928 TClonesArray * ts = gime->TrackSegments() ;
930 cout << "AliPHOSAnalyze::Contamination --> Event " <<ievent
931 << ", Can't find TrackSegments " << endl ;
934 TObjArray * emcrp = gime->EmcRecPoints() ;
936 cout << "AliPHOSAnalyze::Contamination --> Event " <<ievent
937 << ", Can't find EmcRecPoints " << endl ;
942 //=========== Make spectrum of the primary photons
943 const TParticle * primary ;
945 for( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++){
946 primary = gime->Primary(iPrimary) ;
947 Int_t primaryType = primary->GetPdgCode() ;
948 if( primaryType == 22 ) {
949 //check, if photons folls onto PHOS
951 Double_t primX, primZ ;
952 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
954 hPrimary->Fill(primary->Energy()) ;
960 //========== Now scan over RecParticles
961 const AliPHOSRecParticle * recParticle ;
963 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ ){
964 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
965 //fill histo spectrum of all RecParticles
966 hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ;
968 //==========find the closest primary
969 Int_t moduleNumberRec ;
970 Double_t recX, recZ ;
971 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
973 Double_t minDistance = 100. ;
974 Int_t closestPrimary = -1 ;
976 //extract list of primaries: it is stored at EMC RecPoints
977 Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
978 Int_t numberofprimaries ;
979 Int_t * listofprimaries = ((AliPHOSEmcRecPoint *) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
981 const TParticle * primary ;
982 Double_t distance = minDistance ;
985 Double_t dZmin = 0. ;
986 for ( index = 0 ; index < numberofprimaries ; index++){
987 primary = gime->Primary(listofprimaries[index]) ;
989 Double_t primX, primZ ;
990 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
991 if(moduleNumberRec == moduleNumber) {
994 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
995 if(minDistance > distance) {
996 minDistance = distance ;
999 closestPrimary = listofprimaries[index] ;
1004 //===========define the "type" of closest primary
1005 if(closestPrimary >=0 ){
1006 Int_t primaryCode = -1;
1007 const TParticle * primary = gime->Primary(closestPrimary) ;
1008 Int_t primaryType = primary->GetPdgCode() ;
1009 if(primaryType == 22) // photon ?
1012 if(primaryType == 2112) // neutron
1015 if(primaryType == -2112) // Anti neutron
1018 if(primaryType == -2122) //Anti proton
1021 TParticle tempo(*primary) ;
1022 if(tempo.GetPDG()->Charge())
1026 //==========Now look at the type of RecParticle
1027 Float_t energy = CorrectedEnergy(recParticle->Energy()) ;
1028 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
1029 hPhot->Fill(energy ) ;
1030 switch(primaryCode){
1032 hPhotReg->Fill(energy ) ;
1035 hNReg->Fill(energy ) ;
1038 hNBarReg->Fill(energy ) ;
1041 hChargedReg->Fill(energy ) ;
1044 hPbarReg->Fill(energy ) ;
1050 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
1051 (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMFAST)||
1052 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)||
1053 (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMSLOW) ){ //with EM shower
1054 hShape->Fill(energy ) ;
1055 switch(primaryCode){
1057 hPhotEM->Fill(energy ) ;
1060 hNEM->Fill(energy ) ;
1063 hNBarEM->Fill(energy ) ;
1066 hChargedEM->Fill(energy ) ;
1069 hPbarEM->Fill(energy ) ;
1076 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
1077 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHAFAST) ||
1078 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) ||
1079 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHASLOW) ) //nuetral
1080 hVeto->Fill(energy ) ;
1082 //fill number of primaries identified as ...
1083 if(primaryCode >= 0) // Primary code defined
1084 counter[recParticle->GetType()][primaryCode]++ ;
1088 } // no closest primary found
1092 //=================== SaveHistograms
1094 hPrimary->Write(0,kOverwrite);
1095 hAllRP->Write(0,kOverwrite);
1096 hPhot->Write(0,kOverwrite);
1097 hShape->Write(0,kOverwrite);
1098 hVeto->Write(0,kOverwrite);
1099 hPhotReg->Write(0,kOverwrite);
1100 hPhotEM->Write(0,kOverwrite);
1101 hNReg ->Write(0,kOverwrite);
1102 hNEM ->Write(0,kOverwrite);
1103 hNBarReg ->Write(0,kOverwrite);
1104 hNBarEM ->Write(0,kOverwrite);
1105 hChargedReg ->Write(0,kOverwrite);
1106 hChargedEM ->Write(0,kOverwrite);
1107 hPbarReg ->Write(0,kOverwrite);
1108 hPbarEM ->Write(0,kOverwrite);
1110 cfile->Write(0,kOverwrite);
1116 maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
1117 // cout << "Resolutions: Analyzed " << gime->MaxEvent() << " event(s)" << endl ;
1119 cout << "Resolutions: Analyzed " << maxevent << " event(s)" << endl ;
1122 cout << " Primary: Photon Neutron Antineutron Charged hadron AntiProton" << endl ;
1123 cout << "--------------------------------------------------------------------------------" << endl ;
1125 << setw(8) << counter[2][0] << setw(9) << counter[2][1] << setw(13) << counter[2][2]
1126 << setw(15)<< counter[2][3] << setw(13) << counter[2][4] << endl ;
1127 cout << " kGAMMAHA: "
1128 << setw(8) << counter[3][0] << setw(9) << counter[3][1] << setw(13) << counter[3][2]
1129 << setw(15)<< counter[3][3] << setw(13) << counter[3][4] << endl ;
1130 cout << " kNEUTRALEM: "
1131 << setw(8) << counter[0][0] << setw(9) << counter[0][1] << setw(13) << counter[0][2]
1132 << setw(15)<< counter[0][3] << setw(13) << counter[0][4] << endl ;
1133 cout << " kNEUTRALHA: "
1134 << setw(8) << counter[1][0] << setw(9) << counter[1][1] << setw(13) << counter[1][2]
1135 << setw(15)<< counter[1][3] << setw(13) << counter[1][4] << endl ;
1136 cout << " kABSURDEM: "
1137 << setw(8) << counter[4][0] << setw(9) << counter[4][1] << setw(13) << counter[4][2]
1138 << setw(15)<< counter[4][3] << setw(13) << counter[4][4] << endl ;
1139 cout << " kABSURDHA: "
1140 << setw(8) << counter[5][0] << setw(9) << counter[5][1] << setw(13) << counter[5][2]
1141 << setw(15)<< counter[5][3] << setw(13) << counter[5][4] << endl ;
1142 cout << " kELECTRON: "
1143 << setw(8) << counter[6][0] << setw(9) << counter[6][1] << setw(13) << counter[6][2]
1144 << setw(15)<< counter[6][3] << setw(13) << counter[6][4] << endl ;
1145 cout << " kCHARGEDHA: "
1146 << setw(8) << counter[7][0] << setw(9) << counter[7][1] << setw(13) << counter[7][2]
1147 << setw(15)<< counter[7][3] << setw(13) << counter[7][4] << endl ;
1148 cout << "--------------------------------------------------------------------------------" << endl ;
1150 Int_t totalInd = 0 ;
1151 for(i1 = 0; i1<8; i1++)
1152 for(i2 = 0; i2<5; i2++)
1153 totalInd+=counter[i1][i2] ;
1154 cout << "Indentified particles: " << totalInd << endl ;