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 // A basic analysis task to analyse photon detected by PHOS
22 //////////////////////////////////////////////////////////////////////////////
35 #include "AliAnaGammaPhos.h"
36 #include "AliAnalysisManager.h"
38 #include "AliAODEvent.h"
39 #include "AliAODHandler.h"
42 //______________________________________________________________________________
43 AliAnaGammaPhos::AliAnaGammaPhos() :
56 fhPHOSRecParticles(0),
58 fhPHOSInvariantMass(0),
63 //______________________________________________________________________________
64 AliAnaGammaPhos::AliAnaGammaPhos(const char *name) :
65 AliAnalysisTask(name,""),
78 fhPHOSRecParticles(0),
80 fhPHOSInvariantMass(0),
85 DefineInput(0, TChain::Class());
87 DefineOutput(0, TTree::Class()) ;
88 DefineOutput(1, TList::Class()) ;
91 //______________________________________________________________________________
92 AliAnaGammaPhos::~AliAnaGammaPhos()
95 fOutputList->Clear() ;
100 //______________________________________________________________________________
101 void AliAnaGammaPhos::ConnectInputData(const Option_t*)
103 // Initialisation of branch container and histograms
105 AliInfo(Form("*** Initialization of %s", GetName())) ;
108 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
110 AliError(Form("Input 0 for %s not found\n", GetName()));
114 // One should first check if the branch address was taken by some other task
115 char ** address = (char **)GetBranchAddress(0, "ESD");
117 fESD = (AliESD*)(*address);
120 SetBranchAddress(0, "ESD", &fESD);
124 //________________________________________________________________________
125 void AliAnaGammaPhos::CreateOutputObjects()
127 // Create the outputs containers
130 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler());
131 fAOD = handler->GetAOD();
132 fAODPhotons = fAOD->GetClusters() ;
136 fhPHOSPos = new TNtuple("PHOSPos" , "Position in PHOS" , "x:y:z");
137 fhPHOS = new TNtuple("PHOS" , "PHOS" , "event:digits:clusters:photons");
138 fhPHOSEnergy = new TH1D("PHOSEnergy" , "PHOSEnergy" , 1000, 0., 10. ) ;
139 fhPHOSDigits = new TH1I("PHOSDigitsCluster" , "PHOSDigits" , 20 , 0 , 20 ) ;
140 fhPHOSRecParticles = new TH1D("PHOSRecParticles" , "PHOSRecParticles" , 20 , 0., 20. ) ;
141 fhPHOSPhotons = new TH1I("PHOSPhotons" , "PHOSPhotons" , 20 , 0 , 20 ) ;
142 fhPHOSInvariantMass = new TH1D("PHOSInvariantMass" , "PHOSInvariantMass" , 400, 0., 400.) ;
143 fhPHOSDigitsEvent = new TH1I("PHOSDigitsEvent" , "PHOSDigitsEvent" , 30 , 0 , 30 ) ;
145 // create output container
147 fOutputList = new TList() ;
148 fOutputList->SetName(GetName()) ;
150 fOutputList->AddAt(fhPHOSPos, 0) ;
151 fOutputList->AddAt(fhPHOS, 1) ;
152 fOutputList->AddAt(fhPHOSEnergy, 2) ;
153 fOutputList->AddAt(fhPHOSDigits, 3) ;
154 fOutputList->AddAt(fhPHOSRecParticles, 4) ;
155 fOutputList->AddAt(fhPHOSPhotons, 5) ;
156 fOutputList->AddAt(fhPHOSInvariantMass, 6) ;
157 fOutputList->AddAt(fhPHOSDigitsEvent, 7) ;
160 //______________________________________________________________________________
161 void AliAnaGammaPhos::Exec(Option_t *)
163 // Processing of one event
165 Long64_t entry = fChain->GetReadEntry() ;
168 AliError("fESD is not connected to the input!") ;
172 if ( !((entry-1)%100) )
173 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
175 //************************ PHOS *************************************
177 Int_t firstPhosCluster = fESD->GetFirstPHOSCluster() ;
178 const Int_t numberOfPhosClusters = fESD->GetNumberOfPHOSClusters() ;
180 TVector3 ** phosVector = new TVector3*[numberOfPhosClusters] ;
181 Float_t * phosPhotonsEnergy = new Float_t[numberOfPhosClusters] ;
183 Int_t numberOfDigitsInPhos = 0 ;
186 // loop over the PHOS Cluster
187 for(phosCluster = firstPhosCluster ; phosCluster < firstPhosCluster + numberOfPhosClusters ; phosCluster++) {
188 AliESDCaloCluster * caloCluster = fESD->GetCaloCluster(phosCluster) ;
191 caloCluster->GetGlobalPosition( pos ) ;
192 fhPHOSEnergy->Fill( caloCluster->GetClusterEnergy() ) ;
193 fhPHOSPos->Fill( pos[0], pos[1], pos[2] ) ;
194 fhPHOSDigits->Fill(entry, caloCluster->GetNumberOfDigits() ) ;
195 numberOfDigitsInPhos += caloCluster->GetNumberOfDigits() ;
196 Float_t * pid = caloCluster->GetPid() ;
197 if(pid[AliPID::kPhoton] > GetPhotonId() ) {
198 phosVector[fPhotonsInPhos] = new TVector3(pos[0],pos[1],pos[2]) ;
199 phosPhotonsEnergy[fPhotonsInPhos]=caloCluster->GetClusterEnergy() ;
200 //new ((*fAODPhotons)[fPhotonsInPhos++;]) AliAODPhoton ( );
205 fhPHOSRecParticles->Fill(numberOfPhosClusters);
206 fhPHOSPhotons->Fill(fPhotonsInPhos);
207 fhPHOSDigitsEvent->Fill(numberOfDigitsInPhos);
208 fhPHOS->Fill(entry, numberOfDigitsInPhos, numberOfPhosClusters, fPhotonsInPhos) ;
211 if (fPhotonsInPhos > 1 ) {
212 Int_t phosPhoton1, phosPhoton2 ;
213 for(phosPhoton1 = 0 ; phosPhoton1 < fPhotonsInPhos ; phosPhoton1++) {
214 for(phosPhoton2 = phosPhoton1 + 1 ; phosPhoton2 < fPhotonsInPhos ; phosPhoton2++) {
215 Float_t tempMass = TMath::Sqrt( 2 * phosPhotonsEnergy[phosPhoton1] * phosPhotonsEnergy[phosPhoton2] *
216 ( 1 - TMath::Cos(phosVector[phosPhoton1]->Angle(*phosVector[phosPhoton2])) )
218 fhPHOSInvariantMass->Fill(tempMass*1000.);
223 PostData(0, fTreeA) ;
224 PostData(1, fOutputList);
226 delete [] phosVector ;
227 delete [] phosPhotonsEnergy ;
232 //______________________________________________________________________________
233 void AliAnaGammaPhos::Init()
235 // Intialisation of parameters
236 AliInfo("Doing initialisation") ;
240 //______________________________________________________________________________
241 void AliAnaGammaPhos::Terminate(Option_t *)
243 // Processing when the event loop is ended
245 fOutputList = (TList*)GetOutputData(1);
246 fhPHOSPos = (TNtuple*)fOutputList->At(0);
247 fhPHOS = (TNtuple*)fOutputList->At(1);
248 fhPHOSEnergy = (TH1D*)fOutputList->At(2);
249 fhPHOSDigits = (TH1I*)fOutputList->At(3);
250 fhPHOSRecParticles = (TH1D*)fOutputList->At(4);
251 fhPHOSPhotons = (TH1I*)fOutputList->At(5);
252 fhPHOSInvariantMass = (TH1D*)fOutputList->At(6);
253 fhPHOSDigitsEvent = (TH1I*)fOutputList->At(7);
255 Bool_t problem = kFALSE ;
256 AliInfo(Form(" *** %s Report:", GetName())) ;
257 printf(" PHOSEnergy Mean : %5.3f , RMS : %5.3f \n", fhPHOSEnergy->GetMean(), fhPHOSEnergy->GetRMS() ) ;
258 printf(" PHOSDigits Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigits->GetMean(), fhPHOSDigits->GetRMS() ) ;
259 printf(" PHOSRecParticles Mean : %5.3f , RMS : %5.3f \n", fhPHOSRecParticles->GetMean(), fhPHOSRecParticles->GetRMS() ) ;
260 printf(" PHOSPhotons Mean : %5.3f , RMS : %5.3f \n", fhPHOSPhotons->GetMean(), fhPHOSPhotons->GetRMS() ) ;
261 printf(" PHOSInvariantMass Mean : %5.3f , RMS : %5.3f \n", fhPHOSInvariantMass->GetMean(), fhPHOSInvariantMass->GetRMS() ) ;
262 printf(" PHOSDigitsEvent Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigitsEvent->GetMean(), fhPHOSDigitsEvent->GetRMS() ) ;
264 TCanvas * cPHOS = new TCanvas("cPHOS", "PHOS ESD Test", 400, 10, 600, 700) ;
268 if ( fhPHOSEnergy->GetMaximum() > 0. )
270 fhPHOSEnergy->SetAxisRange(0, 25.);
271 fhPHOSEnergy->SetLineColor(2);
272 fhPHOSEnergy->Draw();
275 fhPHOSDigits->SetAxisRange(0,25.);
276 fhPHOSDigits->SetLineColor(2);
277 fhPHOSDigits->Draw();
280 if ( fhPHOSRecParticles->GetMaximum() > 0. )
282 fhPHOSRecParticles->SetAxisRange(0, 25.);
283 fhPHOSRecParticles->SetLineColor(2);
284 fhPHOSRecParticles->Draw();
287 if ( fhPHOSPhotons->GetMaximum() > 0. )
289 fhPHOSPhotons->SetAxisRange(0,25.);
290 fhPHOSPhotons->SetLineColor(2);
291 fhPHOSPhotons->Draw();
294 fhPHOSInvariantMass->SetLineColor(2);
295 fhPHOSInvariantMass->Draw();
298 if ( fhPHOSDigitsEvent->GetMaximum() > 0. )
300 fhPHOSDigitsEvent->SetAxisRange(0,40.);
301 fhPHOSDigitsEvent->SetLineColor(2);
302 fhPHOSDigitsEvent->Draw();
304 cPHOS->Print("PHOS.eps");
307 sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ;
308 gROOT->ProcessLine(line);
309 sprintf(line, ".!rm -fR *.eps");
310 gROOT->ProcessLine(line);
312 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
316 report="Problems found, please check!!!";
320 AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report)) ;