Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-28 07:02:48

0001 /**
0002  \file
0003  Declaration of class Smear::Distributor.
0004  
0005  \author    Michael Savastio
0006  \date      2011-08-19
0007  \copyright 2011 Brookhaven National Lab
0008  */
0009 
0010 #ifndef INCLUDE_EICSMEAR_SMEAR_DISTRIBUTOR_H_
0011 #define INCLUDE_EICSMEAR_SMEAR_DISTRIBUTOR_H_
0012 
0013 #include <Rtypes.h>
0014 
0015 class TF1;
0016 class TString;
0017 
0018 namespace Smear {
0019 
0020 /**
0021  Distribution function for random sampling.
0022  Used by devices to generate smearing on some distribution.
0023  By default, smearing is generated on a Gaussian
0024  of which the Monte Carlo value is the mean, and the standard deviation
0025  is given by the device parametrization.
0026  It is intended that you access this object via the methods provided
0027  in the Device class.
0028  \todo This could do with some reworking, to make it compatible with
0029  an arbitrary function via a functor (which I think is the best way
0030  to go). Move to its own files.
0031  */
0032 class Distributor {
0033  public:
0034   /**
0035    Default constructor.
0036    Gaussian distribution.
0037    */
0038   Distributor();
0039 
0040   /**
0041    Initialise with a ROOT::TF1-style string.
0042    The function should depend on two parameters, the first of which
0043    specifies the function midpoint and the second of which species a width.
0044    See ROOT::TF1 documentation for details of the string format.
0045    For example, for a step function, one could use
0046    Distributor("abs(x-[0])<[1]");
0047    where [0] stands for the first parameter (midpoint) and [1] is the
0048    second parameter (width).
0049    The second and third arguments limit the range of thrown values around
0050    the midpoint to [midpoint - lower, midpoint + upper].
0051    Values of <= 0 give no limit.
0052    The 4th and 5th arguments define the valid range of the function.
0053    */
0054   Distributor(const TString& formula, double lower, double upper,
0055               double minimum = -1.e6, double maximum = 1.e6);
0056 
0057   /**
0058    Destructor.
0059    */
0060   virtual ~Distributor();
0061 
0062   /**
0063    Generate a random value based on a given midpoint and width.
0064    */
0065   virtual double Generate(double midpoint, double width);
0066 
0067  protected:
0068   double mPlus;
0069   double mMinus;
0070   TF1* mDistribution;
0071 
0072   ClassDef(Smear::Distributor, 1)
0073 };
0074 
0075 }  // namespace Smear
0076 
0077 #endif  // INCLUDE_EICSMEAR_SMEAR_DISTRIBUTOR_H_