Commit f1fc7764 authored by Christian Bierlich's avatar Christian Bierlich

more fixing

parent c16f8fda
......@@ -3,7 +3,7 @@
#include "Rivet/Projections/ChargedFinalState.hh"
#include "Rivet/Projections/PrimaryParticles.hh"
#include "Rivet/Tools/Correlators.hh"
#include "YODA/Scatter2D.h"
namespace Rivet {
......@@ -25,38 +25,29 @@ namespace Rivet {
//@{
/// Book histograms and initialise projections before the run
void init() {
ChargedFinalState cfs(Cuts::abseta < 1.0);
declare(cfs, "CFS");
ChargedFinalState pp(Cuts::abseta < 2.0);
declare(pp, "PP");
book(h_c22, "c22",120,0,120);
book(h_c23, "c23",120,0,120);
book(h_v22pT, "v22pT",10,0,10);
ec22 = bookECorrelator<2,2>("ec22",*h_c22);
ec23 = bookECorrelator<3,2>("ec32",*h_c22);
ec22pT = bookECorrelator<2,2>("ec22pT",*h_v22pT);
book(h_c22, "c22", {0.,1.,2.,5.,20.,30.,50.,70.,100});
ec22 = bookECorrelator<2,2>("ec22",{0.,1.,2.,5.,20.,30.,50.,70.,100});
pair<int, int> max = getMaxValues();
// Declare correlator projections.
declare(Correlators(pp, max.first, max.second, h_v22pT),"CRS");
declare(Correlators(pp, max.first, max.second),"CRS");
}
/// Perform the per-event analysis
void analyze(const Event& event) {
const Correlators& c = apply<Correlators>(event,"CRS");
ec22->fill(apply<ChargedFinalState>(event,"CFS").particles().size(), c);
ec23->fill(apply<ChargedFinalState>(event,"CFS").particles().size(), c);
ec22pT->fill(c);
}
/// Normalise histograms etc., after the run
void finalize() {
stream();
cnTwoInt(h_c22,ec22);
cnTwoInt(h_c23,ec23);
vnTwoDiff(h_v22pT,ec22pT);
}
//@}
private:
......@@ -64,11 +55,7 @@ namespace Rivet {
/// @name Histograms
//@{
Scatter2DPtr h_c22;
Scatter2DPtr h_v22pT;
ECorrPtr ec22;
ECorrPtr ec22pT;
Scatter2DPtr h_c23;
ECorrPtr ec23;
//@}
};
......
......@@ -603,20 +603,22 @@ namespace Rivet {
/// Typedef of shared pointer to ECorrelator.
typedef shared_ptr<ECorrelator> ECorrPtr;
/// @brief Book an ECorrelator in the same way as a histogram
/// @todo Rename to book(ECorrPtr, ...)
ECorrPtr bookECorrelator(const string name, const vector<int>& h, const YODA::Scatter2D& hIn) {
vector<double> binIn;
for (auto b : hIn.points()) binIn.push_back(b.xMin());
binIn.push_back(hIn.points().back().xMax());
return bookECorrelator(name, h, binIn);
}
/// @brief Book an ECorrelator in the same way as a histogram
/// @todo Rename to book(ECorrPtr, ...)
ECorrPtr bookECorrelator(const string name, const vector<int>& h, vector<double>& binIn) {
ECorrPtr ecPtr = ECorrPtr(new ECorrelator(h, binIn));
list<Profile1DPtr> eCorrProfs;
for (int i = 0; i < BOOT_BINS; ++i) {
Profile1DPtr tmp;
book(tmp, "TMP/FINAL/"+name+"-"+to_string(i),hIn);
//tmp->setPath(this->name()+"/FINAL/" + name+"-"+to_string(i));
//tmp->setPath(tmp->path()+"FINAL");
book(tmp,"TMP/"+name+"-"+to_string(i),binIn);
eCorrProfs.push_back(tmp);
}
ecPtr->setProfs(eCorrProfs);
......@@ -627,17 +629,12 @@ namespace Rivet {
/// @brief Book a gapped ECorrelator with two harmonic vectors
/// @todo Rename to book(ECorrPtr, ...)
ECorrPtr bookECorrelator(const string name, const vector<int>& h1,
const vector<int>& h2, const YODA::Scatter2D& hIn ) {
vector<double> binIn;
for (auto b : hIn.points()) binIn.push_back(b.xMin());
binIn.push_back(hIn.points().back().xMax());
const vector<int>& h2, vector<double>& binIn) {
ECorrPtr ecPtr = ECorrPtr(new ECorrelator(h1, h2, binIn));
list<Profile1DPtr> eCorrProfs;
for (int i = 0; i < BOOT_BINS; ++i) {
Profile1DPtr tmp;
book(tmp, "TMP/FINAL/"+name+"-"+to_string(i),hIn);
//tmp->setPath(this->name()+"/FINAL/" + name+"-"+to_string(i));
//tmp->setPath(tmp->path()+"FINAL");
book(tmp,"TMP/"+name+"-"+to_string(i),binIn);
eCorrProfs.push_back(tmp);
}
ecPtr->setProfs(eCorrProfs);
......@@ -645,16 +642,35 @@ namespace Rivet {
return ecPtr;
}
/// @brief Book a gapped ECorrelator with two harmonic vectors
/// @todo Rename to book(ECorrPtr, ...)
ECorrPtr bookECorrelator(const string name, const vector<int>& h1,
const vector<int>& h2, const YODA::Scatter2D& hIn ) {
vector<double> binIn;
for (auto b : hIn.points()) binIn.push_back(b.xMin());
binIn.push_back(hIn.points().back().xMax());
return bookECorrelator(name, h1, h2, binIn);
}
/// Shorthand for gapped correlators, splitting the harmonic vector into negative and positive components
///
/// @todo Rename to book(ECorrPtr, ...)
ECorrPtr bookECorrelatorGap (const string name, const vector<int>& h,
ECorrPtr bookECorrelatorGap(const string name, const vector<int>& h,
const YODA::Scatter2D& hIn) {
const vector<int> h1(h.begin(), h.begin() + h.size() / 2);
const vector<int> h2(h.begin() + h.size() / 2, h.end());
return bookECorrelator(name, h1, h2, hIn);
}
/// @brief Templated version of correlator booking which takes
/// @a N desired harmonic and @a M number of particles, and given bins.
///
/// @todo Rename to book(ECorrPtr, ...)
template<unsigned int N, unsigned int M>
ECorrPtr bookECorrelator(const string name, vector<double> binIn) {
return bookECorrelator(name, Correlators::hVec(N, M), binIn);
}
/// @brief Templated version of correlator booking which takes
/// @a N desired harmonic and @a M number of particles
///
......@@ -670,7 +686,11 @@ namespace Rivet {
/// @todo Rename to book(ECorrPtr, ...)
template<unsigned int N, unsigned int M>
ECorrPtr bookECorrelatorGap(const string name, const YODA::Scatter2D& hIn) {
return bookECorrelatorGap(name, Correlators::hVec(N, M), hIn);
const vector<int> h = Correlators::hVec(N,M);
const vector<int> h1(h.begin(), h.begin() + h.size() / 2);
const vector<int> h2(h.begin() + h.size() / 2, h.end());
return bookECorrelator(name, h1, h2, hIn);
}
......@@ -681,7 +701,7 @@ namespace Rivet {
/// (ie. multi-histogram merging) for the analysis.
void stream() {
for (auto ecItr = eCorrPtrs.begin(); ecItr != eCorrPtrs.end(); ++ecItr){
(*ecItr)->fillFromProfs();
//(*ecItr)->fillFromProfs();
corrPlot(list<Profile1DPtr>((*ecItr)->profBegin(), (*ecItr)->profEnd()), *ecItr);
}
}
......@@ -765,6 +785,7 @@ namespace Rivet {
}
h->reset();
h->points().clear();
for (int i = 0, N = points.size(); i < N; ++i)
h->addPoint(points[i]);
}
......@@ -954,8 +975,8 @@ namespace Rivet {
// (and no desire to add it) of sumWX of the profile, so really
// we should use a Dbn1D - but that does not work for Profile1D's.
profBins.push_back( YODA::ProfileBin1D((*hItr)->bin(j).xEdges(),
YODA::Dbn2D( binPtrs[i]->numEntries(), binPtrs[i]->sumW(),
binPtrs[i]->sumW2(), 0., 0., binPtrs[i]->sumWX(), 0, 0)));
YODA::Dbn2D( binPtrs[i]->numEntries(), binPtrs[i]->sumW(),
binPtrs[i]->sumW2(), 0., 0., binPtrs[i]->sumWX(), 0, 0)));
ne += binPtrs[i]->numEntries();
sow += binPtrs[i]->sumW();
sow2 += binPtrs[i]->sumW2();
......@@ -971,10 +992,11 @@ namespace Rivet {
(*hItr)->addBin(profBins[j]);
// The reference flow in the underflow bin.
(*hItr)->setUnderflow(YODA::Dbn2D(refBins[i]->numEntries(),
refBins[i]->sumW(), refBins[i]->sumW2(), 0., 0.,
refBins[i]->sumWX(), 0., 0.));
refBins[i]->sumW(), refBins[i]->sumW2(), 0., 0.,
refBins[i]->sumWX(), 0., 0.));
} // End loop of bootstrapped correlators.
}
// @brief Four particle integrated cn.
const void cnFourInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4) const {
auto e2bins = e2->getBins();
......
......@@ -495,7 +495,7 @@ namespace Rivet {
Scatter2DPtr & Analysis::book(Scatter2DPtr & s2d, const string& hname, size_t npts, double lower, double upper) {
const string path = histoPath(hname);
Scatter2D scat;
Scatter2D scat(path, hname);
const double binwidth = (upper-lower)/npts;
for (size_t pt = 0; pt < npts; ++pt) {
const double bincentre = lower + (pt + 0.5) * binwidth;
......@@ -511,7 +511,7 @@ namespace Rivet {
Scatter2DPtr & Analysis::book(Scatter2DPtr & s2d, const string& hname, const vector<double>& binedges) {
const string path = histoPath(hname);
Scatter2D scat;
Scatter2D scat(path, hname);
for (size_t pt = 0; pt < binedges.size()-1; ++pt) {
const double bincentre = (binedges[pt] + binedges[pt+1]) / 2.0;
const double binwidth = binedges[pt+1] - binedges[pt];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment