#ifndef TDataContainer_hxx_seen #define TDataContainer_hxx_seen #include #include #include #include "TMidasEvent.h" #include "TGenericData.hxx" #include /// class failed_midas_bank_cast: public std::exception { virtual const char* what() const throw() { return "Incorrect bank cast"; } }; /// 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. class TDataContainer { public: TDataContainer(): fMidasEventPointer(0), fOwnMidasEventMemory(false) {} TDataContainer(const TDataContainer &dataContainer); ~TDataContainer(); /// Get the MIDAS data for this event, in TMidasEvent format TMidasEvent& GetMidasData() const; TMidasEvent& GetMidasEvent() const{ return GetMidasData(); } /// Add a templated function that returns event data in the format that we want. template T* GetEventData(const char* name){ // Try to find a cached version of this bank for(unsigned int ibank = 0; ibank < fEventDataList.size(); ibank++){ if(fEventDataList[ibank]->GetName().compare(name) == 0){ // Found bank. Now check it has correct type. T* cast_bank = dynamic_cast(fEventDataList[ibank]); // Throw exception if cached bank is of different type. if(!cast_bank){ std::cout << "TMidasEvent::GetMidasBank: ERROR: you requested bank with name=" << name << std::endl << "A cached version of this bank (of type " << typeid(fEventDataList[ibank]).name() << ") already exists in event; cannot create bank class of new type " << typeid(T).name()< fEventDataList; }; #endif