NuEventVector< T > Class Template Reference

#include <NuEventVector.h>

List of all members.

Public Member Functions

void push_back (const T &x, Double_t POT=0.0)
Double_t pot (void) const
 Returns the POT of the events in this collection.
void resetpot (Double_t pot)
 Resets the POT in this vector.
Double_t maxrw (void) const
 Returns the maximum reweight value.
void scale (Double_t scalefactor)
 Scale all events by some value.

Private Attributes

Double_t fPot
 The POT represented by this class.

Detailed Description

template<class T>
class NuEventVector< T >

A vector for event-class objects, that includes POT. A class must have an accessible rw property to be used as a class template. This is because you can combine multiple sets of event data with different POTs into one whole.

Definition at line 14 of file NuEventVector.h.


Member Function Documentation

template<class T>
Double_t NuEventVector< T >::maxrw ( void   )  const [inline]

Returns the maximum reweight value.

Definition at line 55 of file NuEventVector.h.

Referenced by NuFCEventManager::ReweightSamplesPerBin(), TestEventVector::testMaxRwNoPOT(), TestEventVector::testMaxRwPOT(), TestEventVector::testScaleMax(), TestEventVector::testScaleMaxPOT(), and TestEventVector::testScaleNoPOT().

00055                              {
00056     // Don't do anything if we have no events
00057     if (std::vector<T>::size() == 0) return 0;
00058     
00059     Double_t max = (*this)[0].rw;
00060     
00061     typename std::vector<T>::const_iterator it;
00062     for (it = this->begin(); it != this->end(); ++it) {
00063       max = (max > (*it).rw ? max : (*it).rw);
00064     }
00065     return max;
00066   }

template<class T>
Double_t NuEventVector< T >::pot ( void   )  const [inline]
template<class T>
void NuEventVector< T >::push_back ( const T &  x,
Double_t  POT = 0.0 
) [inline]

Definition at line 20 of file NuEventVector.h.

Referenced by NuFCEventManager::AddEvent(), NuFCEventManager::AddFile(), NuEventVector< NuFCEvent2 >::push_back(), TestEventVector::testEventRw(), TestEventVector::testFCEvent2(), TestEventVector::testMaxRwNoPOT(), TestEventVector::testMaxRwPOT(), TestEventVector::testNoPot(), TestEventVector::testPushback(), TestEventVector::testScaleMax(), TestEventVector::testScaleMaxPOT(), TestEventVector::testScaleNoPOT(), TestEventVector::testScalePOT(), TestEventVector::testSetPot(), and TestEventVector::testSize().

00020                                                    {
00021     // If this is our first event, use the POT value from that event
00022     if (std::vector<T>::size() == 0) fPot = POT;
00023     
00024     // Desired behaviour: If we have a POT, then it is an error to have none
00025     // vice-versa, if we have no POT it is an error to try to use one
00026     if (fPot) {
00027       if (!POT) {
00028         TString str = TString::Format("Have defined POT %g but have passed in none for an event.", fPot);
00029         throw std::logic_error(str.Data());
00030       }
00031     } else {
00032       if (POT) {
00033         TString str = TString::Format("Have no defined POT, but have passed '%g' for an event.", POT);
00034         throw std::logic_error(str.Data());
00035       }
00036     }
00037     // Reweight this event to match our internal POT value
00038     // If we haven't been given POT, we don't know how to weight this event, so don't
00039     Double_t scale = 1.0;
00040     if (POT != 0.0 && fPot != 0.0) {
00041       scale = fPot / POT;
00042     }
00043     // Push it onto our vector
00044     std::vector<T>::push_back(x);
00045     // Now, scale the rw of the event we just added
00046     std::vector<T>::back().rw *= scale;
00047   };

template<class T>
void NuEventVector< T >::resetpot ( Double_t  pot  )  [inline]

Resets the POT in this vector.

Definition at line 52 of file NuEventVector.h.

00052 { fPot = pot; }

template<class T>
void NuEventVector< T >::scale ( Double_t  scalefactor  )  [inline]

Scale all events by some value.

Definition at line 69 of file NuEventVector.h.

Referenced by NuEventVector< NuFCEvent2 >::push_back(), NuFCEventManager::ReweightSamples(), TestEventVector::testScaleMax(), TestEventVector::testScaleMaxPOT(), TestEventVector::testScaleNoPOT(), and TestEventVector::testScalePOT().

00069                                    {
00070     typename std::vector<T>::iterator it;
00071     for (it = this->begin(); it != this->end(); ++it) {
00072       (*it).rw *= scalefactor;
00073     }
00074     // Should we do this? Also scale the POT...
00075     fPot *= scalefactor;
00076   }


Member Data Documentation

template<class T>
Double_t NuEventVector< T >::fPot [private]

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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1