Removing AliITSgeom dependencies from the old ITS clusterer V2 and the corresponding...
[u/mrichter/AliRoot.git] / PWG4 / AliTriggerPHOS.cxx
CommitLineData
6c3efb37 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//_________________________________________________________________________
17// An analysis task to check the PHOS photon data in simulated data
18//
19//*-- Yves Schutz
20//////////////////////////////////////////////////////////////////////////////
21
22#include <TChain.h>
23#include <TFile.h>
24#include <TNtuple.h>
25#include <TVector3.h>
26
27#include "AliTriggerPHOS.h"
28#include "AliESD.h"
29#include "AliLog.h"
30
31//______________________________________________________________________________
32AliTriggerPHOS::AliTriggerPHOS(const char *name) :
33 AliAnalysisTask(name,""),
34 fChain(0),
35 fESD(0),
36 fOutputContainer(0),
37 fNtTrigger22(0),
38 fNtTriggerNN(0)
39
40{
41 // Constructor.
42 // Input slot #0 works with an Ntuple
43 DefineInput(0, TChain::Class());
44 // Output slot #0 writes into a TH1 container
45 DefineOutput(0, TObjArray::Class()) ;
46}
47
48//______________________________________________________________________________
49AliTriggerPHOS::~AliTriggerPHOS()
50{
51 // dtor
52 fOutputContainer->Clear() ;
53 delete fOutputContainer ;
54 delete fNtTrigger22 ;
55 delete fNtTriggerNN ;
56}
57
58
59//______________________________________________________________________________
60void AliTriggerPHOS::ConnectInputData(const Option_t*)
61{
62 // Initialisation of branch container and histograms
63
64 AliInfo(Form("*** Initialization of %s", GetName())) ;
65
66 // Get input data
67 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
68 if (!fChain) {
69 AliError(Form("Input 0 for %s not found\n", GetName()));
70 return ;
71 }
72
73 // One should first check if the branch address was taken by some other task
74 char ** address = (char **)GetBranchAddress(0, "ESD");
75 if (address) {
76 fESD = (AliESD*)(*address);
77 } else {
78 fESD = new AliESD();
79 SetBranchAddress(0, "ESD", &fESD);
80 }
81}
82
83//________________________________________________________________________
84
85void AliTriggerPHOS::CreateOutputObjects()
86{
87
88 // create histograms
4c0b6461 89 fNtTrigger22 = new TNtuple("PHOStrigger22", "Trigger data 2x2 patch", "a22:a220:enMax:phEnMax:eta22:phi22:etaMax:phiMax:phEtaMax:phPhiMax");
90 fNtTriggerNN = new TNtuple("PHOStriggerNN", "Trigger data NxN patch", "aNN:aNN0:enMax:phEnMax:etaNN:phiNN:etaMax:phiMax:phEtaMax:phPhiMax");
6c3efb37 91
92 // create output container
93
94 fOutputContainer = new TObjArray(2) ;
95 fOutputContainer->SetName(GetName()) ;
96
97 fOutputContainer->AddAt(fNtTrigger22, 0) ;
98 fOutputContainer->AddAt(fNtTriggerNN, 1) ;
99
100}
101
102//______________________________________________________________________________
103void AliTriggerPHOS::Exec(Option_t *)
104{
105 // Processing of one event
106
107 Long64_t entry = fChain->GetReadEntry() ;
108
109 if (!fESD) {
110 AliError("fESD is not connected to the input!") ;
111 return ;
112 }
113
114 if ( !((entry-1)%100) )
115 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
116
117 // ************************ PHOS *************************************
118 // Get trigger information
119
120 // trigger amplitudes
121 const TArrayF * triggerAmplitudes = fESD->GetPHOSTriggerAmplitudes();
122 const Float_t a22 = static_cast<Float_t>(triggerAmplitudes->At(0)) ;
123 const Float_t a22O = static_cast<Float_t>(triggerAmplitudes->At(1)) ;
124 const Float_t aNN = static_cast<Float_t>(triggerAmplitudes->At(2)) ;
125 const Float_t aNNO = static_cast<Float_t>(triggerAmplitudes->At(3)) ;
126
127 // trigger position
64df000d 128 const TArrayF * triggerPosition = fESD->GetPHOSTriggerPosition();
4c0b6461 129 const Float_t x22 = static_cast<Float_t>(triggerPosition->At(0)) ;
130 const Float_t y22 = static_cast<Float_t>(triggerPosition->At(1)) ;
131 const Float_t z22 = static_cast<Float_t>(triggerPosition->At(2)) ;
132 const Float_t xNN = static_cast<Float_t>(triggerPosition->At(3)) ;
133 const Float_t yNN = static_cast<Float_t>(triggerPosition->At(4)) ;
134 const Float_t zNN = static_cast<Float_t>(triggerPosition->At(5)) ;
6c3efb37 135
136 Int_t firstPhosCluster = fESD->GetFirstPHOSCluster() ;
137 const Int_t numberOfPhosClusters = fESD->GetNumberOfPHOSClusters() ;
138
139 Float_t enMax = 0. ;
140 Float_t phEnMax = 0. ;
4c0b6461 141 Float_t etaMax = 0.5 ;
142 Float_t phiMax = 0. ;
143 Float_t phEtaMax = 0.5 ;
144 Float_t phPhiMax = 0. ;
145
146 TVector3 vpos22(x22, y22, z22) ;
147 TVector3 vposNN(xNN, yNN, zNN) ;
148 Float_t eta22 = vpos22.Eta() ;
149 Float_t phi22 = vpos22.Phi() * TMath::RadToDeg() + 360. ;
150 Float_t etaNN = vposNN.Eta() ;
151 Float_t phiNN = vposNN.Phi() * TMath::RadToDeg() + 360. ;
6c3efb37 152
153 Int_t phosCluster ;
154
155 // loop over the PHOS Cluster
156
157 for(phosCluster = firstPhosCluster ; phosCluster < firstPhosCluster + numberOfPhosClusters ; phosCluster++) {
158 AliESDCaloCluster * caloCluster = fESD->GetCaloCluster(phosCluster) ;
159 if (caloCluster) {
160
161 Float_t cluEnergy = caloCluster->GetClusterEnergy() ;
162 Float_t pos[3] ;
163 TVector3 vpos ;
164
165 caloCluster->GetGlobalPosition( pos ) ;
166
167 if ( cluEnergy > enMax) {
168 enMax = cluEnergy ;
169 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
170 etaMax = vpos.Eta() ;
171 phiMax = vpos.Phi() ;
172 }
173
174 Float_t * pid = caloCluster->GetPid() ;
175
176 if(pid[AliPID::kPhoton] > 0.9) {
177 if ( cluEnergy > phEnMax) {
178 phEnMax = cluEnergy ;
179 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
180 phEtaMax = vpos.Eta() ;
181 phPhiMax = vpos.Phi() ;
182 }
183 }
184 }
185
4c0b6461 186 fNtTrigger22->Fill(a22, a22O, enMax, phEnMax, eta22, phi22, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
187 fNtTriggerNN->Fill(aNN, aNNO, enMax, phEnMax, etaNN, phiNN, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
6c3efb37 188 }
189
190
191 PostData(0, fOutputContainer);
192
193}
194
195//______________________________________________________________________________
196void AliTriggerPHOS::Terminate(Option_t *)
197{
198 // Processing when the event loop is ended
199
200}