27 template <
typename T,
size_t N>
29 const double minLog10 = std::log10(min);
30 const double maxLog10 = std::log10(max);
31 const double width = (maxLog10-minLog10)/
N;
32 std::array<T, N+1> ret;
34 const double mult =
std::pow(10, width);
35 for (
size_t i=1;
i<=
N; ++
i) {
36 ret[
i] = ret[
i-1]*mult;
72 maxResol_(iConfig.getUntrackedParameter<double>(
"maxResol")),
74 maxPull_(iConfig.getUntrackedParameter<double>(
"maxPull")),
75 binsPull_(iConfig.getUntrackedParameter<
int>(
"binsPull"))
86 minNtracks_(iConfig.getUntrackedParameter<double>(
"minNtracks")),
87 maxNtracks_(iConfig.getUntrackedParameter<double>(
"maxNtracks")),
88 binsNtracks_(iConfig.getUntrackedParameter<
int>(
"binsNtracks")),
89 minNvertices_(iConfig.getUntrackedParameter<double>(
"minNvertices")),
90 maxNvertices_(iConfig.getUntrackedParameter<double>(
"maxNvertices")),
91 binsNvertices_(iConfig.getUntrackedParameter<
int>(
"binsNvertices")),
92 minPt_(iConfig.getUntrackedParameter<double>(
"minPt")),
93 maxPt_(iConfig.getUntrackedParameter<double>(
"maxPt")),
94 minLumi_(iConfig.getUntrackedParameter<double>(
"minLumi")),
95 maxLumi_(iConfig.getUntrackedParameter<double>(
"maxLumi"))
113 const double diffx = vertex1.
x() - vertex2.
x();
114 const double diffy = vertex1.
y() - vertex2.
y();
115 const double diffz = vertex1.
z() - vertex2.
z();
120 const double invSqrt2 = 1./
std::sqrt(2.);
121 resx_ = diffx * invSqrt2;
122 resy_ = diffy * invSqrt2;
123 resz_ = diffz * invSqrt2;
130 double resx()
const {
return resx_; }
131 double resy()
const {
return resy_; }
132 double resz()
const {
return resz_; }
134 double pullx()
const {
return pullx_; }
135 double pully()
const {
return pully_; }
136 double pullz()
const {
return pullz_; }
154 template <
typename T>
156 book(iBooker, binArray.size()-1, binArray.front(), binArray.back());
157 setLogX(binArray.size()-1, binArray.data());
160 template <
typename ...Args>
164 hDiffX_ = iBooker.
book2D(
"res_x_vs_"+postfix_,
"Resolution of X vs. "+postfix_, std::forward<Args>(
args)..., binsResol,-maxResol,maxResol);
165 hDiffY_ = iBooker.
book2D(
"res_y_vs_"+postfix_,
"Resolution of Y vs. "+postfix_, std::forward<Args>(
args)..., binsResol,-maxResol,maxResol);
166 hDiffZ_ = iBooker.
book2D(
"res_z_vs_"+postfix_,
"Resolution of Z vs. "+postfix_, std::forward<Args>(
args)..., binsResol,-maxResol,maxResol);
170 hPullX_ = iBooker.
book2D(
"pull_x_vs_"+postfix_,
"Pull of X vs. "+postfix_, std::forward<Args>(
args)..., binsPull,-maxPull,maxPull);
171 hPullY_ = iBooker.
book2D(
"pull_y_vs_"+postfix_,
"Pull of Y vs. "+postfix_, std::forward<Args>(
args)..., binsPull,-maxPull,maxPull);
172 hPullZ_ = iBooker.
book2D(
"pull_z_vs_"+postfix_,
"Pull of Z vs. "+postfix_, std::forward<Args>(
args)..., binsPull,-maxPull,maxPull);
174 template <
typename ...Args>
176 hDiffX_->getTH2F()->GetXaxis()->Set(std::forward<Args>(
args)...);
177 hDiffY_->getTH2F()->GetXaxis()->Set(std::forward<Args>(
args)...);
178 hDiffZ_->getTH2F()->GetXaxis()->Set(std::forward<Args>(
args)...);
180 hPullX_->getTH2F()->GetXaxis()->Set(std::forward<Args>(
args)...);
181 hPullY_->getTH2F()->GetXaxis()->Set(std::forward<Args>(
args)...);
182 hPullZ_->getTH2F()->GetXaxis()->Set(std::forward<Args>(
args)...);
185 template <
typename T>
187 hDiffX_->Fill(ref, res.
resx());
188 hDiffY_->Fill(ref, res.
resy());
189 hDiffZ_->Fill(ref, res.
resz());
190 hPullX_->Fill(ref, res.
pullx());
191 hPullY_->Fill(ref, res.
pully());
192 hPullZ_->Fill(ref, res.
pullz());
211 hDiff_Ntracks_(
"ntracks", binY),
212 hDiff_sumPt_(
"sumpt", binY),
213 hDiff_Nvertices_(
"nvertices", binY),
214 hDiff_instLumiScal_(
"instLumiScal", binY)
220 hDiffX_ = iBooker.
book1D(
"res_x",
"Resolution of X", binsResol, -maxResol, maxResol);
221 hDiffY_ = iBooker.
book1D(
"res_y",
"Resolution of Y", binsResol, -maxResol, maxResol);
222 hDiffZ_ = iBooker.
book1D(
"res_z",
"Resolution of Z", binsResol, -maxResol, maxResol);
226 hPullX_ = iBooker.
book1D(+
"pull_x",
"Pull of X", binsPull, -maxPull, maxPull);
227 hPullY_ = iBooker.
book1D(+
"pull_y",
"Pull of Y", binsPull, -maxPull, maxPull);
228 hPullZ_ = iBooker.
book1D(+
"pull_z",
"Pull of Z", binsPull, -maxPull, maxPull);
240 void calculateAndFillResolution(
const std::vector<reco::TransientTrack>&
tracks,
243 std::mt19937& engine,
318 descriptions.
add(
"primaryVertexResolution", desc);
354 auto iPV = cbegin(vertices);
356 const auto nvertices = vertices.
size();
364 for(
auto endPV = cend(vertices); iPV != endPV; ++iPV) {
365 if(iPV->tracksSize() >= 4) {
375 std::vector<const reco::Track *> sortedTracks;
381 return a->
pt() >
b->pt();
384 std::vector<reco::TransientTrack> ttracks;
385 ttracks.reserve(sortedTracks.size());
388 tt.setBeamSpot(beamspot);
397 std::mt19937& engine,
399 const size_t end = tracks.size()%2 == 0 ? tracks.size() : tracks.size()-1;
401 std::vector<reco::TransientTrack> set1, set2;
402 set1.reserve(end/2); set2.reserve(end/2);
404 auto dis = std::uniform_int_distribution<>(0, 1);
406 double sumpt1=0, sumpt2=0;
407 for(
size_t i=0;
i<
end;
i += 2) {
408 const size_t set1_i = dis(engine);
409 const size_t set2_i = 1-set1_i;
411 set1.push_back(tracks[
i+set1_i]);
412 set2.push_back(tracks[
i+set2_i]);
414 sumpt1 += set1.back().track().pt();
415 sumpt2 += set2.back().track().pt();
423 hDiffX_->Fill(res.
resx());
424 hDiffY_->Fill(res.
resy());
425 hDiffZ_->Fill(res.
resz());
426 hPullX_->Fill(res.
pullx());
427 hPullY_->Fill(res.
pully());
428 hPullZ_->Fill(res.
pullz());
430 hDiff_Ntracks_.fill(res, set1.size());
431 hDiff_sumPt_.fill(res, (sumpt1+sumpt2)/2.0);
432 hDiff_Nvertices_.fill(res, nvertices);
434 if(!lumiScalers.empty()) {
435 hDiff_instLumiScal_.fill(res, lumiScalers.front().instantLumi());
EventNumber_t event() const
BinningX(const edm::ParameterSet &iConfig)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
trackRef_iterator tracks_end() const
last iterator over tracks
void book(DQMStore::IBooker &iBooker)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double zError() const
error on z
void calculateAndFillResolution(const std::vector< reco::TransientTrack > &tracks, size_t nvertices, const LumiScalersCollection &lumiScalers, std::mt19937 &engine, AdaptiveVertexFitter &fitter)
double y() const
y coordinate
PrimaryVertexResolution(const edm::ParameterSet &iConfig)
reco::TransientTrack build(const reco::Track *p) const
DiffPlots hDiff_instLumiScal_
~PrimaryVertexResolution() override
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
std::vector< Vertex > VertexCollection
collection of Vertex objects
const BinningY & binningY_
void analyze(const edm::Event &, const edm::EventSetup &) override
LuminosityBlockNumber_t luminosityBlock() const
std::string transientTrackBuilder_
const BinningX & binningX_
Plots(const BinningX &binX, const BinningY &binY)
const BinningY & binningY_
#define DEFINE_FWK_MODULE(type)
void setCurrentFolder(std::string const &fullpath)
void fill(const Resolution &res, const T ref)
double pt() const
track transverse momentum
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
BinningY(const edm::ParameterSet &iConfig)
MonitorElement * book1D(Args &&...args)
edm::EDGetTokenT< LumiScalersCollection > lumiScalersSrc_
double z() const
z coordinate
void bookLogX(DQMStore::IBooker &iBooker, const T &binArray)
std::array< T, N+1 > makeLogBins(const T min, const T max)
DiffPlots hDiff_Nvertices_
edm::EDGetTokenT< reco::VertexCollection > vertexSrc_
DiffPlots(const std::string &postfix, const BinningY &binY)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double x() const
x coordinate
double xError() const
error on x
MonitorElement * book2D(Args &&...args)
edm::EDGetTokenT< reco::BeamSpot > beamspotSrc_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< reco::TransientTrack > sortTracksByPt(const reco::Vertex &thePV, const TransientTrackBuilder &ttBuilder, const reco::BeamSpot &beamspot)
Resolution(const reco::Vertex &vertex1, const reco::Vertex &vertex2)
Square< F >::type sqr(const F &f)
std::vector< LumiScalers > LumiScalersCollection
AdaptiveVertexFitter fitter_
trackRef_iterator tracks_begin() const
first iterator over tracks
void book(DQMStore::IBooker &iBooker, Args &&...args)
Power< A, B >::type pow(const A &a, const B &b)
double yError() const
error on y
size_t tracksSize() const
number of tracks
void setLogX(Args &&...args)