#include <TDataContainer.hxx>
Public Member Functions | |
TDataContainer () | |
TDataContainer (const TDataContainer &dataContainer) | |
~TDataContainer () | |
TMidasEvent & | GetMidasData () const |
Get the MIDAS data for this event, in TMidasEvent format. | |
TMidasEvent & | GetMidasEvent () const |
template<typename T > | |
T * | GetEventData (const char *name) |
Add a templated function that returns event data in the format that we want. | |
void | CleanupEvent () |
void | SetMidasEventPointer (TMidasEvent &event) |
Private Member Functions | |
TDataContainer & | operator= (const TDataContainer &event) |
For the moment make empty assign operator. | |
Private Attributes | |
TMidasEvent * | fMidasEventPointer |
bool | fOwnMidasEventMemory |
Do we own the memory pointed to by TMidasEvent pointer? | |
std::vector< TGenericData * > | fEventDataList |
This class is what will get passed back to users for each midas event. It will contain a pointer to the midas event, which the user can access. It will also contain routines that the user can call to access decoded versions of the midas banks. Generally the decoded information will be cleaned out at the end of each event; but there will be options to allow this information to persist.
Definition at line 28 of file TDataContainer.hxx.
TDataContainer::TDataContainer | ( | ) | [inline] |
Definition at line 34 of file TDataContainer.hxx.
00034 : 00035 fMidasEventPointer(0), fOwnMidasEventMemory(false) 00036 {}
TDataContainer::TDataContainer | ( | const TDataContainer & | dataContainer | ) |
Definition at line 6 of file TDataContainer.cxx.
References fMidasEventPointer, fOwnMidasEventMemory, and GetMidasData().
00006 { 00007 00008 fMidasEventPointer = new TMidasEvent(dataContainer.GetMidasData()); 00009 fOwnMidasEventMemory = true; 00010 00011 }
TDataContainer::~TDataContainer | ( | ) |
Definition at line 13 of file TDataContainer.cxx.
References fEventDataList, fMidasEventPointer, and fOwnMidasEventMemory.
00013 { 00014 00015 if(fOwnMidasEventMemory) 00016 delete fMidasEventPointer; 00017 00018 for(unsigned int i = 0; i < fEventDataList.size(); i++){ 00019 delete fEventDataList[i]; 00020 } 00021 00022 }
void TDataContainer::CleanupEvent | ( | ) |
Method to clean up the current events list of event data. Generally this will delete all the existing information, but this behaviour may be modified in some cases.
Definition at line 43 of file TDataContainer.cxx.
References fEventDataList.
Referenced by TRootanaEventLoop::ProcessMidasFile().
00043 { 00044 00045 for(unsigned int i = 0; i < fEventDataList.size(); i++){ 00046 delete fEventDataList[i]; 00047 } 00048 fEventDataList.clear(); 00049 }
T* TDataContainer::GetEventData | ( | const char * | name | ) | [inline] |
Add a templated function that returns event data in the format that we want.
If we couldn't find bank, return null.
Definition at line 48 of file TDataContainer.hxx.
References fEventDataList, TMidasEvent::FindBank(), and GetMidasData().
Referenced by MyTestLoop::ProcessMidasEvent(), Analyzer::ProcessMidasEvent(), TSimpleExampleCanvas::UpdateCanvasHistograms(), TComplicatedExampleCanvas::UpdateCanvasHistograms(), TV792Histograms::UpdateHistograms(), TV1730RawWaveform::UpdateHistograms(), TV1730DppWaveform::UpdateHistograms(), TV1720Waveform::UpdateHistograms(), TV1190Histograms::UpdateHistograms(), TL2249Histograms::UpdateHistograms(), TDT724Waveform::UpdateHistograms(), and TAgilentHistograms::UpdateHistograms().
00048 { 00049 00050 // Try to find a cached version of this bank 00051 for(unsigned int ibank = 0; ibank < fEventDataList.size(); ibank++){ 00052 if(fEventDataList[ibank]->GetName().compare(name) == 0){ 00053 // Found bank. Now check it has correct type. 00054 T* cast_bank = dynamic_cast<T*>(fEventDataList[ibank]); 00055 // Throw exception if cached bank is of different type. 00056 if(!cast_bank){ 00057 std::cout << "TMidasEvent::GetMidasBank: ERROR: you requested bank with name=" << name << std::endl 00058 << "A cached version of this bank (of type " << typeid(fEventDataList[ibank]).name() 00059 << ") already exists in event; cannot create bank class of new type " 00060 << typeid(T).name()<<std::endl; 00061 throw failed_midas_bank_cast(); 00062 } 00063 return cast_bank; 00064 } 00065 00066 } 00067 00068 void *ptr; 00069 int bklen,bktype; 00070 int status = GetMidasData().FindBank(name, &bklen, &bktype, &ptr); 00071 00072 /// If we couldn't find bank, return null. 00073 if(status == 0) return 0; 00074 00075 T *bank = new T(bklen,bktype,name, ptr); 00076 00077 // Cache a version of this bank... 00078 fEventDataList.push_back(bank); 00079 00080 return bank; 00081 00082 }
TMidasEvent & TDataContainer::GetMidasData | ( | ) | const |
Get the MIDAS data for this event, in TMidasEvent format.
Definition at line 66 of file TDataContainer.cxx.
References fMidasEventPointer.
Referenced by GetEventData(), GetMidasEvent(), MyTestLoop::ProcessMidasEvent(), TDataContainer(), MyTestLoop::UpdateHistograms(), TV1730RawWaveform::UpdateHistograms(), TV1730DppWaveform::UpdateHistograms(), TV1720Waveform::UpdateHistograms(), TDT724Waveform::UpdateHistograms(), and TRootanaDisplay::UpdatePlotsAction().
00066 { 00067 00068 // Make sure that point is valid. 00069 if(fMidasEventPointer==0){ 00070 throw TDataContainerNoValidMidasEvent(); 00071 } 00072 00073 return *fMidasEventPointer; 00074 00075 }
TMidasEvent& TDataContainer::GetMidasEvent | ( | ) | const [inline] |
Definition at line 44 of file TDataContainer.hxx.
References GetMidasData().
Referenced by Analyzer::ProcessMidasEvent().
00044 { return GetMidasData(); }
TDataContainer& TDataContainer::operator= | ( | const TDataContainer & | event | ) | [private] |
For the moment make empty assign operator.
void TDataContainer::SetMidasEventPointer | ( | TMidasEvent & | event | ) |
This is the ugly function where we de-reference to get pointer for a TMidasEvent (ugly!). In this case TDataContainer does not own the memory referenced by fMidasEventPointer.
Definition at line 52 of file TDataContainer.cxx.
References fMidasEventPointer, and fOwnMidasEventMemory.
Referenced by TRootanaEventLoop::ProcessMidasFile().
00052 { 00053 00054 // If the MidasPointer is still valid and we own the memory associated with it, 00055 // then we shouldn't be reseting the fMidasEventPointer. 00056 if(fOwnMidasEventMemory && fMidasEventPointer){ 00057 throw TDataContainerBadPointerReset(); 00058 } 00059 00060 fMidasEventPointer = &event; // ugly! 00061 fOwnMidasEventMemory = false; 00062 00063 }
std::vector<TGenericData*> TDataContainer::fEventDataList [private] |
This is the list of banks associated with this event. The event owns these banks and needs to take care of deleting them.
Definition at line 110 of file TDataContainer.hxx.
Referenced by CleanupEvent(), GetEventData(), and ~TDataContainer().
TMidasEvent* TDataContainer::fMidasEventPointer [private] |
Pointer to the TMidasEvent; In some cases we own the memory referenced by pointer; other cases not
Definition at line 98 of file TDataContainer.hxx.
Referenced by GetMidasData(), SetMidasEventPointer(), TDataContainer(), and ~TDataContainer().
bool TDataContainer::fOwnMidasEventMemory [private] |
Do we own the memory pointed to by TMidasEvent pointer?
Definition at line 101 of file TDataContainer.hxx.
Referenced by SetMidasEventPointer(), TDataContainer(), and ~TDataContainer().