]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrDep/AliAnaCaloTrigger.cxx
fixing compilation problem
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCaloTrigger.cxx
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 //_________________________________________________________________________
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.
22 //
23 //*-- Yves Schutz (CERN) & Gustavo Conesa Balbastre (INFN-LNF)
24 //////////////////////////////////////////////////////////////////////////////
25 //Root
26 #include <TNtuple.h>
27 #include <TVector3.h> 
28
29 //Aliroot
30 #include "AliAnaCaloTrigger.h" 
31 #include "AliStack.h"
32 #include "AliESDCaloCluster.h"
33 #include "AliMCEvent.h"
34 #include "AliESDEvent.h"
35
36 //______________________________________________________________________________
37 AliAnaCaloTrigger::AliAnaCaloTrigger() :  
38   fOutputContainer(0),
39   fCalorimeter("PHOS"),
40   fNtTrigger22(0), 
41   fNtTriggerNN(0)
42 {
43   // Default Constructor.
44
45 }
46
47 //______________________________________________________________________________
48 AliAnaCaloTrigger::AliAnaCaloTrigger(const char *name) : 
49   AliAnalysisTaskSE(name),  
50   fOutputContainer(0),
51   fCalorimeter("PHOS"),
52   fNtTrigger22(0), 
53   fNtTriggerNN(0)
54 {
55   // Constructor.
56   // Output slot 
57   DefineOutput(1,  TList::Class()) ; 
58 }
59
60 //____________________________________________________________________________
61 AliAnaCaloTrigger::AliAnaCaloTrigger(const AliAnaCaloTrigger & ct) : 
62   AliAnalysisTaskSE(ct.GetName()),
63   fOutputContainer(ct.fOutputContainer), fCalorimeter(ct. fCalorimeter),
64   fNtTrigger22(ct.fNtTrigger22), fNtTriggerNN(ct.fNtTriggerNN)
65 {
66
67   // cpy ctor
68    
69 }
70
71 //_________________________________________________________________________
72 AliAnaCaloTrigger & AliAnaCaloTrigger::operator = (const AliAnaCaloTrigger & source)
73 {
74   // assignment operator
75   
76   //if(&source == this) return *this;
77   this->~AliAnaCaloTrigger();
78   new(this) AliAnaCaloTrigger(source);
79
80   fOutputContainer = source.fOutputContainer ;
81   fCalorimeter = source. fCalorimeter ;
82   fNtTrigger22 = source.fNtTrigger22 ;
83   fNtTriggerNN = source.fNtTriggerNN ;
84
85   return *this;
86   
87 }
88
89 //______________________________________________________________________________
90 AliAnaCaloTrigger::~AliAnaCaloTrigger()
91 {
92   // dtor
93   if(fOutputContainer){
94     fOutputContainer->Clear() ; 
95     delete fOutputContainer ;
96   }
97 }
98
99
100 //________________________________________________________________________
101
102 void AliAnaCaloTrigger::UserCreateOutputObjects()
103 {  
104
105   // Create the outputs containers
106   OpenFile(1) ;
107
108   // create histograms 
109   fNtTrigger22 = new TNtuple(fCalorimeter+"trigger22", "Trigger data 2x2 patch", "a22:a220:ptGen:enMax:phEnMax:eta22:phi22:etaMax:phiMax:phEtaMax:phPhiMax");
110   fNtTriggerNN = new TNtuple(fCalorimeter+"triggerNN", "Trigger data NxN patch", "aNN:aNN0:ptGen:enMax:phEnMax:etaNN:phiNN:etaMax:phiMax:phEtaMax:phPhiMax");
111   
112   // create output container
113   
114   fOutputContainer = new TList() ; 
115   fOutputContainer->SetName(GetName()) ; 
116   
117   fOutputContainer->AddAt(fNtTrigger22,             0) ; 
118   fOutputContainer->AddAt(fNtTriggerNN,             1) ; 
119
120 }
121
122 //______________________________________________________________________________
123 void AliAnaCaloTrigger::UserExec(Option_t *) 
124 {
125   // Processing of one event
126   
127   if ( !((Entry()-1)%100) ) 
128     printf(" Processing event # %lld\n",  Entry()) ; 
129   AliESDEvent* esd = (AliESDEvent*)InputEvent();
130   
131   //Get MC data, if available
132   AliStack* stack = 0x0; 
133   if(MCEvent())
134     stack = MCEvent()->Stack();
135   
136   // Get trigger information of fCalorimeter 
137   TArrayF * triggerAmplitudes = 0x0 ;
138   TArrayF * triggerPosition   = 0x0 ;
139   Int_t numberOfCaloClusters  =  esd->GetNumberOfCaloClusters() ;
140   
141   if(fCalorimeter == "PHOS"){
142     triggerAmplitudes      = esd->GetPHOSTriggerAmplitudes();
143     triggerPosition        = esd->GetPHOSTriggerPosition();
144   }
145   else if(fCalorimeter == "EMCAL"){
146     triggerAmplitudes    = esd->GetEMCALTriggerAmplitudes();
147     triggerPosition      = esd->GetEMCALTriggerPosition();
148   }
149   
150   if( triggerAmplitudes && triggerPosition ){
151     // trigger amplitudes
152     const Float_t ka22    = static_cast<Float_t>(triggerAmplitudes->At(0)) ; 
153     const Float_t ka22O   = static_cast<Float_t>(triggerAmplitudes->At(1)) ; 
154     const Float_t kaNN    = static_cast<Float_t>(triggerAmplitudes->At(2)) ; 
155     const Float_t kaNNO   = static_cast<Float_t>(triggerAmplitudes->At(3)) ; 
156     
157     // trigger position
158     const Float_t kx22  =  static_cast<Float_t>(triggerPosition->At(0)) ; 
159     const Float_t ky22  =  static_cast<Float_t>(triggerPosition->At(1)) ;
160     const Float_t kz22  =  static_cast<Float_t>(triggerPosition->At(2)) ;
161     const Float_t kxNN  =  static_cast<Float_t>(triggerPosition->At(3)) ; 
162     const Float_t kyNN  =  static_cast<Float_t>(triggerPosition->At(4)) ;
163     const Float_t kzNN  =  static_cast<Float_t>(triggerPosition->At(5)) ; 
164     
165     //printf("ka22 %f, ka220 %f, kaNN %f, kaNN0 %f\n",ka22,ka22O,kaNN,kaNNO);
166     //printf("kx22 %f, ky22 %f, kz22 %f, kxNN %f, kyNN %f, kzNN %f \n",kx22,ky22,kz22,kxNN,kyNN,kzNN);
167     
168     Float_t enMax       = 0. ;
169     Float_t phEnMax     = 0. ;
170     Float_t etaMax      = 0.5 ;
171     Float_t phiMax      = 0. ; 
172     Float_t phEtaMax    = 0.5 ;
173     Float_t phPhiMax    = 0. ; 
174     
175     TVector3 vpos22(kx22, ky22, kz22) ;
176     TVector3 vposNN(kxNN, kyNN, kzNN) ;
177     Float_t eta22 = vpos22.Eta() ; 
178     Float_t phi22 = vpos22.Phi() * TMath::RadToDeg() + 360. ; 
179     Float_t etaNN = vposNN.Eta() ; 
180     Float_t phiNN = vposNN.Phi() * TMath::RadToDeg() + 360. ; 
181     
182     
183     Int_t      icaloCluster = 0 ; 
184     Int_t      labelmax     = -1 ;
185     // loop over the Calorimeters Clusters
186     
187     for(icaloCluster = 0 ; icaloCluster < numberOfCaloClusters ; icaloCluster++) {
188       
189       AliESDCaloCluster * cluster = esd->GetCaloCluster(icaloCluster) ;
190       
191       if (cluster && ( (fCalorimeter == "PHOS" && cluster->IsPHOS())  ||  
192                        (fCalorimeter == "EMCAL" && cluster->IsEMCAL()))) {
193         
194         Float_t cluEnergy = cluster->E() ; 
195         Float_t pos[3] ;
196         TVector3 vpos ;
197         
198         cluster->GetPosition( pos ) ;
199         
200         if ( cluEnergy > enMax) { 
201           enMax    = cluEnergy ; 
202           vpos.SetXYZ(pos[0], pos[1], pos[2]) ; 
203           etaMax   = vpos.Eta() ; 
204           phiMax   = vpos.Phi() ; 
205           labelmax = cluster->GetLabel();
206         }
207         
208         Double_t * pid = cluster->GetPid() ;
209         
210         if(pid[AliPID::kPhoton] > 0.9) {
211           if ( cluEnergy > phEnMax) { 
212             phEnMax   = cluEnergy ; 
213             vpos.SetXYZ(pos[0], pos[1], pos[2]) ; 
214             phEtaMax = vpos.Eta() ; 
215             phPhiMax = vpos.Phi() ; 
216           }
217         }
218       }//if cluster
219       
220       Float_t ptGen = -1;
221       if(stack && labelmax < stack->GetNtrack() && labelmax >= 0 ){
222         TParticle * particle = stack->Particle(labelmax); 
223         ptGen = particle->Energy();
224       }
225       
226       fNtTrigger22->Fill(ka22, ka22O, ptGen, enMax, phEnMax, eta22, phi22, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
227       fNtTriggerNN->Fill(kaNN, kaNNO, ptGen, enMax, phEnMax, etaNN, phiNN, etaMax, phiMax * TMath::RadToDeg() + 360., phEtaMax, phPhiMax * TMath::RadToDeg() + 360.);
228       
229     }//CaloCluster loop
230     
231   }//If trigger arrays filled
232   
233   PostData(1, fOutputContainer);
234   
235 }
236
237 //______________________________________________________________________________
238 //void AliAnaCaloTrigger::Terminate(Option_t *) const
239 //{
240 //  // Processing when the event loop is ended
241 //
242 //}