Belle II Software  release-08-01-10
TOPAssociatedPDF.cc
1 
2 /**************************************************************************
3  * basf2 (Belle II Analysis Software Framework) *
4  * Author: The Belle II Collaboration *
5  * *
6  * See git log for contributors and copyright holders. *
7  * This file is licensed under LGPL-3.0, see LICENSE.md. *
8  **************************************************************************/
9 
10 #include <top/dataobjects/TOPAssociatedPDF.h>
11 #include <TRandom.h>
12 
13 
14 namespace Belle2 {
21  {
22  if (m_weights.empty()) return 0;
23 
24  float sum = m_BGWeight + m_deltaRayWeight;
25  for (const auto& w : m_weights) sum += w;
26  float prob = sum * gRandom->Rndm();
27  float cumul = 0;
28  for (size_t i = 0; i < m_weights.size(); i++) {
29  cumul += m_weights[i];
30  if (prob < cumul) return &m_peaks[i];
31  }
32  return 0;
33  }
34 
36 }
std::vector< float > m_weights
corresponding weights
float m_deltaRayWeight
delta-ray weight
std::vector< PDFPeak > m_peaks
collection of associated PDF peaks
float m_BGWeight
background weight
const PDFPeak * getSinglePeak() const
Returns a PDF peak selected randomly according to weights.
Abstract base class for different kinds of events.
parameters of a PDF peak