#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; // Use the Math namespace using namespace ROOT::Math; double ff_lt(double* x, double* par) { double lt2 = x[0]*x[0]; // l_t^2 double& mg = par[0]; // m_g,min double& mu = par[1]; // \mu return x[0] * log(1. + lt2/(exp(1.0) * mg*mg)) / pow(lt2 + mu*mu, 2); } int main(int argc, char **argv) { int nthreads = atoi(argv[1]); cout << "running with " << nthreads << " threads\n"; int rseed = 438468301; double mg = 0.3, mu = 0.4; const double dt = 0.2; const int Ncasc = 10000; omp_set_num_threads(nthreads); ROOT::EnableThreadSafety(); // initializing the TF1 objects for all threads TRandom3* rnd [nthreads]; TF1* flt [nthreads]; DistSampler * sampler [nthreads]; for(int i=0; iSetFunction(*flt[i],1); // last argument: 1-dim sampler[i]->SetRandom(rnd[i]); sampler[i]->Init(); } cout << "init done\n"; // parallel loop #pragma omp parallel for schedule(static, 1000) for(int icasc=0; icascSetParameters(mg, mu); //double lt = flt[thread_id]->GetRandom(); sampler[thread_id]->SetRange(0.,10.); bool ret = sampler[thread_id]->Init(); double lt[3]; sampler[thread_id]->Sample(lt); } // end parallel loop return 0; }