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

Anp::HistTime Class Reference

#include <PlotTime.h>

Inheritance diagram for Anp::HistTime:

Anp::Base List of all members.

Public Member Functions

 HistTime ()
 HistTime (const VldTimeStamp &vts)
virtual ~HistTime ()
bool Fill (const Record &record, const VldTimeStamp &time)
bool Make (TDirectory *dir)
int GetDay () const
int GetMonth () const
int GetYear () const
int GetDate () const
int GetSecs () const
const std::pair< int, double > GetSpills (int hour=-1)
void FillSol (TH1 *h, const std::string &option)
void FillSid (TH1 *h, const std::string &option)

Private Member Functions

TH1 * GetTH1 (const std::string &key, const std::string &name="")

Private Attributes

bool fPlot
int fNMiss
unsigned int fDay
unsigned int fMonth
unsigned int fYear
int fDate
int fSecs
TDirectory * fDir
std::map< int, SpillfSpill

Friends

class PlotTime

Constructor & Destructor Documentation

Anp::HistTime::HistTime  ) 
 

Definition at line 31 of file PlotTime.cxx.

00032    :fPlot(false),
00033     fNMiss(0),
00034     fDay(0),
00035     fMonth(0),
00036     fYear(0),
00037     fDate(0),
00038     fSecs(0),
00039     fDir(0)
00040 {
00041 }

Anp::HistTime::HistTime const VldTimeStamp vts  )  [explicit]
 

Definition at line 44 of file PlotTime.cxx.

References fDate, fDay, fMonth, fSecs, fYear, VldTimeStamp::GetDate(), and VldTimeStamp::GetSec().

00045    :fPlot(false),
00046     fNMiss(0),
00047     fDay(0),
00048     fMonth(0),
00049     fYear(0),
00050     fDate(0),
00051     fSecs(0),
00052     fDir(0)
00053 {
00054    fDate = time.GetDate(true, 0, &fYear, &fMonth, &fDay);
00055    
00056    const VldTimeStamp btime(fYear, fMonth, fDay, 0, 0, 0);
00057    fSecs = btime.GetSec();
00058 }

Anp::HistTime::~HistTime  )  [virtual]
 

Definition at line 61 of file PlotTime.cxx.

00062 {
00063 }


Member Function Documentation

bool Anp::HistTime::Fill const Record record,
const VldTimeStamp time
 

Definition at line 66 of file PlotTime.cxx.

References fSpill, Anp::Record::GetHeader(), Anp::Record::GetNEvents(), VldTimeStamp::GetTime(), Anp::HistTime::Spill::hour, min, Anp::HistTime::Spill::nevents, Anp::HistTime::Spill::protons, Anp::HistTime::Spill::seconds, Anp::Header::Tor101(), Anp::Header::TorTgt(), Anp::Header::Tr101D(), and Anp::Header::TrTgtD().

Referenced by FillSid(), and FillSol().

00067 {
00068    //
00069    // Fill histograms if they have been created
00070    //
00071    if(!fPlot) return false;
00072 
00073    unsigned int hour = 0, min = 0, sec = 0;
00074 
00075    const int time_ = time.GetTime(true, 0, &hour, &min, &sec);
00076 
00077    Spill spill;
00078    if     (record.GetHeader().TorTgt() > 0.0) spill.protons = record.GetHeader().TorTgt();
00079    else if(record.GetHeader().TrTgtD() > 0.0) spill.protons = record.GetHeader().TrTgtD();
00080    else if(record.GetHeader().Tr101D() > 0.0) spill.protons = record.GetHeader().Tr101D();
00081    else if(record.GetHeader().Tor101() > 0.0) spill.protons = record.GetHeader().Tor101();
00082    
00083    spill.nevents = record.GetNEvents();
00084    spill.hour    = hour;
00085    spill.seconds = 3600*hour + 60*min + sec;
00086 
00087    return fSpill.insert(map<int, Spill>::value_type(time_, spill)).second;
00088 }

void Anp::HistTime::FillSid TH1 *  h,
const std::string &  option
 

Definition at line 179 of file PlotTime.cxx.

References AstUtil::CalendarToJulian(), fDay, Fill(), fMonth, fSpill, fYear, AstUtil::GSTToLST(), AstUtil::JulianToGAST(), Anp::HistTime::Spill::nevents, option, Anp::HistTime::Spill::protons, and Anp::HistTime::Spill::seconds.

00180 {
00181    if(!h)
00182    {
00183       cerr << "HistTime::FillSid - invalid TH1 pointer" << endl;
00184       return;
00185    }
00186    
00187    for(map<int, Spill>::const_iterator sit = fSpill.begin(); sit != fSpill.end(); ++sit)
00188    {
00189       const Spill &spill = sit -> second;
00190       const double hour = spill.seconds/3600.0;
00191 
00192       double juld = 0.0, gmst = 0.0, lsid = 0.0;
00193 
00194       AstUtil::CalendarToJulian(fYear, fMonth, fDay, hour, juld);
00195       AstUtil::JulianToGAST(juld, gmst);
00196       AstUtil::GSTToLST(gmst, AstUtil::kNearDetLongitude, lsid);
00197 
00198       if(lsid < 0.0 || lsid > 24.0)
00199       {
00200          cerr << "HistTime::Fill - invalid time stamp: " << sit -> first << endl;
00201       }
00202       else
00203       {
00204          if(option.find("protons") != string::npos)
00205          {
00206             h -> Fill(lsid/24.0, spill.protons);
00207          }
00208          if(option.find("nevents") != string::npos)
00209          {
00210             h -> Fill(lsid/24.0, spill.nevents);
00211          }
00212       }
00213    }
00214 }

void Anp::HistTime::FillSol TH1 *  h,
const std::string &  option
 

Definition at line 147 of file PlotTime.cxx.

References Fill(), fSpill, Anp::HistTime::Spill::nevents, option, Anp::HistTime::Spill::protons, and Anp::HistTime::Spill::seconds.

00148 {
00149    if(!h)
00150    {
00151       cerr << "HistTime::FillSol - invalid TH1 pointer" << endl;
00152       return;
00153    }
00154 
00155    const int tsec = 24*3600;
00156    for(map<int, Spill>::const_iterator sit = fSpill.begin(); sit != fSpill.end(); ++sit)
00157    {
00158       const Spill &spill = sit -> second;
00159       
00160       if(spill.seconds <= tsec)
00161       {
00162          if(option.find("protons") != string::npos)
00163          {
00164             h -> Fill(spill.seconds/double(tsec), spill.protons);
00165          }
00166          if(option.find("nevents") != string::npos)
00167          {
00168             h -> Fill(spill.seconds/double(tsec), spill.nevents);
00169          }
00170       }
00171       else
00172       {
00173          cerr << "HistTime::Fill - invalid time stamp: " << sit -> first << endl;
00174       }
00175    }
00176 }

int Anp::HistTime::GetDate  )  const [inline]
 

Definition at line 139 of file PlotTime.h.

00139 { return fDate; }

int Anp::HistTime::GetDay  )  const [inline]
 

Definition at line 136 of file PlotTime.h.

00136 { return fDay; }

int Anp::HistTime::GetMonth  )  const [inline]
 

Definition at line 137 of file PlotTime.h.

00137 { return fMonth; }

int Anp::HistTime::GetSecs  )  const [inline]
 

Definition at line 140 of file PlotTime.h.

00140 { return fSecs; }

const pair< int, double > Anp::HistTime::GetSpills int  hour = -1  ) 
 

Definition at line 128 of file PlotTime.cxx.

References fSpill, Anp::HistTime::Spill::hour, Anp::HistTime::Spill::nevents, and Anp::HistTime::Spill::protons.

00129 {
00130    pair<int, double> spill(0, 0.0);
00131 
00132    for(map<int, Spill>::const_iterator sit = fSpill.begin(); sit != fSpill.end(); ++sit)
00133    {
00134       const Spill &spill_ = sit -> second;
00135 
00136       if(hour < 0 || hour == spill_.hour)
00137       {
00138          spill.first  += spill_.nevents;
00139          spill.second += spill_.protons;
00140       }
00141    }
00142 
00143    return spill;
00144 }

TH1 * Anp::HistTime::GetTH1 const std::string &  key,
const std::string &  name = ""
[private]
 

Definition at line 112 of file PlotTime.cxx.

References fDir, and Anp::SetDir().

00113 {
00114    TH1 *h = HistMan::Instance().CreateTH1(key, "kinem");
00115    if(h)
00116    {
00117       Anp::SetDir(h, fDir, name);
00118    }
00119    else
00120    {
00121       ++fNMiss;
00122    }
00123 
00124    return h;
00125 }

int Anp::HistTime::GetYear  )  const [inline]
 

Definition at line 138 of file PlotTime.h.

00138 { return fYear; }

bool Anp::HistTime::Make TDirectory *  dir  ) 
 

Definition at line 91 of file PlotTime.cxx.

References fDir, fNMiss, and fPlot.

00092 {
00093    fPlot = false;
00094 
00095    if(!dir) return false;
00096 
00097    fDir = dir;
00098 
00099    if(fNMiss == 0)
00100    {
00101       fPlot = true;
00102    }
00103    else
00104    {
00105       cerr << "HistTime::Make - missed " << fNMiss << " histograms" << endl;
00106    }
00107 
00108    return fPlot;
00109 }


Friends And Related Function Documentation

friend class PlotTime [friend]
 

Definition at line 65 of file PlotTime.h.


Member Data Documentation

int Anp::HistTime::fDate [private]
 

Definition at line 74 of file PlotTime.h.

Referenced by HistTime().

unsigned int Anp::HistTime::fDay [private]
 

Definition at line 70 of file PlotTime.h.

Referenced by FillSid(), and HistTime().

TDirectory* Anp::HistTime::fDir [private]
 

Definition at line 77 of file PlotTime.h.

Referenced by GetTH1(), and Make().

unsigned int Anp::HistTime::fMonth [private]
 

Definition at line 71 of file PlotTime.h.

Referenced by FillSid(), and HistTime().

int Anp::HistTime::fNMiss [private]
 

Definition at line 68 of file PlotTime.h.

Referenced by Make().

bool Anp::HistTime::fPlot [private]
 

Definition at line 67 of file PlotTime.h.

Referenced by Make().

int Anp::HistTime::fSecs [private]
 

Definition at line 75 of file PlotTime.h.

Referenced by HistTime().

std::map<int, Spill> Anp::HistTime::fSpill [private]
 

Definition at line 79 of file PlotTime.h.

Referenced by Fill(), FillSid(), FillSol(), and GetSpills().

unsigned int Anp::HistTime::fYear [private]
 

Definition at line 72 of file PlotTime.h.

Referenced by FillSid(), and HistTime().


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:04:08 2008 for loon by  doxygen 1.3.9.1