Analyzing Gleam Root Files

By default, full Gleam produces 3 output Root files - one each for the MC, Digi and Recon phases. For this discussion, we'll refer to them as mc.root, digi.root and recon.root. This HowTo addresses analyzing Gleam output data - Gleam has been run and Root files written out.

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

What you'll need are:

Note that 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.

Fire up Root, then (note this assumes the Root libraries for our classes have been loaded already via the .rootrc mechanism)

.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.

.Note that you do not need to provide all the Root files to the macro. If you leave the argument blank (ie ""), then that file will be ignored. The order is important - digi, recon, mc. RootTreeAnalysis will keep track of marching the files along in event order.

RootTreeAnalysis provides you a vehicle to define histograms and fill them. These happen in the RootTreeAnalysis HistDefine and Go functions, respectively. Here is a simple example. Only the HistDefine and McData functions are modified here for creating a single histogram looking 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;
}

Finally you will want peruse the class definitions:


R.Dubois Last Modified: 2004-08-04 15:39:40 -0700