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