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