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"
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
111 fObjGetter = 0 ; // should be instantiated
115 //____________________________________________________________________________
116 AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana)
119 ( (AliPHOSAnalyze &)ana ).Copy(*this) ;
122 //____________________________________________________________________________
123 AliPHOSAnalyze::~AliPHOSAnalyze()
128 //____________________________________________________________________________
129 void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod,const char * branchName,const char* branchTitle){
130 //Draws pimary particles and reconstructed
131 //digits, RecPoints, RecPartices etc
132 //for event Nevent in the module Nmod.
134 TH2F * digitOccupancy = new TH2F("digitOccupancy","EMC digits", 64,-71.,71.,64,-71.,71.);
135 TH2F * sdigitOccupancy = new TH2F("sdigitOccupancy","EMC sdigits", 64,-71.,71.,64,-71.,71.);
136 TH2F * emcOccupancy = new TH2F("emcOccupancy","EMC RecPoints",64,-71.,71.,64,-71.,71.);
137 TH2F * ppsdUp = new TH2F("ppsdUp","PPSD Up digits", 128,-71.,71.,128,-71.,71.) ;
138 TH2F * ppsdUpCl = new TH2F("ppsdUpCl","PPSD Up RecPoints",128,-71.,71.,128,-71.,71.) ;
139 TH2F * ppsdLow = new TH2F("ppsdLow","PPSD Low digits", 128,-71.,71.,128,-71.,71.) ;
140 TH2F * ppsdLowCl = new TH2F("ppsdLowCl","PPSD Low RecPoints",128,-71.,71.,128,-71.,71.) ;
141 TH2F * nbar = new TH2F("nbar","Primary nbar", 64,-71.,71.,64,-71.,71.);
142 TH2F * phot = new TH2F("phot","Primary Photon", 64,-71.,71.,64,-71.,71.);
143 TH2F * charg = new TH2F("charg","Primary charged",64,-71.,71.,64,-71.,71.);
144 TH2F * recPhot = new TH2F("recPhot","RecParticles with primary Photon",64,-71.,71.,64,-71.,71.);
145 TH2F * recNbar = new TH2F("recNbar","RecParticles with primary Nbar", 64,-71.,71.,64,-71.,71.);
147 //========== Create IndexToObjectGetter
148 fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),branchName,branchTitle) ;
149 fObjGetter->GetEvent(Nevent);
151 //Plot Primary Particles
152 TParticle * primary ;
154 for ( iPrimary = 0 ; iPrimary < fObjGetter->GimeNPrimaries() ; iPrimary++)
156 primary = fObjGetter->GimePrimary(iPrimary) ;
157 Int_t primaryType = primary->GetPdgCode() ;
158 if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212) ) {
160 Double_t primX, primZ ;
161 fGeom->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 fGeom->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 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
177 if(moduleNumber==Nmod)
178 nbar->Fill(primZ,primX,primary->Energy()) ;
184 AliPHOSDigit * sdigit ;
186 for(iSDigit = 0; iSDigit < fObjGetter->GimeNSDigits(); iSDigit++)
188 sdigit = fObjGetter->GimeSDigit(iSDigit) ;
190 fGeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
192 fGeom->RelPosInModule(relid,x,z) ;
193 Float_t e = fObjGetter->GimeSDigitizer()->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 AliPHOSDigit * digit ;
207 for(iDigit = 0; iDigit < fObjGetter->GimeNDigits(); iDigit++)
209 digit = fObjGetter->GimeDigit(iDigit) ;
211 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
213 fGeom->RelPosInModule(relid,x,z) ;
214 Float_t e = fObjGetter->GimeSDigitizer()->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 < fObjGetter->GimeNEmcRecPoints() ; irecp ++){
231 AliPHOSEmcRecPoint * emc= fObjGetter->GimeEmcRecPoint(irecp) ;
232 if(emc->GetPHOSMod()==Nmod){
233 emc->GetLocalPosition(pos) ;
234 emcOccupancy->Fill(pos.X(),pos.Z(),emc->GetEnergy());
239 for(irecp = 0; irecp < fObjGetter->GimeNCpvRecPoints() ; irecp ++){
240 AliPHOSRecPoint * cpv = fObjGetter->GimeCpvRecPoint(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 AliPHOSRecParticle * recParticle ;
265 for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ )
267 recParticle = fObjGetter->GimeRecParticle(iRecParticle) ;
268 Int_t moduleNumberRec ;
269 Double_t recX, recZ ;
270 fGeom->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 = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
279 Int_t numberofprimaries ;
280 Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
282 TParticle * primary ;
283 Double_t distance = minDistance ;
285 for ( index = 0 ; index < numberofprimaries ; index++){
286 primary = fObjGetter->GimePrimary(listofprimaries[index]) ;
288 Double_t primX, primZ ;
289 fGeom->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 = fObjGetter->GimePrimary(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
334 fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data()) ;
337 TObjArray * branches;
339 branches = gAlice->TreeS()->GetListOfBranches() ;
341 cout << "TreeS: " << endl ;
342 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
343 TBranch * branch=(TBranch *) branches->At(ibranch) ;
344 if(strstr(branch->GetName(),"PHOS") )
345 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
349 branches = gAlice->TreeD()->GetListOfBranches() ;
351 cout << "TreeD: " << endl ;
352 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
353 TBranch * branch=(TBranch *) branches->At(ibranch) ;
354 if(strstr(branch->GetName(),"PHOS") )
355 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
360 branches = gAlice->TreeR()->GetListOfBranches() ;
362 cout << "TreeR: " << endl ;
363 for(ibranch = 0;ibranch <branches->GetEntries();ibranch++){
364 TBranch * branch=(TBranch *) branches->At(ibranch) ;
365 if(strstr(branch->GetName(),"PHOS") )
366 cout << " " << branch->GetName() << " " << branch->GetTitle() << endl ;
372 //____________________________________________________________________________
373 void AliPHOSAnalyze::InvariantMass(const char* branchTitle)
375 // Calculates Real and Mixed invariant mass distributions
376 fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",branchTitle) ;
378 Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
381 TFile * mfile = new TFile("invmass.root","update");
383 //========== Reading /Booking Histograms
385 hRealEM = (TH2D*) mfile->Get("hRealEM") ;
387 hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
388 TH2D * hRealPhot = 0 ;
390 hRealPhot = (TH2D*)mfile->Get("hRealPhot");
392 hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
394 TH2D * hMixedEM = 0 ;
395 hMixedEM = (TH2D*) mfile->Get("hMixedEM") ;
397 hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
399 TH2D * hMixedPhot = 0 ;
400 hMixedPhot = (TH2D*) mfile->Get("hMixedPhot") ;
402 hMixedPhot = new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
405 //reading event and copyng it to TConesArray of all photons
407 TClonesArray * allRecParticleList = new TClonesArray("AliPHOSRecParticle", 1000) ;
408 Int_t * nRecParticles = new Int_t[nMixedEvents] ; // to mark boundaries of each event in the total list
409 for(Int_t index = 0; index < nMixedEvents; index ++)
410 nRecParticles[index] = 0 ;
411 Int_t iRecPhot = 0 ; // number of EM particles in total list
413 //scan over all events
415 for(event = 0; event < fObjGetter->GetMaxEvent(); event++ ){
417 fObjGetter->GetEvent(event);
419 //copy EM RecParticles to the "total" list
420 AliPHOSRecParticle * recParticle ;
422 for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ )
424 recParticle = fObjGetter->GimeRecParticle(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 if((mevent == 0) && (event +1 == fObjGetter->GetMaxEvent())){
436 //calculate invariant mass:
438 Int_t nCurEvent = 0 ;
440 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
441 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
443 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
444 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
447 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
448 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
449 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
450 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
453 invMass = TMath::Sqrt(invMass);
456 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +
457 (rp1->Py()+rp2->Py() )*( rp1->Py()+rp2->Py() ) );
459 if(irp1 > nRecParticles[nCurEvent])
462 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
463 hRealEM->Fill(invMass,pt);
464 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&
465 (rp2->GetType() == AliPHOSFastRecParticle::kGAMMA) )
466 hRealPhot->Fill(invMass,pt);
469 hMixedEM->Fill(invMass,pt);
470 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&
471 (rp2->GetType() == AliPHOSFastRecParticle::kGAMMA) )
472 hMixedPhot->Fill(invMass,pt);
475 } //loop over second rp
476 }//loop over first rp
478 //Make some cleanings
479 for(Int_t index = 0; index < nMixedEvents; index ++)
480 nRecParticles[index] = 0 ;
482 allRecParticleList->Clear() ;
486 delete allRecParticleList ;
491 hRealEM->Write(0,kOverwrite) ;
492 hRealPhot->Write(0,kOverwrite) ;
493 hMixedEM->Write(0,kOverwrite) ;
494 hMixedPhot->Write(0,kOverwrite) ;
499 delete nRecParticles;
503 //____________________________________________________________________________
504 void AliPHOSAnalyze::EnergyResolution(const char * branchTitle)
506 //fills two dimentional histo: energy of primary vs. energy of reconstructed
508 TH2F * hAllEnergy = 0 ; //all reconstructed with primary photon
509 TH2F * hPhotEnergy= 0 ; //kGamma with primary photon
510 TH2F * hEMEnergy = 0 ; //electromagnetic with primary photon
512 //opening file and reading histograms if any
513 TFile * efile = new TFile("energy.root","update");
515 hAllEnergy = (TH2F*)efile->Get("hAllEnergy") ;
517 hAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
519 hPhotEnergy =(TH2F*) efile->Get("hPhotEnergy") ;
521 hPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
523 hEMEnergy =(TH2F*) efile->Get("hEMEnergy");
525 hEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
528 fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",branchTitle) ;
529 fGeom = fObjGetter->GetPHOSGeometry() ;
532 for ( ievent=0; ievent < fObjGetter->GetMaxEvent() ; ievent++){
534 //read the current event
535 fObjGetter->GetEvent(ievent) ;
537 AliPHOSRecParticle * recParticle ;
539 for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ ){
540 recParticle = fObjGetter->GimeRecParticle(iRecParticle) ;
542 //find the closest primary
543 Int_t moduleNumberRec ;
544 Double_t recX, recZ ;
545 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
547 Double_t minDistance = 100. ;
548 Int_t closestPrimary = -1 ;
550 //extract list of primaries: it is stored at EMC RecPoints
551 Int_t emcIndex = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
552 Int_t numberofprimaries ;
553 Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
556 TParticle * primary ;
557 Double_t distance = minDistance ;
560 Double_t dZmin = 0. ;
561 for ( index = 0 ; index < numberofprimaries ; index++){
562 primary = fObjGetter->GimePrimary(listofprimaries[index]) ;
564 Double_t primX, primZ ;
565 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
566 if(moduleNumberRec == moduleNumber) {
569 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
570 if(minDistance > distance) {
571 minDistance = distance ;
574 closestPrimary = listofprimaries[index] ;
579 //if found primary, fill histograms
580 if(closestPrimary >=0 ){
581 TParticle * primary = fObjGetter->GimePrimary(closestPrimary) ;
582 if(primary->GetPdgCode() == 22){
583 hAllEnergy->Fill(primary->Energy(), recParticle->Energy()) ;
584 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
585 hPhotEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
586 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
589 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)
590 hEMEnergy->Fill(primary->Energy(), recParticle->Energy() ) ;
596 //write filled histograms
598 hAllEnergy->Write(0,kOverwrite) ;
599 hPhotEnergy->Write(0,kOverwrite) ;
600 hEMEnergy->Write(0,kOverwrite) ;
606 //____________________________________________________________________________
607 void AliPHOSAnalyze::PositionResolution(const char * branchTitle)
609 //fills two dimentional histo: energy vs. primary - reconstructed distance
613 TH2F * hAllPosition = 0; // Position of any RP with primary photon
614 TH2F * hPhotPosition = 0; // Position of kGAMMA with primary photon
615 TH2F * hEMPosition = 0; // Position of EM with primary photon
617 TH1F * hAllPositionX = 0; // X-Position Resolution of photons with photon primary
618 TH1F * hAllPositionZ = 0; // Z-Position Resolution of photons with photon primary
621 //opening file and reading histograms if any
622 TFile * pfile = new TFile("position.root","update");
624 hAllPosition = (TH2F*)pfile->Get("hAllPosition");
625 if(hAllPosition == 0)
626 hAllPosition = new TH2F("hAllPosition",
627 "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
628 hPhotPosition= (TH2F*)pfile->Get("hPhotPosition");
629 if(hPhotPosition == 0)
630 hPhotPosition = new TH2F("hPhotPosition",
631 "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
632 hEMPosition= (TH2F*)pfile->Get("hEMPosition") ;
634 hEMPosition = new TH2F("hEMPosition",
635 "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
636 hAllPositionX = (TH1F*)pfile->Get("hAllPositionX") ;
637 if(hAllPositionX == 0)
638 hAllPositionX = new TH1F("hAllPositionX",
639 "Delta X of any RP with primary photon",100, -2., 2.);
640 hAllPositionZ =(TH1F*) pfile->Get("hAllPositionZ") ;
641 if(hAllPositionZ == 0)
642 hAllPositionZ = new TH1F("hAllPositionZ",
643 "Delta X of any RP with primary photon",100, -2., 2.);
646 fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",branchTitle) ;
649 fGeom = AliPHOSGeometry::GetInstance(((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetName(),
650 ((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetTitle() );
653 for ( ievent=0; ievent < fObjGetter->GetMaxEvent() ; ievent++){
655 //read the current event
656 fObjGetter->GetEvent(ievent) ;
658 AliPHOSRecParticle * recParticle ;
660 for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles() ;iRecParticle++ ){
661 recParticle = fObjGetter->GimeRecParticle(iRecParticle) ;
663 //find the closest primary
664 Int_t moduleNumberRec ;
665 Double_t recX, recZ ;
666 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
668 Double_t minDistance = 100. ;
669 Int_t closestPrimary = -1 ;
671 //extract list of primaries: it is stored at EMC RecPoints
672 Int_t emcIndex = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
673 Int_t numberofprimaries ;
674 Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
677 TParticle * primary ;
678 Double_t distance = minDistance ;
679 Double_t dX = 1000; // incredible number
680 Double_t dZ = 1000; // for the case if no primary will be found
682 Double_t dZmin = 0. ;
683 for ( index = 0 ; index < numberofprimaries ; index++){
684 primary = fObjGetter->GimePrimary(listofprimaries[index]) ;
686 Double_t primX, primZ ;
687 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
688 if(moduleNumberRec == moduleNumber) {
691 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
692 if(minDistance > distance) {
693 minDistance = distance ;
696 closestPrimary = listofprimaries[index] ;
701 //if found primary, fill histograms
702 if(closestPrimary >=0 ){
703 TParticle * primary = fObjGetter->GimePrimary(closestPrimary) ;
704 if(primary->GetPdgCode() == 22){
705 hAllPosition->Fill(primary->Energy(), minDistance) ;
706 hAllPositionX->Fill(primary->Energy(), dX) ;
707 hAllPositionZ->Fill(primary->Energy(), dZ) ;
708 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
709 hPhotPosition->Fill(primary->Energy(), minDistance ) ;
710 hEMPosition->Fill(primary->Energy(), minDistance ) ;
713 if(recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)
714 hEMPosition->Fill(primary->Energy(), minDistance ) ;
720 //Write output histgrams
722 hAllPosition->Write(0,kOverwrite) ;
723 hAllPositionX->Write(0,kOverwrite) ;
724 hAllPositionZ->Write(0,kOverwrite) ;
725 hPhotPosition->Write(0,kOverwrite) ;
726 hEMPosition->Write(0,kOverwrite) ;
733 //____________________________________________________________________________
734 void AliPHOSAnalyze::Contamination(const char* RecPointsTitle){
735 // fills spectra of primary photons and several kinds of
736 // reconstructed particles, so that analyzing them one can
737 // estimate conatmination, efficiency of registration etc.
739 //define several general histograms
740 TH1F * hPrimary = 0; //spectrum (P_t distribution) of primary photons
741 TH1F * hAllRP = 0; //spectrum of all RecParticles in PHOS
742 TH1F * hPhot = 0; //spectrum of kGAMMA RecParticles
743 TH1F * hPPSD = 0; //spectrum of all RecParticles with PPSD signal
744 TH1F * hShape = 0; //spectrum of all EM RecParticles
745 TH1F * hVeto = 0; //spectrum of all neutral RecParticles
747 //Now separate histograms in accoradance with primary
749 TH1F * hPhotReg = 0; //Registeres as photon
750 TH1F * hPhotEM = 0; //Registered as EM
751 TH1F * hPhotPPSD= 0; //Registered as RecParticle with PPSD signal
754 TH1F * hNReg = 0; //Registeres as photon
755 TH1F * hNEM = 0; //Registered as EM
756 TH1F * hNPPSD= 0; //Registered as RecParticle with PPSD signal
759 TH1F * hNBarReg = 0; //Registeres as photon
760 TH1F * hNBarEM = 0; //Registered as EM
761 TH1F * hNBarPPSD= 0; //Registered as RecParticle with PPSD signal
763 //primary - charged hadron (pBar excluded)
764 TH1F * hChargedReg = 0; //Registeres as photon
765 TH1F * hChargedEM = 0; //Registered as EM
766 TH1F * hChargedPPSD= 0; //Registered as RecParticle with PPSD signal
769 TH1F * hPbarReg = 0; //Registeres as photon
770 TH1F * hPbarEM = 0; //Registered as EM
771 TH1F * hPbarPPSD= 0; //Registered as RecParticle with PPSD signal
774 //Reading histograms from the file
775 TFile * cfile = new TFile("contamination.root","update") ;
777 //read general histograms
778 hPrimary = (TH1F*) cfile->Get("hPrimary") ;
780 hPrimary= new TH1F("hPrimary", "Primary photon spectrum", 100, 0., 5.);
781 hAllRP = (TH1F*)cfile->Get("hAllRP") ;
783 hAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
784 hPhot = (TH1F*)cfile->Get("hPhot") ;
786 hPhot = new TH1F("hPhot","All kGAMMA RecParticles",100, 0., 5.);
787 hPPSD = (TH1F*)cfile->Get("hPPSD") ;
789 hPPSD = new TH1F("hPPSD", "All PPSD Recparticles", 100, 0., 5.);
790 hShape = (TH1F*) cfile->Get("hShape") ;
792 hShape = new TH1F("hShape","All particles with EM shower",100, 0., 5.);
793 hVeto= (TH1F*)cfile->Get("hVeto") ;
795 hVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
799 hPhotReg = (TH1F*)cfile->Get("hPhotReg");
801 hPhotReg = new TH1F("hPhotReg","Photon registered as photon",100, 0., 5.);
802 hPhotEM =(TH1F*)cfile->Get("hPhotEM");
804 hPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
805 hPhotPPSD= (TH1F*)cfile->Get("hPhotPPSD");
807 hPhotPPSD = new TH1F("hPhotPPSD","Photon registered as PPSD", 100, 0., 5.);
810 hNReg = (TH1F*)cfile->Get("hNReg");
812 hNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
813 hNEM = (TH1F*)cfile->Get("hNEM");
815 hNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
816 hNPPSD=(TH1F*)cfile->Get("hNPPSD");
818 hNPPSD = new TH1F("hNPPSD","N registered as PPSD", 100, 0., 5.);
821 hNBarReg =(TH1F*)cfile->Get("hNBarReg");
823 hNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
824 hNBarEM =(TH1F*)cfile->Get("hNBarEM");
826 hNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
827 hNBarPPSD=(TH1F*)cfile->Get("hNBarPPSD");
829 hNBarPPSD = new TH1F("hNBarPPSD","NBar registered as PPSD", 100, 0., 5.);
831 //primary - charged hadron (pBar excluded)
832 hChargedReg = (TH1F*)cfile->Get("hChargedReg");
834 hChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
835 hChargedEM = (TH1F*)cfile->Get("hChargedEM");
837 hChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
838 hChargedPPSD= (TH1F*)cfile->Get("hChargedPPSD");
840 hChargedPPSD= new TH1F("hChargedPPSD","Charged registered as PPSD",100, 0., 5.);
843 hPbarReg = (TH1F*)cfile->Get("hPbarReg");
845 hPbarReg= new TH1F("hPbarReg", "pBar registered as photon",100, 0., 5.);
846 hPbarEM = (TH1F*)cfile->Get("hPbarEM");
848 hPbarEM= new TH1F("hPbarEM","Pbar registered as EM",100, 0., 5.);
849 hPbarPPSD= (TH1F*)cfile->Get("hPbarPPSD");
851 hPbarPPSD= new TH1F("hPbarPPSD","Pbar as PPSD",100, 0., 5.);
854 //Now make some initializations
856 Int_t counter[8][5] ; //# of registered particles
858 for(i1 = 0; i1<8; i1++)
859 for(i2 = 0; i2<5; i2++)
860 counter[i1][i2] = 0 ;
864 fObjGetter = AliPHOSIndexToObject::GetInstance(ffileName.Data(),"PHOSRP",RecPointsTitle) ;
865 fGeom = AliPHOSGeometry::GetInstance(((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetName(),
866 ((AliPHOS*)gAlice->GetModule("PHOS"))->GetGeometry()->GetTitle() );
869 for ( ievent=0; ievent < fObjGetter->GetMaxEvent() ; ievent++){
871 fObjGetter->GetEvent(ievent) ;
873 //=========== Make spectrum of the primary photons
874 TParticle * primary ;
876 for( iPrimary = 0 ; iPrimary < fObjGetter->GimeNPrimaries() ; iPrimary++){
877 primary = fObjGetter->GimePrimary(iPrimary) ;
878 Int_t primaryType = primary->GetPdgCode() ;
879 if( primaryType == 22 ) {
880 //check, if photons folls onto PHOS
882 Double_t primX, primZ ;
883 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
885 hPrimary->Fill(primary->Energy()) ;
890 //========== Now scan over RecParticles
891 AliPHOSRecParticle * recParticle ;
893 for(iRecParticle = 0; iRecParticle < fObjGetter->GimeNRecParticles(); iRecParticle++ ){
894 recParticle = fObjGetter->GimeRecParticle(iRecParticle) ;
895 //fill histo spectrum of all RecParticles
896 hAllRP->Fill(CorrectedEnergy(recParticle->Energy())) ;
898 //==========find the closest primary
899 Int_t moduleNumberRec ;
900 Double_t recX, recZ ;
901 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
903 Double_t minDistance = 100. ;
904 Int_t closestPrimary = -1 ;
906 //extract list of primaries: it is stored at EMC RecPoints
907 Int_t emcIndex = fObjGetter->GimeTrackSegment(recParticle->GetPHOSTSIndex())->GetEmcIndex() ;
908 Int_t numberofprimaries ;
909 Int_t * listofprimaries = fObjGetter->GimeEmcRecPoint(emcIndex)->GetPrimaries(numberofprimaries) ;
911 TParticle * primary ;
912 Double_t distance = minDistance ;
915 Double_t dZmin = 0. ;
916 for ( index = 0 ; index < numberofprimaries ; index++){
917 primary = fObjGetter->GimePrimary(listofprimaries[index]) ;
919 Double_t primX, primZ ;
920 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
921 if(moduleNumberRec == moduleNumber) {
924 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
925 if(minDistance > distance) {
926 minDistance = distance ;
929 closestPrimary = listofprimaries[index] ;
934 //===========define the "type" of closest primary
935 if(closestPrimary >=0 ){
936 Int_t primaryCode = -1;
937 TParticle * primary = fObjGetter->GimePrimary(closestPrimary) ;
938 Int_t primaryType = primary->GetPdgCode() ;
939 if(primaryType == 22) // photon ?
942 if(primaryType == 2112) // neutron
945 if(primaryType == -2112) // Anti neutron
948 if(primaryType == -2122) //Anti proton
951 if(fObjGetter->GimePrimary(closestPrimary)->GetPDG()->Charge())
954 //==========Now look at the type of RecParticle
955 Float_t energy = CorrectedEnergy(recParticle->Energy()) ;
956 if(recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA){
957 hPhot->Fill(energy ) ;
960 hPhotReg->Fill(energy ) ;
963 hNReg->Fill(energy ) ;
966 hNBarReg->Fill(energy ) ;
969 hChargedReg->Fill(energy ) ;
972 hPbarReg->Fill(energy ) ;
978 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
979 (recParticle->GetType() == AliPHOSFastRecParticle::kGAMMAHA)){ //with PPSD signal
980 hPPSD->Fill(energy ) ;
983 hPhotPPSD->Fill(energy ) ;
986 hNPPSD->Fill(energy ) ;
989 hNBarPPSD->Fill(energy ) ;
992 hChargedPPSD->Fill(energy ) ;
995 hPbarPPSD->Fill(energy ) ;
1001 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
1002 (recParticle->GetType() == AliPHOSFastRecParticle::kELECTRON)||
1003 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)||
1004 (recParticle->GetType() == AliPHOSFastRecParticle::kABSURDEM) ){ //with EM shower
1005 hShape->Fill(energy ) ;
1006 switch(primaryCode){
1008 hPhotEM->Fill(energy ) ;
1011 hNEM->Fill(energy ) ;
1014 hNBarEM->Fill(energy ) ;
1017 hChargedEM->Fill(energy ) ;
1020 hPbarEM->Fill(energy ) ;
1027 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
1028 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALHA) ||
1029 (recParticle->GetType() == AliPHOSFastRecParticle::kGAMMAHA) ||
1030 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM) ) //nuetral
1031 hVeto->Fill(energy ) ;
1033 //fill number of primaries identified as ...
1034 if(primaryCode >= 0) // Primary code defined
1035 counter[recParticle->GetType()][primaryCode]++ ;
1039 } // no closest primary found
1043 //=================== SaveHistograms
1045 hPrimary->Write(0,kOverwrite);
1046 hAllRP->Write(0,kOverwrite);
1047 hPhot->Write(0,kOverwrite);
1048 hPPSD->Write(0,kOverwrite);
1049 hShape->Write(0,kOverwrite);
1050 hVeto->Write(0,kOverwrite);
1051 hPhotReg->Write(0,kOverwrite);
1052 hPhotEM->Write(0,kOverwrite);
1053 hPhotPPSD->Write(0,kOverwrite);
1054 hNReg ->Write(0,kOverwrite);
1055 hNEM ->Write(0,kOverwrite);
1056 hNPPSD->Write(0,kOverwrite);
1057 hNBarReg ->Write(0,kOverwrite);
1058 hNBarEM ->Write(0,kOverwrite);
1059 hNBarPPSD->Write(0,kOverwrite);
1060 hChargedReg ->Write(0,kOverwrite);
1061 hChargedEM ->Write(0,kOverwrite);
1062 hChargedPPSD->Write(0,kOverwrite);
1063 hPbarReg ->Write(0,kOverwrite);
1064 hPbarEM ->Write(0,kOverwrite);
1065 hPbarPPSD->Write(0,kOverwrite);
1067 cfile->Write(0,kOverwrite);
1074 cout << "Resolutions: Analyzed " << fObjGetter->GetMaxEvent() << " event(s)" << endl ;
1077 cout << " Primary: Photon Neutron Antineutron Charged hadron AntiProton" << endl ;
1078 cout << "--------------------------------------------------------------------------------" << endl ;
1080 << setw(8) << counter[2][0] << setw(9) << counter[2][1] << setw(13) << counter[2][2]
1081 << setw(15)<< counter[2][3] << setw(13) << counter[2][4] << endl ;
1082 cout << " kGAMMAHA: "
1083 << setw(8) << counter[3][0] << setw(9) << counter[3][1] << setw(13) << counter[3][2]
1084 << setw(15)<< counter[3][3] << setw(13) << counter[3][4] << endl ;
1085 cout << " kNEUTRALEM: "
1086 << setw(8) << counter[0][0] << setw(9) << counter[0][1] << setw(13) << counter[0][2]
1087 << setw(15)<< counter[0][3] << setw(13) << counter[0][4] << endl ;
1088 cout << " kNEUTRALHA: "
1089 << setw(8) << counter[1][0] << setw(9) << counter[1][1] << setw(13) << counter[1][2]
1090 << setw(15)<< counter[1][3] << setw(13) << counter[1][4] << endl ;
1091 cout << " kABSURDEM: "
1092 << setw(8) << counter[4][0] << setw(9) << counter[4][1] << setw(13) << counter[4][2]
1093 << setw(15)<< counter[4][3] << setw(13) << counter[4][4] << endl ;
1094 cout << " kABSURDHA: "
1095 << setw(8) << counter[5][0] << setw(9) << counter[5][1] << setw(13) << counter[5][2]
1096 << setw(15)<< counter[5][3] << setw(13) << counter[5][4] << endl ;
1097 cout << " kELECTRON: "
1098 << setw(8) << counter[6][0] << setw(9) << counter[6][1] << setw(13) << counter[6][2]
1099 << setw(15)<< counter[6][3] << setw(13) << counter[6][4] << endl ;
1100 cout << " kCHARGEDHA: "
1101 << setw(8) << counter[7][0] << setw(9) << counter[7][1] << setw(13) << counter[7][2]
1102 << setw(15)<< counter[7][3] << setw(13) << counter[7][4] << endl ;
1103 cout << "--------------------------------------------------------------------------------" << endl ;
1105 Int_t totalInd = 0 ;
1106 for(i1 = 0; i1<8; i1++)
1107 for(i2 = 0; i2<5; i2++)
1108 totalInd+=counter[i1][i2] ;
1109 cout << "Indentified particles: " << totalInd << endl ;