More information on this package is here.
#include "TMiniDSTReader.h"
ClassImp(TMiniDSTReader)
TMiniDSTReader::TMiniDSTReader()
{
fEventChain = new TChain("E1DEVNT");
fEvntHeader = new TMiniHEADClass();
fPElectron = new TMiniDSTClass();
fPProton = new TMiniDSTClass();
fCurrentEvent = -1;
fcaPARTStore = NULL;
InitClones();
}
TMiniDSTReader::~TMiniDSTReader()
{
delete fEventChain;
}
Int_t TMiniDSTReader::AddFile(const Char_t *filename)
{
if(access(filename,R_OK) == 0){
if(!fEventChain->Add(filename) || fEventChain->GetNtrees() == 0){
cerr << "Could not properly add the file " << filename << " to event chain.\n";
}
if( GetNFiles() == 1 ) {
cout << "TClasTool::AddFile (INFO): First file added. Initializing Branches" << endl;
InitBranches();
}
return 0;
} else {
cout << "TClasTool::AddFile (ERROR): Cannot access \"" << filename << "\" file for reading" << endl;
return -1;
}
}
Int_t TMiniDSTReader::ReadNext(){
return Next();
}
Int_t TMiniDSTReader::ReadEvent(Int_t evtnum){
cout << "TMiniDSTReader::ReadEvent: this function is not implemented yet." << endl;
return 0;
}
Int_t TMiniDSTReader::Next(){
Int_t status = 0;
if(fCurrentEvent >= fEventChain->GetEntries()-1){
cout << "TMiniDSTReader::Next : End of Event Entries Reached !" << endl;
status = -1;
} else {
CleanEventClones();
fEventChain->GetEntry(++fCurrentEvent);
}
return status;
}
Bool_t TMiniDSTReader::Notify(){
cout << "DSTReader: File in chain has changed..." << endl;
return kTRUE;
}
void TMiniDSTReader::InitClones(){
if(fcaPARTStore==NULL){
fcaPARTStore = new TClonesArray("TMiniDSTClass",10,kTRUE);
cout << "TMiniDSTReader::InitClones : Initializing EVNT Clones Array" << endl;
}
}
void TMiniDSTReader::CleanEventClones(){
if(fcaPARTStore != NULL) fcaPARTStore->Clear();
}
void TMiniDSTReader::InitBranches(){
if(fEventChain){
fEventChain->SetBranchAddress("HEADER",&fEvntHeader);
fEventChain->SetBranchAddress("ELECTRON",&fPElectron);
fEventChain->SetBranchAddress("PROTON",&fPProton);
fEventChain->SetBranchAddress("NTPART",&fcaPARTStore);
}
fEventChain->SetBranchStatus("*",1);
}
void TMiniDSTReader::PrintSummary(){
cout << "Summary of statistics: \n\n";
}
void TMiniDSTReader::PrintEventStatus(){
if (fCurrentEvent < 0) {
cout << "No Current Event to Display! Make sure you have some event read in!" << endl;
} else {
cout << endl << "Status on Run # " << fEvntHeader->NRun <<" Event #" << fEvntHeader->NEvent
<< " NROWS : " << GetNRows("PART") << endl;
}
}
Int_t TMiniDSTReader::GetNRows(const Char_t *bankname){
Int_t nRows = fcaPARTStore->GetEntries() + 2;
return nRows;
}
Int_t TMiniDSTReader::GetEventNumber()
{
return fCurrentEvent;
}
TObject *TMiniDSTReader::GetBankRow(const Char_t *bankname,Int_t nrow){
if(nrow==0) return fPElectron;
if(nrow==1) return fPProton;
if(nrow>1&&nrow<GetNPart()){
return fcaPARTStore->At(nrow-2);
}
return NULL;
}
Int_t TMiniDSTReader::GetChainEntries()
{
return (Int_t) fEventChain->GetEntries();
}
Int_t TMiniDSTReader::GetNPart(){
return GetNRows("EVNT");
}
TVector3 TMiniDSTReader::GetPart3Vector(int indx){
TVector3 v3vect(0,0,0);
if(indx>GetNPart()) return v3vect;
if(indx==0||indx==1){
if(indx==0){
v3vect.SetXYZ(fPElectron->GetPx(),fPElectron->GetPy(),fPElectron->GetPz());
} else {
v3vect.SetXYZ(fPProton->GetPx(),fPProton->GetPy(),fPProton->GetPz());
}
} else {
TMiniDSTClass *mdst = (TMiniDSTClass *) GetBankRow("PART",indx);
v3vect.SetXYZ(mdst->GetPx(),mdst->GetPy(),mdst->GetPz());
}
return v3vect;
}
Int_t TMiniDSTReader::GetPartID(int indx){
Int_t p_id = 2212;
if(indx==0) p_id = 11;
if(indx >1) p_id = 22;
return p_id;
}
Int_t TMiniDSTReader::GetPartCharge(int indx){
Int_t p_ch = 1;
if(indx>1) p_ch = 0;
if(indx==0) p_ch = -1;
return p_ch;
}
TString TMiniDSTReader::GetReaderType(){
TString rtype = "ROOTMINIDSTR2.0";
return rtype;
}
Int_t TMiniDSTReader::GetHelicity()
{
return fEvntHeader->Helicity;
}
Author: Maurik Holtrop
Last update:
CopyLeft - This code is freely available.
ROOT Home page - ClasTool Class index - Class Hierarchy - Top of the page