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

Anp::PlotTime Class Reference

#include <PlotTime.h>

Inheritance diagram for Anp::PlotTime:

Anp::AlgSnarl Anp::Base List of all members.

Public Member Functions

 PlotTime ()
virtual ~PlotTime ()
bool Run (Record &record)
void Config (const Registry &reg)
void Set (TDirectory *dir)
void End (const DataBlock &)

Private Types

typedef std::map< int, Anp::Handle<
Anp::HistTime > > 
PlotMap

Private Member Functions

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

Private Attributes

std::string fDirName
TDirectory * fDir
bool fPlot
int fNMiss
int fNFail
double fPotCut
double fPotDay
double fPotHour
PlotMap fMap
TH1 * fRatePerDay
TH1 * fRatePerHour
TH1 * fProtonsDay
TH1 * fProtonsHour
TH1 * fProtonsvsSol
TH1 * fProtonsvsSid
TH1 * fNEventsDay
TH1 * fNEventsHour
TH1 * fNEventsvsSol
TH1 * fNEventsvsSid

Member Typedef Documentation

typedef std::map<int, Anp::Handle<Anp::HistTime> > Anp::PlotTime::PlotMap [private]
 

Definition at line 104 of file PlotTime.h.


Constructor & Destructor Documentation

Anp::PlotTime::PlotTime  ) 
 

Definition at line 217 of file PlotTime.cxx.

00218    :fDirName("time"),
00219     fDir(0),
00220     fPlot(false),
00221     fNMiss(0),
00222     fNFail(0),
00223     fPotCut(1.0e2),
00224     fPotDay(1.0e5),
00225     fPotHour(1.0e4)
00226 {
00227 }

Anp::PlotTime::~PlotTime  )  [virtual]
 

Definition at line 230 of file PlotTime.cxx.

00231 {
00232 }


Member Function Documentation

void Anp::PlotTime::Config const Registry reg  )  [virtual]
 

Reimplemented from Anp::AlgSnarl.

Definition at line 270 of file PlotTime.cxx.

References fDirName, fPotCut, fPotDay, fPotHour, Registry::Get(), Registry::KeyExists(), and reg.

00271 {
00272    const char *value_char = 0;
00273    if(reg.Get("PlotTimeDirName", value_char) && value_char)
00274    {
00275       fDirName = value_char;
00276    }
00277 
00278    reg.Get("PlotTimePotCut",  fPotCut);
00279    reg.Get("PlotTimePotDay",  fPotDay);
00280    reg.Get("PlotTimePotHour", fPotHour);
00281 
00282    if(reg.KeyExists("PrintConfig"))
00283    {
00284       cout << "PlotTime::Config" << endl
00285            << "   DirName = " << fDirName << endl
00286            << "   PotCut = " << fPotCut << endl
00287            << "   PotDay = " << fPotDay << endl
00288            << "   PotHour = " << fPotHour << endl;
00289    }
00290 }

void Anp::PlotTime::End const DataBlock  )  [virtual]
 

Reimplemented from Anp::AlgSnarl.

Definition at line 323 of file PlotTime.cxx.

References fDir, fMap, fNEventsDay, fNEventsHour, fNEventsvsSid, fNEventsvsSol, fNFail, fPotDay, fPotHour, fProtonsDay, fProtonsHour, fProtonsvsSid, fProtonsvsSol, fRatePerDay, fRatePerHour, and Anp::SetDir().

00324 {
00325    if(!fDir || !fPlot)
00326    {
00327       return;
00328    }
00329 
00330    if(fNFail > 0)
00331    {
00332       cout << "PlotTime::End - failed to add " << fNFail << " snarls" << endl;
00333    }
00334 
00335    unsigned secs_beg = 0, secs_end = 0;
00336    for(PlotMap::iterator pit = fMap.begin(); pit != fMap.end(); ++pit)
00337    {
00338       Handle<HistTime> hist = pit -> second;
00339 
00340       if(pit == fMap.begin())
00341       {
00342          secs_beg = hist -> GetSecs();
00343          secs_end = hist -> GetSecs();
00344       }
00345       else
00346       {
00347          secs_beg = std::min<int>(secs_beg, hist -> GetSecs());
00348          secs_end = std::max<int>(secs_end, hist -> GetSecs());
00349       }
00350    }
00351 
00352    const int nhours = 24 + (secs_end - secs_beg)/3600;
00353    const int ndays  =  1 + (secs_end - secs_beg)/(24*3600);
00354    
00355    TH1 *hday  = 0;
00356    TH1 *hhour = 0;
00357 
00358    if(nhours > 1)
00359    {
00360       hhour = new TH1D("rate_per_hour_vs_time", "rate_per_hour_vs_time", nhours, 0, nhours);
00361       Anp::SetDir(hhour, fDir);
00362    }
00363    if(ndays > 1)
00364    {
00365       hday = new TH1D("rate_per_day_vs_time", "rate_per_day_vs_time", ndays, 0, ndays);
00366       Anp::SetDir(hday, fDir);
00367    }
00368 
00369    for(PlotMap::iterator pit = fMap.begin(); pit != fMap.end(); ++pit)
00370    {
00371       Handle<HistTime> hist = pit -> second;
00372 
00373       const double hour = double(hist -> GetSecs() - secs_beg)/3600.0;
00374       const double day  = double(hist -> GetSecs() - secs_beg)/(24.0*3600.0);
00375 
00376       const pair<int, double> aspill = hist -> GetSpills();
00377 
00378       if(aspill.first > 0 && aspill.second > fPotCut)
00379       {
00380          const double drate  = aspill.first*fPotDay/aspill.second;
00381          const double derror = drate*(0.01 + std::pow(aspill.first, -0.5));
00382 
00383          fNEventsDay -> Fill(aspill.first);
00384          fProtonsDay -> Fill(aspill.second);
00385          fRatePerDay -> Fill(drate);
00386          
00387          hist -> FillSol(fProtonsvsSol, "protons");
00388          hist -> FillSol(fNEventsvsSol, "nevents");
00389 
00390          hist -> FillSid(fProtonsvsSid, "protons");
00391          hist -> FillSid(fNEventsvsSid, "nevents");
00392 
00393          if(hday)
00394          {
00395             const int ibin = hday -> FindBin(day);
00396             hday -> SetBinContent(ibin, drate);
00397             hday -> SetBinError(ibin, derror);
00398          }
00399       }
00400       
00401       for(int ihour = 0; ihour < 24; ++ihour)
00402       {
00403          const pair<int, double> hspill = hist -> GetSpills(ihour);
00404          
00405          if(hspill.first > 0 && hspill.second > fPotCut)
00406          {
00407             const double hrate  = hspill.first*fPotHour/hspill.second;
00408             const double herror = hrate*(0.01 + std::pow(hspill.first, -0.5));
00409 
00410             fNEventsHour -> Fill(hspill.first);
00411             fProtonsHour -> Fill(hspill.second);
00412             fRatePerHour -> Fill(hrate);
00413 
00414             if(hhour)
00415             {
00416                const int ibin = hhour -> FindBin(hour + ihour);
00417                hhour -> SetBinContent(ibin, hrate);
00418                hhour -> SetBinError(ibin, herror);
00419             }
00420          }
00421       }
00422    }
00423 }

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

Definition at line 426 of file PlotTime.cxx.

References fDir, and Anp::SetDir().

00427 {
00428    TH1 *h = HistMan::Instance().CreateTH1(key, "time");
00429    if(h)
00430    {
00431       Anp::SetDir(h, fDir, name);
00432    }
00433    else
00434    {
00435       ++fNMiss;
00436    }
00437 
00438    return h;
00439 }

bool Anp::PlotTime::Run Record record  )  [virtual]
 

Implements Anp::AlgSnarl.

Definition at line 235 of file PlotTime.cxx.

References fDir, fMap, Anp::Record::GetHeader(), Anp::Header::NSec(), Anp::Handle< T >::release(), and Anp::Header::Sec().

00236 {
00237 
00238    const Header &header = record.GetHeader();
00239    const VldTimeStamp time(header.Sec(), header.NSec());   
00240    const int date = time.GetDate();
00241 
00242    PlotMap::iterator hit = fMap.find(date);
00243    if(hit == fMap.end())
00244    {
00245       Handle<HistTime> hist(new HistTime(time));
00246 
00247       //
00248       // Create histograms
00249       //
00250       if(!(hist -> Make(fDir)))
00251       {
00252          hist.release();
00253       }
00254 
00255       hit = fMap.insert(PlotMap::value_type(date, hist)).first;
00256    }
00257    
00258    if((hit -> second).valid())
00259    {
00260       if(!(hit -> second -> Fill(record, time)))
00261       {
00262          ++fNFail;
00263       }
00264    }
00265 
00266    return true;
00267 }

void Anp::PlotTime::Set TDirectory *  dir  )  [virtual]
 

Reimplemented from Anp::AlgSnarl.

Definition at line 293 of file PlotTime.cxx.

References fDir, fDirName, fNEventsDay, fNEventsHour, fNEventsvsSid, fNEventsvsSol, fNMiss, fPlot, fProtonsDay, fProtonsHour, fProtonsvsSid, fProtonsvsSol, fRatePerDay, fRatePerHour, and Anp::GetDir().

00294 {
00295    fPlot = false;
00296 
00297    if(!dir) return;
00298 
00299    fDir = Anp::GetDir(fDirName, dir);
00300 
00301    fRatePerDay   = PlotTime::GetTH1("rate_per_day");
00302    fRatePerHour  = PlotTime::GetTH1("rate_per_hour");
00303    fProtonsDay   = PlotTime::GetTH1("protons_day");
00304    fProtonsHour  = PlotTime::GetTH1("protons_hour");
00305    fProtonsvsSol = PlotTime::GetTH1("protons_vs_time", "protons_vs_sol");
00306    fProtonsvsSid = PlotTime::GetTH1("protons_vs_time", "protons_vs_sid");
00307    fNEventsDay   = PlotTime::GetTH1("nevents_day");
00308    fNEventsHour  = PlotTime::GetTH1("nevents_hour");
00309    fNEventsvsSol = PlotTime::GetTH1("nevents_vs_time", "nevents_vs_sol");
00310    fNEventsvsSid = PlotTime::GetTH1("nevents_vs_time", "nevents_vs_sid");
00311 
00312    if(fNMiss == 0)
00313    {
00314       fPlot = true;
00315    }
00316    else
00317    {
00318       cerr << "PlotTime::Set - missed " << fNMiss << " histograms" << endl;
00319    }
00320 }


Member Data Documentation

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

Definition at line 109 of file PlotTime.h.

Referenced by End(), GetTH1(), Run(), and Set().

std::string Anp::PlotTime::fDirName [private]
 

Definition at line 108 of file PlotTime.h.

Referenced by Config(), and Set().

PlotMap Anp::PlotTime::fMap [private]
 

Definition at line 119 of file PlotTime.h.

Referenced by End(), and Run().

TH1* Anp::PlotTime::fNEventsDay [private]
 

Definition at line 127 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fNEventsHour [private]
 

Definition at line 128 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fNEventsvsSid [private]
 

Definition at line 130 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fNEventsvsSol [private]
 

Definition at line 129 of file PlotTime.h.

Referenced by End(), and Set().

int Anp::PlotTime::fNFail [private]
 

Definition at line 113 of file PlotTime.h.

Referenced by End().

int Anp::PlotTime::fNMiss [private]
 

Definition at line 112 of file PlotTime.h.

Referenced by Set().

bool Anp::PlotTime::fPlot [private]
 

Definition at line 111 of file PlotTime.h.

Referenced by Set().

double Anp::PlotTime::fPotCut [private]
 

Definition at line 115 of file PlotTime.h.

Referenced by Config().

double Anp::PlotTime::fPotDay [private]
 

Definition at line 116 of file PlotTime.h.

Referenced by Config(), and End().

double Anp::PlotTime::fPotHour [private]
 

Definition at line 117 of file PlotTime.h.

Referenced by Config(), and End().

TH1* Anp::PlotTime::fProtonsDay [private]
 

Definition at line 123 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fProtonsHour [private]
 

Definition at line 124 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fProtonsvsSid [private]
 

Definition at line 126 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fProtonsvsSol [private]
 

Definition at line 125 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fRatePerDay [private]
 

Definition at line 121 of file PlotTime.h.

Referenced by End(), and Set().

TH1* Anp::PlotTime::fRatePerHour [private]
 

Definition at line 122 of file PlotTime.h.

Referenced by End(), and Set().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:10:34 2010 for loon by  doxygen 1.3.9.1