Anp::PlotSnarl Class Reference

#include <PlotSnarl.h>

Inheritance diagram for Anp::PlotSnarl:
Anp::AlgSnarl Anp::Base

List of all members.

Public Member Functions

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

Private Member Functions

void Plot (int key, float data)
TH1 * GetTH1 (const std::string &key, const std::string &name="")

Private Attributes

TDirectory * fDir
std::string fDirName
std::map< int, TH1 * > fHist
double fTorMin
double fTorMax
DataBlock fBlock
bool fPlot
int fNMiss
TH1 * fTimeEvent
TH1 * fTimeStrip

Detailed Description

Definition at line 22 of file PlotSnarl.h.


Constructor & Destructor Documentation

Anp::PlotSnarl::PlotSnarl (  ) 

Definition at line 28 of file PlotSnarl.cxx.

00029    :fDir(0),
00030     fDirName("snarl"),
00031     fTorMin(-1.0),
00032     fTorMax(-1.0),
00033     fPlot(false),
00034     fNMiss(0)
00035 {
00036 }

Anp::PlotSnarl::~PlotSnarl (  )  [virtual]

Definition at line 39 of file PlotSnarl.cxx.

00040 {
00041 }


Member Function Documentation

void Anp::PlotSnarl::Config ( const Registry reg  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 86 of file PlotSnarl.cxx.

References fDirName, fTorMax, fTorMin, Registry::Get(), and Registry::KeyExists().

00087 {
00088    //
00089    // Configure self
00090    //
00091    
00092    reg.Get("PlotSnarlTorMin", fTorMin);
00093    reg.Get("PlotSnarlTorMax", fTorMax);
00094 
00095    const char *value_char = 0;
00096    if(reg.Get("PlotSnarlDirName", value_char))
00097    {
00098       fDirName = value_char;
00099    }
00100 
00101    if(reg.KeyExists("PrintConfig"))
00102    {
00103       cout << "PlotSnarl::Config" << endl
00104            << "   DirName = " << fDirName << endl
00105            << "   TorMin = " << fTorMin << endl
00106            << "   TorMax = " << fTorMax << endl;
00107    }
00108 }

void Anp::PlotSnarl::End ( const DataBlock block  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 136 of file PlotSnarl.cxx.

References fBlock, fDir, and DataBlock::SetInput().

00137 {
00138    //
00139    // Write total toroid information
00140    //
00141 
00142    fBlock.SetInput(block);
00143 
00144    if(fDir)
00145    {
00146       fDir -> WriteTObject(&fBlock, "block", "Overwrite");
00147    }
00148 }

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

Definition at line 177 of file PlotSnarl.cxx.

References Anp::HistMan::CreateTH1(), fDir, fNMiss, Anp::HistMan::Instance(), and Anp::SetDir().

Referenced by Set().

00178 {
00179    TH1 *h = HistMan::Instance().CreateTH1(key, "snarl");
00180    if(h)
00181    {
00182       Anp::SetDir(h, fDir, name);
00183    }
00184    else
00185    {
00186       ++fNMiss;
00187    }
00188 
00189    return h;
00190 }

void Anp::PlotSnarl::Plot ( int  key,
float  data 
) [private]

Definition at line 151 of file PlotSnarl.cxx.

References Anp::HistMan::CreateTH1(), fDir, fHist, Anp::HistMan::Instance(), Munits::second, and Anp::SetDir().

Referenced by Run().

00152 {
00153    //
00154    // Find key and fill histogram with data
00155    //
00156    if(!fDir) return;
00157 
00158    map<int, TH1 *>::iterator hit = fHist.find(key);
00159    if(hit == fHist.end())
00160    {
00161       TH1 *h = HistMan::Instance().CreateTH1(key, "snarl");
00162       if(h)
00163       {
00164          Anp::SetDir(h, fDir);
00165       }
00166 
00167       hit = fHist.insert(map<int, TH1 *>::value_type(key, h)).first;
00168    }
00169 
00170    if(hit -> second)
00171    {
00172       hit -> second -> Fill(data);
00173    }
00174 }

bool Anp::PlotSnarl::Run ( Record record  )  [virtual]

Implements Anp::AlgSnarl.

Definition at line 44 of file PlotSnarl.cxx.

References DataBlock::Add(), Anp::Record::DataBeg(), Anp::Record::DataEnd(), Anp::Record::EventBeg(), Anp::Record::EventEnd(), fBlock, fDir, fPlot, fTimeEvent, fTimeStrip, fTorMax, fTorMin, Anp::Record::GetHeader(), MinTime, Anp::Header::NSec(), Plot(), Anp::Record::StripBeg(), Anp::Record::StripEnd(), Anp::Header::Tor101(), and Anp::Header::TorTgt().

00045 {
00046    //
00047    // Plot snarl data
00048    //
00049    if(!fDir || !fPlot) return true;
00050 
00051    if(fTorMin > 0.0)
00052    {
00053       if     (record.GetHeader().TorTgt() < fTorMin) return true;
00054       else if(record.GetHeader().TorTgt() > fTorMax) return true;
00055    }
00056 
00057    fBlock.Add(record);
00058 
00059    for(DataIter idata = record.DataBeg(); idata != record.DataEnd(); ++idata)
00060    {
00061       PlotSnarl::Plot(idata -> Key(), idata -> Data());
00062    }
00063 
00064    //
00065    // Plot toroid reading
00066    //
00067    PlotSnarl::Plot(10, record.GetHeader().Tor101());
00068    PlotSnarl::Plot(11, record.GetHeader().TorTgt());
00069 
00070    const double start_time = record.GetHeader().NSec();
00071 
00072    for(EventIter ievent = record.EventBeg(); ievent != record.EventEnd(); ++ievent)
00073    {
00074       fTimeEvent -> Fill(1.0e9*ievent -> GetBasic().MinTime() - start_time);
00075    }
00076 
00077    for(StripIter istrip = record.StripBeg(); istrip != record.StripEnd(); ++istrip)
00078    {
00079       fTimeStrip -> Fill(istrip -> Time() - start_time);
00080    }
00081 
00082    return true;
00083 }

void Anp::PlotSnarl::Set ( TDirectory *  dir  )  [virtual]

Reimplemented from Anp::AlgSnarl.

Definition at line 111 of file PlotSnarl.cxx.

References fDir, fDirName, fNMiss, fPlot, fTimeEvent, fTimeStrip, Anp::GetDir(), and GetTH1().

00112 {
00113    //
00114    // Get pointer to TDirectory where histograms will be saved
00115    //
00116    fPlot = false;
00117 
00118    if(!dir) return;
00119 
00120    fDir = Anp::GetDir(fDirName.c_str(), dir);
00121 
00122    fTimeEvent = PlotSnarl::GetTH1("time_event");
00123    fTimeStrip = PlotSnarl::GetTH1("time_strip");
00124 
00125    if(fNMiss == 0)
00126    {
00127       fPlot = true;
00128    }
00129    else
00130    {
00131       cerr << "PlotSnarl::Set - missed " << fNMiss << " histograms" << endl;
00132    }
00133 }


Member Data Documentation

Definition at line 54 of file PlotSnarl.h.

Referenced by End(), and Run().

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

Definition at line 45 of file PlotSnarl.h.

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

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

Definition at line 47 of file PlotSnarl.h.

Referenced by Config(), and Set().

std::map<int, TH1 *> Anp::PlotSnarl::fHist [private]

Definition at line 49 of file PlotSnarl.h.

Referenced by Plot().

int Anp::PlotSnarl::fNMiss [private]

Definition at line 57 of file PlotSnarl.h.

Referenced by GetTH1(), and Set().

bool Anp::PlotSnarl::fPlot [private]

Definition at line 56 of file PlotSnarl.h.

Referenced by Run(), and Set().

Definition at line 59 of file PlotSnarl.h.

Referenced by Run(), and Set().

Definition at line 60 of file PlotSnarl.h.

Referenced by Run(), and Set().

double Anp::PlotSnarl::fTorMax [private]

Definition at line 52 of file PlotSnarl.h.

Referenced by Config(), and Run().

double Anp::PlotSnarl::fTorMin [private]

Definition at line 51 of file PlotSnarl.h.

Referenced by Config(), and Run().


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

Generated on 21 Jun 2018 for loon by  doxygen 1.6.1