#include "HepTuple/HepRootFileManager.h" #include "HepTuple/HepHist1D.h" #include "HepTuple/HepHist2D.h" #include "HepTuple/HepHistProf.h" #include "HepTuple/HepNtuple.h" ZM_USING_NAMESPACE( zmht ) USING( namespace std ) #define MAXTRACKS 12 int main(Int4 argc, char** argv) { string filename = "toyz.root"; // Create the file manager and create the new root file. This will fail if // the file already exist HepFileManager * tManager = new HepRootFileManager( filename, HepFileManager::HEP_REFRESH ); Int4 nevents = 10; Int4 numTracks; //Int4 LuxLevel=3; Float8 Pt; //Float8 Ptmean = 2.0; Float8 PtArray[MAXTRACKS]; // Create a 1D histogram with 50 bins and with a range // between 0 and 10 HepHist1D & ppt = tManager->hist1D("Pt distribution", 50, 0.0f, 10.0f); // Instantiate an ntuple, declare it to be columnwise (this is default // anyhow) and tell the manager where to find the data items when we tell // it to capture. HepNtuple & tupl = tManager->ntuple("Kinematics CWN"); // Define a block named Tracks and a column named Ntracks. In addition, // declare this column to contain an index variable and specify it's range. tupl.columnAt("TRACKS::Ntracks",&numTracks,(Int4)1); tupl.span("TRACKS::Ntracks",0,MAXTRACKS); // specify nametag // There are a number of variations on how to declare indexed column arrays. tupl.columnArray("TRACKS::Pt", 1,(Float8)99.9); tupl.dimension("TRACKS::Pt",MAXTRACKS); // specify nametag tupl.index("TRACKS::Pt","Ntracks"); for( Int4 j=0; jwrite(); } // Capture the data inside the ntuple tupl.capture("TRACKS::Ntracks",numTracks); tupl.capture("TRACKS::Pt" ,&(PtArray[0])); tupl.storeCapturedData(); tupl.clearData(); } delete tManager; }