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

Anp::PlotVtx Class Reference

#include <PlotVtx.h>

Inheritance diagram for Anp::PlotVtx:

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

Public Member Functions

 PlotVtx ()
virtual ~PlotVtx ()
bool Run (Record &record)
bool Run (Event &event, const Record &record, bool pass)
void Config (const Registry &reg)
void Set (TDirectory *dir)
void End (const DataBlock &)

Private Types

typedef std::map< std::string,
Anp::Handle< Anp::HistVtx > > 
PlotMap

Private Member Functions

bool Fill (const std::string &input, const Vertex &vtx, double weight)
bool Fill (const std::string &input, const Vertex &lhs, const Vertex &rhs, double weight)
Anp::Handle< Anp::HistVtxGetPlot (const std::string &input)

Private Attributes

std::string fDirName
std::string fInput
TDirectory * fDir
bool fInit
bool fPlot2d
bool fPlotDiff
double fCenterX
double fCenterY
PlotMap fMap

Member Typedef Documentation

typedef std::map<std::string, Anp::Handle<Anp::HistVtx> > Anp::PlotVtx::PlotMap [private]
 

Definition at line 110 of file PlotVtx.h.


Constructor & Destructor Documentation

Anp::PlotVtx::PlotVtx  ) 
 

Definition at line 233 of file PlotVtx.cxx.

00234    :fDirName("vertex"),
00235     fInput("all"),
00236     fDir(0),
00237     fInit(false),
00238     fPlot2d(true),
00239     fPlotDiff(false),
00240     fCenterX(1.4885),
00241     fCenterY(0.1397)
00242 {
00243 }

Anp::PlotVtx::~PlotVtx  )  [virtual]
 

Definition at line 246 of file PlotVtx.cxx.

00247 {
00248 }


Member Function Documentation

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

Reimplemented from Anp::AlgEvent.

Definition at line 323 of file PlotVtx.cxx.

References fCenterX, fCenterY, fDirName, fInput, fPlot2d, fPlotDiff, Registry::Get(), Registry::KeyExists(), Anp::Read(), and reg.

00324 {
00325    const char *value_char = 0;
00326    if(reg.Get("PlotVtxDirName", value_char) && value_char)
00327    {
00328       fDirName = value_char;
00329    }
00330 
00331    value_char = 0;
00332    if(reg.Get("PlotVtxInput", value_char) && value_char)
00333    {
00334       fInput = value_char;
00335    }
00336    
00337    Anp::Read(reg, "PlotVtx2d",   fPlot2d);
00338    Anp::Read(reg, "PlotVtxDiff", fPlotDiff);
00339 
00340    reg.Get("PlotVtxCenterX", fCenterX);
00341    reg.Get("PlotVtxCenterY", fCenterY);
00342 
00343    if(reg.KeyExists("PrintConfig"))
00344    {
00345       cout << "PlotVtx::Config" << endl
00346            << "   DirName = " << fDirName << endl
00347            << "   Input = " << fInput << endl
00348            << "   Plot2d = " << fPlot2d << endl
00349            << "   PlotDiff = " << fPlotDiff << endl
00350            << "   CenterX = " << fCenterX << endl
00351            << "   CenterY = " << fCenterY << endl;
00352    }
00353 }

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

Reimplemented from Anp::AlgEvent.

Definition at line 369 of file PlotVtx.cxx.

References fDir, and fMap.

00370 {
00371    fMap.clear();
00372    fDir = 0;
00373 }

bool Anp::PlotVtx::Fill const std::string &  input,
const Vertex lhs,
const Vertex rhs,
double  weight
[private]
 

Definition at line 394 of file PlotVtx.cxx.

References Fill(), fInput, and Anp::Handle< T >::valid().

00395 {
00396    if(!fPlotDiff)
00397    {
00398       return false;
00399    }
00400 
00401    if(fInput != "all" && fInput != input)
00402    {
00403       return false;
00404    }
00405 
00406    Handle<HistVtx> hist = PlotVtx::GetPlot(input);
00407    if(hist.valid())
00408    {
00409       return hist -> Fill(lhs, rhs, weight);
00410    }
00411 
00412    return false;
00413 }

bool Anp::PlotVtx::Fill const std::string &  input,
const Vertex vtx,
double  weight
[private]
 

Definition at line 376 of file PlotVtx.cxx.

References fInput, and Anp::Handle< T >::valid().

Referenced by Fill().

00377 {
00378    if(fInput != "all" && fInput != input)
00379    {
00380       return false;
00381    }
00382 
00383    Handle<HistVtx> hist = PlotVtx::GetPlot(input);
00384    if(hist.valid())
00385    {
00386       return hist -> Fill(vtx, weight);
00387    }
00388 
00389    return false;
00390 }

Anp::Handle< Anp::HistVtx > Anp::PlotVtx::GetPlot const std::string &  input  )  [private]
 

Definition at line 416 of file PlotVtx.cxx.

References fCenterX, fCenterY, fDir, fMap, Anp::GetDir(), option, and Anp::Handle< T >::release().

00417 {
00418    //
00419    // Find, create first, histogram object
00420    //
00421 
00422    PlotMap::iterator hit = fMap.find(input);
00423    if(hit == fMap.end())
00424    {
00425       Handle<HistVtx> hist(new HistVtx());
00426       TDirectory *dir = Anp::GetDir(input, fDir);
00427 
00428       if(dir)
00429       {
00430          hist -> SetCenter(fCenterX, fCenterY);
00431          
00432          string option;
00433          if(fPlot2d)   option += "plot_2d ";
00434          if(fPlotDiff) option += "plot_diff ";
00435          
00436          //
00437          // Attempt to create histograms
00438          //
00439          if(!(hist -> Make(dir, option))) hist.release();
00440       }
00441       else
00442       {
00443          hist.release();
00444       }
00445 
00446       hit = fMap.insert(PlotMap::value_type(input, hist)).first;
00447    }
00448 
00449    return hit -> second;
00450 }

bool Anp::PlotVtx::Run Event event,
const Record record,
bool  pass
[virtual]
 

Implements Anp::AlgEvent.

Definition at line 291 of file PlotVtx.cxx.

References Anp::Event::GetVtx(), Anp::LongestTrack(), Anp::PrimaryShower(), Anp::Record::ShowerEnd(), Anp::ShowerIter, Anp::Record::TrackEnd(), Anp::TrackIter, and Anp::Event::Weight().

00292 {
00293    //
00294    // Plot event vertex 
00295    //
00296    if(!pass || !fDir) return true;
00297 
00298    PlotVtx::Fill("event", event.GetVtx(), event.Weight());
00299 
00300    const TrackIter  itrack  = Anp::LongestTrack (event, record);
00301    const ShowerIter ishower = Anp::PrimaryShower(event, record);
00302 
00303    if(ishower != record.ShowerEnd())
00304    {
00305       PlotVtx::Fill("event_shower_prm", ishower -> GetVtx(), event.Weight());
00306    }
00307 
00308    if(itrack != record.TrackEnd())
00309    {
00310       PlotVtx::Fill("event_track_beg", itrack -> GetBegVtx(), event.Weight());
00311       PlotVtx::Fill("event_track_end", itrack -> GetEndVtx(), event.Weight());
00312 
00313       if(ishower != record.ShowerEnd())
00314       {
00315          PlotVtx::Fill("event_shower_prm", itrack -> GetEndVtx(), ishower -> GetVtx(), event.Weight());
00316       }
00317    }
00318    
00319    return true;
00320 }

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

Implements Anp::AlgSnarl.

Definition at line 251 of file PlotVtx.cxx.

References Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), Anp::EventIterator, Anp::Record::FindTruth(), fPlotDiff, Anp::Record::GetHeader(), Anp::Header::IsData(), Anp::Record::TrackBeg(), Anp::Record::TrackEnd(), Anp::TrackIter, Anp::Record::TruthBeg(), Anp::Record::TruthEnd(), and Anp::TruthIter.

00252 {
00253    //
00254    // Plot vertex information for events, tracks and showers
00255    //
00256    if(!fDir) return true;
00257 
00258    for(EventIterator ievent = record.EventBegIterator(); ievent != record.EventEndIterator(); ++ievent)
00259    {      
00260       PlotVtx::Run(*ievent, record, true);
00261    }
00262 
00263    for(TrackIter itrack = record.TrackBeg(); itrack != record.TrackEnd(); ++itrack)
00264    {
00265       PlotVtx::Fill("tracks_beg", itrack -> GetBegVtx(), itrack -> Weight());
00266       PlotVtx::Fill("tracks_end", itrack -> GetEndVtx(), itrack -> Weight());
00267    }
00268    
00269    for(TruthIter itruth = record.TruthBeg(); itruth != record.TruthEnd(); ++itruth)
00270    {
00271       PlotVtx::Fill("truths", itruth -> GetVtx(), itruth -> Weight());
00272    }
00273 
00274    if(fPlotDiff && !record.GetHeader().IsData())
00275    {
00276       for(TrackIter itrack = record.TrackBeg(); itrack != record.TrackEnd(); ++itrack)
00277       {
00278          const TruthIter itruth = record.FindTruth(*itrack);
00279          if(itruth != record.TruthEnd())
00280          {
00281             PlotVtx::Fill("truth_minus_track", itruth->GetVtx(), itrack->Weight());
00282             PlotVtx::Fill("truth_minus_track", itruth->GetVtx(), itrack->GetBegVtx(),itrack->Weight());
00283          }
00284       }
00285    }
00286 
00287    return true;
00288 }

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

Reimplemented from Anp::AlgEvent.

Definition at line 356 of file PlotVtx.cxx.

References fDir, fDirName, fInit, and Anp::GetDir().

00357 {
00358    fInit = false;
00359 
00360    if(!dir)
00361    {
00362       return;
00363    }
00364 
00365    fDir = Anp::GetDir(fDirName, dir);
00366 }


Member Data Documentation

double Anp::PlotVtx::fCenterX [private]
 

Definition at line 131 of file PlotVtx.h.

Referenced by Config(), and GetPlot().

double Anp::PlotVtx::fCenterY [private]
 

Definition at line 132 of file PlotVtx.h.

Referenced by Config(), and GetPlot().

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

Definition at line 125 of file PlotVtx.h.

Referenced by End(), GetPlot(), and Set().

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

Definition at line 122 of file PlotVtx.h.

Referenced by Config(), and Set().

bool Anp::PlotVtx::fInit [private]
 

Definition at line 127 of file PlotVtx.h.

Referenced by Set().

std::string Anp::PlotVtx::fInput [private]
 

Definition at line 123 of file PlotVtx.h.

Referenced by Config(), and Fill().

PlotMap Anp::PlotVtx::fMap [private]
 

Definition at line 134 of file PlotVtx.h.

Referenced by End(), and GetPlot().

bool Anp::PlotVtx::fPlot2d [private]
 

Definition at line 128 of file PlotVtx.h.

Referenced by Config().

bool Anp::PlotVtx::fPlotDiff [private]
 

Definition at line 129 of file PlotVtx.h.

Referenced by Config(), and Run().


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