PlotterManager Class Reference

#include <PlotterManager.h>

List of all members.

Public Member Functions

 PlotterManager (const char *path="default")
 ~PlotterManager ()
void AddPlotter (Plotter *plotter)
void Spin (const char *treefile, int nentries=0, bool book=true)
void SpinDirectory (const char *dir)
PedestalsGetPeds ()
HistManGetHistMan ()
KnotGetKnot ()
std::vector< const char * > GetSwicDevNames ()
TFile * GetTreeFile ()
void WriteOut (const char *outfile)

Private Attributes

std::vector< Plotter * > fPlotters
PedestalsfPeds
HistMan fHm
Knot fKnot
TFile * fCurrentTreeFile

Detailed Description

Definition at line 13 of file PlotterManager.h.


Constructor & Destructor Documentation

PlotterManager::PlotterManager ( const char *  path = "default"  ) 

Definition at line 39 of file PlotterManager.cxx.

00040     : fPeds(0), fHm(path), fCurrentTreeFile(0)
00041 {
00042 }

PlotterManager::~PlotterManager (  ) 

Definition at line 44 of file PlotterManager.cxx.

References fCurrentTreeFile, fPeds, and fPlotters.

00045 {
00046     if (fPeds) delete fPeds; fPeds = 0;
00047     if (fCurrentTreeFile) delete fCurrentTreeFile; fCurrentTreeFile = 0;
00048     size_t siz = fPlotters.size();
00049     for (size_t ind=0; ind<siz; ++ind) {
00050         delete fPlotters[ind]; fPlotters[ind] = 0;
00051     }
00052     fPlotters.clear();
00053 }


Member Function Documentation

void PlotterManager::AddPlotter ( Plotter plotter  ) 

Definition at line 75 of file PlotterManager.cxx.

References fPlotters.

00076 {
00077     fPlotters.push_back(plotter);
00078 }

HistMan & PlotterManager::GetHistMan (  ) 

Definition at line 71 of file PlotterManager.cxx.

References fHm.

Referenced by DeltaT::Book(), MaxDaeDt::Book(), DeltaT::Fill(), and MaxDaeDt::Fill().

00072 {
00073     return fHm;
00074 }

Knot& PlotterManager::GetKnot (  )  [inline]

Definition at line 30 of file PlotterManager.h.

References fKnot.

Referenced by DeltaT::Fill(), MaxDaeDt::Fill(), Npot::Fill(), ProtonDist::Fill(), horn_off(), and tortgt_ok().

00030 { return fKnot; }

Pedestals & PlotterManager::GetPeds (  ) 

Definition at line 62 of file PlotterManager.cxx.

References fKnot, fPeds, Pedestals::GeneratePeds(), and ped_devs.

Referenced by ProtonDist::Fill().

00063 {
00064     if (fPeds) return *fPeds;
00065 
00066     cerr << "Generating pedestals\n";
00067     fPeds = new Pedestals;
00068     fPeds->GeneratePeds(fKnot,ped_devs);
00069     return *fPeds;
00070 }

vector< const char * > PlotterManager::GetSwicDevNames (  ) 

Definition at line 55 of file PlotterManager.cxx.

References ped_devs.

Referenced by DeltaT::Book(), DeltaT::Fill(), and MaxDaeDt::Fill().

00056 {
00057     vector<const char*> v;
00058     for (int ind=0; ped_devs[ind]; ++ind) v.push_back(ped_devs[ind]);
00059     return v;
00060 }

TFile* PlotterManager::GetTreeFile (  )  [inline]

Definition at line 32 of file PlotterManager.h.

References fCurrentTreeFile.

00032 { return fCurrentTreeFile; }

void PlotterManager::Spin ( const char *  treefile,
int  nentries = 0,
bool  book = true 
)

Definition at line 80 of file PlotterManager.cxx.

References fCurrentTreeFile, fKnot, fPlotters, Knot::GetEntry(), Knot::GetSize(), and Knot::SetTree().

Referenced by SpinDirectory().

00081 {
00082     cerr << "Loading " << treefile << endl;
00083 
00084     if (fCurrentTreeFile) {
00085         fCurrentTreeFile->Close();
00086         delete fCurrentTreeFile;
00087         fCurrentTreeFile = 0;
00088     }
00089     fCurrentTreeFile = new TFile(treefile);
00090     TTree* bd = dynamic_cast<TTree*>(fCurrentTreeFile->FindObjectAny("bd"));
00091     assert(bd);
00092     fKnot.SetTree(*bd);
00093 
00094     size_t siz = fPlotters.size();
00095 
00096     for (size_t ind=0; ind<siz; ++ind) {
00097         fPlotters[ind]->NewFile(fCurrentTreeFile->GetName());
00098     }
00099 
00100     if (book) {
00101         cerr << "Booking histograms\n";
00102         for (size_t ind=0; ind<siz; ++ind) {
00103             fPlotters[ind]->Book(*this);
00104         }
00105     }
00106 
00107     cerr << "Filling histograms\n";
00108     if (!nentries) nentries = fKnot.GetSize();
00109     for (int entry=0; entry<nentries; ++entry) {
00110         fKnot.GetEntry(entry);
00111 
00112         for (size_t ind=0; ind<siz; ++ind) {
00113             bool ok = fPlotters[ind]->Fill(*this);
00114             if (!ok) break;
00115         }
00116     }
00117 
00118 }

void PlotterManager::SpinDirectory ( const char *  dir  ) 

Definition at line 119 of file PlotterManager.cxx.

References files, gSystem(), and Spin().

00120 {
00121     void *dir = gSystem->OpenDirectory(directory);
00122     if (!dir) {
00123         cerr << "No such directory: " << directory << endl;
00124         return;
00125     }
00126 
00127     const size_t ext_size = sizeof(".bmnt.root")-1;
00128 
00129     vector<string> files;
00130     while (const char* file = gSystem->GetDirEntry(dir)) {
00131         string filename = file;
00132         if ( filename.length() > ext_size
00133              && filename[0] == 'B'
00134              && filename.find(".bmnt.root") == filename.length()-ext_size ) {
00135             filename = directory;
00136             filename += "/";
00137             filename += file;
00138             files.push_back(filename);
00139         }
00140     }
00141     std::sort(files.begin(),files.end());
00142     for (size_t ind = 0; ind < files.size(); ++ind) {
00143         cerr << "Processing " << files[ind] << endl;
00144         this->Spin(files[ind].c_str(),0,!ind);
00145     }
00146 }

void PlotterManager::WriteOut ( const char *  outfile  ) 

Definition at line 148 of file PlotterManager.cxx.

References HistMan::WriteOut().

00149 {
00150     HistMan hm("");
00151     hm.WriteOut(outfile);
00152 }


Member Data Documentation

Definition at line 18 of file PlotterManager.h.

Referenced by GetTreeFile(), Spin(), and ~PlotterManager().

Definition at line 16 of file PlotterManager.h.

Referenced by GetHistMan().

Definition at line 17 of file PlotterManager.h.

Referenced by GetKnot(), GetPeds(), and Spin().

Definition at line 15 of file PlotterManager.h.

Referenced by GetPeds(), and ~PlotterManager().

std::vector<Plotter*> PlotterManager::fPlotters [private]

Definition at line 14 of file PlotterManager.h.

Referenced by AddPlotter(), Spin(), and ~PlotterManager().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1