AtNuDataNtuple Class Reference

#include <AtNuDataNtuple.h>

List of all members.

Public Member Functions

 AtNuDataNtuple ()
 ~AtNuDataNtuple ()
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 * fAtNuDataFile
TTree * fAtNuDataTree
TString fFileName
Int_t fRun
Int_t fSubRun
Int_t fUnixTime
Int_t fDate
Int_t fTime
Int_t fRate
Int_t fGood
AtmosEventfEvent

Detailed Description

Definition at line 13 of file AtNuDataNtuple.h.


Constructor & Destructor Documentation

AtNuDataNtuple::AtNuDataNtuple (  ) 

Definition at line 10 of file AtNuDataNtuple.cxx.

00010                                :
00011   fChain(0),
00012   fEvent(0)
00013 {
00014   this->Reset();
00015 }

AtNuDataNtuple::~AtNuDataNtuple (  ) 

Definition at line 17 of file AtNuDataNtuple.cxx.

00018 {
00019 
00020 }


Member Function Documentation

void AtNuDataNtuple::AddFile ( const char *  file  ) 

Definition at line 39 of file AtNuDataNtuple.cxx.

References fChain.

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

void AtNuDataNtuple::CloseFile (  ) 

Definition at line 81 of file AtNuDataNtuple.cxx.

References fAtNuDataFile, and fAtNuDataTree.

Referenced by Run().

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

void AtNuDataNtuple::OpenFile (  ) 

Definition at line 59 of file AtNuDataNtuple.cxx.

References fAtNuDataFile, fAtNuDataTree, fDate, fFileName, fGood, fRate, fRun, fSubRun, fTime, and fUnixTime.

Referenced by Run().

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

void AtNuDataNtuple::Reset (  ) 

Definition at line 22 of file AtNuDataNtuple.cxx.

References fAtNuDataFile, fAtNuDataTree, fChain, fEvent, and fFileName.

00023 {
00024   if( !fChain ){
00025     fChain = new TChain("ntp","chain");
00026   }
00027 
00028   fChain->Reset();
00029   fChain->SetBranchAddress("evt",&fEvent);
00030  
00031   fAtNuDataFile = 0;
00032   fAtNuDataTree = 0;
00033 
00034   fFileName = "ntpcheck.root";
00035 
00036   return;
00037 }

void AtNuDataNtuple::Run (  ) 

Definition at line 103 of file AtNuDataNtuple.cxx.

References CloseFile(), AtmosEvent::Date, fChain, fDate, fEvent, fGood, fRate, fRun, fSubRun, fTime, fUnixTime, AtNuRunTimes::GoodData(), OpenFile(), AtmosEvent::Run, AtmosEvent::SubRun, AtmosEvent::Time, AtmosEvent::UnixTime, and WriteToFile().

00104 {
00105   std::cout << " *** AtNuDataNtuple::Run() *** " << std::endl;
00106 
00107   // open file
00108   this->OpenFile();
00109 
00110   // loop over events
00111   fUnixTime = -1;
00112   fRun = -1;
00113   fSubRun = -1;
00114   fDate = -1;
00115   fTime = -1;
00116   fRate = 0;
00117   fGood = 0;
00118 
00119   for( Int_t i=0; i<fChain->GetEntries(); i++ ){
00120     fChain->GetEntry(i);
00121 
00122     if( !(fEvent->Run==fRun 
00123        && fEvent->SubRun==fSubRun) ){
00124       std::cout << "  Run: " << fEvent->Run << std::endl;
00125     }
00126 
00127     if( fEvent->UnixTime!=fUnixTime ){
00128 
00129       if( fUnixTime>=0 ){
00130         this->WriteToFile();
00131       }
00132 
00133       fUnixTime = fEvent->UnixTime;
00134       fRun = fEvent->Run;
00135       fSubRun = fEvent->SubRun;
00136       fDate = fEvent->Date;
00137       fTime = fEvent->Time;
00138       fRate = 0;
00139       fGood = AtNuRunTimes::GoodData(fUnixTime);
00140     }
00141 
00142     fRate++;
00143   }
00144 
00145   // write last event
00146   if( fUnixTime>=0 ){
00147     this->WriteToFile();
00148   }
00149 
00150   // close file
00151   this->CloseFile();
00152 
00153   return;
00154 }

void AtNuDataNtuple::SetFileName ( const char *  file  ) 

Definition at line 50 of file AtNuDataNtuple.cxx.

References fFileName.

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

void AtNuDataNtuple::WriteToFile (  ) 

Definition at line 93 of file AtNuDataNtuple.cxx.

References fAtNuDataFile, and fAtNuDataTree.

Referenced by Run().

00094 {
00095   if( fAtNuDataFile ){
00096     TDirectory* tmpd = gDirectory;
00097     fAtNuDataFile->cd();
00098     fAtNuDataTree->Fill();
00099     gDirectory = tmpd;
00100   }
00101 }


Member Data Documentation

Definition at line 33 of file AtNuDataNtuple.h.

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

Definition at line 34 of file AtNuDataNtuple.h.

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

TChain* AtNuDataNtuple::fChain [private]

Definition at line 31 of file AtNuDataNtuple.h.

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

Int_t AtNuDataNtuple::fDate [private]

Definition at line 40 of file AtNuDataNtuple.h.

Referenced by OpenFile(), and Run().

Definition at line 45 of file AtNuDataNtuple.h.

Referenced by Reset(), and Run().

TString AtNuDataNtuple::fFileName [private]

Definition at line 35 of file AtNuDataNtuple.h.

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

Int_t AtNuDataNtuple::fGood [private]

Definition at line 43 of file AtNuDataNtuple.h.

Referenced by OpenFile(), and Run().

Int_t AtNuDataNtuple::fRate [private]

Definition at line 42 of file AtNuDataNtuple.h.

Referenced by OpenFile(), and Run().

Int_t AtNuDataNtuple::fRun [private]

Definition at line 37 of file AtNuDataNtuple.h.

Referenced by OpenFile(), and Run().

Int_t AtNuDataNtuple::fSubRun [private]

Definition at line 38 of file AtNuDataNtuple.h.

Referenced by OpenFile(), and Run().

Int_t AtNuDataNtuple::fTime [private]

Definition at line 41 of file AtNuDataNtuple.h.

Referenced by OpenFile(), and Run().

Int_t AtNuDataNtuple::fUnixTime [private]

Definition at line 39 of file AtNuDataNtuple.h.

Referenced by OpenFile(), 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