AtNuDataFilterNtuple Class Reference

#include <AtNuDataFilterNtuple.h>

List of all members.

Public Member Functions

 AtNuDataFilterNtuple ()
 ~AtNuDataFilterNtuple ()
void Reset ()
void AddFile (const char *file)
void SetFileName (const char *file)
void OpenFile ()
void WriteToFile ()
void CloseFile ()
void Run ()

Private Attributes

TChain * fChain
TFile * fAtNuDataFilterFile
TTree * fAtNuDataFilterTree
TString fFileName
Int_t fRun
Int_t fSubRun
Int_t fUnixTime
Int_t fDate
Int_t fTime
Int_t fRate
Int_t fGood

Detailed Description

Definition at line 11 of file AtNuDataFilterNtuple.h.


Constructor & Destructor Documentation

AtNuDataFilterNtuple::AtNuDataFilterNtuple (  ) 

Definition at line 7 of file AtNuDataFilterNtuple.cxx.

00007                                            :
00008   fChain(0)
00009 {
00010   this->Reset();
00011 }

AtNuDataFilterNtuple::~AtNuDataFilterNtuple (  ) 

Definition at line 13 of file AtNuDataFilterNtuple.cxx.

00014 {
00015 
00016 }


Member Function Documentation

void AtNuDataFilterNtuple::AddFile ( const char *  file  ) 

Definition at line 41 of file AtNuDataFilterNtuple.cxx.

References fChain.

00042 {
00043   std::cout << " adding files from: " << file << std::endl;
00044 
00045   fChain->Add(file);
00046 
00047   std::cout << "   ... total entries=" << fChain->GetEntries() << std::endl;
00048 
00049   return;
00050 }

void AtNuDataFilterNtuple::CloseFile (  ) 

Definition at line 83 of file AtNuDataFilterNtuple.cxx.

References fAtNuDataFilterFile, and fAtNuDataFilterTree.

Referenced by Run().

00084 {
00085   if( fAtNuDataFilterFile ){
00086     std::cout << " closing file: " << fAtNuDataFilterFile->GetName() << std::endl;
00087     TDirectory* tmpd = gDirectory;
00088     fAtNuDataFilterFile->cd();
00089     fAtNuDataFilterTree->Write();
00090     fAtNuDataFilterFile->Close();
00091     gDirectory = tmpd;
00092   }
00093 }

void AtNuDataFilterNtuple::OpenFile (  ) 

Definition at line 61 of file AtNuDataFilterNtuple.cxx.

References fAtNuDataFilterFile, fAtNuDataFilterTree, fDate, fFileName, fGood, fRate, fRun, fSubRun, fTime, and fUnixTime.

Referenced by Run().

00062 {
00063   if( !fAtNuDataFilterFile ){
00064     std::cout << " opening file: " << fFileName.Data() << std::endl;
00065     TDirectory* tmpd = gDirectory;
00066     fAtNuDataFilterFile = new TFile(fFileName.Data(),"recreate");
00067     fAtNuDataFilterTree = new TTree("ntuple","minos monitor ntuple");
00068     fAtNuDataFilterTree->SetDirectory(fAtNuDataFilterFile);
00069 
00070     fAtNuDataFilterTree->Branch("run",&fRun,"run/I");
00071     fAtNuDataFilterTree->Branch("subrun",&fSubRun,"subrun/I");
00072     fAtNuDataFilterTree->Branch("unixtime",&fUnixTime,"unixtime/I");
00073     fAtNuDataFilterTree->Branch("date",&fDate,"date/I");
00074     fAtNuDataFilterTree->Branch("time",&fTime,"time/I");
00075     fAtNuDataFilterTree->Branch("rate",&fRate,"rate/I");
00076     fAtNuDataFilterTree->Branch("good",&fGood,"good/I");
00077 
00078     fAtNuDataFilterTree->SetAutoSave(100);
00079     gDirectory = tmpd;
00080   }
00081 }

void AtNuDataFilterNtuple::Reset (  ) 

Definition at line 18 of file AtNuDataFilterNtuple.cxx.

References fAtNuDataFilterFile, fAtNuDataFilterTree, fChain, fDate, fFileName, fGood, fRate, fRun, fSubRun, fTime, and fUnixTime.

00019 {
00020   if( !fChain ){
00021     fChain = new TChain("ntuple","chain");
00022   }
00023 
00024   fChain->Reset();
00025   fChain->SetBranchAddress("run",&fRun);
00026   fChain->SetBranchAddress("subrun",&fSubRun);
00027   fChain->SetBranchAddress("unixtime",&fUnixTime);
00028   fChain->SetBranchAddress("date",&fDate);
00029   fChain->SetBranchAddress("time",&fTime);
00030   fChain->SetBranchAddress("rate",&fRate);
00031   fChain->SetBranchAddress("good",&fGood);
00032  
00033   fAtNuDataFilterFile = 0;
00034   fAtNuDataFilterTree = 0;
00035 
00036   fFileName = "ntpcheck.root";
00037 
00038   return;
00039 }

void AtNuDataFilterNtuple::Run (  ) 

Definition at line 105 of file AtNuDataFilterNtuple.cxx.

References CloseFile(), fChain, fDate, fGood, fRate, fRun, fSubRun, fTime, fUnixTime, OpenFile(), and WriteToFile().

00106 {
00107   std::cout << " *** AtNuDataNtuple::Run() *** " << std::endl;
00108 
00109   // open file
00110   this->OpenFile();
00111 
00112   // loop over events
00113   fUnixTime = -1;
00114   fRun = -1;
00115   fSubRun = -1;
00116   fDate = -1;
00117   fTime = -1;
00118   fRate = 0;
00119   fGood = 0;
00120 
00121   for( Int_t i=0; i<fChain->GetEntries(); i++ ){
00122     fChain->GetEntry(i);
00123 
00124     this->WriteToFile();
00125   }
00126 
00127   // close file
00128   this->CloseFile();
00129 
00130   return;
00131 }

void AtNuDataFilterNtuple::SetFileName ( const char *  file  ) 

Definition at line 52 of file AtNuDataFilterNtuple.cxx.

References fFileName.

00053 {
00054   std::cout << " *** AtNuDataFilterNtuple::SetFileName(...) *** " << std::endl;
00055 
00056   fFileName = file;
00057 
00058   std::cout << "   output file = " << fFileName.Data() << std::endl;
00059 }

void AtNuDataFilterNtuple::WriteToFile (  ) 

Definition at line 95 of file AtNuDataFilterNtuple.cxx.

References fAtNuDataFilterFile, and fAtNuDataFilterTree.

Referenced by Run().

00096 {
00097   if( fAtNuDataFilterFile ){
00098     TDirectory* tmpd = gDirectory;
00099     fAtNuDataFilterFile->cd();
00100     fAtNuDataFilterTree->Fill();
00101     gDirectory = tmpd;
00102   }
00103 }


Member Data Documentation

Definition at line 31 of file AtNuDataFilterNtuple.h.

Referenced by CloseFile(), OpenFile(), Reset(), and WriteToFile().

Definition at line 32 of file AtNuDataFilterNtuple.h.

Referenced by CloseFile(), OpenFile(), Reset(), and WriteToFile().

TChain* AtNuDataFilterNtuple::fChain [private]

Definition at line 29 of file AtNuDataFilterNtuple.h.

Referenced by AddFile(), Reset(), and Run().

Int_t AtNuDataFilterNtuple::fDate [private]

Definition at line 38 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and Run().

Definition at line 33 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and SetFileName().

Int_t AtNuDataFilterNtuple::fGood [private]

Definition at line 41 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and Run().

Int_t AtNuDataFilterNtuple::fRate [private]

Definition at line 40 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and Run().

Int_t AtNuDataFilterNtuple::fRun [private]

Definition at line 35 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and Run().

Definition at line 36 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and Run().

Int_t AtNuDataFilterNtuple::fTime [private]

Definition at line 39 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and Run().

Definition at line 37 of file AtNuDataFilterNtuple.h.

Referenced by OpenFile(), Reset(), and Run().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1