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 * emcOccupancy = new TH2F("emcOccupancy","EMC RecPoints",64,-71.,71.,64,-71.,71.);
138 TH2F * ppsdUp = new TH2F("ppsdUp","PPSD Up digits", 128,-71.,71.,128,-71.,71.) ;
139 TH2F * ppsdUpCl = new TH2F("ppsdUpCl","PPSD Up RecPoints",128,-71.,71.,128,-71.,71.) ;
140 TH2F * ppsdLow = new TH2F("ppsdLow","PPSD Low digits", 128,-71.,71.,128,-71.,71.) ;
141 TH2F * ppsdLowCl = new TH2F("ppsdLowCl","PPSD Low RecPoints",128,-71.,71.,128,-71.,71.) ;
142 TH2F * nbar = new TH2F("nbar","Primary nbar", 64,-71.,71.,64,-71.,71.);
143 TH2F * phot = new TH2F("phot","Primary Photon", 64,-71.,71.,64,-71.,71.);
144 TH2F * charg = new TH2F("charg","Primary charged",64,-71.,71.,64,-71.,71.);
145 TH2F * recPhot = new TH2F("recPhot","RecParticles with primary Photon",64,-71.,71.,64,-71.,71.);
146 TH2F * recNbar = new TH2F("recNbar","RecParticles with primary Nbar", 64,-71.,71.,64,-71.,71.);
148 //========== Create the Clusterizer
149 fClu = new AliPHOSClusterizerv1() ;
151 fClu->SetEmcEnergyThreshold(0.05) ;
152 fClu->SetEmcClusteringThreshold(0.20) ;
153 fClu->SetPpsdEnergyThreshold (0.0000002) ;
154 fClu->SetPpsdClusteringThreshold(0.0000001) ;
155 fClu->SetLocalMaxCut(0.03) ;
156 fClu->SetCalibrationParameters(0., 0.00000001) ;
158 gAlice->GetEvent(Nevent);
160 TClonesArray * primaryList = gAlice->Particles();
162 TParticle * primary ;
164 for ( iPrimary = 0 ; iPrimary < primaryList->GetEntries() ; iPrimary++)
166 primary = (TParticle*)primaryList->At(iPrimary) ;
167 Int_t primaryType = primary->GetPdgCode() ;
168 if( (primaryType == 211)||(primaryType == -211)||(primaryType == 2212)||(primaryType == -2212) ) {
170 Double_t primX, primZ ;
171 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
172 if(moduleNumber==Nmod)
173 charg->Fill(primZ,primX,primary->Energy()) ;
175 if( primaryType == 22 ) {
177 Double_t primX, primZ ;
178 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
179 if(moduleNumber==Nmod)
180 phot->Fill(primZ,primX,primary->Energy()) ;
183 if( primaryType == -2112 ) {
185 Double_t primX, primZ ;
186 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
187 if(moduleNumber==Nmod)
188 nbar->Fill(primZ,primX,primary->Energy()) ;
193 fPHOS->SetTreeAddress() ;
195 gAlice->TreeD()->GetEvent(0) ;
196 gAlice->TreeR()->GetEvent(0) ;
198 TObjArray ** emcRecPoints = fPHOS->EmcRecPoints() ;
199 TObjArray ** ppsdRecPoints = fPHOS->PpsdRecPoints() ;
200 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
203 AliPHOSDigit * digit ;
205 for(iDigit = 0; iDigit < fPHOS->Digits()->GetEntries(); iDigit++)
207 digit = (AliPHOSDigit *) fPHOS->Digits()->At(iDigit) ;
209 fGeom->AbsToRelNumbering(digit->GetId(), relid) ;
211 fGeom->RelPosInModule(relid,x,z) ;
212 Float_t e = fClu->Calibrate(digit->GetAmp()) ;
214 if(relid[1]==0) //EMC
215 digitOccupancy->Fill(x,z,e) ;
216 if((relid[1]>0)&&(relid[1]<17))
217 ppsdUp->Fill(x,z,e) ;
219 ppsdLow->Fill(x,z,e) ;
226 for(irecp = 0; irecp < (*emcRecPoints)->GetEntries() ; irecp ++){
227 AliPHOSEmcRecPoint * emc= (AliPHOSEmcRecPoint*)(*emcRecPoints)->At(irecp) ;
228 if(emc->GetPHOSMod()==Nmod){
229 emc->GetLocalPosition(pos) ;
230 emcOccupancy->Fill(pos.X(),pos.Z(),emc->GetEnergy());
234 for(irecp = 0; irecp < (*ppsdRecPoints)->GetEntries() ; irecp ++){
235 AliPHOSPpsdRecPoint * ppsd= (AliPHOSPpsdRecPoint *)(*ppsdRecPoints)->At(irecp) ;
236 if(ppsd->GetPHOSMod()==Nmod){
237 ppsd->GetLocalPosition(pos) ;
239 ppsdUpCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
241 ppsdLowCl->Fill(pos.X(),pos.Z(),ppsd->GetEnergy());
245 AliPHOSRecParticle * recParticle ;
247 for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ )
249 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
251 Int_t moduleNumberRec ;
252 Double_t recX, recZ ;
253 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
254 if(moduleNumberRec == Nmod){
256 Double_t minDistance = 5. ;
257 Int_t closestPrimary = -1 ;
259 Int_t numberofprimaries ;
260 Int_t * listofprimaries = recParticle->GetPrimaries(numberofprimaries) ;
262 TParticle * primary ;
263 Double_t distance = minDistance ;
265 for ( index = 0 ; index < numberofprimaries ; index++){
266 primary = (TParticle*)primaryList->At(listofprimaries[index]) ;
268 Double_t primX, primZ ;
269 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
270 if(moduleNumberRec == moduleNumber)
271 distance = TMath::Sqrt((recX-primX)*(recX-primX)+(recZ-primZ)*(recZ-primZ) ) ;
272 if(minDistance > distance)
274 minDistance = distance ;
275 closestPrimary = listofprimaries[index] ;
279 if(closestPrimary >=0 ){
281 Int_t primaryType = ((TParticle *)primaryList->At(closestPrimary))->GetPdgCode() ;
284 recPhot->Fill(recZ,recX,recParticle->Energy()) ;
286 if(primaryType==-2112)
287 recNbar->Fill(recZ,recX,recParticle->Energy()) ;
293 digitOccupancy->Draw("box") ;
294 emcOccupancy->SetLineColor(2) ;
295 emcOccupancy->Draw("boxsame") ;
296 ppsdUp->SetLineColor(3) ;
297 ppsdUp->Draw("boxsame") ;
298 ppsdLow->SetLineColor(4) ;
299 ppsdLow->Draw("boxsame") ;
300 phot->SetLineColor(8) ;
301 phot->Draw("boxsame") ;
302 nbar->SetLineColor(6) ;
303 nbar->Draw("boxsame") ;
306 //____________________________________________________________________________
307 void AliPHOSAnalyze::Reconstruct(Int_t nevents,Int_t firstEvent )
310 // Performs reconstruction of EMC and CPV (GPS2, IHEP or MIXT)
311 // for events from FirstEvent to Nevents
314 for ( ievent=firstEvent; ievent<nevents; ievent++) {
315 if (ievent==firstEvent) {
316 cout << "Analyze > Starting Reconstructing " << endl ;
317 //========== Create the Clusterizer
318 fClu = new AliPHOSClusterizerv1() ;
319 fClu->SetEmcEnergyThreshold(0.05) ;
320 fClu->SetEmcClusteringThreshold(0.20) ;
321 fClu->SetLocalMaxCut(0.03) ;
322 if (strcmp(fGeom->GetName(),"GPS2") == 0 || strcmp(fGeom->GetName(),"MIXT") == 0) {
323 fClu->SetPpsdEnergyThreshold (0.0000002) ;
324 fClu->SetPpsdClusteringThreshold(0.0000001) ;
326 else if (strcmp(fGeom->GetName(),"IHEP") == 0 || strcmp(fGeom->GetName(),"MIXT") == 0) {
327 fClu->SetLocalMaxCutCPV(0.03) ;
328 fClu->SetLogWeightCutCPV(4.0) ;
329 fClu->SetCpvEnergyThreshold(0.09) ;
331 fClu->SetCalibrationParameters(0., 0.00000001) ;
333 //========== Creates the track segment maker
334 fTrs = new AliPHOSTrackSegmentMakerv1() ;
335 // fTrs->UnsetUnfoldFlag() ;
337 //========== Creates the particle identifier for GPS2 only
338 if (strcmp(fGeom->GetName(),"GPS2") == 0 || strcmp(fGeom->GetName(),"MIXT") == 0) {
339 fPID = new AliPHOSPIDv1() ;
340 fPID->SetShowerProfileCuts(0.3, 1.8, 0.3, 1.8 ) ;
343 //========== Creates the Reconstructioner
344 fRec = new AliPHOSReconstructioner(fClu, fTrs, fPID) ;
345 if (fDebugLevel != 0) fRec -> SetDebugReconstruction(kTRUE);
348 if (fDebugLevel != 0 ||
349 (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
350 cout << "======= Analyze ======> Event " << ievent+1 << endl ;
352 //=========== Connects the various Tree's for evt
353 Int_t tracks = gAlice->GetEvent(ievent);
355 fPHOS->Hit2Digit(tracks) ;
357 //=========== Do the reconstruction
358 fPHOS->Reconstruction(fRec);
362 if(fClu) {delete fClu ; fClu =0 ;}
363 if(fPID) {delete fPID ; fPID =0 ;}
364 if(fRec) {delete fRec ; fRec =0 ;}
365 if(fTrs) {delete fTrs ; fTrs =0 ;}
369 //-------------------------------------------------------------------------------------
370 void AliPHOSAnalyze::ReadAndPrintCPV(Int_t EvFirst, Int_t EvLast)
373 // Read and print generated and reconstructed hits in CPV
374 // for events from EvFirst to Nevent.
375 // If only EvFirst is defined, print only this one event.
376 // Author: Yuri Kharlov
380 if (EvFirst!=0 && EvLast==0) EvLast=EvFirst;
381 for ( Int_t ievent=EvFirst; ievent<=EvLast; ievent++) {
383 //========== Event Number>
384 cout << endl << "==== ReadAndPrintCPV ====> Event is " << ievent+1 << endl ;
386 //=========== Connects the various Tree's for evt
387 Int_t ntracks = gAlice->GetEvent(ievent);
389 //========== Creating branches ===================================
390 AliPHOSRecPoint::RecPointsList ** emcRecPoints = fPHOS->EmcRecPoints() ;
391 gAlice->TreeR()->SetBranchAddress( "PHOSEmcRP" , emcRecPoints ) ;
393 AliPHOSRecPoint::RecPointsList ** cpvRecPoints = fPHOS->PpsdRecPoints() ;
394 gAlice->TreeR()->SetBranchAddress( "PHOSPpsdRP", cpvRecPoints ) ;
396 // Read and print CPV hits
398 AliPHOSCPVModule cpvModule;
399 TClonesArray *cpvHits;
401 AliPHOSCPVHit *cpvHit;
406 for (Int_t itrack=0; itrack<ntracks; itrack++) {
407 //=========== Get the Hits Tree for the Primary track itrack
409 gAlice->TreeH()->GetEvent(itrack);
411 for (iModule=0; iModule < fGeom->GetNModules(); iModule++) {
412 cpvModule = fPHOS->GetCPVModule(iModule);
413 cpvHits = cpvModule.Hits();
414 nCPVhits = cpvHits->GetEntriesFast();
415 for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
417 cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
418 p = cpvHit->GetMomentum();
421 ipart = cpvHit->GetIpart();
422 printf("CPV hit in module %d: ",iModule+1);
423 printf(" p = (%f, %f, %f, %f) GeV,\n",
424 p.Px(),p.Py(),p.Pz(),p.Energy());
425 printf(" (X,Z) = (%8.4f, %8.4f) cm, ipart = %d\n",
431 // Read and print CPV reconstructed points
433 //=========== Gets the Reconstruction TTree
434 gAlice->TreeR()->GetEvent(0) ;
435 TIter nextRP(*fPHOS->PpsdRecPoints() ) ;
436 AliPHOSPpsdRecPoint *cpvRecPoint ;
437 Int_t nRecPoints = 0;
438 while( ( cpvRecPoint = (AliPHOSPpsdRecPoint *)nextRP() ) ) {
441 cpvRecPoint->GetLocalPosition(locpos);
442 Int_t phosModule = cpvRecPoint->GetPHOSMod();
443 printf("CPV recpoint in module %d: (X,Z) = (%f,%f) cm\n",
444 phosModule,locpos.X(),locpos.Z());
446 printf("This event has %d generated hits and %d reconstructed points\n",
447 nGenHits,nRecPoints);
451 //____________________________________________________________________________
452 void AliPHOSAnalyze::AnalyzeCPV(Int_t Nevents)
455 // Analyzes CPV characteristics
456 // Author: Yuri Kharlov
462 TH1F *hDx = new TH1F("hDx" ,"CPV x-resolution@reconstruction",100,-5. , 5.);
463 TH1F *hDz = new TH1F("hDz" ,"CPV z-resolution@reconstruction",100,-5. , 5.);
464 TH1F *hDr = new TH1F("hDr" ,"CPV r-resolution@reconstruction",100, 0. , 5.);
465 TH1S *hNrp = new TH1S("hNrp" ,"CPV rec.point multiplicity", 21,-0.5,20.5);
466 TH1S *hNrpX = new TH1S("hNrpX","CPV rec.point Phi-length" , 21,-0.5,20.5);
467 TH1S *hNrpZ = new TH1S("hNrpZ","CPV rec.point Z-length" , 21,-0.5,20.5);
469 cout << "Start CPV Analysis"<< endl ;
470 for ( Int_t ievent=0; ievent<Nevents; ievent++) {
472 //========== Event Number>
473 // if ( (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
474 cout << endl << "==== AnalyzeCPV ====> Event is " << ievent+1 << endl ;
476 //=========== Connects the various Tree's for evt
477 Int_t ntracks = gAlice->GetEvent(ievent);
479 //========== Creating branches ===================================
480 AliPHOSRecPoint::RecPointsList ** emcRecPoints = fPHOS->EmcRecPoints() ;
481 gAlice->TreeR()->SetBranchAddress( "PHOSEmcRP" , emcRecPoints ) ;
483 AliPHOSRecPoint::RecPointsList ** cpvRecPoints = fPHOS->PpsdRecPoints() ;
484 gAlice->TreeR()->SetBranchAddress( "PHOSPpsdRP", cpvRecPoints ) ;
486 // Create and fill arrays of hits for each CPV module
488 Int_t nOfModules = fGeom->GetNModules();
489 TClonesArray **hitsPerModule = new TClonesArray *[nOfModules];
491 for (iModule=0; iModule < nOfModules; iModule++)
492 hitsPerModule[iModule] = new TClonesArray("AliPHOSCPVHit",100);
494 AliPHOSCPVModule cpvModule;
495 TClonesArray *cpvHits;
497 AliPHOSCPVHit *cpvHit;
502 // First go through all primary tracks and fill the arrays
503 // of hits per each CPV module
505 for (Int_t itrack=0; itrack<ntracks; itrack++) {
506 // Get the Hits Tree for the Primary track itrack
508 gAlice->TreeH()->GetEvent(itrack);
509 for (Int_t iModule=0; iModule < nOfModules; iModule++) {
510 cpvModule = fPHOS->GetCPVModule(iModule);
511 cpvHits = cpvModule.Hits();
512 nCPVhits = cpvHits->GetEntriesFast();
513 for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
514 cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
515 p = cpvHit->GetMomentum();
516 xzgen[0] = cpvHit->X();
517 xzgen[1] = cpvHit->Y();
518 ipart = cpvHit->GetIpart();
519 TClonesArray &lhits = *(TClonesArray *)hitsPerModule[iModule];
520 new(lhits[hitsPerModule[iModule]->GetEntriesFast()]) AliPHOSCPVHit(*cpvHit);
525 for (iModule=0; iModule < nOfModules; iModule++) {
526 Int_t nsum = hitsPerModule[iModule]->GetEntriesFast();
527 printf("Module %d has %d hits\n",iModule,nsum);
530 // Then go through reconstructed points and for each find
532 // The distance from the rec.point to the closest hit
533 // gives the coordinate resolution of the CPV
535 // Get the Reconstruction Tree
536 gAlice->TreeR()->GetEvent(0) ;
537 TIter nextRP(*fPHOS->PpsdRecPoints() ) ;
538 AliPHOSCpvRecPoint *cpvRecPoint ;
540 while( ( cpvRecPoint = (AliPHOSCpvRecPoint *)nextRP() ) ) {
542 cpvRecPoint->GetLocalPosition(locpos);
543 Int_t phosModule = cpvRecPoint->GetPHOSMod();
544 Int_t rpMult = cpvRecPoint->GetDigitsMultiplicity();
545 Int_t rpMultX, rpMultZ;
546 cpvRecPoint->GetClusterLengths(rpMultX,rpMultZ);
547 Float_t xrec = locpos.X();
548 Float_t zrec = locpos.Z();
549 Float_t dxmin = 1.e+10;
550 Float_t dzmin = 1.e+10;
551 Float_t r2min = 1.e+10;
554 cpvHits = hitsPerModule[phosModule-1];
555 Int_t nCPVhits = cpvHits->GetEntriesFast();
556 for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
557 cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
560 r2 = TMath::Power((xgen-xrec),2) + TMath::Power((zgen-zrec),2);
569 hDr ->Fill(TMath::Sqrt(r2min));
571 hNrpX->Fill(rpMultX);
572 hNrpZ->Fill(rpMultZ);
574 delete [] hitsPerModule;
578 Text_t outputname[80] ;
579 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
580 TFile output(outputname,"RECREATE");
592 TCanvas *cpvCanvas = new TCanvas("CPV","CPV analysis",20,20,800,400);
593 gStyle->SetOptStat(111111);
594 gStyle->SetOptFit(1);
595 gStyle->SetOptDate(1);
596 cpvCanvas->Divide(3,2);
599 gPad->SetFillColor(10);
600 hNrp->SetFillColor(16);
604 gPad->SetFillColor(10);
605 hNrpX->SetFillColor(16);
609 gPad->SetFillColor(10);
610 hNrpZ->SetFillColor(16);
614 gPad->SetFillColor(10);
615 hDx->SetFillColor(16);
620 gPad->SetFillColor(10);
621 hDz->SetFillColor(16);
626 gPad->SetFillColor(10);
627 hDr->SetFillColor(16);
630 cpvCanvas->Print("CPV.ps");
634 //____________________________________________________________________________
635 void AliPHOSAnalyze::InvariantMass(Int_t Nevents )
637 // Calculates Real and Mixed invariant mass distributions
639 const Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
640 Int_t mixedLoops = (Int_t )TMath::Ceil(Nevents/nMixedEvents) ;
642 //========== Booking Histograms
643 TH2D * hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
644 TH2D * hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
645 TH2D * hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
646 TH2D * hMixedPhot= new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
649 Int_t eventInMixedLoop ;
651 Int_t nRecParticles[4];//nMixedEvents] ;
653 AliPHOSRecParticle::RecParticlesList * allRecParticleList = new TClonesArray("AliPHOSRecParticle", nMixedEvents*1000) ;
655 for(eventInMixedLoop = 0; eventInMixedLoop < mixedLoops; eventInMixedLoop++ ){
658 for ( ievent=0; ievent < nMixedEvents; ievent++){
660 Int_t absEventNumber = eventInMixedLoop*nMixedEvents + ievent ;
662 //=========== Connects the various Tree's for evt
663 gAlice->GetEvent(absEventNumber);
665 //========== Creating branches ===================================
666 fPHOS->SetTreeAddress() ;
668 gAlice->TreeD()->GetEvent(0) ;
669 gAlice->TreeR()->GetEvent(0) ;
671 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
674 AliPHOSRecParticle * recParticle ;
676 for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ )
678 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
679 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
680 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)){
681 new( (*allRecParticleList)[iRecPhot] ) AliPHOSRecParticle(*recParticle) ;
686 nRecParticles[ievent] = iRecPhot-1 ;
689 //Now calculate invariant mass:
691 Int_t nCurEvent = 0 ;
693 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
694 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
696 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
697 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
700 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
701 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
702 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
703 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
706 invMass = TMath::Sqrt(invMass);
709 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +(rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py()));
711 if(irp1 > nRecParticles[nCurEvent])
714 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
715 hRealEM->Fill(invMass,pt);
716 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&(rp2->GetType() == AliPHOSFastRecParticle::kGAMMA))
717 hRealPhot->Fill(invMass,pt);
720 hMixedEM->Fill(invMass,pt);
721 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&(rp2->GetType() == AliPHOSFastRecParticle::kGAMMA))
722 hMixedPhot->Fill(invMass,pt);
725 } //loop over second rp
726 }//loop over first rp
727 allRecParticleList->Delete() ;
730 delete allRecParticleList ;
733 TFile output("invmass.root","RECREATE");
739 hMixedPhot->Write() ;
746 //____________________________________________________________________________
747 void AliPHOSAnalyze::ReadAndPrintEMC(Int_t EvFirst, Int_t EvLast)
750 // Read and print generated and reconstructed hits in EMC
751 // for events from EvFirst to Nevent.
752 // If only EvFirst is defined, print only this one event.
753 // Author: Yuri Kharlov
757 if (EvFirst!=0 && EvLast==0) EvLast=EvFirst;
759 for (ievent=EvFirst; ievent<=EvLast; ievent++) {
761 //========== Event Number>
762 cout << endl << "==== ReadAndPrintEMC ====> Event is " << ievent+1 << endl ;
764 //=========== Connects the various Tree's for evt
765 Int_t ntracks = gAlice->GetEvent(ievent);
766 fPHOS->SetTreeAddress() ;
768 gAlice->TreeD()->GetEvent(0) ;
769 gAlice->TreeR()->GetEvent(0) ;
771 // Loop over reconstructed particles
773 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
774 AliPHOSRecParticle * recParticle ;
778 for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ ) {
779 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
780 Float_t recE = recParticle->Energy();
781 primList = recParticle->GetPrimaries(nPrimary);
782 Int_t moduleNumberRec ;
783 Double_t recX, recZ ;
784 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
785 printf("Rec point: module %d, (X,Z) = (%8.4f,%8.4f) cm, E = %.3f GeV, primary = %d\n",
786 moduleNumberRec,recX,recZ,recE,*primList);
789 // Read and print EMC hits from EMCn branches
791 AliPHOSCPVModule emcModule;
792 TClonesArray *emcHits;
794 AliPHOSCPVHit *emcHit;
797 Int_t ipart, primary;
799 for (Int_t itrack=0; itrack<ntracks; itrack++) {
800 //=========== Get the Hits Tree for the Primary track itrack
802 gAlice->TreeH()->GetEvent(itrack);
804 for (iModule=0; iModule < fGeom->GetNModules(); iModule++) {
805 emcModule = fPHOS->GetEMCModule(iModule);
806 emcHits = emcModule.Hits();
807 nEMChits = emcHits->GetEntriesFast();
808 for (Int_t ihit=0; ihit<nEMChits; ihit++) {
810 emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
811 p = emcHit->GetMomentum();
814 ipart = emcHit->GetIpart();
815 primary= emcHit->GetTrack();
816 printf("EMC hit A: module %d, ",iModule+1);
817 printf(" p = (%f .4, %f .4, %f .4, %f .4) GeV,\n",
818 p.Px(),p.Py(),p.Pz(),p.Energy());
819 printf(" (X,Z) = (%8.4f, %8.4f) cm, ipart = %d, primary = %d\n",
820 xgen,zgen,ipart,primary);
825 // // Read and print EMC hits from PHOS branch
827 // for (Int_t itrack=0; itrack<ntracks; itrack++) {
828 // //=========== Get the Hits Tree for the Primary track itrack
829 // gAlice->ResetHits();
830 // gAlice->TreeH()->GetEvent(itrack);
831 // TClonesArray *hits = fPHOS->Hits();
834 // for ( ihit = 0 ; ihit < hits->GetEntries() ; ihit++ ) {
835 // hit = (AliPHOSHit*)hits->At(ihit) ;
836 // Float_t hitXYZ[3];
837 // hitXYZ[0] = hit->X();
838 // hitXYZ[1] = hit->Y();
839 // hitXYZ[2] = hit->Z();
840 // ipart = hit->GetPid();
841 // primary = hit->GetPrimary();
842 // Int_t absId = hit->GetId();
844 // fGeom->AbsToRelNumbering(absId, relId) ;
845 // Int_t module = relId[0];
846 // if (relId[1]==0 && !(hitXYZ[0]==0 && hitXYZ[2]==0))
847 // printf("EMC hit B: module %d, (X,Z) = (%8.4f, %8.4f) cm, ipart = %d, primary = %d\n",
848 // module,hitXYZ[0],hitXYZ[2],ipart,primary);
855 //____________________________________________________________________________
856 void AliPHOSAnalyze::AnalyzeEMC(Int_t Nevents)
859 // Read generated and reconstructed hits in EMC for Nevents events.
860 // Plots the coordinate and energy resolution histograms.
861 // Coordinate resolution is a difference between the reconstructed
862 // coordinate and the exact coordinate on the face of the PHOS
863 // Author: Yuri Kharlov
869 TH1F *hDx1 = new TH1F("hDx1" ,"EMC x-resolution", 100,-5. , 5.);
870 TH1F *hDz1 = new TH1F("hDz1" ,"EMC z-resolution", 100,-5. , 5.);
871 TH1F *hDE1 = new TH1F("hDE1" ,"EMC E-resolution", 100,-2. , 2.);
873 TH2F *hDx2 = new TH2F("hDx2" ,"EMC x-resolution", 100, 0., 10., 100,-5. , 5.);
874 TH2F *hDz2 = new TH2F("hDz2" ,"EMC z-resolution", 100, 0., 10., 100,-5. , 5.);
875 TH2F *hDE2 = new TH2F("hDE2" ,"EMC E-resolution", 100, 0., 10., 100, 0. , 5.);
877 cout << "Start EMC Analysis"<< endl ;
878 for (Int_t ievent=0; ievent<Nevents; ievent++) {
880 //========== Event Number>
881 if ( (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
882 cout << "==== AnalyzeEMC ====> Event is " << ievent+1 << endl ;
884 //=========== Connects the various Tree's for evt
885 Int_t ntracks = gAlice->GetEvent(ievent);
887 fPHOS->SetTreeAddress() ;
889 gAlice->TreeD()->GetEvent(0) ;
890 gAlice->TreeR()->GetEvent(0) ;
892 // Create and fill arrays of hits for each EMC module
894 Int_t nOfModules = fGeom->GetNModules();
895 TClonesArray **hitsPerModule = new TClonesArray *[nOfModules];
897 for (iModule=0; iModule < nOfModules; iModule++)
898 hitsPerModule[iModule] = new TClonesArray("AliPHOSCPVHit",100);
900 AliPHOSCPVModule emcModule;
901 TClonesArray *emcHits;
903 AliPHOSCPVHit *emcHit;
905 // First go through all primary tracks and fill the arrays
906 // of hits per each EMC module
908 for (Int_t itrack=0; itrack<ntracks; itrack++) {
909 // Get the Hits Tree for the Primary track itrack
911 gAlice->TreeH()->GetEvent(itrack);
912 for (Int_t iModule=0; iModule < nOfModules; iModule++) {
913 emcModule = fPHOS->GetEMCModule(iModule);
914 emcHits = emcModule.Hits();
915 nEMChits = emcHits->GetEntriesFast();
916 for (Int_t ihit=0; ihit<nEMChits; ihit++) {
917 emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
918 TClonesArray &lhits = *(TClonesArray *)hitsPerModule[iModule];
919 new(lhits[hitsPerModule[iModule]->GetEntriesFast()]) AliPHOSCPVHit(*emcHit);
925 // Loop over reconstructed particles
927 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
928 AliPHOSRecParticle * recParticle ;
929 Int_t nEMCrecs = (*recParticleList)->GetEntries();
931 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(0) ;
932 Float_t recE = recParticle->Energy();
934 Double_t recX, recZ ;
935 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), phosModule, recX, recZ) ;
937 // for this rec.point take the hit list in the same PHOS module
939 emcHits = hitsPerModule[phosModule-1];
940 Int_t nEMChits = emcHits->GetEntriesFast();
942 Float_t genX, genZ, genE;
943 for (Int_t ihit=0; ihit<nEMChits; ihit++) {
944 emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
947 genE = emcHit->GetMomentum().E();
949 Float_t dx = recX - genX;
950 Float_t dz = recZ - genZ;
951 Float_t de = recE - genE;
955 hDx2 ->Fill(genE,dx);
956 hDz2 ->Fill(genE,dz);
957 hDE2 ->Fill(genE,recE);
960 delete [] hitsPerModule;
964 Text_t outputname[80] ;
965 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
966 TFile output(outputname,"RECREATE");
978 TCanvas *emcCanvas = new TCanvas("EMC","EMC analysis",20,20,700,300);
979 gStyle->SetOptStat(111111);
980 gStyle->SetOptFit(1);
981 gStyle->SetOptDate(1);
982 emcCanvas->Divide(3,1);
985 gPad->SetFillColor(10);
986 hDx1->SetFillColor(16);
990 gPad->SetFillColor(10);
991 hDz1->SetFillColor(16);
995 gPad->SetFillColor(10);
996 hDE1->SetFillColor(16);
999 emcCanvas->Print("EMC.ps");
1003 //____________________________________________________________________________
1004 void AliPHOSAnalyze::AnalyzeResolutions(Int_t Nevents )
1006 // analyzes Nevents events and calculate Energy and Position resolution as well as
1007 // probaility of correct indentifiing of the incident particle
1009 //========== Booking Histograms
1010 cout << "AnalyzeResolutions > " << "Booking Histograms" << endl ;
1011 BookResolutionHistograms();
1013 Int_t counter[9][5] ;
1014 Int_t i1,i2,totalInd = 0 ;
1015 for(i1 = 0; i1<9; i1++)
1016 for(i2 = 0; i2<5; i2++)
1017 counter[i1][i2] = 0 ;
1019 Int_t totalPrimary = 0 ;
1020 Int_t totalRecPart = 0 ;
1021 Int_t totalRPwithPrim = 0 ;
1024 cout << "Start Analysing"<< endl ;
1025 for ( ievent=0; ievent<Nevents; ievent++)
1028 //========== Event Number>
1029 // if ( ( log10((Float_t)(ievent+1)) - (Int_t)(log10((Float_t)(ievent+1))) ) == 0. )
1030 cout << "AnalyzeResolutions > " << "Event is " << ievent << endl ;
1032 //=========== Connects the various Tree's for evt
1033 gAlice->GetEvent(ievent);
1035 //=========== Gets the Kine TTree
1036 gAlice->TreeK()->GetEvent(0) ;
1038 //=========== Gets the list of Primari Particles
1039 TClonesArray * primaryList = gAlice->Particles();
1041 TParticle * primary ;
1043 for ( iPrimary = 0 ; iPrimary < primaryList->GetEntries() ; iPrimary++)
1045 primary = (TParticle*)primaryList->UncheckedAt(iPrimary) ;
1046 Int_t primaryType = primary->GetPdgCode() ;
1047 if( primaryType == 22 ) {
1048 Int_t moduleNumber ;
1049 Double_t primX, primZ ;
1050 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1052 fhPrimary->Fill(primary->Energy()) ;
1053 if(primary->Energy() > 0.3)
1059 fPHOS->SetTreeAddress() ;
1061 gAlice->TreeD()->GetEvent(0) ;
1062 gAlice->TreeR()->GetEvent(0) ;
1064 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
1066 AliPHOSRecParticle * recParticle ;
1067 Int_t iRecParticle ;
1068 for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ )
1070 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
1071 fhAllRP->Fill(CorrectEnergy(recParticle->Energy())) ;
1073 Int_t moduleNumberRec ;
1074 Double_t recX, recZ ;
1075 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
1077 Double_t minDistance = 100. ;
1078 Int_t closestPrimary = -1 ;
1080 Int_t numberofprimaries ;
1081 Int_t * listofprimaries = recParticle->GetPrimaries(numberofprimaries) ;
1083 TParticle * primary ;
1084 Double_t distance = minDistance ;
1086 Double_t dXmin = 0.;
1087 Double_t dZmin = 0. ;
1088 for ( index = 0 ; index < numberofprimaries ; index++){
1089 primary = (TParticle*)primaryList->UncheckedAt(listofprimaries[index]) ;
1090 Int_t moduleNumber ;
1091 Double_t primX, primZ ;
1092 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1093 if(moduleNumberRec == moduleNumber) {
1096 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
1097 if(minDistance > distance) {
1098 minDistance = distance ;
1101 closestPrimary = listofprimaries[index] ;
1107 if(closestPrimary >=0 ){
1110 Int_t primaryType = ((TParticle *)primaryList->At(closestPrimary))->GetPdgCode() ;
1111 // TParticlePDG* pDGparticle = ((TParticle *)primaryList->At(closestPrimary))->GetPDG();
1112 // Double_t charge = PDGparticle->Charge() ;
1114 // cout <<"Primary " <<primaryType << " E " << ((TParticle *)primaryList->At(closestPrimary))->Energy() << endl ;
1119 primaryCode = 0; //Photon
1120 fhAllEnergy ->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy()) ;
1121 fhAllPosition ->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), minDistance) ;
1122 fhAllPositionX->Fill(dXmin);
1123 fhAllPositionZ->Fill(dZmin);
1126 primaryCode = 1; //Electron
1129 primaryCode = 1; //positron
1132 primaryCode = 4; //K+
1135 primaryCode = 4; //K-
1138 primaryCode = 4; //K0s
1141 primaryCode = 4; //K0l
1144 primaryCode = 2; //K0l
1147 primaryCode = 2; //K0l
1150 primaryCode = 2; //K0l
1153 primaryCode = 2; //K0l
1156 primaryCode = 3; //ELSE
1160 switch(recParticle->GetType())
1162 case AliPHOSFastRecParticle::kGAMMA:
1163 if(primaryType == 22){
1164 fhPhotEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1165 fhEMEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1166 fhPPSDEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1168 fhPhotPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1169 fhEMPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1170 fhPPSDPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1172 fhPhotReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1173 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1174 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1176 fhPhotPhot->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1178 if(primaryType == 2112){ //neutron
1179 fhNReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1180 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1181 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1184 if(primaryType == -2112){ //neutron ~
1185 fhNBarReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1186 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1187 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1190 if(primaryCode == 2){
1191 fhChargedReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1192 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1193 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1196 fhAllReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1197 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1198 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1199 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1200 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1201 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1202 counter[0][primaryCode]++;
1204 case AliPHOSFastRecParticle::kELECTRON:
1205 if(primaryType == 22){
1206 fhPhotElec->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1207 fhEMEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1208 fhEMPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1209 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1210 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1212 if(primaryType == 2112){ //neutron
1213 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1214 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1217 if(primaryType == -2112){ //neutron ~
1218 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1219 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1222 if(primaryCode == 2){
1223 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1224 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1227 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1228 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1229 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1230 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1231 counter[1][primaryCode]++;
1233 case AliPHOSFastRecParticle::kNEUTRALHA:
1234 if(primaryType == 22)
1235 fhPhotNeuH->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1237 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1238 counter[2][primaryCode]++;
1240 case AliPHOSFastRecParticle::kNEUTRALEM:
1241 if(primaryType == 22){
1242 fhEMEnergy->Fill(((TParticle *)primaryList->At(closestPrimary))->Energy(),recParticle->Energy() ) ;
1243 fhEMPosition->Fill(((TParticle *)primaryList->At(closestPrimary))->Energy(),minDistance ) ;
1245 fhPhotNuEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1246 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1248 if(primaryType == 2112) //neutron
1249 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1251 if(primaryType == -2112) //neutron ~
1252 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1254 if(primaryCode == 2)
1255 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1257 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1258 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1259 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1261 counter[3][primaryCode]++;
1263 case AliPHOSFastRecParticle::kCHARGEDHA:
1264 if(primaryType == 22) //photon
1265 fhPhotChHa->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1267 counter[4][primaryCode]++ ;
1269 case AliPHOSFastRecParticle::kGAMMAHA:
1270 if(primaryType == 22){ //photon
1271 fhPhotGaHa->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1272 fhPPSDEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1273 fhPPSDPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1274 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1276 if(primaryType == 2112){ //neutron
1277 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1280 if(primaryType == -2112){ //neutron ~
1281 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1283 if(primaryCode == 2){
1284 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1287 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1288 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1289 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1290 counter[5][primaryCode]++ ;
1292 case AliPHOSFastRecParticle::kABSURDEM:
1293 counter[6][primaryCode]++ ;
1294 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1296 case AliPHOSFastRecParticle::kABSURDHA:
1297 counter[7][primaryCode]++ ;
1300 counter[8][primaryCode]++ ;
1307 cout << "Resolutions: Analyzed " << Nevents << " event(s)" << endl ;
1308 cout << "Resolutions: Total primary " << totalPrimary << endl ;
1309 cout << "Resoluitons: Total reconstracted " << totalRecPart << endl ;
1310 cout << "TotalReconstructed with Primarie " << totalRPwithPrim << endl ;
1311 cout << " Primary: Photon Electron Ch. Hadr. Neutr. Hadr Kaons" << endl ;
1312 cout << " Detected as photon " << counter[0][0] << " " << counter[0][1] << " " << counter[0][2] << " " <<counter[0][3] << " " << counter[0][4] << endl ;
1313 cout << " Detected as electron " << counter[1][0] << " " << counter[1][1] << " " << counter[1][2] << " " <<counter[1][3] << " " << counter[1][4] << endl ;
1314 cout << " Detected as neutral hadron " << counter[2][0] << " " << counter[2][1] << " " << counter[2][2] << " " <<counter[2][3] << " " << counter[2][4] << endl ;
1315 cout << " Detected as neutral EM " << counter[3][0] << " " << counter[3][1] << " " << counter[3][2] << " " <<counter[3][3] << " " << counter[3][4] << endl ;
1316 cout << " Detected as charged hadron " << counter[4][0] << " " << counter[4][1] << " " << counter[4][2] << " " <<counter[4][3] << " " << counter[4][4] << endl ;
1317 cout << " Detected as gamma-hadron " << counter[5][0] << " " << counter[5][1] << " " << counter[5][2] << " " <<counter[5][3] << " " << counter[5][4] << endl ;
1318 cout << " Detected as Absurd EM " << counter[6][0] << " " << counter[6][1] << " " << counter[6][2] << " " <<counter[6][3] << " " << counter[6][4] << endl ;
1319 cout << " Detected as absurd hadron " << counter[7][0] << " " << counter[7][1] << " " << counter[7][2] << " " <<counter[7][3] << " " << counter[7][4] << endl ;
1320 cout << " Detected as undefined " << counter[8][0] << " " << counter[8][1] << " " << counter[8][2] << " " <<counter[8][3] << " " << counter[8][4] << endl ;
1322 for(i1 = 0; i1<9; i1++)
1323 for(i2 = 0; i2<5; i2++)
1324 totalInd+=counter[i1][i2] ;
1325 cout << "Indentified particles " << totalInd << endl ;
1330 //____________________________________________________________________________
1331 void AliPHOSAnalyze::BookingHistograms()
1333 // Books the histograms where the results of the analysis are stored (to be changed)
1336 delete fhVetoDigit ;
1337 delete fhConvertorDigit ;
1338 delete fhEmcCluster ;
1339 delete fhVetoCluster ;
1340 delete fhConvertorCluster ;
1341 delete fhConvertorEmc ;
1343 fhEmcDigit = new TH1F("hEmcDigit", "hEmcDigit", 1000, 0. , 25.);
1344 fhVetoDigit = new TH1F("hVetoDigit", "hVetoDigit", 500, 0. , 3.e-5);
1345 fhConvertorDigit = new TH1F("hConvertorDigit","hConvertorDigit", 500, 0. , 3.e-5);
1346 fhEmcCluster = new TH1F("hEmcCluster", "hEmcCluster", 1000, 0. , 30.);
1347 fhVetoCluster = new TH1F("hVetoCluster", "hVetoCluster", 500, 0. , 3.e-5);
1348 fhConvertorCluster = new TH1F("hConvertorCluster","hConvertorCluster",500, 0. , 3.e-5);
1349 fhConvertorEmc = new TH2F("hConvertorEmc", "hConvertorEmc", 200, 1. , 3., 200, 0., 3.e-5);
1352 //____________________________________________________________________________
1353 void AliPHOSAnalyze::BookResolutionHistograms()
1355 // Books the histograms where the results of the Resolution analysis are stored
1358 // delete fhAllEnergy ;
1360 // delete fhPhotEnergy ;
1362 // delete fhEMEnergy ;
1364 // delete fhPPSDEnergy ;
1367 fhAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
1368 fhPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
1369 fhEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
1370 fhPPSDEnergy = new TH2F("hPPSDEnergy", "Energy of PPSD with primary photon", 100, 0., 5., 100, 0., 5.);
1372 // if(fhAllPosition)
1373 // delete fhAllPosition ;
1374 // if(fhPhotPosition)
1375 // delete fhPhotPosition ;
1377 // delete fhEMPosition ;
1378 // if(fhPPSDPosition)
1379 // delete fhPPSDPosition ;
1382 fhAllPosition = new TH2F("hAllPosition", "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
1383 fhPhotPosition = new TH2F("hPhotPosition", "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
1384 fhEMPosition = new TH2F("hEMPosition", "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
1385 fhPPSDPosition = new TH2F("hPPSDPosition", "Position of PPSD with primary photon", 100, 0., 5., 100, 0., 5.);
1387 fhAllPositionX = new TH1F("hAllPositionX", "#Delta X of any RP with primary photon",100, -2., 2.);
1388 fhAllPositionZ = new TH1F("hAllPositionZ", "#Delta X of any RP with primary photon",100, -2., 2.);
1391 // delete fhAllReg ;
1393 // delete fhPhotReg ;
1397 // delete fhNBarReg ;
1399 // delete fhChargedReg ;
1401 fhAllReg = new TH1F("hAllReg", "All primaries registered as photon", 100, 0., 5.);
1402 fhPhotReg = new TH1F("hPhotReg", "Photon registered as photon", 100, 0., 5.);
1403 fhNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
1404 fhNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
1405 fhChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
1410 // delete fhPhotEM ;
1414 // delete fhNBarEM ;
1416 // delete fhChargedEM ;
1418 fhAllEM = new TH1F("hAllEM", "All primary registered as EM",100, 0., 5.);
1419 fhPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
1420 fhNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
1421 fhNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
1422 fhChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
1425 // delete fhAllPPSD ;
1427 // delete fhPhotPPSD ;
1431 // delete fhNBarPPSD ;
1432 // if(fhChargedPPSD)
1433 // delete fhChargedPPSD ;
1435 fhAllPPSD = new TH1F("hAllPPSD", "All primary registered as PPSD",100, 0., 5.);
1436 fhPhotPPSD = new TH1F("hPhotPPSD", "Photon registered as PPSD", 100, 0., 5.);
1437 fhNPPSD = new TH1F("hNPPSD", "N registered as PPSD", 100, 0., 5.);
1438 fhNBarPPSD = new TH1F("hNBarPPSD", "NBar registered as PPSD", 100, 0., 5.);
1439 fhChargedPPSD= new TH1F("hChargedPPSD","Charged registered as PPSD",100, 0., 5.);
1442 // delete fhPrimary ;
1443 fhPrimary= new TH1F("hPrimary", "hPrimary", 100, 0., 5.);
1454 fhAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
1455 fhVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
1456 fhShape = new TH1F("hShape","All particles with EM shaower",100, 0., 5.);
1457 fhPPSD = new TH1F("hPPSD", "All PPSD photon particles", 100, 0., 5.);
1461 // delete fhPhotPhot ;
1463 // delete fhPhotElec ;
1465 // delete fhPhotNeuH ;
1467 // delete fhPhotNuEM ;
1469 // delete fhPhotChHa ;
1471 // delete fhPhotGaHa ;
1473 fhPhotPhot = new TH1F("hPhotPhot","hPhotPhot", 100, 0., 5.); //Photon registered as photon
1474 fhPhotElec = new TH1F("hPhotElec","hPhotElec", 100, 0., 5.); //Photon registered as Electron
1475 fhPhotNeuH = new TH1F("hPhotNeuH","hPhotNeuH", 100, 0., 5.); //Photon registered as Neutral Hadron
1476 fhPhotNuEM = new TH1F("hPhotNuEM","hPhotNuEM", 100, 0., 5.); //Photon registered as Neutral EM
1477 fhPhotChHa = new TH1F("hPhotChHa","hPhotChHa", 100, 0., 5.); //Photon registered as Charged Hadron
1478 fhPhotGaHa = new TH1F("hPhotGaHa","hPhotGaHa", 100, 0., 5.); //Photon registered as Gamma-Hadron
1481 //____________________________________________________________________________
1482 Bool_t AliPHOSAnalyze::OpenRootFile(Text_t * name)
1484 // Open the root file named "name"
1486 fRootFile = new TFile(name, "update") ;
1487 return fRootFile->IsOpen() ;
1490 //____________________________________________________________________________
1491 void AliPHOSAnalyze::SaveHistograms()
1493 // Saves the histograms in a root file named "name.analyzed"
1495 Text_t outputname[80] ;
1496 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
1497 TFile output(outputname,"RECREATE");
1501 fhAllEnergy->Write() ;
1503 fhPhotEnergy->Write() ;
1505 fhEMEnergy->Write() ;
1507 fhPPSDEnergy->Write() ;
1509 fhAllPosition->Write() ;
1511 fhAllPositionX->Write() ;
1513 fhAllPositionZ->Write() ;
1515 fhPhotPosition->Write() ;
1517 fhEMPosition->Write() ;
1519 fhPPSDPosition->Write() ;
1523 fhPhotReg->Write() ;
1527 fhNBarReg->Write() ;
1529 fhChargedReg->Write() ;
1539 fhChargedEM->Write() ;
1541 fhAllPPSD->Write() ;
1543 fhPhotPPSD->Write() ;
1547 fhNBarPPSD->Write() ;
1549 fhChargedPPSD->Write() ;
1551 fhPrimary->Write() ;
1561 fhPhotPhot->Write() ;
1563 fhPhotElec->Write() ;
1565 fhPhotNeuH->Write() ;
1567 fhPhotNuEM->Write() ;
1569 fhPhotNuEM->Write() ;
1571 fhPhotChHa->Write() ;
1573 fhPhotGaHa->Write() ;
1574 if(fhEnergyCorrelations)
1575 fhEnergyCorrelations->Write() ;
1580 //____________________________________________________________________________
1581 Float_t AliPHOSAnalyze::CorrectEnergy(Float_t ERecPart)
1583 return ERecPart/0.8783 ;
1586 //____________________________________________________________________________
1587 void AliPHOSAnalyze::ResetHistograms()
1589 fhEnergyCorrelations = 0 ; //Energy correlations between Eloss in Convertor and PPSD(2)
1591 fhEmcDigit = 0 ; // Histo of digit energies in the Emc
1592 fhVetoDigit = 0 ; // Histo of digit energies in the Veto
1593 fhConvertorDigit = 0 ; // Histo of digit energies in the Convertor
1594 fhEmcCluster = 0 ; // Histo of Cluster energies in Emc
1595 fhVetoCluster = 0 ; // Histo of Cluster energies in Veto
1596 fhConvertorCluster = 0 ; // Histo of Cluster energies in Convertor
1597 fhConvertorEmc = 0 ; // 2d Convertor versus Emc energies
1600 fhPhotEnergy = 0 ; // Total spectrum of detected photons
1601 fhEMEnergy = 0 ; // Spectrum of detected electrons with electron primary
1604 fhAllPositionX = 0 ;
1605 fhAllPositionZ = 0 ;
1606 fhPhotPosition = 0 ;
1608 fhPPSDPosition = 0 ;