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 // Class containing methods for the isolation cut.
18 // An AOD candidate (AliAODPWG4ParticleCorrelation type)
19 // is passed. Look in a cone around the candidate and study
20 // the hadronic activity inside to decide if the candidate is isolated
23 //*-- Author: Gustavo Conesa (LNF-INFN)
25 //-Yaxian Mao (add the possibility for different IC method with different pt range, 01/10/2010)
26 //-Yaxian Mao (check the candidate particle is the leading particle or not at the same hemishere)
28 //////////////////////////////////////////////////////////////////////////////
31 // --- ROOT system ---
32 #include <TLorentzVector.h>
33 #include <TObjArray.h>
35 // --- AliRoot system ---
36 #include "AliIsolationCut.h"
37 #include "AliAODPWG4ParticleCorrelation.h"
38 #include "AliEMCALGeometry.h"
39 #include "AliEMCALGeoParams.h"
40 #include "AliCalorimeterUtils.h"
41 #include "AliAODTrack.h"
42 #include "AliVCluster.h"
43 #include "AliCaloTrackReader.h"
44 #include "AliMixedEvent.h"
45 #include "AliCaloPID.h"
47 ClassImp(AliIsolationCut)
49 //____________________________________
50 AliIsolationCut::AliIsolationCut() :
63 //Initialize parameters
69 //__________________________________________________________________________________
70 Float_t AliIsolationCut::GetCellDensity(const AliAODPWG4ParticleCorrelation * pCandidate,
71 const AliCaloTrackReader * reader) const
73 // Get good cell density (number of active cells over all cells in cone)
75 Double_t coneCells = 0.; //number of cells in cone with radius fConeSize
76 Double_t coneCellsBad = 0.; //number of bad cells in cone with radius fConeSize
77 Double_t cellDensity = 1.;
79 Float_t phiC = pCandidate->Phi() ;
80 if(phiC<0) phiC+=TMath::TwoPi();
81 Float_t etaC = pCandidate->Eta() ;
83 if(pCandidate->GetDetector()=="EMCAL")
85 AliEMCALGeometry* eGeom = AliEMCALGeometry::GetInstance();
86 AliCalorimeterUtils *cu = reader->GetCaloUtils();
89 if (eGeom->GetAbsCellIdFromEtaPhi(etaC,phiC,absId))
91 //Get absolute (col,row) of candidate
92 Int_t iEta=-1, iPhi=-1, iRCU = -1;
93 Int_t nSupMod = cu->GetModuleNumberCellIndexes(absId, pCandidate->GetDetector(), iEta, iPhi, iRCU);
96 if (nSupMod % 2) colC = AliEMCALGeoParams::fgkEMCALCols + iEta ;
97 Int_t rowC = iPhi + AliEMCALGeoParams::fgkEMCALRows*int(nSupMod/2);
99 Int_t sqrSize = int(fConeSize/0.0143) ; // Size of cell in radians
100 //loop on cells in a square of side fConeSize to check cells in cone
101 for(Int_t icol = colC-sqrSize; icol < colC+sqrSize;icol++)
103 for(Int_t irow = rowC-sqrSize; irow < rowC+sqrSize; irow++)
105 if (Radius(colC, rowC, icol, irow) < sqrSize)
110 Int_t cellEta = -999;
111 Int_t cellPhi = -999;
112 if(icol > AliEMCALGeoParams::fgkEMCALCols-1)
114 cellSM = 0+int(irow/AliEMCALGeoParams::fgkEMCALRows)*2;
115 cellEta = icol-AliEMCALGeoParams::fgkEMCALCols;
116 cellPhi = irow-AliEMCALGeoParams::fgkEMCALRows*int(cellSM/2);
118 if(icol < AliEMCALGeoParams::fgkEMCALCols)
120 cellSM = 1+int(irow/AliEMCALGeoParams::fgkEMCALRows)*2;
122 cellPhi = irow-AliEMCALGeoParams::fgkEMCALRows*int(cellSM/2);
125 //Count as bad "cells" out of EMCAL acceptance
126 if(icol < 0 || icol > AliEMCALGeoParams::fgkEMCALCols*2 ||
127 irow < 0 || irow > AliEMCALGeoParams::fgkEMCALRows*16./3) //5*nRows+1/3*nRows
131 //Count as bad "cells" marked as bad in the DataBase
132 else if (cu->GetEMCALChannelStatus(cellSM,cellEta,cellPhi)==1)
141 else if(fDebug>0) printf("cluster with bad (eta,phi) in EMCal for energy density calculation\n");
145 cellDensity = (coneCells-coneCellsBad)/coneCells;
146 //printf("Energy density = %f\n", cellDensity);
154 //____________________________________________
155 TString AliIsolationCut::GetICParametersList()
157 //Put data member values in string to keep in output container
159 TString parList ; //this will be list of parameters used for this analysis.
160 const Int_t buffersize = 255;
161 char onePar[buffersize] ;
163 snprintf(onePar,buffersize,"--- AliIsolationCut ---\n") ;
165 snprintf(onePar,buffersize,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;
167 snprintf(onePar,buffersize,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;
169 snprintf(onePar,buffersize,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;
171 snprintf(onePar,buffersize,"fICMethod=%d (isolation cut case) \n",fICMethod) ;
173 snprintf(onePar,buffersize,"fPartInCone=%d \n",fPartInCone) ;
175 snprintf(onePar,buffersize,"fFracIsThresh=%i \n",fFracIsThresh) ;
181 //____________________________________
182 void AliIsolationCut::InitParameters()
184 //Initialize the parameters of the analysis.
188 fSumPtThreshold = 0.5 ;
190 fPartInCone = kOnlyCharged;
191 fICMethod = kSumPtFracIC; // 0 pt threshol method, 1 cone pt sum method
195 //________________________________________________________________________________
196 void AliIsolationCut::MakeIsolationCut(const TObjArray * plCTS,
197 const TObjArray * plNe,
198 const AliCaloTrackReader * reader,
199 const AliCaloPID * pid,
200 const Bool_t bFillAOD,
201 AliAODPWG4ParticleCorrelation *pCandidate,
202 const TString & aodArrayRefName,
206 Bool_t & isolated) const
208 //Search in cone around a candidate particle if it is isolated
209 Float_t ptC = pCandidate->Pt() ;
210 Float_t phiC = pCandidate->Phi() ;
211 if(phiC<0) phiC+=TMath::TwoPi();
212 Float_t etaC = pCandidate->Eta() ;
214 Float_t eta = -100. ;
215 Float_t phi = -100. ;
216 Float_t rad = -100. ;
225 printf("AliIsolationCut::MakeIsolationCut() - Cadidate pT %2.2f, eta %2.2f, phi %2.2f, cone %1.2f, thres %2.2f, Fill AOD? %d",
226 pCandidate->Pt(), pCandidate->Eta(), pCandidate->Phi()*TMath::RadToDeg(), fConeSize,fPtThreshold,bFillAOD);
227 if(plCTS) printf(", nTracks %d" ,plCTS->GetEntriesFast());
228 if(plNe) printf(", nClusters %d",plNe ->GetEntriesFast());
233 //Initialize the array with refrences
234 TObjArray * refclusters = 0x0;
235 TObjArray * reftracks = 0x0;
236 Int_t ntrackrefs = 0;
237 Int_t nclusterrefs = 0;
239 //Check charged particles in cone.
241 (fPartInCone==kOnlyCharged || fPartInCone==kNeutralAndCharged))
244 for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ )
247 AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ;
249 //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
250 if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1) ||
251 track->GetID() == pCandidate->GetTrackLabel(2) || track->GetID() == pCandidate->GetTrackLabel(3) ) continue ;
253 p3.SetXYZ(track->Px(),track->Py(),track->Pz());
257 if(phi<0) phi+=TMath::TwoPi();
259 // Only loop the particle at the same side of candidate
260 if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
262 // If at the same side has particle larger than candidate,
263 // then candidate can not be the leading, skip such events
271 pCandidate->SetLeadingParticle(kFALSE);
273 if(bFillAOD && reftracks)
282 //Check if there is any particle inside cone with pt larger than fPtThreshold
284 rad = Radius(etaC, phiC, eta, phi);
287 printf("\t track %d, pT %2.2f, eta %1.2f, phi %2.2f, R candidate %2.2f", ipr,pt,eta,phi,rad);
291 if(fDebug>0) printf(" - inside candidate cone");
298 reftracks = new TObjArray(0);
299 //reftracks->SetName(Form("Tracks%s",aodArrayRefName.Data()));
300 TString tempo(aodArrayRefName) ;
302 reftracks->SetName(tempo);
303 reftracks->SetOwner(kFALSE);
305 reftracks->Add(track);
310 if(pt > fPtThreshold ) n++;
311 if(pt > fPtFraction*ptC ) nfrac++;
315 if(fDebug>0) printf("\n");
317 }// charged particle loop
323 //Check neutral particles in cone.
325 (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged))
329 for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ )
331 AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;
333 //Get the index where the cluster comes, to retrieve the corresponding vertex
335 if (reader->GetMixedEvent())
336 evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ;
339 //Do not count the candidate (photon or pi0) or the daughters of the candidate
340 if(calo->GetID() == pCandidate->GetCaloLabel(0) ||
341 calo->GetID() == pCandidate->GetCaloLabel(1) ) continue ;
343 //Skip matched clusters with tracks in case of neutral+charged analysis
344 if( fPartInCone == kNeutralAndCharged &&
345 pid->IsTrackMatched(calo,reader->GetCaloUtils(),reader->GetInputEvent()) ) continue ;
347 //Assume that come from vertex in straight line
348 calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;
353 if(phi<0) phi+=TMath::TwoPi();
355 // Only loop the particle at the same side of candidate
356 if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
358 // If at the same side has particle larger than candidate,
359 // then candidate can not be the leading, skip such events
367 pCandidate->SetLeadingParticle(kFALSE);
379 refclusters->Clear();
386 //Check if there is any particle inside cone with pt larger than fPtThreshold
388 rad = Radius(etaC, phiC, eta, phi);
391 printf("\t cluster %d, pT %2.2f, eta %1.2f, phi %2.2f, R candidate %2.2f", ipr,pt,eta,phi,rad);
395 if(fDebug>0) printf(" - inside candidate cone");
402 refclusters = new TObjArray(0);
403 //refclusters->SetName(Form("Clusters%s",aodArrayRefName.Data()));
404 TString tempo(aodArrayRefName) ;
405 tempo += "Clusters" ;
406 refclusters->SetName(tempo);
407 refclusters->SetOwner(kFALSE);
409 refclusters->Add(calo);
413 if(pt > fPtThreshold ) n++;
414 //if fPtFraction*ptC<fPtThreshold then consider the fPtThreshold directly
416 if( fPtFraction*ptC<fPtThreshold)
418 if(pt>fPtThreshold) nfrac++ ;
422 if(pt>fPtFraction*ptC) nfrac++;
426 if(pt>fPtFraction*ptC) nfrac++;
431 if(fDebug>0) printf("\n");
433 }// neutral particle loop
438 //Add reference arrays to AOD when filling AODs only
441 if(refclusters) pCandidate->AddObjArray(refclusters);
442 if(reftracks) pCandidate->AddObjArray(reftracks);
445 //Check isolation, depending on selected isolation criteria
446 if( fICMethod == kPtThresIC)
448 if(n==0) isolated = kTRUE ;
450 else if( fICMethod == kSumPtIC)
452 if(coneptsum < fSumPtThreshold)
455 else if( fICMethod == kPtFracIC)
457 if(nfrac==0) isolated = kTRUE ;
459 else if( fICMethod == kSumPtFracIC)
461 //when the fPtFraction*ptC < fSumPtThreshold then consider the later case
463 if(fPtFraction*ptC < fSumPtThreshold && coneptsum < fSumPtThreshold) isolated = kTRUE ;
464 if( fPtFraction*ptC > fSumPtThreshold && coneptsum < fPtFraction*ptC) isolated = kTRUE ;
468 if(coneptsum < fPtFraction*ptC) isolated = kTRUE ;
471 else if( fICMethod == kSumDensityIC)
473 // Get good cell density (number of active cells over all cells in cone)
474 // and correct energy in cone
475 Float_t cellDensity = GetCellDensity(pCandidate,reader);
476 if(coneptsum < fSumPtThreshold*cellDensity)
482 //_____________________________________________________
483 void AliIsolationCut::Print(const Option_t * opt) const
486 //Print some relevant parameters set for the analysis
490 printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
492 printf("IC method = %d\n", fICMethod ) ;
493 printf("Cone Size = %1.2f\n", fConeSize ) ;
494 printf("pT threshold = %2.1f\n", fPtThreshold) ;
495 printf("pT fraction = %3.1f\n", fPtFraction ) ;
496 printf("particle type in cone = %d\n", fPartInCone ) ;
497 printf("using fraction for high pt leading instead of frac ? %i\n",fFracIsThresh);
502 //___________________________________________________________________________
503 Float_t AliIsolationCut::Radius(const Float_t etaC, const Float_t phiC,
504 const Float_t eta , const Float_t phi) const
506 // Calculate the distance to trigger from any particle
508 Float_t dEta = etaC-eta;
509 Float_t dPhi = phiC-phi;
511 if(TMath::Abs(dPhi) >= TMath::Pi())
512 dPhi = TMath::TwoPi()-TMath::Abs(dPhi);
514 return TMath::Sqrt( dEta*dEta + dPhi*dPhi );