本文整理汇总了C++中TTree::SetAutoFlush方法的典型用法代码示例。如果您正苦于以下问题:C++ TTree::SetAutoFlush方法的具体用法?C++ TTree::SetAutoFlush怎么用?C++ TTree::SetAutoFlush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTree
的用法示例。
在下文中一共展示了TTree::SetAutoFlush方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parallelMergeClient
void parallelMergeClient()
{
// Client program which creates and fills 2 histograms and a TTree.
// Every 1000000 fills the histograms and TTree is send to the server which displays the histogram.
//
// To run this demo do the following:
// - Open at least 2 windows
// - Start ROOT in the first windows
// - Execute in the first window: .x fastMergeServer.C
// - Execute in the other windows: root.exe -b -l -q .x treeClient.C
// (You can put it in the background if wanted).
// If you want to run the hserv.C on a different host, just change
// "localhost" in the TSocket ctor below to the desired hostname.
//
//Author: Fons Rademakers, Philippe Canal
gBenchmark->Start("treeClient");
TParallelMergingFile *file = (TParallelMergingFile*)TFile::Open("mergedClient.root?pmerge=localhost:1095","RECREATE");
file->Write();
file->UploadAndReset(); // We do this early to get assigned an index.
UInt_t idx = file->fServerIdx; // This works on in ACLiC.
TH1 *hpx;
if (idx == 0) {
// Create the histogram
hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
hpx->SetFillColor(48); // set nice fillcolor
} else {
hpx = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
}
Float_t px, py;
TTree *tree = new TTree("tree","tree");
tree->SetAutoFlush(4000000);
tree->Branch("px",&px);
tree->Branch("py",&py);
// Fill histogram randomly
gRandom->SetSeed();
const int kUPDATE = 1000000;
for (int i = 0; i < 25000000; ) {
gRandom->Rannor(px,py);
if (idx%2 == 0)
hpx->Fill(px);
else
hpx->Fill(px,py);
tree->Fill();
++i;
if (i && (i%kUPDATE) == 0) {
file->Write();
}
}
file->Write();
delete file;
gBenchmark->Show("treeClient");
}
示例2: parallelMergeTest
void parallelMergeTest(UInt_t nhist, UInt_t ndims = 1, UInt_t nbins = 100)
{
gBenchmark->Start("parallelMergeTest");
TFile *file = TFile::Open("mergedClient.root?pmerge=localhost:1095","RECREATE");
Float_t px, py;
TTree *tree = 0;
switch (ndims) {
case 1: {
for(UInt_t h = 0 ; h < nhist; ++h) {
new TH1F(TString::Format("hpx%d",h),"This is the px distribution",nbins,-4,4);
}
break;
}
case 2: {
for(UInt_t h = 0 ; h < nhist; ++h) {
new TH2F(TString::Format("hpxy%d",h),"py vs px",nbins,-4,4,nbins,-4,-4);
}
break;
}
case 99: {
tree = new TTree("tree","tree");
tree->SetAutoFlush(4000000);
tree->Branch("px",&px);
tree->Branch("py",&py);
}
}
// Fill histogram randomly
gRandom->SetSeed();
const int kUPDATE = 1000000;
for (int i = 0; i < 25000000; ) {
// gRandom->Rannor(px,py);
// if (idx%2 == 0)
// hpx->Fill(px);
// else
// hpx->Fill(px,py);
if(tree) tree->Fill();
++i;
if (i && (i%kUPDATE) == 0) {
file->Write();
}
}
file->Write();
delete file;
gBenchmark->Show("parallelMergeTest");
}
示例3: applyenergy
void applyenergy() {
ROOT::Cintex::Cintex::Enable();
//printf("include: %s\n",gSystem->GetIncludePath());
//return;
Long64_t maxentries = -1;
//TFile *fmc = new TFile("/home/bendavid/cms/hist/hgg-v0-Sept1/local/filefi/merged/hgg-v0_s11-h120gg-gf-v11-pu_noskim.root","READ");
//TFile *fmc = new TFile("/scratch/bendavid/cms/hist/hgg-v0/merged/hgg-v0_f11--h121gg-gf-v14b-pu_noskim.root","READ");
TFile *fmc = new TFile("/scratch/bendavid/cms/hist/hgg-v0/merged/hgg-v0_f11-zjets-v14b-pu_noskim.root","READ");
//TFile *fmc = new TFile("/scratch/bendavid/cms/hist/hgg-v0/t2mit/filefi/025/f11--h121gg-gf-v14b-pu/hgg-v0_f11--h121gg-gf-v14b-pu_noskim_0000.root","READ");
TDirectory *dir = (TDirectory*)fmc->FindObjectAny("PhotonTreeWriterPresel");
TTree *hmcph = (TTree*)dir->Get("hPhotonTree");
TDirectory *dirsingle = (TDirectory*)fmc->FindObjectAny("PhotonTreeWriterSingle");
TTree *hmcsingleph = (TTree*)dirsingle->Get("hPhotonTree");
TFile *fmcele = new TFile("/scratch/bendavid/cms/hist/hgg-v0/merged/hgg-v0_f11-zjets-v14b-pu_noskim.root","READ");
TDirectory *direle = (TDirectory*)fmcele->FindObjectAny("PhotonTreeWriterE");
TTree *hmcele = (TTree*)direle->Get("hPhotonTree");
TDirectory *direlesingle = (TDirectory*)fmcele->FindObjectAny("PhotonTreeWriterE");
TTree *hmcelesingle = (TTree*)direlesingle->Get("hPhotonTreeSingle");
TFile *fdele = new TFile("/scratch/bendavid/cms/hist/hgg-v0/MergedDel2011J16.root","READ");
TDirectory *dirdele = (TDirectory*)fdele->FindObjectAny("PhotonTreeWriterE");
TTree *hdele = (TTree*)dirdele->Get("hPhotonTree");
TDirectory *dirdelesingle = (TDirectory*)fdele->FindObjectAny("PhotonTreeWriterE");
TTree *hdelesingle = (TTree*)dirdelesingle->Get("hPhotonTreeSingle");
TFile *fgbropt = new TFile("fgbrtraintest.root","READ");
const GBRForest *gbropt = (GBRForest*)fgbropt->Get("gbrtrain");
std::vector<std::string> *varlist = (std::vector<std::string>*)fgbropt->Get("varlist");
std::vector<std::string> *varlisteb = varlist;
std::vector<std::string> *varlistee = varlist;
const GBRForest *gbr = 0;
const GBRForest *gbreb = gbropt;
const GBRForest *gbree = gbropt;
UInt_t nvarseb = varlisteb->size();
UInt_t nvarsee = varlistee->size();
Float_t *vals = 0;
Float_t *valseb = new Float_t[nvarseb];
Float_t *valsee = new Float_t[nvarsee];
TFile *fmvacor = new TFile("fmvacor.root","RECREATE");
TTree *hmvacorph = new TTree("hmvacorph","");
TTree *hmvacorele = new TTree("hmvacorele","");
TTree *hmvacorelesingle = new TTree("hmvacorelesingle","");
TTree *hmvacordele = new TTree("hmvacordele","");
TTree *hmvacordelesingle = new TTree("hmvacordelesingle","");
TTree *hmvacorqcdsingle = new TTree("hmvacorqcdsingle","");
hmvacorele->SetAutoFlush(-1000000000);
hmvacorelesingle->SetAutoFlush(-1000000000);
hmvacordele->SetAutoFlush(-1000000000);
hmvacordelesingle->SetAutoFlush(-1000000000);
Float_t massmvacor=0.;
Float_t massmvacorerr=0.;
Float_t massmvacorerrlo=0.;
Float_t massmvacorerrhi=0.;
Float_t ph1emvacor=0.;
Float_t ph1emvacorerr=0.;
Float_t ph1emvacorerrlo=0.;
Float_t ph1emvacorerrhi=0.;
Float_t ph1bdt = 0.;
Float_t ph1bdtvar = 0.;
Int_t ph1dcoridx=0;
Float_t ph1emvadcor=0.;
Float_t ph2emvacor=0.;
Float_t ph2emvacorerr=0.;
Float_t ph2emvacorerrlo=0.;
Float_t ph2emvacorerrhi=0.;
Float_t ph2bdt = 0.;
Float_t ph2bdtvar = 0.;
Int_t ph2dcoridx=0;
Float_t ph2emvadcor=0.;
Float_t phemvacor=0.;
Float_t phemvacorerr=0.;
Float_t phbdt=0.;
//.........这里部分代码省略.........
示例4: treeClient
void treeClient(Bool_t evol=kFALSE)
{
// Client program which creates and fills 2 histograms and a TTree.
// Every 1000000 fills the histograms and TTree is send to the server which displays the histogram.
//
// To run this demo do the following:
// - Open at least 2 windows
// - Start ROOT in the first windows
// - Execute in the first window: .x fastMergeServer.C
// - Execute in the other windows: root.exe -b -l -q .x treeClient.C
// (You can put it in the background if wanted).
// If you want to run the hserv.C on a different host, just change
// "localhost" in the TSocket ctor below to the desired hostname.
//
//Author: Fons Rademakers, Philippe Canal
gBenchmark->Start("treeClient");
// Open connection to server
TSocket *sock = new TSocket("localhost", 9090);
if (!sock->IsValid()) {
Error("treeClient","Could not establish a connection with the server %s:%d.","localhost",9090);
return;
}
// Wait till we get the start message
// server tells us who we are
Int_t status, version, kind;
sock->Recv(status, kind);
if (kind != 0 /* kStartConnection */)
{
Error("treeClient","Unexpected server message: kind=%d status=%d\n",kind,status);
delete sock;
return;
}
sock->Recv(version, kind);
if (kind != 1 /* kStartConnection */)
{
Fatal("treeClient","Unexpected server message: kind=%d status=%d\n",kind,status);
} else {
Info("treeClient","Connected to fastMergeServer version %d\n",version);
}
int idx = status;
Float_t messlen = 0;
Float_t cmesslen = 0;
TMemFile *file = new TMemFile("mergedClient.root","RECREATE");
TH1 *hpx;
if (idx == 0) {
// Create the histogram
hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
hpx->SetFillColor(48); // set nice fillcolor
} else {
hpx = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
}
Float_t px, py;
TTree *tree = new TTree("tree","tree");
tree->SetAutoFlush(4000000);
tree->Branch("px",&px);
tree->Branch("py",&py);
TMessage::EnableSchemaEvolutionForAll(evol);
TMessage mess(kMESS_OBJECT);
// Fill histogram randomly
gRandom->SetSeed();
const int kUPDATE = 1000000;
for (int i = 0; i < 25000000; ) {
gRandom->Rannor(px,py);
if (idx%2 == 0)
hpx->Fill(px);
else
hpx->Fill(px,py);
tree->Fill();
++i;
if (i && (i%kUPDATE) == 0) {
file->Write();
mess.Reset(kMESS_ANY); // re-use TMessage object
mess.WriteInt(idx);
mess.WriteTString(file->GetName());
mess.WriteLong64(file->GetEND()); // 'mess << file->GetEND();' is broken in CINT for Long64_t
file->CopyTo(mess);
sock->Send(mess); // send message
messlen += mess.Length();
cmesslen += mess.CompLength();
file->ResetAfterMerge(0); // This resets only the TTree objects.
hpx->Reset();
}
}
sock->Send("Finished"); // tell server we are finished
if (cmesslen > 0)
printf("Average compression ratio: %g\n", messlen/cmesslen);
gBenchmark->Show("hclient");
// Close the socket
//.........这里部分代码省略.........