Bmnt Class Reference

#include <Bmnt.h>

List of all members.

Public Member Functions

 Bmnt ()
 Create a bmnt with no outfile yet specified.
 Bmnt (const char *outfile)
 Create a bmnt with a pre-specified outfile.
 ~Bmnt ()
 Destructor.
void ProcessFiles (const char **filenames)
 Process the list of files into one pre-specified output file.
void ProcessFile (const char *filename, int nentries=0)
void ProcessDirectory (const char *in_directory, const char *out_directory, bool skip_last=false)
TTree * GetTree ()
void Write ()

Private Attributes

BmntImpfImp

Detailed Description

Definition at line 11 of file Bmnt.h.


Constructor & Destructor Documentation

Bmnt::Bmnt (  ) 

Create a bmnt with no outfile yet specified.

Definition at line 119 of file Bmnt.cxx.

00119             : fImp(new BmntImp)
00120 {
00121 }

Bmnt::Bmnt ( const char *  outfile  ) 

Create a bmnt with a pre-specified outfile.

Definition at line 123 of file Bmnt.cxx.

References fImp, and BmntImp::Start().

00123                                : fImp(new BmntImp)
00124 {
00125     fImp->Start(outfile);
00126 }

Bmnt::~Bmnt (  ) 

Destructor.

Definition at line 128 of file Bmnt.cxx.

References fImp.

00129 {
00130     if (!fImp) return;
00131 
00132     delete fImp; fImp = 0;
00133 }


Member Function Documentation

TTree * Bmnt::GetTree (  ) 

Definition at line 242 of file Bmnt.cxx.

References fImp, and BmntImp::fTree.

00242 { return fImp->fTree; }

void Bmnt::ProcessDirectory ( const char *  in_directory,
const char *  out_directory,
bool  skip_last = false 
)

Process all .mbeam.root files in given input directory and place output in given directory as .bmnt.root. Set skip_last to true to skip the most recent file (maybe because it is not yet written).

Definition at line 147 of file Bmnt.cxx.

References files, fImp, gSystem(), infile, len, outfile, BmntImp::ProcessFile(), BmntImp::Start(), BmntImp::Stop(), and Write().

00149 {
00150     void *dir = gSystem->OpenDirectory(in_directory);
00151     if (!dir) {
00152         cerr << "No such directory: " << in_directory << endl;
00153         return;
00154     }
00155 
00156     vector<string> files;
00157     while (const char* file = gSystem->GetDirEntry(dir)) {
00158         string filename = file;
00159         if ( filename.length() > 5
00160              && filename[0] == 'B'
00161              && filename.find(".mbeam.root") == filename.length()-11 ) {
00162             files.push_back(file);
00163         }
00164     }
00165     std::sort(files.begin(),files.end());
00166     if (skip_last) files.pop_back();
00167     for (size_t ind = 0; ind < files.size(); ++ind) {
00168 
00169         string infile = in_directory;
00170         infile += "/";
00171         infile += files[ind];
00172 
00173         string outfile = out_directory;
00174         size_t start = infile.rfind("/");
00175         size_t len = infile.find(".mbeam.root") - start;
00176         outfile += infile.substr(start,len);
00177         outfile += ".bmnt.root";
00178 
00179         if (!fImp->Start(outfile.c_str())) continue;
00180 
00181         cerr << infile << " --> " << outfile << endl;
00182 
00183         fImp->ProcessFile(infile.c_str(),true);
00184         fImp->ProcessFile(infile.c_str(),false);
00185         this->Write();
00186         fImp->Stop();
00187         delete fImp;
00188         fImp = new BmntImp();
00189     }
00190 }

void Bmnt::ProcessFile ( const char *  filename,
int  nentries = 0 
)

Definition at line 135 of file Bmnt.cxx.

References fImp, and BmntImp::ProcessFile().

00136 {
00137     fImp->ProcessFile(filename, false, nentries);
00138 }

void Bmnt::ProcessFiles ( const char **  filenames  ) 

Process the list of files into one pre-specified output file.

Definition at line 141 of file Bmnt.cxx.

References fImp, and BmntImp::ProcessFile().

Referenced by make_bmnt_one_per_dir().

00142 {
00143     for (int ind=0; filenames[ind]; ++ind) fImp->ProcessFile(filenames[ind],true);
00144     for (int ind=0; filenames[ind]; ++ind) fImp->ProcessFile(filenames[ind],false);
00145 }

void Bmnt::Write (  ) 

Definition at line 244 of file Bmnt.cxx.

References BmntImp::fFile, fImp, and BmntImp::fTree.

Referenced by make_bmnt_one_per_dir(), and ProcessDirectory().

00245 {
00246     fImp->fFile->cd();
00247     fImp->fTree->Write();
00248     fImp->fFile->Close();
00249 }


Member Data Documentation

BmntImp* Bmnt::fImp [private]

Definition at line 12 of file Bmnt.h.

Referenced by Bmnt(), GetTree(), ProcessDirectory(), ProcessFile(), ProcessFiles(), Write(), and ~Bmnt().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1