CMS 3D CMS Logo

Namespaces | Functions
PileUp.cc File Reference
#include "Mixing/Base/interface/PileUp.h"
#include "DataFormats/Provenance/interface/BranchIDListHelper.h"
#include "DataFormats/Provenance/interface/ModuleDescription.h"
#include "DataFormats/Provenance/interface/ThinnedAssociationsHelper.h"
#include "FWCore/Framework/interface/EventPrincipal.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/SignallingProductRegistry.h"
#include "FWCore/Framework/interface/ESRecordsToProductResolverIndices.h"
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
#include "FWCore/ServiceRegistry/interface/ProcessContext.h"
#include "FWCore/Sources/interface/VectorInputSourceDescription.h"
#include "FWCore/Sources/interface/VectorInputSourceFactory.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/GetPassID.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/Version/interface/GetReleaseVersion.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "Mixing/Base/src/SecondaryEventProvider.h"
#include "CondFormats/DataRecord/interface/MixingRcd.h"
#include "CondFormats/RunInfo/interface/MixingModuleConfig.h"
#include "CLHEP/Random/RandPoissonQ.h"
#include "CLHEP/Random/RandPoisson.h"
#include "PileupRandomNumberGenerator.h"
#include <algorithm>
#include <memory>
#include "TMath.h"

Go to the source code of this file.

Namespaces

 edm
 HLT enums.
 

Functions

static Double_t GetRandom (TH1 *th1, CLHEP::HepRandomEngine *rng)
 

Function Documentation

◆ GetRandom()

static Double_t GetRandom ( TH1 *  th1,
CLHEP::HepRandomEngine *  rng 
)
static

return a random number distributed according the histogram bin contents.

This routine is derived from root/hist/hist/src/TH1.cxx

Definition at line 51 of file PileUp.cc.

References funct::integral(), totemT2DQMSource_cfi::nbinsx, diffTwoXMLs::r1, and x.

Referenced by edm::PileUp::CalculatePileup().

51  {
52  Int_t nbinsx = th1->GetNbinsX();
53  Double_t* fIntegral = th1->GetIntegral();
54  Double_t integral = fIntegral[nbinsx];
55 
56  if (integral == 0)
57  return 0;
58 
59  Double_t r1 = rng->flat();
60  Int_t ibin = TMath::BinarySearch(nbinsx, fIntegral, r1);
61  Double_t x = th1->GetBinLowEdge(ibin + 1);
62  if (r1 > fIntegral[ibin])
63  x += th1->GetBinWidth(ibin + 1) * (r1 - fIntegral[ibin]) / (fIntegral[ibin + 1] - fIntegral[ibin]);
64  return x;
65 }
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:70
float x