File indexing completed on 2025-01-18 09:15:14
0001 #include "CustomRand.hxx"
0002
0003 #include "TF1.h"
0004 #include "TMath.h"
0005 #include "TRandom3.h"
0006
0007 #include <stdio.h>
0008 #include <string.h>
0009 #include <iostream>
0010
0011 using namespace std;
0012
0013 CustomRand::CustomRand(const char * fname,
0014 double ERange[2],
0015 double ThetaRange[2],
0016 double PhiRange[2])
0017 {
0018 extern int Gen_seed;
0019
0020 PartSet = true;
0021
0022 int seed = 0;
0023
0024 cout << "Seed setting: " << Gen_seed << endl;
0025
0026
0027
0028 if(gRandom) delete gRandom;
0029 gRandom = new TRandom3(0);
0030
0031 gRandom -> SetSeed(seed);
0032
0033 char PhiName[100] = "Phi_";
0034 strcat(PhiName, fname);
0035 PhiRand = new TF1(PhiName, "1", PhiRange[0], PhiRange[1]);
0036
0037 char ThetaName[100] = "Theta_";
0038 strcat(ThetaName, fname);
0039
0040
0041
0042
0043
0044 ThetaRand = new TF1(ThetaName, "0.5*sin(x)", ThetaRange[0], ThetaRange[1]);
0045
0046 char EName[100] = "E_%c";
0047 std::sprintf(EName, EName, fname);
0048 ERand = new TF1(EName, "1", ERange[0], ERange[1]);
0049 }
0050
0051
0052
0053
0054 CustomRand::CustomRand(const char * fname,
0055 double ERange[2],
0056 double ThetaRange[2],
0057 double PhiRange[2],
0058 int demp_seed)
0059 {
0060 PartSet = true;
0061
0062 int seed = demp_seed;
0063
0064 if(gRandom) delete gRandom;
0065 gRandom = new TRandom3(0);
0066
0067 gRandom -> SetSeed(seed);
0068
0069 char PhiName[100] = "Phi_";
0070 strcat(PhiName, fname);
0071 PhiRand = new TF1(PhiName, "1", PhiRange[0], PhiRange[1]);
0072
0073 char ThetaName[100] = "Theta_";
0074 strcat(ThetaName, fname);
0075
0076
0077
0078
0079
0080 ThetaRand = new TF1(ThetaName, "0.5*sin(x)", ThetaRange[0], ThetaRange[1]);
0081
0082 char EName[100] = "E_%c";
0083 std::sprintf(EName, EName, fname);
0084 ERand = new TF1(EName, "1", ERange[0], ERange[1]);
0085 }
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 double CustomRand::Phi()
0098 {
0099 return PhiRand->GetRandom();
0100 }
0101 double CustomRand::Theta()
0102 {
0103 return ThetaRand->GetRandom();
0104
0105 }
0106 double CustomRand::E()
0107 {
0108 return ERand->GetRandom();
0109 }