]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
isolate leading particles only if requested; remove leading check from AliIsolationCut
authorgconesab <gustavo.conesa.balbastre@cern.ch>
Thu, 21 Aug 2014 15:05:22 +0000 (17:05 +0200)
committergconesab <gustavo.conesa.balbastre@cern.ch>
Thu, 21 Aug 2014 15:05:22 +0000 (17:05 +0200)
PWG/CaloTrackCorrBase/AliIsolationCut.cxx
PWGGA/CaloTrackCorrelations/AliAnaParticleIsolation.cxx
PWGGA/CaloTrackCorrelations/AliAnaParticleIsolation.h

index 403e64d81fdcc05d9414ab8cd80842c5bdf92860..703422b1caa3c6f5f5751fc83a6b6d03ba117e5b 100755 (executable)
@@ -504,25 +504,25 @@ void  AliIsolationCut::MakeIsolationCut(TObjArray * plCTS,
       // Only loop the particle at the same side of candidate
       if(TMath::Abs(phi-phiC) > TMath::PiOver2()) continue ;
       
-      // If at the same side has particle larger than candidate, 
-      // then candidate can not be the leading, skip such events
-      if(pt > ptC)
-      {
-        n         = -1;
-        nfrac     = -1;
-        coneptsumTrack = -1;
-        isolated  = kFALSE;
-        
-        pCandidate->SetLeadingParticle(kFALSE);
-        
-        if(bFillAOD && reftracks) 
-        {
-          reftracks->Clear(); 
-          delete reftracks;
-        }
-        
-        return ;
-      }
+//      // If at the same side has particle larger than candidate, 
+//      // then candidate can not be the leading, skip such events
+//      if(pt > ptC)
+//      {
+//        n         = -1;
+//        nfrac     = -1;
+//        coneptsumTrack = -1;
+//        isolated  = kFALSE;
+//        
+//        pCandidate->SetLeadingParticle(kFALSE);
+//        
+//        if(bFillAOD && reftracks) 
+//        {
+//          reftracks->Clear(); 
+//          delete reftracks;
+//        }
+//        
+//        return ;
+//      }
       
       // // Check if there is any particle inside cone with pt larger than  fPtThreshold
       // Check if the leading particule inside the cone has a ptLead larger than fPtThreshold
@@ -646,33 +646,33 @@ void  AliIsolationCut::MakeIsolationCut(TObjArray * plCTS,
       // Only loop the particle at the same side of candidate
       if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
       
-      // If at the same side has particle larger than candidate, 
-      // then candidate can not be the leading, skip such events
-      if(pt > ptC)
-      {
-        n         = -1;
-        nfrac     = -1;
-        coneptsumCluster = -1;
-        isolated  = kFALSE;
-        
-        pCandidate->SetLeadingParticle(kFALSE);
-        
-        if(bFillAOD)
-        {
-          if(reftracks)
-          {  
-            reftracks  ->Clear();
-            delete reftracks;
-          }
-          
-          if(refclusters)
-          {
-            refclusters->Clear(); 
-            delete refclusters;
-          }
-        }
-        return ;
-      }
+//      // If at the same side has particle larger than candidate,
+//      // then candidate can not be the leading, skip such events
+//      if(pt > ptC)
+//      {
+//        n         = -1;
+//        nfrac     = -1;
+//        coneptsumCluster = -1;
+//        isolated  = kFALSE;
+//        
+//        pCandidate->SetLeadingParticle(kFALSE);
+//        
+//        if(bFillAOD)
+//        {
+//          if(reftracks)
+//          {  
+//            reftracks  ->Clear();
+//            delete reftracks;
+//          }
+//          
+//          if(refclusters)
+//          {
+//            refclusters->Clear(); 
+//            delete refclusters;
+//          }
+//        }
+//        return ;
+//      }
       
       //Check if there is any particle inside cone with pt larger than  fPtThreshold
       
index aa3dbaf626fc527a344abc826ade82abb5e624ab..1d5e01cb8f94942c32247b5a9eb2e7e75cd079ec 100755 (executable)
@@ -69,6 +69,7 @@ fFillTMHisto(0),                  fFillSSHisto(1),
 fFillUEBandSubtractHistograms(1), fFillCellHistograms(0),
 fFillHighMultHistograms(0),       fFillTaggedDecayHistograms(0),
 fFillNLMHistograms(0),
+fLeadingOnly(0),                  fCheckLeadingWithNeutralClusters(0),
 // Several IC
 fNCones(0),                       fNPtThresFrac(0),
 fConeSizes(),                     fPtThresholds(),
@@ -3007,7 +3008,6 @@ void AliAnaParticleIsolation::Init()
   if(!GetReader()->IsCTSSwitchedOn() && GetIsolationCut()->GetParticleTypeInCone()!=AliIsolationCut::kOnlyNeutral)
     AliFatal("STOP!: You want to use CTS tracks in analysis but not read!! \n!!Check the configuration file!!\n");
   
-  
 }
 
 //____________________________________________
@@ -3025,6 +3025,9 @@ void AliAnaParticleIsolation::InitParameters()
   fReMakeIC = kFALSE ;
   fMakeSeveralIC = kFALSE ;
   
+  fLeadingOnly = kTRUE;
+  fCheckLeadingWithNeutralClusters = kTRUE;
+  
   //----------- Several IC-----------------
   fNCones             = 5 ;
   fNPtThresFrac       = 5 ;
@@ -3035,11 +3038,133 @@ void AliAnaParticleIsolation::InitParameters()
   
 }
 
+//_________________________________________________________________________________________
+Bool_t AliAnaParticleIsolation::IsTriggerTheNearSideEventLeadingParticle(Int_t & idLeading)
+{
+  // Check if the what of the selected isolation candidates is leading particle in the same hemisphere
+  // comparing with all the candidates, all the tracks or all the clusters.
+  
+  Double_t ptTrig      = GetMinPt();
+  Double_t phiTrig     = 0 ;
+  Int_t index          =-1 ;
+  AliAODPWG4ParticleCorrelation* pLeading = 0;
+  
+  // Loop on stored AOD particles, find leading trigger on the selected list, with at least min pT.
+  
+  for(Int_t iaod = 0; iaod < GetInputAODBranch()->GetEntriesFast() ; iaod++)
+  {
+    AliAODPWG4ParticleCorrelation* particle =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
+    particle->SetLeadingParticle(kFALSE); // set it later
+    
+    // Vertex cut in case of mixing
+    if(GetMixedEvent())
+    {
+      Int_t check = CheckMixedEventVertex(particle->GetCaloLabel(0), particle->GetTrackLabel(0));
+      if(check ==  0) continue;
+      if(check == -1) return kFALSE; // not sure if it is correct.
+    }
+    
+    //check if it is low pt trigger particle
+    if((particle->Pt() < GetIsolationCut()->GetPtThreshold() ||
+        particle->Pt() < GetIsolationCut()->GetSumPtThreshold()) &&
+       !fMakeSeveralIC)
+    {
+      continue ; //trigger should not come from underlying event
+    }
+
+    // find the leading particles with highest momentum
+    if (particle->Pt() > ptTrig)
+    {
+      ptTrig   = particle->Pt() ;
+      phiTrig  = particle->Phi();
+      index    = iaod     ;
+      pLeading = particle ;
+    }
+  }// finish search of leading trigger particle on the AOD branch.
+  
+  if(index < 0) return kFALSE;
+  
+  idLeading = index;
+  
+  //printf("AOD leading pT %2.2f, ID %d\n", pLeading->Pt(),pLeading->GetCaloLabel(0));
+  
+  if(phiTrig < 0 ) phiTrig += TMath::TwoPi();
+  
+  // Compare if it is the leading of all tracks
+  
+  TVector3 p3;
+  for(Int_t ipr = 0;ipr < GetCTSTracks()->GetEntriesFast() ; ipr ++ )
+  {
+    AliVTrack * track = (AliVTrack *) (GetCTSTracks()->At(ipr)) ;
+    
+    if(track->GetID() == pLeading->GetTrackLabel(0) || track->GetID() == pLeading->GetTrackLabel(1) ||
+       track->GetID() == pLeading->GetTrackLabel(2) || track->GetID() == pLeading->GetTrackLabel(3)   ) continue ;
+    
+    Double_t mom[3] = {track->Px(),track->Py(),track->Pz()};
+    p3.SetXYZ(mom[0],mom[1],mom[2]);
+    Float_t pt   = p3.Pt();
+    Float_t phi  = p3.Phi() ;
+    if(phi < 0) phi+=TMath::TwoPi();
+    
+    //skip this event if near side associated particle pt larger than trigger
+    
+    if(pt > ptTrig && TMath::Abs(phi-phiTrig) < TMath::PiOver2())  return kFALSE;
+    
+  }// track loop
+  
+  // Compare if it is leading of all calorimeter clusters
+  
+  if(fCheckLeadingWithNeutralClusters)
+  {
+    // Select the calorimeter cluster list
+    TObjArray * nePl = 0x0;
+    if      (pLeading->GetDetector() == "PHOS" )
+      nePl = GetPHOSClusters();
+    else
+      nePl = GetEMCALClusters();
+    
+    if(!nePl) return kTRUE; // Do the selection just with the tracks if no calorimeter is available.
+    
+    TLorentzVector lv;
+    for(Int_t ipr = 0;ipr < nePl->GetEntriesFast() ; ipr ++ )
+    {
+      AliVCluster * cluster = (AliVCluster *) (nePl->At(ipr)) ;
+      
+      if(cluster->GetID() == pLeading->GetCaloLabel(0) || cluster->GetID() == pLeading->GetCaloLabel(1) ) continue ;
+      
+      cluster->GetMomentum(lv,GetVertex(0));
+      
+      Float_t pt   = lv.Pt();
+      Float_t phi  = lv.Phi() ;
+      if(phi < 0) phi+=TMath::TwoPi();
+      
+      if(IsTrackMatched(cluster,GetReader()->GetInputEvent())) continue ; // avoid charged clusters, already covered by tracks, or cluster merging with track.
+      
+      // skip this event if near side associated particle pt larger than trigger
+      // not really needed for calorimeter, unless DCal is included
+     
+      if(pt > ptTrig && TMath::Abs(phi-phiTrig) < TMath::PiOver2()) return kFALSE ;
+
+    }// cluster loop
+  } // check neutral clusters
+  
+  idLeading = index ;
+  pLeading->SetLeadingParticle(kTRUE);
+  
+  if( GetDebug() > 1 )
+    printf("AliAnaParticleIsolation::IsTriggerTheNearSideEventLeadingParticle() - Particle AOD with index %d is leading with pT %2.2f\n",
+           idLeading, pLeading->Pt());
+  
+  return kTRUE;
+  
+}
+
 //__________________________________________________
 void  AliAnaParticleIsolation::MakeAnalysisFillAOD()
 {
-  //Do analysis and fill aods
-  //Search for the isolated photon in fCalorimeter with pt > GetMinPt()
+  // Do analysis and fill aods
+  // Search for the isolated photon in fCalorimeter with GetMinPt() < pt < GetMaxPt()
+  // and if the particle is leading in the near side (if requested)
   
   if(!GetInputAODBranch())
     AliFatal(Form("No input particles in AOD with name branch < %s >, STOP",GetInputAODName().Data()));
@@ -3059,69 +3184,65 @@ void  AliAnaParticleIsolation::MakeAnalysisFillAOD()
     pl = GetEMCALClusters();
   
   //Loop on AOD branch, filled previously in AliAnaPhoton, find leading particle to do isolation only with it
-  Double_t ptLeading = 0. ;
-  Int_t    idLeading = -1 ;
   TLorentzVector mom ;
-  Int_t naod = GetInputAODBranch()->GetEntriesFast();
+  Int_t idLeading = -1 ;
+  Int_t iaod0 = 0;
+  Int_t naod  = GetInputAODBranch()->GetEntriesFast();
+  
   if(GetDebug() > 0)
     printf("AliAnaParticleIsolation::MakeAnalysisFillAOD() - Input aod branch entries %d\n", naod);
   
-  for(Int_t iaod = 0; iaod < naod; iaod++)
+  if(IsLeadingOnlyOn())
+  {
+    Bool_t leading = IsTriggerTheNearSideEventLeadingParticle(idLeading);
+    if(!leading)
+    {
+      if(GetDebug() > 1) printf("AliAnaParticleIsolation::MakeAnalysisFillAOD() - Not leading; End fill AODs \n");
+      return;
+    }
+    iaod0 = idLeading  ; // first entry in particle loop
+    naod  = idLeading+1; // last entry in particle loop
+  }
+  
+  // Check isolation of list of candidate particles or leading particle
+  
+  for(Int_t iaod = iaod0; iaod < naod; iaod++)
   {
     AliAODPWG4ParticleCorrelation * aodinput =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
     
-    //If too small or too large pt, skip
-    if(aodinput->Pt() < GetMinPt() || aodinput->Pt() > GetMaxPt() ) continue ;
+    if(IsLeadingOnlyOn()) aodinput->SetLeadingParticle(kTRUE);
+  
+    // Check isolation only of clusters in fiducial region
+    if(IsFiducialCutOn())
+    {
+      Bool_t in = GetFiducialCut()->IsInFiducialCut(*aodinput->Momentum(),aodinput->GetDetector()) ;
+      if(! in ) return ;
+    }
     
+    //If too small or too large pt, skip
+    Float_t pt = aodinput->Pt();
+    if(pt < GetMinPt() || pt > GetMaxPt() ) continue ;
+
     //check if it is low pt trigger particle
-    if((aodinput->Pt() < GetIsolationCut()->GetPtThreshold() ||
-        aodinput->Pt() < GetIsolationCut()->GetSumPtThreshold()) &&
+    if( ( pt < GetIsolationCut()->GetPtThreshold() ||  pt < GetIsolationCut()->GetSumPtThreshold() ) &&
        !fMakeSeveralIC)
     {
       continue ; //trigger should not come from underlying event
     }
     
-    //vertex cut in case of mixing
-    Int_t check = CheckMixedEventVertex(aodinput->GetCaloLabel(0), aodinput->GetTrackLabel(0));
-    if(check ==  0) continue;
-    if(check == -1) return;
+    //After cuts, study isolation
+    n=0; nfrac = 0; isolated = kFALSE; coneptsum = 0;
+    GetIsolationCut()->MakeIsolationCut(GetCTSTracks(),pl,
+                                        GetReader(), GetCaloPID(),
+                                        kTRUE, aodinput, GetAODObjArrayName(),
+                                        n,nfrac,coneptsum, isolated);
     
-    //find the leading particles with highest momentum
-    if ( aodinput->Pt() > ptLeading )
-    {
-      ptLeading = aodinput->Pt() ;
-      idLeading = iaod ;
-    }
-    
-    aodinput->SetLeadingParticle(kFALSE);
-    
-  }//finish searching for leading trigger particle
-  
-  // Check isolation of leading particle
-  if(idLeading < 0) return;
-  
-  AliAODPWG4ParticleCorrelation * aodinput =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(idLeading));
-  aodinput->SetLeadingParticle(kTRUE);
-  
-  // Check isolation only of clusters in fiducial region
-  if(IsFiducialCutOn())
-  {
-    Bool_t in = GetFiducialCut()->IsInFiducialCut(*aodinput->Momentum(),aodinput->GetDetector()) ;
-    if(! in ) return ;
-  }
-  
-  //After cuts, study isolation
-  n=0; nfrac = 0; isolated = kFALSE; coneptsum = 0;
-  GetIsolationCut()->MakeIsolationCut(GetCTSTracks(),pl,
-                                      GetReader(), GetCaloPID(),
-                                      kTRUE, aodinput, GetAODObjArrayName(),
-                                      n,nfrac,coneptsum, isolated);
-  
-  if(!fMakeSeveralIC) aodinput->SetIsolated(isolated);
+    if(!fMakeSeveralIC) aodinput->SetIsolated(isolated);
+  } // particle isolationloop
   
   if(GetDebug() > 1)
   {
-    if(isolated)printf("AliAnaParticleIsolation::MakeAnalysisFillAOD() : Particle %d IS ISOLATED \n",idLeading);
+    if(isolated) printf("AliAnaParticleIsolation::MakeAnalysisFillAOD() : Particle %d IS ISOLATED \n",idLeading);
     printf("AliAnaParticleIsolation::MakeAnalysisFillAOD() - End fill AODs \n");
   }
   
@@ -3130,7 +3251,7 @@ void  AliAnaParticleIsolation::MakeAnalysisFillAOD()
 //_________________________________________________________
 void  AliAnaParticleIsolation::MakeAnalysisFillHistograms()
 {
-  //Do analysis and fill histograms
+  // Do analysis and fill histograms
   
   // In case of simulated data, fill acceptance histograms
   // Not ready for multiple case analysis.
@@ -3145,7 +3266,7 @@ void  AliAnaParticleIsolation::MakeAnalysisFillHistograms()
   {
     AliAODPWG4ParticleCorrelation* aod =  (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
     
-    if(!aod->IsLeadingParticle()) continue; // Try to isolate only leading cluster or track
+    if(IsLeadingOnlyOn() && !aod->IsLeadingParticle()) continue; // Try to isolate only leading cluster or track
     
     // Check isolation only of clusters in fiducial region
     if(IsFiducialCutOn())
index 345d85ac5ba167c9671e732d89d890a65f2758cb..536769acbc66e63fe64013b7e92079ac7f5d2df9 100755 (executable)
@@ -72,6 +72,8 @@ class AliAnaParticleIsolation : public AliAnaCaloTrackCorrBaseClass {
   void         FillTrackMatchingShowerShapeControlHistograms(AliAODPWG4ParticleCorrelation  * pCandidate,
                                                              Int_t mcIndex) ;
   
+  Bool_t       IsTriggerTheNearSideEventLeadingParticle(Int_t & idLeading);
+  
   void         MakeSeveralICAnalysis( AliAODPWG4ParticleCorrelation * ph, Int_t mcIndex ) ;
   
   // Analysis Setters and Getters
@@ -113,6 +115,13 @@ class AliAnaParticleIsolation : public AliAnaCaloTrackCorrBaseClass {
   void         SwitchOnSSHistoFill()                 { fFillSSHisto   = kTRUE    ; }
   void         SwitchOffSSHistoFill()                { fFillSSHisto   = kFALSE   ; }
 
+  Bool_t       IsLeadingOnlyOn()               const { return fLeadingOnly       ; }
+  void         SwitchOnLeadingOnly()                 { fLeadingOnly    = kTRUE   ; }
+  void         SwitchOffLeadingOnly()                { fLeadingOnly    = kFALSE  ; }
+  
+  void         SwitchOnCheckNeutralClustersForLeading() { fCheckLeadingWithNeutralClusters = kTRUE  ; }
+  void         SwitchOffCheckNeutralClustersForLeading(){ fCheckLeadingWithNeutralClusters = kFALSE ; }
+  
   void         SwitchOnUEBandSubtractionHistoFill()  { fFillUEBandSubtractHistograms   = kTRUE    ; }
   void         SwitchOffUEBandSubtractionHistoFill() { fFillUEBandSubtractHistograms   = kFALSE   ; }
 
@@ -151,8 +160,10 @@ class AliAnaParticleIsolation : public AliAnaCaloTrackCorrBaseClass {
   Bool_t   fFillHighMultHistograms;               // Fill high multiplicity histograms
   Bool_t   fFillTaggedDecayHistograms;            // Fill histograms for clusters tagged as decay
   Bool_t   fFillNLMHistograms;                    // Fill NLM histograms
+  Bool_t   fLeadingOnly;                          // Do isolation with leading particle
+  Bool_t   fCheckLeadingWithNeutralClusters;      // Compare the trigger candidate to Leading pT with the clusters pT, by default only charged
 
-  // Analysis data members for multiple cones and pt thresholds 
+  // Analysis data members for multiple cones and pt thresholds
   Int_t    fNCones ;                              //! Number of cone sizes to test
   Int_t    fNPtThresFrac ;                        //! Number of ptThres and ptFrac to test
   
@@ -395,7 +406,7 @@ class AliAnaParticleIsolation : public AliAnaCaloTrackCorrBaseClass {
   AliAnaParticleIsolation(              const AliAnaParticleIsolation & iso) ; // cpy ctor
   AliAnaParticleIsolation & operator = (const AliAnaParticleIsolation & iso) ; // cpy assignment
   
-  ClassDef(AliAnaParticleIsolation,27)
+  ClassDef(AliAnaParticleIsolation,28)
 } ;