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 <<
"\"" << std::endl;
61 void addBranchSizes(TBranch *
branch, Long64_t &size) {
62 size +=
branch->GetTotalSize();
64 Long64_t nB =
branch->GetListOfBranches()->GetEntries();
65 for (Long64_t
i = 0;
i < nB; ++
i) {
66 TBranch *btemp = (TBranch *)
branch->GetListOfBranches()->At(
i);
67 addBranchSizes(btemp, size);
70 Long64_t branchCompressedSizes(TBranch *
branch) {
return branch->GetZipBytes(
"*"); }
75 if (
tree !=
nullptr) {
76 Long64_t nB =
tree->GetListOfBranches()->GetEntries();
77 for (Long64_t
i = 0;
i < nB; ++
i) {
79 TBranch *btemp = (TBranch *)
tree->GetListOfBranches()->At(
i);
80 addBranchSizes(btemp, size);
81 std::cout <<
"Branch " <<
i <<
" of " <<
tree->GetName() <<
" tree: " << btemp->GetName()
82 <<
" Total size = " << size <<
" Compressed size = " << branchCompressedSizes(btemp) << std::endl;
91 Long64_t nB = tr->GetListOfBranches()->GetEntries();
92 for (Long64_t
i = 0;
i < nB; ++
i) {
93 tr->GetListOfBranches()->At(
i)->Print();
104 uuidTree->GetEntry(0);
112 uuidTree->GetEntry(0);
119 TTree *metaDataTree) {
124 fndx->SetAddress(&findexPtr);
127 std::cout <<
"FileIndex not found. If this input file was created with release 1_8_0 or later\n" 128 "this indicates a problem with the file. This condition should be expected with\n" 129 "files created with earlier releases and printout of the event list will fail.\n";
135 std::cout <<
"\nFileFormatVersion = " << fileFormatVersion <<
". ";
136 if (fileFormatVersion.fastCopyPossible())
137 std::cout <<
"This version supports fast copy\n";
139 std::cout <<
"This version does not support fast copy\n";
141 if (fileIndex.allEventsInEntryOrder()) {
142 std::cout <<
"Events are sorted such that fast copy is possible in the \"noEventSort = False\" mode\n";
144 std::cout <<
"Events are sorted such that fast copy is NOT possible in the \"noEventSort = False\" mode\n";
147 fileIndex.sortBy_Run_Lumi_EventEntry();
148 if (fileIndex.allEventsInEntryOrder()) {
149 std::cout <<
"Events are sorted such that fast copy is possible in the \"noEventSort\" mode\n";
151 std::cout <<
"Events are sorted such that fast copy is NOT possible in the \"noEventSort\" mode\n";
153 std::cout <<
"(Note that other factors can prevent fast copy from occurring)\n\n";
158 TTree *metaDataTree) {
163 fndx->SetAddress(&findexPtr);
166 std::cout <<
"IndexIntoFile not found. If this input file was created with release 1_8_0 or later\n" 167 "this indicates a problem with the file. This condition should be expected with\n" 168 "files created with earlier releases and printout of the event list will fail.\n";
173 TBranch *eventAuxBranch =
nullptr;
174 assert(
nullptr != eventsTree);
175 char const *
const kEventAuxiliaryBranchName =
"EventAuxiliary";
176 if (eventsTree->FindBranch(kEventAuxiliaryBranchName) !=
nullptr) {
177 eventAuxBranch = eventsTree->GetBranch(kEventAuxiliaryBranchName);
179 std::cout <<
"Failed to find " << kEventAuxiliaryBranchName
180 <<
" branch in Events TTree. Something is wrong with this file." << std::endl;
185 eventAuxBranch->SetAddress(&eAPtr);
186 std::cout <<
"\nPrinting IndexIntoFile contents. This includes a list of all Runs, LuminosityBlocks\n" 187 <<
"and Events stored in the root file.\n\n";
188 std::cout << std::setw(15) <<
"Run" << std::setw(15) <<
"Lumi" << std::setw(15) <<
"Event" << std::setw(15)
197 std::cout << std::setw(15) <<
it.run() << std::setw(15) <<
it.lumi();
208 eventAuxBranch->GetEntry(
it.entry());
209 eventNum = eventAuxiliary.
id().
event();
214 std::cout << std::setw(15) << eventNum << std::setw(15) <<
it.entry() <<
" " <<
type << std::endl;
217 std::cout <<
"\nFileFormatVersion = " << fileFormatVersion <<
". ";
218 if (fileFormatVersion.fastCopyPossible())
219 std::cout <<
"This version supports fast copy\n";
221 std::cout <<
"This version does not support fast copy\n";
224 std::cout <<
"Events are sorted such that fast copy is possible in the \"noEventSort = false\" mode\n";
226 std::cout <<
"Events are sorted such that fast copy is NOT possible in the \"noEventSort = false\" mode\n";
236 std::cout <<
"(Note that other factors can prevent fast copy from occurring)\n\n";
241 assert(
nullptr != metaDataTree);
247 fft->SetAddress(&fftPtr);
259 TTree *metaDataTree) {
264 fndx->SetAddress(&findexPtr);
267 std::cout <<
"FileIndex not found. If this input file was created with release 1_8_0 or later\n" 268 "this indicates a problem with the file. This condition should be expected with\n" 269 "files created with earlier releases and printout of the event list will fail.\n";
274 << std::setw(15) <<
"Run" << std::setw(15) <<
"Lumi" << std::setw(15) <<
"# Events" 277 unsigned long runID = 0;
278 unsigned long lumiID = 0;
279 for (std::vector<FileIndex::Element>::const_iterator
it = fileIndex.
begin(), itEnd = fileIndex.
end();
it != itEnd;
284 if (runID !=
it->run_ || lumiID !=
it->lumi_) {
287 std::cout << std::setw(15) << runID << std::setw(15) << lumiID << std::setw(15) <<
nEvents <<
"\n";
297 std::cout << std::setw(15) << runID << std::setw(15) << lumiID << std::setw(15) <<
nEvents <<
"\n";
305 TTree *metaDataTree) {
310 fndx->SetAddress(&findexPtr);
313 std::cout <<
"IndexIntoFile not found. If this input file was created with release 1_8_0 or later\n" 314 "this indicates a problem with the file. This condition should be expected with\n" 315 "files created with earlier releases and printout of the event list will fail.\n";
319 << std::setw(15) <<
"Run" << std::setw(15) <<
"Lumi" << std::setw(15) <<
"# Events" 323 unsigned long runID = 0;
324 unsigned long lumiID = 0;
335 if (runID !=
it.run() || lumiID !=
it.lumi()) {
338 std::cout << std::setw(15) << runID << std::setw(15) << lumiID << std::setw(15) <<
nEvents <<
"\n";
354 std::cout << std::setw(15) << runID << std::setw(15) << lumiID << std::setw(15) <<
nEvents <<
"\n";
361 assert(
nullptr != metaDataTree);
367 fft->SetAddress(&fftPtr);
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
IndexIntoFileItr begin(SortOrder sortOrder) const
void longBranchPrint(TTree *tr)
std::string const & metaDataTreeName()
std::string const & fid() const
std::string const & fileIdentifierBranchName()
const_iterator end() const
void printUuids(TTree *uuidTree)
unsigned long long EventNumber_t
TFile * openFileHdl(std::string const &fname)
std::string const & fileFormatVersionBranchName()
static void preIndexIntoFilePrintEventsInLumis(TFile *, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)
bool iterationWillBeInEntryOrder(SortOrder sortOrder) const
Used to determine whether or not to disable fast cloning.
EventID const & id() const
Long64_t numEntries(TFile *hdl, std::string const &trname)
std::string getUuid(TTree *uuidTree)
key
prepare the HTCondor submission files and eventually submit them
std::string const & fileIndexBranchName()
void printTrees(TFile *hdl)
void printBranchNames(TTree *tree)
const_iterator begin() const
void printEventLists(TFile *tfl)
void printEventsInLumis(TFile *tfl)
std::string const & eventTreeName()
static void preIndexIntoFilePrintEventLists(TFile *, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)
std::string const & indexIntoFileBranchName()
EventNumber_t event() const
static void postIndexIntoFilePrintEventLists(TFile *tfl, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)
static void postIndexIntoFilePrintEventsInLumis(TFile *tfl, FileFormatVersion const &fileFormatVersion, TTree *metaDataTree)