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"
77 // --- Standard library ---
79 // --- AliRoot header files ---
82 #include "AliPHOSv1.h"
83 #include "AliPHOSAnalyze.h"
84 #include "AliPHOSDigit.h"
85 #include "AliPHOSSDigitizer.h"
86 #include "AliPHOSTrackSegment.h"
87 #include "AliPHOSRecParticle.h"
88 #include "AliPHOSCpvRecPoint.h"
89 #include "AliPHOSGetter.h"
92 ClassImp(AliPHOSAnalyze)
94 //____________________________________________________________________________
95 AliPHOSAnalyze::AliPHOSAnalyze()
97 // default ctor (useless)
98 fCorrection = 1.2 ; //Value calculated for default parameters of reconstruction
101 //____________________________________________________________________________
102 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName)
104 // ctor: analyze events from root file "name"
105 ffileName = fileName ;
106 fCorrection = 1.05 ; //Value calculated for default parameters of reconstruction
109 //____________________________________________________________________________
110 AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana)
113 ( (AliPHOSAnalyze &)ana ).Copy(*this) ;
116 //____________________________________________________________________________
117 AliPHOSAnalyze::~AliPHOSAnalyze()
122 //____________________________________________________________________________
123 void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,const char* branchTitle){
124 //Draws pimary particles and reconstructed
125 //digits, RecPoints, RecPartices etc
126 //for event Nevent in the module Nmod.
128 //========== Create ObjectGetter
129 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
130 if(Nevent >= gAlice->TreeE()->GetEntries() ) {
131 Error("DrawRecon", "There is no event %d only %d events available", Nevent, gAlice->TreeE()->GetEntries() ) ;
134 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
137 Int_t nx = phosgeom->GetNPhi() ;
138 Int_t nz = phosgeom->GetNZ() ;
139 Float_t * cri= phosgeom->GetEMCAGeometry()->GetCrystalHalfSize() ;
140 Float_t x = nx*cri[0] ;
141 Float_t z = nz*cri[2] ;
142 Int_t nxCPV = (Int_t) (nx*phosgeom->GetPadSizePhi()/(2.*cri[0])) ;
143 Int_t nzCPV = (Int_t) (nz*phosgeom->GetPadSizeZ()/(2.*cri[2])) ;
145 TH2F * emcDigits = (TH2F*) gROOT->FindObject("emcDigits") ;
147 emcDigits->Delete() ;
148 emcDigits = new TH2F("emcDigits","EMC digits", nx,-x,x,nz,-z,z);
149 TH2F * emcSdigits =(TH2F*) gROOT->FindObject("emcSdigits") ;
151 emcSdigits->Delete() ;
152 emcSdigits = new TH2F("emcSdigits","EMC sdigits", nx,-x,x,nz,-z,z);
153 TH2F * emcRecPoints = (TH2F*)gROOT->FindObject("emcRecPoints") ;
155 emcRecPoints->Delete() ;
156 emcRecPoints = new TH2F("emcRecPoints","EMC RecPoints",nx,-x,x,nz,-z,z);
157 TH2F * cpvSdigits =(TH2F*) gROOT->FindObject("cpvSdigits") ;
159 cpvSdigits->Delete() ;
160 cpvSdigits = new TH2F("cpvSdigits","CPV sdigits", nx,-x,x,nz,-z,z);
161 TH2F * cpvDigits = (TH2F*)gROOT->FindObject("cpvDigits") ;
163 cpvDigits->Delete() ;
164 cpvDigits = new TH2F("cpvDigits","CPV digits", nxCPV,-x,x,nzCPV,-z,z) ;
165 TH2F * cpvRecPoints= (TH2F*)gROOT->FindObject("cpvRecPoints") ;
167 cpvRecPoints->Delete() ;
168 cpvRecPoints = new TH2F("cpvRecPoints","CPV RecPoints", nxCPV,-x,x,nzCPV,-z,z) ;
170 TH2F * phot = (TH2F*)gROOT->FindObject("phot") ;
173 phot = new TH2F("phot","Primary Photon", nx,-x,x,nz,-z,z);
174 TH2F * recPhot = (TH2F*)gROOT->FindObject("recPhot") ;
177 recPhot = new TH2F("recPhot","RecParticles with primary Photon",nx,-x,x,nz,-z,z);
180 //Plot Primary Particles
181 const TParticle * primary ;
183 for ( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++)
185 primary = gime->Primary(iPrimary) ;
186 Int_t primaryType = primary->GetPdgCode() ;
187 // if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212)
188 // ||(primaryType == 11)||(primaryType == -11) ) {
189 // Int_t moduleNumber ;
190 // Double_t primX, primZ ;
191 // phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
192 // if(moduleNumber==Nmod)
193 // charg->Fill(primZ,primX,primary->Energy()) ;
195 if( primaryType == 22 ) {
197 Double_t primX, primZ ;
198 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
199 if(moduleNumber==Nmod)
200 phot->Fill(primZ,primX,primary->Energy()) ;
203 // if( primaryType == -2112 ) {
204 // Int_t moduleNumber ;
205 // Double_t primX, primZ ;
206 // phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
207 // if(moduleNumber==Nmod)
208 // nbar->Fill(primZ,primX,primary->Energy()) ;
215 AliPHOSDigit * sdigit ;
216 const TClonesArray * sdigits = gime->SDigits() ;
217 Int_t nsdig[5] = {0,0,0,0,0} ;
219 for(iSDigit = 0; iSDigit < sdigits->GetEntriesFast() ; iSDigit++)
221 sdigit = (AliPHOSDigit *) sdigits->At(iSDigit) ;
223 phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
225 phosgeom->RelPosInModule(relid,x,z) ;
226 Float_t e = gime->SDigitizer()->Calibrate(sdigit->GetAmp()) ;
227 nsdig[relid[0]-1]++ ;
229 if(relid[1]==0) //EMC
230 emcSdigits->Fill(x,z,e) ;
232 cpvSdigits->Fill(x,z,e) ;
237 message = "Number of EMC + CPV SDigits per module: \n" ;
238 message += "%d %d %d %d %d\n";
239 Info("DrawRecon", message.Data(), nsdig[0], nsdig[1], nsdig[2], nsdig[3], nsdig[4] ) ;
243 AliPHOSDigit * digit ;
244 const TClonesArray * digits = gime->Digits();
246 for(iDigit = 0; iDigit < digits->GetEntriesFast(); iDigit++)
248 digit = (AliPHOSDigit *) digits->At(iDigit) ;
250 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
252 phosgeom->RelPosInModule(relid,x,z) ;
253 Float_t e = gime->SDigitizer()->Calibrate(digit->GetAmp()) ;
255 if(relid[1]==0) //EMC
256 emcDigits->Fill(x,z,e) ;
258 cpvDigits->Fill(x,z,e) ;
267 TObjArray * emcrp = gime->EmcRecPoints() ;
269 for(irecp = 0; irecp < emcrp->GetEntriesFast() ; irecp ++){
270 AliPHOSEmcRecPoint * emc = (AliPHOSEmcRecPoint *) emcrp->At(irecp) ;
271 if(emc->GetPHOSMod()==Nmod){
272 emc->GetLocalPosition(pos) ;
273 emcRecPoints->Fill(pos.X(),pos.Z(),emc->GetEnergy());
278 TObjArray * cpvrp = gime->CpvRecPoints() ;
280 for(irecp = 0; irecp < cpvrp->GetEntriesFast() ; irecp ++){
281 AliPHOSRecPoint * cpv = (AliPHOSCpvRecPoint *) cpvrp->At(irecp) ;
282 if(cpv->GetPHOSMod()==Nmod){
283 cpv->GetLocalPosition(pos) ;
284 cpvRecPoints->Fill(pos.X(),pos.Z(),cpv->GetEnergy());
290 AliPHOSRecParticle * recParticle ;
292 TClonesArray * rp = gime->RecParticles() ;
293 TClonesArray * ts = gime->TrackSegments() ;
294 if(rp && ts && emcrp) {
295 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast() ; iRecParticle++ )
297 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
298 Int_t moduleNumberRec ;
299 Double_t recX, recZ ;
300 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
301 if(moduleNumberRec == Nmod){
303 Double_t minDistance = 5. ;
304 Int_t closestPrimary = -1 ;
306 //extract list of primaries: it is stored at EMC RecPoints
307 Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
308 Int_t numberofprimaries ;
309 Int_t * listofprimaries = ((AliPHOSRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
311 const TParticle * primary ;
312 Double_t distance = minDistance ;
314 for ( index = 0 ; index < numberofprimaries ; index++){
315 primary = gime->Primary(listofprimaries[index]) ;
317 Double_t primX, primZ ;
318 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
319 if(moduleNumberRec == moduleNumber)
320 distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ;
321 if(minDistance > distance)
323 minDistance = distance ;
324 closestPrimary = listofprimaries[index] ;
328 if(closestPrimary >=0 ){
330 Int_t primaryType = gime->Primary(closestPrimary)->GetPdgCode() ;
333 recPhot->Fill(recZ,recX,recParticle->Energy()) ;
335 // if(primaryType==-2112)
336 // recNbar->Fill(recZ,recX,recParticle->Energy()) ;
343 //Plot made histograms
344 emcSdigits->Draw("box") ;
345 emcDigits->SetLineColor(5) ;
346 emcDigits->Draw("boxsame") ;
347 emcRecPoints->SetLineColor(2) ;
348 emcRecPoints->Draw("boxsame") ;
349 cpvSdigits->SetLineColor(1) ;
350 cpvSdigits->Draw("boxsame") ;
353 //____________________________________________________________________________
354 void AliPHOSAnalyze::Ls(){
355 //lists branches and titles of PHOS-related branches of TreeR, TreeD, TreeS
357 AliPHOSGetter::GetInstance(ffileName.Data()) ;
360 TObjArray * branches;
362 branches = gAlice->TreeS()->GetListOfBranches() ;
365 message = "TreeS:\n" ;
366 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
367 TBranch * branch=(TBranch *) branches->At(ibranch) ;
368 if(strstr(branch->GetName(),"PHOS") ){
370 message += branch->GetName() ;
372 message += branch->GetTitle() ;
376 branches = gAlice->TreeD()->GetListOfBranches() ;
378 message += "TreeD:\n" ;
379 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
380 TBranch * branch=(TBranch *) branches->At(ibranch) ;
381 if(strstr(branch->GetName(),"PHOS") ) {
383 message += branch->GetName() ;
385 message += branch->GetTitle() ;
390 branches = gAlice->TreeR()->GetListOfBranches() ;
392 message += "TreeR: \n" ;
393 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
394 TBranch * branch=(TBranch *) branches->At(ibranch) ;
395 if(strstr(branch->GetName(),"PHOS") ) {
397 message += branch->GetName() ;
399 message += branch->GetTitle() ;
403 Info("LS", message.Data()) ;
405 //____________________________________________________________________________
406 void AliPHOSAnalyze::InvariantMass(const char* branchTitle)
408 // Calculates Real and Mixed invariant mass distributions
409 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
411 Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
414 TFile * mfile = new TFile("invmass.root","update");
416 //========== Reading /Booking Histograms
418 hRealEM = (TH2D*) mfile->Get("hRealEM") ;
420 hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
421 TH2D * hRealPhot = 0 ;
423 hRealPhot = (TH2D*)mfile->Get("hRealPhot");
425 hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
427 TH2D * hMixedEM = 0 ;
428 hMixedEM = (TH2D*) mfile->Get("hMixedEM") ;
430 hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
432 TH2D * hMixedPhot = 0 ;
433 hMixedPhot = (TH2D*) mfile->Get("hMixedPhot") ;
435 hMixedPhot = new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
438 //reading event and copyng it to TConesArray of all photons
440 TClonesArray * allRecParticleList = new TClonesArray("AliPHOSRecParticle", 1000) ;
441 Int_t * nRecParticles = new Int_t[nMixedEvents] ; // to mark boundaries of each event in the total list
442 for(Int_t index = 0; index < nMixedEvents; index ++)
443 nRecParticles[index] = 0 ;
444 Int_t iRecPhot = 0 ; // number of EM particles in total list
446 //scan over all events
448 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
449 // for(event = 0; event < gime->MaxEvent(); event++ ){
450 for(event = 0; event < maxevent; event++ ){
451 gime->Event(event,"R"); //will read only TreeR
453 //copy EM RecParticles to the "total" list
454 const AliPHOSRecParticle * recParticle ;
456 TClonesArray * rp = gime->RecParticles() ;
458 Error("InvariantMass", "Can't find RecParticles") ;
462 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ )
464 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
465 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
466 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW))
467 new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ;
470 Int_t mevent = event%nMixedEvents ; //event number in the "mixed" cicle
471 nRecParticles[mevent] = iRecPhot-1 ;
473 //check, if it is time to calculate invariant mass?
474 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
475 if((mevent == 0) && (event +1 == maxevent)){
477 // if((mevent == 0) && (event +1 == gime->MaxEvent())){
479 //calculate invariant mass:
481 Int_t nCurEvent = 0 ;
483 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
484 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
486 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
487 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
490 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
491 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
492 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
493 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
496 invMass = TMath::Sqrt(invMass);
499 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +
500 (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) );
502 if(irp1 > nRecParticles[nCurEvent])
505 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
506 hRealEM->Fill(invMass,pt);
507 if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&&
508 (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) )
509 hRealPhot->Fill(invMass,pt);
512 hMixedEM->Fill(invMass,pt);
513 if((rp1->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)&&
514 (rp2->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST) )
515 hMixedPhot->Fill(invMass,pt);
518 } //loop over second rp
519 }//loop over first rp
521 //Make some cleanings
522 for(Int_t index = 0; index < nMixedEvents; index ++)
523 nRecParticles[index] = 0 ;
525 allRecParticleList->Clear() ;
529 delete allRecParticleList ;
534 hRealEM->Write(0,kOverwrite) ;
535 hRealPhot->Write(0,kOverwrite) ;
536 hMixedEM->Write(0,kOverwrite) ;
537 hMixedPhot->Write(0,kOverwrite) ;
542 delete nRecParticles;
546 //____________________________________________________________________________
547 void AliPHOSAnalyze::EnergyResolution(const char * branchTitle)
549 //fills two dimentional histo: energy of primary vs. energy of reconstructed
551 TH2F * hAllEnergy = 0 ; //all reconstructed with primary photon
552 TH2F * hPhotEnergy= 0 ; //kGamma with primary photon
553 TH2F * hEMEnergy = 0 ; //electromagnetic with primary photon
555 //opening file and reading histograms if any
556 TFile * efile = new TFile("energy.root","update");
558 hAllEnergy = (TH2F*)efile->Get("hAllEnergy") ;
560 hAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
562 hPhotEnergy =(TH2F*) efile->Get("hPhotEnergy") ;
564 hPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
566 hEMEnergy =(TH2F*) efile->Get("hEMEnergy");
568 hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
571 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
572 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
575 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
576 for ( ievent=0; ievent < maxevent ; ievent++){
578 //read the current event
579 gime->Event(ievent) ;
581 const AliPHOSRecParticle * recParticle ;
583 TClonesArray * rp = gime->RecParticles() ;
585 Error("EnergyResolution", "Event %d, Can't find RecParticles ", ievent) ;
588 TClonesArray * ts = gime->TrackSegments() ;
590 Error("EnergyResolution", "Event %d, Can't find TrackSegments", ievent) ;
593 TObjArray * emcrp = gime->EmcRecPoints() ;
595 Error("EnergyResolution", "Event %d, Can't find EmcRecPoints") ;
599 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast() ;iRecParticle++ ){
600 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
602 //find the closest primary
603 Int_t moduleNumberRec ;
604 Double_t recX, recZ ;
605 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
607 Double_t minDistance = 100. ;
608 Int_t closestPrimary = -1 ;
610 //extract list of primaries: it is stored at EMC RecPoints
611 Int_t emcIndex = ((AliPHOSTrackSegment*) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
612 Int_t numberofprimaries ;
613 Int_t * listofprimaries = ((AliPHOSEmcRecPoint*) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
616 const TParticle * primary ;
617 Double_t distance = minDistance ;
620 Double_t dZmin = 0. ;
621 for ( index = 0 ; index < numberofprimaries ; index++){
622 primary = gime->Primary(listofprimaries[index]) ;
624 Double_t primX, primZ ;
625 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
626 if(moduleNumberRec == moduleNumber) {
629 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
630 if(minDistance > distance) {
631 minDistance = distance ;
634 closestPrimary = listofprimaries[index] ;
639 //if found primary, fill histograms
640 if(closestPrimary >=0 ){
641 const TParticle * primary = gime->Primary(closestPrimary) ;
642 if(primary->GetPdgCode() == 22){
643 hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ;
644 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
645 hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
646 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
649 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)
650 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
656 //write filled histograms
658 hAllEnergy->Write(0,kOverwrite) ;
659 hPhotEnergy->Write(0,kOverwrite) ;
660 hEMEnergy->Write(0,kOverwrite) ;
666 //____________________________________________________________________________
667 void AliPHOSAnalyze::PositionResolution(const char * branchTitle)
669 //fills two dimentional histo: energy vs. primary - reconstructed distance
673 TH2F * hAllPosition = 0; // Position of any RP with primary photon
674 TH2F * hPhotPosition = 0; // Position of kGAMMA with primary photon
675 TH2F * hEMPosition = 0; // Position of EM with primary photon
677 TH1F * hAllPositionX = 0; // X-Position Resolution of photons with photon primary
678 TH1F * hAllPositionZ = 0; // Z-Position Resolution of photons with photon primary
681 //opening file and reading histograms if any
682 TFile * pfile = new TFile("position.root","update");
684 hAllPosition = (TH2F*)pfile->Get("hAllPosition");
685 if(hAllPosition == 0)
686 hAllPosition = new TH2F("hAllPosition",
687 "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
688 hPhotPosition= (TH2F*)pfile->Get("hPhotPosition");
689 if(hPhotPosition == 0)
690 hPhotPosition = new TH2F("hPhotPosition",
691 "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
692 hEMPosition= (TH2F*)pfile->Get("hEMPosition") ;
694 hEMPosition = new TH2F("hEMPosition",
695 "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
696 hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ;
697 if(hAllPositionX == 0)
698 hAllPositionX = new TH1F("hAllPositionX",
699 "Delta X of any RP with primary photon",100, -2., 2.);
700 hAllPositionZ =(TH1F*) pfile->Get("hAllPositionZ") ;
701 if(hAllPositionZ == 0)
702 hAllPositionZ = new TH1F("hAllPositionZ",
703 "Delta X of any RP with primary photon",100, -2., 2.);
706 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
707 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
710 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
711 for ( ievent=0; ievent < maxevent ; ievent++){
713 //read the current event
714 gime->Event(ievent) ;
715 TClonesArray * rp = gime->RecParticles() ;
717 Error("PositionResolution", "Event %d, Can't find RecParticles", ievent) ;
720 TClonesArray * ts = gime->TrackSegments() ;
722 Error("PositionResolution", "Event %d, Can't find TrackSegments", ievent) ;
725 TObjArray * emcrp = gime->EmcRecPoints() ;
727 Error("PositionResolution", "Event %d, Can't find EmcRecPoints", ievent) ;
732 const AliPHOSRecParticle * recParticle ;
734 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ ){
735 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
737 //find the closest primary
738 Int_t moduleNumberRec ;
739 Double_t recX, recZ ;
740 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
742 Double_t minDistance = 100. ;
743 Int_t closestPrimary = -1 ;
745 //extract list of primaries: it is stored at EMC RecPoints
746 Int_t emcIndex = ((AliPHOSTrackSegment*) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
747 Int_t numberofprimaries ;
748 Int_t * listofprimaries = ((AliPHOSEmcRecPoint *) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
751 const TParticle * primary ;
752 Double_t distance = minDistance ;
753 Double_t dX = 1000; // incredible number
754 Double_t dZ = 1000; // for the case if no primary will be found
756 Double_t dZmin = 0. ;
757 for ( index = 0 ; index < numberofprimaries ; index++){
758 primary = gime->Primary(listofprimaries[index]) ;
760 Double_t primX, primZ ;
761 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
762 if(moduleNumberRec == moduleNumber) {
765 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
766 if(minDistance > distance) {
767 minDistance = distance ;
770 closestPrimary = listofprimaries[index] ;
775 //if found primary, fill histograms
776 if(closestPrimary >=0 ){
777 const TParticle * primary = gime->Primary(closestPrimary) ;
778 if(primary->GetPdgCode() == 22){
779 hAllPosition->Fill(primary->Energy(), minDistance) ;
780 hAllPositionX->Fill(primary->Energy(), dX) ;
781 hAllPositionZ->Fill(primary->Energy(), dZ) ;
782 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
783 hPhotPosition->Fill(primary->Energy(), minDistance ) ;
784 hEMPosition->Fill(primary->Energy(), minDistance ) ;
787 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)
788 hEMPosition->Fill(primary->Energy(), minDistance ) ;
794 //Write output histgrams
796 hAllPosition->Write(0,kOverwrite) ;
797 hAllPositionX->Write(0,kOverwrite) ;
798 hAllPositionZ->Write(0,kOverwrite) ;
799 hPhotPosition->Write(0,kOverwrite) ;
800 hEMPosition->Write(0,kOverwrite) ;
807 //____________________________________________________________________________
808 void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){
809 // fills spectra of primary photons and several kinds of
810 // reconstructed particles, so that analyzing them one can
811 // estimate conatmination, efficiency of registration etc.
813 //define several general histograms
814 TH1F * hPrimary = 0; //spectrum (P_t distribution) of primary photons
815 TH1F * hAllRP = 0; //spectrum of all RecParticles in PHOS
816 TH1F * hPhot = 0; //spectrum of kGAMMA RecParticles
817 TH1F * hShape = 0; //spectrum of all EM RecParticles
818 TH1F * hVeto = 0; //spectrum of all neutral RecParticles
820 //Now separate histograms in accoradance with primary
822 TH1F * hPhotReg = 0; //Registeres as photon
823 TH1F * hPhotEM = 0; //Registered as EM
826 TH1F * hNReg = 0; //Registeres as photon
827 TH1F * hNEM = 0; //Registered as EM
830 TH1F * hNBarReg = 0; //Registeres as photon
831 TH1F * hNBarEM = 0; //Registered as EM
833 //primary - charged hadron (pBar excluded)
834 TH1F * hChargedReg = 0; //Registeres as photon
835 TH1F * hChargedEM = 0; //Registered as EM
838 TH1F * hPbarReg = 0; //Registeres as photon
839 TH1F * hPbarEM = 0; //Registered as EM
842 //Reading histograms from the file
843 TFile * cfile = new TFile("contamination.root","update") ;
845 //read general histograms
846 hPrimary = (TH1F*) cfile->Get("hPrimary") ;
848 hPrimary= new TH1F("hPrimary", "Primary photon spectrum", 100, 0., 5.);
849 hAllRP = (TH1F*)cfile->Get("hAllRP") ;
851 hAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
852 hPhot = (TH1F*)cfile->Get("hPhot") ;
854 hPhot = new TH1F("hPhot","All kGAMMA RecParticles",100, 0., 5.);
855 hShape = (TH1F*) cfile->Get("hShape") ;
857 hShape = new TH1F("hShape","All particles with EM shower",100, 0., 5.);
858 hVeto= (TH1F*)cfile->Get("hVeto") ;
860 hVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
864 hPhotReg = (TH1F*)cfile->Get("hPhotReg");
866 hPhotReg = new TH1F("hPhotReg","Photon registered as photon",100, 0., 5.);
867 hPhotEM =(TH1F*)cfile->Get("hPhotEM");
869 hPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
872 hNReg = (TH1F*)cfile->Get("hNReg");
874 hNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
875 hNEM = (TH1F*)cfile->Get("hNEM");
877 hNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
880 hNBarReg =(TH1F*)cfile->Get("hNBarReg");
882 hNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
883 hNBarEM =(TH1F*)cfile->Get("hNBarEM");
885 hNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
887 //primary - charged hadron (pBar excluded)
888 hChargedReg = (TH1F*)cfile->Get("hChargedReg");
890 hChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
891 hChargedEM = (TH1F*)cfile->Get("hChargedEM");
893 hChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
896 hPbarReg = (TH1F*)cfile->Get("hPbarReg");
898 hPbarReg= new TH1F("hPbarReg", "pBar registered as photon",100, 0., 5.);
899 hPbarEM = (TH1F*)cfile->Get("hPbarEM");
901 hPbarEM= new TH1F("hPbarEM","Pbar registered as EM",100, 0., 5.);
904 //Now make some initializations
906 Int_t counter[8][5] ; //# of registered particles
908 for(i1 = 0; i1<8; i1++)
909 for(i2 = 0; i2<5; i2++)
910 counter[i1][i2] = 0 ;
914 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),RecPointsTitle) ;
915 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
918 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
919 for ( ievent=0; ievent < maxevent ; ievent++){
921 gime->Event(ievent) ;
923 TClonesArray * rp = gime->RecParticles() ;
925 Error("Contamination", "Event %d, Can't find RecParticles", ievent) ;
928 TClonesArray * ts = gime->TrackSegments() ;
930 Error("Contamination", "Event %d, Can't find TrackSegments", ievent) ;
933 TObjArray * emcrp = gime->EmcRecPoints() ;
935 Error("Contamination", "Event %d, Can't find EmcRecPoints", ievent) ;
940 //=========== Make spectrum of the primary photons
941 const TParticle * primary ;
943 for( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++){
944 primary = gime->Primary(iPrimary) ;
945 Int_t primaryType = primary->GetPdgCode() ;
946 if( primaryType == 22 ) {
947 //check, if photons folls onto PHOS
949 Double_t primX, primZ ;
950 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
952 hPrimary->Fill(primary->Energy()) ;
958 //========== Now scan over RecParticles
959 const AliPHOSRecParticle * recParticle ;
961 for(iRecParticle = 0; iRecParticle < rp->GetEntriesFast(); iRecParticle++ ){
962 recParticle = (AliPHOSRecParticle *) rp->At(iRecParticle) ;
963 //fill histo spectrum of all RecParticles
964 hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ;
966 //==========find the closest primary
967 Int_t moduleNumberRec ;
968 Double_t recX, recZ ;
969 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
971 Double_t minDistance = 100. ;
972 Int_t closestPrimary = -1 ;
974 //extract list of primaries: it is stored at EMC RecPoints
975 Int_t emcIndex = ((AliPHOSTrackSegment *) ts->At(recParticle->GetPHOSTSIndex()))->GetEmcIndex() ;
976 Int_t numberofprimaries ;
977 Int_t * listofprimaries = ((AliPHOSEmcRecPoint *) emcrp->At(emcIndex))->GetPrimaries(numberofprimaries) ;
979 const TParticle * primary ;
980 Double_t distance = minDistance ;
983 Double_t dZmin = 0. ;
984 for ( index = 0 ; index < numberofprimaries ; index++){
985 primary = gime->Primary(listofprimaries[index]) ;
987 Double_t primX, primZ ;
988 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
989 if(moduleNumberRec == moduleNumber) {
992 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
993 if(minDistance > distance) {
994 minDistance = distance ;
997 closestPrimary = listofprimaries[index] ;
1002 //===========define the "type" of closest primary
1003 if(closestPrimary >=0 ){
1004 Int_t primaryCode = -1;
1005 const TParticle * primary = gime->Primary(closestPrimary) ;
1006 Int_t primaryType = primary->GetPdgCode() ;
1007 if(primaryType == 22) // photon ?
1010 if(primaryType == 2112) // neutron
1013 if(primaryType == -2112) // Anti neutron
1016 if(primaryType == -2122) //Anti proton
1019 TParticle tempo(*primary) ;
1020 if(tempo.GetPDG()->Charge())
1024 //==========Now look at the type of RecParticle
1025 Float_t energy = CorrectedEnergy(recParticle->Energy()) ;
1026 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST){
1027 hPhot->Fill(energy ) ;
1028 switch(primaryCode){
1030 hPhotReg->Fill(energy ) ;
1033 hNReg->Fill(energy ) ;
1036 hNBarReg->Fill(energy ) ;
1039 hChargedReg->Fill(energy ) ;
1042 hPbarReg->Fill(energy ) ;
1048 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
1049 (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMFAST)||
1050 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW)||
1051 (recParticle->GetType() == AliPHOSFastRecParticle::kCHARGEDEMSLOW) ){ //with EM shower
1052 hShape->Fill(energy ) ;
1053 switch(primaryCode){
1055 hPhotEM->Fill(energy ) ;
1058 hNEM->Fill(energy ) ;
1061 hNBarEM->Fill(energy ) ;
1064 hChargedEM->Fill(energy ) ;
1067 hPbarEM->Fill(energy ) ;
1074 if((recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMFAST)||
1075 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHAFAST) ||
1076 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEMSLOW) ||
1077 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHASLOW) ) //nuetral
1078 hVeto->Fill(energy ) ;
1080 //fill number of primaries identified as ...
1081 if(primaryCode >= 0) // Primary code defined
1082 counter[recParticle->GetType()][primaryCode]++ ;
1086 } // no closest primary found
1090 //=================== SaveHistograms
1092 hPrimary->Write(0,kOverwrite);
1093 hAllRP->Write(0,kOverwrite);
1094 hPhot->Write(0,kOverwrite);
1095 hShape->Write(0,kOverwrite);
1096 hVeto->Write(0,kOverwrite);
1097 hPhotReg->Write(0,kOverwrite);
1098 hPhotEM->Write(0,kOverwrite);
1099 hNReg ->Write(0,kOverwrite);
1100 hNEM ->Write(0,kOverwrite);
1101 hNBarReg ->Write(0,kOverwrite);
1102 hNBarEM ->Write(0,kOverwrite);
1103 hChargedReg ->Write(0,kOverwrite);
1104 hChargedEM ->Write(0,kOverwrite);
1105 hPbarReg ->Write(0,kOverwrite);
1106 hPbarEM ->Write(0,kOverwrite);
1108 cfile->Write(0,kOverwrite);
1114 maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
1117 message = "Resolutions: Analyzed %d event(s)\n" ;
1119 message += " Primary: Photon Neutron Antineutron Charged hadron AntiProton\n" ;
1120 message += "--------------------------------------------------------------------------------\n" ;
1121 message += " kGAMMA: " ;
1122 message += "%d %d %d %d %d\n" ;
1123 message += " kGAMMAHA: " ;
1124 message += "%d %d %d %d %d\n" ;
1125 message += " kNEUTRALEM: " ;
1126 message += "%d %d %d %d %d\n" ;
1127 message += " kNEUTRALHA: " ;
1128 message += "%d %d %d %d %d\n" ;
1129 message += " kABSURDEM: ";
1130 message += "%d %d %d %d %d\n" ;
1131 message += " kABSURDHA: " ;
1132 message += "%d %d %d %d %d\n" ;
1133 message += " kELECTRON: " ;
1134 message += "%d %d %d %d %d\n" ;
1135 message += " kCHARGEDHA: " ;
1136 message += "%d %d %d %d %d\n" ;
1138 message += "--------------------------------------------------------------------------------" ;
1141 Int_t totalInd = 0 ;
1142 for(i1 = 0; i1<8; i1++)
1143 for(i2 = 0; i2<5; i2++)
1144 totalInd+=counter[i1][i2] ;
1145 message += "Indentified particles: %d" ;
1147 Info("Contamination", message.Data(), maxevent,
1148 counter[2][0], counter[2][1], counter[2][2], counter[2][3], counter[2][4],
1149 counter[3][0], counter[3][1], counter[3][2], counter[3][3], counter[3][4],
1150 counter[0][0], counter[0][1], counter[0][2], counter[0][3], counter[0][4],
1151 counter[1][0], counter[1][1], counter[1][2], counter[1][3], counter[1][4],
1152 counter[4][0], counter[4][1], counter[4][2], counter[4][3], counter[4][4],
1153 counter[5][0], counter[5][1], counter[5][2], counter[5][3], counter[5][4],
1154 counter[6][0], counter[6][1], counter[6][2], counter[6][3], counter[6][4],
1155 counter[7][0], counter[7][1], counter[7][2], counter[7][3], counter[7][4],