本文整理汇总了C++中TRandom::Landau方法的典型用法代码示例。如果您正苦于以下问题:C++ TRandom::Landau方法的具体用法?C++ TRandom::Landau怎么用?C++ TRandom::Landau使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRandom
的用法示例。
在下文中一共展示了TRandom::Landau方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tv3Write
void tv3Write() {
//creates the Tree
TVector3 *v = new TVector3();
TVector3::Class()->IgnoreTObjectStreamer();
TFile *f = new TFile("v3.root","recreate");
TTree *T = new TTree("T","v3 Tree");
T->Branch("v3","TVector3",&v,32000,1);
TRandom r;
for (Int_t i=0;i<10000;i++) {
v->SetXYZ(r.Gaus(0,1),r.Landau(0,1),r.Gaus(100,10));
T->Fill();
}
T->Write();
T->Print();
delete f;
}
示例2: CreateParentTree
void CreateParentTree() {
// create a simple TTree with 5 branches
// Two branches ("Run" and "Event") will be used to index the Tree
TFile *f = new TFile("treeparent.root","recreate");
TTree *T = new TTree("T","test friend trees");
T->Branch("Run",&Run,"Run/I");
T->Branch("Event",&Event,"Event/I");
T->Branch("x",&x,"x/F");
T->Branch("y",&y,"y/F");
T->Branch("z",&z,"z/F");
TRandom r;
for (Int_t i=0;i<10000;i++) {
if (i < 5000) Run = 1;
else Run = 2;
Event = i;
x = r.Gaus(10,1);
y = r.Gaus(20,2);
z = r.Landau(2,1);
T->Fill();
}
T->Print();
T->Write();
delete f;
}
示例3: GenerateTree
//_____________________________________________________________________________
Int_t ProofAux::GenerateTree(const char *fnt, Long64_t ent, TString &fn)
{
// Generate the main tree for the 'friends' tutorial; the tree is called
// 'Tmain', has 'ent' entries and is saved to file 'fnt'.
// The full file path is returned in 'fn'.
// Return 0 on success, -1 on error.
Int_t rc = -1;
// Check the filename
fn = fnt;
if (fn.IsNull()) {
Error("GenerateTree", "file name undefined!");
return rc;
}
TUrl uu(fn, kTRUE);
if (!strcmp(uu.GetProtocol(), "file") && !fn.BeginsWith("/")) {
// Local file with relative path: create under the data directory
if (!gProofServ ||
!(gProofServ->GetDataDir()) || strlen(gProofServ->GetDataDir()) <= 0) {
Error("GenerateTree", "data directory undefined!");
return rc;
}
// Insert data directory
fn.Insert(0, TString::Format("%s/", gProofServ->GetDataDir()));
// Make sure the directory exists
TString dir = gSystem->DirName(fn);
if (gSystem->AccessPathName(dir, kWritePermission)) {
if (gSystem->mkdir(dir, kTRUE) != 0) {
Error("GenerateTree", "problems creating directory %s to store the file", dir.Data());
return rc;
}
}
}
// Create the file
TDirectory* savedir = gDirectory;
TFile *f = new TFile(fn, "RECREATE");
if (!f || f->IsZombie()) {
Error("GenerateTree", "problems opening file %s", fn.Data());
return rc;
}
savedir->cd();
rc = 0;
// Create the tree
TTree *T = new TTree("Tmain","Main tree for tutorial friends");
T->SetDirectory(f);
Int_t Run = 1;
T->Branch("Run",&Run,"Run/I");
Long64_t Event = 0;
T->Branch("Event",&Event,"Event/L");
Float_t x = 0., y = 0., z = 0.;
T->Branch("x",&x,"x/F");
T->Branch("y",&y,"y/F");
T->Branch("z",&z,"z/F");
TRandom r;
for (Long64_t i = 0; i < ent; i++) {
if (i > 0 && i%1000 == 0) Run++;
Event = i;
x = r.Gaus(10,1);
y = r.Gaus(20,2);
z = r.Landau(2,1);
T->Fill();
}
T->Print();
f->cd();
T->Write();
T->SetDirectory(0);
f->Close();
delete f;
delete T;
// Notify success
Info("GenerateTree", "file '%s' successfully created", fn.Data());
// Add to the list
TString fds(fn);
if (!strcmp(uu.GetProtocol(), "file")) {
if (gSystem->Getenv("LOCALDATASERVER")) {
if (strcmp(TUrl(gSystem->Getenv("LOCALDATASERVER"), kTRUE).GetProtocol(), "file"))
fds.Insert(0, TString::Format("%s/", gSystem->Getenv("LOCALDATASERVER")));
} else {
fds.Insert(0, TString::Format("root://%s/", gSystem->HostName()));
}
}
fMainList->Add(new TObjString(fds));
// Done
return rc;
}