<commit_before>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * 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.                  *
 **************************************************************************/

/* $Id$ */

// Base class for generators using external MC generators.
// For example AliGenPythia using Pythia.
// Provides basic functionality: setting of kinematic cuts on 
// decay products and particle selection.
// <EMAIL>

#include <TClonesArray.h>
#include <TMath.h>
#include <TPDGCode.h>
#include <TParticle.h>

#include "AliGenMC.h"
#include "AliRun.h"
#include "AliGeometry.h"

ClassImp(AliGenMC)

AliGenMC::AliGenMC()
    :AliGenerator(),
     fParticles(0),
     fParentSelect(8),
     fChildSelect(8),
     fCutOnChild(0),
     fChildPtMin(0.),
     fChildPtMax(1.e10),
     fChildPMin(0.),
     fChildPMax(1.e10),
     fChildPhiMin(0.),
     fChildPhiMax(2. * TMath::Pi()),
     fChildThetaMin(0.),
     fChildThetaMax(TMath::Pi()),
     fChildYMin(-12.),
     fChildYMax(12.),
     fXingAngleX(0.),
     fXingAngleY(0.),
     fForceDecay(kAll),
     fMaxLifeTime(1.e-15),
     fAProjectile(1),
     fZProjectile(1),
     fATarget(1),
     fZTarget(1),
     fProjectile("P"),
     fTarget("P"),    
     fDyBoost(0.),
     fGeometryAcceptance(0),
     fPdgCodeParticleforAcceptanceCut(0),
     fNumberOfAcceptedParticles(0),
     fNprimaries(0)
{
// Default Constructor
}

AliGenMC::AliGenMC(Int_t npart)
    :AliGenerator(npart),
     fParticles(0),
     fParentSelect(8),
     fChildSelect(8),
     fCutOnChild(0),
     fChildPtMin(0.),
     fChildPtMax(1.e10),
     fChildPMin(0.),
     fChildPMax(1.e10),
     fChildPhiMin(0.),
     fChildPhiMax(2. * TMath::Pi()),
     fChildThetaMin(0.),
     fChildThetaMax(TMath::Pi()),
     fChildYMin(-12.),
     fChildYMax(12.),
     fXingAngleX(0.),
     fXingAngleY(0.),
     fForceDecay(kAll),
     fMaxLifeTime(1.e-15),
     fAProjectile(1),
     fZProjectile(1),
     fATarget(1),
     fZTarget(1),
     fProjectile("P"),
     fTarget("P"),    
     fDyBoost(0.),
     fGeometryAcceptance(0),
     fPdgCodeParticleforAcceptanceCut(0),
     fNumberOfAcceptedParticles(0),
     fNprimaries(0)
{
//  Constructor
// 
    for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
}

AliGenMC::~AliGenMC()
{
// Destructor
}

void AliGenMC::Init()
{
//
//  Initialization
    switch (fForceDecay) {
    case kBSemiElectronic:
    case kSemiElectronic:
    case kDiElectron:
    case kBJpsiDiElectron:
    case kBPsiPrimeDiElectron:
	fChildSelect[0] = kElectron;	
	break;
    case kHardMuons:	
    case kBSemiMuonic:
    case kSemiMuonic:
    case kDiMuon:
    case kBJpsiDiMuon:
    case kBPsiPrimeDiMuon:
    case kPiToMu:
    case kKaToMu:
    case kWToMuon:
    case kWToCharmToMuon:
    case kZDiMuon:
    case kZDiElectron:
	fChildSelect[0]=kMuonMinus;
	break;
    case kWToCharm:
	break;
    case kHadronicD:
    case kHadronicDWithout4Bodies:
	fChildSelect[0]=kPiPlus;
	fChildSelect[1]=kKPlus;
	break;
    case kPhiKK:
	fChildSelect[0]=kKPlus;
	break;
    case kBJpsi:
	fChildSelect[0]=443;
	break;
    case kOmega:	
    case kAll:
    case kAllMuonic:
    case kNoDecay:
    case kNoDecayHeavy:
    case kNeutralPion:
	break;
    }

    if (fZTarget != 0 && fAProjectile != 0) 
    {
	fDyBoost    = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) / 
					 (Double_t(fZTarget)    * Double_t(fAProjectile)));
    }
}


Bool_t AliGenMC::ParentSelected(Int_t ip) const
{
// True if particle is in list of parent particles to be selected
    for (Int_t i=0; i<8; i++)
    {
	if (fParentSelect.At(i) == ip) return kTRUE;
    }
    return kFALSE;
}

Bool_t AliGenMC::ChildSelected(Int_t ip) const
{
// True if particle is in list of decay products to be selected
    for (Int_t i=0; i<5; i++)
    {
	if (fChildSelect.At(i) == ip) return kTRUE;
    }
    return kFALSE;
}

Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
{
// Perform kinematic selection
    Float_t pz    = particle->Pz();
    Float_t  e    = particle->Energy();
    Float_t pt    = particle->Pt();
    Float_t p     = particle->P();
    Float_t theta = particle->Theta();
    Float_t mass  = particle->GetCalcMass();
    Float_t mt2   = pt * pt + mass * mass;
    Float_t phi   = particle->Phi();
    
    Double_t y, y0;

    if (TMath::Abs(pz) <  e) {
	y = 0.5*TMath::Log((e+pz)/(e-pz));
    } else {
	y = 1.e10;
    }
    
    if (mt2) {
	y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
    } else {
	if (TMath::Abs(y) < 1.e10) {
	    y0 = y;
	} else {
	    y0 = 1.e10;
	}<commit_msg>Using double precision<commit_after>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * 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.                  *
 **************************************************************************/

/* $Id$ */

// Base class for generators using external MC generators.
// For example AliGenPythia using Pythia.
// Provides basic functionality: setting of kinematic cuts on 
// decay products and particle selection.
// and<EMAIL>

#include <TClonesArray.h>
#include <TMath.h>
#include <TPDGCode.h>
#include <TParticle.h>

#include "AliGenMC.h"
#include "AliRun.h"
#include "AliGeometry.h"

ClassImp(AliGenMC)

AliGenMC::AliGenMC()
    :AliGenerator(),
     fParticles(0),
     fParentSelect(8),
     fChildSelect(8),
     fCutOnChild(0),
     fChildPtMin(0.),
     fChildPtMax(1.e10),
     fChildPMin(0.),
     fChildPMax(1.e10),
     fChildPhiMin(0.),
     fChildPhiMax(2. * TMath::Pi()),
     fChildThetaMin(0.),
     fChildThetaMax(TMath::Pi()),
     fChildYMin(-12.),
     fChildYMax(12.),
     fXingAngleX(0.),
     fXingAngleY(0.),
     fForceDecay(kAll),
     fMaxLifeTime(1.e-15),
     fAProjectile(1),
     fZProjectile(1),
     fATarget(1),
     fZTarget(1),
     fProjectile("P"),
     fTarget("P"),    
     fDyBoost(0.),
     fGeometryAcceptance(0),
     fPdgCodeParticleforAcceptanceCut(0),
     fNumberOfAcceptedParticles(0),
     fNprimaries(0)
{
// Default Constructor
}

AliGenMC::AliGenMC(Int_t npart)
    :AliGenerator(npart),
     fParticles(0),
     fParentSelect(8),
     fChildSelect(8),
     fCutOnChild(0),
     fChildPtMin(0.),
     fChildPtMax(1.e10),
     fChildPMin(0.),
     fChildPMax(1.e10),
     fChildPhiMin(0.),
     fChildPhiMax(2. * TMath::Pi()),
     fChildThetaMin(0.),
     fChildThetaMax(TMath::Pi()),
     fChildYMin(-12.),
     fChildYMax(12.),
     fXingAngleX(0.),
     fXingAngleY(0.),
     fForceDecay(kAll),
     fMaxLifeTime(1.e-15),
     fAProjectile(1),
     fZProjectile(1),
     fATarget(1),
     fZTarget(1),
     fProjectile("P"),
     fTarget("P"),    
     fDyBoost(0.),
     fGeometryAcceptance(0),
     fPdgCodeParticleforAcceptanceCut(0),
     fNumberOfAcceptedParticles(0),
     fNprimaries(0)
{
//  Constructor
// 
    for (Int_t i=0; i<8; i++) fParentSelect[i]=fChildSelect[i]=0;
}

AliGenMC::~AliGenMC()
{
// Destructor
}

void AliGenMC::Init()
{
//
//  Initialization
    switch (fForceDecay) {
    case kBSemiElectronic:
    case kSemiElectronic:
    case kDiElectron:
    case kBJpsiDiElectron:
    case kBPsiPrimeDiElectron:
	fChildSelect[0] = kElectron;	
	break;
    case kHardMuons:	
    case kBSemiMuonic:
    case kSemiMuonic:
    case kDiMuon:
    case kBJpsiDiMuon:
    case kBPsiPrimeDiMuon:
    case kPiToMu:
    case kKaToMu:
    case kWToMuon:
    case kWToCharmToMuon:
    case kZDiMuon:
    case kZDiElectron:
	fChildSelect[0]=kMuonMinus;
	break;
    case kWToCharm:
	break;
    case kHadronicD:
    case kHadronicDWithout4Bodies:
	fChildSelect[0]=kPiPlus;
	fChildSelect[1]=kKPlus;
	break;
    case kPhiKK:
	fChildSelect[0]=kKPlus;
	break;
    case kBJpsi:
	fChildSelect[0]=443;
	break;
    case kOmega:	
    case kAll:
    case kAllMuonic:
    case kNoDecay:
    case kNoDecayHeavy:
    case kNeutralPion:
	break;
    }

    if (fZTarget != 0 && fAProjectile != 0) 
    {
	fDyBoost    = - 0.5 * TMath::Log(Double_t(fZProjectile) * Double_t(fATarget) / 
					 (Double_t(fZTarget)    * Double_t(fAProjectile)));
    }
}


Bool_t AliGenMC::ParentSelected(Int_t ip) const
{
// True if particle is in list of parent particles to be selected
    for (Int_t i=0; i<8; i++)
    {
	if (fParentSelect.At(i) == ip) return kTRUE;
    }
    return kFALSE;
}

Bool_t AliGenMC::ChildSelected(Int_t ip) const
{
// True if particle is in list of decay products to be selected
    for (Int_t i=0; i<5; i++)
    {
	if (fChildSelect.At(i) == ip) return kTRUE;
    }
    return kFALSE;
}

Bool_t AliGenMC::KinematicSelection(TParticle *particle, Int_t flag) const
{
// Perform kinematic selection
    Double_t pz    = particle->Pz();
    Double_t  e    = particle->Energy();
    Double_t pt    = particle->Pt();
    Double_t p     = particle->P();
    Double_t theta = particle->Theta();
    Double_t mass  = particle->GetCalcMass();
    Double_t mt2   = pt * pt + mass * mass;
    Double_t phi   = particle->Phi();
    
    Double_t y, y0;

    if (TMath::Abs(pz) <  e) {
	y = 0.5*TMath::Log((e+pz)/(e-pz));
    } else {
	y = 1.e10;
    }
    
    if (mt2) {
	y0 = 0.5*TMath::Log((e+TMath::Abs(pz))*(e+TMath::Abs(pz))/mt2);
    } else {
	if (TMath::Abs(y) < 1.e10) {
	    y0 = y;
	} else {
	    y0 = 1.e10;
	}
{'fraction_non_alphanumeric': 0.14967978042086003, 'fraction_numerical': 0.021043000914913082, 'mean_word_length': 2.669352131587781, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '304659', 'n_tokens_mistral': 4062, 'n_tokens_neox': 3886, 'n_words': 830}