]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliIsolationCut.cxx
Adding ZDC TDC histo for DQM shifter
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliIsolationCut.cxx
CommitLineData
1c5acb87 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/* $Id: $ */
16
17//_________________________________________________________________________
18// Class containing methods for the isolation cut.
591cc579 19// An AOD candidate (AliAODPWG4ParticleCorrelation type)
20// is passed. Look in a cone around the candidate and study
21// the hadronic activity inside to decide if the candidate is isolated
1c5acb87 22//
23//
24//*-- Author: Gustavo Conesa (LNF-INFN)
5025c139 25
26//-Yaxian Mao (add the possibility for different IC method with different pt range, 01/10/2010)
27//-Yaxian Mao (check the candidate particle is the leading particle or not at the same hemishere)
28
1c5acb87 29//////////////////////////////////////////////////////////////////////////////
30
31
32// --- ROOT system ---
33//#include <Riostream.h>
34#include <TLorentzVector.h>
591cc579 35#include <TObjArray.h>
1c5acb87 36
37// --- AliRoot system ---
38#include "AliIsolationCut.h"
1c5acb87 39#include "AliAODPWG4ParticleCorrelation.h"
40#include "AliAODTrack.h"
0ae57829 41#include "AliVCluster.h"
233e0df8 42#include "AliCaloTrackReader.h"
f8006433 43#include "AliMixedEvent.h"
1c5acb87 44
45ClassImp(AliIsolationCut)
46
47//____________________________________________________________________________
48 AliIsolationCut::AliIsolationCut() :
49 TObject(),
5025c139 50 fConeSize(0.),fPtThreshold(0.), fSumPtThreshold(0.), fPtFraction(0.), fICMethod(0),fPartInCone(0)
1c5acb87 51
52{
53 //default ctor
54
55 //Initialize parameters
56 InitParameters();
57
58}
78219bac 59/*
1c5acb87 60//____________________________________________________________________________
61AliIsolationCut::AliIsolationCut(const AliIsolationCut & g) :
62 TObject(g),
63 fConeSize(g.fConeSize),
64 fPtThreshold(g.fPtThreshold),
65 fPtFraction(g.fPtFraction),
66 fICMethod(g.fICMethod)
67{
68 // cpy ctor
477d6cee 69
1c5acb87 70}
71
72//_________________________________________________________________________
73AliIsolationCut & AliIsolationCut::operator = (const AliIsolationCut & source)
74{
75 // assignment operator
76
77 if(&source == this) return *this;
477d6cee 78
1c5acb87 79 fConeSize = source.fConeSize ;
80 fPtThreshold = source.fPtThreshold ;
81 fICMethod = source.fICMethod ;
82 fPtFraction = source.fPtFraction ;
83
84 return *this;
85
86}
78219bac 87*/
1c5acb87 88//____________________________________________________________________________
89TString AliIsolationCut::GetICParametersList()
90{
477d6cee 91 //Put data member values in string to keep in output container
92
93 TString parList ; //this will be list of parameters used for this analysis.
5ae09196 94 const Int_t buffersize = 255;
95 char onePar[buffersize] ;
477d6cee 96
5ae09196 97 snprintf(onePar,buffersize,"--- AliIsolationCut ---\n") ;
477d6cee 98 parList+=onePar ;
5ae09196 99 snprintf(onePar,buffersize,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;
477d6cee 100 parList+=onePar ;
5ae09196 101 snprintf(onePar,buffersize,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;
477d6cee 102 parList+=onePar ;
5ae09196 103 snprintf(onePar,buffersize,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;
477d6cee 104 parList+=onePar ;
5ae09196 105 snprintf(onePar,buffersize,"fICMethod=%d (isolation cut case) \n",fICMethod) ;
477d6cee 106 parList+=onePar ;
5ae09196 107 snprintf(onePar,buffersize,"fPartInCone=%d \n",fPartInCone) ;
b6991fc4 108 parList+=onePar ;
109
477d6cee 110 return parList;
1c5acb87 111}
112
113//____________________________________________________________________________
114void AliIsolationCut::InitParameters()
115{
116 //Initialize the parameters of the analysis.
477d6cee 117
b6991fc4 118 fConeSize = 0.4 ;
119 fPtThreshold = 1. ;
5025c139 120 fSumPtThreshold = 0.5 ;
b6991fc4 121 fPtFraction = 0.1 ;
122 fPartInCone = kNeutralAndCharged;
123 fICMethod = kPtThresIC; // 0 pt threshol method, 1 cone pt sum method
477d6cee 124
1c5acb87 125}
126
127//__________________________________________________________________
233e0df8 128void AliIsolationCut::MakeIsolationCut(TObjArray * const plCTS, TObjArray * const plNe, AliCaloTrackReader * const reader,
d7c10d78 129 const Bool_t bFillAOD, AliAODPWG4ParticleCorrelation *pCandidate,
130 const TString & aodArrayRefName,
1c5acb87 131 Int_t & n, Int_t & nfrac, Float_t &coneptsum, Bool_t &isolated) const
132{
477d6cee 133 //Search in cone around a candidate particle if it is isolated
134 Float_t phiC = pCandidate->Phi() ;
9ccc5a0b 135 Float_t etaC = pCandidate->Eta() ;
136 Float_t ptC = pCandidate->Pt() ;
137 Float_t pt = -100. ;
8d823743 138 Float_t eta = -100. ;
139 Float_t phi = -100. ;
140 Float_t rad = -100. ;
141
142 n = 0 ;
143 nfrac = 0 ;
477d6cee 144 coneptsum = 0.;
8d823743 145 isolated = kFALSE;
5025c139 146
a3aebfff 147 //Initialize the array with refrences
591cc579 148 TObjArray * refclusters = 0x0;
9ccc5a0b 149 TObjArray * reftracks = 0x0;
150 Int_t ntrackrefs = 0;
4ba526c9 151 Int_t nclusterrefs = 0;
477d6cee 152 //Check charged particles in cone.
b6991fc4 153 if(plCTS && (fPartInCone==kOnlyCharged || fPartInCone==kNeutralAndCharged)){
477d6cee 154 TVector3 p3;
155 for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
156 AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ;
157 //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
158 if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1)) continue ;
159 p3.SetXYZ(track->Px(),track->Py(),track->Pz());
160 pt = p3.Pt();
161 eta = p3.Eta();
162 phi = p3.Phi() ;
163 if(phi<0) phi+=TMath::TwoPi();
164
5025c139 165 //only loop the particle at the same side of candidate
166 if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
167 //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
168 if(pt > ptC){
8d823743 169 n = -1;
170 nfrac = -1;
5025c139 171 coneptsum = -1;
8d823743 172 isolated = kFALSE;
d7c10d78 173 if(bFillAOD && reftracks) reftracks->Clear();
5025c139 174 return ;
175 }
477d6cee 176 //Check if there is any particle inside cone with pt larger than fPtThreshold
177 rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
178
179 if(rad < fConeSize){
d7c10d78 180 if(bFillAOD) {
5ae09196 181 ntrackrefs++;
182 if(ntrackrefs == 1){
183 reftracks = new TObjArray(0);
8d823743 184 //reftracks->SetName(Form("Tracks%s",aodArrayRefName.Data()));
185 TString tempo(aodArrayRefName) ;
186 tempo += "Tracks" ;
187 reftracks->SetName(tempo);
5ae09196 188 reftracks->SetOwner(kFALSE);
189 }
190 reftracks->Add(track);
191 }
192 //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
193 coneptsum+=pt;
8d823743 194 if(pt > fPtThreshold ) n++;
5ae09196 195 if(pt > fPtFraction*ptC ) nfrac++;
d7c10d78 196 } // Inside cone
477d6cee 197 }// charged particle loop
198 }//Tracks
199
200 //Check neutral particles in cone.
b6991fc4 201 if(plNe && (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged)){
233e0df8 202
5ae09196 203 //Get vertex for photon momentum calculation
f8006433 204 //Double_t vertex2[] = {0,0,0} ; //vertex second AOD input ;
205 //if(reader->GetDataType()!= AliCaloTrackReader::kMC)
206 //{
5ae09196 207 //if(reader->GetSecondInputAODTree()) reader->GetSecondInputAODVertex(vertex2);
f8006433 208 //}
477d6cee 209 TLorentzVector mom ;
210 for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
0ae57829 211 AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;
477d6cee 212
f8006433 213 //Get the index where the cluster comes, to retrieve the corresponding vertex
214 Int_t evtIndex = 0 ;
215 if (reader->GetMixedEvent()) {
216 evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ;
217 }
218
477d6cee 219 //Do not count the candidate (photon or pi0) or the daughters of the candidate
220 if(calo->GetID() == pCandidate->GetCaloLabel(0) || calo->GetID() == pCandidate->GetCaloLabel(1)) continue ; //Skip matched clusters with tracks
221
222 if(calo->GetNTracksMatched() > 0) continue ;
f8006433 223
4ba526c9 224 //Input from second AOD?
f8006433 225 //Int_t input = 0;
5ae09196 226 // if (pCandidate->GetDetector() == "EMCAL" && reader->GetAODEMCALNormalInputEntries() <= ipr) input = 1 ;
227 // else if(pCandidate->GetDetector() == "PHOS" && reader->GetAODPHOSNormalInputEntries() <= ipr) input = 1;
4ba526c9 228
229 //Get Momentum vector,
f8006433 230 //if (input == 0)
231 calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;//Assume that come from vertex in straight line
232 //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line
4ba526c9 233
234 pt = mom.Pt();
477d6cee 235 eta = mom.Eta();
236 phi = mom.Phi() ;
237 if(phi<0) phi+=TMath::TwoPi();
5025c139 238 //only loop the particle at the same side of candidate
239
240 if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
241 //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
242 if(pt > ptC){
8d823743 243 n = -1;
244 nfrac = -1;
5025c139 245 coneptsum = -1;
8d823743 246 isolated = kFALSE;
d7c10d78 247 if(bFillAOD){
8d823743 248 if(reftracks) reftracks ->Clear();
5025c139 249 if(refclusters)refclusters->Clear();
250 }
251 return ;
252 }
477d6cee 253
254 //Check if there is any particle inside cone with pt larger than fPtThreshold
255 rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));
256 if(rad < fConeSize){
d7c10d78 257 if(bFillAOD) {
5ae09196 258 nclusterrefs++;
259 if(nclusterrefs==1){
260 refclusters = new TObjArray(0);
8d823743 261 //refclusters->SetName(Form("Clusters%s",aodArrayRefName.Data()));
262 TString tempo(aodArrayRefName) ;
263 tempo += "Clusters" ;
5a39e602 264 refclusters->SetName(tempo);
5ae09196 265 refclusters->SetOwner(kFALSE);
266 }
267 refclusters->Add(calo);
268 }
269 //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
270 coneptsum+=pt;
8d823743 271 if(pt > fPtThreshold ) n++;
5025c139 272 //if fPtFraction*ptC<fPtThreshold then consider the fPtThreshold directly
d7c10d78 273 if(fPtFraction*ptC<fPtThreshold) {
8d823743 274 if(pt>fPtThreshold) nfrac++ ;
d7c10d78 275 }
276 else {
277 if(pt>fPtFraction*ptC) nfrac++;
278 }
477d6cee 279 }//in cone
280 }// neutral particle loop
281 }//neutrals
5025c139 282
477d6cee 283 //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
284
a3aebfff 285 //Add reference arrays to AOD when filling AODs only
d7c10d78 286 if(bFillAOD) {
4ba526c9 287 if(refclusters) pCandidate->AddObjArray(refclusters);
f8006433 288 if(reftracks) pCandidate->AddObjArray(reftracks);
a3aebfff 289 }
477d6cee 290 //Check isolation, depending on method.
291 if( fICMethod == kPtThresIC){
292 if(n==0) isolated = kTRUE ;
293 }
294 else if( fICMethod == kSumPtIC){
5025c139 295 if(coneptsum < fSumPtThreshold)
477d6cee 296 isolated = kTRUE ;
297 }
298 else if( fICMethod == kPtFracIC){
299 if(nfrac==0) isolated = kTRUE ;
300 }
301 else if( fICMethod == kSumPtFracIC){
5025c139 302 //when the fPtFraction*ptC < fSumPtThreshold then consider the later case
303 if(coneptsum < fPtFraction*ptC && coneptsum < fSumPtThreshold) isolated = kTRUE ;
477d6cee 304 }
5ae09196 305
1c5acb87 306}
307
308//__________________________________________________________________
309void AliIsolationCut::Print(const Option_t * opt) const
310{
311
312 //Print some relevant parameters set for the analysis
313 if(! opt)
314 return;
315
316 printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
317
318 printf("IC method = %d\n", fICMethod) ;
319 printf("Cone Size = %1.2f\n", fConeSize) ;
320 printf("pT threshold = %2.1f\n", fPtThreshold) ;
321 printf("pT fraction = %3.1f\n", fPtFraction) ;
b6991fc4 322 printf("particle type in cone = %d\n",fPartInCone);
1c5acb87 323 printf(" \n") ;
324
325}