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/src/SignallingProductRegistry.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 <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

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 48 of file PileUp.cc.

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

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

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