<commit_before>//  $Id$

//**************************************************************************
//* This file is property of and copyright by the ALICE Project            * 
//* ALICE Experiment at CERN, All rights reserved.                         *
//*                                                                        *
//* Primary Authors: <NAME> <<EMAIL>>        *
//*                  <NAME> <<EMAIL>>           *
//*                  <NAME>       <<EMAIL>>               *
//*                                                                        *
//* Permission to use, copy, modify and distribute this software and its   *
//* documentation strictly for non-commercial purposes is hereby granted   *
//* without fee, provided that the above copyright notice appears in all   *
//* copies and that both the copyright notice and this permission notice   *
//* appear in the supporting documentation. The authors make no claims     *
//* about the suitability of this software for any purpose. It is          *
//* provided "as is" without express or implied warranty.                  *
//**************************************************************************

/// @file   AliDxHFEParticleSelectionEl.cxx
/// @author <NAME>, <NAME>, <NAME>
/// @date   2012-03-19
/// @brief  D0 selection for D0-HFE correlation
///
#include "AliDxHFEParticleSelectionEl.h"
#include "AliSelectNonHFE.h"
#include "AliReducedParticle.h"
#include "AliESDtrackCuts.h"
#include "AliVParticle.h"
#include "AliVEvent.h"
#include "AliPID.h"
#include "AliPIDResponse.h"
#include "AliHFEcontainer.h"
#include "AliHFEpid.h"
#include "AliHFEpidBase.h"
#include "AliHFEtools.h"
#include "AliHFEcuts.h"
#include "AliAODTrack.h"
#include "AliAODEvent.h"
#include "AliAnalysisDataSlot.h"
#include "AliAnalysisDataContainer.h"
#include "AliAnalysisManager.h"
#include "AliExternalTrackParam.h"
#include "AliAODVertex.h"
#include "AliHFEextraCuts.h"
#include "AliCFManager.h"
#include "THnSparse.h"
#include "AliLog.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TAxis.h"
#include "TList.h"
#include "TObjArray.h"
#include "AliKFParticle.h"
#include "AliKFVertex.h"
#include <iostream>
#include <cerrno>
#include <memory>

using namespace std;

/// ROOT macro for the implementation of ROOT specific class methods
ClassImp(AliDxHFEParticleSelectionEl)

AliDxHFEParticleSelectionEl::AliDxHFEParticleSelectionEl(const char* opt)
  : AliDxHFEParticleSelection("electron", opt)
  , fPIDTOFTPC(NULL)
  , fPIDTOF(NULL)
  , fPIDTPC(NULL)
  , fPIDTPCEMCAL(NULL)
  , fElectronProperties(NULL)
  , fHistoList(NULL)
  , fCutPidList(NULL)
  , fPIDResponse(NULL)
  , fCuts(NULL)
  , fSelNHFE(NULL)
  , fTrackCuts(NULL)
  , fCFM(NULL)
  , fFinalCutStep(kPIDTOFTPC)
  , fInvMassLow(0.1)
  , fUseInvMassCut(kNoInvMass)
  , fSystem(0)
  , fTrackNum(0)
  , fImpactParamCutRadial(3)
  , fEtaCut(0.8)
  , fSurvivedCutStep(kNotSelected)
  , fStoreCutStepInfo(kFALSE)
  , fSetFilterBit(kTRUE)
  , fBit(0)
  , fMaxPtCombinedPID(999)
  , fUseEMCAL(kFALSE)
  , fMinM20(0.03)
  , fMaxM20(0.3)
  , fMinM02(0.03)
  , fMaxM02(0.5)
  , fDispersion(1)
  , fEovPMin(0.8)
  , fEovPMax(1.2)
{
  // constructor
  // 
  // 
  // 
  // 
  ParseArguments(opt);
}

AliDxHFEParticleSelectionEl::~AliDxHFEParticleSelectionEl()
{
  // destructor
  if (fElectronProperties) {
    delete fElectronProperties;
    fElectronProperties=NULL;
  }
  if(fHistoList){
    delete fHistoList;
    fHistoList=NULL;
  }
  if(fCFM){
    delete fCFM;
    fCFM=NULL;
  }
  if(fPIDResponse){
    delete fPIDResponse;
    fPIDResponse=NULL;
  }
  // NOTE: external objects fPID and fCuts are not deleted here
  fPIDTOFTPC=NULL;
  fPIDTOF=NULL;
  fPIDTPC=NULL;
  fPIDTPCEMCAL=NULL;
  fCuts=NULL;
  if(fSelNHFE){
    delete fSelNHFE;
    fSelNHFE=NULL;
  }
  if(fTrackCuts){
    delete fTrackCuts;
    fTrackCuts=NULL;
  }
}

const char* AliDxHFEParticleSelectionEl::fgkCutBinNames[]={
  "kRecKineITSTPC",
  "kRecPrim",
  "kHFEcuts",
  "kHFEcutsTOFPID",
  "kHFEcutsTPCPID",
  "kPIDTOF",
  "kPIDTPC",
  "kPIDTPCTOF",
  "kINVMASS",
  "Selected e"
};

int AliDxHFEParticleSelectionEl::Init()
{
  //
  // init function
  // 
  int iResult=0;
  // TODO: think about initializing fSelNHFE and fTrackCuts from the macro
  //Initialization of invariant mass cut function (AliSelectNonHFE)
  fSelNHFE= new AliSelectNonHFE("IM","IM");
  // Cuts for associated track in Inv Mass cut
  fTrackCuts = new AliESDtrackCuts();
  fTrackCuts->SetAcceptKinkDaughters(kFALSE);
  fTrackCuts->SetRequireTPCRefit(kTRUE);
  fTrackCuts->SetEtaRange(-0.9,0.9);
  fTrackCuts->SetRequireSigmaToVertex(kTRUE);
  fTrackCuts->SetMaxChi2PerClusterTPC(4.0);
  fTrackCuts->SetMinNClustersTPC(80);
  fTrackCuts->SetPtRange(0.3,1e10);
  
  fSelNHFE->SetTrackCuts(-3, 3, fTrackCuts);
  fSelNHFE->SetInvariantMassCut(fInvMassLow);
  fSelNHFE->SetAlgorithm("KF");
  fSelNHFE->SetAODanalysis(kTRUE);
  
  
  // Implicit call to InitControlObjects() before setting up CFM and fCuts
  // (if not there)
  iResult=AliDxHFEParticleSelection::Init();
  if (iResult<0) return iResult;
  
  //--------Initialize correction Framework and Cuts-------------------------
  // Consider moving this, either to separate function or
  // add a set function for AliCFManager
  // Do we need this? Can we just call AliHFEcuts::CheckParticleCuts
  AliInfo("Setting up CFM");
  fCFM = new AliCFManager;
  // the setup of cut objects is done in AliHFEcuts::Initialize
  // the ids used by this class must be the same, the code might be broken if
  // the sequence in AliHFEcuts::Initialize is changed
  const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
  // reset pointers in the CF manager
  fCFM->SetNStepParticle(kNcutSteps);
  for(Int_t istep = 0; istep < kNcutSteps; istep++) {
    fCFM->SetParticleCutsList(istep, NULL);
  }
  if(!fCuts) {
    AliWarning("Cuts not available. Default cuts will be used");
    fCuts = new AliHFEcuts;
    fCuts->CreateStandardCuts();
  }
  // TODO: error handling?
  fCuts->Initialize(fCFM);
  
  //Setting up TPC PID
  //Add settings for asymmetric cut on nSigma TPC
  //TODO: have this completely set up from addtask 
  const int paramSize=4;
  Double_t params[paramSize];
  memset(params, 0, sizeof(Double_t)*paramSize);
  if(fUseEMCAL)  params[0]=-3.;
  else params[0]=-1.;
  fPIDTPC = new AliHFEpid("hfePidTPC");
  if(!fPIDTPC->GetNumberOfPIDdetectors()) { 
    fPIDTPC->AddDetector("TPC",1);
  }
  fPIDTPC->ConfigureTPCdefaultCut(NULL, params, 3.);
  fPIDTPC->InitializePID();

  if(fUseInvMassCut>kNoInvMass)  AliDebug(2,Form("Setting up with invariant mass cut of %f",fInvMassLow));
  if(fStoreCutStepInfo) AliDebug(2,"will store cut step info");
  AliDebug(2,Form("Stopping selection after step: %d", fFinalCutStep));
  
  return 0;
  
}

THnSparse* AliDxHFEParticleSelectionEl::DefineTHnSparse()
{
  
  //
  // Defines the THnSparse. For now, only calls CreatControlTHnSparse
  // TODO: Add also invariant mass? here and in correlation, to do cut afterwards..
  <commit_msg>Removed setting up TPC PID in electron class (set from AddTask)<commit_after>//  $Id$

//**************************************************************************
//* This file is property of and copyright by the ALICE Project            * 
//* ALICE Experiment at CERN, All rights reserved.                         *
//*                                                                        *
//* Primary Authors: <NAME> <<EMAIL>>        *
//*                  <NAME> <<EMAIL>>           *
//*                  <NAME>       <<EMAIL>>               *
//*                                                                        *
//* Permission to use, copy, modify and distribute this software and its   *
//* documentation strictly for non-commercial purposes is hereby granted   *
//* without fee, provided that the above copyright notice appears in all   *
//* copies and that both the copyright notice and this permission notice   *
//* appear in the supporting documentation. The authors make no claims     *
//* about the suitability of this software for any purpose. It is          *
//* provided "as is" without express or implied warranty.                  *
//**************************************************************************

/// @file   AliDxHFEParticleSelectionEl.cxx
/// @author <NAME>, <NAME>, <NAME>
/// @date   2012-03-19
/// @brief  D0 selection for D0-HFE correlation
///
#include "AliDxHFEParticleSelectionEl.h"
#include "AliSelectNonHFE.h"
#include "AliReducedParticle.h"
#include "AliESDtrackCuts.h"
#include "AliVParticle.h"
#include "AliVEvent.h"
#include "AliPID.h"
#include "AliPIDResponse.h"
#include "AliHFEcontainer.h"
#include "AliHFEpid.h"
#include "AliHFEpidBase.h"
#include "AliHFEtools.h"
#include "AliHFEcuts.h"
#include "AliAODTrack.h"
#include "AliAODEvent.h"
#include "AliAnalysisDataSlot.h"
#include "AliAnalysisDataContainer.h"
#include "AliAnalysisManager.h"
#include "AliExternalTrackParam.h"
#include "AliAODVertex.h"
#include "AliHFEextraCuts.h"
#include "AliCFManager.h"
#include "THnSparse.h"
#include "AliLog.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TAxis.h"
#include "TList.h"
#include "TObjArray.h"
#include "AliKFParticle.h"
#include "AliKFVertex.h"
#include <iostream>
#include <cerrno>
#include <memory>

using namespace std;

/// ROOT macro for the implementation of ROOT specific class methods
ClassImp(AliDxHFEParticleSelectionEl)

AliDxHFEParticleSelectionEl::AliDxHFEParticleSelectionEl(const char* opt)
  : AliDxHFEParticleSelection("electron", opt)
  , fPIDTOFTPC(NULL)
  , fPIDTOF(NULL)
  , fPIDTPC(NULL)
  , fPIDTPCEMCAL(NULL)
  , fElectronProperties(NULL)
  , fHistoList(NULL)
  , fCutPidList(NULL)
  , fPIDResponse(NULL)
  , fCuts(NULL)
  , fSelNHFE(NULL)
  , fTrackCuts(NULL)
  , fCFM(NULL)
  , fFinalCutStep(kPIDTOFTPC)
  , fInvMassLow(0.1)
  , fUseInvMassCut(kNoInvMass)
  , fSystem(0)
  , fTrackNum(0)
  , fImpactParamCutRadial(3)
  , fEtaCut(0.8)
  , fSurvivedCutStep(kNotSelected)
  , fStoreCutStepInfo(kFALSE)
  , fSetFilterBit(kTRUE)
  , fBit(0)
  , fMaxPtCombinedPID(999)
  , fUseEMCAL(kFALSE)
  , fMinM20(0.03)
  , fMaxM20(0.3)
  , fMinM02(0.03)
  , fMaxM02(0.5)
  , fDispersion(1)
  , fEovPMin(0.8)
  , fEovPMax(1.2)
{
  // constructor
  // 
  // 
  // 
  // 
  ParseArguments(opt);
}

AliDxHFEParticleSelectionEl::~AliDxHFEParticleSelectionEl()
{
  // destructor
  if (fElectronProperties) {
    delete fElectronProperties;
    fElectronProperties=NULL;
  }
  if(fHistoList){
    delete fHistoList;
    fHistoList=NULL;
  }
  if(fCFM){
    delete fCFM;
    fCFM=NULL;
  }
  if(fPIDResponse){
    delete fPIDResponse;
    fPIDResponse=NULL;
  }
  // NOTE: external objects fPID and fCuts are not deleted here
  fPIDTOFTPC=NULL;
  fPIDTOF=NULL;
  fPIDTPC=NULL;
  fPIDTPCEMCAL=NULL;
  fCuts=NULL;
  if(fSelNHFE){
    delete fSelNHFE;
    fSelNHFE=NULL;
  }
  if(fTrackCuts){
    delete fTrackCuts;
    fTrackCuts=NULL;
  }
}

const char* AliDxHFEParticleSelectionEl::fgkCutBinNames[]={
  "kRecKineITSTPC",
  "kRecPrim",
  "kHFEcuts",
  "kHFEcutsTOFPID",
  "kHFEcutsTPCPID",
  "kPIDTOF",
  "kPIDTPC",
  "kPIDTPCTOF",
  "kINVMASS",
  "Selected e"
};

int AliDxHFEParticleSelectionEl::Init()
{
  //
  // init function
  // 
  int iResult=0;
  // TODO: think about initializing fSelNHFE and fTrackCuts from the macro
  //Initialization of invariant mass cut function (AliSelectNonHFE)
  fSelNHFE= new AliSelectNonHFE("IM","IM");
  // Cuts for associated track in Inv Mass cut
  fTrackCuts = new AliESDtrackCuts();
  fTrackCuts->SetAcceptKinkDaughters(kFALSE);
  fTrackCuts->SetRequireTPCRefit(kTRUE);
  fTrackCuts->SetEtaRange(-0.9,0.9);
  fTrackCuts->SetRequireSigmaToVertex(kTRUE);
  fTrackCuts->SetMaxChi2PerClusterTPC(4.0);
  fTrackCuts->SetMinNClustersTPC(80);
  fTrackCuts->SetPtRange(0.3,1e10);
  
  fSelNHFE->SetTrackCuts(-3, 3, fTrackCuts);
  fSelNHFE->SetInvariantMassCut(fInvMassLow);
  fSelNHFE->SetAlgorithm("KF");
  fSelNHFE->SetAODanalysis(kTRUE);
  
  
  // Implicit call to InitControlObjects() before setting up CFM and fCuts
  // (if not there)
  iResult=AliDxHFEParticleSelection::Init();
  if (iResult<0) return iResult;
  
  //--------Initialize correction Framework and Cuts-------------------------
  // Consider moving this, either to separate function or
  // add a set function for AliCFManager
  // Do we need this? Can we just call AliHFEcuts::CheckParticleCuts
  AliInfo("Setting up CFM");
  fCFM = new AliCFManager;
  // the setup of cut objects is done in AliHFEcuts::Initialize
  // the ids used by this class must be the same, the code might be broken if
  // the sequence in AliHFEcuts::Initialize is changed
  const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
  // reset pointers in the CF manager
  fCFM->SetNStepParticle(kNcutSteps);
  for(Int_t istep = 0; istep < kNcutSteps; istep++) {
    fCFM->SetParticleCutsList(istep, NULL);
  }
  if(!fCuts) {
    AliWarning("Cuts not available. Default cuts will be used");
    fCuts = new AliHFEcuts;
    fCuts->CreateStandardCuts();
  }
  // TODO: error handling?
  fCuts->Initialize(fCFM);

  if(fUseInvMassCut>kNoInvMass)  AliDebug(2,Form("Setting up with invariant mass cut of %f",fInvMassLow));
  if(fStoreCutStepInfo) AliDebug(2,"will store cut step info");
  AliDebug(2,Form("Stopping selection after step: %d", fFinalCutStep));
  
  return 0;
  
}

THnSparse* AliDxHFEParticleSelectionEl::DefineTHnSparse()
{
  
  //
  // Defines the THnSparse. For now, only calls CreatControlTHnSparse
  // TODO: Add also invariant mass? here and in correlation, to do cut afterwards..
  
{'fraction_non_alphanumeric': 0.143139118356605, 'fraction_numerical': 0.01067329483149353, 'mean_word_length': 3.4940867279894876, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7481509', 'n_tokens_mistral': 5117, 'n_tokens_neox': 4898, 'n_words': 1063}