00001 #ifndef DATA_BASE_CC 00002 #define DATA_BASE_CC 00003 00004 #include "data_base.hh" 00005 00006 namespace larlight { 00007 00008 //******************************************************************************************* 00009 void data_base::add_association(DATA::DATA_TYPE type, const std::vector<unsigned short> ass) 00010 //******************************************************************************************* 00011 { 00012 00013 if( _ass.find(type) == _ass.end() ) 00014 00015 _ass[type]=std::vector<std::vector<unsigned short> >(); 00016 00017 _ass[type].push_back(ass); 00018 00019 00020 } 00021 00022 //************************************************************* 00023 size_t data_base::size_association(DATA::DATA_TYPE type) const 00024 //************************************************************* 00025 { 00026 00027 if( _ass.find(type) == _ass.end() ) return 0; 00028 00029 return ((_ass.find(type))->second).size(); 00030 //return _ass[type].size(); 00031 00032 } 00033 00034 //************************************************************************************************* 00035 const std::vector<unsigned short> data_base::association(DATA::DATA_TYPE type, size_t index) const 00036 //************************************************************************************************* 00037 { 00038 00039 size_t ass_length = size_association(type); 00040 00041 if( !(ass_length) ) { 00042 00043 Message::send(MSG::ERROR,__FUNCTION__, 00044 Form("There is no association to %s",DATA::DATA_TREE_NAME[type].c_str())); 00045 00046 return std::vector<unsigned short>(); 00047 00048 } 00049 00050 if( ass_length <= index ) { 00051 00052 Message::send(MSG::ERROR,__FUNCTION__, 00053 Form("There are only %zu associations. No association @ index=%zu",ass_length,index)); 00054 00055 return std::vector<unsigned short>(); 00056 00057 } 00058 00059 return ((_ass.find(type))->second).at(index); 00060 } 00061 00062 //************************** 00063 void event_base::clear_data() 00064 //************************** 00065 { 00066 data_base::clear_data(); 00067 fRunNumber = fSubRunNumber = fEventID = DATA::INVALID_UINT; 00068 } 00069 00070 } 00071 00072 #endif