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 PHOSv1 events:
20 // Construct histograms and displays them.
21 // Use the macro EditorBar.C for best access to the functionnalities
23 //*-- Author: Y. Schutz (SUBATECH) & Gines Martinez (SUBATECH)
24 //////////////////////////////////////////////////////////////////////////////
26 // --- ROOT system ---
32 #include "TParticle.h"
33 #include "TClonesArray.h"
39 // --- Standard library ---
44 // --- AliRoot header files ---
47 #include "AliPHOSAnalyze.h"
48 #include "AliPHOSClusterizerv1.h"
49 #include "AliPHOSTrackSegmentMakerv1.h"
50 #include "AliPHOSPIDv1.h"
51 #include "AliPHOSReconstructioner.h"
52 #include "AliPHOSDigit.h"
53 #include "AliPHOSTrackSegment.h"
54 #include "AliPHOSRecParticle.h"
55 #include "AliPHOSIndexToObject.h"
56 #include "AliPHOSHit.h"
57 #include "AliPHOSCPVHit.h"
58 #include "AliPHOSCpvRecPoint.h"
60 ClassImp(AliPHOSAnalyze)
62 //____________________________________________________________________________
63 AliPHOSAnalyze::AliPHOSAnalyze()
65 // default ctor (useless)
70 //____________________________________________________________________________
71 AliPHOSAnalyze::AliPHOSAnalyze(Text_t * name)
73 // ctor: analyze events from root file "name"
75 Bool_t ok = OpenRootFile(name) ;
77 cout << " AliPHOSAnalyze > Error opening " << name << endl ;
80 //========== Get AliRun object from file
81 gAlice = (AliRun*) fRootFile->Get("gAlice") ;
83 //=========== Get the PHOS object and associated geometry from the file
84 fPHOS = (AliPHOSv1 *)gAlice->GetDetector("PHOS") ;
85 fGeom = AliPHOSGeometry::GetInstance( fPHOS->GetGeometry()->GetName(), fPHOS->GetGeometry()->GetTitle() );
87 //========== Initializes the Index to Object converter
88 fObjGetter = AliPHOSIndexToObject::GetInstance(fPHOS) ;
89 //========== Current event number
101 //____________________________________________________________________________
102 AliPHOSAnalyze::AliPHOSAnalyze(const AliPHOSAnalyze & ana)
105 ( (AliPHOSAnalyze &)ana ).Copy(*this) ;
108 //____________________________________________________________________________
109 void AliPHOSAnalyze::Copy(TObject & obj)
111 // copy an analysis into an other one
113 // I do nothing more because the copy is silly but the Code checkers requires one
116 //____________________________________________________________________________
117 AliPHOSAnalyze::~AliPHOSAnalyze()
121 if(fRootFile->IsOpen()) fRootFile->Close() ;
122 if(fRootFile) {delete fRootFile ; fRootFile=0 ;}
123 if(fPHOS) {delete fPHOS ; fPHOS =0 ;}
124 if(fClu) {delete fClu ; fClu =0 ;}
125 if(fPID) {delete fPID ; fPID =0 ;}
126 if(fRec) {delete fRec ; fRec =0 ;}
127 if(fTrs) {delete fTrs ; fTrs =0 ;}
130 //____________________________________________________________________________
131 void AliPHOSAnalyze::DrawRecon(Int_t Nevent,Int_t Nmod){
132 //Draws pimary particles and reconstructed
133 //digits, RecPoints, RecPartices etc
134 //for event Nevent in the module Nmod.
136 TH2F * digitOccupancy = new TH2F("digitOccupancy","EMC digits", 64,-71.,71.,64,-71.,71.);
137 TH2F * sdigitOccupancy = new TH2F("sdigitOccupancy","EMC sdigits", 64,-71.,71.,64,-71.,71.);
138 TH2F * emcOccupancy = new TH2F("emcOccupancy","EMC RecPoints",64,-71.,71.,64,-71.,71.);
139 TH2F * ppsdUp = new TH2F("ppsdUp","PPSD Up digits", 128,-71.,71.,128,-71.,71.) ;
140 TH2F * ppsdUpCl = new TH2F("ppsdUpCl","PPSD Up RecPoints",128,-71.,71.,128,-71.,71.) ;
141 TH2F * ppsdLow = new TH2F("ppsdLow","PPSD Low digits", 128,-71.,71.,128,-71.,71.) ;
142 TH2F * ppsdLowCl = new TH2F("ppsdLowCl","PPSD Low RecPoints",128,-71.,71.,128,-71.,71.) ;
143 TH2F * nbar = new TH2F("nbar","Primary nbar", 64,-71.,71.,64,-71.,71.);
144 TH2F * phot = new TH2F("phot","Primary Photon", 64,-71.,71.,64,-71.,71.);
145 TH2F * charg = new TH2F("charg","Primary charged",64,-71.,71.,64,-71.,71.);
146 TH2F * recPhot = new TH2F("recPhot","RecParticles with primary Photon",64,-71.,71.,64,-71.,71.);
147 TH2F * recNbar = new TH2F("recNbar","RecParticles with primary Nbar", 64,-71.,71.,64,-71.,71.);
149 //========== Create the Clusterizer
150 fClu = new AliPHOSClusterizerv1() ;
152 gAlice->GetEvent(Nevent);
154 TParticle * primary ;
156 for ( iPrimary = 0 ; iPrimary < gAlice->GetNtrack() ; iPrimary++)
158 primary = gAlice->Particle(iPrimary) ;
159 Int_t primaryType = primary->GetPdgCode() ;
160 if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212) ) {
162 Double_t primX, primZ ;
163 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
164 if(moduleNumber==Nmod)
165 charg->Fill(primZ,primX,primary->Energy()) ;
167 if( primaryType == 22 ) {
169 Double_t primX, primZ ;
170 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
171 if(moduleNumber==Nmod)
172 phot->Fill(primZ,primX,primary->Energy()) ;
175 if( primaryType == -2112 ) {
177 Double_t primX, primZ ;
178 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
179 if(moduleNumber==Nmod)
180 nbar->Fill(primZ,primX,primary->Energy()) ;
185 // fPHOS->SetTreeAddress() ;
187 gAlice->TreeS()->GetEvent(0) ;
190 AliPHOSDigit * sdigit ;
192 if(fPHOS->SDigits()){
193 for(iSDigit = 0; iSDigit < fPHOS->SDigits()->GetEntries(); iSDigit++)
195 sdigit = (AliPHOSDigit *) fPHOS->SDigits()->At(iSDigit) ;
197 fGeom->AbsToRelNumbering(sdigit->GetId(), relid) ;
199 fGeom->RelPosInModule(relid,x,z) ;
200 Float_t e = fPHOS->Calibrate(sdigit->GetAmp()) ;
202 if(relid[1]==0) //EMC
203 sdigitOccupancy->Fill(x,z,e) ;
204 if((relid[1]>0)&&(relid[1]<17))
205 ppsdUp->Fill(x,z,e) ;
207 ppsdLow->Fill(x,z,e) ;
212 cout << "No SDigits read " << endl ;
215 gAlice->TreeD()->GetEvent(0) ;
219 AliPHOSDigit * digit ;
220 for(iDigit = 0; iDigit < fPHOS->Digits()->GetEntries(); iDigit++)
222 digit = (AliPHOSDigit *) fPHOS->Digits()->At(iDigit) ;
224 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
226 fGeom->RelPosInModule(relid,x,z) ;
227 Float_t e = fClu->Calibrate(digit->GetAmp()) ;
229 if(relid[1]==0) //EMC
230 digitOccupancy->Fill(x,z,e) ;
231 if((relid[1]>0)&&(relid[1]<17))
232 ppsdUp->Fill(x,z,e) ;
234 ppsdLow->Fill(x,z,e) ;
239 cout << "No Digits read " << endl ;
242 gAlice->TreeR()->GetEvent(0) ;
244 TObjArray * emcRecPoints = fPHOS->EmcRecPoints() ;
245 TObjArray * ppsdRecPoints = fPHOS->PpsdRecPoints() ;
246 TClonesArray * recParticleList = fPHOS->RecParticles() ;
253 for(irecp = 0; irecp < emcRecPoints->GetEntries() ; irecp ++){
254 AliPHOSEmcRecPoint * emc= (AliPHOSEmcRecPoint*)emcRecPoints->At(irecp) ;
255 if(emc->GetPHOSMod()==Nmod){
256 emc->GetLocalPosition(pos) ;
257 emcOccupancy->Fill(pos.X(),pos.Z(),emc->GetEnergy());
262 cout << "No EMC rec points read " << endl ;
266 for(irecp = 0; irecp < ppsdRecPoints->GetEntries() ; irecp ++){
267 AliPHOSPpsdRecPoint * ppsd= (AliPHOSPpsdRecPoint *)ppsdRecPoints->At(irecp) ;
268 if(ppsd->GetPHOSMod()==Nmod){
269 ppsd->GetLocalPosition(pos) ;
271 ppsdUpCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
273 ppsdLowCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
278 cout << "No PPSD/CPV rec points read " << endl ;
281 AliPHOSRecParticle * recParticle ;
283 if(recParticleList ){
284 for(iRecParticle = 0; iRecParticle < recParticleList->GetEntries() ;iRecParticle++ )
286 recParticle = (AliPHOSRecParticle *) recParticleList->At(iRecParticle) ;
288 Int_t moduleNumberRec ;
289 Double_t recX, recZ ;
290 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
291 if(moduleNumberRec == Nmod){
293 Double_t minDistance = 5. ;
294 Int_t closestPrimary = -1 ;
296 Int_t numberofprimaries ;
297 Int_t * listofprimaries = recParticle->GetPrimaries(numberofprimaries) ;
299 TParticle * primary ;
300 Double_t distance = minDistance ;
302 for ( index = 0 ; index < numberofprimaries ; index++){
303 primary = gAlice->Particle(listofprimaries[index]) ;
305 Double_t primX, primZ ;
306 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
307 if(moduleNumberRec == moduleNumber)
308 distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ;
309 if(minDistance > distance)
311 minDistance = distance ;
312 closestPrimary = listofprimaries[index] ;
316 if(closestPrimary >=0 ){
318 Int_t primaryType = gAlice->Particle(closestPrimary)->GetPdgCode() ;
321 recPhot->Fill(recZ,recX,recParticle->Energy()) ;
323 if(primaryType==-2112)
324 recNbar->Fill(recZ,recX,recParticle->Energy()) ;
330 cout << "Not Rec Prticles read " << endl ;
333 digitOccupancy->Draw("box") ;
334 sdigitOccupancy->SetLineColor(5) ;
335 sdigitOccupancy->Draw("box") ;
336 emcOccupancy->SetLineColor(2) ;
337 emcOccupancy->Draw("boxsame") ;
338 ppsdUp->SetLineColor(3) ;
339 ppsdUp->Draw("boxsame") ;
340 ppsdLow->SetLineColor(4) ;
341 ppsdLow->Draw("boxsame") ;
342 phot->SetLineColor(8) ;
343 phot->Draw("boxsame") ;
344 nbar->SetLineColor(6) ;
345 nbar->Draw("boxsame") ;
348 //____________________________________________________________________________
349 void AliPHOSAnalyze::Reconstruct(Int_t nevents,Int_t firstEvent )
352 // Performs reconstruction of EMC and CPV (GPS2, IHEP or MIXT)
353 // for events from FirstEvent to Nevents
356 for ( ievent=firstEvent; ievent<nevents; ievent++) {
357 if (ievent==firstEvent) {
358 cout << "Analyze > Starting Reconstructing " << endl ;
359 //========== Create the Clusterizer
360 fClu = new AliPHOSClusterizerv1() ;
362 //========== Creates the track segment maker
363 fTrs = new AliPHOSTrackSegmentMakerv1() ;
364 // fTrs->UnsetUnfoldFlag() ;
366 //========== Creates the particle identifier
367 fPID = new AliPHOSPIDv1() ;
368 fPID->SetShowerProfileCuts(0.3, 1.8, 0.3, 1.8 ) ;
370 //========== Creates the Reconstructioner
371 fRec = new AliPHOSReconstructioner(fClu, fTrs, fPID) ;
372 if (fDebugLevel != 0) fRec -> SetDebugReconstruction(kTRUE);
375 if (fDebugLevel != 0 ||
376 (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
377 cout << "======= Analyze ======> Event " << ievent+1 << endl ;
381 gAlice->Hits2Digits() ;
383 //=========== Do the reconstruction
384 fPHOS->Reconstruction(fRec);
388 if(fClu) {delete fClu ; fClu =0 ;}
389 if(fPID) {delete fPID ; fPID =0 ;}
390 if(fRec) {delete fRec ; fRec =0 ;}
391 if(fTrs) {delete fTrs ; fTrs =0 ;}
395 //-------------------------------------------------------------------------------------
396 void AliPHOSAnalyze::ReadAndPrintCPV(Int_t EvFirst, Int_t EvLast)
399 // // Read and print generated and reconstructed hits in CPV
400 // // for events from EvFirst to Nevent.
401 // // If only EvFirst is defined, print only this one event.
402 // // Author: Yuri Kharlov
403 // // 12 October 2000
406 // if (EvFirst!=0 && EvLast==0) EvLast=EvFirst;
407 // for ( Int_t ievent=EvFirst; ievent<=EvLast; ievent++) {
409 // //========== Event Number>
410 // cout << endl << "==== ReadAndPrintCPV ====> Event is " << ievent+1 << endl ;
412 // //=========== Connects the various Tree's for evt
413 // Int_t ntracks = gAlice->GetEvent(ievent);
415 // //========== Creating branches ===================================
416 // AliPHOSRecPoint::RecPointsList ** emcRecPoints = fPHOS->EmcRecPoints() ;
417 // gAlice->TreeR()->SetBranchAddress( "PHOSEmcRP" , emcRecPoints ) ;
419 // AliPHOSRecPoint::RecPointsList ** cpvRecPoints = fPHOS->PpsdRecPoints() ;
420 // gAlice->TreeR()->SetBranchAddress( "PHOSPpsdRP", cpvRecPoints ) ;
422 // // Read and print CPV hits
424 // AliPHOSCPVModule cpvModule;
425 // TClonesArray *cpvHits;
427 // AliPHOSCPVHit *cpvHit;
429 // Float_t xgen, zgen;
431 // Int_t nGenHits = 0;
432 // for (Int_t itrack=0; itrack<ntracks; itrack++) {
433 // //=========== Get the Hits Tree for the Primary track itrack
434 // gAlice->ResetHits();
435 // gAlice->TreeH()->GetEvent(itrack);
436 // Int_t iModule = 0 ;
437 // for (iModule=0; iModule < fGeom->GetNCPVModules(); iModule++) {
438 // cpvModule = fPHOS->GetCPVModule(iModule);
439 // cpvHits = cpvModule.Hits();
440 // nCPVhits = cpvHits->GetEntriesFast();
441 // for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
443 // cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
444 // p = cpvHit->GetMomentum();
445 // xgen = cpvHit->X();
446 // zgen = cpvHit->Y();
447 // ipart = cpvHit->GetIpart();
448 // printf("CPV hit in module %d: ",iModule+1);
449 // printf(" p = (%f, %f, %f, %f) GeV,\n",
450 // p.Px(),p.Py(),p.Pz(),p.Energy());
451 // printf(" (X,Z) = (%8.4f, %8.4f) cm, ipart = %d\n",
457 // // Read and print CPV reconstructed points
459 // //=========== Gets the Reconstruction TTree
460 // gAlice->TreeR()->GetEvent(0) ;
461 // printf("Recpoints: %d\n",(*fPHOS->CpvRecPoints())->GetEntries());
462 // TIter nextRP(*fPHOS->CpvRecPoints() ) ;
463 // AliPHOSCpvRecPoint *cpvRecPoint ;
464 // Int_t nRecPoints = 0;
465 // while( ( cpvRecPoint = (AliPHOSCpvRecPoint *)nextRP() ) ) {
468 // cpvRecPoint->GetLocalPosition(locpos);
469 // Int_t phosModule = cpvRecPoint->GetPHOSMod();
470 // printf("CPV recpoint in module %d: (X,Z) = (%f,%f) cm\n",
471 // phosModule,locpos.X(),locpos.Z());
473 // printf("This event has %d generated hits and %d reconstructed points\n",
474 // nGenHits,nRecPoints);
478 //____________________________________________________________________________
479 void AliPHOSAnalyze::AnalyzeCPV(Int_t Nevents)
482 // // Analyzes CPV characteristics
483 // // Author: Yuri Kharlov
487 // // Book histograms
489 // TH1F *hDx = new TH1F("hDx" ,"CPV x-resolution@reconstruction",100,-5. , 5.);
490 // TH1F *hDz = new TH1F("hDz" ,"CPV z-resolution@reconstruction",100,-5. , 5.);
491 // TH1F *hDr = new TH1F("hDr" ,"CPV r-resolution@reconstruction",100, 0. , 5.);
492 // TH1S *hNrp = new TH1S("hNrp" ,"CPV rec.point multiplicity", 21,-0.5,20.5);
493 // TH1S *hNrpX = new TH1S("hNrpX","CPV rec.point Phi-length" , 21,-0.5,20.5);
494 // TH1S *hNrpZ = new TH1S("hNrpZ","CPV rec.point Z-length" , 21,-0.5,20.5);
496 // cout << "Start CPV Analysis"<< endl ;
497 // for ( Int_t ievent=0; ievent<Nevents; ievent++) {
499 // //========== Event Number>
500 // // if ( (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
501 // cout << endl << "==== AnalyzeCPV ====> Event is " << ievent+1 << endl ;
503 // //=========== Connects the various Tree's for evt
504 // Int_t ntracks = gAlice->GetEvent(ievent);
506 // //========== Creating branches ===================================
507 // AliPHOSRecPoint::RecPointsList ** emcRecPoints = fPHOS->EmcRecPoints() ;
508 // gAlice->TreeR()->SetBranchAddress( "PHOSEmcRP" , emcRecPoints ) ;
510 // AliPHOSRecPoint::RecPointsList ** cpvRecPoints = fPHOS->PpsdRecPoints() ;
511 // gAlice->TreeR()->SetBranchAddress( "PHOSPpsdRP", cpvRecPoints ) ;
513 // // Create and fill arrays of hits for each CPV module
515 // Int_t nOfModules = fGeom->GetNModules();
516 // TClonesArray **hitsPerModule = new TClonesArray *[nOfModules];
517 // Int_t iModule = 0;
518 // for (iModule=0; iModule < nOfModules; iModule++)
519 // hitsPerModule[iModule] = new TClonesArray("AliPHOSCPVHit",100);
521 // AliPHOSCPVModule cpvModule;
522 // TClonesArray *cpvHits;
524 // AliPHOSCPVHit *cpvHit;
529 // // First go through all primary tracks and fill the arrays
530 // // of hits per each CPV module
532 // for (Int_t itrack=0; itrack<ntracks; itrack++) {
533 // // Get the Hits Tree for the Primary track itrack
534 // gAlice->ResetHits();
535 // gAlice->TreeH()->GetEvent(itrack);
536 // for (Int_t iModule=0; iModule < nOfModules; iModule++) {
537 // cpvModule = fPHOS->GetCPVModule(iModule);
538 // cpvHits = cpvModule.Hits();
539 // nCPVhits = cpvHits->GetEntriesFast();
540 // for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
541 // cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
542 // p = cpvHit->GetMomentum();
543 // xzgen[0] = cpvHit->X();
544 // xzgen[1] = cpvHit->Y();
545 // ipart = cpvHit->GetIpart();
546 // TClonesArray &lhits = *(TClonesArray *)hitsPerModule[iModule];
547 // new(lhits[hitsPerModule[iModule]->GetEntriesFast()]) AliPHOSCPVHit(*cpvHit);
549 // cpvModule.Clear();
552 // for (iModule=0; iModule < nOfModules; iModule++) {
553 // Int_t nsum = hitsPerModule[iModule]->GetEntriesFast();
554 // printf("Module %d has %d hits\n",iModule,nsum);
557 // // Then go through reconstructed points and for each find
558 // // the closeset hit
559 // // The distance from the rec.point to the closest hit
560 // // gives the coordinate resolution of the CPV
562 // // Get the Reconstruction Tree
563 // gAlice->TreeR()->GetEvent(0) ;
564 // TIter nextRP(*fPHOS->PpsdRecPoints() ) ;
565 // AliPHOSCpvRecPoint *cpvRecPoint ;
566 // Float_t xgen, zgen;
567 // while( ( cpvRecPoint = (AliPHOSCpvRecPoint *)nextRP() ) ) {
569 // cpvRecPoint->GetLocalPosition(locpos);
570 // Int_t phosModule = cpvRecPoint->GetPHOSMod();
571 // Int_t rpMult = cpvRecPoint->GetDigitsMultiplicity();
572 // Int_t rpMultX, rpMultZ;
573 // cpvRecPoint->GetClusterLengths(rpMultX,rpMultZ);
574 // Float_t xrec = locpos.X();
575 // Float_t zrec = locpos.Z();
576 // Float_t dxmin = 1.e+10;
577 // Float_t dzmin = 1.e+10;
578 // Float_t r2min = 1.e+10;
581 // cpvHits = hitsPerModule[phosModule-1];
582 // Int_t nCPVhits = cpvHits->GetEntriesFast();
583 // for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
584 // cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
585 // xgen = cpvHit->X();
586 // zgen = cpvHit->Y();
587 // r2 = TMath::Power((xgen-xrec),2) + TMath::Power((zgen-zrec),2);
588 // if ( r2 < r2min ) {
590 // dxmin = xgen - xrec;
591 // dzmin = zgen - zrec;
594 // hDx ->Fill(dxmin);
595 // hDz ->Fill(dzmin);
596 // hDr ->Fill(TMath::Sqrt(r2min));
597 // hNrp ->Fill(rpMult);
598 // hNrpX->Fill(rpMultX);
599 // hNrpZ->Fill(rpMultZ);
601 // delete [] hitsPerModule;
603 // // Save histograms
605 // Text_t outputname[80] ;
606 // sprintf(outputname,"%s.analyzed",fRootFile->GetName());
607 // TFile output(outputname,"RECREATE");
617 // // Plot histograms
619 // TCanvas *cpvCanvas = new TCanvas("CPV","CPV analysis",20,20,800,400);
620 // gStyle->SetOptStat(111111);
621 // gStyle->SetOptFit(1);
622 // gStyle->SetOptDate(1);
623 // cpvCanvas->Divide(3,2);
626 // gPad->SetFillColor(10);
627 // hNrp->SetFillColor(16);
631 // gPad->SetFillColor(10);
632 // hNrpX->SetFillColor(16);
636 // gPad->SetFillColor(10);
637 // hNrpZ->SetFillColor(16);
641 // gPad->SetFillColor(10);
642 // hDx->SetFillColor(16);
647 // gPad->SetFillColor(10);
648 // hDz->SetFillColor(16);
653 // gPad->SetFillColor(10);
654 // hDr->SetFillColor(16);
657 // cpvCanvas->Print("CPV.ps");
661 //____________________________________________________________________________
662 void AliPHOSAnalyze::InvariantMass(Int_t Nevents )
664 // Calculates Real and Mixed invariant mass distributions
666 const Int_t knMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
667 Int_t mixedLoops = (Int_t )TMath::Ceil(Nevents/knMixedEvents) ;
669 //========== Booking Histograms
670 TH2D * hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
671 TH2D * hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
672 TH2D * hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
673 TH2D * hMixedPhot= new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
676 Int_t eventInMixedLoop ;
678 Int_t nRecParticles[4];//knMixedEvents] ;
680 AliPHOSRecParticle::RecParticlesList * allRecParticleList = new TClonesArray("AliPHOSRecParticle", knMixedEvents*1000) ;
682 for(eventInMixedLoop = 0; eventInMixedLoop < mixedLoops; eventInMixedLoop++ ){
685 for ( ievent=0; ievent < knMixedEvents; ievent++){
687 Int_t absEventNumber = eventInMixedLoop*knMixedEvents + ievent ;
689 //=========== Connects the various Tree's for evt
690 gAlice->GetEvent(absEventNumber);
692 //========== Creating branches ===================================
693 fPHOS->SetTreeAddress() ;
695 gAlice->TreeD()->GetEvent(0) ;
696 gAlice->TreeR()->GetEvent(0) ;
698 TClonesArray * recParticleList = fPHOS->RecParticles() ;
701 AliPHOSRecParticle * recParticle ;
703 for(iRecParticle = 0; iRecParticle < recParticleList->GetEntries() ;iRecParticle++ )
705 recParticle = (AliPHOSRecParticle *) recParticleList->At(iRecParticle) ;
706 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
707 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)){
708 new( (*allRecParticleList)[iRecPhot] ) AliPHOSRecParticle(*recParticle) ;
713 nRecParticles[ievent] = iRecPhot-1 ;
716 //Now calculate invariant mass:
718 Int_t nCurEvent = 0 ;
720 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
721 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
723 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
724 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
727 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
728 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
729 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
730 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
733 invMass = TMath::Sqrt(invMass);
736 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +(rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py()));
738 if(irp1 > nRecParticles[nCurEvent])
741 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
742 hRealEM->Fill(invMass,pt);
743 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&(rp2->GetType() == AliPHOSFastRecParticle::kGAMMA))
744 hRealPhot->Fill(invMass,pt);
747 hMixedEM->Fill(invMass,pt);
748 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&(rp2->GetType() == AliPHOSFastRecParticle::kGAMMA))
749 hMixedPhot->Fill(invMass,pt);
752 } //loop over second rp
753 }//loop over first rp
754 allRecParticleList->Delete() ;
757 delete allRecParticleList ;
760 TFile output("invmass.root","RECREATE");
766 hMixedPhot->Write() ;
773 //____________________________________________________________________________
774 void AliPHOSAnalyze::ReadAndPrintEMC(Int_t EvFirst, Int_t EvLast)
777 // // Read and print generated and reconstructed hits in EMC
778 // // for events from EvFirst to Nevent.
779 // // If only EvFirst is defined, print only this one event.
780 // // Author: Yuri Kharlov
781 // // 24 November 2000
784 // if (EvFirst!=0 && EvLast==0) EvLast=EvFirst;
786 // for (ievent=EvFirst; ievent<=EvLast; ievent++) {
788 // //========== Event Number>
789 // cout << endl << "==== ReadAndPrintEMC ====> Event is " << ievent+1 << endl ;
791 // //=========== Connects the various Tree's for evt
792 // Int_t ntracks = gAlice->GetEvent(ievent);
793 // fPHOS->SetTreeAddress() ;
795 // gAlice->TreeD()->GetEvent(0) ;
796 // gAlice->TreeR()->GetEvent(0) ;
798 // // Loop over reconstructed particles
800 // TClonesArray ** recParticleList = fPHOS->RecParticles() ;
801 // AliPHOSRecParticle * recParticle ;
802 // Int_t iRecParticle ;
805 // for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ ) {
806 // recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
807 // Float_t recE = recParticle->Energy();
808 // primList = recParticle->GetPrimaries(nPrimary);
809 // Int_t moduleNumberRec ;
810 // Double_t recX, recZ ;
811 // fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
812 // printf("Rec point: module %d, (X,Z) = (%8.4f,%8.4f) cm, E = %.3f GeV, primary = %d\n",
813 // moduleNumberRec,recX,recZ,recE,*primList);
816 // // Read and print EMC hits from EMCn branches
818 // AliPHOSCPVModule emcModule;
819 // TClonesArray *emcHits;
821 // AliPHOSCPVHit *emcHit;
823 // Float_t xgen, zgen;
824 // Int_t ipart, primary;
825 // Int_t nGenHits = 0;
826 // for (Int_t itrack=0; itrack<ntracks; itrack++) {
827 // //=========== Get the Hits Tree for the Primary track itrack
828 // gAlice->ResetHits();
829 // gAlice->TreeH()->GetEvent(itrack);
830 // Int_t iModule = 0 ;
831 // for (iModule=0; iModule < fGeom->GetNModules(); iModule++) {
832 // emcModule = fPHOS->GetEMCModule(iModule);
833 // emcHits = emcModule.Hits();
834 // nEMChits = emcHits->GetEntriesFast();
835 // for (Int_t ihit=0; ihit<nEMChits; ihit++) {
837 // emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
838 // p = emcHit->GetMomentum();
839 // xgen = emcHit->X();
840 // zgen = emcHit->Y();
841 // ipart = emcHit->GetIpart();
842 // primary= emcHit->GetTrack();
843 // printf("EMC hit A: module %d, ",iModule+1);
844 // printf(" p = (%f .4, %f .4, %f .4, %f .4) GeV,\n",
845 // p.Px(),p.Py(),p.Pz(),p.Energy());
846 // printf(" (X,Z) = (%8.4f, %8.4f) cm, ipart = %d, primary = %d\n",
847 // xgen,zgen,ipart,primary);
852 // // // Read and print EMC hits from PHOS branch
854 // // for (Int_t itrack=0; itrack<ntracks; itrack++) {
855 // // //=========== Get the Hits Tree for the Primary track itrack
856 // // gAlice->ResetHits();
857 // // gAlice->TreeH()->GetEvent(itrack);
858 // // TClonesArray *hits = fPHOS->Hits();
859 // // AliPHOSHit *hit ;
861 // // for ( ihit = 0 ; ihit < hits->GetEntries() ; ihit++ ) {
862 // // hit = (AliPHOSHit*)hits->At(ihit) ;
863 // // Float_t hitXYZ[3];
864 // // hitXYZ[0] = hit->X();
865 // // hitXYZ[1] = hit->Y();
866 // // hitXYZ[2] = hit->Z();
867 // // ipart = hit->GetPid();
868 // // primary = hit->GetPrimary();
869 // // Int_t absId = hit->GetId();
870 // // Int_t relId[4];
871 // // fGeom->AbsToRelNumbering(absId, relId) ;
872 // // Int_t module = relId[0];
873 // // if (relId[1]==0 && !(hitXYZ[0]==0 && hitXYZ[2]==0))
874 // // printf("EMC hit B: module %d, (X,Z) = (%8.4f, %8.4f) cm, ipart = %d, primary = %d\n",
875 // // module,hitXYZ[0],hitXYZ[2],ipart,primary);
882 //____________________________________________________________________________
883 void AliPHOSAnalyze::AnalyzeEMC(Int_t Nevents)
886 // // Read generated and reconstructed hits in EMC for Nevents events.
887 // // Plots the coordinate and energy resolution histograms.
888 // // Coordinate resolution is a difference between the reconstructed
889 // // coordinate and the exact coordinate on the face of the PHOS
890 // // Author: Yuri Kharlov
891 // // 27 November 2000
894 // // Book histograms
896 // TH1F *hDx1 = new TH1F("hDx1" ,"EMC x-resolution", 100,-5. , 5.);
897 // TH1F *hDz1 = new TH1F("hDz1" ,"EMC z-resolution", 100,-5. , 5.);
898 // TH1F *hDE1 = new TH1F("hDE1" ,"EMC E-resolution", 100,-2. , 2.);
900 // TH2F *hDx2 = new TH2F("hDx2" ,"EMC x-resolution", 100, 0., 10., 100,-5. , 5.);
901 // TH2F *hDz2 = new TH2F("hDz2" ,"EMC z-resolution", 100, 0., 10., 100,-5. , 5.);
902 // TH2F *hDE2 = new TH2F("hDE2" ,"EMC E-resolution", 100, 0., 10., 100, 0. , 5.);
904 // cout << "Start EMC Analysis"<< endl ;
905 // for (Int_t ievent=0; ievent<Nevents; ievent++) {
907 // //========== Event Number>
908 // if ( (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
909 // cout << "==== AnalyzeEMC ====> Event is " << ievent+1 << endl ;
911 // //=========== Connects the various Tree's for evt
912 // Int_t ntracks = gAlice->GetEvent(ievent);
914 // fPHOS->SetTreeAddress() ;
916 // gAlice->TreeD()->GetEvent(0) ;
917 // gAlice->TreeR()->GetEvent(0) ;
919 // // Create and fill arrays of hits for each EMC module
921 // Int_t nOfModules = fGeom->GetNModules();
922 // TClonesArray **hitsPerModule = new TClonesArray *[nOfModules];
924 // for (iModule=0; iModule < nOfModules; iModule++)
925 // hitsPerModule[iModule] = new TClonesArray("AliPHOSCPVHit",100);
927 // AliPHOSCPVModule emcModule;
928 // TClonesArray *emcHits;
930 // AliPHOSCPVHit *emcHit;
932 // // First go through all primary tracks and fill the arrays
933 // // of hits per each EMC module
935 // for (Int_t itrack=0; itrack<ntracks; itrack++) {
936 // // Get the Hits Tree for the Primary track itrack
937 // gAlice->ResetHits();
938 // gAlice->TreeH()->GetEvent(itrack);
939 // for (Int_t iModule=0; iModule < nOfModules; iModule++) {
940 // emcModule = fPHOS->GetEMCModule(iModule);
941 // emcHits = emcModule.Hits();
942 // nEMChits = emcHits->GetEntriesFast();
943 // for (Int_t ihit=0; ihit<nEMChits; ihit++) {
944 // emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
945 // TClonesArray &lhits = *(TClonesArray *)hitsPerModule[iModule];
946 // new(lhits[hitsPerModule[iModule]->GetEntriesFast()]) AliPHOSCPVHit(*emcHit);
948 // emcModule.Clear();
952 // // Loop over reconstructed particles
954 // TClonesArray ** recParticleList = fPHOS->RecParticles() ;
955 // AliPHOSRecParticle * recParticle ;
956 // Int_t nEMCrecs = (*recParticleList)->GetEntries();
957 // if (nEMCrecs == 1) {
958 // recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(0) ;
959 // Float_t recE = recParticle->Energy();
961 // Double_t recX, recZ ;
962 // fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), phosModule, recX, recZ) ;
964 // // for this rec.point take the hit list in the same PHOS module
966 // emcHits = hitsPerModule[phosModule-1];
967 // Int_t nEMChits = emcHits->GetEntriesFast();
968 // if (nEMChits == 1) {
969 // Float_t genX, genZ, genE;
970 // for (Int_t ihit=0; ihit<nEMChits; ihit++) {
971 // emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
972 // genX = emcHit->X();
973 // genZ = emcHit->Y();
974 // genE = emcHit->GetMomentum().E();
976 // Float_t dx = recX - genX;
977 // Float_t dz = recZ - genZ;
978 // Float_t de = recE - genE;
982 // hDx2 ->Fill(genE,dx);
983 // hDz2 ->Fill(genE,dz);
984 // hDE2 ->Fill(genE,recE);
987 // delete [] hitsPerModule;
989 // // Save histograms
991 // Text_t outputname[80] ;
992 // sprintf(outputname,"%s.analyzed",fRootFile->GetName());
993 // TFile output(outputname,"RECREATE");
1003 // // Plot histograms
1005 // TCanvas *emcCanvas = new TCanvas("EMC","EMC analysis",20,20,700,300);
1006 // gStyle->SetOptStat(111111);
1007 // gStyle->SetOptFit(1);
1008 // gStyle->SetOptDate(1);
1009 // emcCanvas->Divide(3,1);
1011 // emcCanvas->cd(1);
1012 // gPad->SetFillColor(10);
1013 // hDx1->SetFillColor(16);
1016 // emcCanvas->cd(2);
1017 // gPad->SetFillColor(10);
1018 // hDz1->SetFillColor(16);
1021 // emcCanvas->cd(3);
1022 // gPad->SetFillColor(10);
1023 // hDE1->SetFillColor(16);
1026 // emcCanvas->Print("EMC.ps");
1030 //____________________________________________________________________________
1031 void AliPHOSAnalyze::AnalyzeResolutions(Int_t Nevents )
1033 // analyzes Nevents events and calculate Energy and Position resolution as well as
1034 // probaility of correct indentifiing of the incident particle
1036 //========== Booking Histograms
1037 cout << "AnalyzeResolutions > " << "Booking Histograms" << endl ;
1038 BookResolutionHistograms();
1040 Int_t counter[9][5] ;
1041 Int_t i1,i2,totalInd = 0 ;
1042 for(i1 = 0; i1<9; i1++)
1043 for(i2 = 0; i2<5; i2++)
1044 counter[i1][i2] = 0 ;
1046 Int_t totalPrimary = 0 ;
1047 Int_t totalRecPart = 0 ;
1048 Int_t totalRPwithPrim = 0 ;
1051 cout << "Start Analysing"<< endl ;
1052 for ( ievent=0; ievent<Nevents; ievent++)
1055 //========== Event Number>
1056 // if ( ( log10((Float_t)(ievent+1)) - (Int_t)(log10((Float_t)(ievent+1))) ) == 0. )
1057 cout << "AnalyzeResolutions > " << "Event is " << ievent << endl ;
1059 //=========== Connects the various Tree's for evt
1060 gAlice->GetEvent(ievent);
1062 //=========== Gets the Kine TTree
1063 gAlice->TreeK()->GetEvent(0) ;
1065 //=========== Gets the list of Primari Particles
1067 TParticle * primary ;
1069 for ( iPrimary = 0 ; iPrimary < gAlice->GetNtrack() ; iPrimary++)
1071 primary = gAlice->Particle(iPrimary) ;
1072 Int_t primaryType = primary->GetPdgCode() ;
1073 if( primaryType == 22 ) {
1074 Int_t moduleNumber ;
1075 Double_t primX, primZ ;
1076 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1078 fhPrimary->Fill(primary->Energy()) ;
1079 if(primary->Energy() > 0.3)
1085 fPHOS->SetTreeAddress() ;
1087 gAlice->TreeD()->GetEvent(0) ;
1088 gAlice->TreeR()->GetEvent(0) ;
1090 TClonesArray * recParticleList = fPHOS->RecParticles() ;
1092 AliPHOSRecParticle * recParticle ;
1093 Int_t iRecParticle ;
1094 for(iRecParticle = 0; iRecParticle < recParticleList->GetEntries() ;iRecParticle++ )
1096 recParticle = (AliPHOSRecParticle *) recParticleList->At(iRecParticle) ;
1097 fhAllRP->Fill(CorrectEnergy(recParticle->Energy())) ;
1099 Int_t moduleNumberRec ;
1100 Double_t recX, recZ ;
1101 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
1103 Double_t minDistance = 100. ;
1104 Int_t closestPrimary = -1 ;
1106 Int_t numberofprimaries ;
1107 Int_t * listofprimaries = recParticle->GetPrimaries(numberofprimaries) ;
1109 TParticle * primary ;
1110 Double_t distance = minDistance ;
1112 Double_t dXmin = 0.;
1113 Double_t dZmin = 0. ;
1114 for ( index = 0 ; index < numberofprimaries ; index++){
1115 primary = gAlice->Particle(listofprimaries[index]) ;
1116 Int_t moduleNumber ;
1117 Double_t primX, primZ ;
1118 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1119 if(moduleNumberRec == moduleNumber) {
1122 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
1123 if(minDistance > distance) {
1124 minDistance = distance ;
1127 closestPrimary = listofprimaries[index] ;
1133 if(closestPrimary >=0 ){
1136 Int_t primaryType = gAlice->Particle(closestPrimary)->GetPdgCode() ;
1137 // TParticlePDG* pDGparticle = gAlice->ParticleAt(closestPrimary)->GetPDG();
1138 // Double_t charge = PDGparticle->Charge() ;
1140 // cout <<"Primary " <<primaryType << " E " << ((TParticle *)primaryList->At(closestPrimary))->Energy() << endl ;
1145 primaryCode = 0; //Photon
1146 fhAllEnergy ->Fill(gAlice->Particle(closestPrimary)->Energy(), recParticle->Energy()) ;
1147 fhAllPosition ->Fill(gAlice->Particle(closestPrimary)->Energy(), minDistance) ;
1148 fhAllPositionX->Fill(dXmin);
1149 fhAllPositionZ->Fill(dZmin);
1152 primaryCode = 1; //Electron
1155 primaryCode = 1; //positron
1158 primaryCode = 4; //K+
1161 primaryCode = 4; //K-
1164 primaryCode = 4; //K0s
1167 primaryCode = 4; //K0l
1170 primaryCode = 2; //K0l
1173 primaryCode = 2; //K0l
1176 primaryCode = 2; //K0l
1179 primaryCode = 2; //K0l
1182 primaryCode = 3; //ELSE
1186 switch(recParticle->GetType())
1188 case AliPHOSFastRecParticle::kGAMMA:
1189 if(primaryType == 22){
1190 fhPhotEnergy->Fill(gAlice->Particle(closestPrimary)->Energy(), recParticle->Energy() ) ;
1191 fhEMEnergy->Fill(gAlice->Particle(closestPrimary)->Energy(), recParticle->Energy() ) ;
1192 fhPPSDEnergy->Fill(gAlice->Particle(closestPrimary)->Energy(), recParticle->Energy() ) ;
1194 fhPhotPosition->Fill(gAlice->Particle(closestPrimary)->Energy(),minDistance) ;
1195 fhEMPosition->Fill(gAlice->Particle(closestPrimary)->Energy(),minDistance) ;
1196 fhPPSDPosition->Fill(gAlice->Particle(closestPrimary)->Energy(),minDistance) ;
1198 fhPhotReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1199 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1200 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1202 fhPhotPhot->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1204 if(primaryType == 2112){ //neutron
1205 fhNReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1206 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1207 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1210 if(primaryType == -2112){ //neutron ~
1211 fhNBarReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1212 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1213 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1216 if(primaryCode == 2){
1217 fhChargedReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1218 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1219 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1222 fhAllReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1223 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1224 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1225 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1226 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1227 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1228 counter[0][primaryCode]++;
1230 case AliPHOSFastRecParticle::kELECTRON:
1231 if(primaryType == 22){
1232 fhPhotElec->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1233 fhEMEnergy->Fill(gAlice->Particle(closestPrimary)->Energy(), recParticle->Energy() ) ;
1234 fhEMPosition->Fill(gAlice->Particle(closestPrimary)->Energy(),minDistance) ;
1235 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1236 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1238 if(primaryType == 2112){ //neutron
1239 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1240 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1243 if(primaryType == -2112){ //neutron ~
1244 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1245 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1248 if(primaryCode == 2){
1249 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1250 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1253 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1254 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1255 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1256 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1257 counter[1][primaryCode]++;
1259 case AliPHOSFastRecParticle::kNEUTRALHA:
1260 if(primaryType == 22)
1261 fhPhotNeuH->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1263 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1264 counter[2][primaryCode]++;
1266 case AliPHOSFastRecParticle::kNEUTRALEM:
1267 if(primaryType == 22){
1268 fhEMEnergy->Fill(gAlice->Particle(closestPrimary)->Energy(),recParticle->Energy() ) ;
1269 fhEMPosition->Fill(gAlice->Particle(closestPrimary)->Energy(),minDistance ) ;
1271 fhPhotNuEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1272 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1274 if(primaryType == 2112) //neutron
1275 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1277 if(primaryType == -2112) //neutron ~
1278 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1280 if(primaryCode == 2)
1281 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1283 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1284 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1285 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1287 counter[3][primaryCode]++;
1289 case AliPHOSFastRecParticle::kCHARGEDHA:
1290 if(primaryType == 22) //photon
1291 fhPhotChHa->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1293 counter[4][primaryCode]++ ;
1295 case AliPHOSFastRecParticle::kGAMMAHA:
1296 if(primaryType == 22){ //photon
1297 fhPhotGaHa->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1298 fhPPSDEnergy->Fill(gAlice->Particle(closestPrimary)->Energy(), recParticle->Energy() ) ;
1299 fhPPSDPosition->Fill(gAlice->Particle(closestPrimary)->Energy(),minDistance) ;
1300 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1302 if(primaryType == 2112){ //neutron
1303 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1306 if(primaryType == -2112){ //neutron ~
1307 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1309 if(primaryCode == 2){
1310 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1313 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1314 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1315 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1316 counter[5][primaryCode]++ ;
1318 case AliPHOSFastRecParticle::kABSURDEM:
1319 counter[6][primaryCode]++ ;
1320 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1322 case AliPHOSFastRecParticle::kABSURDHA:
1323 counter[7][primaryCode]++ ;
1326 counter[8][primaryCode]++ ;
1333 cout << "Resolutions: Analyzed " << Nevents << " event(s)" << endl ;
1334 cout << "Resolutions: Total primary " << totalPrimary << endl ;
1335 cout << "Resoluitons: Total reconstracted " << totalRecPart << endl ;
1336 cout << "TotalReconstructed with Primarie " << totalRPwithPrim << endl ;
1337 cout << " Primary: Photon Electron Ch. Hadr. Neutr. Hadr Kaons" << endl ;
1338 cout << " Detected as photon " << counter[0][0] << " " << counter[0][1] << " " << counter[0][2] << " " <<counter[0][3] << " " << counter[0][4] << endl ;
1339 cout << " Detected as electron " << counter[1][0] << " " << counter[1][1] << " " << counter[1][2] << " " <<counter[1][3] << " " << counter[1][4] << endl ;
1340 cout << " Detected as neutral hadron " << counter[2][0] << " " << counter[2][1] << " " << counter[2][2] << " " <<counter[2][3] << " " << counter[2][4] << endl ;
1341 cout << " Detected as neutral EM " << counter[3][0] << " " << counter[3][1] << " " << counter[3][2] << " " <<counter[3][3] << " " << counter[3][4] << endl ;
1342 cout << " Detected as charged hadron " << counter[4][0] << " " << counter[4][1] << " " << counter[4][2] << " " <<counter[4][3] << " " << counter[4][4] << endl ;
1343 cout << " Detected as gamma-hadron " << counter[5][0] << " " << counter[5][1] << " " << counter[5][2] << " " <<counter[5][3] << " " << counter[5][4] << endl ;
1344 cout << " Detected as Absurd EM " << counter[6][0] << " " << counter[6][1] << " " << counter[6][2] << " " <<counter[6][3] << " " << counter[6][4] << endl ;
1345 cout << " Detected as absurd hadron " << counter[7][0] << " " << counter[7][1] << " " << counter[7][2] << " " <<counter[7][3] << " " << counter[7][4] << endl ;
1346 cout << " Detected as undefined " << counter[8][0] << " " << counter[8][1] << " " << counter[8][2] << " " <<counter[8][3] << " " << counter[8][4] << endl ;
1348 for(i1 = 0; i1<9; i1++)
1349 for(i2 = 0; i2<5; i2++)
1350 totalInd+=counter[i1][i2] ;
1351 cout << "Indentified particles " << totalInd << endl ;
1356 //____________________________________________________________________________
1357 void AliPHOSAnalyze::BookingHistograms()
1359 // Books the histograms where the results of the analysis are stored (to be changed)
1362 delete fhVetoDigit ;
1363 delete fhConvertorDigit ;
1364 delete fhEmcCluster ;
1365 delete fhVetoCluster ;
1366 delete fhConvertorCluster ;
1367 delete fhConvertorEmc ;
1369 fhEmcDigit = new TH1F("hEmcDigit", "hEmcDigit", 1000, 0. , 25.);
1370 fhVetoDigit = new TH1F("hVetoDigit", "hVetoDigit", 500, 0. , 3.e-5);
1371 fhConvertorDigit = new TH1F("hConvertorDigit","hConvertorDigit", 500, 0. , 3.e-5);
1372 fhEmcCluster = new TH1F("hEmcCluster", "hEmcCluster", 1000, 0. , 30.);
1373 fhVetoCluster = new TH1F("hVetoCluster", "hVetoCluster", 500, 0. , 3.e-5);
1374 fhConvertorCluster = new TH1F("hConvertorCluster","hConvertorCluster",500, 0. , 3.e-5);
1375 fhConvertorEmc = new TH2F("hConvertorEmc", "hConvertorEmc", 200, 1. , 3., 200, 0., 3.e-5);
1378 //____________________________________________________________________________
1379 void AliPHOSAnalyze::BookResolutionHistograms()
1381 // Books the histograms where the results of the Resolution analysis are stored
1384 // delete fhAllEnergy ;
1386 // delete fhPhotEnergy ;
1388 // delete fhEMEnergy ;
1390 // delete fhPPSDEnergy ;
1393 fhAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
1394 fhPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
1395 fhEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
1396 fhPPSDEnergy = new TH2F("hPPSDEnergy", "Energy of PPSD with primary photon", 100, 0., 5., 100, 0., 5.);
1398 // if(fhAllPosition)
1399 // delete fhAllPosition ;
1400 // if(fhPhotPosition)
1401 // delete fhPhotPosition ;
1403 // delete fhEMPosition ;
1404 // if(fhPPSDPosition)
1405 // delete fhPPSDPosition ;
1408 fhAllPosition = new TH2F("hAllPosition", "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
1409 fhPhotPosition = new TH2F("hPhotPosition", "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
1410 fhEMPosition = new TH2F("hEMPosition", "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
1411 fhPPSDPosition = new TH2F("hPPSDPosition", "Position of PPSD with primary photon", 100, 0., 5., 100, 0., 5.);
1413 fhAllPositionX = new TH1F("hAllPositionX", "#Delta X of any RP with primary photon",100, -2., 2.);
1414 fhAllPositionZ = new TH1F("hAllPositionZ", "#Delta X of any RP with primary photon",100, -2., 2.);
1417 // delete fhAllReg ;
1419 // delete fhPhotReg ;
1423 // delete fhNBarReg ;
1425 // delete fhChargedReg ;
1427 fhAllReg = new TH1F("hAllReg", "All primaries registered as photon", 100, 0., 5.);
1428 fhPhotReg = new TH1F("hPhotReg", "Photon registered as photon", 100, 0., 5.);
1429 fhNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
1430 fhNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
1431 fhChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
1436 // delete fhPhotEM ;
1440 // delete fhNBarEM ;
1442 // delete fhChargedEM ;
1444 fhAllEM = new TH1F("hAllEM", "All primary registered as EM",100, 0., 5.);
1445 fhPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
1446 fhNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
1447 fhNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
1448 fhChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
1451 // delete fhAllPPSD ;
1453 // delete fhPhotPPSD ;
1457 // delete fhNBarPPSD ;
1458 // if(fhChargedPPSD)
1459 // delete fhChargedPPSD ;
1461 fhAllPPSD = new TH1F("hAllPPSD", "All primary registered as PPSD",100, 0., 5.);
1462 fhPhotPPSD = new TH1F("hPhotPPSD", "Photon registered as PPSD", 100, 0., 5.);
1463 fhNPPSD = new TH1F("hNPPSD", "N registered as PPSD", 100, 0., 5.);
1464 fhNBarPPSD = new TH1F("hNBarPPSD", "NBar registered as PPSD", 100, 0., 5.);
1465 fhChargedPPSD= new TH1F("hChargedPPSD","Charged registered as PPSD",100, 0., 5.);
1468 // delete fhPrimary ;
1469 fhPrimary= new TH1F("hPrimary", "hPrimary", 100, 0., 5.);
1480 fhAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
1481 fhVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
1482 fhShape = new TH1F("hShape","All particles with EM shaower",100, 0., 5.);
1483 fhPPSD = new TH1F("hPPSD", "All PPSD photon particles", 100, 0., 5.);
1487 // delete fhPhotPhot ;
1489 // delete fhPhotElec ;
1491 // delete fhPhotNeuH ;
1493 // delete fhPhotNuEM ;
1495 // delete fhPhotChHa ;
1497 // delete fhPhotGaHa ;
1499 fhPhotPhot = new TH1F("hPhotPhot","hPhotPhot", 100, 0., 5.); //Photon registered as photon
1500 fhPhotElec = new TH1F("hPhotElec","hPhotElec", 100, 0., 5.); //Photon registered as Electron
1501 fhPhotNeuH = new TH1F("hPhotNeuH","hPhotNeuH", 100, 0., 5.); //Photon registered as Neutral Hadron
1502 fhPhotNuEM = new TH1F("hPhotNuEM","hPhotNuEM", 100, 0., 5.); //Photon registered as Neutral EM
1503 fhPhotChHa = new TH1F("hPhotChHa","hPhotChHa", 100, 0., 5.); //Photon registered as Charged Hadron
1504 fhPhotGaHa = new TH1F("hPhotGaHa","hPhotGaHa", 100, 0., 5.); //Photon registered as Gamma-Hadron
1507 //____________________________________________________________________________
1508 Bool_t AliPHOSAnalyze::OpenRootFile(Text_t * name)
1510 // Open the root file named "name"
1512 fRootFile = new TFile(name, "update") ;
1513 return fRootFile->IsOpen() ;
1516 //____________________________________________________________________________
1517 void AliPHOSAnalyze::SaveHistograms()
1519 // Saves the histograms in a root file named "name.analyzed"
1521 Text_t outputname[80] ;
1522 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
1523 TFile output(outputname,"RECREATE");
1527 fhAllEnergy->Write() ;
1529 fhPhotEnergy->Write() ;
1531 fhEMEnergy->Write() ;
1533 fhPPSDEnergy->Write() ;
1535 fhAllPosition->Write() ;
1537 fhAllPositionX->Write() ;
1539 fhAllPositionZ->Write() ;
1541 fhPhotPosition->Write() ;
1543 fhEMPosition->Write() ;
1545 fhPPSDPosition->Write() ;
1549 fhPhotReg->Write() ;
1553 fhNBarReg->Write() ;
1555 fhChargedReg->Write() ;
1565 fhChargedEM->Write() ;
1567 fhAllPPSD->Write() ;
1569 fhPhotPPSD->Write() ;
1573 fhNBarPPSD->Write() ;
1575 fhChargedPPSD->Write() ;
1577 fhPrimary->Write() ;
1587 fhPhotPhot->Write() ;
1589 fhPhotElec->Write() ;
1591 fhPhotNeuH->Write() ;
1593 fhPhotNuEM->Write() ;
1595 fhPhotNuEM->Write() ;
1597 fhPhotChHa->Write() ;
1599 fhPhotGaHa->Write() ;
1600 if(fhEnergyCorrelations)
1601 fhEnergyCorrelations->Write() ;
1606 //____________________________________________________________________________
1607 Float_t AliPHOSAnalyze::CorrectEnergy(Float_t ERecPart)
1609 return ERecPart/0.8783 ;
1612 //____________________________________________________________________________
1613 void AliPHOSAnalyze::ResetHistograms()
1615 fhEnergyCorrelations = 0 ; //Energy correlations between Eloss in Convertor and PPSD(2)
1617 fhEmcDigit = 0 ; // Histo of digit energies in the Emc
1618 fhVetoDigit = 0 ; // Histo of digit energies in the Veto
1619 fhConvertorDigit = 0 ; // Histo of digit energies in the Convertor
1620 fhEmcCluster = 0 ; // Histo of Cluster energies in Emc
1621 fhVetoCluster = 0 ; // Histo of Cluster energies in Veto
1622 fhConvertorCluster = 0 ; // Histo of Cluster energies in Convertor
1623 fhConvertorEmc = 0 ; // 2d Convertor versus Emc energies
1626 fhPhotEnergy = 0 ; // Total spectrum of detected photons
1627 fhEMEnergy = 0 ; // Spectrum of detected electrons with electron primary
1630 fhAllPositionX = 0 ;
1631 fhAllPositionZ = 0 ;
1632 fhPhotPosition = 0 ;
1634 fhPPSDPosition = 0 ;