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 // An analysis task to check the PHOS photon data in simulated data
22 //////////////////////////////////////////////////////////////////////////////
35 #include "AliPHOSQATask.h"
39 //______________________________________________________________________________
40 AliPHOSQATask::AliPHOSQATask(const char *name) :
41 AliAnalysisTask(name,""),
47 fhPHOSRecParticles(0),
49 fhPHOSInvariantMass(0),
53 // Input slot #0 works with an Ntuple
54 DefineInput(0, TChain::Class());
55 // Output slot #0 writes into a TH1 container
56 DefineOutput(0, TObjArray::Class()) ;
59 //______________________________________________________________________________
60 AliPHOSQATask::~AliPHOSQATask()
63 fOutputContainer->Clear() ;
64 delete fOutputContainer ;
70 delete fhPHOSRecParticles ;
71 delete fhPHOSPhotons ;
72 delete fhPHOSInvariantMass ;
73 delete fhPHOSDigitsEvent ;
77 //______________________________________________________________________________
78 void AliPHOSQATask::ConnectInputData(const Option_t*)
80 // Initialisation of branch container and histograms
82 AliInfo(Form("*** Initialization of %s", GetName())) ;
85 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
87 AliError(Form("Input 0 for %s not found\n", GetName()));
91 // One should first check if the branch address was taken by some other task
92 char ** address = (char **)GetBranchAddress(0, "ESD");
94 fESD = (AliESD*)(*address);
97 SetBranchAddress(0, "ESD", &fESD);
101 //________________________________________________________________________
102 void AliPHOSQATask::CreateOutputObjects()
108 fhPHOSPos = new TNtuple("PHOSPos" , "Position in PHOS" , "x:y:z");
109 fhPHOS = new TNtuple("PHOS" , "PHOS" , "event:digits:clusters:photons");
110 fhPHOSEnergy = new TH1D("PHOSEnergy" , "PHOSEnergy" , 1000, 0., 10. ) ;
111 fhPHOSDigits = new TH1I("PHOSDigitsCluster" , "PHOSDigits" , 20 , 0 , 20 ) ;
112 fhPHOSRecParticles = new TH1D("PHOSRecParticles" , "PHOSRecParticles" , 20 , 0., 20. ) ;
113 fhPHOSPhotons = new TH1I("PHOSPhotons" , "PHOSPhotons" , 20 , 0 , 20 ) ;
114 fhPHOSInvariantMass = new TH1D("PHOSInvariantMass" , "PHOSInvariantMass" , 400, 0., 400.) ;
115 fhPHOSDigitsEvent = new TH1I("PHOSDigitsEvent" , "PHOSDigitsEvent" , 30 , 0 , 30 ) ;
117 // create output container
119 fOutputContainer = new TObjArray(8) ;
120 fOutputContainer->SetName(GetName()) ;
122 fOutputContainer->AddAt(fhPHOSPos, 0) ;
123 fOutputContainer->AddAt(fhPHOS, 1) ;
124 fOutputContainer->AddAt(fhPHOSEnergy, 2) ;
125 fOutputContainer->AddAt(fhPHOSDigits, 3) ;
126 fOutputContainer->AddAt(fhPHOSRecParticles, 4) ;
127 fOutputContainer->AddAt(fhPHOSPhotons, 5) ;
128 fOutputContainer->AddAt(fhPHOSInvariantMass, 6) ;
129 fOutputContainer->AddAt(fhPHOSDigitsEvent, 7) ;
132 //______________________________________________________________________________
133 void AliPHOSQATask::Exec(Option_t *)
135 // Processing of one event
137 Long64_t entry = fChain->GetReadEntry() ;
140 AliError("fESD is not connected to the input!") ;
144 if ( !((entry-1)%100) )
145 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
147 //************************ PHOS *************************************
149 Int_t firstPhosCluster = fESD->GetFirstPHOSCluster() ;
150 const Int_t numberOfPhosClusters = fESD->GetNumberOfPHOSClusters() ;
152 TVector3 ** phosVector = new TVector3*[numberOfPhosClusters] ;
153 Float_t * phosPhotonsEnergy = new Float_t[numberOfPhosClusters] ;
155 Int_t numberOfPhotonsInPhos = 0 ;
156 Int_t numberOfDigitsInPhos = 0 ;
158 // loop over the PHOS Cluster
159 for(phosCluster = firstPhosCluster ; phosCluster < firstPhosCluster + numberOfPhosClusters ; phosCluster++) {
160 AliESDCaloCluster * caloCluster = fESD->GetCaloCluster(phosCluster) ;
163 caloCluster->GetGlobalPosition( pos ) ;
164 fhPHOSEnergy->Fill( caloCluster->GetClusterEnergy() ) ;
165 fhPHOSPos->Fill( pos[0], pos[1], pos[2] ) ;
166 fhPHOSDigits->Fill(entry, caloCluster->GetNumberOfDigits() ) ;
167 numberOfDigitsInPhos += caloCluster->GetNumberOfDigits() ;
168 Float_t * pid = caloCluster->GetPid() ;
169 if(pid[AliPID::kPhoton] > 0.9) {
170 phosVector[numberOfPhotonsInPhos] = new TVector3(pos[0],pos[1],pos[2]) ;
171 phosPhotonsEnergy[numberOfPhotonsInPhos]=caloCluster->GetClusterEnergy() ;
172 numberOfPhotonsInPhos++;
177 fhPHOSRecParticles->Fill(numberOfPhosClusters);
178 fhPHOSPhotons->Fill(numberOfPhotonsInPhos);
179 fhPHOSDigitsEvent->Fill(numberOfDigitsInPhos);
180 fhPHOS->Fill(entry, numberOfDigitsInPhos, numberOfPhosClusters, numberOfPhotonsInPhos) ;
183 if (numberOfPhotonsInPhos > 1 ) {
184 Int_t phosPhoton1, phosPhoton2 ;
185 for(phosPhoton1 = 0 ; phosPhoton1 < numberOfPhotonsInPhos ; phosPhoton1++) {
186 for(phosPhoton2 = phosPhoton1 + 1 ; phosPhoton2 < numberOfPhotonsInPhos ; phosPhoton2++) {
187 Float_t tempMass = TMath::Sqrt( 2 * phosPhotonsEnergy[phosPhoton1] * phosPhotonsEnergy[phosPhoton2] *
188 ( 1 - TMath::Cos(phosVector[phosPhoton1]->Angle(*phosVector[phosPhoton2])) )
190 fhPHOSInvariantMass->Fill(tempMass*1000.);
195 PostData(0, fOutputContainer);
197 delete [] phosVector ;
198 delete [] phosPhotonsEnergy ;
202 //______________________________________________________________________________
203 void AliPHOSQATask::Terminate(Option_t *)
205 // Processing when the event loop is ended
207 fOutputContainer = (TObjArray*)GetOutputData(0);
208 fhPHOSPos = (TNtuple*)fOutputContainer->At(0);
209 fhPHOS = (TNtuple*)fOutputContainer->At(1);
210 fhPHOSEnergy = (TH1D*)fOutputContainer->At(2);
211 fhPHOSDigits = (TH1I*)fOutputContainer->At(3);
212 fhPHOSRecParticles = (TH1D*)fOutputContainer->At(4);
213 fhPHOSPhotons = (TH1I*)fOutputContainer->At(5);
214 fhPHOSInvariantMass = (TH1D*)fOutputContainer->At(6);
215 fhPHOSDigitsEvent = (TH1I*)fOutputContainer->At(7);
217 Bool_t problem = kFALSE ;
218 AliInfo(Form(" *** %s Report:", GetName())) ;
219 printf(" PHOSEnergy Mean : %5.3f , RMS : %5.3f \n", fhPHOSEnergy->GetMean(), fhPHOSEnergy->GetRMS() ) ;
220 printf(" PHOSDigits Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigits->GetMean(), fhPHOSDigits->GetRMS() ) ;
221 printf(" PHOSRecParticles Mean : %5.3f , RMS : %5.3f \n", fhPHOSRecParticles->GetMean(), fhPHOSRecParticles->GetRMS() ) ;
222 printf(" PHOSPhotons Mean : %5.3f , RMS : %5.3f \n", fhPHOSPhotons->GetMean(), fhPHOSPhotons->GetRMS() ) ;
223 printf(" PHOSInvariantMass Mean : %5.3f , RMS : %5.3f \n", fhPHOSInvariantMass->GetMean(), fhPHOSInvariantMass->GetRMS() ) ;
224 printf(" PHOSDigitsEvent Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigitsEvent->GetMean(), fhPHOSDigitsEvent->GetRMS() ) ;
226 TCanvas * cPHOS = new TCanvas("cPHOS", "PHOS ESD Test", 400, 10, 600, 700) ;
230 if ( fhPHOSEnergy->GetMaximum() > 0. )
232 fhPHOSEnergy->SetAxisRange(0, 25.);
233 fhPHOSEnergy->SetLineColor(2);
234 fhPHOSEnergy->Draw();
237 fhPHOSDigits->SetAxisRange(0,25.);
238 fhPHOSDigits->SetLineColor(2);
239 fhPHOSDigits->Draw();
242 if ( fhPHOSRecParticles->GetMaximum() > 0. )
244 fhPHOSRecParticles->SetAxisRange(0, 25.);
245 fhPHOSRecParticles->SetLineColor(2);
246 fhPHOSRecParticles->Draw();
249 if ( fhPHOSPhotons->GetMaximum() > 0. )
251 fhPHOSPhotons->SetAxisRange(0,25.);
252 fhPHOSPhotons->SetLineColor(2);
253 fhPHOSPhotons->Draw();
256 fhPHOSInvariantMass->SetLineColor(2);
257 fhPHOSInvariantMass->Draw();
260 if ( fhPHOSDigitsEvent->GetMaximum() > 0. )
262 fhPHOSDigitsEvent->SetAxisRange(0,40.);
263 fhPHOSDigitsEvent->SetLineColor(2);
264 fhPHOSDigitsEvent->Draw();
266 cPHOS->Print("PHOS.eps");
269 sprintf(line, ".!tar -zcf %s.tar.gz *.eps", GetName()) ;
270 gROOT->ProcessLine(line);
271 sprintf(line, ".!rm -fR *.eps");
272 gROOT->ProcessLine(line);
274 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!!", GetName())) ;
278 report="Problems found, please check!!!";
282 AliInfo(Form("*** %s Summary Report: %s \n",GetName(), report)) ;