#define _USE_MATH_DEFINES #include #include #include #include // Root libraries #include "TRandom3.h" #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; Double_t w(double x) { Double_t E=M_E; Double_t Pi=M_PI; Double_t value=(1. - cos(Pi/8. + x/10.)/pow(E,x/500.))/pow(E,x/1000.); return value; } void tmgn() { cout.precision(24); Double_t x, y; TFile *fileout = new TFile("5dfnctn15.root", "RECREATE"); TTree *Tout= new TTree("Tout", "timegen"); Tout->Branch("time",&x,"x/D"); Int_t nBins = 300; Double_t xMin = 0.0; Double_t xMax = 1500.0; gRandom = new TRandom3(0); //TRandom3 rand(0); Int_t nEvents = 1e6; ofstream myconf; myconf.precision(30); Int_t i; myconf.open("5dtest.dat",ios::trunc); Int_t counter=0; for (i = 0; i < nEvents; i++) { Double_t ceiling, test, prob; ceiling =2.0001; test = 1.; prob = 0.; while (test > prob) { //x = xMin + (xMax - xMin) * rand.Rndm(); x = xMin + (xMax - xMin) * gRandom->Uniform(1.0); y = w(x); prob = (double)y / (double) ceiling; test = gRandom->Uniform(1.0); // test = rand.Rndm(); counter+=1; } Tout->Fill(); myconf<Write(); fileout->Close(); cout<<"Out of"<<" "< mtrx; while(fin >> number){ mtrx.push_back(number); } std::sort (mtrx.begin(), mtrx.end()); const Int_t nevents = mtrx.size(); for (Int_t i=0;i