本文整理汇总了C++中TStopwatch::RealTime方法的典型用法代码示例。如果您正苦于以下问题:C++ TStopwatch::RealTime方法的具体用法?C++ TStopwatch::RealTime怎么用?C++ TStopwatch::RealTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStopwatch
的用法示例。
在下文中一共展示了TStopwatch::RealTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void run(int nEvents = 100000) {
TChain* fChain = new TChain("T");
ifstream sourceFiles("input.txt");
char line[128];
int count = 0;
while (sourceFiles >> line) {
fChain->Add(line);
++count;
}
cout << count << " files added!" << endl;
sourceFiles.close();
TStopwatch timer;
timer.Start();
fChain->Process("adcAnalyzer.C+", "", 8*nEvents, 0);
timer.Stop();
cout << "\n\nDone!" << endl;
cout << "CPU Time : " << timer.CpuTime() << " s (total), " << timer.CpuTime()/nEvents << " s (per event)" << endl;
cout << "RealTime : " << timer.RealTime() << " s (total), " << timer.RealTime()/nEvents << " s (per event)" << endl;
cout << "\n";
}
示例2: read_tree
Float_t read_tree(const char *filename = "data.root", Double_t bytes = 10000000)
{
printf("Reading events from a root tree \n");
TFile *filein = new TFile(filename,"READ");
if ( filein->IsZombie() ) {
printf("Cannot open file \n");
return 0.0;
}
Int_t nbgamma; Int_t e[1000]; // up to 1000 energies ..should be ok
TTree *treein;
treein = (TTree *)filein->Get("TEST");
if ( treein == NULL ) return 0;
else {
treein->SetBranchAddress("mult",&nbgamma);
treein->SetBranchAddress("e",&e);
}
// write events and compute the needed time
TStopwatch watch;
watch.Start();
treein->Draw("e","","goff");
watch.Stop();
cout << " --> Reading rate " << bytes / (1024*1024*watch.RealTime()) << " MB/s"<< endl ;
filein->Close(); delete filein; return bytes / (1024*1024*watch.RealTime()) ;
}
示例3: Run
bool TTimeHists::Run()
{
// run all tests with current settings, and check for identity of content.
Double_t check[2];
Long64_t rep[2];
for (int h = 0; h < 2; ++h) {
rep[h] = 0;
SetupValues();
try {
TStopwatch w;
w.Start();
SetupHist((EHist) h);
w.Stop();
do {
w.Start(kFALSE);
Fill((EHist) h);
check[h] = Check((EHist) h);
w.Stop();
++rep[h];
} while ((!h && w.RealTime() < 0.1)
|| (h && rep[0] > 0 && rep[1] < rep[0]));
fTime[h][0] = (1.* fNum * rep[h]) / w.RealTime() / 1E6;
fTime[h][1] = (1.* fNum * rep[h]) / w.CpuTime() / 1E6;
if (h == 1 && (fTime[h][0] > 1E20 || fTime[h][1] > 1E20)) {
do {
// some more cycles:
w.Start(kFALSE);
Fill((EHist) h);
Check((EHist) h);
w.Stop();
++rep[h];
} while (w.RealTime() < 0.1);
fTime[h][0] = (1.* fNum * rep[h]) / w.RealTime() / 1E6;
fTime[h][1] = (1.* fNum * rep[h]) / w.CpuTime() / 1E6;
}
if (fTime[h][0] > 1E20) fTime[h][0] = 1E20;
if (fTime[h][1] > 1E20) fTime[h][1] = 1E20;
}
catch (std::exception&) {
fTime[h][0] = fTime[h][1] = -1.;
check[h] = -1.; // can never be < 1 without exception
rep[h] = -1;
}
}
if (check[0] != check[1])
if (check[0] != -1.)
printf("ERROR: mismatch of histogram (%g) and sparse histogram (%g) for dim=%d, bins=%d!\n",
check[0], check[1], fDim, fBins);
// else
// printf("ERROR: cannot allocate histogram for dim=%d, bins=%d - out of memory!\n",
// fDim, fBins);
return (check[0] == check[1]);
}
示例4: read
void read() {
TRandom R;
TStopwatch timer;
TFile f1("mathcoreVectorIO_1.root");
// create tree
TTree *t1 = (TTree*)f1.Get("t1");
XYZTVector *v1 = 0;
t1->SetBranchAddress("LV branch",&v1);
timer.Start();
int n = (int) t1->GetEntries();
std::cout << " Tree Entries " << n << std::endl;
double etot=0;
for (int i = 0; i < n; ++i) {
t1->GetEntry(i);
etot += v1->Px();
etot += v1->Py();
etot += v1->Pz();
etot += v1->E();
}
timer.Stop();
std::cout << " Time for new Vector " << timer.RealTime() << " " << timer.CpuTime() << std::endl;
std::cout << " TOT average : n = " << n << "\t " << etot/double(n) << endl;
// create tree with old LV
TFile f2("mathcoreVectorIO_2.root");
TTree *t2 = (TTree*)f2.Get("t2");
TLorentzVector * v2 = 0;
t2->SetBranchAddress("TLV branch",&v2);
timer.Start();
n = (int) t2->GetEntries();
std::cout << " Tree Entries " << n << std::endl;
etot = 0;
for (int i = 0; i < n; ++i) {
t2->GetEntry(i);
etot += v2->Px();
etot += v2->Py();
etot += v2->Pz();
etot += v2->E();
}
timer.Stop();
std::cout << " Time for old Vector " << timer.RealTime() << " " << timer.CpuTime() << endl;
std::cout << " TOT average:\t" << etot/double(n) << endl;
}
示例5: MCMonitoring
void MCMonitoring(
const UInt_t num_events,
const TString base_name,
const TString base_path = "."
)
{
TStopwatch timer;
timer.Start();
const TString sim_file = base_path + "/r3bsim." + base_name + ".root";
const TString par_file = base_path + "/r3bpar." + base_name + ".root";
const TString out_file = base_path + "/mcmon." + base_name + ".root";
FairRunAna* run = new FairRunAna();
run->SetInputFile(sim_file);
run->SetOutputFile(out_file);
ConnectParFileToRuntimeDb(par_file, run->GetRuntimeDb());
run->AddTask(new R3BNeulandMCMon());
run->Init();
run->Run(0, num_events);
timer.Stop();
cout << endl;
cout << "Macro finished succesfully!" << endl;
cout << "Output file writen: " << out_file << endl;
cout << "Parameter file writen: " << par_file << endl;
cout << "Real time: " << timer.RealTime() << "s, CPU time: " << timer.CpuTime() << "s" << endl;
cout << endl;
}
示例6: read
void read() {
TRandom R;
TStopwatch timer;
TFile f1("mathcoreVectorIO_F.root");
// create tree
TTree *t1 = (TTree*)f1.Get("t1");
XYZTVectorF *v1 = 0;
t1->SetBranchAddress("LV branch",&v1);
timer.Start();
int n = (int) t1->GetEntries();
std::cout << " Tree Entries " << n << std::endl;
double etot=0;
for (int i = 0; i < n; ++i) {
t1->GetEntry(i);
etot += v1->E();
}
timer.Stop();
std::cout << " Time for new Float Vector " << timer.RealTime() << " " << timer.CpuTime() << std::endl;
std::cout << " E average" << n<< " " << etot << " " << etot/double(n) << endl;
}
示例7: ana_Main_MC_arg_winscan
void ana_Main_MC_arg_winscan(string which_MC_to_use, string MCFileLocation) {
gSystem->Load("libSusyEvent.so");
// Look ../jec/JetMETObjects/README
gSystem->Load("../jec/lib/libJetMETObjects.so");
// Printing utility for ntuple variables
gROOT->LoadMacro("SusyEventPrinter.cc+");
// Main analysis code
gROOT->LoadMacro("SusyMainAna_MC_arg_windowscan.cc+");
// chain of inputs
TChain* chain = new TChain("susyTree");
//////////////// MC files /////////////////
//MCpoint* thisMCpoint = setupMCpoint(which_MC_to_use);
chain->Add(MCFileLocation.data());
//chain->Add(thisMCpoint->filepath.c_str());
//chain->Add("../susyEvents_AB_1M_ho200_v2.root");
//chain->Add("../susyEvents_newNatural.root"); //last used!!
//chain->Add("/eos/uscms/store/user/abarker/MC/newNat350_225/MC_AB_2500k_NEWnaturalHiggsinoNLSPout_mst_350_M3_5025_mu_225.root");//same thing as ../susyEvents_newNatural.root
//chain->Add("/eos/uscms/store/user/abarker/MC/st_250_ho_150/MC_AB_2500k_st_250_ho_150.root");
//chain->Add("/eos/uscms/store/user/abarker/MC/st_250_ho_200/MC_AB_2500k_st_250_ho_200.root");
//chain->Add("/eos/uscms/store/user/abarker/MC/st_350_ho_200/MC_AB_2500k_mst_350_mu_200.root");
//chain->Add("/eos/uscms/store/user/abarker/MC/ho_140/MC_AB_2500k_ho_140.root");
//chain->Add("/eos/uscms/store/user/abarker/MC/ho_200/MC_AB_2500k_ho_200.root");
//chain->Add("../susyEvents_newNatural.root");
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_NEWnaturalHiggsinoNLSPout_mst_350_M3_5025_mu_225.root");
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_st_250_ho_150.root");
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_st_250_ho_200.root");
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_mst_350_mu_200.root");
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_ho_140.root");
//chain->Add("dcache:/pnfs/cms/WAX/resilient/abarker/MC/MC_AB_2500k_ho_200.root");
SusyMainAna_MC_arg_windowscan* sea = new SusyMainAna_MC_arg_windowscan(chain);
// configuration parameters
// any values given here will replace the default values
sea->SetDataset("ttbar_relval"); // dataset name
sea->SetPrintInterval(1e4); // print frequency
sea->SetPrintLevel(0); // print level for event contents
sea->SetUseTrigger(false);
sea->SetFilter(false); // filter events passing final cuts
sea->SetProcessNEvents(-1); // number of events to be processed
TStopwatch ts;
ts.Start();
sea->Loop(which_MC_to_use);
ts.Stop();
std::cout << "RealTime : " << ts.RealTime()/60.0 << " minutes" << std::endl;
std::cout << "CPUTime : " << ts.CpuTime()/60.0 << " minutes" << std::endl;
}
示例8: write_tree
Float_t write_tree(const char *filename = "data.root", Int_t nbevents = 10000000, Int_t compression = 0)
{
printf("Writing %d events in a root tree with compression level %d \n",nbevents,compression);
TFile *fileout = new TFile(filename,"recreate");
if ( fileout->IsZombie() ) {
printf("Cannot open file \n");
return 0.0;
}
fileout->SetCompressionLevel(compression);
Double_t wbytes = 0.0;
Int_t nbgamma; Int_t e[1000];
for (Int_t i = 1; i < 1000; i++) e[i] = 200*i;
TTree *treeout;
treeout = new TTree("TEST","TEST");
treeout->Branch("mult",&nbgamma,"nbgamma/I"); treeout->Branch("e",e,"e[nbgamma]/I");
// write events and compute the needed time
TStopwatch watch;
watch.Start();
for (int i = 0; i < nbevents; i++ ) {
nbgamma = 2 + i % 5; wbytes += 4.0; wbytes += nbgamma * 4.0;
treeout->Fill();
}
watch.Stop();
printf(" --> Writing rate %f MB/s [%f] \n",wbytes/(1024*1024*watch.RealTime()),wbytes/(1024*1024));
fileout->Close(); delete fileout;
return wbytes;
}
示例9: write
void write(int n) {
TRandom R;
TStopwatch timer;
TFile f1("mathcoreVectorIO_F.root","RECREATE");
// create tree
TTree t1("t1","Tree with new Float LorentzVector");
XYZTVectorF *v1 = new XYZTVectorF();
t1.Branch("LV branch","ROOT::Math::XYZTVectorF",&v1);
timer.Start();
for (int i = 0; i < n; ++i) {
double Px = R.Gaus(0,10);
double Py = R.Gaus(0,10);
double Pz = R.Gaus(0,10);
double E = R.Gaus(100,10);
v1->SetCoordinates(Px,Py,Pz,E);
t1.Fill();
}
f1.Write();
timer.Stop();
std::cout << " Time for new Float Vector " << timer.RealTime() << " " << timer.CpuTime() << std::endl;
t1.Print();
}
示例10: seism
void seism() {
TStopwatch sw; sw.Start();
//set time offset
TDatime dtime;
gStyle->SetTimeOffset(dtime.Convert());
TCanvas *c1 = new TCanvas("c1","Time on axis",10,10,1000,500);
c1->SetFillColor(42);
c1->SetFrameFillColor(33);
c1->SetGrid();
Float_t bintime = 1; //one bin = 1 second. change it to set the time scale
TH1F *ht = new TH1F("ht","The ROOT seism",10,0,10*bintime);
Float_t signal = 1000;
ht->SetMaximum( signal);
ht->SetMinimum(-signal);
ht->SetStats(0);
ht->SetLineColor(2);
ht->GetXaxis()->SetTimeDisplay(1);
ht->GetYaxis()->SetNdivisions(520);
ht->Draw();
for (Int_t i=1;i<2300;i++) {
//======= Build a signal : noisy damped sine ======
Float_t noise = gRandom->Gaus(0,120);
if (i > 700) noise += signal*sin((i-700.)*6.28/30)*exp((700.-i)/300.);
ht->SetBinContent(i,noise);
c1->Modified();
c1->Update();
gSystem->ProcessEvents(); //canvas can be edited during the loop
}
printf("Real Time = %8.3fs, Cpu Time = %8.3fs\n",sw.RealTime(),sw.CpuTime());
}
示例11: run
void run(TString runNumber)
{
TStopwatch timer;
timer.Start();
TString dirIn1 = "/Volumes/Data/kresan/s438/data/";
TString dirIn2 = "/Volumes/Data/kresan/s438/tcal/";
TString dirOut = "/Volumes/Data/kresan/s438/digi/";
TString tdiffParName = "tdiff_" + runNumber + ".dat";
TString inputFileName1 = dirIn2 + runNumber + "_tcal.root"; // name of input file
TString parFileName = dirIn1 + "params_" + runNumber + "_raw.root"; // name of parameter file
TString outputFileName = dirOut + runNumber + "_digi.root"; // name of output file
// Create analysis run -------------------------------------------------------
FairRunAna* run = new FairRunAna();
run->SetInputFile(inputFileName1.Data());
run->SetOutputFile(outputFileName.Data());
// ---------------------------------------------------------------------------
// ----- Runtime DataBase info -----------------------------------------------
FairRuntimeDb* rtdb = run->GetRuntimeDb();
FairParRootFileIo* parIo1 = new FairParRootFileIo();
parIo1->open(parFileName);
rtdb->setFirstInput(parIo1);
rtdb->setOutput(parIo1);
rtdb->saveOutput();
// ---------------------------------------------------------------------------
// Tdiff calibration ---------------------------------------------------------
R3BLandTdiff* landTdiff = new R3BLandTdiff("LandTdiff", 1);
landTdiff->SetTdiffParName(tdiffParName.Data());
run->AddTask(landTdiff);
// ---------------------------------------------------------------------------
// Analysis ------------------------------------------------------------------
R3BLandAna* landAna = new R3BLandAna("LandAna", 1);
landAna->SetNofBars(100);
run->AddTask(landAna);
// ---------------------------------------------------------------------------
// Initialize ----------------------------------------------------------------
run->Init();
FairLogger::GetLogger()->SetLogScreenLevel("INFO");
// ---------------------------------------------------------------------------
// Run -----------------------------------------------------------------------
run->Run();
// ---------------------------------------------------------------------------
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
cout << endl << endl;
cout << "Macro finished succesfully." << endl;
cout << "Output file is " << outputFileName << endl;
cout << "Parameter file is " << parFileName << endl;
cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl << endl;
}
示例12: testIntegPerf
void testIntegPerf(double x1, double x2, int n = 100000){
std::cout << "\n\n***************************************************************\n";
std::cout << "Test integration performances in interval [ " << x1 << " , " << x2 << " ]\n\n";
TStopwatch timer;
double dx = (x2-x1)/double(n);
//ROOT::Math::Functor1D<ROOT::Math::IGenFunction> f1(& TMath::BreitWigner);
ROOT::Math::WrappedFunction<> f1(func);
timer.Start();
ROOT::Math::Integrator ig(f1 );
double s1 = 0.0;
nc = 0;
for (int i = 0; i < n; ++i) {
double x = x1 + dx*i;
s1+= ig.Integral(x1,x);
}
timer.Stop();
std::cout << "Time using ROOT::Math::Integrator :\t" << timer.RealTime() << std::endl;
std::cout << "Number of function calls = " << nc/n << std::endl;
int pr = std::cout.precision(18); std::cout << s1 << std::endl; std::cout.precision(pr);
//TF1 *fBW = new TF1("fBW","TMath::BreitWigner(x)",x1, x2); // this is faster but cannot measure number of function calls
TF1 *fBW = new TF1("fBW",func2,x1, x2,0);
timer.Start();
nc = 0;
double s2 = 0;
for (int i = 0; i < n; ++i) {
double x = x1 + dx*i;
s2+= fBW->Integral(x1,x );
}
timer.Stop();
std::cout << "Time using TF1::Integral :\t\t\t" << timer.RealTime() << std::endl;
std::cout << "Number of function calls = " << nc/n << std::endl;
pr = std::cout.precision(18); std::cout << s1 << std::endl; std::cout.precision(pr);
}
示例13: dmesondecaylength
void dmesondecaylength()
{
//gStyle->SetOptStat("nemruoi");
gStyle->SetTitleSize(.04,"S");
gStyle->SetOptTitle(1);
gStyle->SetTitleOffset(1.0,"X");
gStyle->SetTitleOffset(.88,"Y");
gStyle->SetTitleSize(.04,"X");
gStyle->SetTitleSize(.04,"Y");
gStyle->SetLabelSize(.035,"X");
gStyle->SetLabelSize(.035,"Y");
gStyle->SetHistLineWidth(2);
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
// ----- Timer --------------------------------------------------------
TStopwatch timer;
timer.Start();
// ------------------------------------------------------------------------
double c= 3* std::pow(10.,8.);
double mt= 1040*std::pow(10.,-15.); // mean decay time
double mass= 1.869; // rest mass in GeV/c^2
//TCanvas* can = new TCanvas("can","Radiation Length for start detector",0,0,100,100);
TCanvas *c1 = new TCanvas("c1", "c1",0,52,1191,692);
TH1D* h = new TH1D("hist","D-meson, D-meson decay length",24,0,24);
h->SetTitle("D^{+} meson decay length = c#tau#sqrt{(#gamma_{D^{+}}^{2}-1)};Momentum (GeV/c); Decay length (mm)");
Int_t ci; // for color index setting
ci = TColor::GetColor("#000099");
for (int p=1; p<=24; p++)
{
double E = p*p + mass*mass;
E= std:: sqrt(E);
double gamma = E/mass;
double decaylength = c* std::sqrt(gamma*gamma -1)*mt*1000;
std:: cout<<" Decay length=" <<decaylength<<std::endl;
h->SetLineColor(ci);
h->GetXaxis()->CenterTitle(true);
h->GetYaxis()->CenterTitle(true);
h->SetMarkerColor(2);
h->SetMarkerStyle(20);
h->SetBinContent(p,decaylength);
h->Draw("E2-text");
}
// ----- Finish -------------------------------------------------------
timer.Stop();
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
cout << endl << endl;
cout << "Macro finished succesfully." << endl;
cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
cout << endl;
// ------------------------------------------------------------------------
}
示例14: run
void run(Long64_t nEntries = 1e4, string args = "TEST muon 2012")
{
string libMake = gSystem->GetMakeSharedLib();
const string delWarn("-Wshadow");
int pos1 = libMake.find(delWarn);
libMake= libMake.substr(0, pos1) + libMake.substr(pos1+delWarn.size()+1);
gSystem->SetMakeSharedLib(libMake.c_str());
//container classes
gROOT->LoadMacro("../src/TCPhysObject.cc+");
gROOT->LoadMacro("../src/TCTrack.cc+");
gROOT->LoadMacro("../src/TCEGamma.cc+");
gROOT->LoadMacro("../src/TCJet.cc+");
gROOT->LoadMacro("../src/TCMET.cc+");
gROOT->LoadMacro("../src/TCElectron.cc+");
gROOT->LoadMacro("../src/TCMuon.cc+");
gROOT->LoadMacro("../src/TCTau.cc+");
gROOT->LoadMacro("../src/TCPhoton.cc+");
gROOT->LoadMacro("../src/TCGenJet.cc+");
gROOT->LoadMacro("../src/TCGenParticle.cc+");
gROOT->LoadMacro("../src/TCPrimaryVtx.cc+");
gROOT->LoadMacro("../src/TCTriggerObject.cc+");
//analysis plugins (selectors, utiltities, etc.)
gROOT->LoadMacro("../plugins/HistManager.cc+");
gROOT->LoadMacro("../plugins/EGammaMvaEleEstimator.cc+");
gROOT->LoadMacro("../plugins/rochcor2012jan22.C+");
gROOT->LoadMacro("../plugins/WeightUtils.cc+");
gROOT->LoadMacro("../plugins/TriggerSelector.cc+");
gROOT->LoadMacro("../plugins/Selector.cc+");
TChain* fChain = new TChain("ntupleProducer/eventTree");
ifstream sourceFiles("input.txt");
char line[2048];
int count = 0;
while (sourceFiles >> line) {
fChain->Add(line);
++count;
}
cout << count << " files added!"<<endl;
sourceFiles.close();
TStopwatch timer;
timer.Start();
fChain->Process("fcncAnalyzer.C+", args.c_str(), nEntries, 0);
cout << "\n\nDone!" << endl;
cout << "CPU Time : " << timer.CpuTime() << endl;
cout << "RealTime : " << timer.RealTime() << endl;
cout << "\n";
}
示例15: write
double write(int n) {
TRandom R;
TStopwatch timer;
TFile f1("mathcoreLV.root","RECREATE");
// create tree
TTree t1("t1","Tree with new LorentzVector");
std::vector<ROOT::Math::XYZTVector> tracks;
std::vector<ROOT::Math::XYZTVector> * pTracks = &tracks;
t1.Branch("tracks","std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >",&pTracks);
double M = 0.13957; // set pi+ mass
timer.Start();
double sum = 0;
for (int i = 0; i < n; ++i) {
int nPart = R.Poisson(5);
pTracks->clear();
pTracks->reserve(nPart);
for (int j = 0; j < nPart; ++j) {
double px = R.Gaus(0,10);
double py = R.Gaus(0,10);
double pt = sqrt(px*px +py*py);
double eta = R.Uniform(-3,3);
double phi = R.Uniform(0.0 , 2*TMath::Pi() );
RhoEtaPhiVector vcyl( pt, eta, phi);
// set energy
double E = sqrt( vcyl.R()*vcyl.R() + M*M);
XYZTVector q( vcyl.X(), vcyl.Y(), vcyl.Z(), E);
// fill track vector
pTracks->push_back(q);
// evaluate sum of components to check
sum += q.x()+q.y()+q.z()+q.t();
}
t1.Fill();
}
f1.Write();
timer.Stop();
std::cout << " Time for new Vector " << timer.RealTime() << " " << timer.CpuTime() << std::endl;
t1.Print();
return sum;
}