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 **************************************************************************/
16 //_________________________________________________________________________
17 // An analysis task to check the PHOS/EMCAL simulated trigger
19 //*-- Yves Schutz & Gustavo Conesa Balbastre
20 //////////////////////////////////////////////////////////////////////////////
27 #include "AliAnaCaloTrigger.h"
28 #include "AliAnalysisManager.h"
29 #include "AliESDEvent.h"
31 #include "AliESDCaloCluster.h"
33 //______________________________________________________________________________
34 AliAnaCaloTrigger::AliAnaCaloTrigger() :
43 // Default Constructor.
47 //______________________________________________________________________________
48 AliAnaCaloTrigger::AliAnaCaloTrigger(const char *name) :
49 AliAnalysisTask(name,"AnaCaloTrigger"),
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()) ;
64 //____________________________________________________________________________
65 AliAnaCaloTrigger::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)
72 SetName (ct.GetName()) ;
73 SetTitle(ct.GetTitle()) ;
77 //_________________________________________________________________________
78 AliAnaCaloTrigger & AliAnaCaloTrigger::operator = (const AliAnaCaloTrigger & source)
80 // assignment operator
82 if(&source == this) return *this;
84 fChain = source.fChain ;
86 fOutputContainer = source.fOutputContainer ;
87 fCalorimeter = source. fCalorimeter ;
88 fNtTrigger22 = source.fNtTrigger22 ;
89 fNtTriggerNN = source.fNtTriggerNN ;
95 //______________________________________________________________________________
96 AliAnaCaloTrigger::~AliAnaCaloTrigger()
99 fOutputContainer->Clear() ;
100 delete fOutputContainer ;
101 delete fNtTrigger22 ;
102 delete fNtTriggerNN ;
106 //______________________________________________________________________________
107 void AliAnaCaloTrigger::ConnectInputData(const Option_t*)
109 // Initialisation of branch container and histograms
111 AliInfo(Form("*** Initialization of %s", GetName())) ;
114 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
116 AliError(Form("Input 0 for %s not found\n", GetName()));
120 fESD = new AliESDEvent();
121 fESD->ReadFromTree(fChain);
125 //________________________________________________________________________
127 void AliAnaCaloTrigger::CreateOutputObjects()
130 // Create the outputs containers
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");
137 // create output container
139 fOutputContainer = new TObjArray(2) ;
140 fOutputContainer->SetName(GetName()) ;
142 fOutputContainer->AddAt(fNtTrigger22, 0) ;
143 fOutputContainer->AddAt(fNtTriggerNN, 1) ;
147 //______________________________________________________________________________
148 void AliAnaCaloTrigger::Exec(Option_t *)
150 // Processing of one event
152 Long64_t entry = fChain->GetReadEntry() ;
155 AliError("fESD is not connected to the input!") ;
159 if ( !((entry-1)%100) )
160 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
162 // Get trigger information of fCalorimeter
163 TArrayF * triggerAmplitudes = 0x0 ;
164 TArrayF * triggerPosition = 0x0 ;
165 Int_t numberOfCaloClusters = fESD->GetNumberOfCaloClusters() ;
167 if(fCalorimeter == "PHOS"){
168 triggerAmplitudes = fESD->GetPHOSTriggerAmplitudes();
169 triggerPosition = fESD->GetPHOSTriggerPosition();
171 else if(fCalorimeter == "EMCAL"){
172 triggerAmplitudes = fESD->GetEMCALTriggerAmplitudes();
173 triggerPosition = fESD->GetEMCALTriggerPosition();
176 if( triggerAmplitudes && triggerPosition ){
177 // trigger amplitudes
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)) ;
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)) ;
192 Float_t phEnMax = 0. ;
193 Float_t etaMax = 0.5 ;
194 Float_t phiMax = 0. ;
195 Float_t phEtaMax = 0.5 ;
196 Float_t phPhiMax = 0. ;
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. ;
207 // loop over the Calorimeters Clusters
209 for(icaloCluster = 0 ; icaloCluster < numberOfCaloClusters ; icaloCluster++) {
211 AliESDCaloCluster * cluster = fESD->GetCaloCluster(icaloCluster) ;
213 if (cluster && ( (fCalorimeter == "PHOS" && cluster->IsPHOS()) ||
214 (fCalorimeter == "EMCAL" && cluster->IsEMCAL()))) {
216 Float_t cluEnergy = cluster->E() ;
220 cluster->GetPosition( pos ) ;
222 if ( cluEnergy > enMax) {
224 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
225 etaMax = vpos.Eta() ;
226 phiMax = vpos.Phi() ;
229 Double_t * pid = cluster->GetPid() ;
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() ;
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.);
245 }//If trigger arrays filled
247 PostData(0, fOutputContainer);
251 //______________________________________________________________________________
252 void AliAnaCaloTrigger::Terminate(Option_t *)
254 // Processing when the event loop is ended