CMS 3D CMS Logo

Public Member Functions | Public Attributes | Protected Member Functions

TEcnaRootFile Class Reference

#include <TEcnaRootFile.h>

List of all members.

Public Member Functions

void CloseFile ()
Bool_t OpenR (const Text_t *="")
Bool_t OpenW (const Text_t *="")
Bool_t ReadElement (Int_t)
Bool_t ReadElement (CnaResultTyp, Int_t)
Int_t ReadElementNextEntryNumber (CnaResultTyp, Int_t)
 TEcnaRootFile (const Text_t *)
 TEcnaRootFile (const Text_t *, TString)
 TEcnaRootFile ()
 ~TEcnaRootFile ()

Public Attributes

TEcnaResultTypefCnaIndivResult
TBranch * fCnaResultsBranch
TTree * fCnaResultsTree
Int_t fCounterBytesCnaResults
Int_t fNbEntries
TFile * fRootFile
TString fRootFileName
TString fRootFileStatus

Protected Member Functions

void Init ()

Detailed Description

Definition at line 10 of file TEcnaRootFile.h.


Constructor & Destructor Documentation

TEcnaRootFile::TEcnaRootFile ( )
TEcnaRootFile::TEcnaRootFile ( const Text_t *  name)

Definition at line 23 of file TEcnaRootFile.cc.

References fRootFileName, Init(), and AlCaRecoCosmics_cfg::name.

                                               {
//constructor

 // cout << "[Info Management] CLASS: TEcnaRootFile.      CREATE OBJECT: this = " << this << endl;

  Init();
  fRootFileName = name;
}
TEcnaRootFile::TEcnaRootFile ( const Text_t *  name,
TString  status 
)

Definition at line 32 of file TEcnaRootFile.cc.

References fRootFileName, fRootFileStatus, Init(), AlCaRecoCosmics_cfg::name, and ntuplemaker::status.

                                                               {
//constructor

 // cout << "[Info Management] CLASS: TEcnaRootFile.      CREATE OBJECT: this = " << this << endl;

  Init();
  fRootFileName   = name;
  fRootFileStatus = status;
}
TEcnaRootFile::~TEcnaRootFile ( )

Definition at line 42 of file TEcnaRootFile.cc.

References fCnaIndivResult.

                              {
//destructor

  //cout << "[Info Management] CLASS: TEcnaRootFile.      DESTROY OBJECT: this = " << this << endl;

  if( fCnaIndivResult != 0 ){delete fCnaIndivResult;}
}

Member Function Documentation

void TEcnaRootFile::CloseFile ( )

Definition at line 63 of file TEcnaRootFile.cc.

References fCnaResultsBranch, fCnaResultsTree, fCounterBytesCnaResults, and fRootFile.

                              {
//Close the CNA root file for reading
  fRootFile->Close();
  delete fRootFile; fRootFile = 0;
  fCounterBytesCnaResults = 0;
  fCnaResultsTree         = 0;
  fCnaResultsBranch       = 0;
}
void TEcnaRootFile::Init ( void  ) [protected]
Bool_t TEcnaRootFile::OpenR ( const Text_t *  name = "")

Definition at line 72 of file TEcnaRootFile.cc.

References fCnaIndivResult, fCnaResultsBranch, fCnaResultsTree, fNbEntries, fRootFile, fRootFileName, AlCaRecoCosmics_cfg::name, and convertSQLiteXML::ok.

                                              {
//Open the CNA root file for reading
  Bool_t ok;
  TString sEmpty = "";
  if( name != sEmpty ){fRootFileName = name;}

  if( fRootFile == 0 ){fRootFile = new TFile(fRootFileName.Data(),"READ");}

  ok = fRootFile->IsOpen();
  if (ok) {
    fCnaResultsTree = (TTree *)fRootFile->Get("CNAResults");
    if (fCnaResultsTree) {
      if( fCnaIndivResult == 0 ){fCnaIndivResult = new TEcnaResultType();}
      fCnaResultsBranch = fCnaResultsTree->GetBranch("Results");
      fCnaResultsBranch->SetAddress(&fCnaIndivResult);
      fNbEntries = (Int_t) fCnaResultsTree->GetEntries();
    }
    else ok = kFALSE;
  }
  return ok;
}
Bool_t TEcnaRootFile::OpenW ( const Text_t *  name = "")

Definition at line 94 of file TEcnaRootFile.cc.

References fCnaIndivResult, fCnaResultsBranch, fCnaResultsTree, fRootFile, fRootFileName, AlCaRecoCosmics_cfg::name, and convertSQLiteXML::ok.

                                              {
//Open root file for writing
  Bool_t ok = kTRUE;
  TString sEmpty = "";
  if( name != sEmpty ){fRootFileName = name;}

  if( fRootFile == 0 ){fRootFile = new TFile(fRootFileName.Data(),"RECREATE");}
  if (fRootFile) {
    fCnaResultsTree = new TTree("CNAResults","CNAResults");
    fCnaIndivResult = new TEcnaResultType();
    fCnaResultsBranch = fCnaResultsTree->
      Branch("Results","TEcnaResultType", &fCnaIndivResult, 64000, 0);
  }
  else ok = kFALSE;
  return ok;
}
Bool_t TEcnaRootFile::ReadElement ( Int_t  i)

Definition at line 111 of file TEcnaRootFile.cc.

References fCnaResultsTree, fCounterBytesCnaResults, and convertSQLiteXML::ok.

                                         {
//Read element i
  Bool_t ok = kTRUE;
  fCounterBytesCnaResults += fCnaResultsTree->GetEntry(i);
  return ok;
}
Bool_t TEcnaRootFile::ReadElement ( CnaResultTyp  typ,
Int_t  k 
)

Definition at line 118 of file TEcnaRootFile.cc.

References fCnaIndivResult, fCnaResultsTree, fCounterBytesCnaResults, TEcnaResultType::fIthElement, fNbEntries, TEcnaResultType::fTypOfCnaResult, i, gen::k, and convertSQLiteXML::ok.

                                                           {
//Look for kth element of type typ
  Bool_t ok = kFALSE;
  Int_t i = 0;
  do {
    fCounterBytesCnaResults += fCnaResultsTree->GetEntry(i);
    ok = ( ( fCnaIndivResult->fIthElement == k ) &&
           ( fCnaIndivResult->fTypOfCnaResult == typ ));
    i++;
  } while ((i<fNbEntries) && (!ok));
  return ok;
}
Int_t TEcnaRootFile::ReadElementNextEntryNumber ( CnaResultTyp  typ,
Int_t  k 
)

Definition at line 131 of file TEcnaRootFile.cc.

References fCnaIndivResult, fCnaResultsTree, fCounterBytesCnaResults, TEcnaResultType::fIthElement, fNbEntries, TEcnaResultType::fTypOfCnaResult, i, gen::k, and convertSQLiteXML::ok.

                                                                         {
//Look for kth element of type typ and return the next entry number
  Bool_t ok = kFALSE;

  Int_t i = 0;
  do {
    fCounterBytesCnaResults += fCnaResultsTree->GetEntry(i);
    ok = ( ( fCnaIndivResult->fIthElement == k ) &&
           ( fCnaIndivResult->fTypOfCnaResult == typ ));
    i++;
  } while ((i<fNbEntries) && (!ok));

  if( ok == kFALSE ){i = -1;}
  return i;
}

Member Data Documentation

Definition at line 27 of file TEcnaRootFile.h.

Referenced by CloseFile(), Init(), OpenR(), and OpenW().

Definition at line 23 of file TEcnaRootFile.h.

Referenced by CloseFile(), Init(), OpenR(), OpenW(), ReadElement(), and ReadElementNextEntryNumber().

Definition at line 21 of file TEcnaRootFile.h.

Referenced by CloseFile(), Init(), ReadElement(), and ReadElementNextEntryNumber().

Definition at line 22 of file TEcnaRootFile.h.

Referenced by Init(), OpenR(), ReadElement(), and ReadElementNextEntryNumber().

Definition at line 20 of file TEcnaRootFile.h.

Referenced by CloseFile(), Init(), OpenR(), and OpenW().

Definition at line 18 of file TEcnaRootFile.h.

Referenced by Init(), OpenR(), OpenW(), and TEcnaRootFile().

Definition at line 19 of file TEcnaRootFile.h.

Referenced by Init(), and TEcnaRootFile().