]>
Commit | Line | Data |
---|---|---|
ce9d0223 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id: */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | // A basic analysis task to analyse photon detected by PHOS | |
20 | // | |
21 | //*-- Yves Schutz | |
22 | ////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | #include <TCanvas.h> | |
25 | #include <TChain.h> | |
26 | #include <TFile.h> | |
27 | #include <TH1.h> | |
28 | #include <TH1F.h> | |
29 | #include <TH1I.h> | |
30 | #include <TLegend.h> | |
31 | #include <TNtuple.h> | |
32 | #include <TROOT.h> | |
33 | #include <TVector3.h> | |
34 | ||
35 | #include "AliAnaGammaPhos.h" | |
36 | #include "AliAnalysisManager.h" | |
37 | #include "AliESD.h" | |
38 | #include "AliAODEvent.h" | |
39 | #include "AliAODHandler.h" | |
c0acc236 | 40 | #include "AliAODPhoton.h" |
ce9d0223 | 41 | #include "AliLog.h" |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliAnaGammaPhos::AliAnaGammaPhos() : | |
45 | fChain(0x0), | |
46 | fDebug(0), | |
47 | fESD(0x0), | |
48 | fAOD(0x0), | |
49 | fAODPhotons(0x0), | |
50 | fPhotonsInPhos(0), | |
51 | fTreeA(0x0), | |
52 | fPhotonId(1.0), | |
53 | fOutputList(0x0), | |
54 | fhPHOS(0), | |
55 | fhPHOSEnergy(0), | |
56 | fhPHOSDigits(0), | |
57 | fhPHOSRecParticles(0), | |
58 | fhPHOSPhotons(0), | |
59 | fhPHOSInvariantMass(0), | |
60 | fhPHOSDigitsEvent(0) | |
61 | { | |
62 | //Default constructor | |
63 | } | |
64 | //______________________________________________________________________________ | |
65 | AliAnaGammaPhos::AliAnaGammaPhos(const char *name) : | |
66 | AliAnalysisTask(name,""), | |
67 | fChain(0x0), | |
68 | fDebug(0), | |
69 | fESD(0x0), | |
70 | fAOD(0x0), | |
71 | fAODPhotons(0x0), | |
72 | fPhotonsInPhos(0), | |
73 | fTreeA(0x0), | |
74 | fPhotonId(1.0), | |
75 | fOutputList(0x0), | |
76 | fhPHOS(0), | |
77 | fhPHOSEnergy(0), | |
78 | fhPHOSDigits(0), | |
79 | fhPHOSRecParticles(0), | |
80 | fhPHOSPhotons(0), | |
81 | fhPHOSInvariantMass(0), | |
82 | fhPHOSDigitsEvent(0) | |
83 | { | |
84 | // Constructor. | |
85 | // Input slot #0 | |
86 | DefineInput(0, TChain::Class()); | |
87 | // Output slots | |
88 | DefineOutput(0, TTree::Class()) ; | |
89 | DefineOutput(1, TList::Class()) ; | |
90 | } | |
91 | ||
92 | //______________________________________________________________________________ | |
93 | AliAnaGammaPhos::~AliAnaGammaPhos() | |
94 | { | |
95 | // dtor | |
c0acc236 | 96 | // fOutputList->Clear() ; |
97 | //delete fOutputList ; | |
ce9d0223 | 98 | } |
99 | ||
100 | ||
101 | //______________________________________________________________________________ | |
102 | void AliAnaGammaPhos::ConnectInputData(const Option_t*) | |
103 | { | |
104 | // Initialisation of branch container and histograms | |
105 | ||
106 | AliInfo(Form("*** Initialization of %s", GetName())) ; | |
107 | ||
108 | // Get input data | |
109 | fChain = dynamic_cast<TChain *>(GetInputData(0)) ; | |
110 | if (!fChain) { | |
111 | AliError(Form("Input 0 for %s not found\n", GetName())); | |
112 | return ; | |
113 | } | |
114 | ||
115 | // One should first check if the branch address was taken by some other task | |
116 | char ** address = (char **)GetBranchAddress(0, "ESD"); | |
117 | if (address) { | |
118 | fESD = (AliESD*)(*address); | |
119 | } else { | |
120 | fESD = new AliESD(); | |
121 | SetBranchAddress(0, "ESD", &fESD); | |
122 | } | |
123 | } | |
124 | ||
125 | //________________________________________________________________________ | |
126 | void AliAnaGammaPhos::CreateOutputObjects() | |
127 | { | |
128 | // Create the outputs containers | |
129 | ||
130 | OpenFile(0) ; | |
131 | AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler()); | |
c0acc236 | 132 | fTreeA = handler->GetTree() ; |
ce9d0223 | 133 | fAOD = handler->GetAOD(); |
134 | fAODPhotons = fAOD->GetClusters() ; | |
c0acc236 | 135 | |
ce9d0223 | 136 | |
137 | OpenFile(1) ; | |
138 | ||
139 | fhPHOSPos = new TNtuple("PHOSPos" , "Position in PHOS" , "x:y:z"); | |
140 | fhPHOS = new TNtuple("PHOS" , "PHOS" , "event:digits:clusters:photons"); | |
141 | fhPHOSEnergy = new TH1D("PHOSEnergy" , "PHOSEnergy" , 1000, 0., 10. ) ; | |
142 | fhPHOSDigits = new TH1I("PHOSDigitsCluster" , "PHOSDigits" , 20 , 0 , 20 ) ; | |
143 | fhPHOSRecParticles = new TH1D("PHOSRecParticles" , "PHOSRecParticles" , 20 , 0., 20. ) ; | |
144 | fhPHOSPhotons = new TH1I("PHOSPhotons" , "PHOSPhotons" , 20 , 0 , 20 ) ; | |
145 | fhPHOSInvariantMass = new TH1D("PHOSInvariantMass" , "PHOSInvariantMass" , 400, 0., 400.) ; | |
146 | fhPHOSDigitsEvent = new TH1I("PHOSDigitsEvent" , "PHOSDigitsEvent" , 30 , 0 , 30 ) ; | |
147 | ||
148 | // create output container | |
149 | ||
150 | fOutputList = new TList() ; | |
151 | fOutputList->SetName(GetName()) ; | |
152 | ||
153 | fOutputList->AddAt(fhPHOSPos, 0) ; | |
154 | fOutputList->AddAt(fhPHOS, 1) ; | |
155 | fOutputList->AddAt(fhPHOSEnergy, 2) ; | |
156 | fOutputList->AddAt(fhPHOSDigits, 3) ; | |
157 | fOutputList->AddAt(fhPHOSRecParticles, 4) ; | |
158 | fOutputList->AddAt(fhPHOSPhotons, 5) ; | |
159 | fOutputList->AddAt(fhPHOSInvariantMass, 6) ; | |
160 | fOutputList->AddAt(fhPHOSDigitsEvent, 7) ; | |
161 | } | |
162 | ||
163 | //______________________________________________________________________________ | |
164 | void AliAnaGammaPhos::Exec(Option_t *) | |
165 | { | |
166 | // Processing of one event | |
167 | ||
168 | Long64_t entry = fChain->GetReadEntry() ; | |
169 | ||
170 | if (!fESD) { | |
171 | AliError("fESD is not connected to the input!") ; | |
172 | return ; | |
173 | } | |
174 | ||
175 | if ( !((entry-1)%100) ) | |
176 | AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ; | |
177 | ||
178 | //************************ PHOS ************************************* | |
179 | ||
180 | Int_t firstPhosCluster = fESD->GetFirstPHOSCluster() ; | |
181 | const Int_t numberOfPhosClusters = fESD->GetNumberOfPHOSClusters() ; | |
182 | ||
183 | TVector3 ** phosVector = new TVector3*[numberOfPhosClusters] ; | |
184 | Float_t * phosPhotonsEnergy = new Float_t[numberOfPhosClusters] ; | |
185 | Int_t phosCluster ; | |
186 | Int_t numberOfDigitsInPhos = 0 ; | |
187 | ||
188 | fPhotonsInPhos = 0 ; | |
189 | // loop over the PHOS Cluster | |
190 | for(phosCluster = firstPhosCluster ; phosCluster < firstPhosCluster + numberOfPhosClusters ; phosCluster++) { | |
191 | AliESDCaloCluster * caloCluster = fESD->GetCaloCluster(phosCluster) ; | |
192 | if (caloCluster) { | |
193 | Float_t pos[3] ; | |
c0acc236 | 194 | caloCluster->GetPosition( pos ) ; |
195 | fhPHOSEnergy->Fill( caloCluster->E() ) ; | |
ce9d0223 | 196 | fhPHOSPos->Fill( pos[0], pos[1], pos[2] ) ; |
197 | fhPHOSDigits->Fill(entry, caloCluster->GetNumberOfDigits() ) ; | |
198 | numberOfDigitsInPhos += caloCluster->GetNumberOfDigits() ; | |
199 | Float_t * pid = caloCluster->GetPid() ; | |
200 | if(pid[AliPID::kPhoton] > GetPhotonId() ) { | |
201 | phosVector[fPhotonsInPhos] = new TVector3(pos[0],pos[1],pos[2]) ; | |
c0acc236 | 202 | phosPhotonsEnergy[fPhotonsInPhos]=caloCluster->E() ; |
ce9d0223 | 203 | //new ((*fAODPhotons)[fPhotonsInPhos++;]) AliAODPhoton ( ); |
204 | } | |
205 | } | |
206 | } //PHOS clusters | |
207 | ||
208 | fhPHOSRecParticles->Fill(numberOfPhosClusters); | |
209 | fhPHOSPhotons->Fill(fPhotonsInPhos); | |
210 | fhPHOSDigitsEvent->Fill(numberOfDigitsInPhos); | |
211 | fhPHOS->Fill(entry, numberOfDigitsInPhos, numberOfPhosClusters, fPhotonsInPhos) ; | |
212 | ||
213 | // invariant Mass | |
214 | if (fPhotonsInPhos > 1 ) { | |
215 | Int_t phosPhoton1, phosPhoton2 ; | |
216 | for(phosPhoton1 = 0 ; phosPhoton1 < fPhotonsInPhos ; phosPhoton1++) { | |
217 | for(phosPhoton2 = phosPhoton1 + 1 ; phosPhoton2 < fPhotonsInPhos ; phosPhoton2++) { | |
218 | Float_t tempMass = TMath::Sqrt( 2 * phosPhotonsEnergy[phosPhoton1] * phosPhotonsEnergy[phosPhoton2] * | |
219 | ( 1 - TMath::Cos(phosVector[phosPhoton1]->Angle(*phosVector[phosPhoton2])) ) | |
220 | ); | |
221 | fhPHOSInvariantMass->Fill(tempMass*1000.); | |
222 | } | |
223 | } | |
224 | } | |
225 | ||
226 | PostData(0, fTreeA) ; | |
227 | PostData(1, fOutputList); | |
228 | ||
229 | delete [] phosVector ; | |
230 | delete [] phosPhotonsEnergy ; | |
231 | ||
232 | } | |
233 | ||
234 | ||
235 | //______________________________________________________________________________ | |
236 | void AliAnaGammaPhos::Init() | |
237 | { | |
238 | // Intialisation of parameters | |
239 | AliInfo("Doing initialisation") ; | |
240 | SetPhotonId(0.9) ; | |
241 | } | |
242 | ||
243 | //______________________________________________________________________________ | |
75480d65 | 244 | void AliAnaGammaPhos:: Normalize(const Double_t norm) |
245 | { | |
246 | // Normalize some histograms | |
247 | fhPHOSEnergy->Scale(norm) ; | |
248 | fhPHOSInvariantMass->Scale(norm) ; | |
249 | } | |
250 | ||
251 | //______________________________________________________________________________ | |
ce9d0223 | 252 | void AliAnaGammaPhos::Terminate(Option_t *) |
253 | { | |
254 | // Processing when the event loop is ended | |
255 | ||
c0acc236 | 256 | // fOutputList = (TList*)GetOutputData(0); |
257 | // fhPHOSPos = (TNtuple*)fOutputList->At(0); | |
258 | // fhPHOS = (TNtuple*)fOutputList->At(1); | |
259 | // fhPHOSEnergy = (TH1D*)fOutputList->At(2); | |
260 | // fhPHOSDigits = (TH1I*)fOutputList->At(3); | |
261 | // fhPHOSRecParticles = (TH1D*)fOutputList->At(4); | |
262 | // fhPHOSPhotons = (TH1I*)fOutputList->At(5); | |
263 | // fhPHOSInvariantMass = (TH1D*)fOutputList->At(6); | |
264 | // fhPHOSDigitsEvent = (TH1I*)fOutputList->At(7); | |
ce9d0223 | 265 | |
266 | Bool_t problem = kFALSE ; | |
267 | AliInfo(Form(" *** %s Report:", GetName())) ; | |
268 | printf(" PHOSEnergy Mean : %5.3f , RMS : %5.3f \n", fhPHOSEnergy->GetMean(), fhPHOSEnergy->GetRMS() ) ; | |
269 | printf(" PHOSDigits Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigits->GetMean(), fhPHOSDigits->GetRMS() ) ; | |
270 | printf(" PHOSRecParticles Mean : %5.3f , RMS : %5.3f \n", fhPHOSRecParticles->GetMean(), fhPHOSRecParticles->GetRMS() ) ; | |
271 | printf(" PHOSPhotons Mean : %5.3f , RMS : %5.3f \n", fhPHOSPhotons->GetMean(), fhPHOSPhotons->GetRMS() ) ; | |
272 | printf(" PHOSInvariantMass Mean : %5.3f , RMS : %5.3f \n", fhPHOSInvariantMass->GetMean(), fhPHOSInvariantMass->GetRMS() ) ; | |
273 | printf(" PHOSDigitsEvent Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigitsEvent->GetMean(), fhPHOSDigitsEvent->GetRMS() ) ; | |
274 | ||
275 | TCanvas * cPHOS = new TCanvas("cPHOS", "PHOS ESD Test", 400, 10, 600, 700) ; | |
276 | cPHOS->Divide(3, 2); | |
277 | ||
278 | cPHOS->cd(1) ; | |
279 | if ( fhPHOSEnergy->GetMaximum() > 0. ) | |
280 | gPad->SetLogy(); | |
281 | fhPHOSEnergy->SetAxisRange(0, 25.); | |
282 | fhPHOSEnergy->SetLineColor(2); | |
283 | fhPHOSEnergy->Draw(); | |
284 | ||
285 | cPHOS->cd(2) ; | |
286 | fhPHOSDigits->SetAxisRange(0,25.); | |
287 | fhPHOSDigits->SetLineColor(2); | |
288 | fhPHOSDigits->Draw(); | |
289 | ||
290 | cPHOS->cd(3) ; | |
291 | if ( fhPHOSRecParticles->GetMaximum() > 0. ) | |
292 | gPad->SetLogy(); | |
293 | fhPHOSRecParticles->SetAxisRange(0, 25.); | |
294 | fhPHOSRecParticles->SetLineColor(2); | |
295 | fhPHOSRecParticles->Draw(); | |
296 | ||
297 | cPHOS->cd(4) ; | |
298 | if ( fhPHOSPhotons->GetMaximum() > 0. ) | |
299 | gPad->SetLogy(); | |
300 | fhPHOSPhotons->SetAxisRange(0,25.); | |
301 | fhPHOSPhotons->SetLineColor(2); | |
302 | fhPHOSPhotons->Draw(); | |
303 | ||
304 | cPHOS->cd(5) ; | |
305 | fhPHOSInvariantMass->SetLineColor(2); | |
306 | fhPHOSInvariantMass->Draw(); | |
307 | ||
308 | cPHOS->cd(6) ; | |
309 | if ( fhPHOSDigitsEvent->GetMaximum() > 0. ) | |
310 | gPad->SetLogy(); | |
311 | fhPHOSDigitsEvent->SetAxisRange(0,40.); | |
312 | fhPHOSDigitsEvent->SetLineColor(2); | |
313 | fhPHOSDigitsEvent->Draw(); | |
314 | ||
315 | cPHOS->Print("PHOS.eps"); | |
316 | ||
317 | char line[1024] ; | |
318 | sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ; | |
319 | gROOT->ProcessLine(line); | |
320 | sprintf(line, ".!rm -fR *.eps"); | |
321 | gROOT->ProcessLine(line); | |
322 | ||
323 | AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ; | |
324 | ||
325 | char * report ; | |
326 | if(problem) | |
327 | report="Problems found, please check!!!"; | |
328 | else | |
329 | report="OK"; | |
330 | ||
331 | AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report)) ; | |
332 | } |