Last active
April 1, 2025 19:56
-
-
Save jdbrice/b0c7f502ac0005a4b0868e63bcf0fce3 to your computer and use it in GitHub Desktop.
Size of PicoDst structures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <TFile.h> | |
#include <TTree.h> | |
#include <TBranch.h> | |
#include <TList.h> | |
#include <TObjArray.h> | |
void compareBranches(const char* filename = "pythia_for_full_sim.picoDst.root") { | |
TFile* file = TFile::Open(filename, "READ"); | |
if (!file || file->IsZombie()) { | |
printf("Error opening file\n"); | |
return; | |
} | |
TTree* tree = (TTree*)file->Get("PicoDst"); | |
Long64_t nEvents = tree->GetEntries(); | |
Long64_t totalBytes = tree->GetZipBytes(); // Uncompressed size of all branches | |
printf("Total uncompressed size: %lld bytes, %.2f bytes/event\n", | |
totalBytes, (double)totalBytes / nEvents); | |
// List of branches to subset (example: "Event", "Track") | |
const char* branchNames[] = {"FwdTracks", "FcsHits", "FcsClusters"}; | |
int nBranches = sizeof(branchNames) / sizeof(branchNames[0]); | |
Long64_t subsetBytes = 0; | |
for (int i = 0; i < nBranches; i++) { | |
TBranch* branch = tree->GetBranch(branchNames[i]); | |
if (branch) { | |
Long64_t branchBytes = branch->GetZipBytes(); | |
subsetBytes += branchBytes; | |
printf("Branch %s: %lld bytes, %.2f bytes/event\n", | |
branchNames[i], branchBytes, (double)branchBytes / nEvents); | |
} else { | |
printf("Branch %s not found\n", branchNames[i]); | |
} | |
} | |
printf("Subset size: %lld bytes, %.2f bytes/event\n", | |
subsetBytes, (double)subsetBytes / nEvents); | |
printf("Subset fraction of total: %.2f%%\n", | |
(double)subsetBytes / totalBytes * 100); | |
file->Close(); | |
} | |
void compareAllBranches(const char* filename = "pythia_for_full_sim.picoDst.root") { | |
TFile* file = TFile::Open(filename, "READ"); | |
if (!file || file->IsZombie()) { | |
printf("Error opening file\n"); | |
return; | |
} | |
TTree* tree = (TTree*)file->Get("PicoDst"); | |
if (!tree) { | |
printf("Tree 'PicoDst' not found\n"); | |
file->Close(); | |
return; | |
} | |
Long64_t nEvents = tree->GetEntries(); | |
Long64_t totalBytes = tree->GetZipBytes(); // Uncompressed size of all branches | |
printf("Total uncompressed size: %lld bytes, %.2f bytes/event\n", | |
totalBytes, (double)totalBytes / nEvents); | |
// Get all branches dynamically | |
TObjArray* branches = tree->GetListOfBranches(); | |
int nBranches = branches->GetEntries(); | |
Long64_t sumBytes = 0; | |
for (int i = 0; i < nBranches; i++) { | |
TBranch* branch = (TBranch*)branches->At(i); | |
const char* branchName = branch->GetName(); | |
Long64_t branchBytes = branch->GetZipBytes(); | |
sumBytes += branchBytes; | |
printf("Branch %s: %lld bytes, %.2f bytes/event, %.2f%% of total\n", | |
branchName, branchBytes, (double)branchBytes / nEvents, | |
(double)branchBytes / totalBytes * 100); | |
} | |
printf("Sum of branch sizes: %lld bytes, %.2f bytes/event\n", | |
sumBytes, (double)sumBytes / nEvents); | |
printf("Sum as fraction of total: %.2f%%\n", | |
(double)sumBytes / totalBytes * 100); | |
file->Close(); | |
} | |
void pico_size() { | |
compareBranches(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "StPicoEvent/StPicoEvent.h" | |
#include "StPicoEvent/StPicoTrack.h" | |
#include "StPicoEvent/StPicoBTowHit.h" | |
#include "StPicoEvent/StPicoBTofHit.h" | |
#include "StPicoEvent/StPicoMtdHit.h" | |
#include "StPicoEvent/StPicoEmcTrigger.h" | |
#include "StPicoEvent/StPicoBTofPidTraits.h" | |
#include "StPicoEvent/StPicoMtdPidTraits.h" | |
#include "StPicoEvent/StPicoEmcPidTraits.h" | |
#include "StPicoEvent/StPicoTrackCovMatrix.h" | |
#include "StPicoEvent/StPicoBEmcSmdEHit.h" | |
#include "StPicoEvent/StPicoBEmcSmdPHit.h" | |
#include "StPicoEvent/StPicoETofHit.h" | |
#include "StPicoEvent/StPicoETofPidTraits.h" | |
#include "StPicoEvent/StPicoFwdTrack.h" // Forward tracks | |
#include "StPicoEvent/StPicoFcsHit.h" | |
#include "StPicoEvent/StPicoFcsCluster.h" | |
void printPicoDstSizes() { | |
std::cout << "Size of PicoDst Classes (bytes):\n"; | |
std::cout << "------------------------------\n"; | |
std::cout << "StPicoEvent: " << sizeof(StPicoEvent) << "\n"; | |
std::cout << "StPicoTrack: " << sizeof(StPicoTrack) << "\n"; | |
std::cout << "StPicoBTowHit: " << sizeof(StPicoBTowHit) << "\n"; | |
std::cout << "StPicoBTofHit: " << sizeof(StPicoBTofHit) << "\n"; | |
std::cout << "StPicoMtdHit: " << sizeof(StPicoMtdHit) << "\n"; | |
std::cout << "StPicoEmcTrigger: " << sizeof(StPicoEmcTrigger) << "\n"; | |
std::cout << "StPicoBTofPidTraits: " << sizeof(StPicoBTofPidTraits) << "\n"; | |
std::cout << "StPicoMtdPidTraits: " << sizeof(StPicoMtdPidTraits) << "\n"; | |
std::cout << "StPicoEmcPidTraits: " << sizeof(StPicoEmcPidTraits) << "\n"; | |
std::cout << "StPicoTrackCovMatrix:" << sizeof(StPicoTrackCovMatrix) << "\n"; | |
std::cout << "StPicoBEmcSmdEHit: " << sizeof(StPicoBEmcSmdEHit) << "\n"; | |
std::cout << "StPicoBEmcSmdPHit: " << sizeof(StPicoBEmcSmdPHit) << "\n"; | |
std::cout << "StPicoETofHit: " << sizeof(StPicoETofHit) << "\n"; | |
std::cout << "StPicoETofPidTraits: " << sizeof(StPicoETofPidTraits) << "\n"; | |
std::cout << "StPicoFwdTrack: " << sizeof(StPicoFwdTrack) << "\n"; | |
std::cout << "StPicoFcsHit: " << sizeof(StPicoFcsHit) << "\n"; | |
std::cout << "StPicoFcsCluster: " << sizeof(StPicoFcsCluster) << "\n"; | |
} | |
int main() { | |
printPicoDstSizes(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment