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.2) ;
331 fClu->SetCalibrationParameters(0., 0.00000001) ;
333 //========== Creates the track segment maker
334 fTrs = new AliPHOSTrackSegmentMakerv1() ;
335 // fTrs->UnsetUnfoldFlag() ;
337 //========== Creates the particle identifier
338 fPID = new AliPHOSPIDv1() ;
339 fPID->SetShowerProfileCuts(0.3, 1.8, 0.3, 1.8 ) ;
341 //========== Creates the Reconstructioner
342 fRec = new AliPHOSReconstructioner(fClu, fTrs, fPID) ;
343 if (fDebugLevel != 0) fRec -> SetDebugReconstruction(kTRUE);
346 if (fDebugLevel != 0 ||
347 (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
348 cout << "======= Analyze ======> Event " << ievent+1 << endl ;
350 //=========== Connects the various Tree's for evt
351 Int_t tracks = gAlice->GetEvent(ievent);
353 fPHOS->Hit2Digit(tracks) ;
355 //=========== Do the reconstruction
356 fPHOS->Reconstruction(fRec);
360 if(fClu) {delete fClu ; fClu =0 ;}
361 if(fPID) {delete fPID ; fPID =0 ;}
362 if(fRec) {delete fRec ; fRec =0 ;}
363 if(fTrs) {delete fTrs ; fTrs =0 ;}
367 //-------------------------------------------------------------------------------------
368 void AliPHOSAnalyze::ReadAndPrintCPV(Int_t EvFirst, Int_t EvLast)
371 // // Read and print generated and reconstructed hits in CPV
372 // // for events from EvFirst to Nevent.
373 // // If only EvFirst is defined, print only this one event.
374 // // Author: Yuri Kharlov
375 // // 12 October 2000
378 // if (EvFirst!=0 && EvLast==0) EvLast=EvFirst;
379 // for ( Int_t ievent=EvFirst; ievent<=EvLast; ievent++) {
381 // //========== Event Number>
382 // cout << endl << "==== ReadAndPrintCPV ====> Event is " << ievent+1 << endl ;
384 // //=========== Connects the various Tree's for evt
385 // Int_t ntracks = gAlice->GetEvent(ievent);
387 // //========== Creating branches ===================================
388 // AliPHOSRecPoint::RecPointsList ** emcRecPoints = fPHOS->EmcRecPoints() ;
389 // gAlice->TreeR()->SetBranchAddress( "PHOSEmcRP" , emcRecPoints ) ;
391 // AliPHOSRecPoint::RecPointsList ** cpvRecPoints = fPHOS->PpsdRecPoints() ;
392 // gAlice->TreeR()->SetBranchAddress( "PHOSPpsdRP", cpvRecPoints ) ;
394 // // Read and print CPV hits
396 // AliPHOSCPVModule cpvModule;
397 // TClonesArray *cpvHits;
399 // AliPHOSCPVHit *cpvHit;
401 // Float_t xgen, zgen;
403 // Int_t nGenHits = 0;
404 // for (Int_t itrack=0; itrack<ntracks; itrack++) {
405 // //=========== Get the Hits Tree for the Primary track itrack
406 // gAlice->ResetHits();
407 // gAlice->TreeH()->GetEvent(itrack);
408 // Int_t iModule = 0 ;
409 // for (iModule=0; iModule < fGeom->GetNCPVModules(); iModule++) {
410 // cpvModule = fPHOS->GetCPVModule(iModule);
411 // cpvHits = cpvModule.Hits();
412 // nCPVhits = cpvHits->GetEntriesFast();
413 // for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
415 // cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
416 // p = cpvHit->GetMomentum();
417 // xgen = cpvHit->X();
418 // zgen = cpvHit->Y();
419 // ipart = cpvHit->GetIpart();
420 // printf("CPV hit in module %d: ",iModule+1);
421 // printf(" p = (%f, %f, %f, %f) GeV,\n",
422 // p.Px(),p.Py(),p.Pz(),p.Energy());
423 // printf(" (X,Z) = (%8.4f, %8.4f) cm, ipart = %d\n",
429 // // Read and print CPV reconstructed points
431 // //=========== Gets the Reconstruction TTree
432 // gAlice->TreeR()->GetEvent(0) ;
433 // printf("Recpoints: %d\n",(*fPHOS->CpvRecPoints())->GetEntries());
434 // TIter nextRP(*fPHOS->CpvRecPoints() ) ;
435 // AliPHOSCpvRecPoint *cpvRecPoint ;
436 // Int_t nRecPoints = 0;
437 // while( ( cpvRecPoint = (AliPHOSCpvRecPoint *)nextRP() ) ) {
440 // cpvRecPoint->GetLocalPosition(locpos);
441 // Int_t phosModule = cpvRecPoint->GetPHOSMod();
442 // printf("CPV recpoint in module %d: (X,Z) = (%f,%f) cm\n",
443 // phosModule,locpos.X(),locpos.Z());
445 // printf("This event has %d generated hits and %d reconstructed points\n",
446 // nGenHits,nRecPoints);
450 //____________________________________________________________________________
451 void AliPHOSAnalyze::AnalyzeCPV(Int_t Nevents)
454 // Analyzes CPV characteristics
455 // Author: Yuri Kharlov
461 TH1F *hDx = new TH1F("hDx" ,"CPV x-resolution@reconstruction",100,-5. , 5.);
462 TH1F *hDz = new TH1F("hDz" ,"CPV z-resolution@reconstruction",100,-5. , 5.);
463 TH1F *hDr = new TH1F("hDr" ,"CPV r-resolution@reconstruction",100, 0. , 5.);
464 TH1S *hNrp = new TH1S("hNrp" ,"CPV rec.point multiplicity", 21,-0.5,20.5);
465 TH1S *hNrpX = new TH1S("hNrpX","CPV rec.point Phi-length" , 21,-0.5,20.5);
466 TH1S *hNrpZ = new TH1S("hNrpZ","CPV rec.point Z-length" , 21,-0.5,20.5);
468 cout << "Start CPV Analysis"<< endl ;
469 for ( Int_t ievent=0; ievent<Nevents; ievent++) {
471 //========== Event Number>
472 // if ( (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
473 cout << endl << "==== AnalyzeCPV ====> Event is " << ievent+1 << endl ;
475 //=========== Connects the various Tree's for evt
476 Int_t ntracks = gAlice->GetEvent(ievent);
478 //========== Creating branches ===================================
479 AliPHOSRecPoint::RecPointsList ** emcRecPoints = fPHOS->EmcRecPoints() ;
480 gAlice->TreeR()->SetBranchAddress( "PHOSEmcRP" , emcRecPoints ) ;
482 AliPHOSRecPoint::RecPointsList ** cpvRecPoints = fPHOS->PpsdRecPoints() ;
483 gAlice->TreeR()->SetBranchAddress( "PHOSPpsdRP", cpvRecPoints ) ;
485 // Create and fill arrays of hits for each CPV module
487 Int_t nOfModules = fGeom->GetNModules();
488 TClonesArray **hitsPerModule = new TClonesArray *[nOfModules];
490 for (iModule=0; iModule < nOfModules; iModule++)
491 hitsPerModule[iModule] = new TClonesArray("AliPHOSCPVHit",100);
493 AliPHOSCPVModule cpvModule;
494 TClonesArray *cpvHits;
496 AliPHOSCPVHit *cpvHit;
501 // First go through all primary tracks and fill the arrays
502 // of hits per each CPV module
504 for (Int_t itrack=0; itrack<ntracks; itrack++) {
505 // Get the Hits Tree for the Primary track itrack
507 gAlice->TreeH()->GetEvent(itrack);
508 for (Int_t iModule=0; iModule < nOfModules; iModule++) {
509 cpvModule = fPHOS->GetCPVModule(iModule);
510 cpvHits = cpvModule.Hits();
511 nCPVhits = cpvHits->GetEntriesFast();
512 for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
513 cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
514 p = cpvHit->GetMomentum();
515 xzgen[0] = cpvHit->X();
516 xzgen[1] = cpvHit->Y();
517 ipart = cpvHit->GetIpart();
518 TClonesArray &lhits = *(TClonesArray *)hitsPerModule[iModule];
519 new(lhits[hitsPerModule[iModule]->GetEntriesFast()]) AliPHOSCPVHit(*cpvHit);
524 for (iModule=0; iModule < nOfModules; iModule++) {
525 Int_t nsum = hitsPerModule[iModule]->GetEntriesFast();
526 printf("Module %d has %d hits\n",iModule,nsum);
529 // Then go through reconstructed points and for each find
531 // The distance from the rec.point to the closest hit
532 // gives the coordinate resolution of the CPV
534 // Get the Reconstruction Tree
535 gAlice->TreeR()->GetEvent(0) ;
536 TIter nextRP(*fPHOS->PpsdRecPoints() ) ;
537 AliPHOSCpvRecPoint *cpvRecPoint ;
539 while( ( cpvRecPoint = (AliPHOSCpvRecPoint *)nextRP() ) ) {
541 cpvRecPoint->GetLocalPosition(locpos);
542 Int_t phosModule = cpvRecPoint->GetPHOSMod();
543 Int_t rpMult = cpvRecPoint->GetDigitsMultiplicity();
544 Int_t rpMultX, rpMultZ;
545 cpvRecPoint->GetClusterLengths(rpMultX,rpMultZ);
546 Float_t xrec = locpos.X();
547 Float_t zrec = locpos.Z();
548 Float_t dxmin = 1.e+10;
549 Float_t dzmin = 1.e+10;
550 Float_t r2min = 1.e+10;
553 cpvHits = hitsPerModule[phosModule-1];
554 Int_t nCPVhits = cpvHits->GetEntriesFast();
555 for (Int_t ihit=0; ihit<nCPVhits; ihit++) {
556 cpvHit = (AliPHOSCPVHit*)cpvHits->UncheckedAt(ihit);
559 r2 = TMath::Power((xgen-xrec),2) + TMath::Power((zgen-zrec),2);
568 hDr ->Fill(TMath::Sqrt(r2min));
570 hNrpX->Fill(rpMultX);
571 hNrpZ->Fill(rpMultZ);
573 delete [] hitsPerModule;
577 Text_t outputname[80] ;
578 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
579 TFile output(outputname,"RECREATE");
591 TCanvas *cpvCanvas = new TCanvas("CPV","CPV analysis",20,20,800,400);
592 gStyle->SetOptStat(111111);
593 gStyle->SetOptFit(1);
594 gStyle->SetOptDate(1);
595 cpvCanvas->Divide(3,2);
598 gPad->SetFillColor(10);
599 hNrp->SetFillColor(16);
603 gPad->SetFillColor(10);
604 hNrpX->SetFillColor(16);
608 gPad->SetFillColor(10);
609 hNrpZ->SetFillColor(16);
613 gPad->SetFillColor(10);
614 hDx->SetFillColor(16);
619 gPad->SetFillColor(10);
620 hDz->SetFillColor(16);
625 gPad->SetFillColor(10);
626 hDr->SetFillColor(16);
629 cpvCanvas->Print("CPV.ps");
633 //____________________________________________________________________________
634 void AliPHOSAnalyze::InvariantMass(Int_t Nevents )
636 // Calculates Real and Mixed invariant mass distributions
638 const Int_t nMixedEvents = 4 ; //# of events used for calculation of 'mixed' distribution
639 Int_t mixedLoops = (Int_t )TMath::Ceil(Nevents/nMixedEvents) ;
641 //========== Booking Histograms
642 TH2D * hRealEM = new TH2D("hRealEM", "Real for EM particles", 250,0.,1.,40,0.,4.) ;
643 TH2D * hRealPhot = new TH2D("hRealPhot", "Real for kPhoton particles", 250,0.,1.,40,0.,4.) ;
644 TH2D * hMixedEM = new TH2D("hMixedEM", "Mixed for EM particles", 250,0.,1.,40,0.,4.) ;
645 TH2D * hMixedPhot= new TH2D("hMixedPhot","Mixed for kPhoton particles",250,0.,1.,40,0.,4.) ;
648 Int_t eventInMixedLoop ;
650 Int_t nRecParticles[4];//nMixedEvents] ;
652 AliPHOSRecParticle::RecParticlesList * allRecParticleList = new TClonesArray("AliPHOSRecParticle", nMixedEvents*1000) ;
654 for(eventInMixedLoop = 0; eventInMixedLoop < mixedLoops; eventInMixedLoop++ ){
657 for ( ievent=0; ievent < nMixedEvents; ievent++){
659 Int_t absEventNumber = eventInMixedLoop*nMixedEvents + ievent ;
661 //=========== Connects the various Tree's for evt
662 gAlice->GetEvent(absEventNumber);
664 //========== Creating branches ===================================
665 fPHOS->SetTreeAddress() ;
667 gAlice->TreeD()->GetEvent(0) ;
668 gAlice->TreeR()->GetEvent(0) ;
670 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
673 AliPHOSRecParticle * recParticle ;
675 for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ )
677 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
678 if((recParticle->GetType() == AliPHOSFastRecParticle::kGAMMA)||
679 (recParticle->GetType() == AliPHOSFastRecParticle::kNEUTRALEM)){
680 new( (*allRecParticleList)[iRecPhot] ) AliPHOSRecParticle(*recParticle) ;
685 nRecParticles[ievent] = iRecPhot-1 ;
688 //Now calculate invariant mass:
690 Int_t nCurEvent = 0 ;
692 for(irp1 = 0; irp1 < allRecParticleList->GetEntries()-1; irp1++){
693 AliPHOSRecParticle * rp1 = (AliPHOSRecParticle *)allRecParticleList->At(irp1) ;
695 for(irp2 = irp1+1; irp2 < allRecParticleList->GetEntries(); irp2++){
696 AliPHOSRecParticle * rp2 = (AliPHOSRecParticle *)allRecParticleList->At(irp2) ;
699 invMass = (rp1->Energy()+rp2->Energy())*(rp1->Energy()+rp2->Energy())-
700 (rp1->Px()+rp2->Px())*(rp1->Px()+rp2->Px())-
701 (rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py())-
702 (rp1->Pz()+rp2->Pz())*(rp1->Pz()+rp2->Pz()) ;
705 invMass = TMath::Sqrt(invMass);
708 pt = TMath::Sqrt((rp1->Px()+rp2->Px() )*( rp1->Px()+rp2->Px() ) +(rp1->Py()+rp2->Py())*(rp1->Py()+rp2->Py()));
710 if(irp1 > nRecParticles[nCurEvent])
713 if(irp2 <= nRecParticles[nCurEvent]){ //'Real' event
714 hRealEM->Fill(invMass,pt);
715 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&(rp2->GetType() == AliPHOSFastRecParticle::kGAMMA))
716 hRealPhot->Fill(invMass,pt);
719 hMixedEM->Fill(invMass,pt);
720 if((rp1->GetType() == AliPHOSFastRecParticle::kGAMMA)&&(rp2->GetType() == AliPHOSFastRecParticle::kGAMMA))
721 hMixedPhot->Fill(invMass,pt);
724 } //loop over second rp
725 }//loop over first rp
726 allRecParticleList->Delete() ;
729 delete allRecParticleList ;
732 TFile output("invmass.root","RECREATE");
738 hMixedPhot->Write() ;
745 //____________________________________________________________________________
746 void AliPHOSAnalyze::ReadAndPrintEMC(Int_t EvFirst, Int_t EvLast)
749 // Read and print generated and reconstructed hits in EMC
750 // for events from EvFirst to Nevent.
751 // If only EvFirst is defined, print only this one event.
752 // Author: Yuri Kharlov
756 if (EvFirst!=0 && EvLast==0) EvLast=EvFirst;
758 for (ievent=EvFirst; ievent<=EvLast; ievent++) {
760 //========== Event Number>
761 cout << endl << "==== ReadAndPrintEMC ====> Event is " << ievent+1 << endl ;
763 //=========== Connects the various Tree's for evt
764 Int_t ntracks = gAlice->GetEvent(ievent);
765 fPHOS->SetTreeAddress() ;
767 gAlice->TreeD()->GetEvent(0) ;
768 gAlice->TreeR()->GetEvent(0) ;
770 // Loop over reconstructed particles
772 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
773 AliPHOSRecParticle * recParticle ;
777 for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ ) {
778 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
779 Float_t recE = recParticle->Energy();
780 primList = recParticle->GetPrimaries(nPrimary);
781 Int_t moduleNumberRec ;
782 Double_t recX, recZ ;
783 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
784 printf("Rec point: module %d, (X,Z) = (%8.4f,%8.4f) cm, E = %.3f GeV, primary = %d\n",
785 moduleNumberRec,recX,recZ,recE,*primList);
788 // Read and print EMC hits from EMCn branches
790 AliPHOSCPVModule emcModule;
791 TClonesArray *emcHits;
793 AliPHOSCPVHit *emcHit;
796 Int_t ipart, primary;
798 for (Int_t itrack=0; itrack<ntracks; itrack++) {
799 //=========== Get the Hits Tree for the Primary track itrack
801 gAlice->TreeH()->GetEvent(itrack);
803 for (iModule=0; iModule < fGeom->GetNModules(); iModule++) {
804 emcModule = fPHOS->GetEMCModule(iModule);
805 emcHits = emcModule.Hits();
806 nEMChits = emcHits->GetEntriesFast();
807 for (Int_t ihit=0; ihit<nEMChits; ihit++) {
809 emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
810 p = emcHit->GetMomentum();
813 ipart = emcHit->GetIpart();
814 primary= emcHit->GetTrack();
815 printf("EMC hit A: module %d, ",iModule+1);
816 printf(" p = (%f .4, %f .4, %f .4, %f .4) GeV,\n",
817 p.Px(),p.Py(),p.Pz(),p.Energy());
818 printf(" (X,Z) = (%8.4f, %8.4f) cm, ipart = %d, primary = %d\n",
819 xgen,zgen,ipart,primary);
824 // // Read and print EMC hits from PHOS branch
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 // TClonesArray *hits = fPHOS->Hits();
833 // for ( ihit = 0 ; ihit < hits->GetEntries() ; ihit++ ) {
834 // hit = (AliPHOSHit*)hits->At(ihit) ;
835 // Float_t hitXYZ[3];
836 // hitXYZ[0] = hit->X();
837 // hitXYZ[1] = hit->Y();
838 // hitXYZ[2] = hit->Z();
839 // ipart = hit->GetPid();
840 // primary = hit->GetPrimary();
841 // Int_t absId = hit->GetId();
843 // fGeom->AbsToRelNumbering(absId, relId) ;
844 // Int_t module = relId[0];
845 // if (relId[1]==0 && !(hitXYZ[0]==0 && hitXYZ[2]==0))
846 // printf("EMC hit B: module %d, (X,Z) = (%8.4f, %8.4f) cm, ipart = %d, primary = %d\n",
847 // module,hitXYZ[0],hitXYZ[2],ipart,primary);
854 //____________________________________________________________________________
855 void AliPHOSAnalyze::AnalyzeEMC(Int_t Nevents)
858 // Read generated and reconstructed hits in EMC for Nevents events.
859 // Plots the coordinate and energy resolution histograms.
860 // Coordinate resolution is a difference between the reconstructed
861 // coordinate and the exact coordinate on the face of the PHOS
862 // Author: Yuri Kharlov
868 TH1F *hDx1 = new TH1F("hDx1" ,"EMC x-resolution", 100,-5. , 5.);
869 TH1F *hDz1 = new TH1F("hDz1" ,"EMC z-resolution", 100,-5. , 5.);
870 TH1F *hDE1 = new TH1F("hDE1" ,"EMC E-resolution", 100,-2. , 2.);
872 TH2F *hDx2 = new TH2F("hDx2" ,"EMC x-resolution", 100, 0., 10., 100,-5. , 5.);
873 TH2F *hDz2 = new TH2F("hDz2" ,"EMC z-resolution", 100, 0., 10., 100,-5. , 5.);
874 TH2F *hDE2 = new TH2F("hDE2" ,"EMC E-resolution", 100, 0., 10., 100, 0. , 5.);
876 cout << "Start EMC Analysis"<< endl ;
877 for (Int_t ievent=0; ievent<Nevents; ievent++) {
879 //========== Event Number>
880 if ( (ievent+1) % (Int_t)TMath::Power( 10, (Int_t)TMath::Log10(ievent+1) ) == 0)
881 cout << "==== AnalyzeEMC ====> Event is " << ievent+1 << endl ;
883 //=========== Connects the various Tree's for evt
884 Int_t ntracks = gAlice->GetEvent(ievent);
886 fPHOS->SetTreeAddress() ;
888 gAlice->TreeD()->GetEvent(0) ;
889 gAlice->TreeR()->GetEvent(0) ;
891 // Create and fill arrays of hits for each EMC module
893 Int_t nOfModules = fGeom->GetNModules();
894 TClonesArray **hitsPerModule = new TClonesArray *[nOfModules];
896 for (iModule=0; iModule < nOfModules; iModule++)
897 hitsPerModule[iModule] = new TClonesArray("AliPHOSCPVHit",100);
899 AliPHOSCPVModule emcModule;
900 TClonesArray *emcHits;
902 AliPHOSCPVHit *emcHit;
904 // First go through all primary tracks and fill the arrays
905 // of hits per each EMC module
907 for (Int_t itrack=0; itrack<ntracks; itrack++) {
908 // Get the Hits Tree for the Primary track itrack
910 gAlice->TreeH()->GetEvent(itrack);
911 for (Int_t iModule=0; iModule < nOfModules; iModule++) {
912 emcModule = fPHOS->GetEMCModule(iModule);
913 emcHits = emcModule.Hits();
914 nEMChits = emcHits->GetEntriesFast();
915 for (Int_t ihit=0; ihit<nEMChits; ihit++) {
916 emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
917 TClonesArray &lhits = *(TClonesArray *)hitsPerModule[iModule];
918 new(lhits[hitsPerModule[iModule]->GetEntriesFast()]) AliPHOSCPVHit(*emcHit);
924 // Loop over reconstructed particles
926 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
927 AliPHOSRecParticle * recParticle ;
928 Int_t nEMCrecs = (*recParticleList)->GetEntries();
930 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(0) ;
931 Float_t recE = recParticle->Energy();
933 Double_t recX, recZ ;
934 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), phosModule, recX, recZ) ;
936 // for this rec.point take the hit list in the same PHOS module
938 emcHits = hitsPerModule[phosModule-1];
939 Int_t nEMChits = emcHits->GetEntriesFast();
941 Float_t genX, genZ, genE;
942 for (Int_t ihit=0; ihit<nEMChits; ihit++) {
943 emcHit = (AliPHOSCPVHit*)emcHits->UncheckedAt(ihit);
946 genE = emcHit->GetMomentum().E();
948 Float_t dx = recX - genX;
949 Float_t dz = recZ - genZ;
950 Float_t de = recE - genE;
954 hDx2 ->Fill(genE,dx);
955 hDz2 ->Fill(genE,dz);
956 hDE2 ->Fill(genE,recE);
959 delete [] hitsPerModule;
963 Text_t outputname[80] ;
964 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
965 TFile output(outputname,"RECREATE");
977 TCanvas *emcCanvas = new TCanvas("EMC","EMC analysis",20,20,700,300);
978 gStyle->SetOptStat(111111);
979 gStyle->SetOptFit(1);
980 gStyle->SetOptDate(1);
981 emcCanvas->Divide(3,1);
984 gPad->SetFillColor(10);
985 hDx1->SetFillColor(16);
989 gPad->SetFillColor(10);
990 hDz1->SetFillColor(16);
994 gPad->SetFillColor(10);
995 hDE1->SetFillColor(16);
998 emcCanvas->Print("EMC.ps");
1002 //____________________________________________________________________________
1003 void AliPHOSAnalyze::AnalyzeResolutions(Int_t Nevents )
1005 // analyzes Nevents events and calculate Energy and Position resolution as well as
1006 // probaility of correct indentifiing of the incident particle
1008 //========== Booking Histograms
1009 cout << "AnalyzeResolutions > " << "Booking Histograms" << endl ;
1010 BookResolutionHistograms();
1012 Int_t counter[9][5] ;
1013 Int_t i1,i2,totalInd = 0 ;
1014 for(i1 = 0; i1<9; i1++)
1015 for(i2 = 0; i2<5; i2++)
1016 counter[i1][i2] = 0 ;
1018 Int_t totalPrimary = 0 ;
1019 Int_t totalRecPart = 0 ;
1020 Int_t totalRPwithPrim = 0 ;
1023 cout << "Start Analysing"<< endl ;
1024 for ( ievent=0; ievent<Nevents; ievent++)
1027 //========== Event Number>
1028 // if ( ( log10((Float_t)(ievent+1)) - (Int_t)(log10((Float_t)(ievent+1))) ) == 0. )
1029 cout << "AnalyzeResolutions > " << "Event is " << ievent << endl ;
1031 //=========== Connects the various Tree's for evt
1032 gAlice->GetEvent(ievent);
1034 //=========== Gets the Kine TTree
1035 gAlice->TreeK()->GetEvent(0) ;
1037 //=========== Gets the list of Primari Particles
1038 TClonesArray * primaryList = gAlice->Particles();
1040 TParticle * primary ;
1042 for ( iPrimary = 0 ; iPrimary < primaryList->GetEntries() ; iPrimary++)
1044 primary = (TParticle*)primaryList->UncheckedAt(iPrimary) ;
1045 Int_t primaryType = primary->GetPdgCode() ;
1046 if( primaryType == 22 ) {
1047 Int_t moduleNumber ;
1048 Double_t primX, primZ ;
1049 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1051 fhPrimary->Fill(primary->Energy()) ;
1052 if(primary->Energy() > 0.3)
1058 fPHOS->SetTreeAddress() ;
1060 gAlice->TreeD()->GetEvent(0) ;
1061 gAlice->TreeR()->GetEvent(0) ;
1063 TClonesArray ** recParticleList = fPHOS->RecParticles() ;
1065 AliPHOSRecParticle * recParticle ;
1066 Int_t iRecParticle ;
1067 for(iRecParticle = 0; iRecParticle < (*recParticleList)->GetEntries() ;iRecParticle++ )
1069 recParticle = (AliPHOSRecParticle *) (*recParticleList)->At(iRecParticle) ;
1070 fhAllRP->Fill(CorrectEnergy(recParticle->Energy())) ;
1072 Int_t moduleNumberRec ;
1073 Double_t recX, recZ ;
1074 fGeom->ImpactOnEmc(recParticle->Theta(), recParticle->Phi(), moduleNumberRec, recX, recZ) ;
1076 Double_t minDistance = 100. ;
1077 Int_t closestPrimary = -1 ;
1079 Int_t numberofprimaries ;
1080 Int_t * listofprimaries = recParticle->GetPrimaries(numberofprimaries) ;
1082 TParticle * primary ;
1083 Double_t distance = minDistance ;
1085 Double_t dXmin = 0.;
1086 Double_t dZmin = 0. ;
1087 for ( index = 0 ; index < numberofprimaries ; index++){
1088 primary = (TParticle*)primaryList->UncheckedAt(listofprimaries[index]) ;
1089 Int_t moduleNumber ;
1090 Double_t primX, primZ ;
1091 fGeom->ImpactOnEmc(primary->Theta(), primary->Phi(), moduleNumber, primX, primZ) ;
1092 if(moduleNumberRec == moduleNumber) {
1095 distance = TMath::Sqrt(dX*dX + dZ*dZ) ;
1096 if(minDistance > distance) {
1097 minDistance = distance ;
1100 closestPrimary = listofprimaries[index] ;
1106 if(closestPrimary >=0 ){
1109 Int_t primaryType = ((TParticle *)primaryList->At(closestPrimary))->GetPdgCode() ;
1110 // TParticlePDG* pDGparticle = ((TParticle *)primaryList->At(closestPrimary))->GetPDG();
1111 // Double_t charge = PDGparticle->Charge() ;
1113 // cout <<"Primary " <<primaryType << " E " << ((TParticle *)primaryList->At(closestPrimary))->Energy() << endl ;
1118 primaryCode = 0; //Photon
1119 fhAllEnergy ->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy()) ;
1120 fhAllPosition ->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), minDistance) ;
1121 fhAllPositionX->Fill(dXmin);
1122 fhAllPositionZ->Fill(dZmin);
1125 primaryCode = 1; //Electron
1128 primaryCode = 1; //positron
1131 primaryCode = 4; //K+
1134 primaryCode = 4; //K-
1137 primaryCode = 4; //K0s
1140 primaryCode = 4; //K0l
1143 primaryCode = 2; //K0l
1146 primaryCode = 2; //K0l
1149 primaryCode = 2; //K0l
1152 primaryCode = 2; //K0l
1155 primaryCode = 3; //ELSE
1159 switch(recParticle->GetType())
1161 case AliPHOSFastRecParticle::kGAMMA:
1162 if(primaryType == 22){
1163 fhPhotEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1164 fhEMEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1165 fhPPSDEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1167 fhPhotPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1168 fhEMPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1169 fhPPSDPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1171 fhPhotReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1172 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1173 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1175 fhPhotPhot->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1177 if(primaryType == 2112){ //neutron
1178 fhNReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1179 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1180 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1183 if(primaryType == -2112){ //neutron ~
1184 fhNBarReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1185 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1186 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1189 if(primaryCode == 2){
1190 fhChargedReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1191 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1192 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1195 fhAllReg->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1196 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1197 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1198 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1199 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1200 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1201 counter[0][primaryCode]++;
1203 case AliPHOSFastRecParticle::kELECTRON:
1204 if(primaryType == 22){
1205 fhPhotElec->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1206 fhEMEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1207 fhEMPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1208 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1209 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1211 if(primaryType == 2112){ //neutron
1212 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1213 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1216 if(primaryType == -2112){ //neutron ~
1217 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1218 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1221 if(primaryCode == 2){
1222 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1223 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1226 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1227 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1228 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1229 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1230 counter[1][primaryCode]++;
1232 case AliPHOSFastRecParticle::kNEUTRALHA:
1233 if(primaryType == 22)
1234 fhPhotNeuH->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1236 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1237 counter[2][primaryCode]++;
1239 case AliPHOSFastRecParticle::kNEUTRALEM:
1240 if(primaryType == 22){
1241 fhEMEnergy->Fill(((TParticle *)primaryList->At(closestPrimary))->Energy(),recParticle->Energy() ) ;
1242 fhEMPosition->Fill(((TParticle *)primaryList->At(closestPrimary))->Energy(),minDistance ) ;
1244 fhPhotNuEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1245 fhPhotEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1247 if(primaryType == 2112) //neutron
1248 fhNEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1250 if(primaryType == -2112) //neutron ~
1251 fhNBarEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1253 if(primaryCode == 2)
1254 fhChargedEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1256 fhAllEM->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1257 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1258 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1260 counter[3][primaryCode]++;
1262 case AliPHOSFastRecParticle::kCHARGEDHA:
1263 if(primaryType == 22) //photon
1264 fhPhotChHa->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1266 counter[4][primaryCode]++ ;
1268 case AliPHOSFastRecParticle::kGAMMAHA:
1269 if(primaryType == 22){ //photon
1270 fhPhotGaHa->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1271 fhPPSDEnergy->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(), recParticle->Energy() ) ;
1272 fhPPSDPosition->Fill(((TParticle *) primaryList->At(closestPrimary))->Energy(),minDistance) ;
1273 fhPhotPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1275 if(primaryType == 2112){ //neutron
1276 fhNPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1279 if(primaryType == -2112){ //neutron ~
1280 fhNBarPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1282 if(primaryCode == 2){
1283 fhChargedPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1286 fhAllPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1287 fhVeto->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1288 fhPPSD->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1289 counter[5][primaryCode]++ ;
1291 case AliPHOSFastRecParticle::kABSURDEM:
1292 counter[6][primaryCode]++ ;
1293 fhShape->Fill(CorrectEnergy(recParticle->Energy()) ) ;
1295 case AliPHOSFastRecParticle::kABSURDHA:
1296 counter[7][primaryCode]++ ;
1299 counter[8][primaryCode]++ ;
1306 cout << "Resolutions: Analyzed " << Nevents << " event(s)" << endl ;
1307 cout << "Resolutions: Total primary " << totalPrimary << endl ;
1308 cout << "Resoluitons: Total reconstracted " << totalRecPart << endl ;
1309 cout << "TotalReconstructed with Primarie " << totalRPwithPrim << endl ;
1310 cout << " Primary: Photon Electron Ch. Hadr. Neutr. Hadr Kaons" << endl ;
1311 cout << " Detected as photon " << counter[0][0] << " " << counter[0][1] << " " << counter[0][2] << " " <<counter[0][3] << " " << counter[0][4] << endl ;
1312 cout << " Detected as electron " << counter[1][0] << " " << counter[1][1] << " " << counter[1][2] << " " <<counter[1][3] << " " << counter[1][4] << endl ;
1313 cout << " Detected as neutral hadron " << counter[2][0] << " " << counter[2][1] << " " << counter[2][2] << " " <<counter[2][3] << " " << counter[2][4] << endl ;
1314 cout << " Detected as neutral EM " << counter[3][0] << " " << counter[3][1] << " " << counter[3][2] << " " <<counter[3][3] << " " << counter[3][4] << endl ;
1315 cout << " Detected as charged hadron " << counter[4][0] << " " << counter[4][1] << " " << counter[4][2] << " " <<counter[4][3] << " " << counter[4][4] << endl ;
1316 cout << " Detected as gamma-hadron " << counter[5][0] << " " << counter[5][1] << " " << counter[5][2] << " " <<counter[5][3] << " " << counter[5][4] << endl ;
1317 cout << " Detected as Absurd EM " << counter[6][0] << " " << counter[6][1] << " " << counter[6][2] << " " <<counter[6][3] << " " << counter[6][4] << endl ;
1318 cout << " Detected as absurd hadron " << counter[7][0] << " " << counter[7][1] << " " << counter[7][2] << " " <<counter[7][3] << " " << counter[7][4] << endl ;
1319 cout << " Detected as undefined " << counter[8][0] << " " << counter[8][1] << " " << counter[8][2] << " " <<counter[8][3] << " " << counter[8][4] << endl ;
1321 for(i1 = 0; i1<9; i1++)
1322 for(i2 = 0; i2<5; i2++)
1323 totalInd+=counter[i1][i2] ;
1324 cout << "Indentified particles " << totalInd << endl ;
1329 //____________________________________________________________________________
1330 void AliPHOSAnalyze::BookingHistograms()
1332 // Books the histograms where the results of the analysis are stored (to be changed)
1335 delete fhVetoDigit ;
1336 delete fhConvertorDigit ;
1337 delete fhEmcCluster ;
1338 delete fhVetoCluster ;
1339 delete fhConvertorCluster ;
1340 delete fhConvertorEmc ;
1342 fhEmcDigit = new TH1F("hEmcDigit", "hEmcDigit", 1000, 0. , 25.);
1343 fhVetoDigit = new TH1F("hVetoDigit", "hVetoDigit", 500, 0. , 3.e-5);
1344 fhConvertorDigit = new TH1F("hConvertorDigit","hConvertorDigit", 500, 0. , 3.e-5);
1345 fhEmcCluster = new TH1F("hEmcCluster", "hEmcCluster", 1000, 0. , 30.);
1346 fhVetoCluster = new TH1F("hVetoCluster", "hVetoCluster", 500, 0. , 3.e-5);
1347 fhConvertorCluster = new TH1F("hConvertorCluster","hConvertorCluster",500, 0. , 3.e-5);
1348 fhConvertorEmc = new TH2F("hConvertorEmc", "hConvertorEmc", 200, 1. , 3., 200, 0., 3.e-5);
1351 //____________________________________________________________________________
1352 void AliPHOSAnalyze::BookResolutionHistograms()
1354 // Books the histograms where the results of the Resolution analysis are stored
1357 // delete fhAllEnergy ;
1359 // delete fhPhotEnergy ;
1361 // delete fhEMEnergy ;
1363 // delete fhPPSDEnergy ;
1366 fhAllEnergy = new TH2F("hAllEnergy", "Energy of any RP with primary photon",100, 0., 5., 100, 0., 5.);
1367 fhPhotEnergy = new TH2F("hPhotEnergy", "Energy of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
1368 fhEMEnergy = new TH2F("hEMEnergy", "Energy of EM with primary photon", 100, 0., 5., 100, 0., 5.);
1369 fhPPSDEnergy = new TH2F("hPPSDEnergy", "Energy of PPSD with primary photon", 100, 0., 5., 100, 0., 5.);
1371 // if(fhAllPosition)
1372 // delete fhAllPosition ;
1373 // if(fhPhotPosition)
1374 // delete fhPhotPosition ;
1376 // delete fhEMPosition ;
1377 // if(fhPPSDPosition)
1378 // delete fhPPSDPosition ;
1381 fhAllPosition = new TH2F("hAllPosition", "Position of any RP with primary photon",100, 0., 5., 100, 0., 5.);
1382 fhPhotPosition = new TH2F("hPhotPosition", "Position of kGAMMA with primary photon",100, 0., 5., 100, 0., 5.);
1383 fhEMPosition = new TH2F("hEMPosition", "Position of EM with primary photon", 100, 0., 5., 100, 0., 5.);
1384 fhPPSDPosition = new TH2F("hPPSDPosition", "Position of PPSD with primary photon", 100, 0., 5., 100, 0., 5.);
1386 fhAllPositionX = new TH1F("hAllPositionX", "#Delta X of any RP with primary photon",100, -2., 2.);
1387 fhAllPositionZ = new TH1F("hAllPositionZ", "#Delta X of any RP with primary photon",100, -2., 2.);
1390 // delete fhAllReg ;
1392 // delete fhPhotReg ;
1396 // delete fhNBarReg ;
1398 // delete fhChargedReg ;
1400 fhAllReg = new TH1F("hAllReg", "All primaries registered as photon", 100, 0., 5.);
1401 fhPhotReg = new TH1F("hPhotReg", "Photon registered as photon", 100, 0., 5.);
1402 fhNReg = new TH1F("hNReg", "N registered as photon", 100, 0., 5.);
1403 fhNBarReg = new TH1F("hNBarReg", "NBar registered as photon", 100, 0., 5.);
1404 fhChargedReg= new TH1F("hChargedReg", "Charged hadron registered as photon",100, 0., 5.);
1409 // delete fhPhotEM ;
1413 // delete fhNBarEM ;
1415 // delete fhChargedEM ;
1417 fhAllEM = new TH1F("hAllEM", "All primary registered as EM",100, 0., 5.);
1418 fhPhotEM = new TH1F("hPhotEM", "Photon registered as EM", 100, 0., 5.);
1419 fhNEM = new TH1F("hNEM", "N registered as EM", 100, 0., 5.);
1420 fhNBarEM = new TH1F("hNBarEM", "NBar registered as EM", 100, 0., 5.);
1421 fhChargedEM= new TH1F("hChargedEM","Charged registered as EM",100, 0., 5.);
1424 // delete fhAllPPSD ;
1426 // delete fhPhotPPSD ;
1430 // delete fhNBarPPSD ;
1431 // if(fhChargedPPSD)
1432 // delete fhChargedPPSD ;
1434 fhAllPPSD = new TH1F("hAllPPSD", "All primary registered as PPSD",100, 0., 5.);
1435 fhPhotPPSD = new TH1F("hPhotPPSD", "Photon registered as PPSD", 100, 0., 5.);
1436 fhNPPSD = new TH1F("hNPPSD", "N registered as PPSD", 100, 0., 5.);
1437 fhNBarPPSD = new TH1F("hNBarPPSD", "NBar registered as PPSD", 100, 0., 5.);
1438 fhChargedPPSD= new TH1F("hChargedPPSD","Charged registered as PPSD",100, 0., 5.);
1441 // delete fhPrimary ;
1442 fhPrimary= new TH1F("hPrimary", "hPrimary", 100, 0., 5.);
1453 fhAllRP = new TH1F("hAllRP","All Reconstructed particles", 100, 0., 5.);
1454 fhVeto = new TH1F("hVeto", "All uncharged particles", 100, 0., 5.);
1455 fhShape = new TH1F("hShape","All particles with EM shaower",100, 0., 5.);
1456 fhPPSD = new TH1F("hPPSD", "All PPSD photon particles", 100, 0., 5.);
1460 // delete fhPhotPhot ;
1462 // delete fhPhotElec ;
1464 // delete fhPhotNeuH ;
1466 // delete fhPhotNuEM ;
1468 // delete fhPhotChHa ;
1470 // delete fhPhotGaHa ;
1472 fhPhotPhot = new TH1F("hPhotPhot","hPhotPhot", 100, 0., 5.); //Photon registered as photon
1473 fhPhotElec = new TH1F("hPhotElec","hPhotElec", 100, 0., 5.); //Photon registered as Electron
1474 fhPhotNeuH = new TH1F("hPhotNeuH","hPhotNeuH", 100, 0., 5.); //Photon registered as Neutral Hadron
1475 fhPhotNuEM = new TH1F("hPhotNuEM","hPhotNuEM", 100, 0., 5.); //Photon registered as Neutral EM
1476 fhPhotChHa = new TH1F("hPhotChHa","hPhotChHa", 100, 0., 5.); //Photon registered as Charged Hadron
1477 fhPhotGaHa = new TH1F("hPhotGaHa","hPhotGaHa", 100, 0., 5.); //Photon registered as Gamma-Hadron
1480 //____________________________________________________________________________
1481 Bool_t AliPHOSAnalyze::OpenRootFile(Text_t * name)
1483 // Open the root file named "name"
1485 fRootFile = new TFile(name, "update") ;
1486 return fRootFile->IsOpen() ;
1489 //____________________________________________________________________________
1490 void AliPHOSAnalyze::SaveHistograms()
1492 // Saves the histograms in a root file named "name.analyzed"
1494 Text_t outputname[80] ;
1495 sprintf(outputname,"%s.analyzed",fRootFile->GetName());
1496 TFile output(outputname,"RECREATE");
1500 fhAllEnergy->Write() ;
1502 fhPhotEnergy->Write() ;
1504 fhEMEnergy->Write() ;
1506 fhPPSDEnergy->Write() ;
1508 fhAllPosition->Write() ;
1510 fhAllPositionX->Write() ;
1512 fhAllPositionZ->Write() ;
1514 fhPhotPosition->Write() ;
1516 fhEMPosition->Write() ;
1518 fhPPSDPosition->Write() ;
1522 fhPhotReg->Write() ;
1526 fhNBarReg->Write() ;
1528 fhChargedReg->Write() ;
1538 fhChargedEM->Write() ;
1540 fhAllPPSD->Write() ;
1542 fhPhotPPSD->Write() ;
1546 fhNBarPPSD->Write() ;
1548 fhChargedPPSD->Write() ;
1550 fhPrimary->Write() ;
1560 fhPhotPhot->Write() ;
1562 fhPhotElec->Write() ;
1564 fhPhotNeuH->Write() ;
1566 fhPhotNuEM->Write() ;
1568 fhPhotNuEM->Write() ;
1570 fhPhotChHa->Write() ;
1572 fhPhotGaHa->Write() ;
1573 if(fhEnergyCorrelations)
1574 fhEnergyCorrelations->Write() ;
1579 //____________________________________________________________________________
1580 Float_t AliPHOSAnalyze::CorrectEnergy(Float_t ERecPart)
1582 return ERecPart/0.8783 ;
1585 //____________________________________________________________________________
1586 void AliPHOSAnalyze::ResetHistograms()
1588 fhEnergyCorrelations = 0 ; //Energy correlations between Eloss in Convertor and PPSD(2)
1590 fhEmcDigit = 0 ; // Histo of digit energies in the Emc
1591 fhVetoDigit = 0 ; // Histo of digit energies in the Veto
1592 fhConvertorDigit = 0 ; // Histo of digit energies in the Convertor
1593 fhEmcCluster = 0 ; // Histo of Cluster energies in Emc
1594 fhVetoCluster = 0 ; // Histo of Cluster energies in Veto
1595 fhConvertorCluster = 0 ; // Histo of Cluster energies in Convertor
1596 fhConvertorEmc = 0 ; // 2d Convertor versus Emc energies
1599 fhPhotEnergy = 0 ; // Total spectrum of detected photons
1600 fhEMEnergy = 0 ; // Spectrum of detected electrons with electron primary
1603 fhAllPositionX = 0 ;
1604 fhAllPositionZ = 0 ;
1605 fhPhotPosition = 0 ;
1607 fhPPSDPosition = 0 ;