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

PhysicsNtuple/Event.cxx

Go to the documentation of this file.
00001 // $Id: Event.cxx,v 1.24 2009/10/15 18:30:13 jyuko Exp $
00002 
00003 // C++
00004 #include <cassert>
00005 #include <climits>
00006 #include <cmath>
00007 #include <iostream>
00008 
00009 // Local
00010 #include "PhysicsNtuple/Shower.h"
00011 #include "PhysicsNtuple/Track.h"
00012 
00013 // Local
00014 #include "PhysicsNtuple/Event.h"
00015 
00016 using namespace std;
00017 
00018 //-------------------------------------------------------------------
00019 Anp::Event::Event()
00020    :fBasic(),
00021     fNu(),
00022     fVtx(),
00023     index(-1000),
00024     gev(-1.0e6),
00025     pid(-1.0e6),
00026     fData(),
00027     fShower(),
00028     fTrack()
00029 {
00030 }
00031 
00032 //-------------------------------------------------------------------
00033 Anp::Event::~Event()
00034 {
00035 }
00036 
00037 //----------------------------------------------------------------------
00038 void Anp::Event::Clear()
00039 {
00040    fBasic.Clear();
00041    fNu.Clear();
00042    fVtx.Clear();
00043 
00044    index = -10000;
00045    gev   = -1.0e6;
00046    pid   = -1.0e6;
00047 
00048    fData.clear();
00049    fShower.clear();
00050    fTrack.clear();
00051 }
00052 
00053 //----------------------------------------------------------------------
00054 void Anp::Event::ClearData()
00055 { 
00056    fData.clear();
00057 }
00058 
00059 //---------------------------------------------------------------------- 
00060 bool Anp::Event::Add(const int key, const float data)
00061 { 
00062    //
00063    // Add data at key, if key does not already exits 
00064    //
00065 
00066    assert(std::abs(key) < SHRT_MAX && "key is out of range");
00067    
00068    if(KeyExists(key))
00069    {
00070       cerr << "Event::Add(" << key << ") - key already exists" << endl;
00071       return false;
00072    }
00073    
00074    fData.push_back(Anp::Data(static_cast<short>(key), data));
00075    return true;
00076 }
00077 
00078 //----------------------------------------------------------------------
00079 bool Anp::Event::FirstShower(const short index) const
00080 {
00081    if(fShower.empty())
00082    {
00083       return false;
00084    }
00085    
00086    return (fShower.front() == index);
00087 }
00088 
00089 //----------------------------------------------------------------------
00090 float Anp::Event::DataAt(const short key) const
00091 {
00092    //
00093    // Return data at key, if key exits 
00094    //
00095 
00096    const DataIter it = find(fData.begin(), fData.end(), key);
00097    if(it == fData.end())
00098    {
00099       return -999.0;
00100    }
00101    
00102    return it -> Data();
00103 }
00104 
00105 //----------------------------------------------------------------------
00106 void Anp::Event::Print(ostream &os) const
00107 {
00108    os << "Event::Print" << endl
00109       << "   index = " << index << endl
00110       << "   gev = " << gev << endl
00111       << "   nshower = " << GetNShowers() << endl
00112       << "   ntrack = " << GetNTracks() << endl;
00113    
00114    for(DataVec::const_iterator dit = fData.begin(); dit != fData.end(); ++dit)
00115    {
00116       os  << "   (key, data) = (" << dit -> Key() << ", " << dit -> Data() << ")" << endl;
00117    }
00118    
00119    fBasic.Print(os);
00120    fNu.Print(os);
00121    fVtx.Print(os);
00122 }
00123 
00124 //----------------------------------------------------------------------
00125 bool Anp::operator==(const Event  &event, const Shower &shower)
00126 {
00127    return event.MatchShower(shower.ShowerIndex());
00128 }
00129 
00130 //----------------------------------------------------------------------
00131 bool Anp::operator==(const Shower &shower, const Event &event)
00132 {
00133    return event.MatchShower(shower.ShowerIndex());
00134 }
00135 
00136 //----------------------------------------------------------------------
00137 bool Anp::operator==(const Track &track, const Event &event)
00138 {
00139    return event.MatchTrack(track.TrackIndex());
00140 }
00141 
00142 //----------------------------------------------------------------------
00143 bool Anp::operator==(const Event &event, const Track &track)
00144 {
00145    return event.MatchTrack(track.TrackIndex());
00146 }

Generated on Mon Feb 15 11:06:39 2010 for loon by  doxygen 1.3.9.1