Skip to content

Commit

Permalink
Use external DPMJET if found
Browse files Browse the repository at this point in the history
This commit is the preparation to remove DPMJET/ from AliRoot;
TDPMjet (as interface to DPMJET) must remain in AliRoot!
  • Loading branch information
qgp committed Feb 18, 2017
1 parent 96e6b18 commit e602a1f
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 8 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,16 @@ else()

# AliRoot modules requiring Fortran
set(ALIROOT_MODULES_FORTRAN
DIME HERWIG HIJING LHAPDF MICROCERN PYTHIA6 PYTHIA8 TAmpt TDPMjet
DIME HERWIG HIJING LHAPDF MICROCERN PYTHIA6 PYTHIA8 TAmpt
TEPEMGEN THbtp THerwig THijing THydjet TPHIC TUHKMgen)
if(NOT DISABLE_FORTRAN)
list(INSERT ALIROOT_MODULES 0 "${ALIROOT_MODULES_FORTRAN}")
find_package(DPMJET)
if(NOT DPMJET_FOUND)
if (DPMJET_FOUND)
list(INSERT ALIROOT_MODULES 0 "TDPMjet")
else()
message(WARNING "Using DPMJET from AliRoot. This is deprecated and it will be removed soon!")
list(INSERT ALIROOT_MODULES 0 "DPMJET")
list(INSERT ALIROOT_MODULES 0 "DPMJET" "TDPMjet")
endif()
else()
string(REPLACE ";" " " ALIROOT_MODULES_FORTRAN_FLAT "${ALIROOT_MODULES_FORTRAN}")
Expand Down
98 changes: 98 additions & 0 deletions TDPMjet/AliDpmJetRndm.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/**************************************************************************
* 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$ */

//-----------------------------------------------------------------------------
// Class: AliDpmJetRndm
// Responsibilities: Interface to Root random number generator
// from Fortran (re-implements FINCTION dt_rndm_dpmjet)
// Very similar to AliHijingRndm
// Note: Since AliGenDpmJet belongs to another module (TDPMjet) one cannot
// pass the ponter to the generator via static variable
// Collaborators: AliGenDPMjet class
//-----------------------------------------------------------------------------

#include <TRandom.h>

#include "AliDpmJetRndm.h"

TRandom * AliDpmJetRndm::fgDpmJetRandom=0;

ClassImp(AliDpmJetRndm)


//_______________________________________________________________________
void AliDpmJetRndm::SetDpmJetRandom(TRandom *ran) {
//
// Sets the pointer to an existing random numbers generator
//
if(ran) fgDpmJetRandom=ran;
else fgDpmJetRandom=gRandom;
}

//_______________________________________________________________________
TRandom * AliDpmJetRndm::GetDpmJetRandom() {
//
// Retrieves the pointer to the random numbers generator
//
return fgDpmJetRandom;
}

#ifndef WIN32
# define dt_rndm_dpmjet dt_rndm_dpmjet_
# define dt_rndmst_dpmjet dt_rndmst_dpmjet_
# define dt_rndmin_dpmjet dt_rndmin_dpmjet_
# define dt_rndmou_dpmjet dt_rndmou_dpmjet_
# define rninit_dpmjet rninit_dpmjet_
# define type_of_call
#else
# define dt_rndm_dpmjet DT_RNDM_DPMJET_
# define dt_rndmst_dpmjet DT_RNDMST_DPMJET
# define dt_rndmin_dpmjet DT_RNDMIN_DPMJET
# define dt_rndmou_dpmjet DT_RNDMOU_DPMJET
# define rninit_dpmjet RNINIT_DPMJET
# define type_of_call _stdcall
#endif


extern "C" {
void type_of_call dt_rndmst_(Int_t &, Int_t &, Int_t &, Int_t &)
{printf("Dummy version of dt_rndmst reached\n");}

void type_of_call dt_rndmin_(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
{printf("Dummy version of dt_rndmin reached\n");}

void type_of_call dt_rndmou_(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
{printf("Dummy version of dt_rndmou reached\n");}

void type_of_call dt_rndmte_(Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
{printf("Dummy version of dt_rndmou reached\n");}

void type_of_call rninit_(Int_t &, Int_t &, Int_t &, Int_t &)
{printf("Dummy version of rninit reached\n");}

Double_t type_of_call dt_rndm_(Int_t &)
{
// Wrapper to static method which retrieves the
// pointer to the Root (C++) generator
Float_t r;
do r = AliDpmJetRndm::GetDpmJetRandom()->Rndm();
while(0 >= r || r >= 1);
return r;
}
}


45 changes: 45 additions & 0 deletions TDPMjet/AliDpmJetRndm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef ALIDPMJETRNDM_H
#define ALIDPMJETRNDM_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */

/* $Id$ */

#include <Rtypes.h>
#include <TError.h>

class TRandom;

class AliDpmJetRndm {
public:
AliDpmJetRndm() {
// Default constructor. The static data member is initialized
// in the implementation file
}
AliDpmJetRndm(const AliDpmJetRndm & /*rn*/) {
// Copy constructor: no copy allowed for the object
::Fatal("Copy constructor","Not allowed\n");
}
virtual ~AliDpmJetRndm() {
// Destructor
fgDpmJetRandom=0;
}

AliDpmJetRndm & operator=(const AliDpmJetRndm& /*rn*/) {
// Assignment operator: no assignment allowed
::Fatal("Assignment operator","Not allowed\n");
return (*this);
}

static void SetDpmJetRandom(TRandom *ran=0);
static TRandom * GetDpmJetRandom();

private:

static TRandom * fgDpmJetRandom; //! pointer to the random number generator

ClassDef(AliDpmJetRndm,0) //Random Number generator wrapper (non persistent)
};

#endif

12 changes: 7 additions & 5 deletions TDPMjet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ include_directories(${AliRoot_SOURCE_DIR}/${MODULE})

# Additional includes - alphabetical order except ROOT
include_directories(${ROOT_INCLUDE_DIR}
${AliRoot_SOURCE_DIR}/DPMJET
${AliRoot_SOURCE_DIR}/EVGEN
${AliRoot_SOURCE_DIR}/STEER/STEER
${AliRoot_SOURCE_DIR}/STEER/STEERBase
Expand All @@ -31,6 +30,7 @@ include_directories(${ROOT_INCLUDE_DIR}
# Sources - alphabetical order
set(SRCS
TDPMjet.cxx
AliDpmJetRndm.cxx
AliGenDPMjet.cxx
AliIonPDGCodes.cxx
)
Expand All @@ -43,14 +43,14 @@ string(REPLACE ".cxx" ".h" HDRS "${SRCS}")
get_directory_property(incdirs INCLUDE_DIRECTORIES)
generate_dictionary("${MODULE}" "${MODULE}LinkDef.h" "${HDRS}" "${incdirs}")

# Add a library to the project using the specified source files
add_library_tested(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)

if(DPMJET_FOUND)
# Use external DPMJET if found
link_directories($DPMJET_LIBPATH)
link_directories(${DPMJET_LIBPATH})
endif()

# Add a library to the project using the specified source files
add_library_tested(${MODULE} SHARED ${SRCS} G__${MODULE}.cxx)

# Generate the ROOT map
# Dependecies
set(LIBDEPS DPMJET EVGEN STEER STEERBase)
Expand All @@ -72,3 +72,5 @@ install(TARGETS ${MODULE}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
install(FILES ${HDRS} DESTINATION include)

message(STATUS "TDPMjet enabled")
2 changes: 2 additions & 0 deletions TDPMjet/TDPMjetLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
#pragma link C++ class AliGenDPMjet+;
#pragma link C++ class AliIonPDGCodes+;

#pragma link C++ class AliDpmJetRndm+;

#endif
11 changes: 11 additions & 0 deletions cmake/FindDPMJET.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
message(STATUS "looking for DPMJET in \"${DPMJET}"\")

find_library(DPMJET_LIB NAMES DPMJET PATHS ${DPMJET}/lib NO_DEFAULT_PATH)

if (DPMJET_LIB)
set(DPMJET_LIBPATH ${DPMJET}/lib)
set(DPMJET_FOUND TRUE)
message(STATUS "DPMJET found")
else()
message(STATUS "DPMJET not found")
endif()

0 comments on commit e602a1f

Please sign in to comment.