Page History
...
Code Block |
---|
// Initialization
if(!TROOT::Initialized()) {static TROOT root( "RootManager", "RootManager ROOT God" );}
// Open output file
TFile* pfile = new TFile("file.root", "RECREATE", "Created for you by RootManager" );
// Create histograms
TH1D *pHis1 = new TH1D("pHis1","My comment to TH1D", 100, 0.5, 100+0.5);
TH2D *pHis2 = new TH2D("pHis2","My comment to TH1D", 100, 0.5, 100+0.5,
200, 0.5, 200+0.5);
// Fill histograms in each event
pHis1 -> Fill( value, [weight] );
pHis2 -> Fill( x, y, [weight] );
// Write histograms in file in the very end
pHis1 -> Write();
pHis2 -> Write();
//Close file
pfile -> Close();
|
...
Code Block |
---|
// Define some structures for TTree typedef struct {float x,y,z;} POINT; static POINT point; float new_v; // Create TTree TTree* ptree = new TTree("ptree", "My comment to TTree"); // Create branches TBranch *pbranch = ptree->Branch("new_v", &new_v, "new_v/F"); ptree->Branch("point",&point,"x:y:z"); // Fill data structures for each event new_v = gRandom->Gaus(0, 1); point.x = gRandom->Gaus(1, 1); point.y = gRandom->Gaus(2, 1); point.z = gRandom->Gaus(3, 1); // Add an event record to the tree ptree->Fill(); // Write the tree to the file ptree -> Write(); |
Histogramming in BABAR
...
All histograms in Workbook examples are based on plane Root...
Histograms
Code Block |
---|
HepHistogram myPlot("The Title",100,0.,1.); float x, weight; ... myPlot.accumulate( x, weight ); |
NTuple
Code Block |
---|
#include "HepTuple/Histogram.h" #include "HepTuple/TupleManager.h" HepTupleManager* manager = gblEnv->getGen()->ntupleManager(); HepTuple *_ntuple = manager->ntuple("file-name.root"); _ntuple->column("run", eventID->run(), -99, "Event" ); _ntuple->column("event", eventCounter, -99, "Event" ); _ntuple->dumpData(); // for each event |
...
Overview
Content Tools