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 "AliPHOSPpsdRecPoint.h"
93 #include "AliPHOSGetter.h"
96 ClassImp(AliPHOSAnalyze)
98 //____________________________________________________________________________
99 AliPHOSAnalyze::AliPHOSAnalyze()
101 // default ctor (useless)
102 fCorrection = 1.2 ; //Value calculated for default parameters of reconstruction
105 //____________________________________________________________________________
106 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName)
108 // ctor: analyze events from root file "name"
109 ffileName = fileName ;
110 fCorrection = 1.05 ; //Value calculated for default parameters of reconstruction
113 //____________________________________________________________________________
114 AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana)
117 ( (AliPHOSAnalyze &)ana ).Copy(*this) ;
120 //____________________________________________________________________________
121 AliPHOSAnalyze::~AliPHOSAnalyze()
126 //____________________________________________________________________________
127 void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,const char* branchTitle){
128 //Draws pimary particles and reconstructed
129 //digits, RecPoints, RecPartices etc
130 //for event Nevent in the module Nmod.
132 TH2F * digitOccupancy = new TH2F("digitOccupancy","EMC digits", 64,-71.,71.,64,-71.,71.);
133 TH2F * sdigitOccupancy = new TH2F("sdigitOccupancy","EMC sdigits", 64,-71.,71.,64,-71.,71.);
134 TH2F * emcOccupancy = new TH2F("emcOccupancy","EMC RecPoints",64,-71.,71.,64,-71.,71.);
135 TH2F * ppsdUp = new TH2F("ppsdUp","PPSD Up digits", 128,-71.,71.,128,-71.,71.) ;
136 TH2F * ppsdUpCl = new TH2F("ppsdUpCl","PPSD Up RecPoints",128,-71.,71.,128,-71.,71.) ;
137 TH2F * ppsdLow = new TH2F("ppsdLow","PPSD Low digits", 128,-71.,71.,128,-71.,71.) ;
138 TH2F * ppsdLowCl = new TH2F("ppsdLowCl","PPSD Low RecPoints",128,-71.,71.,128,-71.,71.) ;
139 TH2F * nbar = new TH2F("nbar","Primary nbar", 64,-71.,71.,64,-71.,71.);
140 TH2F * phot = new TH2F("phot","Primary Photon", 64,-71.,71.,64,-71.,71.);
141 TH2F * charg = new TH2F("charg","Primary charged",64,-71.,71.,64,-71.,71.);
142 TH2F * recPhot = new TH2F("recPhot","RecParticles with primary Photon",64,-71.,71.,64,-71.,71.);
143 TH2F * recNbar = new TH2F("recNbar","RecParticles with primary Nbar", 64,-71.,71.,64,-71.,71.);
145 //========== Create ObjectGetter
146 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
147 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
150 //Plot Primary Particles
151 const TParticle * primary ;
153 for ( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++)
155 primary = gime->Primary(iPrimary) ;
156 Int_t primaryType = primary->GetPdgCode() ;
157 if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212) ) {
159 Double_t primX, primZ ;
160 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
161 if(moduleNumber==Nmod)
162 charg->Fill(primZ,primX,primary->Energy()) ;
164 if( primaryType == 22 ) {
166 Double_t primX, primZ ;
167 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
168 if(moduleNumber==Nmod)
169 phot->Fill(primZ,primX,primary->Energy()) ;
172 if( primaryType == -2112 ) {
174 Double_t primX, primZ ;
175 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
176 if(moduleNumber==Nmod)
177 nbar->Fill(primZ,primX,primary->Energy()) ;
183 const AliPHOSDigit * sdigit ;
185 for(iSDigit = 0; iSDigit < gime->NSDigits(); iSDigit++)
187 sdigit = gime->SDigit(iSDigit) ;
189 phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
191 phosgeom->RelPosInModule(relid,x,z) ;
192 Float_t e = gime->SDigitizer()->Calibrate(sdigit->GetAmp()) ;
194 if(relid[1]==0) //EMC
195 sdigitOccupancy->Fill(x,z,e) ;
196 if((relid[1]>0)&&(relid[1]<17))
197 ppsdUp->Fill(x,z,e) ;
199 ppsdLow->Fill(x,z,e) ;
205 const AliPHOSDigit * digit ;
206 for(iDigit = 0; iDigit < gime->NDigits(); iDigit++)
208 digit = gime->Digit(iDigit) ;
210 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
212 phosgeom->RelPosInModule(relid,x,z) ;
213 Float_t e = gime->SDigitizer()->Calibrate(digit->GetAmp()) ;
215 if(relid[1]==0) //EMC
216 digitOccupancy->Fill(x,z,e) ;
217 if((relid[1]>0)&&(relid[1]<17))
218 ppsdUp->Fill(x,z,e) ;
220 ppsdLow->Fill(x,z,e) ;
229 for(irecp = 0; irecp < gime->NEmcRecPoints() ; irecp ++){
230 const AliPHOSEmcRecPoint * emc= gime->EmcRecPoint(irecp) ;
231 if(emc->GetPHOSMod()==Nmod){
232 emc->GetLocalPosition(pos) ;
233 emcOccupancy->Fill(pos.X(),pos.Z(),emc->GetEnergy());
238 for(irecp = 0; irecp < gime->NCpvRecPoints() ; irecp ++){
239 const AliPHOSRecPoint * cpv = gime->CpvRecPoint(irecp) ;
240 if((strcmp(cpv->ClassName(),"AliPHOSPpsdRecPoint" )) == 0){ // PPSD Rec Point
241 AliPHOSPpsdRecPoint * ppsd = (AliPHOSPpsdRecPoint*) cpv ;
242 ppsd->GetLocalPosition(pos) ;
243 if(ppsd->GetPHOSMod()==Nmod){
244 ppsd->GetLocalPosition(pos) ;
246 ppsdUpCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
248 ppsdLowCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
252 AliPHOSCpvRecPoint * cpv1 = (AliPHOSCpvRecPoint*) cpv ;
253 if(cpv1->GetPHOSMod()==Nmod){
254 cpv1->GetLocalPosition(pos) ;
255 ppsdUpCl->Fill(pos.X(),pos.Z(),cpv1->GetEnergy());
262 const AliPHOSRecParticle * recParticle ;
264 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ )
266 recParticle = gime->RecParticle(iRecParticle) ;
267 Int_t moduleNumberRec ;
268 Double_t recX, recZ ;
269 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
270 if(moduleNumberRec == Nmod){
272 Double_t minDistance = 5. ;
273 Int_t closestPrimary = -1 ;
276 //extract list of primaries: it is stored at EMC RecPoints
277 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
278 Int_t numberofprimaries ;
279 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
281 const TParticle * primary ;
282 Double_t distance = minDistance ;
284 for ( index = 0 ; index < numberofprimaries ; index++){
285 primary = gime->Primary(listofprimaries[index]) ;
287 Double_t primX, primZ ;
288 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
289 if(moduleNumberRec == moduleNumber)
290 distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ;
291 if(minDistance > distance)
293 minDistance = distance ;
294 closestPrimary = listofprimaries[index] ;
298 if(closestPrimary >=0 ){
300 Int_t primaryType = gime->Primary(closestPrimary)->GetPdgCode() ;
303 recPhot->Fill(recZ,recX,recParticle->Energy()) ;
305 if(primaryType==-2112)
306 recNbar->Fill(recZ,recX,recParticle->Energy()) ;
312 //Plot made histograms
313 digitOccupancy->Draw("box") ;
314 sdigitOccupancy->SetLineColor(5) ;
315 sdigitOccupancy->Draw("box") ;
316 emcOccupancy->SetLineColor(2) ;
317 emcOccupancy->Draw("boxsame") ;
318 ppsdUp->SetLineColor(3) ;
319 ppsdUp->Draw("boxsame") ;
320 ppsdLow->SetLineColor(4) ;
321 ppsdLow->Draw("boxsame") ;
322 phot->SetLineColor(8) ;
323 phot->Draw("boxsame") ;
324 nbar->SetLineColor(6) ;
325 nbar->Draw("boxsame") ;
328 //____________________________________________________________________________
329 void AliPHOSAnalyze::Ls(){
330 //lists branches and titles of PHOS-related branches of TreeR, TreeD, TreeS
332 AliPHOSGetter::GetInstance(ffileName.Data()) ;
335 TObjArray * branches;
337 branches = gAlice->TreeS()->GetListOfBranches() ;
339 cout << "TreeS: " << endl ;
340 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
341 TBranch * branch=(TBranch *) branches->At(ibranch) ;
342 if(strstr(branch->GetName(),"PHOS") )
343 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
347 branches = gAlice->TreeD()->GetListOfBranches() ;
349 cout << "TreeD: " << endl ;
350 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
351 TBranch * branch=(TBranch *) branches->At(ibranch) ;
352 if(strstr(branch->GetName(),"PHOS") )
353 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
358 branches = gAlice->TreeR()->GetListOfBranches() ;
360 cout << "TreeR: " << endl ;
361 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
362 TBranch * branch=(TBranch *) branches->At(ibranch) ;
363 if(strstr(branch->GetName(),"PHOS") )
364 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
370 //____________________________________________________________________________
371 void AliPHOSAnalyze::InvariantMass(const char* branchTitle)
373 // Calculates Real and Mixed invariant mass distributions
374 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
376 Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
379 TFile * mfile = new TFile("invmass.root","update");
381 //========== Reading /Booking Histograms
383 hRealEM = (TH2D*) mfile->Get("hRealEM") ;
385 hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
386 TH2D * hRealPhot = 0 ;
388 hRealPhot = (TH2D*)mfile->Get("hRealPhot");
390 hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
392 TH2D * hMixedEM = 0 ;
393 hMixedEM = (TH2D*) mfile->Get("hMixedEM") ;
395 hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
397 TH2D * hMixedPhot = 0 ;
398 hMixedPhot = (TH2D*) mfile->Get("hMixedPhot") ;
400 hMixedPhot = new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
403 //reading event and copyng it to TConesArray of all photons
405 TClonesArray * allRecParticleList = new TClonesArray("AliPHOSRecParticle", 1000) ;
406 Int_t * nRecParticles = new Int_t[nMixedEvents] ; // to mark boundaries of each event in the total list
407 for(Int_t index = 0; index < nMixedEvents; index ++)
408 nRecParticles[index] = 0 ;
409 Int_t iRecPhot = 0 ; // number of EM particles in total list
411 //scan over all events
413 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
414 // for(event = 0; event < gime->MaxEvent(); event++ ){
415 for(event = 0; event < maxevent; event++ ){
418 //copy EM RecParticles to the "total" list
419 const AliPHOSRecParticle * recParticle ;
421 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ )
423 recParticle = gime->RecParticle(iRecParticle) ;
424 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
425 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM))
426 new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ;
429 Int_t mevent = event%nMixedEvents ; //event number in the "mixed" cicle
430 nRecParticles[mevent] = iRecPhot-1 ;
432 //check, if it is time to calculate invariant mass?
433 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
434 if((mevent == 0) && (event +1 == maxevent)){
436 // if((mevent == 0) && (event +1 == gime->MaxEvent())){
438 //calculate invariant mass:
440 Int_t nCurEvent = 0 ;
442 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
443 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
445 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
446 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
449 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
450 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
451 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
452 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
455 invMass = TMath::Sqrt(invMass);
458 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +
459 (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) );
461 if(irp1 > nRecParticles[nCurEvent])
464 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
465 hRealEM->Fill(invMass,pt);
466 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&
467 (rp2->GetType() == AliPHOSFastRecParticle::kGAMMA) )
468 hRealPhot->Fill(invMass,pt);
471 hMixedEM->Fill(invMass,pt);
472 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&
473 (rp2->GetType() == AliPHOSFastRecParticle::kGAMMA) )
474 hMixedPhot->Fill(invMass,pt);
477 } //loop over second rp
478 }//loop over first rp
480 //Make some cleanings
481 for(Int_t index = 0; index < nMixedEvents; index ++)
482 nRecParticles[index] = 0 ;
484 allRecParticleList->Clear() ;
488 delete allRecParticleList ;
493 hRealEM->Write(0,kOverwrite) ;
494 hRealPhot->Write(0,kOverwrite) ;
495 hMixedEM->Write(0,kOverwrite) ;
496 hMixedPhot->Write(0,kOverwrite) ;
501 delete nRecParticles;
505 //____________________________________________________________________________
506 void AliPHOSAnalyze::EnergyResolution(const char * branchTitle)
508 //fills two dimentional histo: energy of primary vs. energy of reconstructed
510 TH2F * hAllEnergy = 0 ; //all reconstructed with primary photon
511 TH2F * hPhotEnergy= 0 ; //kGamma with primary photon
512 TH2F * hEMEnergy = 0 ; //electromagnetic with primary photon
514 //opening file and reading histograms if any
515 TFile * efile = new TFile("energy.root","update");
517 hAllEnergy = (TH2F*)efile->Get("hAllEnergy") ;
519 hAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
521 hPhotEnergy =(TH2F*) efile->Get("hPhotEnergy") ;
523 hPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
525 hEMEnergy =(TH2F*) efile->Get("hEMEnergy");
527 hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
530 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
531 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
534 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
535 // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){
536 for ( ievent=0; ievent < maxevent ; ievent++){
538 //read the current event
539 gime->Event(ievent) ;
541 const AliPHOSRecParticle * recParticle ;
543 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ){
544 recParticle = gime->RecParticle(iRecParticle) ;
546 //find the closest primary
547 Int_t moduleNumberRec ;
548 Double_t recX, recZ ;
549 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
551 Double_t minDistance = 100. ;
552 Int_t closestPrimary = -1 ;
554 //extract list of primaries: it is stored at EMC RecPoints
555 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
556 Int_t numberofprimaries ;
557 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
560 const TParticle * primary ;
561 Double_t distance = minDistance ;
564 Double_t dZmin = 0. ;
565 for ( index = 0 ; index < numberofprimaries ; index++){
566 primary = gime->Primary(listofprimaries[index]) ;
568 Double_t primX, primZ ;
569 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
570 if(moduleNumberRec == moduleNumber) {
573 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
574 if(minDistance > distance) {
575 minDistance = distance ;
578 closestPrimary = listofprimaries[index] ;
583 //if found primary, fill histograms
584 if(closestPrimary >=0 ){
585 const TParticle * primary = gime->Primary(closestPrimary) ;
586 if(primary->GetPdgCode() == 22){
587 hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ;
588 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
589 hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
590 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
593 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)
594 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
600 //write filled histograms
602 hAllEnergy->Write(0,kOverwrite) ;
603 hPhotEnergy->Write(0,kOverwrite) ;
604 hEMEnergy->Write(0,kOverwrite) ;
610 //____________________________________________________________________________
611 void AliPHOSAnalyze::PositionResolution(const char * branchTitle)
613 //fills two dimentional histo: energy vs. primary - reconstructed distance
617 TH2F * hAllPosition = 0; // Position of any RP with primary photon
618 TH2F * hPhotPosition = 0; // Position of kGAMMA with primary photon
619 TH2F * hEMPosition = 0; // Position of EM with primary photon
621 TH1F * hAllPositionX = 0; // X-Position Resolution of photons with photon primary
622 TH1F * hAllPositionZ = 0; // Z-Position Resolution of photons with photon primary
625 //opening file and reading histograms if any
626 TFile * pfile = new TFile("position.root","update");
628 hAllPosition = (TH2F*)pfile->Get("hAllPosition");
629 if(hAllPosition == 0)
630 hAllPosition = new TH2F("hAllPosition",
631 "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
632 hPhotPosition= (TH2F*)pfile->Get("hPhotPosition");
633 if(hPhotPosition == 0)
634 hPhotPosition = new TH2F("hPhotPosition",
635 "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
636 hEMPosition= (TH2F*)pfile->Get("hEMPosition") ;
638 hEMPosition = new TH2F("hEMPosition",
639 "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
640 hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ;
641 if(hAllPositionX == 0)
642 hAllPositionX = new TH1F("hAllPositionX",
643 "Delta X of any RP with primary photon",100, -2., 2.);
644 hAllPositionZ =(TH1F*) pfile->Get("hAllPositionZ") ;
645 if(hAllPositionZ == 0)
646 hAllPositionZ = new TH1F("hAllPositionZ",
647 "Delta X of any RP with primary photon",100, -2., 2.);
650 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
651 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
654 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
655 // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){
656 for ( ievent=0; ievent < maxevent ; ievent++){
658 //read the current event
659 gime->Event(ievent) ;
661 const AliPHOSRecParticle * recParticle ;
663 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ){
664 recParticle = gime->RecParticle(iRecParticle) ;
666 //find the closest primary
667 Int_t moduleNumberRec ;
668 Double_t recX, recZ ;
669 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
671 Double_t minDistance = 100. ;
672 Int_t closestPrimary = -1 ;
674 //extract list of primaries: it is stored at EMC RecPoints
675 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
676 Int_t numberofprimaries ;
677 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
680 const TParticle * primary ;
681 Double_t distance = minDistance ;
682 Double_t dX = 1000; // incredible number
683 Double_t dZ = 1000; // for the case if no primary will be found
685 Double_t dZmin = 0. ;
686 for ( index = 0 ; index < numberofprimaries ; index++){
687 primary = gime->Primary(listofprimaries[index]) ;
689 Double_t primX, primZ ;
690 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
691 if(moduleNumberRec == moduleNumber) {
694 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
695 if(minDistance > distance) {
696 minDistance = distance ;
699 closestPrimary = listofprimaries[index] ;
704 //if found primary, fill histograms
705 if(closestPrimary >=0 ){
706 const TParticle * primary = gime->Primary(closestPrimary) ;
707 if(primary->GetPdgCode() == 22){
708 hAllPosition->Fill(primary->Energy(), minDistance) ;
709 hAllPositionX->Fill(primary->Energy(), dX) ;
710 hAllPositionZ->Fill(primary->Energy(), dZ) ;
711 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
712 hPhotPosition->Fill(primary->Energy(), minDistance ) ;
713 hEMPosition->Fill(primary->Energy(), minDistance ) ;
716 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)
717 hEMPosition->Fill(primary->Energy(), minDistance ) ;
723 //Write output histgrams
725 hAllPosition->Write(0,kOverwrite) ;
726 hAllPositionX->Write(0,kOverwrite) ;
727 hAllPositionZ->Write(0,kOverwrite) ;
728 hPhotPosition->Write(0,kOverwrite) ;
729 hEMPosition->Write(0,kOverwrite) ;
736 //____________________________________________________________________________
737 void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){
738 // fills spectra of primary photons and several kinds of
739 // reconstructed particles, so that analyzing them one can
740 // estimate conatmination, efficiency of registration etc.
742 //define several general histograms
743 TH1F * hPrimary = 0; //spectrum (P_t distribution) of primary photons
744 TH1F * hAllRP = 0; //spectrum of all RecParticles in PHOS
745 TH1F * hPhot = 0; //spectrum of kGAMMA RecParticles
746 TH1F * hPPSD = 0; //spectrum of all RecParticles with PPSD signal
747 TH1F * hShape = 0; //spectrum of all EM RecParticles
748 TH1F * hVeto = 0; //spectrum of all neutral RecParticles
750 //Now separate histograms in accoradance with primary
752 TH1F * hPhotReg = 0; //Registeres as photon
753 TH1F * hPhotEM = 0; //Registered as EM
754 TH1F * hPhotPPSD= 0; //Registered as RecParticle with PPSD signal
757 TH1F * hNReg = 0; //Registeres as photon
758 TH1F * hNEM = 0; //Registered as EM
759 TH1F * hNPPSD= 0; //Registered as RecParticle with PPSD signal
762 TH1F * hNBarReg = 0; //Registeres as photon
763 TH1F * hNBarEM = 0; //Registered as EM
764 TH1F * hNBarPPSD= 0; //Registered as RecParticle with PPSD signal
766 //primary - charged hadron (pBar excluded)
767 TH1F * hChargedReg = 0; //Registeres as photon
768 TH1F * hChargedEM = 0; //Registered as EM
769 TH1F * hChargedPPSD= 0; //Registered as RecParticle with PPSD signal
772 TH1F * hPbarReg = 0; //Registeres as photon
773 TH1F * hPbarEM = 0; //Registered as EM
774 TH1F * hPbarPPSD= 0; //Registered as RecParticle with PPSD signal
777 //Reading histograms from the file
778 TFile * cfile = new TFile("contamination.root","update") ;
780 //read general histograms
781 hPrimary = (TH1F*) cfile->Get("hPrimary") ;
783 hPrimary= new TH1F("hPrimary", "Primary photon spectrum", 100, 0., 5.);
784 hAllRP = (TH1F*)cfile->Get("hAllRP") ;
786 hAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
787 hPhot = (TH1F*)cfile->Get("hPhot") ;
789 hPhot = new TH1F("hPhot","All kGAMMA RecParticles",100, 0., 5.);
790 hPPSD = (TH1F*)cfile->Get("hPPSD") ;
792 hPPSD = new TH1F("hPPSD", "All PPSD Recparticles", 100, 0., 5.);
793 hShape = (TH1F*) cfile->Get("hShape") ;
795 hShape = new TH1F("hShape","All particles with EM shower",100, 0., 5.);
796 hVeto= (TH1F*)cfile->Get("hVeto") ;
798 hVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
802 hPhotReg = (TH1F*)cfile->Get("hPhotReg");
804 hPhotReg = new TH1F("hPhotReg","Photon registered as photon",100, 0., 5.);
805 hPhotEM =(TH1F*)cfile->Get("hPhotEM");
807 hPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
808 hPhotPPSD= (TH1F*)cfile->Get("hPhotPPSD");
810 hPhotPPSD = new TH1F("hPhotPPSD","Photon registered as PPSD", 100, 0., 5.);
813 hNReg = (TH1F*)cfile->Get("hNReg");
815 hNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
816 hNEM = (TH1F*)cfile->Get("hNEM");
818 hNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
819 hNPPSD=(TH1F*)cfile->Get("hNPPSD");
821 hNPPSD = new TH1F("hNPPSD","N registered as PPSD", 100, 0., 5.);
824 hNBarReg =(TH1F*)cfile->Get("hNBarReg");
826 hNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
827 hNBarEM =(TH1F*)cfile->Get("hNBarEM");
829 hNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
830 hNBarPPSD=(TH1F*)cfile->Get("hNBarPPSD");
832 hNBarPPSD = new TH1F("hNBarPPSD","NBar registered as PPSD", 100, 0., 5.);
834 //primary - charged hadron (pBar excluded)
835 hChargedReg = (TH1F*)cfile->Get("hChargedReg");
837 hChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
838 hChargedEM = (TH1F*)cfile->Get("hChargedEM");
840 hChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
841 hChargedPPSD= (TH1F*)cfile->Get("hChargedPPSD");
843 hChargedPPSD= new TH1F("hChargedPPSD","Charged registered as PPSD",100, 0., 5.);
846 hPbarReg = (TH1F*)cfile->Get("hPbarReg");
848 hPbarReg= new TH1F("hPbarReg", "pBar registered as photon",100, 0., 5.);
849 hPbarEM = (TH1F*)cfile->Get("hPbarEM");
851 hPbarEM= new TH1F("hPbarEM","Pbar registered as EM",100, 0., 5.);
852 hPbarPPSD= (TH1F*)cfile->Get("hPbarPPSD");
854 hPbarPPSD= new TH1F("hPbarPPSD","Pbar as PPSD",100, 0., 5.);
857 //Now make some initializations
859 Int_t counter[8][5] ; //# of registered particles
861 for(i1 = 0; i1<8; i1++)
862 for(i2 = 0; i2<5; i2++)
863 counter[i1][i2] = 0 ;
867 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),RecPointsTitle) ;
868 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
871 Int_t maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
872 // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){
873 for ( ievent=0; ievent < maxevent ; ievent++){
875 gime->Event(ievent) ;
877 //=========== Make spectrum of the primary photons
878 const TParticle * primary ;
880 for( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++){
881 primary = gime->Primary(iPrimary) ;
882 Int_t primaryType = primary->GetPdgCode() ;
883 if( primaryType == 22 ) {
884 //check, if photons folls onto PHOS
886 Double_t primX, primZ ;
887 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
889 hPrimary->Fill(primary->Energy()) ;
894 //========== Now scan over RecParticles
895 const AliPHOSRecParticle * recParticle ;
897 for(iRecParticle = 0; iRecParticle < gime->NRecParticles(); iRecParticle++ ){
898 recParticle = gime->RecParticle(iRecParticle) ;
899 //fill histo spectrum of all RecParticles
900 hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ;
902 //==========find the closest primary
903 Int_t moduleNumberRec ;
904 Double_t recX, recZ ;
905 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
907 Double_t minDistance = 100. ;
908 Int_t closestPrimary = -1 ;
910 //extract list of primaries: it is stored at EMC RecPoints
911 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
912 Int_t numberofprimaries ;
913 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
915 const TParticle * primary ;
916 Double_t distance = minDistance ;
919 Double_t dZmin = 0. ;
920 for ( index = 0 ; index < numberofprimaries ; index++){
921 primary = gime->Primary(listofprimaries[index]) ;
923 Double_t primX, primZ ;
924 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
925 if(moduleNumberRec == moduleNumber) {
928 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
929 if(minDistance > distance) {
930 minDistance = distance ;
933 closestPrimary = listofprimaries[index] ;
938 //===========define the "type" of closest primary
939 if(closestPrimary >=0 ){
940 Int_t primaryCode = -1;
941 const TParticle * primary = gime->Primary(closestPrimary) ;
942 Int_t primaryType = primary->GetPdgCode() ;
943 if(primaryType == 22) // photon ?
946 if(primaryType == 2112) // neutron
949 if(primaryType == -2112) // Anti neutron
952 if(primaryType == -2122) //Anti proton
955 TParticle tempo(*primary) ;
956 if(tempo.GetPDG()->Charge())
960 //==========Now look at the type of RecParticle
961 Float_t energy = CorrectedEnergy(recParticle->Energy()) ;
962 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
963 hPhot->Fill(energy ) ;
966 hPhotReg->Fill(energy ) ;
969 hNReg->Fill(energy ) ;
972 hNBarReg->Fill(energy ) ;
975 hChargedReg->Fill(energy ) ;
978 hPbarReg->Fill(energy ) ;
984 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
985 (recParticle->GetType() == AliPHOSFastRecParticle::kGAMMAHA)){ //with PPSD signal
986 hPPSD->Fill(energy ) ;
989 hPhotPPSD->Fill(energy ) ;
992 hNPPSD->Fill(energy ) ;
995 hNBarPPSD->Fill(energy ) ;
998 hChargedPPSD->Fill(energy ) ;
1001 hPbarPPSD->Fill(energy ) ;
1007 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
1008 (recParticle->GetType() == AliPHOSFastRecParticle::kELECTRON)||
1009 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)||
1010 (recParticle->GetType() == AliPHOSFastRecParticle::kABSURDEM) ){ //with EM shower
1011 hShape->Fill(energy ) ;
1012 switch(primaryCode){
1014 hPhotEM->Fill(energy ) ;
1017 hNEM->Fill(energy ) ;
1020 hNBarEM->Fill(energy ) ;
1023 hChargedEM->Fill(energy ) ;
1026 hPbarEM->Fill(energy ) ;
1033 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
1034 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHA) ||
1035 (recParticle->GetType() == AliPHOSFastRecParticle::kGAMMAHA) ||
1036 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM) ) //nuetral
1037 hVeto->Fill(energy ) ;
1039 //fill number of primaries identified as ...
1040 if(primaryCode >= 0) // Primary code defined
1041 counter[recParticle->GetType()][primaryCode]++ ;
1045 } // no closest primary found
1049 //=================== SaveHistograms
1051 hPrimary->Write(0,kOverwrite);
1052 hAllRP->Write(0,kOverwrite);
1053 hPhot->Write(0,kOverwrite);
1054 hPPSD->Write(0,kOverwrite);
1055 hShape->Write(0,kOverwrite);
1056 hVeto->Write(0,kOverwrite);
1057 hPhotReg->Write(0,kOverwrite);
1058 hPhotEM->Write(0,kOverwrite);
1059 hPhotPPSD->Write(0,kOverwrite);
1060 hNReg ->Write(0,kOverwrite);
1061 hNEM ->Write(0,kOverwrite);
1062 hNPPSD->Write(0,kOverwrite);
1063 hNBarReg ->Write(0,kOverwrite);
1064 hNBarEM ->Write(0,kOverwrite);
1065 hNBarPPSD->Write(0,kOverwrite);
1066 hChargedReg ->Write(0,kOverwrite);
1067 hChargedEM ->Write(0,kOverwrite);
1068 hChargedPPSD->Write(0,kOverwrite);
1069 hPbarReg ->Write(0,kOverwrite);
1070 hPbarEM ->Write(0,kOverwrite);
1071 hPbarPPSD->Write(0,kOverwrite);
1073 cfile->Write(0,kOverwrite);
1079 maxevent = (Int_t)gAlice->TreeE()->GetEntries() ;
1080 // cout << "Resolutions: Analyzed " << gime->MaxEvent() << " event(s)" << endl ;
1082 cout << "Resolutions: Analyzed " << maxevent << " event(s)" << endl ;
1085 cout << " Primary: Photon Neutron Antineutron Charged hadron AntiProton" << endl ;
1086 cout << "--------------------------------------------------------------------------------" << endl ;
1088 << setw(8) << counter[2][0] << setw(9) << counter[2][1] << setw(13) << counter[2][2]
1089 << setw(15)<< counter[2][3] << setw(13) << counter[2][4] << endl ;
1090 cout << " kGAMMAHA: "
1091 << setw(8) << counter[3][0] << setw(9) << counter[3][1] << setw(13) << counter[3][2]
1092 << setw(15)<< counter[3][3] << setw(13) << counter[3][4] << endl ;
1093 cout << " kNEUTRALEM: "
1094 << setw(8) << counter[0][0] << setw(9) << counter[0][1] << setw(13) << counter[0][2]
1095 << setw(15)<< counter[0][3] << setw(13) << counter[0][4] << endl ;
1096 cout << " kNEUTRALHA: "
1097 << setw(8) << counter[1][0] << setw(9) << counter[1][1] << setw(13) << counter[1][2]
1098 << setw(15)<< counter[1][3] << setw(13) << counter[1][4] << endl ;
1099 cout << " kABSURDEM: "
1100 << setw(8) << counter[4][0] << setw(9) << counter[4][1] << setw(13) << counter[4][2]
1101 << setw(15)<< counter[4][3] << setw(13) << counter[4][4] << endl ;
1102 cout << " kABSURDHA: "
1103 << setw(8) << counter[5][0] << setw(9) << counter[5][1] << setw(13) << counter[5][2]
1104 << setw(15)<< counter[5][3] << setw(13) << counter[5][4] << endl ;
1105 cout << " kELECTRON: "
1106 << setw(8) << counter[6][0] << setw(9) << counter[6][1] << setw(13) << counter[6][2]
1107 << setw(15)<< counter[6][3] << setw(13) << counter[6][4] << endl ;
1108 cout << " kCHARGEDHA: "
1109 << setw(8) << counter[7][0] << setw(9) << counter[7][1] << setw(13) << counter[7][2]
1110 << setw(15)<< counter[7][3] << setw(13) << counter[7][4] << endl ;
1111 cout << "--------------------------------------------------------------------------------" << endl ;
1113 Int_t totalInd = 0 ;
1114 for(i1 = 0; i1<8; i1++)
1115 for(i2 = 0; i2<5; i2++)
1116 totalInd+=counter[i1][i2] ;
1117 cout << "Indentified particles: " << totalInd << endl ;