12 #include "TIterator.h" 25 TFile *hdl = TFile::Open(fname.c_str(),
"read");
28 std::cout <<
"ERR Could not open file " << fname.c_str() << std::endl;
37 TList *keylist = hdl->GetListOfKeys();
38 TIterator *iter = keylist->MakeIterator();
40 while ((key = (TKey*)iter->Next())) {
41 TObject *
obj = hdl->Get(key->GetName());
51 TTree *
tree = (TTree*)hdl->Get(trname.c_str());
53 return tree->GetEntries();
55 std::cout <<
"ERR cannot find a TTree named \"" << trname <<
"\"" 62 void addBranchSizes(TBranch *
branch, Long64_t&
size) {
63 size += branch->GetTotalSize();
65 Long64_t nB = branch->GetListOfBranches()->GetEntries();
66 for (Long64_t
i = 0;
i < nB; ++
i) {
67 TBranch *btemp = (TBranch *)branch->GetListOfBranches()->At(
i);
68 addBranchSizes(btemp, size);
75 Long64_t nB = tree->GetListOfBranches()->GetEntries();
76 for (Long64_t
i = 0;
i < nB; ++
i) {
78 TBranch *btemp = (TBranch *)tree->GetListOfBranches()->At(
i);
79 addBranchSizes(btemp, size);
80 std::cout <<
"Branch " <<
i <<
" of " << tree->GetName() <<
" tree: " << btemp->GetName() <<
" Total size = " << size << std::endl;
89 Long64_t nB = tr->GetListOfBranches()->GetEntries();
90 for (Long64_t
i = 0;
i < nB; ++
i) {
91 tr->GetListOfBranches()->At(
i)->Print();
102 uuidTree->GetEntry(0);
110 uuidTree->GetEntry(0);
120 fndx->SetAddress(&findexPtr);
123 std::cout <<
"FileIndex not found. If this input file was created with release 1_8_0 or later\n" 124 "this indicates a problem with the file. This condition should be expected with\n" 125 "files created with earlier releases and printout of the event list will fail.\n";
131 std::cout <<
"\nFileFormatVersion = " << fileFormatVersion <<
". ";
132 if (fileFormatVersion.fastCopyPossible())
std::cout <<
"This version supports fast copy\n";
133 else std::cout <<
"This version does not support fast copy\n";
135 if (fileIndex.allEventsInEntryOrder()) {
136 std::cout <<
"Events are sorted such that fast copy is possible in the \"noEventSort = False\" mode\n";
138 std::cout <<
"Events are sorted such that fast copy is NOT possible in the \"noEventSort = False\" mode\n";
141 fileIndex.sortBy_Run_Lumi_EventEntry();
142 if (fileIndex.allEventsInEntryOrder()) {
143 std::cout <<
"Events are sorted such that fast copy is possible in the \"noEventSort\" mode\n";
145 std::cout <<
"Events are sorted such that fast copy is NOT possible in the \"noEventSort\" mode\n";
147 std::cout <<
"(Note that other factors can prevent fast copy from occurring)\n\n";
155 fndx->SetAddress(&findexPtr);
158 std::cout <<
"IndexIntoFile not found. If this input file was created with release 1_8_0 or later\n" 159 "this indicates a problem with the file. This condition should be expected with\n" 160 "files created with earlier releases and printout of the event list will fail.\n";
165 TBranch* eventAuxBranch = 0;
166 assert(0 != eventsTree);
167 char const*
const kEventAuxiliaryBranchName =
"EventAuxiliary";
168 if(eventsTree->FindBranch(kEventAuxiliaryBranchName) != 0){
169 eventAuxBranch = eventsTree->GetBranch(kEventAuxiliaryBranchName);
171 std::cout <<
"Failed to find " << kEventAuxiliaryBranchName <<
" branch in Events TTree. Something is wrong with this file." << std::endl;
176 eventAuxBranch->SetAddress(&eAPtr);
177 std::cout <<
"\nPrinting IndexIntoFile contents. This includes a list of all Runs, LuminosityBlocks\n" 178 <<
"and Events stored in the root file.\n\n";
180 << std::setw(15) <<
"Lumi" 181 << std::setw(15) <<
"Event" 182 << std::setw(15) <<
"TTree Entry" 189 std::cout << std::setw(15) << it.run() << std::setw(15) << it.lumi();
200 eventAuxBranch->GetEntry(it.entry());
201 eventNum = eventAuxiliary.
id().
event();
206 std::cout << std::setw(15) << eventNum << std::setw(15) << it.entry() <<
" " << type << std::endl;
209 std::cout <<
"\nFileFormatVersion = " << fileFormatVersion <<
". ";
210 if (fileFormatVersion.fastCopyPossible())
std::cout <<
"This version supports fast copy\n";
211 else std::cout <<
"This version does not support fast copy\n";
214 std::cout <<
"Events are sorted such that fast copy is possible in the \"noEventSort = false\" mode\n";
216 std::cout <<
"Events are sorted such that fast copy is NOT possible in the \"noEventSort = false\" mode\n";
226 std::cout <<
"(Note that other factors can prevent fast copy from occurring)\n\n";
231 assert(0 != metaDataTree);
237 fft->SetAddress(&fftPtr);
252 fndx->SetAddress(&findexPtr);
255 std::cout <<
"FileIndex not found. If this input file was created with release 1_8_0 or later\n" 256 "this indicates a problem with the file. This condition should be expected with\n" 257 "files created with earlier releases and printout of the event list will fail.\n";
261 std::cout <<
"\n"<< std::setw(15) <<
"Run" 262 << std::setw(15) <<
"Lumi" 263 << std::setw(15) <<
"# Events" 266 unsigned long runID = 0;
267 unsigned long lumiID = 0;
268 for(std::vector<FileIndex::Element>::const_iterator it = fileIndex.
begin(), itEnd = fileIndex.
end(); it != itEnd; ++it) {
273 if(runID !=it->run_ || lumiID !=it->lumi_) {
277 << std::setw(15) << lumiID
278 << std::setw(15) << nEvents<<
"\n";
289 << std::setw(15) << lumiID
290 << std::setw(15) << nEvents<<
"\n";
301 fndx->SetAddress(&findexPtr);
304 std::cout <<
"IndexIntoFile not found. If this input file was created with release 1_8_0 or later\n" 305 "this indicates a problem with the file. This condition should be expected with\n" 306 "files created with earlier releases and printout of the event list will fail.\n";
309 std::cout <<
"\n"<< std::setw(15) <<
"Run" 310 << std::setw(15) <<
"Lumi" 311 << std::setw(15) <<
"# Events" 315 unsigned long runID = 0;
316 unsigned long lumiID = 0;
326 if(runID != it.run() || lumiID != it.lumi()) {
330 << std::setw(15) << lumiID
331 << std::setw(15) << nEvents<<
"\n";
348 << std::setw(15) << lumiID
349 << std::setw(15) << nEvents<<
"\n";
356 assert(0 != metaDataTree);
362 fft->SetAddress(&fftPtr);
EventNumber_t event() const
void longBranchPrint(TTree *tr)
void printUuids(TTree *uuidTree)
unsigned long long EventNumber_t
std::string const & fileFormatVersionBranchName()
IndexIntoFileItr begin(SortOrder sortOrder) const
static void preIndexIntoFilePrintEventsInLumis(TFile *, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)
std::string const & fileIndexBranchName()
std::string const & fid() const
std::string const & indexIntoFileBranchName()
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
Long64_t numEntries(TFile *hdl, std::string const &trname)
std::string getUuid(TTree *uuidTree)
const_iterator end() const
bool iterationWillBeInEntryOrder(SortOrder sortOrder) const
Used to determine whether or not to disable fast cloning.
std::string const & metaDataTreeName()
void printTrees(TFile *hdl)
void printBranchNames(TTree *tree)
void printEventLists(TFile *tfl)
void printEventsInLumis(TFile *tfl)
EventID const & id() const
std::string const & eventTreeName()
static void preIndexIntoFilePrintEventLists(TFile *, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)
const_iterator begin() const
TFile * openFileHdl(std::string const &fname)
std::string const & fileIdentifierBranchName()
static void postIndexIntoFilePrintEventLists(TFile *tfl, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)
static void postIndexIntoFilePrintEventsInLumis(TFile *tfl, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)