Anp::RecordStore Class Reference

#include <RecordStore.h>

List of all members.

Public Types

typedef std::vector< Anp::RecordSnarlVec
typedef std::vector< Anp::EventEventVec
typedef SnarlVec::const_iterator SnarlIter
typedef EventVec::const_iterator EventIter

Public Member Functions

 RecordStore ()
 ~RecordStore ()
void Add (const Record &record)
void NextEvent ()
void PrevEvent ()
void NextSnarl ()
void PrevSnarl ()
bool IsValid () const
void PrintTruth () const
void PrintData () const
unsigned int GetNSnarls () const
unsigned int GetNEvents () const
SnarlIter CurrSnarl () const
EventIter CurrEvent () const
EventIter EventBeg () const
EventIter EventEnd () const
SnarlIter SnarlBeg () const
SnarlIter SnarlEnd () const

Private Member Functions

void LoadSnarl ()
void PrintFirst () const

Private Attributes

SnarlVec fSnarlVec
EventVec fEventVec
SnarlIter fCurrSnarl
EventIter fCurrEvent

Detailed Description

Definition at line 12 of file RecordStore.h.


Member Typedef Documentation

typedef EventVec::const_iterator Anp::RecordStore::EventIter

Definition at line 20 of file RecordStore.h.

typedef std::vector<Anp::Event> Anp::RecordStore::EventVec

Definition at line 17 of file RecordStore.h.

typedef SnarlVec::const_iterator Anp::RecordStore::SnarlIter

Definition at line 19 of file RecordStore.h.

Definition at line 16 of file RecordStore.h.


Constructor & Destructor Documentation

Anp::RecordStore::RecordStore (  ) 

Definition at line 12 of file RecordStore.cxx.

00013    :fSnarlVec(),
00014     fEventVec(),
00015     fCurrSnarl(fSnarlVec.end()),
00016     fCurrEvent(fEventVec.end())
00017 {
00018 }

Anp::RecordStore::~RecordStore (  ) 

Member Function Documentation

void Anp::RecordStore::Add ( const Record record  ) 

Definition at line 21 of file RecordStore.cxx.

References fCurrEvent, fCurrSnarl, fEventVec, and fSnarlVec.

Referenced by Anp::EventDisplay::Add().

00022 {
00023    fSnarlVec.push_back(record);
00024 
00025    fCurrSnarl = fSnarlVec.end();
00026    fCurrEvent = fEventVec.end();
00027 }

Anp::RecordStore::EventIter Anp::RecordStore::CurrEvent (  )  const

Definition at line 62 of file RecordStore.cxx.

References fCurrEvent.

Referenced by Anp::EventDisplay::NewEvent(), PrintData(), Anp::EventDisplay::PrintTab(), and PrintTruth().

00063 {
00064    return fCurrEvent;
00065 }

Anp::RecordStore::SnarlIter Anp::RecordStore::CurrSnarl (  )  const

Definition at line 57 of file RecordStore.cxx.

References fCurrSnarl.

Referenced by Anp::EventDisplay::NewEvent(), Anp::EventDisplay::PrintTab(), and PrintTruth().

00058 {
00059    return fCurrSnarl;
00060 }

Anp::RecordStore::EventIter Anp::RecordStore::EventBeg (  )  const

Definition at line 68 of file RecordStore.cxx.

References fEventVec.

Referenced by LoadSnarl().

00069 {
00070    return fEventVec.begin();
00071 }

Anp::RecordStore::EventIter Anp::RecordStore::EventEnd (  )  const

Definition at line 73 of file RecordStore.cxx.

References fEventVec.

Referenced by LoadSnarl(), and Anp::EventDisplay::PrintTab().

00074 {
00075    return fEventVec.end();
00076 }

unsigned int Anp::RecordStore::GetNEvents (  )  const

Definition at line 51 of file RecordStore.cxx.

References fEventVec.

Referenced by NextSnarl(), PrevSnarl(), and PrintFirst().

00052 {
00053    return fEventVec.size();
00054 }

unsigned int Anp::RecordStore::GetNSnarls (  )  const

Definition at line 46 of file RecordStore.cxx.

References fSnarlVec.

Referenced by LoadSnarl(), NextEvent(), NextSnarl(), PrevEvent(), and PrevSnarl().

00047 {
00048    return fSnarlVec.size();
00049 }

bool Anp::RecordStore::IsValid (  )  const

Definition at line 30 of file RecordStore.cxx.

References fCurrEvent, fCurrSnarl, fEventVec, and fSnarlVec.

Referenced by Anp::EventDisplay::NewEvent(), PrintData(), Anp::EventDisplay::PrintData(), Anp::EventDisplay::PrintTab(), PrintTruth(), and Anp::EventDisplay::PrintTruth().

00031 {
00032    if(fCurrSnarl == fSnarlVec.end())
00033    {
00034       return false;
00035    }
00036 
00037    if(fCurrEvent == fEventVec.end())
00038    {
00039       return false;
00040    }
00041 
00042    return true;
00043 }

void Anp::RecordStore::LoadSnarl (  )  [private]

Definition at line 211 of file RecordStore.cxx.

References EventBeg(), EventEnd(), fCurrEvent, fCurrSnarl, fEventVec, fSnarlVec, and GetNSnarls().

Referenced by NextSnarl(), and PrevSnarl().

00212 {
00213    if(GetNSnarls() < 1)
00214    {
00215       cerr << "RecordStore is empty" << endl;
00216       return;
00217    }
00218 
00219    if(fCurrSnarl == fSnarlVec.end())
00220    {
00221       cerr << "RecordStore::LoadSnarl() - invalid current snarl iterator" << endl;
00222       return;
00223    }
00224 
00225    fEventVec.clear();
00226    fEventVec.insert(fEventVec.begin(),
00227                     fCurrSnarl -> EventBeg(),
00228                     fCurrSnarl -> EventEnd());
00229 
00230    if(fEventVec.empty())
00231    {
00232       cerr << "RecordStore::LoadSnarl() - current snarl is empty" << endl;
00233       fCurrEvent = fEventVec.end();
00234       return;
00235    }
00236 
00237    fCurrEvent = fEventVec.begin();
00238 }

void Anp::RecordStore::NextEvent (  ) 

Definition at line 90 of file RecordStore.cxx.

References fCurrEvent, fEventVec, GetNSnarls(), and NextSnarl().

Referenced by Anp::EventDisplay::NextEvent().

00091 {
00092    if(GetNSnarls() < 1)
00093    {
00094       cerr << "RecordStore is empty..." << endl;
00095       return;
00096    }
00097    
00098    if(fCurrEvent == fEventVec.end())
00099    {
00100       NextSnarl();
00101       return;
00102    }
00103    else if(fCurrEvent + 1 == fEventVec.end())
00104    {
00105       NextSnarl();
00106       return;      
00107    }
00108    
00109    ++fCurrEvent;
00110 }

void Anp::RecordStore::NextSnarl (  ) 

Definition at line 136 of file RecordStore.cxx.

References fCurrSnarl, fSnarlVec, GetNEvents(), GetNSnarls(), LoadSnarl(), and PrintFirst().

Referenced by NextEvent(), and Anp::EventDisplay::NextSnarl().

00137 {
00138    if(GetNSnarls() < 1)
00139    {
00140       cerr << "RecordStore is empty" << endl;
00141       return;
00142    }
00143 
00144    if(fCurrSnarl == fSnarlVec.end())
00145    {
00146       cerr << "\nLoading first snarl" << endl;
00147       fCurrSnarl = fSnarlVec.begin();
00148       PrintFirst();
00149    }
00150    else if(!(fCurrSnarl + 1 < fSnarlVec.end()))
00151    {
00152       cerr << "Reached last snarl... starting over" << endl;
00153       fCurrSnarl = fSnarlVec.begin();
00154    }
00155    else 
00156    {
00157       ++fCurrSnarl;
00158    }
00159 
00160    for(; fCurrSnarl != fSnarlVec.end(); ++fCurrSnarl)
00161    {
00162       if(fCurrSnarl -> GetNEvents() > 0)
00163       {
00164          LoadSnarl();
00165          return;
00166       }
00167    }
00168 
00169    NextSnarl();
00170 }

void Anp::RecordStore::PrevEvent (  ) 

Definition at line 113 of file RecordStore.cxx.

References fCurrEvent, fEventVec, GetNSnarls(), and PrevSnarl().

Referenced by Anp::EventDisplay::PrevEvent().

00114 {
00115    if(GetNSnarls() < 1)
00116    {
00117       cerr << "RecordStore is empty..." << endl;
00118       return;
00119    }
00120    
00121    if(fCurrEvent == fEventVec.end())
00122    {
00123       PrevSnarl();
00124       return;
00125    }
00126    else if(fCurrEvent == fEventVec.begin())
00127    {
00128       PrevSnarl();
00129       return;      
00130    }
00131    
00132    --fCurrEvent;
00133 }

void Anp::RecordStore::PrevSnarl (  ) 

Definition at line 174 of file RecordStore.cxx.

References fCurrSnarl, fSnarlVec, GetNEvents(), GetNSnarls(), LoadSnarl(), and PrintFirst().

Referenced by PrevEvent(), and Anp::EventDisplay::PrevSnarl().

00175 {
00176    if(GetNSnarls() < 1)
00177    {
00178       cerr << "RecordStore is empty" << endl;
00179       return;
00180    }
00181 
00182    if(fCurrSnarl == fSnarlVec.end())
00183    {
00184       cerr << "\nLoading first snarl" << endl;
00185       fCurrSnarl = fSnarlVec.begin();
00186       PrintFirst();
00187    }
00188    else if(fCurrSnarl == fSnarlVec.begin())
00189    {
00190       cerr << "Reached first snarl... looping over to last snarl" << endl;
00191       fCurrSnarl = fSnarlVec.end() - 1;
00192    }
00193    else 
00194    {
00195       --fCurrSnarl;
00196    }
00197 
00198    for(; fCurrSnarl != fSnarlVec.begin(); --fCurrSnarl)
00199    {
00200       if(fCurrSnarl -> GetNEvents() > 0)
00201       {
00202          LoadSnarl();
00203          return;
00204       }
00205    }
00206 
00207    PrevSnarl();
00208 }

void Anp::RecordStore::PrintData (  )  const

Definition at line 349 of file RecordStore.cxx.

References CurrEvent(), IsValid(), and it.

Referenced by Anp::EventDisplay::PrintData().

00350 {
00351   if(!IsValid())
00352     {
00353       cerr << "RecordStore::PrintData() - bad RecordStore status" << endl;
00354       return;
00355     }
00356 
00357   const Event &event = *CurrEvent();
00358   for(DataIter it =event.DataBeg(); it!=event.DataEnd(); it++){
00359     cout<<it->Key()<<" "<<it->Data()<<endl;
00360   }
00361 
00362 }

void Anp::RecordStore::PrintFirst (  )  const [private]

Definition at line 241 of file RecordStore.cxx.

References fSnarlVec, GetNEvents(), and it.

Referenced by NextSnarl(), and PrevSnarl().

00242 {
00243    unsigned int nevents = 0;
00244    for(SnarlIter it = fSnarlVec.begin(); it != fSnarlVec.end(); ++it)
00245    {
00246       nevents += it -> GetNEvents();
00247    }
00248 
00249    cout << "RecordStore: number of records " << fSnarlVec.size() << endl
00250         << "             number of events  " << nevents << endl;
00251 }

void Anp::RecordStore::PrintTruth (  )  const

Definition at line 254 of file RecordStore.cxx.

References CurrEvent(), CurrSnarl(), Lit::Find(), Anp::Record::FindTruth(), Anp::Record::GetHeader(), Anp::Header::IsData(), IsValid(), Particle::kNuE, Particle::kNuEBar, Particle::kNuM, Particle::kNuMBar, Particle::kNuT, Particle::kNuTBar, and Anp::Record::TruthEnd().

Referenced by Anp::EventDisplay::PrintTruth().

00255 {
00256    if(!IsValid())
00257    {
00258       cerr << "RecordStore::PrintTruth() - bad RecordStore status" << endl;
00259       return;
00260    }
00261 
00262    const Record &record = *CurrSnarl();
00263    const Event &event = *CurrEvent();
00264 
00265    if(record.GetHeader().IsData())
00266    {
00267       return;
00268    }
00269 
00270    TruthIter truth = record.FindTruth(event);
00271    if(truth == record.TruthEnd())
00272    {
00273       cerr << "RecordStore::PrintTruth() - failed to find truth info" << endl;
00274       return;      
00275    }
00276     
00277    string name = "Unknown particle";
00278    switch (truth -> Particle())
00279    {
00280    case Particle::kNuE: 
00281       name = "nuE";
00282       break;
00283    case Particle::kNuEBar: 
00284       name = "nuEbar";
00285       break;
00286    case Particle::kNuM: 
00287       name = "nuM";
00288       break;
00289    case Particle::kNuMBar: 
00290       name = "nuMbar";
00291       break;
00292    case Particle::kNuT: 
00293       name = "nuT";
00294       break;
00295    case Particle::kNuTBar: 
00296       name = "nuTbar";
00297       break;
00298    default:
00299       break;
00300    }
00301 
00302    string action = "UN", reson = "UNK";
00303    if(truth -> Interaction() == 0)
00304    {
00305       action = "NC";
00306    }
00307    else if(truth -> Interaction() == 1)
00308    {
00309       action = "CC";
00310    }
00311 
00312    if(truth -> Resonance() == 1001)
00313    {
00314       reson = "QES";
00315    }
00316    else if(truth -> Resonance() == 1002)
00317    {
00318       reson = "RES";
00319    }
00320    else if(truth -> Resonance() == 1003)
00321    {
00322       reson = "DIS";
00323    }
00324    else if(truth -> Resonance() == 1004)
00325    {
00326       reson = "COH";
00327    }
00328 
00329    float pur = 0.0, com = 0.0;
00330    
00331    TruthRecoIter evt_th = truth -> Find(event);
00332    if(evt_th != truth -> RecoEnd())
00333    {
00334       pur = evt_th -> Purity();
00335       com = evt_th -> ComplAll();
00336    }
00337    
00338    const float trueE = truth -> Energy();
00339    const float recoE = event.Gev();
00340 
00341    cout << action << "-" << reson << " " << setw(6) << name 
00342         << " | pur = " << setw(3) << pur
00343         << ", comp = " << setw(3) << com
00344         << " true E = " << setw(4) << setprecision(3) << trueE
00345         << ", reco E = " << setw(4) << setprecision(3) << recoE
00346         << endl;
00347 }

Anp::RecordStore::SnarlIter Anp::RecordStore::SnarlBeg (  )  const

Definition at line 79 of file RecordStore.cxx.

References fSnarlVec.

00080 {
00081    return fSnarlVec.begin();
00082 }

Anp::RecordStore::SnarlIter Anp::RecordStore::SnarlEnd (  )  const

Definition at line 84 of file RecordStore.cxx.

References fSnarlVec.

Referenced by Anp::EventDisplay::PrintTab().

00085 {
00086    return fSnarlVec.end();
00087 }


Member Data Documentation

Definition at line 61 of file RecordStore.h.

Referenced by Add(), CurrEvent(), IsValid(), LoadSnarl(), NextEvent(), and PrevEvent().

Definition at line 60 of file RecordStore.h.

Referenced by Add(), CurrSnarl(), IsValid(), LoadSnarl(), NextSnarl(), and PrevSnarl().

Definition at line 58 of file RecordStore.h.

Referenced by Add(), EventBeg(), EventEnd(), GetNEvents(), IsValid(), LoadSnarl(), NextEvent(), and PrevEvent().


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

Generated on 3 Dec 2018 for loon by  doxygen 1.6.1