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

SAnaNtup Class Reference

#include <StdNtup.h>

List of all members.

Public Member Functions

 ~SAnaNtup ()
bool Add (void *pntr, std::string ClassName, std::string TreeName)
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 23 of file StdNtup.cxx.

References fFile, fTreeName, and fTreeNameMap.

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

SAnaNtup::SAnaNtup  )  [private]
 

Definition at line 13 of file StdNtup.cxx.

References fPntr, fTree, fTreeName, and fTreeNameMap.

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


Member Function Documentation

bool SAnaNtup::Add void *  pntr,
std::string  ClassName,
std::string  TreeName
 

Definition at line 51 of file StdNtup.cxx.

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

Referenced by main(), and fillntup::FillNtup::Update().

00052 {
00053 // void std::
00054   char* msg[4] = {"SAnaNtup::Add -- pointer already exists!",
00055                   "SAnaNtup::Add -- tree name already exists!",
00056                   "SAnaNtup::Add -- tree name is empty!",
00057                   "SAnaNtup::Add -- tree title is empty!"};
00058   
00059   cout << " STD NTUP IN HERE 1 " << endl;
00060   
00061   // demand that neither pointer nor tree name has already been used
00062   assert_jobc(find(fPntr.begin(),fPntr.end(),pntr) == fPntr.end(),msg[0]);
00063   assert_jobc(find(fTreeName.begin(),fTreeName.end(),TreeName) == fTreeName.end(),msg[1]);
00064 
00065   // demand that the strings are not empty
00066   assert_jobc(TreeName. length() > 0,msg[2]);
00067  
00068   cout << " STD NTUP IN HERE 2 " << endl;
00069   
00070   if (!fFile) 
00071     fFile = new TFile("StdNtup.root","recreate");
00072   
00073   fFile->cd();
00074 
00075   cout << " STD NTUP IN HERE 3 " << endl;
00076   
00077     // now create the tree
00078   TTree* tree = new TTree(TreeName.c_str(),TreeName.c_str());
00079   
00080   cout << " STD NTUP IN HERE 4 " << endl;
00081     
00082   string brName = "f" + TreeName;
00083  
00084   string clName = ClassName;
00085    
00086   cout << " STD NTUP IN HERE 5 " << endl;
00087   
00088   cout << " br_name " << brName.c_str() << " class_name " << clName.c_str() << " pntr " << pntr <<  endl;
00089     
00090   tree->Branch(brName.c_str(),clName.c_str(),pntr,32000,99);
00091    
00092   cout << " STD NTUP IN HERE 6 " << endl;
00093   
00094   fTree.push_back(tree);
00095 
00096   fPntr.push_back(pntr);
00097   fTreeName.push_back(TreeName);
00098 
00099   // create link between tree name and pointer to tree
00100   fTreeNameMap[TreeName] = tree;
00101   
00102   return true;
00103 }

bool SAnaNtup::Fill string  TreeName  ) 
 

Definition at line 125 of file StdNtup.cxx.

References fFile, and fTreeNameMap.

Referenced by fillntup::FillNtup::Ana(), and main().

00126 {
00127   fFile->cd();
00128 
00129   if (fTreeNameMap[TreeName]) {
00130     fTreeNameMap[TreeName]->Fill();
00131    
00132     return true;
00133   }
00134   
00135   return false;
00136 }

SAnaNtup & SAnaNtup::Instance  )  [static]
 

Definition at line 40 of file StdNtup.cxx.

References fInstance.

Referenced by main().

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

void SAnaNtup::Print string  TreeName  ) 
 

Definition at line 107 of file StdNtup.cxx.

References fTreeNameMap.

00108 {
00109   if (fTreeNameMap[TreeName])
00110     fTreeNameMap[TreeName]->Print();
00111 
00112 }

void SAnaNtup::Save string  TreeName  ) 
 

Definition at line 116 of file StdNtup.cxx.

References fTreeNameMap.

Referenced by main(), and fillntup::FillNtup::~FillNtup().

00117 {
00118   if (fTreeNameMap[TreeName])
00119     fTreeNameMap[TreeName]->AutoSave();
00120 
00121 }


Member Data Documentation

TFile* SAnaNtup::fFile [private]
 

Definition at line 261 of file StdNtup.h.

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

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

Definition at line 9 of file StdNtup.cxx.

Referenced by Instance().

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

Definition at line 263 of file StdNtup.h.

Referenced by Add(), and SAnaNtup().

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

Definition at line 262 of file StdNtup.h.

Referenced by Add(), and SAnaNtup().

vector<string> SAnaNtup::fTreeName [private]
 

Definition at line 265 of file StdNtup.h.

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

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

Definition at line 267 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 Mon Nov 23 04:45:29 2009 for NOvA Offline by  doxygen 1.3.9.1