size_t DataRepresentation::GetDataIndexPos(size_t dataIndex_) const{ for(size_t i = 0; i < fInverse.size(); i++){ if (dataIndex_ == fInverse.at(i).first) return fInverse.at(i).second; } throw RepresentationError("Incompatible data representation"); // }
std::vector<double> Event::ToObsSet(const ObsSet& rep_) const{ size_t nObs = rep_.GetNObservables(); if (!nObs) throw RepresentationError("Event Data queried with empty representation!"); std::vector<double> vals(nObs, 0); // can you do this better with iterators? try{ for(size_t i = 0; i < nObs; i++) vals[i] = fObservations.at(rep_.GetIndex(i)); } catch(std::out_of_range&){ throw RepresentationError("Data representation asked for indicies not in the data!"); } return vals; }
size_t BinnedPdf::FindBin(const EventData& data_) const{ try{ return fHistogram.FindBin(data_.ToRepresentation(fDataRep)); } catch (const DimensionError& e_){ throw RepresentationError(std::string("Representation in compatible with pdf ") + e_.what()); } }
void BinnedPdf::Fill(const EventData& data_, double weight_){ try{ fHistogram.Fill(data_.ToRepresentation(fDataRep), weight_); } catch (const DimensionError& e_){ throw RepresentationError(std::string("Representation in compatible with pdf ") + e_.what()); } }
double BinnedPdf::Probability(const EventData& oberservations_) const{ try{ return operator()(oberservations_.ToRepresentation(fDataRep)); } catch(const RepresentationError& e_){ throw RepresentationError("BinnedPdf::Probability() failed with " + std::string(e_.what()) + " is the rep set correctly?"); } }
std::vector<size_t> DataRepresentation::GetRelativeIndices(const DataRepresentation& otherRep_) const{ // given a longer represetation containing the indices of this rep, where are the shared indices // in the big rep if(otherRep_.fNObservables < fNObservables) throw RepresentationError("Tried to take relatice indices in compatible representations "); std::vector<size_t> relativeIndices(fIndices.size(), 0); for(size_t i = 0; i < fIndices.size(); i++) relativeIndices[i] = otherRep_.GetDataIndexPos(fIndices.at(i)); return relativeIndices; }