LCOV - code coverage report
Current view: top level - PYTHIA6/AliPythia6 - AliPythiaRndm.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 16 18.8 %
Date: 2016-06-14 17:26:59 Functions: 2 7 28.6 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : //-----------------------------------------------------------------------------
      19             : //   Class: AliPythiaRndm
      20             : //   Responsibilities: Interface to Root random number generator
      21             : //                     from Fortran (re-implements FINCTION PYR from PYTHIA)
      22             : //                     Very similar to AliHijingRndm
      23             : //   Collaborators: AliPythia and AliGenPythia classes
      24             : //   Example:
      25             : //
      26             : //   root> AliPythia::Instance();
      27             : //   root> AliPythiaRndm::SetPythiaRandom(new TRandom3());
      28             : //   root> AliPythiaRndm::GetPythiaRandom()->SetSeed(0);
      29             : //   root> cout<<"Seed "<< AliPythiaRndm::GetPythiaRandom()->GetSeed() <<endl;
      30             : //
      31             : //-----------------------------------------------------------------------------
      32             : 
      33             : #include <TMath.h>
      34             : #include <TRandom.h>
      35             : 
      36             : #include "AliPythiaRndm.h"
      37             : 
      38             : TRandom * AliPythiaRndm::fgPythiaRandom=0;
      39             : 
      40           2 : ClassImp(AliPythiaRndm)
      41             : 
      42             : 
      43             : //_______________________________________________________________________
      44             : void AliPythiaRndm::SetPythiaRandom(TRandom *ran) {
      45             :   //
      46             :   // Sets the pointer to an existing random numbers generator
      47             :   //
      48           0 :   if(ran) fgPythiaRandom=ran;
      49           0 :   else fgPythiaRandom=gRandom;
      50           0 : }
      51             : 
      52             : //_______________________________________________________________________
      53             : TRandom * AliPythiaRndm::GetPythiaRandom() {
      54             :   //
      55             :   // Retrieves the pointer to the random numbers generator
      56             :   //
      57           3 :   if (!fgPythiaRandom) fgPythiaRandom=gRandom;
      58           1 :   return fgPythiaRandom;
      59             : }
      60             : 
      61             : //_______________________________________________________________________
      62             : #define pyr        pyr_
      63             : #define pygauss    pygauss_
      64             : #define pyrset     pyrset_
      65             : #define pyrget     pyrget_
      66             : 
      67             : extern "C" {
      68             :     Double_t pyr(Int_t*)
      69             :     {
      70             :         // Wrapper to FUNCTION PYR from PYTHIA
      71             :         // Uses static method to retrieve the pointer to the (C++) generator
      72             :         Double_t r;
      73           0 :         do r=AliPythiaRndm::GetPythiaRandom()->Rndm();
      74           0 :         while(0 >= r || r >= 1);
      75           0 :         return r;
      76             :     }
      77             : 
      78             :     Double_t pygauss(Double_t x0, Double_t sig)
      79             :     {
      80             :         Double_t s = 2.;
      81             :         Double_t v1 = 0.;
      82             :         Double_t v2 = 0.;
      83             : 
      84           0 :         while (s > 1.) {
      85           0 :             v1 = 2. * pyr(0) - 1.;
      86           0 :             v2 = 2. * pyr(0) - 1.;
      87           0 :             s = v1 * v1 + v2 * v2;
      88             :         }
      89           0 :         return v1 * TMath::Sqrt(-2. * TMath::Log(s) / s) * sig + x0;
      90             :     }
      91             : 
      92           0 :     void pyrset(Int_t*,Int_t*) {}
      93           0 :     void pyrget(Int_t*,Int_t*) {}
      94             : }

Generated by: LCOV version 1.11