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 ++ )
246 AliVTrack* track = dynamic_cast<AliVTrack*>(plCTS->At(ipr)) ;
250 //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
251 if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1) ||
252 track->GetID() == pCandidate->GetTrackLabel(2) || track->GetID() == pCandidate->GetTrackLabel(3) ) continue ;
254 p3.SetXYZ(track->Px(),track->Py(),track->Pz());
260 {// Mixed event stored in AliAODPWG4Particles
261 AliAODPWG4Particle * trackmix = dynamic_cast<AliAODPWG4Particle*>(plCTS->At(ipr)) ;
264 printf("AliIsolationCut::MakeIsolationCut() - Wrong track data type, continue\n");
269 eta = trackmix->Eta();
270 phi = trackmix->Phi() ;
273 if( phi < 0 ) phi+=TMath::TwoPi();
275 // Only loop the particle at the same side of candidate
276 if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
278 // If at the same side has particle larger than candidate,
279 // then candidate can not be the leading, skip such events
287 pCandidate->SetLeadingParticle(kFALSE);
289 if(bFillAOD && reftracks)
298 //Check if there is any particle inside cone with pt larger than fPtThreshold
300 rad = Radius(etaC, phiC, eta, phi);
303 printf("\t track %d, pT %2.2f, eta %1.2f, phi %2.2f, R candidate %2.2f", ipr,pt,eta,phi,rad);
307 if(fDebug>0) printf(" - inside candidate cone");
314 reftracks = new TObjArray(0);
315 //reftracks->SetName(Form("Tracks%s",aodArrayRefName.Data()));
316 TString tempo(aodArrayRefName) ;
318 reftracks->SetName(tempo);
319 reftracks->SetOwner(kFALSE);
321 reftracks->Add(track);
326 if(pt > fPtThreshold ) n++;
327 if(pt > fPtFraction*ptC ) nfrac++;
331 if(fDebug>0) printf("\n");
333 }// charged particle loop
339 //Check neutral particles in cone.
341 (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged))
345 for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ )
347 AliVCluster * calo = dynamic_cast<AliVCluster *>(plNe->At(ipr)) ;
351 //Get the index where the cluster comes, to retrieve the corresponding vertex
353 if (reader->GetMixedEvent())
354 evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ;
357 //Do not count the candidate (photon or pi0) or the daughters of the candidate
358 if(calo->GetID() == pCandidate->GetCaloLabel(0) ||
359 calo->GetID() == pCandidate->GetCaloLabel(1) ) continue ;
361 //Skip matched clusters with tracks in case of neutral+charged analysis
362 if( fPartInCone == kNeutralAndCharged &&
363 pid->IsTrackMatched(calo,reader->GetCaloUtils(),reader->GetInputEvent()) ) continue ;
365 //Assume that come from vertex in straight line
366 calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;
373 {// Mixed event stored in AliAODPWG4Particles
374 AliAODPWG4Particle * calomix = dynamic_cast<AliAODPWG4Particle*>(plNe->At(ipr)) ;
377 printf("AliIsolationCut::MakeIsolationCut() - Wrong calo data type, continue\n");
382 eta = calomix->Eta();
383 phi = calomix->Phi() ;
386 if( phi < 0 ) phi+=TMath::TwoPi();
389 // Only loop the particle at the same side of candidate
390 if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
392 // If at the same side has particle larger than candidate,
393 // then candidate can not be the leading, skip such events
401 pCandidate->SetLeadingParticle(kFALSE);
413 refclusters->Clear();
420 //Check if there is any particle inside cone with pt larger than fPtThreshold
422 rad = Radius(etaC, phiC, eta, phi);
425 printf("\t cluster %d, pT %2.2f, eta %1.2f, phi %2.2f, R candidate %2.2f", ipr,pt,eta,phi,rad);
429 if(fDebug>0) printf(" - inside candidate cone");
436 refclusters = new TObjArray(0);
437 //refclusters->SetName(Form("Clusters%s",aodArrayRefName.Data()));
438 TString tempo(aodArrayRefName) ;
439 tempo += "Clusters" ;
440 refclusters->SetName(tempo);
441 refclusters->SetOwner(kFALSE);
443 refclusters->Add(calo);
447 if(pt > fPtThreshold ) n++;
448 //if fPtFraction*ptC<fPtThreshold then consider the fPtThreshold directly
450 if( fPtFraction*ptC<fPtThreshold)
452 if(pt>fPtThreshold) nfrac++ ;
456 if(pt>fPtFraction*ptC) nfrac++;
460 if(pt>fPtFraction*ptC) nfrac++;
465 if(fDebug>0) printf("\n");
467 }// neutral particle loop
472 //Add reference arrays to AOD when filling AODs only
475 if(refclusters) pCandidate->AddObjArray(refclusters);
476 if(reftracks) pCandidate->AddObjArray(reftracks);
479 //Check isolation, depending on selected isolation criteria
480 if( fICMethod == kPtThresIC)
482 if(n==0) isolated = kTRUE ;
484 else if( fICMethod == kSumPtIC)
486 if(coneptsum < fSumPtThreshold)
489 else if( fICMethod == kPtFracIC)
491 if(nfrac==0) isolated = kTRUE ;
493 else if( fICMethod == kSumPtFracIC)
495 //when the fPtFraction*ptC < fSumPtThreshold then consider the later case
497 if(fPtFraction*ptC < fSumPtThreshold && coneptsum < fSumPtThreshold) isolated = kTRUE ;
498 if( fPtFraction*ptC > fSumPtThreshold && coneptsum < fPtFraction*ptC) isolated = kTRUE ;
502 if(coneptsum < fPtFraction*ptC) isolated = kTRUE ;
505 else if( fICMethod == kSumDensityIC)
507 // Get good cell density (number of active cells over all cells in cone)
508 // and correct energy in cone
509 Float_t cellDensity = GetCellDensity(pCandidate,reader);
510 if(coneptsum < fSumPtThreshold*cellDensity)
516 //_____________________________________________________
517 void AliIsolationCut::Print(const Option_t * opt) const
520 //Print some relevant parameters set for the analysis
524 printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
526 printf("IC method = %d\n", fICMethod ) ;
527 printf("Cone Size = %1.2f\n", fConeSize ) ;
528 printf("pT threshold = %2.1f\n", fPtThreshold) ;
529 printf("pT fraction = %3.1f\n", fPtFraction ) ;
530 printf("particle type in cone = %d\n", fPartInCone ) ;
531 printf("using fraction for high pt leading instead of frac ? %i\n",fFracIsThresh);
536 //___________________________________________________________________________
537 Float_t AliIsolationCut::Radius(const Float_t etaC, const Float_t phiC,
538 const Float_t eta , const Float_t phi) const
540 // Calculate the distance to trigger from any particle
542 Float_t dEta = etaC-eta;
543 Float_t dPhi = phiC-phi;
545 if(TMath::Abs(dPhi) >= TMath::Pi())
546 dPhi = TMath::TwoPi()-TMath::Abs(dPhi);
548 return TMath::Sqrt( dEta*dEta + dPhi*dPhi );