Deprecated: Array and string offset access syntax with curly braces is deprecated in /mnt/hep_web/hep_web/member/n-kota/dokuwiki/inc/init.php on line 542
===== イベントループの進行状況を表示させたい =====
Tree から1イベントずつ取ってきて処理するような解析をよくやるが、その時にイベントループの進行状況を表示させたい。
const Long64_t nentry = tree->GetEntries(); // Loopさせるイベント数を取得
const Long64_t n_100 = nentry/100; // イベント数÷100 を定義しておく
cout << "# events : " << nentry << endl;
for( Long64_t ientry = 0 ; ientry < nentry ; ++ientry ){
if( nentry>100 ){
if( (ientry%n_100==0) && (ientry!=0) ){
if( ientry % (n_100 * 10) == 0 )
std::cerr << (ientry / n_100) << "% processed. " << std::endl; // 10%毎に表示、改行。
else if( ientry / n_100 < 10 )
std::cerr << " " << (ientry / n_100) << "% " << std::flush; // 1%毎に表示。改行なし。1桁数(1〜9)の前に空白。
else
std::cerr << (ientry / n_100) << "% " << std::flush; // 1%毎に表示。改行なし。
}
}
tree->GetEntry(ientry);
...
coutじゃなくてcerrを使うと良いとかどうとか。。。