1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
// -*- C++ -*-
//
// Package: MultiplicityCorrelator
// Class: MultiplicityCorrelator
//
/**\class MultiplicityCorrelator MultiplicityCorrelator.cc DPGAnalysis/SiStripTools/src/MultiplicityCorrelator.cc
Description: <one line class summary>
Implementation:
<Notes on implementation>
*/
//
// Original Author: Andrea Venturi
// Created: Mon Oct 27 17:37:53 CET 2008
// $Id: MultiplicityCorrelator.cc,v 1.3 2011/12/11 10:04:09 venturia Exp $
//
//
// system include files
#include <memory>
// user include files
#include <vector>
#include <map>
#include <limits>
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DPGAnalysis/SiStripTools/interface/MultiplicityCorrelatorHistogramMaker.h"
//
// class decleration
//
class MultiplicityCorrelator : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
public:
explicit MultiplicityCorrelator(const edm::ParameterSet&);
~MultiplicityCorrelator() override;
private:
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
void beginRun(const edm::Run&, const edm::EventSetup&) override;
void endRun(const edm::Run&, const edm::EventSetup&) override {}
void endJob() override;
// ----------member data ---------------------------
std::vector<MultiplicityCorrelatorHistogramMaker*> m_mchms;
std::vector<edm::EDGetTokenT<std::map<unsigned int, int> > > m_xMultiplicityMapTokens;
std::vector<edm::EDGetTokenT<std::map<unsigned int, int> > > m_yMultiplicityMapTokens;
std::vector<std::string> m_xLabels;
std::vector<std::string> m_yLabels;
std::vector<unsigned int> m_xSelections;
std::vector<unsigned int> m_ySelections;
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
MultiplicityCorrelator::MultiplicityCorrelator(const edm::ParameterSet& iConfig)
: m_mchms(),
m_xMultiplicityMapTokens(),
m_yMultiplicityMapTokens(),
m_xLabels(),
m_yLabels(),
m_xSelections(),
m_ySelections() {
//now do what ever initialization is needed
std::vector<edm::ParameterSet> correlationConfigs =
iConfig.getParameter<std::vector<edm::ParameterSet> >("correlationConfigurations");
for (std::vector<edm::ParameterSet>::const_iterator ps = correlationConfigs.begin(); ps != correlationConfigs.end();
++ps) {
m_xMultiplicityMapTokens.push_back(
consumes<std::map<unsigned int, int> >(ps->getParameter<edm::InputTag>("xMultiplicityMap")));
m_yMultiplicityMapTokens.push_back(
consumes<std::map<unsigned int, int> >(ps->getParameter<edm::InputTag>("yMultiplicityMap")));
m_xLabels.push_back(ps->getParameter<std::string>("xDetLabel"));
m_yLabels.push_back(ps->getParameter<std::string>("yDetLabel"));
m_xSelections.push_back(ps->getParameter<unsigned int>("xDetSelection"));
m_ySelections.push_back(ps->getParameter<unsigned int>("yDetSelection"));
m_mchms.push_back(new MultiplicityCorrelatorHistogramMaker(*ps, consumesCollector()));
}
}
MultiplicityCorrelator::~MultiplicityCorrelator() {
for (unsigned int i = 0; i < m_mchms.size(); ++i) {
delete m_mchms[i];
}
}
//
// member functions
//
// ------------ method called to for each event ------------
void MultiplicityCorrelator::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
for (unsigned int i = 0; i < m_mchms.size(); ++i) {
Handle<std::map<unsigned int, int> > xMults;
iEvent.getByToken(m_xMultiplicityMapTokens[i], xMults);
Handle<std::map<unsigned int, int> > yMults;
iEvent.getByToken(m_yMultiplicityMapTokens[i], yMults);
// check if the selection exists
std::map<unsigned int, int>::const_iterator xmult = xMults->find(m_xSelections[i]);
std::map<unsigned int, int>::const_iterator ymult = yMults->find(m_ySelections[i]);
if (xmult != xMults->end() && ymult != yMults->end()) {
m_mchms[i]->fill(iEvent, xmult->second, ymult->second);
} else {
edm::LogWarning("DetSelectionNotFound")
<< " DetSelection " << m_xSelections[i] << " " << m_ySelections[i] << " not found";
}
}
}
// ------------ method called once each job just before starting event loop ------------
void MultiplicityCorrelator::beginJob() {}
void MultiplicityCorrelator::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
for (unsigned int i = 0; i < m_mchms.size(); ++i) {
m_mchms[i]->beginRun(iRun);
}
}
// ------------ method called once each job just after ending the event loop ------------
void MultiplicityCorrelator::endJob() {}
//define this as a plug-in
DEFINE_FWK_MODULE(MultiplicityCorrelator);
|