Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

stdnt::SAnaNtup Class Reference

#include <StdNtup.h>

List of all members.

Public Member Functions

 ~SAnaNtup ()
bool Add (void *pntr, string ClassName="StdNtup", string TreeName="", string TreeTitle="Standard Analysis Ntuple")
bool Fill (string TreeName)
void Print (string TreeName)
void Save (string TreeName)

Static Public Member Functions

SAnaNtupInstance ()

Private Member Functions

 SAnaNtup ()

Private Attributes

TFile * fFile
vector< TTree * > fTree
vector< void * > fPntr
vector< string > fTreeName
map< string, TTree * > fTreeNameMap

Static Private Attributes

SAnaNtupfInstance = 0


Constructor & Destructor Documentation

SAnaNtup::~SAnaNtup  ) 
 

Definition at line 24 of file StdNtup.cxx.

References fFile, fTreeName, and fTreeNameMap.

00025 {
00026 
00027   for (unsigned int i=0; i<fTreeName.size(); ++i)
00028     fTreeNameMap[fTreeName[i]]->AutoSave();
00029   
00030   fFile->Close();
00031 
00032   delete fFile;
00033 
00034   for (unsigned int i=0; i<fTreeName.size(); ++i)
00035     delete fTreeNameMap[fTreeName[i]];
00036 
00037 }

SAnaNtup::SAnaNtup  )  [private]
 

Definition at line 14 of file StdNtup.cxx.

References fPntr, fTree, fTreeName, and fTreeNameMap.

00014                    : fFile(0)
00015 {
00016   fTree.clear();
00017   fPntr.clear();
00018   fTreeName.clear();
00019   fTreeNameMap.clear();
00020 }


Member Function Documentation

bool SAnaNtup::Add void *  pntr,
string  ClassName = "StdNtup",
string  TreeName = "",
string  TreeTitle = "Standard Analysis Ntuple"
 

Definition at line 52 of file StdNtup.cxx.

References assert_jobc, fFile, fPntr, fTree, fTreeName, and fTreeNameMap.

Referenced by main().

00054 {
00055   char* msg[4] = {"SAnaNtup::Add -- pointer already exists!",
00056                   "SAnaNtup::Add -- tree name already exists!",
00057                   "SAnaNtup::Add -- tree name is empty!",
00058                   "SAnaNtup::Add -- tree title is empty!"};
00059 
00060   // demand that neither pointer nor tree name has already been used
00061   assert_jobc(find(fPntr.begin(),fPntr.end(),pntr) == fPntr.end(),msg[0]);
00062   assert_jobc(find(fTreeName.begin(),fTreeName.end(),TreeName) == fTreeName.end(),msg[1]);
00063 
00064   // demand that the strings are not empty
00065   assert_jobc(TreeName. length() > 0,msg[2]);
00066   assert_jobc(TreeTitle.length() > 0,msg[3]);
00067 
00068   if (!fFile) 
00069     fFile = new TFile("stdntup.root","recreate");
00070   
00071   fFile->cd();
00072 
00073   // now create the tree
00074   TTree* tree = new TTree(TreeName.c_str(),TreeTitle.c_str());
00075   string brName = "f" + TreeName;
00076   tree->Branch(brName.c_str(),ClassName.c_str(),pntr);
00077   fTree.push_back(tree);
00078 
00079   fPntr.push_back(pntr);
00080   fTreeName.push_back(TreeName);
00081 
00082   // create link between tree name and pointer to tree
00083   fTreeNameMap[TreeName] = tree;
00084   
00085   return true;
00086 }

bool SAnaNtup::Fill string  TreeName  ) 
 

Definition at line 108 of file StdNtup.cxx.

References fFile, and fTreeNameMap.

Referenced by main().

00109 {
00110   fFile->cd();
00111 
00112   if (fTreeNameMap[TreeName]) {
00113     fTreeNameMap[TreeName]->Fill();
00114     //    fTreeNameMap[TreeName]->AutoSave();
00115     return true;
00116   }
00117   
00118   return false;
00119 }

SAnaNtup & SAnaNtup::Instance  )  [static]
 

Definition at line 41 of file StdNtup.cxx.

References fInstance.

00042 {
00043 
00044   if (!fInstance)
00045     fInstance = new SAnaNtup;
00046   return *fInstance;
00047 
00048 }

void SAnaNtup::Print string  TreeName  ) 
 

Definition at line 90 of file StdNtup.cxx.

References fTreeNameMap.

00091 {
00092   if (fTreeNameMap[TreeName])
00093     fTreeNameMap[TreeName]->Print();
00094 
00095 }

void SAnaNtup::Save string  TreeName  ) 
 

Definition at line 99 of file StdNtup.cxx.

References fTreeNameMap.

Referenced by main().

00100 {
00101   if (fTreeNameMap[TreeName])
00102     fTreeNameMap[TreeName]->AutoSave();
00103 
00104 }


Member Data Documentation

TFile* stdnt::SAnaNtup::fFile [private]
 

Definition at line 273 of file StdNtup.h.

Referenced by Add(), Fill(), and ~SAnaNtup().

SAnaNtup * SAnaNtup::fInstance = 0 [static, private]
 

Definition at line 10 of file StdNtup.cxx.

Referenced by Instance().

vector<void*> stdnt::SAnaNtup::fPntr [private]
 

Definition at line 275 of file StdNtup.h.

Referenced by Add(), and SAnaNtup().

vector<TTree*> stdnt::SAnaNtup::fTree [private]
 

Definition at line 274 of file StdNtup.h.

Referenced by Add(), and SAnaNtup().

vector<string> stdnt::SAnaNtup::fTreeName [private]
 

Definition at line 277 of file StdNtup.h.

Referenced by Add(), SAnaNtup(), and ~SAnaNtup().

map<string, TTree*> stdnt::SAnaNtup::fTreeNameMap [private]
 

Definition at line 279 of file StdNtup.h.

Referenced by Add(), Fill(), Print(), SAnaNtup(), Save(), and ~SAnaNtup().


The documentation for this class was generated from the following files:
Generated on Thu Sep 4 02:05:36 2008 for NOvA Offline by doxygen 1.3.5