Print Version

 

Analyzing Gleam Root Files

Use this procedure to analyze Gleam output data after Gleam has been run and Root files written out.

Note: By default, full Gleam produces 3 output Root files, referred to as:

Prerequisites

????The RootTreeAnalysis macro has been created to provide a common approach to analyzing Gleam's Root files and to provide the commonly used functions.

 

Note: For using the macro, the .cxx file does not need to be named RootTreeAnalysis - but inside the class must be RootTreeAnalysis. It is more convenient for you to name it for its function so you can have several laying around for your analyses.

Analyze an Output File

To perform an analysis, start Root, then:

.L myRootAnalysis.cxx                                   // to load the macro

RootTreeAnalysis* m = new RootTreeAnalysis("digi.root","recon.root","mc.root");  // load files

m->Go();                                                       // to analyze the files

TBrowser b;                                                  // fire up the browser to view the histograms

delete m;

RootTreeAnalysis* m = new RootTreeAnalysis("digiNew.root","reconNew.root","mcNew.root");  // load  new files

m->Go();    // to look at these guys

m->setHistName("myFirstHistos");

m->WriteHist();                        // save your histos as myFirstHistos.root

...  edit your macro myRootTreeAnalsis.cxx  ....

delete m;

.L myRootTreeAnalysis.cxx

etc.

Notes:

In the following example, only the HistDefine and McData functions are modified to create a single histogram looking at the MC branch of the tree.

#include "RootTreeAnalysis.h"

UInt_t digiEventId, reconEventId, mcEventId;
UInt_t digiRunNum, reconRunNum, mcRunNum;


/* Setup ALL histograms */
void RootTreeAnalysis::HistDefine() {

gStyle->SetOptStat(111111);

histFile = new TFile(m_histFileName,"RECREATE");

TH1F *PARTCOUNTMC = new TH1F("PARTCOUNTMC", "MC Part Count",
20, 0, 20);
}

/* Process the Monte Carlo Data
Called by Go()
*/

void RootTreeAnalysis::McData() {

// get multiplicities

((TH1F*)GetObjectPtr("PARTCOUNTMC"))->Fill((Float_t)mc->getMcParticleCol()->GetEntries());
}


/* Event Loop
All Analysis goes here
*/
void RootTreeAnalysis::Go(Int_t numEvents)

// To read only selected branches - saves processing time
// Comment out any branches you are not interested in.

// mc branches:
if (mcTree) {
mcTree->SetBranchStatus("*", 0); // disable all branches
// Activate desired branches...
mcTree->SetBranchStatus("m_eventId", 1);
mcTree->SetBranchStatus("m_particleCol", 1);
mcTree->SetBranchStatus("m_runId", 1); 
mcTree->SetBranchStatus("m_integratingHitCol", 1); 
mcTree->SetBranchStatus("m_positionHitCol", 0); 
}


// determine how many events to process
Int_t nentries = GetEntries();
std::cout << "\nNum Events in File is: " << nentries << std::endl;
Int_t curI;
Int_t nMax = TMath::Min(numEvents+m_StartEvent,nentries);
if (m_StartEvent == nentries) {
std::cout << " all events in file read" << std::endl;
return;
}
if (nentries <= 0) return;

// Keep track of how many bytes we have read in from the data files
Int_t nbytes = 0, nb = 0;

// BEGINNING OF EVENT LOOP
for (Int_t ievent=m_StartEvent; ievent<nMax; ievent++, curI=ievent) {

if (mc) {
mc->Clear();
}

if (evt) {
evt->Clear();
}

digiEventId = 0; reconEventId = 0; mcEventId = 0;
digiRunNum = 0; reconRunNum = 0; mcRunNum = 0;

nb = GetEvent(ievent);
nbytes += nb;


// Monte Carlo ONLY analysis
if (mc) { // if we have mc data process it
mcEventId = mc->getEventId();
mcRunNum = mc->getRunId();
McData();


// Digi ONLY analysis
if (evt) {
digiEventId = evt->getEventId(); 
digiRunNum = evt->getRunId();

// DigiTkr();
// DigiCal();
// DigiAcd();
}

// Monte Carlo ONLY analysis
if (rec) { // if we have mc data process it
reconEventId = rec->getEventId();
reconRunNum = rec->getRunId();
// ReconCal();


} // end analysis code in event loop

m_StartEvent = curI;
}

Owned by R.Dubois

 

Last updated by: Chuck Patterson 10/27/2004.
Back to Top