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
ja:root:wantto11 [GiriWiki]

ユーザ用ツール

サイト用ツール


ja:root:wantto11

TChainでループを回している時、参照しているイベントの属するTTreeが記録されたファイル名を知りたい


TChainを使ってイベント毎に処理をさせている時、当該イベントがどのファイルに属しているtreeに含まれているイベントなのかを知るのには、

  TChain *Chain = new TChain("...");
  const Long64_t nentry = Chain->GetEntries();
    for( Long64_t ientry = 0 ; ientry < nentry ; ++ientry ){
      Chain->GetEntry(ientry);
      .....
      TFile *CurrentFile = Chain->GetFile();
      Char_t *filename = CurrentFile->GetName();
      .....

のようにしてやればよい。

ややこしい版のやり方としては

TFile *CurrentFile = Chain->GetFile();
TUrl *url = CurrentFile->GetEndpointUrl()
Char_t *filename = url->GetFile()

というようなやり方でもできるよう。非推奨。

ja/root/wantto11.txt · 最終更新: 2018/08/22 17:27 by kota