本文整理汇总了C++中TStopwatch::Continue方法的典型用法代码示例。如果您正苦于以下问题:C++ TStopwatch::Continue方法的具体用法?C++ TStopwatch::Continue怎么用?C++ TStopwatch::Continue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStopwatch
的用法示例。
在下文中一共展示了TStopwatch::Continue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExamineMidasFile
void ExamineMidasFile(const char *filename) {
std::ifstream in(filename, std::ifstream::in | std::ifstream::binary);
if(!in.is_open()) {
printf("unable to open file %s\n",filename);
return;
}
in.seekg(0, std::ifstream::end);
long long filesize = in.tellg();
in.close();
TMidasFile mfile;
TMidasEvent mevent;
std::map<int,int> type_counter;
mfile.Open(filename);
long long starttime = 0;
long long stoptime = 0;
int currenteventnumber = 0;
long long bytesread = 0;
bool loop = true;
TStopwatch sw;
sw.Start();
while(loop) {
bytesread += mfile.Read(&mevent);
switch(mevent.GetEventId()) {
case 0x8000: //run start
printf( DGREEN );
mevent.Print();
printf( RESET_COLOR );
starttime = mevent.GetTimeStamp();
break;
case 0x8001: //run stop
printf( " \r");
printf( DRED );
mevent.Print();
printf( RESET_COLOR );
stoptime = mevent.GetTimeStamp();
loop = false;
break;
default:
type_counter[mevent.GetEventId()]++;
break;
}
if((++currenteventnumber%15000)== 0) {
printf( " Looping over event %i have looped %.2fMB/%.2f MB => %.1f MB/s " "\r",
currenteventnumber,(bytesread/1000000.0),(filesize/1000000.0),(bytesread/1000000.0)/sw.RealTime());
sw.Continue();
}
}
printf( " Looping over event %i have looped %.2fMB/%.2f MB => %.1f MB/s " "\r",
currenteventnumber,(bytesread/1000000.0),(filesize/1000000.0),(bytesread/1000000.0)/sw.RealTime());
printf("\n\n");
printf("EventTypes Seen: \n");
for(std::map<int,int>::iterator it=type_counter.begin(); it!=type_counter.end(); it++) {
printf("\tEventId[%i] = %i\n",it->first,it->second);
}
printf("\n");
printf("Run lenght = %i seconds\n",stoptime-starttime);
printf("\n");
return;
}
示例2: islostlep
//.........这里部分代码省略.........
TH1F* h_ldp_weight[209] ;
for ( int sbi=1; sbi<=208; sbi++ ) {
char hname[100] ;
sprintf( hname, "h_ldp_weight_bin%03d", sbi ) ;
h_ldp_weight[sbi] = new TH1F( hname, hname, 100, 0., 2. ) ;
}
Long64_t nentries = fChain->GetEntries();
printf("\n\n") ;
printf(" Looping over sample: %s\n", samplename ) ;
printf(" Number of entries: %lld\n\n", nentries ) ;
Long64_t loopmax = nentries ;
if ( nloop > 0 ) loopmax = nloop ;
Long64_t nbytes = 0, nb = 0;
TStopwatch sw ;
sw.Start() ;
int time(0) ;
float projected_remaining(999999.) ;
for (Long64_t jentry=0; jentry<loopmax;jentry++) {
Long64_t ievt = jentry ;
if ( ievt%1000 == 0 ) { // timer printing stuff
int thistime = sw.RealTime() ;
sw.Continue() ;
if ( thistime < 2 ) {
printf(" %10llu out of %10llu (%6.1f%%) \r", ievt, nentries, 100.*ievt/(1.*nentries) ) ;
} else {
if ( thistime > time ) projected_remaining = (1.*thistime)/(1.*ievt)*(nentries-ievt) ;
if ( projected_remaining < 100 ) {
printf(" %10llu out of %10llu (%6.1f%%) seconds remaining %4.0f \r", ievt, nentries, 100.*ievt/(1.*nentries), projected_remaining ) ;
} else if ( projected_remaining < 3600 ) {
printf(" %10llu out of %10llu (%6.1f%%) time remaining %2d:%02d \r", ievt, nentries, 100.*ievt/(1.*nentries),
TMath::Nint(projected_remaining)/60, TMath::Nint(projected_remaining)%60 ) ;
} else {
printf(" %10llu out of %10llu (%6.1f%%) time remaining %2d:%02d:%02d \r", ievt, nentries, 100.*ievt/(1.*nentries),
TMath::Nint(projected_remaining)/3600, (TMath::Nint(projected_remaining)%3600)/60, TMath::Nint(projected_remaining)%60 ) ;
}
}
fflush(stdout) ;
time = thistime ;
} // timer printing stuff
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
set_bi() ;
double hw = Weight * lumi_ ;
if ( islostlep && hasHadTau ) continue ;
if ( ishadtau && !hasHadTau ) continue ;
//-- take out the trash
示例3: trcls
void trcls(const char *fname, const char *oname, const char *tkdbc)
{
AMSChain ch;
TString sfn = fname;
if (!sfn.Contains(".root")) sfn += "*.root";
if (ch.Add(sfn) <= 0) return;
Int_t ntr = ch.GetNtrees();
Int_t nent = ch.GetEntries();
if (ntr <= 0 || nent <= 0) return;
cout << "Ntr,Nent= " << ntr << " " << nent << endl;
for (Int_t i = 0; i < ntr; i++)
cout << ch.GetListOfFiles()->At(i)->GetTitle() << endl;
Int_t idata[13];
Float_t fdata[28];
TFile of(oname, "recreate");
TTree *tree = new TTree("tree", "trcls");
tree->Branch("idata", idata, "run/I:event/I:ient/I:time/I:tkml[9]/I");
tree->Branch("fdata", fdata, "engc/F:enge/F:rgt/F:chrg/F:"
"p0x/F:p0y/F:dzx/F:dzy/F:csqx/F:csqy/F:"
"xcog[9]/F:ycog[9]/F");
if (tkdbc && tkdbc[0] && tkdbc[0] != '0') {
ch.GetEvent(0);
TkDBc::Head->init(3, tkdbc);
}
TrExtAlignDB::OverLoadFlag = 0;
Int_t malg = 2; // kAlcaraz | kMultScat
Int_t pat0 = 3; // Inner only
Int_t nevt = 0;
Int_t nrsl = 0;
Int_t npsl = 0;
Int_t nfil = 0;
Int_t intv = 10000;
signal(SIGTERM, handler);
signal(SIGINT, handler);
TStopwatch timer;
timer.Start();
for (Int_t ient = 0; ient < nent && !SigTERM; ient++) {
AMSEventR *evt = ch.GetEvent(ient);
nevt++;
if (nevt%intv == 0 || nevt == nent) {
Double_t tm = timer.RealTime();
timer.Continue();
cout << Form("%6d %6d %6d %7d (%5.1f%%) %4.0f sec (%4.1f kHz)",
nrsl, npsl, nfil, nevt,
100.*nevt/nent, tm, nevt/tm*1e-3)
<< endl;
}
if (evt->nTrRecHit() >= 1600) continue;
if (evt->nTrTrack () != 1) continue;
TrTrackR *trk = evt->pTrTrack(0);
if (!trk) continue;
Double_t chgp = TrCharge::GetQ(trk, 1);
Double_t chgn = TrCharge::GetQ(trk, 0);
if (chgp <= 0 || chgn <= 0) continue;
Int_t mfp = trk->iTrTrackPar(malg, pat0, 0);
if (mfp < 0) continue;
Double_t rgtp = trk->GetRigidity(mfp);
if (TMath::Abs(rgtp) < 5) continue;
//////////////////// Recalc and refit ////////////////////
trk->RecalcHitCoordinates();
Int_t mf0 = trk->iTrTrackPar(malg, pat0, 2);
if (mf0 < 0) continue;
Double_t rgt0 = trk->GetRigidity(mf0);
if (TMath::Abs(rgt0) < 10) continue;
nrsl++;
//////////////////// Pre-selection ////////////////////
Bool_t psel = kTRUE;
Int_t span = (TrTrackSelection::GetSpanFlags(trk) & 0xff);
if (!(span & TrTrackSelection::kMaxInt) ||
!(span & TrTrackSelection::kAllPlane)) psel = kFALSE;
if (!(span & TrTrackSelection::kHalfL1N)) {
if (!(span & TrTrackSelection::kHalfL9)) psel = kFALSE;
AMSPoint pnt = trk->InterpolateLayerJ(9);
if (TMath::Abs(pnt.x()) > 33) psel = kFALSE;
}
if (psel) npsl++;
//.........这里部分代码省略.........
示例4: ScanTree
//int ScanTree ( TTree* tree) {
int ScanTree ( TTree* tree, char *fileName) {
// This reads in the tree. As you might imagine.
Init(tree);
TFile *histFile = new TFile(fileName,"RECREATE");
TDirectory *histDir = histFile->mkdir("eff_hist");
TStopwatch timer;
timer.Start();
// Declare the usual constants
double pi = 3.141592653;
double ptCut = 5.0;
vector<int> *l1UsedBySim = new vector<int>;
vector<int> *l2UsedBySim = new vector<int>;
vector<int> *l3UsedBySim = new vector<int>;
histDir->cd();
// int nPtBins = 19;
// Double_t pt_Edges[20] = {0, 5, 7, 9, 11, 13, 15, 18, 21, 24, 27, 30, 34, 38, 42, 50, 60, 70, 80, 100};
// int nPtBins = 8;
// Double_t pt_Edges[9] = {0, 1, 2, 3, 4, 6, 8, 10, 20};
int nPtBins = 11;
Double_t pt_Edges[12] = {0, 3, 5, 7, 9, 11, 13, 15, 18, 21, 24, 30};
TH1F *l3OverXEtaEffNum = new TH1F("l3OverXEtaEffNum","l3 associated sim #eta",24,-2.4,2.4);
TH1F *l3OverXPtEffNum = new TH1F("l3OverXPtEffNum","l3 associated sim pt",nPtBins,pt_Edges);
TH2F *l3OverXPtEtaEffNum = new TH2F("l3OverXPtEtaEffNum","blah",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l2OverXEtaEffNum = new TH1F("l2OverXEtaEffNum","l2 associated sim #eta",24,-2.4,2.4);
TH1F *l2OverXPtEffNum = new TH1F("l2OverXPtEffNum","l2 associated sim pt",nPtBins,pt_Edges);
TH2F *l2OverXPtEtaEffNum = new TH2F("l2OverXPtEtaEffNum","blah",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l1OverXEtaEffNum = new TH1F("l1OverXEtaEffNum","l1 associated sim #eta",24,-2.4,2.4);
TH1F *l1OverXPtEffNum = new TH1F("l1OverXPtEffNum","l1 associated sim pt",nPtBins,pt_Edges);
TH2F *l1OverXPtEtaEffNum = new TH2F("l1OverXPtEtaEffNum","blah",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *lXOverSimEtaEffDenom = new TH1F("lXOverSimEtaEffDenom","sim #eta",24,-2.4,2.4);
TH1F *lXOverSimPtEffDenom = new TH1F("lXOverSimPtEffDenom","lX associated sim pt",nPtBins,pt_Edges);
TH2F *lXOverSimPtEtaEffDenom = new TH2F("lXOverSimPtEtaEffDenom","blah",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *lXOverL1EtaEffDenom = new TH1F("lXOverL1EtaEffDenom","l1 associated sim #eta",24,-2.4,2.4);
TH1F *lXOverL1PtEffDenom = new TH1F("lXOverL1PtEffDenom","lX associated sim pt",nPtBins,pt_Edges);
TH2F *lXOverL1PtEtaEffDenom = new TH2F("lXOverL1PtEtaEffDenom","blah",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *lXOverL2EtaEffDenom = new TH1F("lXOverL2EtaEffDenom","l2 associated sim #eta",24,-2.4,2.4);
TH1F *lXOverL2PtEffDenom = new TH1F("lXOverL2PtEffDenom","lX associated sim pt",nPtBins,pt_Edges);
TH2F *lXOverL2PtEtaEffDenom = new TH2F("lXOverL2PtEtaEffDenom","blah",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l3OverSimEtaEff = new TH1F("l3OverSimEtaEff","l3/sim eff vs. assoc. sim #eta",24,-2.4,2.4);
TH1F *l3OverSimPtEff = new TH1F("l3OverSimPtEff","l3/sim eff vs. assoc. sim pt",nPtBins,pt_Edges);
TH2F *l3OverSimPtEtaEff = new TH2F("l3OverSimPtEtaEff","l3/sim eff map: p_{T} vs #eta",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l3OverL1EtaEff = new TH1F("l3OverL1EtaEff","l3/l1 eff vs. assoc. sim #eta",24,-2.4,2.4);
TH1F *l3OverL1PtEff = new TH1F("l3OverL1PtEff","l3/l1 eff vs. assoc. sim pt",nPtBins,pt_Edges);
TH2F *l3OverL1PtEtaEff = new TH2F("l3OverL1PtEtaEff","l3/l1 eff map: p_{T} vs #eta",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l3OverL2EtaEff = new TH1F("l3OverL2EtaEff","l3/l2 eff vs. assoc. sim #eta",24,-2.4,2.4);
TH1F *l3OverL2PtEff = new TH1F("l3OverL2PtEff","l3/l2 eff vs. assoc. sim pt",nPtBins,pt_Edges);
TH2F *l3OverL2PtEtaEff = new TH2F("l3OverL2PtEtaEff","l3/l2 eff map: p_{T} vs #eta",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l2OverSimEtaEff = new TH1F("l2OverSimEtaEff","l2/sim eff vs. assoc. sim #eta",24,-2.4,2.4);
TH1F *l2OverSimPtEff = new TH1F("l2OverSimPtEff","l2/sim eff vs. assoc. sim pt",nPtBins,pt_Edges);
TH2F *l2OverSimPtEtaEff = new TH2F("l2OverSimPtEtaEff","l2/sim eff map: p_{T} vs #eta",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l2OverL1EtaEff = new TH1F("l2OverL1EtaEff","l2/l1 eff vs. assoc. sim #eta",24,-2.4,2.4);
TH1F *l2OverL1PtEff = new TH1F("l2OverL1PtEff","l2/l1 eff vs. assoc. sim pt",nPtBins,pt_Edges);
TH2F *l2OverL1PtEtaEff = new TH2F("l2OverL1PtEtaEff","l2/l1 eff map: p_{T} vs #eta",nPtBins,pt_Edges,24,-2.4,2.4);
TH1F *l1OverSimEtaEff = new TH1F("l1OverSimEtaEff","l1/sim eff vs. assoc. sim #eta",24,-2.4,2.4);
TH1F *l1OverSimPtEff = new TH1F("l1OverSimPtEff","l1/sim eff vs. assoc. sim pt",nPtBins,pt_Edges);
TH2F *l1OverSimPtEtaEff = new TH2F("l1OverSimPtEtaEff","l1/sim eff map: p_{T} vs #eta",nPtBins,pt_Edges,24,-2.4,2.4);
int nEntries = tree->GetEntries();
//Event Loop
for( int iEntry = 0; iEntry < nEntries; iEntry++) {
if (iEntry%1000 == 0) cout << "Event " << iEntry << " time " << timer.RealTime() << " cpu " << timer.CpuTime() << endl;
timer.Continue();
tree->GetEntry(iEntry);
double max_simPt = -999;
try {
// cout << "trying passL1" << endl;
bool passL1 = false;
for (int iL1 = 0; iL1 < nL1; iL1++) {
if ((*l1Pt).at(iL1) + 0.01 > 7 && (*l1Quality).at(iL1) >= 4) {
passL1 = true;
}
}
// cout << "trying passL2" << endl;
bool passL2 = false;
for (int iL2 = 0; iL2 < nL2; iL2++) {
if (passL1) {
if ((*l2Pt).at(iL2) > 7 && (*l2Eta).at(iL2) > -2.5 && (*l2Eta).at(iL2) < 2.5) {
passL2 = true;
//.........这里部分代码省略.........