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 **************************************************************************/
15 //_________________________________________________________________________
16 // An analysis task to check the PHOS photon data in simulated data
19 //////////////////////////////////////////////////////////////////////////////
31 #include "AliPHOSQATask.h"
35 //______________________________________________________________________________
36 AliPHOSQATask::AliPHOSQATask(const char *name) :
37 AliAnalysisTask(name,""),
43 fhPHOSRecParticles(0),
45 fhPHOSInvariantMass(0),
49 // Input slot #0 works with an Ntuple
50 DefineInput(0, TChain::Class());
51 // Output slot #0 writes into a TH1 container
52 DefineOutput(0, TObjArray::Class()) ;
55 //______________________________________________________________________________
56 AliPHOSQATask::~AliPHOSQATask()
59 fOutputContainer->Clear() ;
60 delete fOutputContainer ;
66 delete fhPHOSRecParticles ;
67 delete fhPHOSPhotons ;
68 delete fhPHOSInvariantMass ;
69 delete fhPHOSDigitsEvent ;
73 //______________________________________________________________________________
74 void AliPHOSQATask::Init(const Option_t*)
76 // Initialisation of branch container and histograms
78 AliInfo(Form("*** Initialization of %s", GetName())) ;
81 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
83 AliError(Form("Input 0 for %s not found\n", GetName()));
88 // One should first check if the branch address was taken by some other task
89 char ** address = (char **)GetBranchAddress(0, "ESD") ;
91 fESD = (AliESD *)(*address) ;
93 fChain->SetBranchAddress("ESD", &fESD) ;
95 // The output objects will be written to
96 TDirectory * cdir = gDirectory ;
97 // Open a file for output #0
98 char outputName[1024] ;
99 sprintf(outputName, "%s.root", GetName() ) ;
100 OpenFile(0, outputName , "RECREATE") ;
106 fhPHOSPos = new TNtuple("PHOSPos" , "Position in PHOS" , "x:y:z");
107 fhPHOS = new TNtuple("PHOS" , "PHOS" , "event:digits:clusters:photons");
108 fhPHOSEnergy = new TH1D("PHOSEnergy" , "PHOSEnergy" , 1000, 0., 10. ) ;
109 fhPHOSDigits = new TH1I("PHOSDigitsCluster" , "PHOSDigits" , 20 , 0 , 20 ) ;
110 fhPHOSRecParticles = new TH1D("PHOSRecParticles" , "PHOSRecParticles" , 20 , 0., 20. ) ;
111 fhPHOSPhotons = new TH1I("PHOSPhotons" , "PHOSPhotons" , 20 , 0 , 20 ) ;
112 fhPHOSInvariantMass = new TH1D("PHOSInvariantMass" , "PHOSInvariantMass" , 400, 0., 400.) ;
113 fhPHOSDigitsEvent = new TH1I("PHOSDigitsEvent" , "PHOSDigitsEvent" , 30 , 0 , 30 ) ;
115 // create output container
117 fOutputContainer = new TObjArray(8) ;
118 fOutputContainer->SetName(GetName()) ;
120 fOutputContainer->AddAt(fhPHOSPos, 0) ;
121 fOutputContainer->AddAt(fhPHOS, 1) ;
122 fOutputContainer->AddAt(fhPHOSEnergy, 2) ;
123 fOutputContainer->AddAt(fhPHOSDigits, 3) ;
124 fOutputContainer->AddAt(fhPHOSRecParticles, 4) ;
125 fOutputContainer->AddAt(fhPHOSPhotons, 5) ;
126 fOutputContainer->AddAt(fhPHOSInvariantMass, 6) ;
127 fOutputContainer->AddAt(fhPHOSDigitsEvent, 7) ;
130 //______________________________________________________________________________
131 void AliPHOSQATask::Exec(Option_t *)
133 // Processing of one event
135 Long64_t entry = fChain->GetReadEntry() ;
138 AliError("fESD is not connected to the input!") ;
142 if ( !((entry-1)%100) )
143 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
145 //************************ PHOS *************************************
147 Int_t firstPhosCluster = fESD->GetFirstPHOSCluster() ;
148 const Int_t numberOfPhosClusters = fESD->GetNumberOfPHOSClusters() ;
150 TVector3 ** phosVector = new TVector3*[numberOfPhosClusters] ;
151 Float_t * phosPhotonsEnergy = new Float_t[numberOfPhosClusters] ;
153 Int_t numberOfPhotonsInPhos = 0 ;
154 Int_t numberOfDigitsInPhos = 0 ;
156 // loop over the PHOS Cluster
157 for(phosCluster = firstPhosCluster ; phosCluster < firstPhosCluster + numberOfPhosClusters ; phosCluster++) {
158 AliESDCaloCluster * caloCluster = fESD->GetCaloCluster(phosCluster) ;
161 caloCluster->GetGlobalPosition( pos ) ;
162 fhPHOSEnergy->Fill( caloCluster->GetClusterEnergy() ) ;
163 fhPHOSPos->Fill( pos[0], pos[1], pos[2] ) ;
164 fhPHOSDigits->Fill(entry, caloCluster->GetNumberOfDigits() ) ;
165 numberOfDigitsInPhos += caloCluster->GetNumberOfDigits() ;
166 Float_t * pid = caloCluster->GetPid() ;
167 if(pid[AliPID::kPhoton] > 0.9) {
168 phosVector[numberOfPhotonsInPhos] = new TVector3(pos[0],pos[1],pos[2]) ;
169 phosPhotonsEnergy[numberOfPhotonsInPhos]=caloCluster->GetClusterEnergy() ;
170 numberOfPhotonsInPhos++;
175 fhPHOSRecParticles->Fill(numberOfPhosClusters);
176 fhPHOSPhotons->Fill(numberOfPhotonsInPhos);
177 fhPHOSDigitsEvent->Fill(numberOfDigitsInPhos);
178 fhPHOS->Fill(entry, numberOfDigitsInPhos, numberOfPhosClusters, numberOfPhotonsInPhos) ;
181 if (numberOfPhotonsInPhos > 1 ) {
182 Int_t phosPhoton1, phosPhoton2 ;
183 for(phosPhoton1 = 0 ; phosPhoton1 < numberOfPhotonsInPhos ; phosPhoton1++) {
184 for(phosPhoton2 = phosPhoton1 + 1 ; phosPhoton2 < numberOfPhotonsInPhos ; phosPhoton2++) {
185 Float_t tempMass = TMath::Sqrt( 2 * phosPhotonsEnergy[phosPhoton1] * phosPhotonsEnergy[phosPhoton2] *
186 ( 1 - TMath::Cos(phosVector[phosPhoton1]->Angle(*phosVector[phosPhoton2])) )
188 fhPHOSInvariantMass->Fill(tempMass*1000.);
193 PostData(0, fOutputContainer);
195 delete [] phosVector ;
196 delete [] phosPhotonsEnergy ;
200 //______________________________________________________________________________
201 void AliPHOSQATask::Terminate(Option_t *)
203 // Processing when the event loop is ended
205 printf("PHOSEnergy Mean : %5.3f , RMS : %5.3f \n", fhPHOSEnergy->GetMean(), fhPHOSEnergy->GetRMS() ) ;
206 printf("PHOSDigits Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigits->GetMean(), fhPHOSDigits->GetRMS() ) ;
207 printf("PHOSRecParticles Mean : %5.3f , RMS : %5.3f \n", fhPHOSRecParticles->GetMean(), fhPHOSRecParticles->GetRMS() ) ;
208 printf("PHOSPhotons Mean : %5.3f , RMS : %5.3f \n", fhPHOSPhotons->GetMean(), fhPHOSPhotons->GetRMS() ) ;
209 printf("PHOSInvariantMass Mean : %5.3f , RMS : %5.3f \n", fhPHOSInvariantMass->GetMean(), fhPHOSInvariantMass->GetRMS() ) ;
210 printf("PHOSDigitsEvent Mean : %5.3f , RMS : %5.3f \n", fhPHOSDigitsEvent->GetMean(), fhPHOSDigitsEvent->GetRMS() ) ;
212 TCanvas * cPHOS = new TCanvas("cPHOS", "PHOS ESD Test", 400, 10, 600, 700) ;
217 fhPHOSEnergy->SetAxisRange(0, 25.);
218 fhPHOSEnergy->SetLineColor(2);
219 fhPHOSEnergy->Draw();
222 fhPHOSDigits->SetAxisRange(0,25.);
223 fhPHOSDigits->SetLineColor(2);
224 fhPHOSDigits->Draw();
228 fhPHOSRecParticles->SetAxisRange(0, 25.);
229 fhPHOSRecParticles->SetLineColor(2);
230 fhPHOSRecParticles->Draw();
234 fhPHOSPhotons->SetAxisRange(0,25.);
235 fhPHOSPhotons->SetLineColor(2);
236 fhPHOSPhotons->Draw();
239 fhPHOSInvariantMass->SetLineColor(2);
240 fhPHOSInvariantMass->Draw();
244 fhPHOSDigitsEvent->SetAxisRange(0,40.);
245 fhPHOSDigitsEvent->SetLineColor(2);
246 fhPHOSDigitsEvent->Draw();
248 cPHOS->Print("PHOS.eps");
251 sprintf(line, ".!tar -zcvf %s.tar.gz *.eps", GetName()) ;
252 gROOT->ProcessLine(line);
253 sprintf(line, ".!rm -fR *.eps");
254 gROOT->ProcessLine(line);
256 AliInfo(Form("!!! All the eps files are in %s.tar.gz !!! \n", GetName())) ;