]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/AliAnaCaloTrigger.cxx
streaming of AliAnaGamma and its data members (removed ! in .h) (MG)
[u/mrichter/AliRoot.git] / PWG4 / AliAnaCaloTrigger.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//_________________________________________________________________________
f38b754b 17// An analysis task to check the trigger data in ESD
18// Creates an ntuple for 2x2 and NxN triggers
19// Each ntuple connects the maximum trigger amplitudes
20// and its positions with reconstructed clusters
6c3efb37 21//
f38b754b 22//*-- Yves Schutz (CERN) & Gustavo Conesa Balbastre (INFN-LNF)
6c3efb37 23//////////////////////////////////////////////////////////////////////////////
24
25#include <TChain.h>
26#include <TFile.h>
27#include <TNtuple.h>
28#include <TVector3.h>
29
f3299f82 30#include "AliAnaCaloTrigger.h"
9ea45617 31#include "AliAnalysisManager.h"
32#include "AliESDEvent.h"
6c3efb37 33#include "AliLog.h"
9ea45617 34#include "AliESDCaloCluster.h"
35
36//______________________________________________________________________________
37AliAnaCaloTrigger::AliAnaCaloTrigger() :
38 fChain(0),
39 fESD(0),
40 fOutputContainer(0),
41 fCalorimeter("PHOS"),
42 fNtTrigger22(0),
43 fNtTriggerNN(0)
44
45{
46 // Default Constructor.
47
48}
6c3efb37 49
50//______________________________________________________________________________
f3299f82 51AliAnaCaloTrigger::AliAnaCaloTrigger(const char *name) :
9ea45617 52 AliAnalysisTask(name,"AnaCaloTrigger"),
6c3efb37 53 fChain(0),
54 fESD(0),
55 fOutputContainer(0),
f3299f82 56 fCalorimeter("PHOS"),
6c3efb37 57 fNtTrigger22(0),
58 fNtTriggerNN(0)
59
60{
61 // Constructor.
62 // Input slot #0 works with an Ntuple
63 DefineInput(0, TChain::Class());
64 // Output slot #0 writes into a TH1 container
65 DefineOutput(0, TObjArray::Class()) ;
66}
463ee300 67//____________________________________________________________________________
68AliAnaCaloTrigger::AliAnaCaloTrigger(const AliAnaCaloTrigger & ct) :
69 AliAnalysisTask(ct), fChain(ct.fChain), fESD(ct.fESD),
70 fOutputContainer(ct.fOutputContainer), fCalorimeter(ct. fCalorimeter),
71 fNtTrigger22(ct.fNtTrigger22), fNtTriggerNN(ct.fNtTriggerNN)
72{
73
74 // cpy ctor
75 SetName (ct.GetName()) ;
76 SetTitle(ct.GetTitle()) ;
77
78}
79
80//_________________________________________________________________________
81AliAnaCaloTrigger & AliAnaCaloTrigger::operator = (const AliAnaCaloTrigger & source)
82{
83 // assignment operator
84
85 if(&source == this) return *this;
86
87 fChain = source.fChain ;
88 fESD = source.fESD ;
89 fOutputContainer = source.fOutputContainer ;
90 fCalorimeter = source. fCalorimeter ;
91 fNtTrigger22 = source.fNtTrigger22 ;
92 fNtTriggerNN = source.fNtTriggerNN ;
93
94 return *this;
95
96}
6c3efb37 97
98//______________________________________________________________________________
f3299f82 99AliAnaCaloTrigger::~AliAnaCaloTrigger()
6c3efb37 100{
101 // dtor
102 fOutputContainer->Clear() ;
103 delete fOutputContainer ;
104 delete fNtTrigger22 ;
105 delete fNtTriggerNN ;
106}
107
108
109//______________________________________________________________________________
f3299f82 110void AliAnaCaloTrigger::ConnectInputData(const Option_t*)
6c3efb37 111{
112 // Initialisation of branch container and histograms
113
114 AliInfo(Form("*** Initialization of %s", GetName())) ;
115
116 // Get input data
117 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
118 if (!fChain) {
119 AliError(Form("Input 0 for %s not found\n", GetName()));
120 return ;
121 }
122
9ea45617 123 fESD = new AliESDEvent();
124 fESD->ReadFromTree(fChain);
125
6c3efb37 126}
127
128//________________________________________________________________________
129
f3299f82 130void AliAnaCaloTrigger::CreateOutputObjects()
6c3efb37 131{
132
9ea45617 133 // Create the outputs containers
134 OpenFile(0) ;
135
6c3efb37 136 // create histograms
f3299f82 137 fNtTrigger22 = new TNtuple(fCalorimeter+"trigger22", "Trigger data 2x2 patch", "a22:a220:enMax:phEnMax:eta22:phi22:etaMax:phiMax:phEtaMax:phPhiMax");
138 fNtTriggerNN = new TNtuple(fCalorimeter+"triggerNN", "Trigger data NxN patch", "aNN:aNN0:enMax:phEnMax:etaNN:phiNN:etaMax:phiMax:phEtaMax:phPhiMax");
9ea45617 139
6c3efb37 140 // create output container
141
142 fOutputContainer = new TObjArray(2) ;
143 fOutputContainer->SetName(GetName()) ;
9ea45617 144
6c3efb37 145 fOutputContainer->AddAt(fNtTrigger22, 0) ;
146 fOutputContainer->AddAt(fNtTriggerNN, 1) ;
147
148}
149
150//______________________________________________________________________________
f3299f82 151void AliAnaCaloTrigger::Exec(Option_t *)
6c3efb37 152{
153 // Processing of one event
154
155 Long64_t entry = fChain->GetReadEntry() ;
156
157 if (!fESD) {
158 AliError("fESD is not connected to the input!") ;
159 return ;
160 }
161
162 if ( !((entry-1)%100) )
163 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
164
f3299f82 165 // Get trigger information of fCalorimeter
166 TArrayF * triggerAmplitudes = 0x0 ;
167 TArrayF * triggerPosition = 0x0 ;
9ea45617 168 Int_t numberOfCaloClusters = fESD->GetNumberOfCaloClusters() ;
f3299f82 169
170 if(fCalorimeter == "PHOS"){
171 triggerAmplitudes = fESD->GetPHOSTriggerAmplitudes();
172 triggerPosition = fESD->GetPHOSTriggerPosition();
f3299f82 173 }
174 else if(fCalorimeter == "EMCAL"){
175 triggerAmplitudes = fESD->GetEMCALTriggerAmplitudes();
176 triggerPosition = fESD->GetEMCALTriggerPosition();
f3299f82 177 }
6797e4bc 178
179 if( triggerAmplitudes && triggerPosition ){
6c3efb37 180 // trigger amplitudes
f38b754b 181 const Float_t ka22 = static_cast<Float_t>(triggerAmplitudes->At(0)) ;
182 const Float_t ka22O = static_cast<Float_t>(triggerAmplitudes->At(1)) ;
183 const Float_t kaNN = static_cast<Float_t>(triggerAmplitudes->At(2)) ;
184 const Float_t kaNNO = static_cast<Float_t>(triggerAmplitudes->At(3)) ;
6c3efb37 185
186 // trigger position
f38b754b 187 const Float_t kx22 = static_cast<Float_t>(triggerPosition->At(0)) ;
188 const Float_t ky22 = static_cast<Float_t>(triggerPosition->At(1)) ;
189 const Float_t kz22 = static_cast<Float_t>(triggerPosition->At(2)) ;
190 const Float_t kxNN = static_cast<Float_t>(triggerPosition->At(3)) ;
191 const Float_t kyNN = static_cast<Float_t>(triggerPosition->At(4)) ;
192 const Float_t kzNN = static_cast<Float_t>(triggerPosition->At(5)) ;
6c3efb37 193
6c3efb37 194 Float_t enMax = 0. ;
195 Float_t phEnMax = 0. ;
4c0b6461 196 Float_t etaMax = 0.5 ;
197 Float_t phiMax = 0. ;
198 Float_t phEtaMax = 0.5 ;
199 Float_t phPhiMax = 0. ;
200
f38b754b 201 TVector3 vpos22(kx22, ky22, kz22) ;
202 TVector3 vposNN(kxNN, kyNN, kzNN) ;
4c0b6461 203 Float_t eta22 = vpos22.Eta() ;
204 Float_t phi22 = vpos22.Phi() * TMath::RadToDeg() + 360. ;
205 Float_t etaNN = vposNN.Eta() ;
206 Float_t phiNN = vposNN.Phi() * TMath::RadToDeg() + 360. ;
6c3efb37 207
f3299f82 208 Int_t icaloCluster ;
6c3efb37 209
f3299f82 210 // loop over the Calorimeters Clusters
6c3efb37 211
9ea45617 212 for(icaloCluster = 0 ; icaloCluster < numberOfCaloClusters ; icaloCluster++) {
213
f3299f82 214 AliESDCaloCluster * cluster = fESD->GetCaloCluster(icaloCluster) ;
9ea45617 215
216 if (cluster && ( (fCalorimeter == "PHOS" && cluster->IsPHOS()) ||
217 (fCalorimeter == "EMCAL" && cluster->IsEMCAL()))) {
218
018c8391 219 Float_t cluEnergy = cluster->E() ;
6c3efb37 220 Float_t pos[3] ;
221 TVector3 vpos ;
222
018c8391 223 cluster->GetPosition( pos ) ;
6c3efb37 224
225 if ( cluEnergy > enMax) {
226 enMax = cluEnergy ;
227 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
228 etaMax = vpos.Eta() ;
229 phiMax = vpos.Phi() ;
230 }
231
4b707925 232 Double_t * pid = cluster->GetPid() ;
6c3efb37 233
234 if(pid[AliPID::kPhoton] > 0.9) {
235 if ( cluEnergy > phEnMax) {
236 phEnMax = cluEnergy ;
237 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
238 phEtaMax = vpos.Eta() ;
239 phPhiMax = vpos.Phi() ;
240 }
241 }
6797e4bc 242 }//if cluster
6c3efb37 243
f38b754b 244 fNtTrigger22->Fill(ka22, ka22O, enMax, phEnMax, eta22, phi22, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
245 fNtTriggerNN->Fill(kaNN, kaNNO, enMax, phEnMax, etaNN, phiNN, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
6797e4bc 246 }//CaloCluster loop
6c3efb37 247
6797e4bc 248 }//If trigger arrays filled
6c3efb37 249
250 PostData(0, fOutputContainer);
251
252}
253
254//______________________________________________________________________________
f3299f82 255void AliAnaCaloTrigger::Terminate(Option_t *)
6c3efb37 256{
257 // Processing when the event loop is ended
258
259}