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"
31 //______________________________________________________________________________
32 AliAnaCaloTrigger::AliAnaCaloTrigger(const char *name) :
33 AliAnalysisTask(name,""),
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()) ;
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)
56 SetName (ct.GetName()) ;
57 SetTitle(ct.GetTitle()) ;
61 //_________________________________________________________________________
62 AliAnaCaloTrigger & AliAnaCaloTrigger::operator = (const AliAnaCaloTrigger & source)
64 // assignment operator
66 if(&source == this) return *this;
68 fChain = source.fChain ;
70 fOutputContainer = source.fOutputContainer ;
71 fCalorimeter = source. fCalorimeter ;
72 fNtTrigger22 = source.fNtTrigger22 ;
73 fNtTriggerNN = source.fNtTriggerNN ;
79 //______________________________________________________________________________
80 AliAnaCaloTrigger::~AliAnaCaloTrigger()
83 fOutputContainer->Clear() ;
84 delete fOutputContainer ;
90 //______________________________________________________________________________
91 void AliAnaCaloTrigger::ConnectInputData(const Option_t*)
93 // Initialisation of branch container and histograms
95 AliInfo(Form("*** Initialization of %s", GetName())) ;
98 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
100 AliError(Form("Input 0 for %s not found\n", GetName()));
104 // One should first check if the branch address was taken by some other task
105 char ** address = (char **)GetBranchAddress(0, "ESD");
107 fESD = (AliESD*)(*address);
110 SetBranchAddress(0, "ESD", &fESD);
114 //________________________________________________________________________
116 void AliAnaCaloTrigger::CreateOutputObjects()
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");
123 // create output container
125 fOutputContainer = new TObjArray(2) ;
126 fOutputContainer->SetName(GetName()) ;
128 fOutputContainer->AddAt(fNtTrigger22, 0) ;
129 fOutputContainer->AddAt(fNtTriggerNN, 1) ;
133 //______________________________________________________________________________
134 void AliAnaCaloTrigger::Exec(Option_t *)
136 // Processing of one event
138 Long64_t entry = fChain->GetReadEntry() ;
141 AliError("fESD is not connected to the input!") ;
145 if ( !((entry-1)%100) )
146 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
148 // Get trigger information of fCalorimeter
149 TArrayF * triggerAmplitudes = 0x0 ;
150 TArrayF * triggerPosition = 0x0 ;
151 Int_t firstCaloCluster = 0 ;
152 Int_t numberOfCaloClusters = 0 ;
154 if(fCalorimeter == "PHOS"){
155 triggerAmplitudes = fESD->GetPHOSTriggerAmplitudes();
156 triggerPosition = fESD->GetPHOSTriggerPosition();
157 firstCaloCluster = fESD->GetFirstPHOSCluster() ;
158 numberOfCaloClusters = fESD->GetNumberOfPHOSClusters() ;
160 else if(fCalorimeter == "EMCAL"){
161 triggerAmplitudes = fESD->GetEMCALTriggerAmplitudes();
162 triggerPosition = fESD->GetEMCALTriggerPosition();
163 firstCaloCluster = fESD->GetFirstEMCALCluster() ;
164 numberOfCaloClusters = fESD->GetNumberOfEMCALClusters() ;
167 if( triggerAmplitudes && triggerPosition ){
168 // trigger amplitudes
169 const Float_t a22 = static_cast<Float_t>(triggerAmplitudes->At(0)) ;
170 const Float_t a22O = static_cast<Float_t>(triggerAmplitudes->At(1)) ;
171 const Float_t aNN = static_cast<Float_t>(triggerAmplitudes->At(2)) ;
172 const Float_t aNNO = static_cast<Float_t>(triggerAmplitudes->At(3)) ;
175 const Float_t x22 = static_cast<Float_t>(triggerPosition->At(0)) ;
176 const Float_t y22 = static_cast<Float_t>(triggerPosition->At(1)) ;
177 const Float_t z22 = static_cast<Float_t>(triggerPosition->At(2)) ;
178 const Float_t xNN = static_cast<Float_t>(triggerPosition->At(3)) ;
179 const Float_t yNN = static_cast<Float_t>(triggerPosition->At(4)) ;
180 const Float_t zNN = static_cast<Float_t>(triggerPosition->At(5)) ;
183 Float_t phEnMax = 0. ;
184 Float_t etaMax = 0.5 ;
185 Float_t phiMax = 0. ;
186 Float_t phEtaMax = 0.5 ;
187 Float_t phPhiMax = 0. ;
189 TVector3 vpos22(x22, y22, z22) ;
190 TVector3 vposNN(xNN, yNN, zNN) ;
191 Float_t eta22 = vpos22.Eta() ;
192 Float_t phi22 = vpos22.Phi() * TMath::RadToDeg() + 360. ;
193 Float_t etaNN = vposNN.Eta() ;
194 Float_t phiNN = vposNN.Phi() * TMath::RadToDeg() + 360. ;
198 // loop over the Calorimeters Clusters
200 for(icaloCluster = firstCaloCluster ; icaloCluster < firstCaloCluster + numberOfCaloClusters ; icaloCluster++) {
201 AliESDCaloCluster * cluster = fESD->GetCaloCluster(icaloCluster) ;
204 Float_t cluEnergy = cluster->E() ;
208 cluster->GetPosition( pos ) ;
210 if ( cluEnergy > enMax) {
212 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
213 etaMax = vpos.Eta() ;
214 phiMax = vpos.Phi() ;
217 Float_t * pid = cluster->GetPid() ;
219 if(pid[AliPID::kPhoton] > 0.9) {
220 if ( cluEnergy > phEnMax) {
221 phEnMax = cluEnergy ;
222 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
223 phEtaMax = vpos.Eta() ;
224 phPhiMax = vpos.Phi() ;
229 fNtTrigger22->Fill(a22, a22O, enMax, phEnMax, eta22, phi22, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
230 fNtTriggerNN->Fill(aNN, aNNO, enMax, phEnMax, etaNN, phiNN, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
233 }//If trigger arrays filled
235 PostData(0, fOutputContainer);
239 //______________________________________________________________________________
240 void AliAnaCaloTrigger::Terminate(Option_t *)
242 // Processing when the event loop is ended