void standaloneBoxGen(double pabs, int nevents, double fThetaMin, double fThetaMax, TString output_filename, double seed = 123456.) { double mp = 0.938272; double fPhiMin = 0.0; double fPhiMax = 360.0; TClonesArray ca("TParticle", 1); TClonesArray *pars = &ca; TFile *f = new TFile(output_filename, "RECREATE"); TTree *t = new TTree("data", "data"); t->Branch("Particles", &pars); gRandom->SetSeed(seed); //boost::progress_display show_progress(nevents); for (unsigned int i = 0; i < nevents; i++) { //double theta = tmp->GetRandom(gen_range_low, gen_range_high) / 1000.0; //double phi = gRandom->Uniform(-C_PI, C_PI); double theta = gRandom->Uniform(fThetaMin,fThetaMax) * TMath::DegToRad(); double phi = gRandom->Uniform(fPhiMin,fPhiMax) * TMath::DegToRad(); double pz = pabs*TMath::Cos(theta); double pt = pabs*TMath::Sin(theta); double px = pt*TMath::Cos(phi); double py = pt*TMath::Sin(phi); TLorentzVector vertex(0, 0, 0, 0); TLorentzVector mom(px, py, pz, sqrt(mp * mp + pabs * pabs)); TParticle p(-2212, 1, 0, 0, 0, 0, mom, vertex); new (ca[0]) TParticle(-2212, 1, 0, 0, 0, 0, mom, vertex); t->Fill(); ca.Delete(); // ++show_progress; } t->Write(); f->Close(); }