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 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
21 // and if MC stack available, with pt of parent.
23 //*-- Yves Schutz (CERN) & Gustavo Conesa Balbastre (INFN-LNF)
24 //////////////////////////////////////////////////////////////////////////////
30 #include "AliAnaCaloTrigger.h"
33 #include "AliESDCaloCluster.h"
34 #include "AliMCEvent.h"
35 #include "AliESDEvent.h"
37 //______________________________________________________________________________
38 AliAnaCaloTrigger::AliAnaCaloTrigger() :
45 // Default Constructor.
49 //______________________________________________________________________________
50 AliAnaCaloTrigger::AliAnaCaloTrigger(const char *name) :
51 AliAnalysisTaskSE(name),
60 DefineOutput(1, TList::Class()) ;
63 //____________________________________________________________________________
64 AliAnaCaloTrigger::AliAnaCaloTrigger(const AliAnaCaloTrigger & ct) :
65 AliAnalysisTaskSE(ct.GetName()),
66 fOutputContainer(ct.fOutputContainer), fCalorimeter(ct. fCalorimeter),
67 fNtTrigger22(ct.fNtTrigger22), fNtTriggerNN(ct.fNtTriggerNN)
74 //_________________________________________________________________________
75 AliAnaCaloTrigger & AliAnaCaloTrigger::operator = (const AliAnaCaloTrigger & source)
77 // assignment operator
79 //if(&source == this) return *this;
80 this->~AliAnaCaloTrigger();
81 new(this) AliAnaCaloTrigger(source);
83 fOutputContainer = source.fOutputContainer ;
84 fCalorimeter = source. fCalorimeter ;
85 fNtTrigger22 = source.fNtTrigger22 ;
86 fNtTriggerNN = source.fNtTriggerNN ;
92 //______________________________________________________________________________
93 AliAnaCaloTrigger::~AliAnaCaloTrigger()
97 fOutputContainer->Clear() ;
98 delete fOutputContainer ;
103 //________________________________________________________________________
105 void AliAnaCaloTrigger::UserCreateOutputObjects()
108 // Create the outputs containers
112 fNtTrigger22 = new TNtuple(fCalorimeter+"trigger22", "Trigger data 2x2 patch", "a22:a220:ptGen:enMax:phEnMax:eta22:phi22:etaMax:phiMax:phEtaMax:phPhiMax");
113 fNtTriggerNN = new TNtuple(fCalorimeter+"triggerNN", "Trigger data NxN patch", "aNN:aNN0:ptGen:enMax:phEnMax:etaNN:phiNN:etaMax:phiMax:phEtaMax:phPhiMax");
115 // create output container
117 fOutputContainer = new TList() ;
118 fOutputContainer->SetName(GetName()) ;
120 fOutputContainer->AddAt(fNtTrigger22, 0) ;
121 fOutputContainer->AddAt(fNtTriggerNN, 1) ;
125 //______________________________________________________________________________
126 void AliAnaCaloTrigger::UserExec(Option_t *)
128 // Processing of one event
130 if ( !((Entry()-1)%100) )
131 printf(" Processing event # %lld\n", Entry()) ;
132 AliESDEvent* esd = (AliESDEvent*)InputEvent();
134 //Get MC data, if available
135 AliStack* stack = 0x0;
137 stack = MCEvent()->Stack();
139 // Get trigger information of fCalorimeter
140 TArrayF * triggerAmplitudes = 0x0 ;
141 TArrayF * triggerPosition = 0x0 ;
142 Int_t numberOfCaloClusters = esd->GetNumberOfCaloClusters() ;
144 if(fCalorimeter == "PHOS"){
145 triggerAmplitudes = esd->GetPHOSTriggerAmplitudes();
146 triggerPosition = esd->GetPHOSTriggerPosition();
148 else if(fCalorimeter == "EMCAL"){
149 triggerAmplitudes = esd->GetEMCALTriggerAmplitudes();
150 triggerPosition = esd->GetEMCALTriggerPosition();
153 if( triggerAmplitudes && triggerPosition ){
154 // trigger amplitudes
155 const Float_t ka22 = static_cast<Float_t>(triggerAmplitudes->At(0)) ;
156 const Float_t ka22O = static_cast<Float_t>(triggerAmplitudes->At(1)) ;
157 const Float_t kaNN = static_cast<Float_t>(triggerAmplitudes->At(2)) ;
158 const Float_t kaNNO = static_cast<Float_t>(triggerAmplitudes->At(3)) ;
161 const Float_t kx22 = static_cast<Float_t>(triggerPosition->At(0)) ;
162 const Float_t ky22 = static_cast<Float_t>(triggerPosition->At(1)) ;
163 const Float_t kz22 = static_cast<Float_t>(triggerPosition->At(2)) ;
164 const Float_t kxNN = static_cast<Float_t>(triggerPosition->At(3)) ;
165 const Float_t kyNN = static_cast<Float_t>(triggerPosition->At(4)) ;
166 const Float_t kzNN = static_cast<Float_t>(triggerPosition->At(5)) ;
168 //printf("ka22 %f, ka220 %f, kaNN %f, kaNN0 %f\n",ka22,ka22O,kaNN,kaNNO);
169 //printf("kx22 %f, ky22 %f, kz22 %f, kxNN %f, kyNN %f, kzNN %f \n",kx22,ky22,kz22,kxNN,kyNN,kzNN);
172 Float_t phEnMax = 0. ;
173 Float_t etaMax = 0.5 ;
174 Float_t phiMax = 0. ;
175 Float_t phEtaMax = 0.5 ;
176 Float_t phPhiMax = 0. ;
178 TVector3 vpos22(kx22, ky22, kz22) ;
179 TVector3 vposNN(kxNN, kyNN, kzNN) ;
180 Float_t eta22 = vpos22.Eta() ;
181 Float_t phi22 = vpos22.Phi() * TMath::RadToDeg() + 360. ;
182 Float_t etaNN = vposNN.Eta() ;
183 Float_t phiNN = vposNN.Phi() * TMath::RadToDeg() + 360. ;
186 Int_t icaloCluster = 0 ;
187 Int_t labelmax = -1 ;
188 // loop over the Calorimeters Clusters
190 for(icaloCluster = 0 ; icaloCluster < numberOfCaloClusters ; icaloCluster++) {
192 AliESDCaloCluster * cluster = esd->GetCaloCluster(icaloCluster) ;
194 if (cluster && ( (fCalorimeter == "PHOS" && cluster->IsPHOS()) ||
195 (fCalorimeter == "EMCAL" && cluster->IsEMCAL()))) {
197 Float_t cluEnergy = cluster->E() ;
201 cluster->GetPosition( pos ) ;
203 if ( cluEnergy > enMax) {
205 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
206 etaMax = vpos.Eta() ;
207 phiMax = vpos.Phi() ;
208 labelmax = cluster->GetLabel();
211 Double_t * pid = cluster->GetPid() ;
213 if(pid[AliPID::kPhoton] > 0.9) {
214 if ( cluEnergy > phEnMax) {
215 phEnMax = cluEnergy ;
216 vpos.SetXYZ(pos[0], pos[1], pos[2]) ;
217 phEtaMax = vpos.Eta() ;
218 phPhiMax = vpos.Phi() ;
224 if(stack && labelmax < stack->GetNtrack() && labelmax >= 0 ){
225 TParticle * particle = stack->Particle(labelmax);
226 ptGen = particle->Energy();
229 fNtTrigger22->Fill(ka22, ka22O, ptGen, enMax, phEnMax, eta22, phi22, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
230 fNtTriggerNN->Fill(kaNN, kaNNO, ptGen, enMax, phEnMax, etaNN, phiNN, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
234 }//If trigger arrays filled
236 PostData(1, fOutputContainer);
240 //______________________________________________________________________________
241 //void AliAnaCaloTrigger::Terminate(Option_t *) const
243 // // Processing when the event loop is ended