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 "AliPHOSIndexToObject.h"
92 #include "AliPHOSCpvRecPoint.h"
93 #include "AliPHOSPpsdRecPoint.h"
94 #include "AliPHOSGetter.h"
97 ClassImp(AliPHOSAnalyze)
99 //____________________________________________________________________________
100 AliPHOSAnalyze::AliPHOSAnalyze()
102 // default ctor (useless)
103 fCorrection = 1.2 ; //Value calculated for default parameters of reconstruction
106 //____________________________________________________________________________
107 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * fileName)
109 // ctor: analyze events from root file "name"
110 ffileName = fileName ;
111 fCorrection = 1.05 ; //Value calculated for default parameters of reconstruction
114 //____________________________________________________________________________
115 AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana)
118 ( (AliPHOSAnalyze &)ana ).Copy(*this) ;
121 //____________________________________________________________________________
122 AliPHOSAnalyze::~AliPHOSAnalyze()
127 //____________________________________________________________________________
128 void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,const char* branchTitle){
129 //Draws pimary particles and reconstructed
130 //digits, RecPoints, RecPartices etc
131 //for event Nevent in the module Nmod.
133 TH2F * digitOccupancy = new TH2F("digitOccupancy","EMC digits", 64,-71.,71.,64,-71.,71.);
134 TH2F * sdigitOccupancy = new TH2F("sdigitOccupancy","EMC sdigits", 64,-71.,71.,64,-71.,71.);
135 TH2F * emcOccupancy = new TH2F("emcOccupancy","EMC RecPoints",64,-71.,71.,64,-71.,71.);
136 TH2F * ppsdUp = new TH2F("ppsdUp","PPSD Up digits", 128,-71.,71.,128,-71.,71.) ;
137 TH2F * ppsdUpCl = new TH2F("ppsdUpCl","PPSD Up RecPoints",128,-71.,71.,128,-71.,71.) ;
138 TH2F * ppsdLow = new TH2F("ppsdLow","PPSD Low digits", 128,-71.,71.,128,-71.,71.) ;
139 TH2F * ppsdLowCl = new TH2F("ppsdLowCl","PPSD Low RecPoints",128,-71.,71.,128,-71.,71.) ;
140 TH2F * nbar = new TH2F("nbar","Primary nbar", 64,-71.,71.,64,-71.,71.);
141 TH2F * phot = new TH2F("phot","Primary Photon", 64,-71.,71.,64,-71.,71.);
142 TH2F * charg = new TH2F("charg","Primary charged",64,-71.,71.,64,-71.,71.);
143 TH2F * recPhot = new TH2F("recPhot","RecParticles with primary Photon",64,-71.,71.,64,-71.,71.);
144 TH2F * recNbar = new TH2F("recNbar","RecParticles with primary Nbar", 64,-71.,71.,64,-71.,71.);
146 //========== Create ObjectGetter
147 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
148 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
151 //Plot Primary Particles
152 const TParticle * primary ;
154 for ( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++)
156 primary = gime->Primary(iPrimary) ;
157 Int_t primaryType = primary->GetPdgCode() ;
158 if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212) ) {
160 Double_t primX, primZ ;
161 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
162 if(moduleNumber==Nmod)
163 charg->Fill(primZ,primX,primary->Energy()) ;
165 if( primaryType == 22 ) {
167 Double_t primX, primZ ;
168 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
169 if(moduleNumber==Nmod)
170 phot->Fill(primZ,primX,primary->Energy()) ;
173 if( primaryType == -2112 ) {
175 Double_t primX, primZ ;
176 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
177 if(moduleNumber==Nmod)
178 nbar->Fill(primZ,primX,primary->Energy()) ;
184 const AliPHOSDigit * sdigit ;
186 for(iSDigit = 0; iSDigit < gime->NSDigits(); iSDigit++)
188 sdigit = gime->SDigit(iSDigit) ;
190 phosgeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
192 phosgeom->RelPosInModule(relid,x,z) ;
193 Float_t e = gime->SDigitizer()->Calibrate(sdigit->GetAmp()) ;
195 if(relid[1]==0) //EMC
196 sdigitOccupancy->Fill(x,z,e) ;
197 if((relid[1]>0)&&(relid[1]<17))
198 ppsdUp->Fill(x,z,e) ;
200 ppsdLow->Fill(x,z,e) ;
206 const AliPHOSDigit * digit ;
207 for(iDigit = 0; iDigit < gime->NDigits(); iDigit++)
209 digit = gime->Digit(iDigit) ;
211 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
213 phosgeom->RelPosInModule(relid,x,z) ;
214 Float_t e = gime->SDigitizer()->Calibrate(digit->GetAmp()) ;
216 if(relid[1]==0) //EMC
217 digitOccupancy->Fill(x,z,e) ;
218 if((relid[1]>0)&&(relid[1]<17))
219 ppsdUp->Fill(x,z,e) ;
221 ppsdLow->Fill(x,z,e) ;
230 for(irecp = 0; irecp < gime->NEmcRecPoints() ; irecp ++){
231 const AliPHOSEmcRecPoint * emc= gime->EmcRecPoint(irecp) ;
232 if(emc->GetPHOSMod()==Nmod){
233 emc->GetLocalPosition(pos) ;
234 emcOccupancy->Fill(pos.X(),pos.Z(),emc->GetEnergy());
239 for(irecp = 0; irecp < gime->NCpvRecPoints() ; irecp ++){
240 const AliPHOSRecPoint * cpv = gime->CpvRecPoint(irecp) ;
241 if((strcmp(cpv->ClassName(),"AliPHOSPpsdRecPoint" )) == 0){ // PPSD Rec Point
242 AliPHOSPpsdRecPoint * ppsd = (AliPHOSPpsdRecPoint*) cpv ;
243 ppsd->GetLocalPosition(pos) ;
244 if(ppsd->GetPHOSMod()==Nmod){
245 ppsd->GetLocalPosition(pos) ;
247 ppsdUpCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
249 ppsdLowCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
253 AliPHOSCpvRecPoint * cpv1 = (AliPHOSCpvRecPoint*) cpv ;
254 if(cpv1->GetPHOSMod()==Nmod){
255 cpv1->GetLocalPosition(pos) ;
256 ppsdUpCl->Fill(pos.X(),pos.Z(),cpv1->GetEnergy());
263 const AliPHOSRecParticle * recParticle ;
265 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ )
267 recParticle = gime->RecParticle(iRecParticle) ;
268 Int_t moduleNumberRec ;
269 Double_t recX, recZ ;
270 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
271 if(moduleNumberRec == Nmod){
273 Double_t minDistance = 5. ;
274 Int_t closestPrimary = -1 ;
277 //extract list of primaries: it is stored at EMC RecPoints
278 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
279 Int_t numberofprimaries ;
280 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
282 const TParticle * primary ;
283 Double_t distance = minDistance ;
285 for ( index = 0 ; index < numberofprimaries ; index++){
286 primary = gime->Primary(listofprimaries[index]) ;
288 Double_t primX, primZ ;
289 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
290 if(moduleNumberRec == moduleNumber)
291 distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ;
292 if(minDistance > distance)
294 minDistance = distance ;
295 closestPrimary = listofprimaries[index] ;
299 if(closestPrimary >=0 ){
301 Int_t primaryType = gime->Primary(closestPrimary)->GetPdgCode() ;
304 recPhot->Fill(recZ,recX,recParticle->Energy()) ;
306 if(primaryType==-2112)
307 recNbar->Fill(recZ,recX,recParticle->Energy()) ;
313 //Plot made histograms
314 digitOccupancy->Draw("box") ;
315 sdigitOccupancy->SetLineColor(5) ;
316 sdigitOccupancy->Draw("box") ;
317 emcOccupancy->SetLineColor(2) ;
318 emcOccupancy->Draw("boxsame") ;
319 ppsdUp->SetLineColor(3) ;
320 ppsdUp->Draw("boxsame") ;
321 ppsdLow->SetLineColor(4) ;
322 ppsdLow->Draw("boxsame") ;
323 phot->SetLineColor(8) ;
324 phot->Draw("boxsame") ;
325 nbar->SetLineColor(6) ;
326 nbar->Draw("boxsame") ;
329 //____________________________________________________________________________
330 void AliPHOSAnalyze::Ls(){
331 //lists branches and titles of PHOS-related branches of TreeR, TreeD, TreeS
333 AliPHOSGetter::GetInstance(ffileName.Data()) ;
336 TObjArray * branches;
338 branches = gAlice->TreeS()->GetListOfBranches() ;
340 cout << "TreeS: " << endl ;
341 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
342 TBranch * branch=(TBranch *) branches->At(ibranch) ;
343 if(strstr(branch->GetName(),"PHOS") )
344 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
348 branches = gAlice->TreeD()->GetListOfBranches() ;
350 cout << "TreeD: " << endl ;
351 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
352 TBranch * branch=(TBranch *) branches->At(ibranch) ;
353 if(strstr(branch->GetName(),"PHOS") )
354 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
359 branches = gAlice->TreeR()->GetListOfBranches() ;
361 cout << "TreeR: " << endl ;
362 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
363 TBranch * branch=(TBranch *) branches->At(ibranch) ;
364 if(strstr(branch->GetName(),"PHOS") )
365 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
371 //____________________________________________________________________________
372 void AliPHOSAnalyze::InvariantMass(const char* branchTitle)
374 // Calculates Real and Mixed invariant mass distributions
375 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
377 Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
380 TFile * mfile = new TFile("invmass.root","update");
382 //========== Reading /Booking Histograms
384 hRealEM = (TH2D*) mfile->Get("hRealEM") ;
386 hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
387 TH2D * hRealPhot = 0 ;
389 hRealPhot = (TH2D*)mfile->Get("hRealPhot");
391 hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
393 TH2D * hMixedEM = 0 ;
394 hMixedEM = (TH2D*) mfile->Get("hMixedEM") ;
396 hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
398 TH2D * hMixedPhot = 0 ;
399 hMixedPhot = (TH2D*) mfile->Get("hMixedPhot") ;
401 hMixedPhot = new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
404 //reading event and copyng it to TConesArray of all photons
406 TClonesArray * allRecParticleList = new TClonesArray("AliPHOSRecParticle", 1000) ;
407 Int_t * nRecParticles = new Int_t[nMixedEvents] ; // to mark boundaries of each event in the total list
408 for(Int_t index = 0; index < nMixedEvents; index ++)
409 nRecParticles[index] = 0 ;
410 Int_t iRecPhot = 0 ; // number of EM particles in total list
412 //scan over all events
414 Int_t maxevent = gAlice->TreeE()->GetEntries() ;
415 // for(event = 0; event < gime->MaxEvent(); event++ ){
416 for(event = 0; event < maxevent; event++ ){
419 //copy EM RecParticles to the "total" list
420 const AliPHOSRecParticle * recParticle ;
422 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ )
424 recParticle = gime->RecParticle(iRecParticle) ;
425 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
426 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM))
427 new( (*allRecParticleList)[iRecPhot++] ) AliPHOSRecParticle(*recParticle) ;
430 Int_t mevent = event%nMixedEvents ; //event number in the "mixed" cicle
431 nRecParticles[mevent] = iRecPhot-1 ;
433 //check, if it is time to calculate invariant mass?
434 Int_t maxevent = gAlice->TreeE()->GetEntries() ;
435 if((mevent == 0) && (event +1 == maxevent)){
437 // if((mevent == 0) && (event +1 == gime->MaxEvent())){
439 //calculate invariant mass:
441 Int_t nCurEvent = 0 ;
443 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
444 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
446 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
447 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
450 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
451 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
452 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
453 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
456 invMass = TMath::Sqrt(invMass);
459 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +
460 (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) );
462 if(irp1 > nRecParticles[nCurEvent])
465 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
466 hRealEM->Fill(invMass,pt);
467 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&
468 (rp2->GetType() == AliPHOSFastRecParticle::kGAMMA) )
469 hRealPhot->Fill(invMass,pt);
472 hMixedEM->Fill(invMass,pt);
473 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&
474 (rp2->GetType() == AliPHOSFastRecParticle::kGAMMA) )
475 hMixedPhot->Fill(invMass,pt);
478 } //loop over second rp
479 }//loop over first rp
481 //Make some cleanings
482 for(Int_t index = 0; index < nMixedEvents; index ++)
483 nRecParticles[index] = 0 ;
485 allRecParticleList->Clear() ;
489 delete allRecParticleList ;
494 hRealEM->Write(0,kOverwrite) ;
495 hRealPhot->Write(0,kOverwrite) ;
496 hMixedEM->Write(0,kOverwrite) ;
497 hMixedPhot->Write(0,kOverwrite) ;
502 delete nRecParticles;
506 //____________________________________________________________________________
507 void AliPHOSAnalyze::EnergyResolution(const char * branchTitle)
509 //fills two dimentional histo: energy of primary vs. energy of reconstructed
511 TH2F * hAllEnergy = 0 ; //all reconstructed with primary photon
512 TH2F * hPhotEnergy= 0 ; //kGamma with primary photon
513 TH2F * hEMEnergy = 0 ; //electromagnetic with primary photon
515 //opening file and reading histograms if any
516 TFile * efile = new TFile("energy.root","update");
518 hAllEnergy = (TH2F*)efile->Get("hAllEnergy") ;
520 hAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
522 hPhotEnergy =(TH2F*) efile->Get("hPhotEnergy") ;
524 hPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
526 hEMEnergy =(TH2F*) efile->Get("hEMEnergy");
528 hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
531 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
532 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
535 Int_t maxevent = gAlice->TreeE()->GetEntries() ;
536 // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){
537 for ( ievent=0; ievent < maxevent ; ievent++){
539 //read the current event
540 gime->Event(ievent) ;
542 const AliPHOSRecParticle * recParticle ;
544 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ){
545 recParticle = gime->RecParticle(iRecParticle) ;
547 //find the closest primary
548 Int_t moduleNumberRec ;
549 Double_t recX, recZ ;
550 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
552 Double_t minDistance = 100. ;
553 Int_t closestPrimary = -1 ;
555 //extract list of primaries: it is stored at EMC RecPoints
556 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
557 Int_t numberofprimaries ;
558 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
561 const TParticle * primary ;
562 Double_t distance = minDistance ;
565 Double_t dZmin = 0. ;
566 for ( index = 0 ; index < numberofprimaries ; index++){
567 primary = gime->Primary(listofprimaries[index]) ;
569 Double_t primX, primZ ;
570 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
571 if(moduleNumberRec == moduleNumber) {
574 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
575 if(minDistance > distance) {
576 minDistance = distance ;
579 closestPrimary = listofprimaries[index] ;
584 //if found primary, fill histograms
585 if(closestPrimary >=0 ){
586 const TParticle * primary = gime->Primary(closestPrimary) ;
587 if(primary->GetPdgCode() == 22){
588 hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ;
589 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
590 hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
591 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
594 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)
595 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
601 //write filled histograms
603 hAllEnergy->Write(0,kOverwrite) ;
604 hPhotEnergy->Write(0,kOverwrite) ;
605 hEMEnergy->Write(0,kOverwrite) ;
611 //____________________________________________________________________________
612 void AliPHOSAnalyze::PositionResolution(const char * branchTitle)
614 //fills two dimentional histo: energy vs. primary - reconstructed distance
618 TH2F * hAllPosition = 0; // Position of any RP with primary photon
619 TH2F * hPhotPosition = 0; // Position of kGAMMA with primary photon
620 TH2F * hEMPosition = 0; // Position of EM with primary photon
622 TH1F * hAllPositionX = 0; // X-Position Resolution of photons with photon primary
623 TH1F * hAllPositionZ = 0; // Z-Position Resolution of photons with photon primary
626 //opening file and reading histograms if any
627 TFile * pfile = new TFile("position.root","update");
629 hAllPosition = (TH2F*)pfile->Get("hAllPosition");
630 if(hAllPosition == 0)
631 hAllPosition = new TH2F("hAllPosition",
632 "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
633 hPhotPosition= (TH2F*)pfile->Get("hPhotPosition");
634 if(hPhotPosition == 0)
635 hPhotPosition = new TH2F("hPhotPosition",
636 "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
637 hEMPosition= (TH2F*)pfile->Get("hEMPosition") ;
639 hEMPosition = new TH2F("hEMPosition",
640 "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
641 hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ;
642 if(hAllPositionX == 0)
643 hAllPositionX = new TH1F("hAllPositionX",
644 "Delta X of any RP with primary photon",100, -2., 2.);
645 hAllPositionZ =(TH1F*) pfile->Get("hAllPositionZ") ;
646 if(hAllPositionZ == 0)
647 hAllPositionZ = new TH1F("hAllPositionZ",
648 "Delta X of any RP with primary photon",100, -2., 2.);
651 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),branchTitle) ;
652 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
655 Int_t maxevent = gAlice->TreeE()->GetEntries() ;
656 // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){
657 for ( ievent=0; ievent < maxevent ; ievent++){
660 //read the current event
661 gime->Event(ievent) ;
663 const AliPHOSRecParticle * recParticle ;
665 for(iRecParticle = 0; iRecParticle < gime->NRecParticles() ;iRecParticle++ ){
666 recParticle = gime->RecParticle(iRecParticle) ;
668 //find the closest primary
669 Int_t moduleNumberRec ;
670 Double_t recX, recZ ;
671 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
673 Double_t minDistance = 100. ;
674 Int_t closestPrimary = -1 ;
676 //extract list of primaries: it is stored at EMC RecPoints
677 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
678 Int_t numberofprimaries ;
679 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
682 const TParticle * primary ;
683 Double_t distance = minDistance ;
684 Double_t dX = 1000; // incredible number
685 Double_t dZ = 1000; // for the case if no primary will be found
687 Double_t dZmin = 0. ;
688 for ( index = 0 ; index < numberofprimaries ; index++){
689 primary = gime->Primary(listofprimaries[index]) ;
691 Double_t primX, primZ ;
692 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
693 if(moduleNumberRec == moduleNumber) {
696 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
697 if(minDistance > distance) {
698 minDistance = distance ;
701 closestPrimary = listofprimaries[index] ;
706 //if found primary, fill histograms
707 if(closestPrimary >=0 ){
708 const TParticle * primary = gime->Primary(closestPrimary) ;
709 if(primary->GetPdgCode() == 22){
710 hAllPosition->Fill(primary->Energy(), minDistance) ;
711 hAllPositionX->Fill(primary->Energy(), dX) ;
712 hAllPositionZ->Fill(primary->Energy(), dZ) ;
713 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
714 hPhotPosition->Fill(primary->Energy(), minDistance ) ;
715 hEMPosition->Fill(primary->Energy(), minDistance ) ;
718 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)
719 hEMPosition->Fill(primary->Energy(), minDistance ) ;
725 //Write output histgrams
727 hAllPosition->Write(0,kOverwrite) ;
728 hAllPositionX->Write(0,kOverwrite) ;
729 hAllPositionZ->Write(0,kOverwrite) ;
730 hPhotPosition->Write(0,kOverwrite) ;
731 hEMPosition->Write(0,kOverwrite) ;
738 //____________________________________________________________________________
739 void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){
740 // fills spectra of primary photons and several kinds of
741 // reconstructed particles, so that analyzing them one can
742 // estimate conatmination, efficiency of registration etc.
744 //define several general histograms
745 TH1F * hPrimary = 0; //spectrum (P_t distribution) of primary photons
746 TH1F * hAllRP = 0; //spectrum of all RecParticles in PHOS
747 TH1F * hPhot = 0; //spectrum of kGAMMA RecParticles
748 TH1F * hPPSD = 0; //spectrum of all RecParticles with PPSD signal
749 TH1F * hShape = 0; //spectrum of all EM RecParticles
750 TH1F * hVeto = 0; //spectrum of all neutral RecParticles
752 //Now separate histograms in accoradance with primary
754 TH1F * hPhotReg = 0; //Registeres as photon
755 TH1F * hPhotEM = 0; //Registered as EM
756 TH1F * hPhotPPSD= 0; //Registered as RecParticle with PPSD signal
759 TH1F * hNReg = 0; //Registeres as photon
760 TH1F * hNEM = 0; //Registered as EM
761 TH1F * hNPPSD= 0; //Registered as RecParticle with PPSD signal
764 TH1F * hNBarReg = 0; //Registeres as photon
765 TH1F * hNBarEM = 0; //Registered as EM
766 TH1F * hNBarPPSD= 0; //Registered as RecParticle with PPSD signal
768 //primary - charged hadron (pBar excluded)
769 TH1F * hChargedReg = 0; //Registeres as photon
770 TH1F * hChargedEM = 0; //Registered as EM
771 TH1F * hChargedPPSD= 0; //Registered as RecParticle with PPSD signal
774 TH1F * hPbarReg = 0; //Registeres as photon
775 TH1F * hPbarEM = 0; //Registered as EM
776 TH1F * hPbarPPSD= 0; //Registered as RecParticle with PPSD signal
779 //Reading histograms from the file
780 TFile * cfile = new TFile("contamination.root","update") ;
782 //read general histograms
783 hPrimary = (TH1F*) cfile->Get("hPrimary") ;
785 hPrimary= new TH1F("hPrimary", "Primary photon spectrum", 100, 0., 5.);
786 hAllRP = (TH1F*)cfile->Get("hAllRP") ;
788 hAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
789 hPhot = (TH1F*)cfile->Get("hPhot") ;
791 hPhot = new TH1F("hPhot","All kGAMMA RecParticles",100, 0., 5.);
792 hPPSD = (TH1F*)cfile->Get("hPPSD") ;
794 hPPSD = new TH1F("hPPSD", "All PPSD Recparticles", 100, 0., 5.);
795 hShape = (TH1F*) cfile->Get("hShape") ;
797 hShape = new TH1F("hShape","All particles with EM shower",100, 0., 5.);
798 hVeto= (TH1F*)cfile->Get("hVeto") ;
800 hVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
804 hPhotReg = (TH1F*)cfile->Get("hPhotReg");
806 hPhotReg = new TH1F("hPhotReg","Photon registered as photon",100, 0., 5.);
807 hPhotEM =(TH1F*)cfile->Get("hPhotEM");
809 hPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
810 hPhotPPSD= (TH1F*)cfile->Get("hPhotPPSD");
812 hPhotPPSD = new TH1F("hPhotPPSD","Photon registered as PPSD", 100, 0., 5.);
815 hNReg = (TH1F*)cfile->Get("hNReg");
817 hNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
818 hNEM = (TH1F*)cfile->Get("hNEM");
820 hNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
821 hNPPSD=(TH1F*)cfile->Get("hNPPSD");
823 hNPPSD = new TH1F("hNPPSD","N registered as PPSD", 100, 0., 5.);
826 hNBarReg =(TH1F*)cfile->Get("hNBarReg");
828 hNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
829 hNBarEM =(TH1F*)cfile->Get("hNBarEM");
831 hNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
832 hNBarPPSD=(TH1F*)cfile->Get("hNBarPPSD");
834 hNBarPPSD = new TH1F("hNBarPPSD","NBar registered as PPSD", 100, 0., 5.);
836 //primary - charged hadron (pBar excluded)
837 hChargedReg = (TH1F*)cfile->Get("hChargedReg");
839 hChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
840 hChargedEM = (TH1F*)cfile->Get("hChargedEM");
842 hChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
843 hChargedPPSD= (TH1F*)cfile->Get("hChargedPPSD");
845 hChargedPPSD= new TH1F("hChargedPPSD","Charged registered as PPSD",100, 0., 5.);
848 hPbarReg = (TH1F*)cfile->Get("hPbarReg");
850 hPbarReg= new TH1F("hPbarReg", "pBar registered as photon",100, 0., 5.);
851 hPbarEM = (TH1F*)cfile->Get("hPbarEM");
853 hPbarEM= new TH1F("hPbarEM","Pbar registered as EM",100, 0., 5.);
854 hPbarPPSD= (TH1F*)cfile->Get("hPbarPPSD");
856 hPbarPPSD= new TH1F("hPbarPPSD","Pbar as PPSD",100, 0., 5.);
859 //Now make some initializations
861 Int_t counter[8][5] ; //# of registered particles
863 for(i1 = 0; i1<8; i1++)
864 for(i2 = 0; i2<5; i2++)
865 counter[i1][i2] = 0 ;
869 AliPHOSGetter * gime = AliPHOSGetter::GetInstance(ffileName.Data(),RecPointsTitle) ;
870 const AliPHOSGeometry * phosgeom = gime->PHOSGeometry() ;
873 Int_t maxevent = gAlice->TreeE()->GetEntries() ;
874 // for ( ievent=0; ievent < gime->MaxEvent() ; ievent++){
875 for ( ievent=0; ievent < maxevent ; ievent++){
877 gime->Event(ievent) ;
879 //=========== Make spectrum of the primary photons
880 const TParticle * primary ;
882 for( iPrimary = 0 ; iPrimary < gime->NPrimaries() ; iPrimary++){
883 primary = gime->Primary(iPrimary) ;
884 Int_t primaryType = primary->GetPdgCode() ;
885 if( primaryType == 22 ) {
886 //check, if photons folls onto PHOS
888 Double_t primX, primZ ;
889 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
891 hPrimary->Fill(primary->Energy()) ;
896 //========== Now scan over RecParticles
897 const AliPHOSRecParticle * recParticle ;
899 for(iRecParticle = 0; iRecParticle < gime->NRecParticles(); iRecParticle++ ){
900 recParticle = gime->RecParticle(iRecParticle) ;
901 //fill histo spectrum of all RecParticles
902 hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ;
904 //==========find the closest primary
905 Int_t moduleNumberRec ;
906 Double_t recX, recZ ;
907 phosgeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
909 Double_t minDistance = 100. ;
910 Int_t closestPrimary = -1 ;
912 //extract list of primaries: it is stored at EMC RecPoints
913 Int_t emcIndex = gime->TrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
914 Int_t numberofprimaries ;
915 Int_t * listofprimaries = gime->EmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
917 const TParticle * primary ;
918 Double_t distance = minDistance ;
921 Double_t dZmin = 0. ;
922 for ( index = 0 ; index < numberofprimaries ; index++){
923 primary = gime->Primary(listofprimaries[index]) ;
925 Double_t primX, primZ ;
926 phosgeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
927 if(moduleNumberRec == moduleNumber) {
930 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
931 if(minDistance > distance) {
932 minDistance = distance ;
935 closestPrimary = listofprimaries[index] ;
940 //===========define the "type" of closest primary
941 if(closestPrimary >=0 ){
942 Int_t primaryCode = -1;
943 const TParticle * primary = gime->Primary(closestPrimary) ;
944 Int_t primaryType = primary->GetPdgCode() ;
945 if(primaryType == 22) // photon ?
948 if(primaryType == 2112) // neutron
951 if(primaryType == -2112) // Anti neutron
954 if(primaryType == -2122) //Anti proton
957 TParticle tempo(*primary) ;
958 if(tempo.GetPDG()->Charge())
962 //==========Now look at the type of RecParticle
963 Float_t energy = CorrectedEnergy(recParticle->Energy()) ;
964 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
965 hPhot->Fill(energy ) ;
968 hPhotReg->Fill(energy ) ;
971 hNReg->Fill(energy ) ;
974 hNBarReg->Fill(energy ) ;
977 hChargedReg->Fill(energy ) ;
980 hPbarReg->Fill(energy ) ;
986 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
987 (recParticle->GetType() == AliPHOSFastRecParticle::kGAMMAHA)){ //with PPSD signal
988 hPPSD->Fill(energy ) ;
991 hPhotPPSD->Fill(energy ) ;
994 hNPPSD->Fill(energy ) ;
997 hNBarPPSD->Fill(energy ) ;
1000 hChargedPPSD->Fill(energy ) ;
1003 hPbarPPSD->Fill(energy ) ;
1009 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
1010 (recParticle->GetType() == AliPHOSFastRecParticle::kELECTRON)||
1011 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)||
1012 (recParticle->GetType() == AliPHOSFastRecParticle::kABSURDEM) ){ //with EM shower
1013 hShape->Fill(energy ) ;
1014 switch(primaryCode){
1016 hPhotEM->Fill(energy ) ;
1019 hNEM->Fill(energy ) ;
1022 hNBarEM->Fill(energy ) ;
1025 hChargedEM->Fill(energy ) ;
1028 hPbarEM->Fill(energy ) ;
1035 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
1036 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHA) ||
1037 (recParticle->GetType() == AliPHOSFastRecParticle::kGAMMAHA) ||
1038 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM) ) //nuetral
1039 hVeto->Fill(energy ) ;
1041 //fill number of primaries identified as ...
1042 if(primaryCode >= 0) // Primary code defined
1043 counter[recParticle->GetType()][primaryCode]++ ;
1047 } // no closest primary found
1051 //=================== SaveHistograms
1053 hPrimary->Write(0,kOverwrite);
1054 hAllRP->Write(0,kOverwrite);
1055 hPhot->Write(0,kOverwrite);
1056 hPPSD->Write(0,kOverwrite);
1057 hShape->Write(0,kOverwrite);
1058 hVeto->Write(0,kOverwrite);
1059 hPhotReg->Write(0,kOverwrite);
1060 hPhotEM->Write(0,kOverwrite);
1061 hPhotPPSD->Write(0,kOverwrite);
1062 hNReg ->Write(0,kOverwrite);
1063 hNEM ->Write(0,kOverwrite);
1064 hNPPSD->Write(0,kOverwrite);
1065 hNBarReg ->Write(0,kOverwrite);
1066 hNBarEM ->Write(0,kOverwrite);
1067 hNBarPPSD->Write(0,kOverwrite);
1068 hChargedReg ->Write(0,kOverwrite);
1069 hChargedEM ->Write(0,kOverwrite);
1070 hChargedPPSD->Write(0,kOverwrite);
1071 hPbarReg ->Write(0,kOverwrite);
1072 hPbarEM ->Write(0,kOverwrite);
1073 hPbarPPSD->Write(0,kOverwrite);
1075 cfile->Write(0,kOverwrite);
1081 maxevent = gAlice->TreeE()->GetEntries() ;
1082 // cout << "Resolutions: Analyzed " << gime->MaxEvent() << " event(s)" << endl ;
1084 cout << "Resolutions: Analyzed " << maxevent << " event(s)" << endl ;
1087 cout << " Primary: Photon Neutron Antineutron Charged hadron AntiProton" << endl ;
1088 cout << "--------------------------------------------------------------------------------" << endl ;
1090 << setw(8) << counter[2][0] << setw(9) << counter[2][1] << setw(13) << counter[2][2]
1091 << setw(15)<< counter[2][3] << setw(13) << counter[2][4] << endl ;
1092 cout << " kGAMMAHA: "
1093 << setw(8) << counter[3][0] << setw(9) << counter[3][1] << setw(13) << counter[3][2]
1094 << setw(15)<< counter[3][3] << setw(13) << counter[3][4] << endl ;
1095 cout << " kNEUTRALEM: "
1096 << setw(8) << counter[0][0] << setw(9) << counter[0][1] << setw(13) << counter[0][2]
1097 << setw(15)<< counter[0][3] << setw(13) << counter[0][4] << endl ;
1098 cout << " kNEUTRALHA: "
1099 << setw(8) << counter[1][0] << setw(9) << counter[1][1] << setw(13) << counter[1][2]
1100 << setw(15)<< counter[1][3] << setw(13) << counter[1][4] << endl ;
1101 cout << " kABSURDEM: "
1102 << setw(8) << counter[4][0] << setw(9) << counter[4][1] << setw(13) << counter[4][2]
1103 << setw(15)<< counter[4][3] << setw(13) << counter[4][4] << endl ;
1104 cout << " kABSURDHA: "
1105 << setw(8) << counter[5][0] << setw(9) << counter[5][1] << setw(13) << counter[5][2]
1106 << setw(15)<< counter[5][3] << setw(13) << counter[5][4] << endl ;
1107 cout << " kELECTRON: "
1108 << setw(8) << counter[6][0] << setw(9) << counter[6][1] << setw(13) << counter[6][2]
1109 << setw(15)<< counter[6][3] << setw(13) << counter[6][4] << endl ;
1110 cout << " kCHARGEDHA: "
1111 << setw(8) << counter[7][0] << setw(9) << counter[7][1] << setw(13) << counter[7][2]
1112 << setw(15)<< counter[7][3] << setw(13) << counter[7][4] << endl ;
1113 cout << "--------------------------------------------------------------------------------" << endl ;
1115 Int_t totalInd = 0 ;
1116 for(i1 = 0; i1<8; i1++)
1117 for(i2 = 0; i2<5; i2++)
1118 totalInd+=counter[i1][i2] ;
1119 cout << "Indentified particles: " << totalInd << endl ;