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.
32 // root [0] AliPHOSAnalyze * a = new AliPHOSAnalyze("galice.root")
33 // // set the file you want to analyse
34 // root [1] a->DrawRecon(1,3)
35 // // plot RecObjects, made in event 1, PHOS module 3
36 // root [2] a->DrawRecon(1,3,"PHOSRP","another PID")
37 // // plot RecObjets made in the event 1, PHOS module 3,
38 // // produced in the another reconstruction pass,
39 // // which produced PHOS RecParticles ("PHOSRP") with
40 // // title "another PID".
41 // root [3] a->InvariantMass()
42 // // Calculates "REAL" and "MIXED" invariant mass
43 // // distributions of kGAMMA and (kGAMMA+kNEUTRALEM)
44 // // and APPENDS this to the file "invmass.root"
45 // root [4] a->PositionResolution()
46 // // calculates two dimentional histos: energy of the primary
47 // // photon vs distance betwin incedence point and reconstructed
48 // // poisition. One can analyse the produced file position.root
49 // // with macro PhotonPosition.C
50 // root [5] a->EnergyResolution()
51 // // calculates two dimentional histos: energy of the primary
52 // // photon vs energy of the reconstructed particle. One can
53 // // analyse the produced file energy.root
54 // // with macro PhotonEnergy.C
55 // root [6] a->Contamination()
56 // // fills spectra of primary photons and several kinds of
57 // // reconstructed particles, so that analyzing them one can
58 // // estimate conatmination, efficiency of registration etc.
60 //*-- Author: Dmitri Peressounko (SUBATECH & RRC Kurchatov Institute)
61 //////////////////////////////////////////////////////////////////////////////
64 // --- ROOT system ---
70 #include "TParticle.h"
71 #include "TClonesArray.h"
75 // --- Standard library ---
77 // --- AliRoot header files ---
81 #include "AliPHOSGeometry.h"
82 #include "AliPHOSAnalyze.h"
83 #include "AliPHOSDigit.h"
84 #include "AliPHOSSDigitizer.h"
85 #include "AliPHOSEmcRecPoint.h"
86 #include "AliPHOSCpvRecPoint.h"
87 #include "AliPHOSTrackSegment.h"
88 #include "AliPHOSRecParticle.h"
89 #include "AliPHOSLoader.h"
92 ClassImp(AliPHOSAnalyze)
94 //____________________________________________________________________________
95 AliPHOSAnalyze::AliPHOSAnalyze():
96 fCorrection(1.2), //Value calculated for default parameters of reconstruction
101 // default ctor (useless)
104 //____________________________________________________________________________
105 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName):
106 fCorrection(1.05), //Value calculated for default parameters of reconstruction
111 // ctor: analyze events from root file "name"
112 fRunLoader = AliRunLoader::Open(fileName,"AliPHOSAnalyze");
113 if (fRunLoader == 0x0)
115 AliError(Form("Error Loading session"));
119 //____________________________________________________________________________
120 AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana):
128 ( (AliPHOSAnalyze &)ana ).Copy(*this) ;
131 //____________________________________________________________________________
132 AliPHOSAnalyze::~AliPHOSAnalyze()
137 //____________________________________________________________________________
138 void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod){
139 //Draws pimary particles and reconstructed
140 //digits, RecPoints, RecPartices etc
141 //for event Nevent in the module Nmod.
143 //========== Create ObjectLoader
144 if (fRunLoader == 0x0)
146 AliError(Form("Error Loading session"));
150 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(fRunLoader->GetLoader("PHOSLoader"));
153 AliError(Form("Could not obtain the Loader object !"));
158 if(Nevent >= fRunLoader->GetNumberOfEvents() ) {
159 AliError(Form("There is no event %d only %d events available", Nevent, fRunLoader->GetNumberOfEvents() )) ;
162 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
163 fRunLoader->GetEvent(Nevent);
165 Int_t nx = phosgeom->GetNPhi() ;
166 Int_t nz = phosgeom->GetNZ() ;
167 Float_t * cri= phosgeom->GetEMCAGeometry()->GetCrystalHalfSize() ;
168 Float_t x = nx*cri[0] ;
169 Float_t z = nz*cri[2] ;
170 Int_t nxCPV = (Int_t) (nx*phosgeom->GetPadSizePhi()/(2.*cri[0])) ;
171 Int_t nzCPV = (Int_t) (nz*phosgeom->GetPadSizeZ()/(2.*cri[2])) ;
173 TH2F * emcDigits = (TH2F*) gROOT->FindObject("emcDigits") ;
175 emcDigits->Delete() ;
176 emcDigits = new TH2F("emcDigits","EMC digits", nx,-x,x,nz,-z,z);
177 TH2F * emcSdigits =(TH2F*) gROOT->FindObject("emcSdigits") ;
179 emcSdigits->Delete() ;
180 emcSdigits = new TH2F("emcSdigits","EMC sdigits", nx,-x,x,nz,-z,z);
181 TH2F * emcRecPoints = (TH2F*)gROOT->FindObject("emcRecPoints") ;
183 emcRecPoints->Delete() ;
184 emcRecPoints = new TH2F("emcRecPoints","EMC RecPoints",nx,-x,x,nz,-z,z);
185 TH2F * cpvSdigits =(TH2F*) gROOT->FindObject("cpvSdigits") ;
187 cpvSdigits->Delete() ;
188 cpvSdigits = new TH2F("cpvSdigits","CPV sdigits", nx,-x,x,nz,-z,z);
189 TH2F * cpvDigits = (TH2F*)gROOT->FindObject("cpvDigits") ;
191 cpvDigits->Delete() ;
192 cpvDigits = new TH2F("cpvDigits","CPV digits", nxCPV,-x,x,nzCPV,-z,z) ;
193 TH2F * cpvRecPoints= (TH2F*)gROOT->FindObject("cpvRecPoints") ;
195 cpvRecPoints->Delete() ;
196 cpvRecPoints = new TH2F("cpvRecPoints","CPV RecPoints", nxCPV,-x,x,nzCPV,-z,z) ;
198 TH2F * phot = (TH2F*)gROOT->FindObject("phot") ;
201 phot = new TH2F("phot","Primary Photon", nx,-x,x,nz,-z,z);
202 TH2F * recPhot = (TH2F*)gROOT->FindObject("recPhot") ;
205 recPhot = new TH2F("recPhot","RecParticles with primary Photon",nx,-x,x,nz,-z,z);
208 //Plot Primary Particles
210 if (fRunLoader->Stack() == 0x0) fRunLoader->LoadKinematics("READ");
213 const TParticle * primary ;
215 for ( iPrimary = 0 ; iPrimary < fRunLoader->Stack()->GetNprimary() ; iPrimary++)
217 primary = fRunLoader->Stack()->Particle(iPrimary);
219 Int_t primaryType = primary->GetPdgCode();
220 // if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212)
221 // ||(primaryType == 11)||(primaryType == -11) ) {
222 // Int_t moduleNumber ;
223 // Double_t primX, primZ ;
224 // phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
225 // if(moduleNumber==Nmod)
226 // charg->Fill(primZ,primX,primary->Energy()) ;
228 if( primaryType == 22 ) {
230 Double_t primX, primZ ;
231 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
232 if(moduleNumber==Nmod)
233 phot->Fill(primZ,primX,primary->Energy()) ;
236 // if( primaryType == -2112 ) {
237 // Int_t moduleNumber ;
238 // Double_t primX, primZ ;
239 // phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
240 // if(moduleNumber==Nmod)
241 // nbar->Fill(primZ,primX,primary->Energy()) ;
248 AliPHOSDigit * sdigit ;
249 const TClonesArray * sdigits = gime->SDigits() ;
250 Int_t nsdig[5] = {0,0,0,0,0} ;
252 for(iSDigit = 0; iSDigit < sdigits->GetEntriesFast() ; iSDigit++)
254 sdigit = (AliPHOSDigit *) sdigits->At(iSDigit) ;
256 phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
258 phosgeom->RelPosInModule(relid,x,z);
259 AliPHOSSDigitizer* sd = dynamic_cast<AliPHOSSDigitizer*>(gime->SDigitizer());
260 Float_t e = sd->Calibrate(sdigit->GetAmp()) ;
261 nsdig[relid[0]-1]++ ;
263 if(relid[1]==0) //EMC
264 emcSdigits->Fill(x,z,e) ;
266 cpvSdigits->Fill(x,z,e) ;
271 message = "Number of EMC + CPV SDigits per module: \n" ;
272 message += "%d %d %d %d %d\n";
273 AliInfo(Form(message.Data(), nsdig[0], nsdig[1], nsdig[2], nsdig[3], nsdig[4] )) ;
277 AliPHOSDigit * digit ;
278 const TClonesArray * digits = gime->Digits();
280 for(iDigit = 0; iDigit < digits->GetEntriesFast(); iDigit++)
282 digit = (AliPHOSDigit *) digits->At(iDigit) ;
284 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
286 phosgeom->RelPosInModule(relid,x,z) ;
287 AliPHOSSDigitizer* sd = dynamic_cast<AliPHOSSDigitizer*>(gime->SDigitizer());
288 Float_t e = sd->Calibrate(digit->GetAmp()) ;
290 if(relid[1]==0) //EMC
291 emcDigits->Fill(x,z,e) ;
293 cpvDigits->Fill(x,z,e) ;
302 TObjArray * emcrp = gime->EmcRecPoints() ;
304 for(irecp = 0; irecp < emcrp->GetEntriesFast() ; irecp ++){
305 AliPHOSEmcRecPoint * emc = (AliPHOSEmcRecPoint *) emcrp->At(irecp) ;
306 if(emc->GetPHOSMod()==Nmod){
307 emc->GetLocalPosition(pos) ;
308 emcRecPoints->Fill(pos.X(),pos.Z(),emc->GetEnergy());
313 TObjArray * cpvrp = gime->CpvRecPoints() ;
315 for(irecp = 0; irecp < cpvrp->GetEntriesFast() ; irecp ++){
316 AliPHOSRecPoint * cpv = (AliPHOSCpvRecPoint *) cpvrp->At(irecp) ;
317 if(cpv->GetPHOSMod()==Nmod){
318 cpv->GetLocalPosition(pos) ;
319 cpvRecPoints->Fill(pos.X(),pos.Z(),cpv->GetEnergy());
325 AliPHOSRecParticle * recParticle ;
327 TClonesArray * rp = gime->RecParticles() ;
328 TClonesArray * ts = gime->TrackSegments() ;
329 if(rp && ts && emcrp) {
330 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast() ; iRecParticle++ )
332 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
333 Int_t moduleNumberRec ;
334 Double_t recX, recZ ;
335 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
336 if(moduleNumberRec == Nmod){
338 Double_t minDistance = 5. ;
339 Int_t closestPrimary = -1 ;
341 //extract list of primaries: it is stored at EMC RecPoints
342 Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
343 Int_t numberofprimaries ;
344 Int_t * listofprimaries = ((AliPHOSRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
346 const TParticle * primary ;
347 Double_t distance = minDistance ;
349 for ( index = 0 ; index < numberofprimaries ; index++){
350 primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ;
352 Double_t primX, primZ ;
353 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
354 if(moduleNumberRec == moduleNumber)
355 distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ;
356 if(minDistance > distance)
358 minDistance = distance ;
359 closestPrimary = listofprimaries[index] ;
363 if(closestPrimary >=0 ){
365 Int_t primaryType = fRunLoader->Stack()->Particle(closestPrimary)->GetPdgCode() ;
368 recPhot->Fill(recZ,recX,recParticle->Energy()) ;
370 // if(primaryType==-2112)
371 // recNbar->Fill(recZ,recX,recParticle->Energy()) ;
378 //Plot made histograms
379 emcSdigits->Draw("box") ;
380 emcDigits->SetLineColor(5) ;
381 emcDigits->Draw("boxsame") ;
382 emcRecPoints->SetLineColor(2) ;
383 emcRecPoints->Draw("boxsame") ;
384 cpvSdigits->SetLineColor(1) ;
385 cpvSdigits->Draw("boxsame") ;
388 //____________________________________________________________________________
389 void AliPHOSAnalyze::Ls(){
390 //lists branches and titles of PHOS-related branches of TreeR, TreeD, TreeS
392 if (fRunLoader == 0x0)
394 AliError(Form("Error Loading session"));
398 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(fRunLoader->GetLoader("PHOSLoader"));
401 AliError(Form("Could not obtain the Loader object !"));
407 TObjArray * branches;
409 if (gime->TreeS() == 0x0)
411 if (gime->LoadSDigits("READ"))
413 AliError(Form("Problems with loading summable digits"));
417 branches = gime->TreeS()->GetListOfBranches() ;
420 message = "TreeS:\n" ;
421 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
422 TBranch * branch=(TBranch *) branches->At(ibranch) ;
423 if(strstr(branch->GetName(),"PHOS") ){
425 message += branch->GetName() ;
427 message += branch->GetTitle() ;
431 if (gime->TreeD() == 0x0)
433 if (gime->LoadDigits("READ"))
435 AliError(Form("Problems with loading digits"));
440 branches = gime->TreeD()->GetListOfBranches() ;
442 message += "TreeD:\n" ;
443 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
444 TBranch * branch=(TBranch *) branches->At(ibranch) ;
445 if(strstr(branch->GetName(),"PHOS") ) {
447 message += branch->GetName() ;
449 message += branch->GetTitle() ;
454 if (gime->TreeR() == 0x0)
456 if (gime->LoadRecPoints("READ"))
458 AliError(Form("Problems with loading rec points"));
463 branches = gime->TreeR()->GetListOfBranches() ;
465 message += "TreeR: \n" ;
466 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
467 TBranch * branch=(TBranch *) branches->At(ibranch) ;
468 if(strstr(branch->GetName(),"PHOS") ) {
470 message += branch->GetName() ;
472 message += branch->GetTitle() ;
476 AliInfo(Form(message.Data())) ;
478 //____________________________________________________________________________
479 void AliPHOSAnalyze::InvariantMass()
481 // Calculates Real and Mixed invariant mass distributions
482 if (fRunLoader == 0x0)
484 AliError(Form("Error Loading session"));
488 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(fRunLoader->GetLoader("PHOSLoader"));
491 AliError(Form("Could not obtain the Loader object !"));
495 gime->LoadRecParticles("READ");
497 Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
501 TFile * mfile = new TFile("invmass.root","update");
503 //========== Reading /Booking Histograms
505 hRealEM = (TH2D*) mfile->Get("hRealEM") ;
507 hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
508 TH2D * hRealPhot = 0 ;
510 hRealPhot = (TH2D*)mfile->Get("hRealPhot");
512 hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
514 TH2D * hMixedEM = 0 ;
515 hMixedEM = (TH2D*) mfile->Get("hMixedEM") ;
517 hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
519 TH2D * hMixedPhot = 0 ;
520 hMixedPhot = (TH2D*) mfile->Get("hMixedPhot") ;
522 hMixedPhot = new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
525 //reading event and copyng it to TConesArray of all photons
527 TClonesArray * allRecParticleList = new TClonesArray("AliPHOSRecParticle", 1000) ;
528 Int_t * nRecParticles = new Int_t[nMixedEvents] ; // to mark boundaries of each event in the total list
529 for(Int_t index = 0; index < nMixedEvents; index ++)
530 nRecParticles[index] = 0 ;
531 Int_t iRecPhot = 0 ; // number of EM particles in total list
533 //scan over all events
537 if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader();
540 Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries();
541 // for(event = 0; event < gime->MaxEvent(); event++ ){
545 for(event = 0; event < maxevent; event++ ){
546 fRunLoader->GetEvent(event); //will read only TreeR
548 //copy EM RecParticles to the "total" list
549 const AliPHOSRecParticle * recParticle ;
551 TClonesArray * rp = gime->RecParticles() ;
553 AliError(Form("Can't find RecParticles")) ;
557 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ )
559 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
560 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
561 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW))
562 new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ;
565 Int_t mevent = event%nMixedEvents ; //event number in the "mixed" cicle
566 nRecParticles[mevent] = iRecPhot-1 ;
568 //check, if it is time to calculate invariant mass?
569 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
570 if((mevent == 0) && (event +1 == maxevent)){
572 // if((mevent == 0) && (event +1 == gime->MaxEvent())){
574 //calculate invariant mass:
576 Int_t nCurEvent = 0 ;
578 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
579 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
581 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
582 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
585 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
586 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
587 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
588 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
591 invMass = TMath::Sqrt(invMass);
594 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +
595 (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) );
597 if(irp1 > nRecParticles[nCurEvent])
600 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
601 hRealEM->Fill(invMass,pt);
602 if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&&
603 (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) )
604 hRealPhot->Fill(invMass,pt);
607 hMixedEM->Fill(invMass,pt);
608 if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&&
609 (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) )
610 hMixedPhot->Fill(invMass,pt);
613 } //loop over second rp
614 }//loop over first rp
616 //Make some cleanings
617 for(Int_t index = 0; index < nMixedEvents; index ++)
618 nRecParticles[index] = 0 ;
620 allRecParticleList->Clear() ;
624 delete allRecParticleList ;
629 hRealEM->Write(0,kOverwrite) ;
630 hRealPhot->Write(0,kOverwrite) ;
631 hMixedEM->Write(0,kOverwrite) ;
632 hMixedPhot->Write(0,kOverwrite) ;
637 delete nRecParticles;
641 //____________________________________________________________________________
642 void AliPHOSAnalyze::EnergyResolution()
644 //fills two dimentional histo: energy of primary vs. energy of reconstructed
646 TH2F * hAllEnergy = 0 ; //all reconstructed with primary photon
647 TH2F * hPhotEnergy= 0 ; //kGamma with primary photon
648 TH2F * hEMEnergy = 0 ; //electromagnetic with primary photon
650 //opening file and reading histograms if any
651 TFile * efile = new TFile("energy.root","update");
653 hAllEnergy = (TH2F*)efile->Get("hAllEnergy") ;
655 hAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
657 hPhotEnergy =(TH2F*) efile->Get("hPhotEnergy") ;
659 hPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
661 hEMEnergy =(TH2F*) efile->Get("hEMEnergy");
663 hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
666 if (fRunLoader == 0x0)
668 AliError(Form("Error Loading session"));
672 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(fRunLoader->GetLoader("PHOSLoader"));
675 AliError(Form("Could not obtain the Loader object !"));
680 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry();
683 Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries();
685 fRunLoader->LoadKinematics("READ");
686 gime->LoadTracks("READ");
688 for ( ievent=0; ievent < maxevent ; ievent++){
690 //read the current event
691 fRunLoader->GetEvent(ievent) ;
693 const AliPHOSRecParticle * recParticle ;
695 TClonesArray * rp = gime->RecParticles() ;
697 AliError(Form("Event %d, Can't find RecParticles ", ievent)) ;
700 TClonesArray * ts = gime->TrackSegments() ;
702 AliError(Form("Event %d, Can't find TrackSegments", ievent)) ;
705 TObjArray * emcrp = gime->EmcRecPoints() ;
707 AliError(Form("Event %d, Can't find EmcRecPoints")) ;
711 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast() ;iRecParticle++ ){
712 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
714 //find the closest primary
715 Int_t moduleNumberRec ;
716 Double_t recX, recZ ;
717 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
719 Double_t minDistance = 100. ;
720 Int_t closestPrimary = -1 ;
722 //extract list of primaries: it is stored at EMC RecPoints
723 Int_t emcIndex = ((AliPHOSTrackSegment*) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
724 Int_t numberofprimaries ;
725 Int_t * listofprimaries = ((AliPHOSEmcRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
728 const TParticle * primary ;
729 Double_t distance = minDistance ;
732 Double_t dZmin = 0. ;
733 for ( index = 0 ; index < numberofprimaries ; index++){
735 primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ;
738 Double_t primX, primZ ;
739 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
740 if(moduleNumberRec == moduleNumber) {
743 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
744 if(minDistance > distance) {
745 minDistance = distance ;
748 closestPrimary = listofprimaries[index] ;
753 //if found primary, fill histograms
754 if(closestPrimary >=0 ){
755 const TParticle * primary = fRunLoader->Stack()->Particle(closestPrimary) ;
756 if(primary->GetPdgCode() == 22){
757 hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ;
758 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
759 hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
760 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
763 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)
764 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
770 //write filled histograms
772 hAllEnergy->Write(0,kOverwrite) ;
773 hPhotEnergy->Write(0,kOverwrite) ;
774 hEMEnergy->Write(0,kOverwrite) ;
780 //____________________________________________________________________________
781 void AliPHOSAnalyze::PositionResolution()
783 //fills two dimentional histo: energy vs. primary - reconstructed distance
787 TH2F * hAllPosition = 0; // Position of any RP with primary photon
788 TH2F * hPhotPosition = 0; // Position of kGAMMA with primary photon
789 TH2F * hEMPosition = 0; // Position of EM with primary photon
791 TH1F * hAllPositionX = 0; // X-Position Resolution of photons with photon primary
792 TH1F * hAllPositionZ = 0; // Z-Position Resolution of photons with photon primary
795 //opening file and reading histograms if any
796 TFile * pfile = new TFile("position.root","update");
798 hAllPosition = (TH2F*)pfile->Get("hAllPosition");
799 if(hAllPosition == 0)
800 hAllPosition = new TH2F("hAllPosition",
801 "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
802 hPhotPosition= (TH2F*)pfile->Get("hPhotPosition");
803 if(hPhotPosition == 0)
804 hPhotPosition = new TH2F("hPhotPosition",
805 "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
806 hEMPosition= (TH2F*)pfile->Get("hEMPosition") ;
808 hEMPosition = new TH2F("hEMPosition",
809 "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
810 hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ;
811 if(hAllPositionX == 0)
812 hAllPositionX = new TH1F("hAllPositionX",
813 "Delta X of any RP with primary photon",100, -2., 2.);
814 hAllPositionZ =(TH1F*) pfile->Get("hAllPositionZ") ;
815 if(hAllPositionZ == 0)
816 hAllPositionZ = new TH1F("hAllPositionZ",
817 "Delta X of any RP with primary photon",100, -2., 2.);
819 if (fRunLoader == 0x0)
821 AliError(Form("Error Loading session"));
825 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(fRunLoader->GetLoader("PHOSLoader"));
828 AliError(Form("Could not obtain the Loader object !"));
832 if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader();
834 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
837 Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries() ;
838 for ( ievent=0; ievent < maxevent ; ievent++){
840 //read the current event
841 fRunLoader->GetEvent(ievent) ;
842 TClonesArray * rp = gime->RecParticles() ;
844 AliError(Form("Event %d, Can't find RecParticles", ievent)) ;
847 TClonesArray * ts = gime->TrackSegments() ;
849 AliError(Form("Event %d, Can't find TrackSegments", ievent)) ;
852 TObjArray * emcrp = gime->EmcRecPoints() ;
854 AliError(Form("Event %d, Can't find EmcRecPoints", ievent)) ;
859 const AliPHOSRecParticle * recParticle ;
861 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ ){
862 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
864 //find the closest primary
865 Int_t moduleNumberRec ;
866 Double_t recX, recZ ;
867 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
869 Double_t minDistance = 100. ;
870 Int_t closestPrimary = -1 ;
872 //extract list of primaries: it is stored at EMC RecPoints
873 Int_t emcIndex = ((AliPHOSTrackSegment*) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
874 Int_t numberofprimaries ;
875 Int_t * listofprimaries = ((AliPHOSEmcRecPoint *) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
878 const TParticle * primary ;
879 Double_t distance = minDistance ;
880 Double_t dX = 1000; // incredible number
881 Double_t dZ = 1000; // for the case if no primary will be found
883 Double_t dZmin = 0. ;
884 for ( index = 0 ; index < numberofprimaries ; index++){
885 primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ;
887 Double_t primX, primZ ;
888 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
889 if(moduleNumberRec == moduleNumber) {
892 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
893 if(minDistance > distance) {
894 minDistance = distance ;
897 closestPrimary = listofprimaries[index] ;
902 //if found primary, fill histograms
903 if(closestPrimary >=0 ){
904 const TParticle * primary = fRunLoader->Stack()->Particle(closestPrimary) ;
905 if(primary->GetPdgCode() == 22){
906 hAllPosition->Fill(primary->Energy(), minDistance) ;
907 hAllPositionX->Fill(primary->Energy(), dX) ;
908 hAllPositionZ->Fill(primary->Energy(), dZ) ;
909 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
910 hPhotPosition->Fill(primary->Energy(), minDistance ) ;
911 hEMPosition->Fill(primary->Energy(), minDistance ) ;
914 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)
915 hEMPosition->Fill(primary->Energy(), minDistance ) ;
921 //Write output histgrams
923 hAllPosition->Write(0,kOverwrite) ;
924 hAllPositionX->Write(0,kOverwrite) ;
925 hAllPositionZ->Write(0,kOverwrite) ;
926 hPhotPosition->Write(0,kOverwrite) ;
927 hEMPosition->Write(0,kOverwrite) ;
934 //____________________________________________________________________________
935 void AliPHOSAnalyze::Contamination(){
936 // fills spectra of primary photons and several kinds of
937 // reconstructed particles, so that analyzing them one can
938 // estimate conatmination, efficiency of registration etc.
940 //define several general histograms
941 TH1F * hPrimary = 0; //spectrum (P_t distribution) of primary photons
942 TH1F * hAllRP = 0; //spectrum of all RecParticles in PHOS
943 TH1F * hPhot = 0; //spectrum of kGAMMA RecParticles
944 TH1F * hShape = 0; //spectrum of all EM RecParticles
945 TH1F * hVeto = 0; //spectrum of all neutral RecParticles
947 //Now separate histograms in accoradance with primary
949 TH1F * hPhotReg = 0; //Registeres as photon
950 TH1F * hPhotEM = 0; //Registered as EM
953 TH1F * hNReg = 0; //Registeres as photon
954 TH1F * hNEM = 0; //Registered as EM
957 TH1F * hNBarReg = 0; //Registeres as photon
958 TH1F * hNBarEM = 0; //Registered as EM
960 //primary - charged hadron (pBar excluded)
961 TH1F * hChargedReg = 0; //Registeres as photon
962 TH1F * hChargedEM = 0; //Registered as EM
965 TH1F * hPbarReg = 0; //Registeres as photon
966 TH1F * hPbarEM = 0; //Registered as EM
969 //Reading histograms from the file
970 TFile * cfile = new TFile("contamination.root","update") ;
972 //read general histograms
973 hPrimary = (TH1F*) cfile->Get("hPrimary") ;
975 hPrimary= new TH1F("hPrimary", "Primary photon spectrum", 100, 0., 5.);
976 hAllRP = (TH1F*)cfile->Get("hAllRP") ;
978 hAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
979 hPhot = (TH1F*)cfile->Get("hPhot") ;
981 hPhot = new TH1F("hPhot","All kGAMMA RecParticles",100, 0., 5.);
982 hShape = (TH1F*) cfile->Get("hShape") ;
984 hShape = new TH1F("hShape","All particles with EM shower",100, 0., 5.);
985 hVeto= (TH1F*)cfile->Get("hVeto") ;
987 hVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
991 hPhotReg = (TH1F*)cfile->Get("hPhotReg");
993 hPhotReg = new TH1F("hPhotReg","Photon registered as photon",100, 0., 5.);
994 hPhotEM =(TH1F*)cfile->Get("hPhotEM");
996 hPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
999 hNReg = (TH1F*)cfile->Get("hNReg");
1001 hNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
1002 hNEM = (TH1F*)cfile->Get("hNEM");
1004 hNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
1007 hNBarReg =(TH1F*)cfile->Get("hNBarReg");
1009 hNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
1010 hNBarEM =(TH1F*)cfile->Get("hNBarEM");
1012 hNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
1014 //primary - charged hadron (pBar excluded)
1015 hChargedReg = (TH1F*)cfile->Get("hChargedReg");
1017 hChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
1018 hChargedEM = (TH1F*)cfile->Get("hChargedEM");
1020 hChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
1023 hPbarReg = (TH1F*)cfile->Get("hPbarReg");
1025 hPbarReg= new TH1F("hPbarReg", "pBar registered as photon",100, 0., 5.);
1026 hPbarEM = (TH1F*)cfile->Get("hPbarEM");
1028 hPbarEM= new TH1F("hPbarEM","Pbar registered as EM",100, 0., 5.);
1031 //Now make some initializations
1033 Int_t counter[8][5] ; //# of registered particles
1035 for(i1 = 0; i1<8; i1++)
1036 for(i2 = 0; i2<5; i2++)
1037 counter[i1][i2] = 0 ;
1041 if (fRunLoader == 0x0)
1043 AliError(Form("Error Loading session"));
1047 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(fRunLoader->GetLoader("PHOSLoader"));
1050 AliError(Form("Could not obtain the Loader object !"));
1054 if (fRunLoader->TreeE() == 0x0) fRunLoader->LoadHeader();
1055 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
1058 Int_t maxevent = (Int_t)fRunLoader->TreeE()->GetEntries() ;
1059 for ( ievent=0; ievent < maxevent ; ievent++){
1061 fRunLoader->GetEvent(ievent) ;
1063 TClonesArray * rp = gime->RecParticles() ;
1065 AliError(Form("Event %d, Can't find RecParticles", ievent)) ;
1068 TClonesArray * ts = gime->TrackSegments() ;
1070 AliError(Form("Event %d, Can't find TrackSegments", ievent)) ;
1073 TObjArray * emcrp = gime->EmcRecPoints() ;
1075 AliError(Form("Event %d, Can't find EmcRecPoints", ievent)) ;
1080 //=========== Make spectrum of the primary photons
1081 const TParticle * primary ;
1083 for( iPrimary = 0 ; iPrimary < fRunLoader->Stack()->GetNprimary() ; iPrimary++){
1084 primary = fRunLoader->Stack()->Particle(iPrimary) ;
1085 Int_t primaryType = primary->GetPdgCode() ;
1086 if( primaryType == 22 ) {
1087 //check, if photons folls onto PHOS
1088 Int_t moduleNumber ;
1089 Double_t primX, primZ ;
1090 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1092 hPrimary->Fill(primary->Energy()) ;
1098 //========== Now scan over RecParticles
1099 const AliPHOSRecParticle * recParticle ;
1100 Int_t iRecParticle ;
1101 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ ){
1102 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
1103 //fill histo spectrum of all RecParticles
1104 hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ;
1106 //==========find the closest primary
1107 Int_t moduleNumberRec ;
1108 Double_t recX, recZ ;
1109 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
1111 Double_t minDistance = 100. ;
1112 Int_t closestPrimary = -1 ;
1114 //extract list of primaries: it is stored at EMC RecPoints
1115 Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
1116 Int_t numberofprimaries ;
1117 Int_t * listofprimaries = ((AliPHOSEmcRecPoint *) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
1119 const TParticle * primary ;
1120 Double_t distance = minDistance ;
1122 Double_t dXmin = 0.;
1123 Double_t dZmin = 0. ;
1124 for ( index = 0 ; index < numberofprimaries ; index++){
1125 primary = fRunLoader->Stack()->Particle(listofprimaries[index]) ;
1126 Int_t moduleNumber ;
1127 Double_t primX, primZ ;
1128 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1129 if(moduleNumberRec == moduleNumber) {
1132 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
1133 if(minDistance > distance) {
1134 minDistance = distance ;
1137 closestPrimary = listofprimaries[index] ;
1142 //===========define the "type" of closest primary
1143 if(closestPrimary >=0 ){
1144 Int_t primaryCode = -1;
1145 const TParticle * primary = fRunLoader->Stack()->Particle(closestPrimary) ;
1146 Int_t primaryType = primary->GetPdgCode() ;
1147 if(primaryType == 22) // photon ?
1150 if(primaryType == 2112) // neutron
1153 if(primaryType == -2112) // Anti neutron
1156 if(primaryType == -2122) //Anti proton
1159 TParticle tempo(*primary) ;
1160 if(tempo.GetPDG()->Charge())
1164 //==========Now look at the type of RecParticle
1165 Float_t energy = CorrectedEnergy(recParticle->Energy()) ;
1166 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
1167 hPhot->Fill(energy ) ;
1168 switch(primaryCode){
1170 hPhotReg->Fill(energy ) ;
1173 hNReg->Fill(energy ) ;
1176 hNBarReg->Fill(energy ) ;
1179 hChargedReg->Fill(energy ) ;
1182 hPbarReg->Fill(energy ) ;
1188 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
1189 (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMFAST)||
1190 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)||
1191 (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMSLOW) ){ //with EM shower
1192 hShape->Fill(energy ) ;
1193 switch(primaryCode){
1195 hPhotEM->Fill(energy ) ;
1198 hNEM->Fill(energy ) ;
1201 hNBarEM->Fill(energy ) ;
1204 hChargedEM->Fill(energy ) ;
1207 hPbarEM->Fill(energy ) ;
1214 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
1215 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHAFAST) ||
1216 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) ||
1217 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHASLOW) ) //nuetral
1218 hVeto->Fill(energy ) ;
1220 //fill number of primaries identified as ...
1221 if(primaryCode >= 0) // Primary code defined
1222 counter[recParticle->GetType()][primaryCode]++ ;
1226 } // no closest primary found
1230 //=================== SaveHistograms
1232 hPrimary->Write(0,kOverwrite);
1233 hAllRP->Write(0,kOverwrite);
1234 hPhot->Write(0,kOverwrite);
1235 hShape->Write(0,kOverwrite);
1236 hVeto->Write(0,kOverwrite);
1237 hPhotReg->Write(0,kOverwrite);
1238 hPhotEM->Write(0,kOverwrite);
1239 hNReg ->Write(0,kOverwrite);
1240 hNEM ->Write(0,kOverwrite);
1241 hNBarReg ->Write(0,kOverwrite);
1242 hNBarEM ->Write(0,kOverwrite);
1243 hChargedReg ->Write(0,kOverwrite);
1244 hChargedEM ->Write(0,kOverwrite);
1245 hPbarReg ->Write(0,kOverwrite);
1246 hPbarEM ->Write(0,kOverwrite);
1248 cfile->Write(0,kOverwrite);
1254 maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
1257 message = "Resolutions: Analyzed %d event(s)\n" ;
1259 message += " Primary: Photon Neutron Antineutron Charged hadron AntiProton\n" ;
1260 message += "--------------------------------------------------------------------------------\n" ;
1261 message += " kGAMMA: " ;
1262 message += "%d %d %d %d %d\n" ;
1263 message += " kGAMMAHA: " ;
1264 message += "%d %d %d %d %d\n" ;
1265 message += " kNEUTRALEM: " ;
1266 message += "%d %d %d %d %d\n" ;
1267 message += " kNEUTRALHA: " ;
1268 message += "%d %d %d %d %d\n" ;
1269 message += " kABSURDEM: ";
1270 message += "%d %d %d %d %d\n" ;
1271 message += " kABSURDHA: " ;
1272 message += "%d %d %d %d %d\n" ;
1273 message += " kELECTRON: " ;
1274 message += "%d %d %d %d %d\n" ;
1275 message += " kCHARGEDHA: " ;
1276 message += "%d %d %d %d %d\n" ;
1278 message += "--------------------------------------------------------------------------------" ;
1281 Int_t totalInd = 0 ;
1282 for(i1 = 0; i1<8; i1++)
1283 for(i2 = 0; i2<5; i2++)
1284 totalInd+=counter[i1][i2] ;
1285 message += "Indentified particles: %d" ;
1287 AliInfo(Form(message.Data(), maxevent,
1288 counter[2][0], counter[2][1], counter[2][2], counter[2][3], counter[2][4],
1289 counter[3][0], counter[3][1], counter[3][2], counter[3][3], counter[3][4],
1290 counter[0][0], counter[0][1], counter[0][2], counter[0][3], counter[0][4],
1291 counter[1][0], counter[1][1], counter[1][2], counter[1][3], counter[1][4],
1292 counter[4][0], counter[4][1], counter[4][2], counter[4][3], counter[4][4],
1293 counter[5][0], counter[5][1], counter[5][2], counter[5][3], counter[5][4],
1294 counter[6][0], counter[6][1], counter[6][2], counter[6][3], counter[6][4],
1295 counter[7][0], counter[7][1], counter[7][2], counter[7][3], counter[7][4],