2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 //_________________________________________________________________________
18 // Cheking Reconstruction procedure of PHOS
19 //*-- Author : Gines MARTINEZ SUBATECH january 2000
20 //////////////////////////////////////////////////////////////////////////////
22 // --- ROOT system ---
29 #include "TParticle.h"
31 // --- Standard library ---
37 // --- AliRoot header files ---
40 #include "AliPHOSGeometry.h"
41 #include "AliPHOSv0.h"
42 #include "AliPHOSDigit.h"
43 #include "AliPHOSRecPoint.h"
44 #include "AliPHOSEmcRecPoint.h"
45 #include "AliPHOSPpsdRecPoint.h"
46 #include "AliPHOSClusterizerv1.h"
47 #include "AliPHOSReconstructioner.h"
48 #include "AliPHOSTrackSegment.h"
49 #include "AliPHOSTrackSegmentMakerv1.h"
50 #include "ReconstructionTest.h"
53 void ReconstructionTest(Text_t* infile,Int_t evt, Int_t Module)
55 //========== Opening galice.root file
56 TFile * file = new TFile(infile);
57 //========== Get AliRun object from file
58 gAlice = (AliRun*) file->Get("gAlice");
59 //=========== Gets the PHOS object and associated geometry from the file
60 AliPHOSv0 * PHOS = (AliPHOSv0 *)gAlice->GetDetector("PHOS");
61 AliPHOSGeometry * Geom = AliPHOSGeometry::GetInstance(PHOS->GetGeometry()->GetName(),PHOS->GetGeometry()->GetTitle());
62 //========== Creates the Clusterizer
63 AliPHOSClusterizerv1 clusterizer;
64 clusterizer.SetEmcEnergyThreshold(0.01) ;
65 clusterizer.SetEmcClusteringThreshold(0.1) ;
66 clusterizer.SetPpsdEnergyThreshold(0.0000001) ;
67 clusterizer.SetPpsdClusteringThreshold(0.0000002) ;
68 clusterizer.SetLocalMaxCut(0.03) ;
69 clusterizer.SetCalibrationParameters(0., 0.0000001) ;
70 //========== Creates the track segment maker
71 AliPHOSTrackSegmentMakerv1 tracksegmentmaker ;
72 //========== Creates the Reconstructioner
73 AliPHOSReconstructioner Reconstructioner(clusterizer,tracksegmentmaker);
74 //=========== Connects the various Tree's for evt
75 gAlice->GetEvent(evt);
76 //=========== Gets the Digit TTree
77 gAlice->TreeD()->GetEvent(0) ;
78 //=========== Gets the number of entries in the Digits array
79 Int_t nId = PHOS->Digits()->GetEntries();
80 printf("ReconstructionTest> Number of entries in the Digit array is %d \n",nId);
81 //=========== Do the reconstruction
82 AliPHOSDigit * digit ;
83 TIter next(PHOS->Digits()) ;
85 while( ( digit = (AliPHOSDigit *)next() ) )
86 Etot+=clusterizer.Calibrate(digit->GetAmp()) ;
87 cout <<"ReconstructionTest> Found " << nId << " digits in PHOS with total energy " << Etot << endl ;
88 PHOS->Reconstruction(Reconstructioner);
89 //================Make checks===========================
91 //=========== Creating Canvas
92 TCanvas * ModuleCanvas = new TCanvas("Module","Events in a single PHOS Module", 650, 500) ;
93 ModuleCanvas->Draw() ;
95 //=========== Creating 2d-histogram of the PHOS Module
96 // a little bit junkie but is used to test Geom functinalities
98 Double_t tm, tM, pm, pM ; // min and Max theta and phi covered by Module 1
100 Geom->EmcModuleCoverage(1, tm, tM, pm, pM);
101 // convert angles into coordinates local to the EMC module of interest
103 Int_t EmcModuleNumber ;
104 Double_t EmcModulexm, EmcModulezm ; // minimum local coordinate in a given EMCA module
105 Double_t EmcModulexM, EmcModulezM ; // maximum local coordinate in a given EMCA module
106 Geom->ImpactOnEmc(tm, pm, EmcModuleNumber, EmcModulezm, EmcModulexm) ;
107 Geom->ImpactOnEmc(tM, pM, EmcModuleNumber, EmcModulezM, EmcModulexM) ;
108 Int_t xdim = (Int_t)( ( EmcModulexM - EmcModulexm ) / Geom->GetCrystalSize(0) ) ;
109 Int_t zdim = (Int_t)( ( EmcModulezM - EmcModulezm ) / Geom->GetCrystalSize(2) ) ;
110 Float_t xmin = EmcModulexm - Geom->GetCrystalSize(0) ;
111 Float_t xMax = EmcModulexM + Geom->GetCrystalSize(0) ;
112 Float_t zmin = EmcModulezm - Geom->GetCrystalSize(2) ;
113 Float_t zMax = EmcModulezM + Geom->GetCrystalSize(2) ;
114 // histogram of reconstructed events
115 Text_t HistoName[80];
116 sprintf(HistoName,"Event %d: Reconstructed particles in module %d", evt, Module) ;
117 TH2F * hModule = new TH2F("HistoReconstructed", HistoName,
118 xdim, xmin, xMax, zdim, zmin, zMax) ;
119 hModule->SetMaximum(2.0);
120 hModule->SetMinimum(0.0);
121 hModule->SetStats(kFALSE);
122 // histogram of generated particles
123 sprintf(HistoName,"Event %d: Incident particles in module %d", evt, Module) ;
124 TH2F * HistoParticle = new TH2F("HistoParticle", HistoName,
125 xdim, xmin, xMax, zdim, zmin, zMax) ;
126 HistoParticle->SetStats(kFALSE) ;
128 //=========== Digits of Module
129 TIter next2(PHOS->Digits()) ;
130 Float_t Energy, y, z;
131 Int_t RelId[4]; Int_t NumberOfDigits = 0 ;
132 while((digit = (AliPHOSDigit *)next2()))
134 Geom->AbsToRelNumbering(digit->GetId(), RelId) ;
135 if (RelId[0] == Module)
138 Energy = clusterizer.Calibrate(digit->GetAmp()) ;
140 Geom->RelPosInModule(RelId,y,z) ;
142 hModule->Fill(y,z,Energy) ;
145 cout <<"TestRec> Found in Module " << Module << " " << NumberOfDigits << " digits with total energy " << Etot << endl ;
146 hModule->Draw("col2") ;
148 //=========== Cluster in Module
149 TClonesArray * EmcRP = PHOS->EmcClusters() ;
151 Int_t TotalNumberOfClusters = 0 ;
152 Int_t NumberOfClusters = 0 ;
153 TIter nextemc(EmcRP) ;
154 AliPHOSEmcRecPoint * emc ;
155 while((emc = (AliPHOSEmcRecPoint *)nextemc()))
157 TotalNumberOfClusters++ ;
158 if ( emc->GetPHOSMod() == Module )
161 Energy = emc->GetTotalEnergy() ;
166 cout << "TestRec> Found " << TotalNumberOfClusters << " EMC Clusters in PHOS" << endl ;
167 cout << "TestRec> Found in Module " << Module << " " << NumberOfClusters << " EMC Clusters " << endl ;
168 cout << "TestRec> Total energy " <<Etot << endl ;
170 TPaveText * PaveText = new TPaveText(22, 80, 83, 90);
172 sprintf(text, "digits: %d; clusters: %d", NumberOfDigits, NumberOfClusters) ;
173 PaveText->AddText(text) ;
175 ModuleCanvas->Update();
177 //=========== Cluster in Module PPSD Down
178 TClonesArray * PpsdRP = PHOS->PpsdClusters() ;
180 TIter nextPpsd(PpsdRP) ;
181 AliPHOSPpsdRecPoint * Ppsd ;
182 while((Ppsd = (AliPHOSPpsdRecPoint *)nextPpsd()))
184 TotalNumberOfClusters++ ;
185 if ( Ppsd->GetPHOSMod() == Module )
188 Energy = Ppsd->GetEnergy() ;
190 if (!Ppsd->GetUp()) Ppsd->Draw("P") ;
193 cout << "TestRec> Found " << TotalNumberOfClusters << " Ppsd Down Clusters in PHOS" << endl ;
194 cout << "TestRec> Found in Module " << Module << " " << NumberOfClusters << " Ppsd Down Clusters " << endl ;
195 cout << "TestRec> Total energy " <<Etot << endl ;
197 //=========== Cluster in Module PPSD Up
198 PpsdRP = PHOS->PpsdClusters() ;
200 TIter nextPpsdUp(PpsdRP) ;
201 while((Ppsd = (AliPHOSPpsdRecPoint *)nextPpsdUp()))
203 TotalNumberOfClusters++ ;
204 if ( Ppsd->GetPHOSMod() == Module )
207 Energy = Ppsd->GetEnergy() ;
209 if (Ppsd->GetUp()) Ppsd->Draw("P") ;
212 cout << "TestRec> Found " << TotalNumberOfClusters << " Ppsd Up Clusters in PHOS" << endl ;
213 cout << "TestRec> Found in Module " << Module << " " << NumberOfClusters << " Ppsd Up Clusters " << endl ;
214 cout << "TestRec> Total energy " <<Etot << endl ;
216 // Get pointers to Alice Particle TClonesArray
217 TParticle * Particle;
218 TClonesArray * ArrayOfParticles = gAlice->Particles();
219 TCanvas * KineCanvas = new TCanvas("KineCnvas", "Incident particles", 650, 500) ;
221 TTree * Kine = gAlice->TreeK() ;
222 Stat_t NumberOfParticles = Kine->GetEntries() ;
223 cout << "events in Kine " << NumberOfParticles << endl ;
225 // loop over particles
227 Int_t nparticlein = 0 ;
228 for (index1 = 0 ; index1 < NumberOfParticles ; index1++){
229 Int_t nparticle = ArrayOfParticles->GetEntriesFast() ;
230 cout << nparticle << endl ;
232 for( index2 = 0 ; index2 < nparticle; index2++) {
233 Particle = (TParticle*)ArrayOfParticles->UncheckedAt(index2) ;
234 Int_t ParticleType = Particle->GetPdgCode() ;
235 Double_t Phi = Particle->Phi() ;
236 Double_t Theta = Particle->Theta() ;
239 Geom->ImpactOnEmc(Theta, Phi, mod, z, x) ;
240 if ( mod == Module ) {
242 HistoParticle->Fill( x, -z, Particle->Energy() ) ; //-z don't know why, but that is how it works
247 HistoParticle->Draw("color") ;
248 TPaveText * PaveText2 = new TPaveText(22, 80, 83, 90);
249 sprintf(text, "Particles: %d ", nparticlein) ;
250 PaveText2->AddText(text) ;
252 KineCanvas->Update();
254 // TObjArray * trsegl = PHOS->TrackSegments() ;
255 // AliPHOSTrackSegment trseg ;
257 // Int_t NTrackSegments = trsegl->GetEntries() ;
260 // for(index = 0; index < NTrackSegments ; index++){
261 // trseg = (AliPHOSTrackSegment * )trsegl->At(index) ;
262 // Etot+= trseg->GetEnergy() ;
263 // if ( trseg->GetPHOSMod() == Module )
265 // // trseg->Draw("P");
269 // cout << "Found " << trsegl->GetEntries() << " Track segments with total energy "<< Etot << endl ;