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;
35 for (
size_t i = 1;
i <=
N; ++
i) {
36 ret[
i] = ret[
i - 1] *
mult;
74 :
maxResol_(iConfig.getUntrackedParameter<double>(
"maxResol")),
75 binsResol_(iConfig.getUntrackedParameter<int>(
"binsResol")),
76 maxPull_(iConfig.getUntrackedParameter<double>(
"maxPull")),
77 binsPull_(iConfig.getUntrackedParameter<int>(
"binsPull")) {}
87 :
minNtracks_(iConfig.getUntrackedParameter<double>(
"minNtracks")),
88 maxNtracks_(iConfig.getUntrackedParameter<double>(
"maxNtracks")),
89 binsNtracks_(iConfig.getUntrackedParameter<int>(
"binsNtracks")),
90 minNvertices_(iConfig.getUntrackedParameter<double>(
"minNvertices")),
91 maxNvertices_(iConfig.getUntrackedParameter<double>(
"maxNvertices")),
92 binsNvertices_(iConfig.getUntrackedParameter<int>(
"binsNvertices")),
93 maxXY_(iConfig.getUntrackedParameter<double>(
"maxXY")),
94 binsXY_(iConfig.getUntrackedParameter<int>(
"binsXY")),
95 maxZ_(iConfig.getUntrackedParameter<double>(
"maxZ")),
96 binsZ_(iConfig.getUntrackedParameter<int>(
"binsZ")),
97 minPt_(iConfig.getUntrackedParameter<double>(
"minPt")),
98 maxPt_(iConfig.getUntrackedParameter<double>(
"maxPt")),
99 minLumi_(iConfig.getUntrackedParameter<double>(
"minLumi")),
100 maxLumi_(iConfig.getUntrackedParameter<double>(
"maxLumi")) {}
121 const double diffx = vertex1.
x() - vertex2.
x();
122 const double diffy = vertex1.
y() - vertex2.
y();
123 const double diffz = vertex1.
z() - vertex2.
z();
128 const double invSqrt2 = 1. /
std::sqrt(2.);
129 resx_ = diffx * invSqrt2;
130 resy_ = diffy * invSqrt2;
131 resz_ = diffz * invSqrt2;
137 avgx_ = (vertex1.
x() + vertex2.
x()) / 2.;
138 avgy_ = (vertex1.
y() + vertex2.
y()) / 2.;
139 avgz_ = (vertex1.
z() + vertex2.
z()) / 2.;
170 template <
typename T>
172 book(iBooker, binArray.size() - 1, binArray.front(), binArray.back());
173 setLogX(binArray.size() - 1, binArray.data());
176 template <
typename... Args>
182 std::forward<Args>(
args)...,
188 std::forward<Args>(
args)...,
194 std::forward<Args>(
args)...,
203 std::forward<Args>(
args)...,
209 std::forward<Args>(
args)...,
215 std::forward<Args>(
args)...,
220 template <
typename... Args>
231 template <
typename T>
268 hDiffX_ = iBooker.
book1D(
"res_x",
"Resolution of X", binsResol, -maxResol, maxResol);
269 hDiffY_ = iBooker.
book1D(
"res_y",
"Resolution of Y", binsResol, -maxResol, maxResol);
270 hDiffZ_ = iBooker.
book1D(
"res_z",
"Resolution of Z", binsResol, -maxResol, maxResol);
274 hPullX_ = iBooker.
book1D(+
"pull_x",
"Pull of X", binsPull, -maxPull, maxPull);
275 hPullY_ = iBooker.
book1D(+
"pull_y",
"Pull of Y", binsPull, -maxPull, maxPull);
276 hPullZ_ = iBooker.
book1D(+
"pull_z",
"Pull of Z", binsPull, -maxPull, maxPull);
284 constexpr
int binsPt = 30;
287 constexpr
int binsLumi = 100;
294 std::mt19937& engine,
331 beamspotSrc_(consumes<
reco::
BeamSpot>(iConfig.getUntrackedParameter<edm::
InputTag>(
"beamspotSrc"))),
334 forceSCAL_(iConfig.getUntrackedParameter<bool>(
"forceSCAL")),
335 rootFolder_(iConfig.getUntrackedParameter<std::
string>(
"rootFolder")),
338 hPV_(binningX_, binningY_),
339 hOtherV_(binningX_, binningY_) {}
381 descriptions.
add(
"primaryVertexResolution", desc);
395 if (vertices.empty())
404 if (lumiScalers.
isValid() && !lumiScalers->empty()) {
405 LumiScalersCollection::const_iterator scalit = lumiScalers->begin();
406 lumi = scalit->instantLumi();
411 lumi = metaData->instLumi();
422 auto iPV = cbegin(vertices);
424 const auto nvertices = vertices.
size();
432 for (
auto endPV = cend(vertices); iPV != endPV; ++iPV) {
433 if (iPV->tracksSize() >= 4) {
443 std::vector<const reco::Track*> sortedTracks;
450 return a->
pt() >
b->pt();
453 std::vector<reco::TransientTrack> ttracks;
454 ttracks.reserve(sortedTracks.size());
457 tt.setBeamSpot(beamspot);
466 std::mt19937& engine,
468 const size_t end = tracks.size() % 2 == 0 ? tracks.size() : tracks.size() - 1;
470 std::vector<reco::TransientTrack> set1, set2;
471 set1.reserve(end / 2);
472 set2.reserve(end / 2);
474 auto dis = std::uniform_int_distribution<>(0, 1);
476 double sumpt1 = 0, sumpt2 = 0;
477 for (
size_t i = 0;
i <
end;
i += 2) {
478 const size_t set1_i = dis(engine);
479 const size_t set2_i = 1 - set1_i;
481 set1.push_back(tracks[
i + set1_i]);
482 set2.push_back(tracks[
i + set2_i]);
484 sumpt1 += set1.back().track().pt();
485 sumpt2 += set2.back().track().pt();
EventNumber_t event() const
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttbToken_
tuple ret
prodAgent to be discontinued
BinningX(const edm::ParameterSet &iConfig)
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
virtual void setCurrentFolder(std::string const &fullpath)
void book(DQMStore::IBooker &iBooker)
double zError() const
error on z
#define DEFINE_FWK_MODULE(type)
void calculateAndFillResolution(const std::vector< reco::TransientTrack > &tracks, size_t nvertices, float lumi, std::mt19937 &engine, AdaptiveVertexFitter &fitter)
double y() const
y coordinate
PrimaryVertexResolution(const edm::ParameterSet &iConfig)
Class to contain the online luminosity from soft FED 1022.
reco::TransientTrack build(const reco::Track *p) const
DiffPlots hDiff_instLumiScal_
~PrimaryVertexResolution() override
std::vector< Vertex > VertexCollection
collection of Vertex objects
auto const & tracks
cannot be loose
const BinningY & binningY_
void analyze(const edm::Event &, const edm::EventSetup &) override
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const override
std::vector< Vertex > VertexCollection
LuminosityBlockNumber_t luminosityBlock() const
const BinningX & binningX_
bool getData(T &iHolder) const
Plots(const BinningX &binX, const BinningY &binY)
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
const BinningY & binningY_
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)
edm::EDGetTokenT< LumiScalersCollection > lumiScalersSrc_
trackRef_iterator tracks_end() const
last iterator over tracks
double z() const
z coordinate
void bookLogX(DQMStore::IBooker &iBooker, const T &binArray)
trackRef_iterator tracks_begin() const
first iterator over tracks
DiffPlots hDiff_Nvertices_
size_t tracksSize() const
number of tracks
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
std::array< T, N+1 > makeLogBins(const T &min, const T &max)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
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)
std::vector< LumiScalers > LumiScalersCollection
AdaptiveVertexFitter fitter_
void book(DQMStore::IBooker &iBooker, Args &&...args)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
edm::EDGetTokenT< OnlineLuminosityRecord > metaDataSrc_
Power< A, B >::type pow(const A &a, const B &b)
double yError() const
error on y
void setLogX(Args &&...args)