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"
40 #include "AliAODPhoton.h"
43 //______________________________________________________________________________
44 AliAnaGammaPhos::AliAnaGammaPhos() :
57 fhPHOSRecParticles(0),
59 fhPHOSInvariantMass(0),
64 //______________________________________________________________________________
65 AliAnaGammaPhos::AliAnaGammaPhos(const char *name) :
66 AliAnalysisTask(name,""),
79 fhPHOSRecParticles(0),
81 fhPHOSInvariantMass(0),
86 DefineInput(0, TChain::Class());
88 DefineOutput(0, TTree::Class()) ;
89 DefineOutput(1, TList::Class()) ;
92 //______________________________________________________________________________
93 AliAnaGammaPhos::~AliAnaGammaPhos()
96 // fOutputList->Clear() ;
97 //delete fOutputList ;
101 //______________________________________________________________________________
102 void AliAnaGammaPhos::ConnectInputData(const Option_t*)
104 // Initialisation of branch container and histograms
106 AliInfo(Form("*** Initialization of %s", GetName())) ;
109 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
111 AliError(Form("Input 0 for %s not found\n", GetName()));
115 // One should first check if the branch address was taken by some other task
116 char ** address = (char **)GetBranchAddress(0, "ESD");
118 fESD = (AliESD*)(*address);
121 SetBranchAddress(0, "ESD", &fESD);
125 //________________________________________________________________________
126 void AliAnaGammaPhos::CreateOutputObjects()
128 // Create the outputs containers
131 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler());
132 fTreeA = handler->GetTree() ;
133 fAOD = handler->GetAOD();
134 fAODPhotons = fAOD->GetClusters() ;
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 ) ;
148 // create output container
150 fOutputList = new TList() ;
151 fOutputList->SetName(GetName()) ;
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) ;
163 //______________________________________________________________________________
164 void AliAnaGammaPhos::Exec(Option_t *)
166 // Processing of one event
168 Long64_t entry = fChain->GetReadEntry() ;
171 AliError("fESD is not connected to the input!") ;
175 if ( !((entry-1)%100) )
176 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
178 //************************ PHOS *************************************
180 Int_t firstPhosCluster = fESD->GetFirstPHOSCluster() ;
181 const Int_t numberOfPhosClusters = fESD->GetNumberOfPHOSClusters() ;
183 TVector3 ** phosVector = new TVector3*[numberOfPhosClusters] ;
184 Float_t * phosPhotonsEnergy = new Float_t[numberOfPhosClusters] ;
186 Int_t numberOfDigitsInPhos = 0 ;
189 // loop over the PHOS Cluster
190 for(phosCluster = firstPhosCluster ; phosCluster < firstPhosCluster + numberOfPhosClusters ; phosCluster++) {
191 AliESDCaloCluster * caloCluster = fESD->GetCaloCluster(phosCluster) ;
194 caloCluster->GetPosition( pos ) ;
195 fhPHOSEnergy->Fill( caloCluster->E() ) ;
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]) ;
202 phosPhotonsEnergy[fPhotonsInPhos]=caloCluster->E() ;
203 //new ((*fAODPhotons)[fPhotonsInPhos++;]) AliAODPhoton ( );
208 fhPHOSRecParticles->Fill(numberOfPhosClusters);
209 fhPHOSPhotons->Fill(fPhotonsInPhos);
210 fhPHOSDigitsEvent->Fill(numberOfDigitsInPhos);
211 fhPHOS->Fill(entry, numberOfDigitsInPhos, numberOfPhosClusters, fPhotonsInPhos) ;
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])) )
221 fhPHOSInvariantMass->Fill(tempMass*1000.);
226 PostData(0, fTreeA) ;
227 PostData(1, fOutputList);
229 delete [] phosVector ;
230 delete [] phosPhotonsEnergy ;
235 //______________________________________________________________________________
236 void AliAnaGammaPhos::Init()
238 // Intialisation of parameters
239 AliInfo("Doing initialisation") ;
243 //______________________________________________________________________________
244 void AliAnaGammaPhos::Terminate(Option_t *)
246 // Processing when the event loop is ended
248 // fOutputList = (TList*)GetOutputData(0);
249 // fhPHOSPos = (TNtuple*)fOutputList->At(0);
250 // fhPHOS = (TNtuple*)fOutputList->At(1);
251 // fhPHOSEnergy = (TH1D*)fOutputList->At(2);
252 // fhPHOSDigits = (TH1I*)fOutputList->At(3);
253 // fhPHOSRecParticles = (TH1D*)fOutputList->At(4);
254 // fhPHOSPhotons = (TH1I*)fOutputList->At(5);
255 // fhPHOSInvariantMass = (TH1D*)fOutputList->At(6);
256 // fhPHOSDigitsEvent = (TH1I*)fOutputList->At(7);
259 Bool_t problem = kFALSE ;
260 AliInfo(Form(" *** %s Report:", GetName())) ;
261 printf(" PHOSEnergy Mean : %5.3f , RMS : %5.3f \n", fhPHOSEnergy->GetMean(), fhPHOSEnergy->GetRMS() ) ;
262 printf(" PHOSDigits Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigits->GetMean(), fhPHOSDigits->GetRMS() ) ;
263 printf(" PHOSRecParticles Mean : %5.3f , RMS : %5.3f \n", fhPHOSRecParticles->GetMean(), fhPHOSRecParticles->GetRMS() ) ;
264 printf(" PHOSPhotons Mean : %5.3f , RMS : %5.3f \n", fhPHOSPhotons->GetMean(), fhPHOSPhotons->GetRMS() ) ;
265 printf(" PHOSInvariantMass Mean : %5.3f , RMS : %5.3f \n", fhPHOSInvariantMass->GetMean(), fhPHOSInvariantMass->GetRMS() ) ;
266 printf(" PHOSDigitsEvent Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigitsEvent->GetMean(), fhPHOSDigitsEvent->GetRMS() ) ;
268 TCanvas * cPHOS = new TCanvas("cPHOS", "PHOS ESD Test", 400, 10, 600, 700) ;
272 if ( fhPHOSEnergy->GetMaximum() > 0. )
274 fhPHOSEnergy->SetAxisRange(0, 25.);
275 fhPHOSEnergy->SetLineColor(2);
276 fhPHOSEnergy->Draw();
279 fhPHOSDigits->SetAxisRange(0,25.);
280 fhPHOSDigits->SetLineColor(2);
281 fhPHOSDigits->Draw();
284 if ( fhPHOSRecParticles->GetMaximum() > 0. )
286 fhPHOSRecParticles->SetAxisRange(0, 25.);
287 fhPHOSRecParticles->SetLineColor(2);
288 fhPHOSRecParticles->Draw();
291 if ( fhPHOSPhotons->GetMaximum() > 0. )
293 fhPHOSPhotons->SetAxisRange(0,25.);
294 fhPHOSPhotons->SetLineColor(2);
295 fhPHOSPhotons->Draw();
298 fhPHOSInvariantMass->SetLineColor(2);
299 fhPHOSInvariantMass->Draw();
302 if ( fhPHOSDigitsEvent->GetMaximum() > 0. )
304 fhPHOSDigitsEvent->SetAxisRange(0,40.);
305 fhPHOSDigitsEvent->SetLineColor(2);
306 fhPHOSDigitsEvent->Draw();
308 cPHOS->Print("PHOS.eps");
311 sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ;
312 gROOT->ProcessLine(line);
313 sprintf(line, ".!rm -fR *.eps");
314 gROOT->ProcessLine(line);
316 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
320 report="Problems found, please check!!!";
324 AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report)) ;