Post on 18-Dec-2015
E906 Data Analysis Frame (II)
Jia-Ye Chen
2010.10.13
Contents Motivations Analysis Frame
Locations Events Rebuild (structure)
Functions Upgrade Main Frame
Data Analysis (class) Define Class Main Frame
Motivations (I) Following the data extracted from mySQL database by
ROOT-base program, to rebuild the event stream data formation instead of mySQL table structure include “event”, “run”, “spill”, “mdimuon”, “mtrack” and “mhit”. The main purpose is to rearrange all information associated within the same physics event, rather than separate in different tables.
Instead of “Tree/Branch/Leaf”, a 2-Level data formation “Tree/Leaf” was implemented, where the “Branch” is same as the “Leaf”.
[jychen@ipas012 src]$root dimuon.ccroot[0]Processing dimuon.ccWarning in <Tfile::ReadStreamerInfo>: /sp8data11/shyao/rootfile/r290.root: not a TStreamInfo object
Motivations (II) Bring in the “Class” in C++ programming
from the default ROOT function “makeClass”, one step further than “structure” in C programming. And also, to simplify the data access by reading Tree rather than massive “br?->GetEntry(i)”.(GetEntries / GetEntry)
The sub-purpose is to remove multi-declared information, such as “eventID”, “runID”, “trackID” and so on.
Analysis Frame – Locations
ipas012.phys.sinica.edu.tw Event Rebuild
Directory : /usrX/jychen/e906/eventRebuild Header files : ./include.v5/*.h Source files : ./src.v6/*.cc
Data Analysis Directory : /usrX/jychen/e906/dimuonAna
Header files : ./include/*.h Source files : ./src/*.cc
Analysis Frame – Event Rebuild Functions upgrade
logger.cc : save the log and generate the file “dimuon.log” in the directory “../bin”.
error.cc : save the error messages and generate the file “dimuon.err” in the directory “../bin”.
readSwitch.cc : read the switch file from “switch.in” from the directory “../bin”.
trackInit.cc : initialize the temporary track structure by inputting the initial values.
branchBuild.cc : rebuild the branch list for event stream structure.
eventReconstruct.cc : reconstruct the event stream. eventFill.cc : fill the new event-stream data into new
output ROOT file.
Analysis Frame – Event Rebuild main file : dimuon.cc
int dimuon(){
char switchFile[100] = "../bin/switch.in";
char errorLogFile[100] = "dimuon";
char logFile[100] = "dimuon";
// Open this error log file
if ( openErrorLog(errorLogFile) ) return (FILE_ERR);
// Open this log file
if ( openLogFile(logFile) ) return (FILE_ERR);
// reading switch file : "../bin/switch.in"
if ( readSwitch(switchFile, &sw) ) return (FILE_ERR);
// Open a .root file
TFile *f = new TFile("/sp8data11/shyao/rootfile/r290.root");
// build Branch:Leaf table
branchBuild( tree2, &columnTracks );
// construct event stream
for ( int eventNum=0; eventNum < 2 ; eventNum++ ){
// track initialization
trackInit( tracks, ntrk );
// event reconstruction : rearrangement
for ( int j=tmpTrack1; j <= tmpTrack2; j++ ){
eventReconstruct( &event, &mtrack, tracks, &H, tmpTrack1);
} // j Loop
// event reconstruction : filling
eventFill( &columnTracks, tracks, ntrk );
// tree filling
tree2->Fill();
} // eventNum Loop
Analysis Frame – Data Analysis class file : ana.h
#ifndef ANA_h
#define ANA_h
#include "../include/arraySize"
class ana {
public :
TTree *fChain;
// Declaration of leaf types
Int_t numTracks;
Double_t trk_p0[MAX_TRACK][4];
Double_t trk_pf[MAX_TRACK][4];
// List of branches
TBranch *b_numTracks;
TBranch *b_trk_p0;
TBranch *b_trk_pf;
virtual void Init();
virtual void Loop();
virtual void SetBranch(TTree *tree);
};
#endif
Analysis Frame – Data Analysis main file : main.cc
void main(){
ana t;
t.Init();
t.SetBranch(tree2);
t.Loop();
}
ana::Init(){
TFile *f = new TFile("outputFile/test2.root");
TTree *tree2 = (TTree*)f->Get("tree2");
}
void ana::SetBranch(TTree *tree){
fChain = tree;
fChain->SetBranchAddress("numTracks", &numTracks, &b_numTracks);
fChain->SetBranchAddress("trk_p0", trk_p0, &b_trk_p0);
fChain->SetBranchAddress("trk_pf", trk_pf, &b_trk_pf);
}
void ana::Loop(){
Int_t nentries = fChain->GetEntriesFast();
for (Int_t iEvent=0; iEvent < nentries; iEvent++){
fChain->GetEntry(iEvent);
cout << numTracks << endl;
}
}