102 : m_useweight(iConfig.getParameter<
bool>(
"useWeight")),
103 m_useVisibleVertices(iConfig.getParameter<
bool>(
"useVisibleVertices")),
105 m_doubleToken(consumes<double>(iConfig.getParameter<
edm::
InputTag>(
"weightProduct"))),
106 m_vecPileupSummaryInfoToken(
108 m_recoVertexCollectionToken(
114 edm::LogInfo(
"UseVisibleVertices") <<
"Only visible vertices will be used to compute Npileup";
116 usesResource(
"TFileService");
120 "recovsmcnvtx2d",
"Number of reco vertices vs pileup interactions", 60, -0.5, 59.5, 60, -0.5, 59.5);
124 tfserv->
make<TProfile>(
"recovsmcnvtxprof",
"Mean number of reco vs pileup vertices", 60, -0.5, 59.5);
129 "recovsmclumi2d",
"Number of reco vertices vs ave pileup interactions", 200, 0., 50., 60, -0.5, 59.5);
133 tfserv->
make<TProfile>(
"recovsmclumiprof",
"Mean number of reco vs ave pileup vertices", 200, 0., 50.);
139 "recovsmcnvtxweightedprof",
"Mean number of reco vs pileup vertices (1-w) weight", 60, -0.5, 59.5);
144 "recovsmclumiweightedprof",
"Mean number of reco vs ave pileup vertices (1-w) weight", 200, 0., 50.);
150 "Reco-MC vertex z position (first vertex)",
158 "Reco-MC vertex z position (closest vertex)",
165 m_hclosestvtx = tfserv->
make<TH1F>(
"closestvtx",
"Closest reco vtx ID", 30, -0.5, 29.5);
170 "Reco-MC vertex z position (first vertex) vs Npileup",
181 "Reco-MC vertex z position (closest vertex) v Npileup",
192 tfserv->
make<TH2F>(
"closestvtxvsnpu",
"Closest reco vtx ID vs Npileup", 30, -0.5, 29.5, 30, -0.5, 29.5);
222 std::vector<PileupSummaryInfo>::const_iterator pileupinfo;
224 for (pileupinfo = pileupinfos->begin(); pileupinfo != pileupinfos->end(); ++pileupinfo) {
225 if (pileupinfo->getBunchCrossing() == 0)
236 if (pileupinfo->getBunchCrossing() != 0) {
237 edm::LogError(
"NoInTimePileUpInfo") <<
"Cannot find the in-time pileup info " << pileupinfo->getBunchCrossing();
240 int npileup = pileupinfo->getPU_NumInteractions();
243 npileup = pileupinfo->getPU_zpositions().size();
264 if (!pvcoll->empty()) {
265 if (!(*pvcoll)[0].isFake()) {
267 if (Evt->vertices_begin() != Evt->vertices_end()) {
276 double minabsdist = -1.;
277 double mindist = -999.;
280 for (
unsigned int ivtx = 0; ivtx < pvcoll->size(); ++ivtx) {
281 if (closestvtx < 0 ||
282 minabsdist >
std::abs((*pvcoll)[ivtx].
z() - (*Evt->vertices_begin())->point3d().z() / 10.)) {
283 mindist = (*pvcoll)[ivtx].z() - (*Evt->vertices_begin())->point3d().z() / 10.;
288 if (closestvtx >= 0) {
TProfile * m_hrecovsmclumiweightedprof
edm::EDGetTokenT< edm::HepMCProduct > m_hepMCProductToken
~MCvsRecoVerticesAnalyzer() override
TProfile * m_hrecovsmcnvtxprof
TH2F * m_hdeltazclosevsnpu
TH2F * m_hdeltazfirstvsnpu
TH2F * m_hclosestvtxvsnpu
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > m_vecPileupSummaryInfoToken
Log< level::Error, false > LogError
std::vector< Vertex > VertexCollection
void analyze(const edm::Event &, const edm::EventSetup &) override
T getUntrackedParameter(std::string const &, T const &) const
TProfile * m_hrecovsmcnvtxweightedprof
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
const bool m_useVisibleVertices
const HepMC::GenEvent * GetEvent() const
MCvsRecoVerticesAnalyzer(const edm::ParameterSet &)
Log< level::Info, false > LogInfo
edm::EDGetTokenT< double > m_doubleToken
T * make(const Args &...args) const
make new ROOT object
const edm::ParameterSet m_histoParameters
edm::EDGetTokenT< reco::VertexCollection > m_recoVertexCollectionToken
TProfile * m_hrecovsmclumiprof