<commit_before>//
//  Class for handling of ESD track cuts.
//
//  The class manages a number of track quality cuts, a
//  track-to-vertex cut and a number of kinematic cuts. Two methods
//  can be used to figure out if an ESD track survives the cuts:
//  AcceptTrack which takes a single AliESDtrack as argument and
//  returns kTRUE/kFALSE or GetAcceptedTracks which takes an AliESDEvent
//  object and returns an TObjArray (of AliESDtracks) with the tracks
//  in the ESD that survived the cuts.
//
//
//  TODO:
//  - add functionality to save and load cuts
//  - add histograms for kinematic cut variables?
//  - upper and lower cuts for all (non-boolean) cuts
//  - update print method
//  - put comments to each variable
//

#ifndef ALIESDTRACKCUTS_H
#define ALIESDTRACKCUTS_H

#include <TString.h>

#include "AliAnalysisCuts.h"

class AliESDEvent;
class AliESDtrack;
class AliLog;
class TTree;
class TH1;
class TH1F;
class TH2F;
class TF1;
class TCollection;
class TFormula;

class AliESDtrackCuts : public AliAnalysisCuts
{
public:
  enum ITSClusterRequirement { kOff = 0, kNone, kAny, kFirst, kOnlyFirst, kSecond, kOnlySecond, kBoth };
  enum Detector { kSPD = 0, kSDD, kSSD };
  enum ITSULayers { kITSU012 = 0, kITSU34, kITSU56 };
  enum MultEstTrackCuts { kMultEstTrackCutGlobal = 0, kMultEstTrackCutITSSA, kMultEstTrackCutDCAwSPD, kMultEstTrackCutDCAwoSPD, kNMultEstTrackCuts /* this must always be the last */};
  enum MultEstTrackType { kTrackletsITSTPC = 0, kTrackletsITSSA, kTracklets };
  enum VertexType { kVertexTracks = 0x1, kVertexSPD = 0x2, kVertexTPC = 0x4 };
  
  AliESDtrackCuts(const Char_t* name = "AliESDtrackCuts", const Char_t* title = "");
  virtual ~AliESDtrackCuts();

  virtual Bool_t IsSelected(TObject* obj)
       {return AcceptTrack((AliESDtrack*)obj);}
  virtual Bool_t IsSelected(TList* /*list*/) {return kTRUE;}

  Bool_t AcceptTrack(const AliESDtrack* esdTrack);
  TObjArray* GetAcceptedTracks(const AliESDEvent* esd, Bool_t bTPC = kFALSE);
  Int_t CountAcceptedTracks(const AliESDEvent* const esd);
  
  static Int_t GetReferenceMultiplicity(const AliESDEvent* esd, Bool_t tpcOnly);
  static Int_t GetReferenceMultiplicity(const AliESDEvent* esd, MultEstTrackType trackType = kTrackletsITSTPC, Float_t etaRange = 0.5);
  static AliESDtrackCuts* GetMultEstTrackCuts(MultEstTrackCuts cut);

  static AliESDtrack* GetTPCOnlyTrack(const AliESDEvent* esd, Int_t iTrack);
  
  // Standard cut definitions
  static AliESDtrackCuts* GetStandardTPCOnlyTrackCuts();
  static AliESDtrackCuts* GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries=kTRUE);
  static AliESDtrackCuts* GetStandardITSTPCTrackCuts2010(Bool_t selPrimaries=kTRUE, Int_t clusterCut=0);
  static AliESDtrackCuts* GetStandardITSTPCTrackCuts2011(Bool_t selPrimaries=kTRUE, Int_t clusterCut=1);
  static AliESDtrackCuts* GetStandardITSSATrackCuts2009(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSSATrackCuts2010(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSSATrackCutsPbPb2010(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSPureSATrackCuts2009(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSPureSATrackCuts2010(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  // Standard cuts for daughter tracks
  static AliESDtrackCuts* GetStandardV0DaughterCuts();

  virtual Long64_t Merge(TCollection* list);
  virtual void Copy(TObject &c) const;
  AliESDtrackCuts(const AliESDtrackCuts& pd);  // Copy Constructor
  AliESDtrackCuts &operator=(const AliESDtrackCuts &c);

  //######################################################
  // track quality cut setters  
  void SetMinNClustersTPC(Int_t min=-1)          {fCutMinNClusterTPC=min;}
  void SetMinNClustersTPCPtDep(TFormula *f1=0x0, Float_t ptmax=0.);
  void SetMinNClustersITS(Int_t min=-1)          {fCutMinNClusterITS=min;}
  void SetMinNCrossedRowsTPC(Float_t min=-1) { fCutMinNCrossedRowsTPC=min;}
  void SetMinRatioCrossedRowsOverFindableClustersTPC(Float_t min = -1) { fCutMinRatioCrossedRowsOverFindableClustersTPC=min;}
  void SetMinLengthActiveVolumeTPC(Float_t min = 120.) {fCutMinLengthActiveVolumeTPC=min;}
  void SetClusterRequirementITS(Detector det, ITSClusterRequirement req = kOff) { fCutClusterRequirementITS[det] = req; }
  void SetClusterRequirementITS(ITSULayers det, ITSClusterRequirement req = kOff) { fCutClusterRequirementITS[det] = req; }
  void SetMaxChi2PerClusterTPC(Float_t max=1e10) {fCutMaxChi2PerClusterTPC=max;}
  void SetMaxChi2PerClusterITS(Float_t max=1e10) {fCutMaxChi2PerClusterITS=max;}
  void SetMaxChi2TPCConstrainedGlobal(Float_t max=1e10) {fCutMaxChi2TPCConstrainedVsGlobal = max; }
  void SetMaxChi2TPCConstrainedGlobalVertexType(Int_t vertexType = kVertexTracks | kVertexSPD) { fCutMaxChi2TPCConstrainedVsGlobalVertexType = vertexType; }
  void SetMaxNOfMissingITSPoints(Int_t max=6)    {fCutMaxMissingITSPoints=max;}
  void SetRequireTPCRefit(Bool_t b=kFALSE)       {fCutRequireTPCRefit=b;}
  void SetRequireTPCStandAlone(Bool_t b=kFALSE)  {fCutRequireTPCStandAlone=b;}
  void SetRequireITSRefit(Bool_t b=kFALSE)       {fCutRequireITSRefit=b;}
  void SetRequireITSPid(Bool_t b=kFALSE)         {fCutRequireITSPid=b;}
  void SetRequireITSStandAlone(Bool_t b=kFALSE)    {fCutRequireITSStandAlone = b;} 
  void SetRequireITSPureStandAlone(Bool_t b=kFALSE){fCutRequireITSpureSA = b;}


  void SetAcceptKinkDaughters(Bool_t b=kTRUE)    {fCutAcceptKinkDaughters=b;}
  void SetAcceptSharedTPCClusters(Bool_t b=kTRUE){fCutAcceptSharedTPCClusters=b;}
  void SetMaxFractionSharedTPCClusters(Float_t max=1e10) {fCutMaxFractionSharedTPCClusters=max;}
  void SetMaxCovDiagonalElements(Float_t c1=1e10, Float_t c2=1e10, Float_t c3=1e10, Float_t c4=1e10, Float_t c5=1e10) 
    {fCutMaxC11=c1; fCutMaxC22=c2; fCutMaxC33=c3; fCutMaxC44=c4; fCutMaxC55=c5;}
  void SetMaxRel1PtUncertainty(Float_t max=1e10)      {fCutMaxRel1PtUncertainty=max;}


  // track to vertex cut setters
  void SetMaxNsigmaToVertex(Float_t sigma=1e10)       {fCutNsigmaToVertex = sigma; SetRequireSigmaToVertex(kTRUE);}
  void SetRequireSigmaToVertex(Bool_t b=kTRUE)        {fCutSigmaToVertexRequired = b;}
  void SetMaxDCAToVertexXY(Float_t dist=1e10)         {fCutMaxDCAToVertexXY = dist;}
  void SetMaxDCAToVertexZ(Float_t dist=1e10)          {fCutMaxDCAToVertexZ = dist;}
  void SetMinDCAToVertexXY(Float_t dist=0.)           {fCutMinDCAToVertexXY = dist;}
  void SetMinDCAToVertexZ(Float_t dist=0.)            {fCutMinDCAToVertexZ = dist;}
  void SetMaxDCAToVertexXYPtDep(const char *dist="");
  void SetMaxDCAToVertexZPtDep(const char *dist=""); 
  void SetMinDCAToVertexXYPtDep(const char *dist="");
  void SetMinDCAToVertexZPtDep(const char *dist=""); 
  void SetDCAToVertex2D(Bool_t b=kFALSE)              {fCutDCAToVertex2D = b;}


  // getters  
  Int_t   GetMinNClusterTPC()        const   { return fCutMinNClusterTPC;}
  Float_t GetMinLengthActiveVolumeTPC() const { return fCutMinLengthActiveVolumeTPC;}
  Int_t   GetMinNClustersITS()       const   { return fCutMinNClusterITS;}
  TFormula *GetMinNClustersTPCPtDep() const  { return f1CutMinNClustersTPCPtDep;}
  ITSClusterRequirement GetClusterRequirementITS(Detector det) const { return fCutClusterRequirementITS[det]; }
  ITSClusterRequirement GetClusterRequirementITS(ITSULayers det) const { return fCutClusterRequirementITS[det]; }
  Float_t GetMaxChi2PerClusterTPC()  const   { return fCutMaxChi2PerClusterTPC;}
  Float_t GetMaxChi2PerClusterITS()  const   { return fCutMaxChi2PerClusterITS;}
  Float_t GetMaxChi2TPCConstrainedGlobal() const { return fCutMaxChi2TPCConstrainedVsGlobal; }
  Int_t GetMaxChi2TPCConstrainedGlobalVertexType() const { return fCutMaxChi2TPCConstrainedVsGlobalVertexType; }
  Int_t   GetMaxNOfMissingITSPoints() const   { return  fCutMaxMissingITSPoints;}
  Bool_t  GetRequireTPCRefit()       const   { return fCutRequireTPCRefit;}
  Bool_t  GetRequireTPCStandAlone()  const   { return fCutRequireTPCStandAlone;}
  Bool_t  GetRequireITSRefit()       const   { return fCutRequireITSRefit;}
  Bool_t  GetRequireITSStandAlone()  const   { return fCutRequireITSStandAlone; }
  Bool_t  GetAcceptKinkDaughters()   const   { return fCutAcceptKinkDaughters;}
  Bool_t  GetAcceptSharedTPCClusters()        const   {return fCutAcceptSharedTPCClusters;}
  Float_t GetMaxFractionSharedTPCClusters()   const   {return fCutMaxFractionSharedTPCClusters;}
  void    GetMaxCovDiagonalElements(Float_t& c1, Float_t& c2, Float_t& c3, Float_t& c4, Float_t& c5) const<commit_msg>Adding missing getters (for Jonas).<commit_after>//
//  Class for handling of ESD track cuts.
//
//  The class manages a number of track quality cuts, a
//  track-to-vertex cut and a number of kinematic cuts. Two methods
//  can be used to figure out if an ESD track survives the cuts:
//  AcceptTrack which takes a single AliESDtrack as argument and
//  returns kTRUE/kFALSE or GetAcceptedTracks which takes an AliESDEvent
//  object and returns an TObjArray (of AliESDtracks) with the tracks
//  in the ESD that survived the cuts.
//
//
//  TODO:
//  - add functionality to save and load cuts
//  - add histograms for kinematic cut variables?
//  - upper and lower cuts for all (non-boolean) cuts
//  - update print method
//  - put comments to each variable
//

#ifndef ALIESDTRACKCUTS_H
#define ALIESDTRACKCUTS_H

#include <TString.h>

#include "AliAnalysisCuts.h"

class AliESDEvent;
class AliESDtrack;
class AliLog;
class TTree;
class TH1;
class TH1F;
class TH2F;
class TF1;
class TCollection;
class TFormula;

class AliESDtrackCuts : public AliAnalysisCuts
{
public:
  enum ITSClusterRequirement { kOff = 0, kNone, kAny, kFirst, kOnlyFirst, kSecond, kOnlySecond, kBoth };
  enum Detector { kSPD = 0, kSDD, kSSD };
  enum ITSULayers { kITSU012 = 0, kITSU34, kITSU56 };
  enum MultEstTrackCuts { kMultEstTrackCutGlobal = 0, kMultEstTrackCutITSSA, kMultEstTrackCutDCAwSPD, kMultEstTrackCutDCAwoSPD, kNMultEstTrackCuts /* this must always be the last */};
  enum MultEstTrackType { kTrackletsITSTPC = 0, kTrackletsITSSA, kTracklets };
  enum VertexType { kVertexTracks = 0x1, kVertexSPD = 0x2, kVertexTPC = 0x4 };
  
  AliESDtrackCuts(const Char_t* name = "AliESDtrackCuts", const Char_t* title = "");
  virtual ~AliESDtrackCuts();

  virtual Bool_t IsSelected(TObject* obj)
       {return AcceptTrack((AliESDtrack*)obj);}
  virtual Bool_t IsSelected(TList* /*list*/) {return kTRUE;}

  Bool_t AcceptTrack(const AliESDtrack* esdTrack);
  TObjArray* GetAcceptedTracks(const AliESDEvent* esd, Bool_t bTPC = kFALSE);
  Int_t CountAcceptedTracks(const AliESDEvent* const esd);
  
  static Int_t GetReferenceMultiplicity(const AliESDEvent* esd, Bool_t tpcOnly);
  static Int_t GetReferenceMultiplicity(const AliESDEvent* esd, MultEstTrackType trackType = kTrackletsITSTPC, Float_t etaRange = 0.5);
  static AliESDtrackCuts* GetMultEstTrackCuts(MultEstTrackCuts cut);

  static AliESDtrack* GetTPCOnlyTrack(const AliESDEvent* esd, Int_t iTrack);
  
  // Standard cut definitions
  static AliESDtrackCuts* GetStandardTPCOnlyTrackCuts();
  static AliESDtrackCuts* GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries=kTRUE);
  static AliESDtrackCuts* GetStandardITSTPCTrackCuts2010(Bool_t selPrimaries=kTRUE, Int_t clusterCut=0);
  static AliESDtrackCuts* GetStandardITSTPCTrackCuts2011(Bool_t selPrimaries=kTRUE, Int_t clusterCut=1);
  static AliESDtrackCuts* GetStandardITSSATrackCuts2009(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSSATrackCuts2010(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSSATrackCutsPbPb2010(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSPureSATrackCuts2009(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  static AliESDtrackCuts* GetStandardITSPureSATrackCuts2010(Bool_t selPrimaries=kTRUE, Bool_t useForPid=kTRUE);
  // Standard cuts for daughter tracks
  static AliESDtrackCuts* GetStandardV0DaughterCuts();

  virtual Long64_t Merge(TCollection* list);
  virtual void Copy(TObject &c) const;
  AliESDtrackCuts(const AliESDtrackCuts& pd);  // Copy Constructor
  AliESDtrackCuts &operator=(const AliESDtrackCuts &c);

  //######################################################
  // track quality cut setters  
  void SetMinNClustersTPC(Int_t min=-1)          {fCutMinNClusterTPC=min;}
  void SetMinNClustersTPCPtDep(TFormula *f1=0x0, Float_t ptmax=0.);
  void SetMinNClustersITS(Int_t min=-1)          {fCutMinNClusterITS=min;}
  void SetMinNCrossedRowsTPC(Float_t min=-1) { fCutMinNCrossedRowsTPC=min;}
  void SetMinRatioCrossedRowsOverFindableClustersTPC(Float_t min = -1) { fCutMinRatioCrossedRowsOverFindableClustersTPC=min;}
  void SetMinLengthActiveVolumeTPC(Float_t min = 120.) {fCutMinLengthActiveVolumeTPC=min;}
  void SetClusterRequirementITS(Detector det, ITSClusterRequirement req = kOff) { fCutClusterRequirementITS[det] = req; }
  void SetClusterRequirementITS(ITSULayers det, ITSClusterRequirement req = kOff) { fCutClusterRequirementITS[det] = req; }
  void SetMaxChi2PerClusterTPC(Float_t max=1e10) {fCutMaxChi2PerClusterTPC=max;}
  void SetMaxChi2PerClusterITS(Float_t max=1e10) {fCutMaxChi2PerClusterITS=max;}
  void SetMaxChi2TPCConstrainedGlobal(Float_t max=1e10) {fCutMaxChi2TPCConstrainedVsGlobal = max; }
  void SetMaxChi2TPCConstrainedGlobalVertexType(Int_t vertexType = kVertexTracks | kVertexSPD) { fCutMaxChi2TPCConstrainedVsGlobalVertexType = vertexType; }
  void SetMaxNOfMissingITSPoints(Int_t max=6)    {fCutMaxMissingITSPoints=max;}
  void SetRequireTPCRefit(Bool_t b=kFALSE)       {fCutRequireTPCRefit=b;}
  void SetRequireTPCStandAlone(Bool_t b=kFALSE)  {fCutRequireTPCStandAlone=b;}
  void SetRequireITSRefit(Bool_t b=kFALSE)       {fCutRequireITSRefit=b;}
  void SetRequireITSPid(Bool_t b=kFALSE)         {fCutRequireITSPid=b;}
  void SetRequireITSStandAlone(Bool_t b=kFALSE)    {fCutRequireITSStandAlone = b;} 
  void SetRequireITSPureStandAlone(Bool_t b=kFALSE){fCutRequireITSpureSA = b;}


  void SetAcceptKinkDaughters(Bool_t b=kTRUE)    {fCutAcceptKinkDaughters=b;}
  void SetAcceptSharedTPCClusters(Bool_t b=kTRUE){fCutAcceptSharedTPCClusters=b;}
  void SetMaxFractionSharedTPCClusters(Float_t max=1e10) {fCutMaxFractionSharedTPCClusters=max;}
  void SetMaxCovDiagonalElements(Float_t c1=1e10, Float_t c2=1e10, Float_t c3=1e10, Float_t c4=1e10, Float_t c5=1e10) 
    {fCutMaxC11=c1; fCutMaxC22=c2; fCutMaxC33=c3; fCutMaxC44=c4; fCutMaxC55=c5;}
  void SetMaxRel1PtUncertainty(Float_t max=1e10)      {fCutMaxRel1PtUncertainty=max;}


  // track to vertex cut setters
  void SetMaxNsigmaToVertex(Float_t sigma=1e10)       {fCutNsigmaToVertex = sigma; SetRequireSigmaToVertex(kTRUE);}
  void SetRequireSigmaToVertex(Bool_t b=kTRUE)        {fCutSigmaToVertexRequired = b;}
  void SetMaxDCAToVertexXY(Float_t dist=1e10)         {fCutMaxDCAToVertexXY = dist;}
  void SetMaxDCAToVertexZ(Float_t dist=1e10)          {fCutMaxDCAToVertexZ = dist;}
  void SetMinDCAToVertexXY(Float_t dist=0.)           {fCutMinDCAToVertexXY = dist;}
  void SetMinDCAToVertexZ(Float_t dist=0.)            {fCutMinDCAToVertexZ = dist;}
  void SetMaxDCAToVertexXYPtDep(const char *dist="");
  void SetMaxDCAToVertexZPtDep(const char *dist=""); 
  void SetMinDCAToVertexXYPtDep(const char *dist="");
  void SetMinDCAToVertexZPtDep(const char *dist=""); 
  void SetDCAToVertex2D(Bool_t b=kFALSE)              {fCutDCAToVertex2D = b;}


  // getters  
  Int_t   GetMinNClusterTPC()        const   { return fCutMinNClusterTPC;}
  Float_t GetMinNCrossedRowsTPC()    const   { return fCutMinNCrossedRowsTPC;}
  Float_t GetMinRatioCrossedRowsOverFindableClustersTPC()    const   { return fCutMinRatioCrossedRowsOverFindableClustersTPC;}
  Float_t GetMinLengthActiveVolumeTPC() const { return fCutMinLengthActiveVolumeTPC;}
  Int_t   GetMinNClustersITS()       const   { return fCutMinNClusterITS;}
  TFormula *GetMinNClustersTPCPtDep() const  { return f1CutMinNClustersTPCPtDep;}
  ITSClusterRequirement GetClusterRequirementITS(Detector det) const { return fCutClusterRequirementITS[det]; }
  ITSClusterRequirement GetClusterRequirementITS(ITSULayers det) const { return fCutClusterRequirementITS[det]; }
  Float_t GetMaxChi2PerClusterTPC()  const   { return fCutMaxChi2PerClusterTPC;}
  Float_t GetMaxChi2PerClusterITS()  const   { return fCutMaxChi2PerClusterITS;}
  Float_t GetMaxChi2TPCConstrainedGlobal() const { return fCutMaxChi2TPCConstrainedVsGlobal; }
  Int_t GetMaxChi2TPCConstrainedGlobalVertexType() const { return fCutMaxChi2TPCConstrainedVsGlobalVertexType; }
  Int_t   GetMaxNOfMissingITSPoints() const   { return  fCutMaxMissingITSPoints;}
  Bool_t  GetRequireTPCRefit()       const   { return fCutRequireTPCRefit;}
  Bool_t  GetRequireTPCStandAlone()  const   { return fCutRequireTPCStandAlone;}
  Bool_t  GetRequireITSRefit()       const   { return fCutRequireITSRefit;}
  Bool_t  GetRequireITSStandAlone()  const   { return fCutRequireITSStandAlone; }
  Bool_t  GetAcceptKinkDaughters()   const   { return fCutAcceptKinkDaughters;}
  Bool_t  GetAcceptSharedTPCClusters()        const   {return fCutAcceptSharedTPCClusters;}
  Float_t GetMaxFractionSharedTPCClusters()   const   {return fCutMaxFractionSharedTPCClusters;}
  void    GetMaxCovDiagonalElements(Float_t& c1, Float_t& c2, Float_t& c3, Float_t& c4, Float_t& c5) const
{'fraction_non_alphanumeric': 0.08599494485294118, 'fraction_numerical': 0.01838235294117647, 'mean_word_length': 5.891923990498812, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3484352', 'n_tokens_mistral': 6484, 'n_tokens_neox': 6198, 'n_words': 1257}