2#ifndef RIVET_Correlators_HH
3#define RIVET_Correlators_HH
21#include "Rivet/Analysis.hh"
22#include "Rivet/Projection.hh"
23#include "Rivet/Projections/ParticleFinder.hh"
24#include "YODA/Scatter2D.h"
55 int pMaxIn = 0, vector<double> pTbinEdgesIn = {});
59 int pMaxIn,
const YODA::Scatter2D hIn);
75 bool overflow =
false)
const;
86 vector<int> n1, vector<int> n2)
const;
99 const vector<pair<double,double>>
106 static vector<int>
hVec(
int n,
int m) {
108 cout <<
"Harmonic Vector: Number of particles must be an even number." << endl;
111 vector<int> ret = {};
112 for (
int i = 0; i < m; ++i) {
113 if (i < m/2) ret.push_back(n);
114 else ret.push_back(-n);
122 int nMax = 0, pMax = 0;
123 for (vector<int> h : hList) {
124 int tmpN = 0, tmpP = 0;
125 for (
int i = 0; i < int(h.size()); ++i) {
129 if (tmpN > nMax) nMax = tmpN;
130 if (tmpP > pMax) pMax = tmpP;
132 return make_pair(nMax,pMax);
147 if (nMax != other->nMax)
return CmpState::NEQ;
148 if (pMax != other->pMax)
return CmpState::NEQ;
149 if (pTbinEdges != other->pTbinEdges)
return CmpState::NEQ;
154 void fillCorrelators(
const Particle&
p,
const double& weight);
157 const complex<double> getQ(
int n,
int p)
const {
158 bool isNeg = (n < 0);
159 if (isNeg)
return conj( qVec[abs(n)][
p] );
160 else return qVec[n][
p];
164 const complex<double> getP(
int n,
int p,
double pT = 0.)
const {
165 bool isNeg = (n < 0);
166 map<double, Vec2D>::const_iterator pTitr = pVec.lower_bound(
pT);
167 if (pTitr == pVec.end())
return DBL_NAN;
168 if (isNeg)
return conj( pTitr->second[abs(n)][
p] );
169 else return pTitr->second[n][
p];
178 const complex<double> recCorr(
int order, vector<int> n,
179 vector<int>
p,
bool useP,
double pT = 0.)
const;
185 const complex<double> twoPartCorr(
int n1,
int n2,
int p1 = 1,
186 int p2 = 1,
double pT = 0.,
bool useP =
false)
const;
192 const complex<double> _ZERO = {0., 0.};
193 const double _TINY = 1e-10;
196 typedef vector< vector<complex<double>> > Vec2D;
200 map<double, Vec2D> pVec;
206 vector<double> pTbinEdges;
227 static const int BOOT_BINS = 9;
244 virtual ~CorBinBase() {};
246 virtual void fill(
const pair<double, double>& cor,
const double& weight = 1.0) = 0;
247 virtual double mean()
const = 0;
256 class CorSingleBin :
public CorBinBase {
261 : _sumWX(0.), _sumW(0.), _sumW2(0.), _numEntries(0.)
270 void fill(
const pair<double, double>& cor,
const double& weight = 1.0) {
272 if (cor.second < 1e-10)
return;
275 _sumWX += cor.first * weight;
276 _sumW += weight * cor.second;
277 _sumW2 += weight * weight * cor.second * cor.second;
282 double mean()
const {
283 if (_sumW < 1e-10)
return 0;
284 return _sumWX / _sumW;
288 double sumW()
const {
293 double sumW2()
const {
298 double sumWX()
const {
303 double numEntries()
const {
308 void addContent(
double ne,
double sw,
double sw2,
double swx) {
318 double _sumWX, _sumW, _sumW2, _numEntries;
327 class CorBin :
public CorBinBase {
335 CorBin() :
binIndex(0), nBins(BOOT_BINS) {
336 for(
size_t i = 0; i < nBins; ++i) bins.push_back(CorSingleBin());
343 void fill(
const pair<double, double>& cor,
const double& weight = 1.0) {
345 if (cor.second < 1e-10)
return;
353 double mean()
const {
356 for (
auto b : bins) {
357 if (b.sumW() < 1e-10)
continue;
365 vector<CorSingleBin> getBins()
const {
370 template<
class T=CorBinBase>
371 vector<T*> getBinPtrs() {
372 vector<T*> ret(bins.size());
373 transform(bins.begin(), bins.end(), ret.begin(), [](CorSingleBin& b) {return &b;});
379 vector<CorSingleBin> bins;
410 : h1(h), h2({}), binX(binIn), binContent(binIn.size() - 1), reference()
417 ECorrelator(vector<int> h1In, vector<int> h2In, vector<double> binIn)
418 : h1(h1In), h2(h2In), binX(binIn), binContent(binIn.size() - 1), reference()
423 int index = getBinIndex(obs);
424 if (index < 0)
return;
433 cout <<
"Trying to fill gapped correlator, but harmonics behind the gap (h2) are not given!" << endl;
436 int index = getBinIndex(obs);
437 if (index < 0)
return;
448 if (diffCorr.size() != binX.size() - 1)
449 cout <<
"Tried to fill event with wrong binning (ungapped)" << endl;
450 for (
size_t i = 0; i < diffCorr.size(); ++i) {
451 int index = getBinIndex(binX[i]);
452 if (index < 0)
return;
453 binContent[index].fill(diffCorr[i], weight);
464 cout <<
"Trying to fill gapped correlator, but harmonics behind "
465 "the gap (h2) are not given!" << endl;
470 if (diffCorr.size() != binX.size() - 1)
471 cout <<
"Tried to fill event with wrong binning (gapped)" << endl;
472 for (
size_t i = 0; i < diffCorr.size(); ++i) {
473 int index = getBinIndex(binX[i]);
474 if (index < 0)
return;
475 binContent[index].fill(diffCorr[i], weight);
487 vector<CorBinBase*> ret(binContent.size());
488 transform(binContent.begin(), binContent.end(), ret.begin(), [](CorBin& b) {return &b;});
514 if (reference.mean() < 1e-10)
515 cout <<
"Warning: ECorrelator, reference bin is zero." << endl;
527 auto refs = reference.getBinPtrs<CorSingleBin>();
528 for (
size_t i = 0; i < profs.size(); ++i) {
529 if (yao->path() ==
"/RAW/"+
name+
"/TMP/"+profs[i]) {
530 YODA::Profile1DPtr pPtr = dynamic_pointer_cast<YODA::Profile1D>(yao);
531 for (
size_t j = 0; j < binX.size() - 1; ++j) {
532 const YODA::ProfileBin1D& pBin = pPtr->binAt(binX[j]);
533 auto tmp = binContent[j].getBinPtrs<CorSingleBin>();
534 tmp[i]->addContent(pBin.numEntries(), pBin.sumW(), pBin.sumW2(),
538 const YODA::Dbn2D& uBin = pPtr->underflow();
539 refs[i]->addContent(uBin.numEntries(), uBin.sumW(), uBin.sumW2(),
550 int getBinIndex(
const double& obs)
const {
553 if (obs >= binX.back())
return -1;
555 if (obs < binX[0])
return -1;
557 for (
int i = 0, N = binX.size() - 1; i < N; ++i, ++index)
558 if (obs >= binX[i] && obs < binX[i + 1])
break;
568 vector<CorBin> binContent;
573 vector <string> profs;
580 vector< vector<int>> harmVecs;
581 for (
auto eItr = eCorrPtrs.begin(); eItr != eCorrPtrs.end(); ++eItr) {
582 vector<int> h1 = (*eItr)->getH1();
583 vector<int> h2 = (*eItr)->getH2();
584 if (h1.size() > 0) harmVecs.push_back(h1);
585 if (h2.size() > 0) harmVecs.push_back(h2);
587 if (harmVecs.size() == 0) {
588 cout <<
"Warning: You tried to extract max values from harmonic "
589 "vectors, but have not booked any." << endl;
590 return pair<int,int>();
601 vector<double> binIn;
602 for (
auto b : hIn.points()) binIn.push_back(b.xMin());
603 binIn.push_back(hIn.points().back().xMax());
611 vector<string> eCorrProfs;
612 for (
int i = 0; i < BOOT_BINS; ++i) {
614 book(tmp,
"TMP/"+
name+
"-"+to_string(i),binIn);
615 eCorrProfs.push_back(
name+
"-"+to_string(i));
617 ecPtr->setProfs(eCorrProfs);
618 eCorrPtrs.push_back(ecPtr);
625 const vector<int>& h2, vector<double>& binIn) {
627 vector<string> eCorrProfs;
628 for (
int i = 0; i < BOOT_BINS; ++i) {
630 book(tmp,
"TMP/"+
name+
"-"+to_string(i),binIn);
631 eCorrProfs.push_back(
name+
"-"+to_string(i));
633 ecPtr->setProfs(eCorrProfs);
634 eCorrPtrs.push_back(ecPtr);
641 const vector<int>& h2,
const YODA::Scatter2D& hIn ) {
642 vector<double> binIn;
643 for (
auto b : hIn.points()) binIn.push_back(b.xMin());
644 binIn.push_back(hIn.points().back().xMax());
653 const YODA::Scatter2D& hIn) {
654 const vector<int> h1(h.begin(), h.begin() + h.size() / 2);
655 const vector<int> h2(h.begin() + h.size() / 2, h.end());
663 template<
unsigned int N,
unsigned int M>
672 template<
unsigned int N,
unsigned int M>
681 template<
unsigned int N,
unsigned int M>
684 const vector<int> h1(h.begin(), h.begin() + h.size() / 2);
685 const vector<int> h2(h.begin() + h.size() / 2, h.end());
693 list<ECorrPtr> eCorrPtrs;
703 :
Analysis(n), errorMethod(VARIANCE)
714 static void fillScatter(Scatter2DPtr h, vector<double>& binx, T func) {
715 vector<YODA::Point2D> points;
717 bool hasBins = (h->points().size() > 0);
718 for (
int i = 0, N = binx.size() - 1; i < N; ++i) {
719 double xMid = (binx[i] + binx[i + 1]) / 2.0;
720 double xeMin = fabs(xMid - binx[i]);
721 double xeMax = fabs(xMid - binx[i + 1]);
723 xMid = h->points()[i].x();
724 xeMin = h->points()[i].xErrMinus();
725 xeMax = h->points()[i].xErrPlus();
727 double yVal = func(i);
728 if (std::isnan(yVal)) yVal = 0.;
730 points.push_back(YODA::Point2D(xMid, yVal, xeMin, xeMax, yErr, yErr));
734 for (
int i = 0, N = points.size(); i < N; ++i) h->addPoint(points[i]);
746 vector<pair<double, double> >& yErr)
const {
747 vector<YODA::Point2D> points;
749 bool hasBins = (h->points().size() > 0);
750 for (
int i = 0, N = binx.size() - 1; i < N; ++i) {
751 double xMid = (binx[i] + binx[i + 1]) / 2.0;
752 double xeMin = fabs(xMid - binx[i]);
753 double xeMax = fabs(xMid - binx[i + 1]);
755 xMid = h->points()[i].x();
756 xeMin = h->points()[i].xErrMinus();
757 xeMax = h->points()[i].xErrPlus();
759 double yVal = func(i);
760 if (std::isnan(yVal))
761 points.push_back(YODA::Point2D(xMid, 0., xeMin, xeMax,0., 0.));
763 points.push_back(YODA::Point2D(xMid, yVal, xeMin, xeMax,
764 yErr[i].first, yErr[i].second));
769 for (
int i = 0, N = points.size(); i < N; ++i)
770 h->addPoint(points[i]);
777 static void nthPow(Scatter2DPtr hOut,
const Scatter2DPtr hIn,
const double& n,
const double& k = 1.0) {
778 if (n == 0 || n == 1) {
779 cout <<
"Error: Do not take the 0th or 1st power of a Scatter2D,"
780 " use scale instead." << endl;
783 if (hIn->points().size() != hOut->points().size()) {
784 cout <<
"nthRoot: Scatterplots: " << hIn->name() <<
" and " <<
785 hOut->name() <<
" not initialized with same length." << endl;
788 vector<YODA::Point2D> points;
790 double eFac = pow(k,1./n)/n;
791 for (
auto b : hIn->points()) {
792 double yVal = pow(k * b.y(),n);
793 if (std::isnan(yVal))
794 points.push_back(YODA::Point2D(b.x(), 0., b.xErrMinus(),
795 b.xErrPlus(), 0, 0 ));
797 double yemin = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrMinus();
798 if (std::isnan(yemin)) yemin = b.yErrMinus();
799 double yemax = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrPlus();
800 if (std::isnan(yemax)) yemax = b.yErrPlus();
801 points.push_back(YODA::Point2D(b.x(), yVal, b.xErrMinus(),
802 b.xErrPlus(), yemin, yemax ));
806 hOut->points().clear();
807 for (
int i = 0, N = points.size(); i < N; ++i)
808 hOut->addPoint(points[i]);
815 static void nthPow(Scatter2DPtr h,
const double& n,
const double& k = 1.0) {
816 if (n == 0 || n == 1) {
817 cout <<
"Error: Do not take the 0th or 1st power of a Scatter2D,"
818 " use scale instead." << endl;
821 vector<YODA::Point2D> points;
822 vector<YODA::Point2D> pIn = h->points();
824 double eFac = pow(k,1./n)/n;
826 double yVal = pow(k * b.y(),n);
827 if (std::isnan(yVal))
828 points.push_back(YODA::Point2D(b.x(), 0., b.xErrMinus(),
829 b.xErrPlus(), 0, 0 ));
831 double yemin = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrMinus();
832 if (std::isnan(yemin)) yemin = b.yErrMinus();
833 double yemax = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrPlus();
834 if (std::isnan(yemax)) yemax = b.yErrPlus();
835 points.push_back(YODA::Point2D(b.x(), yVal, b.xErrMinus(),
836 b.xErrPlus(), yemin, yemax ));
841 for (
int i = 0, N = points.size(); i < N; ++i) h->addPoint(points[i]);
853 for (
int i = 0; i < BOOT_BINS; ++i) avg += func(i);
854 avg /= double(BOOT_BINS);
857 for (
int i = 0; i < BOOT_BINS; ++i) var += pow(func(i) - avg, 2.);
858 var /= (double(BOOT_BINS) - 1);
859 return pair<double, double>(var, var);
871 for (
int i = 0; i < BOOT_BINS; ++i) avg += func(i);
872 avg /= double(BOOT_BINS);
876 for (
int i = 0; i < BOOT_BINS; ++i) {
877 double yVal = func(i);
878 if (yMin > yVal) yMin = yVal;
879 else if (yMax < yVal) yMax = yVal;
881 return pair<double, double>(fabs(avg - yMin), fabs(yMax - avg));
891 cout <<
"Error: Error method not found!" << endl;
892 return pair<double, double>(0.,0.);
898 vector<CorBin> bins = e2->getBins();
899 vector<double> binx = e2->getBinX();
901 if (binx.size() - 1 != bins.size()){
902 cout <<
"cnTwoInt: Bin size (x,y) differs!" << endl;
905 vector<CorBinBase*> binPtrs;
907 auto cn = [&] (
int i) {
return binPtrs[i]->mean(); };
909 vector<pair<double, double> > yErr;
910 for (
int j = 0, N = bins.size(); j < N; ++j) {
911 binPtrs = bins[j].getBinPtrs();
914 binPtrs = e2->getBinPtrs();
937 void rawHookIn(YODA::AnalysisObjectPtr yao)
final {
939 for (
auto ec : eCorrPtrs)
if(ec->fillFromProfile(yao,
name()))
break;;
946 void rawHookOut(vector<MultiweightAOPtr> raos,
size_t iW)
final {
948 for (
auto ec : eCorrPtrs) {
949 vector<CorBin> corBins = ec->getBins();
950 vector<double> binx = ec->getBinX();
951 auto ref = ec->getReference();
952 auto refBins = ref.getBinPtrs<CorSingleBin>();
954 if (binx.size() - 1 != corBins.size()){
955 cout <<
"corrPlot: Bin size (x,y) differs!" << endl;
959 for (
int i = 0, N = ec->profs.size(); i < N; ++i) {
960 for (
auto rao : raos) {
961 if (rao->path() ==
"/"+
name()+
"/TMP/"+ec->profs[i]) {
963 rao.get()->setActiveWeightIdx(iW);
964 YODA::Profile1DPtr pPtr = dynamic_pointer_cast<YODA::Profile1D>(
965 rao.get()->activeYODAPtr());
967 vector<YODA::ProfileBin1D> profBins;
969 double ne = 0., sow = 0., sow2 = 0.;
970 for (
size_t j = 0, N = binx.size() - 1; j < N; ++j) {
971 vector<CorSingleBin*> binPtrs =
972 corBins[j].getBinPtrs<CorSingleBin>();
976 profBins.push_back( YODA::ProfileBin1D(pPtr->bin(j).xEdges(),
977 YODA::Dbn2D( binPtrs[i]->numEntries(), binPtrs[i]->sumW(),
978 binPtrs[i]->sumW2(), 0., 0., binPtrs[i]->sumWX(), 0, 0)));
979 ne += binPtrs[i]->numEntries();
980 sow += binPtrs[i]->sumW();
981 sow2 += binPtrs[i]->sumW2();
985 pPtr->bins().clear();
987 pPtr->addBins(profBins);
989 pPtr->setTotalDbn(YODA::Dbn2D(ne,sow,sow2,0.,0.,0.,0.,0.));
991 pPtr->setUnderflow(YODA::Dbn2D(refBins[i]->numEntries(),
992 refBins[i]->
sumW(), refBins[i]->
sumW2(), 0., 0.,
993 refBins[i]->sumWX(), 0., 0.));
1002 auto e2bins = e2->getBins();
1003 auto e4bins = e4->getBins();
1004 auto binx = e2->getBinX();
1005 if (binx.size() - 1 != e2bins.size()){
1006 cout <<
"cnFourInt: Bin size (x,y) differs!" << endl;
1009 if (binx != e4->getBinX()) {
1010 cout <<
"Error in cnFourInt: Correlator x-binning differs!" << endl;
1013 vector<CorBinBase*> e2binPtrs;
1014 vector<CorBinBase*> e4binPtrs;
1015 auto cn = [&] (
int i) {
1016 double e22 = e2binPtrs[i]->mean() * e2binPtrs[i]->mean();
1017 return e4binPtrs[i]->mean() - 2. * e22;
1020 vector<pair<double, double> > yErr;
1021 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1022 e2binPtrs = e2bins[j].getBinPtrs();
1023 e4binPtrs = e4bins[j].getBinPtrs();
1027 e2binPtrs = e2->getBinPtrs();
1028 e4binPtrs = e4->getBinPtrs();
1035 cnFourInt(h, e2, e4);
1043 auto e2bins = e2->getBins();
1044 auto e4bins = e4->getBins();
1045 auto e6bins = e6->getBins();
1046 auto binx = e2->getBinX();
1047 if (binx.size() - 1 != e2bins.size()){
1048 cout <<
"cnSixInt: Bin size (x,y) differs!" << endl;
1051 if (binx != e4->getBinX() || binx != e6->getBinX()) {
1052 cout <<
"Error in cnSixInt: Correlator x-binning differs!" << endl;
1055 vector<CorBinBase*> e2binPtrs;
1056 vector<CorBinBase*> e4binPtrs;
1057 vector<CorBinBase*> e6binPtrs;
1058 auto cn = [&] (
int i) {
1059 double e23 = pow(e2binPtrs[i]->
mean(), 3.0);
1060 return e6binPtrs[i]->mean() - 9.*e2binPtrs[i]->mean()*e4binPtrs[i]->mean() +
1064 vector<pair<double, double> > yErr;
1065 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1066 e2binPtrs = e2bins[j].getBinPtrs();
1067 e4binPtrs = e4bins[j].getBinPtrs();
1068 e6binPtrs = e6bins[j].getBinPtrs();
1072 e2binPtrs = e2->getBinPtrs();
1073 e4binPtrs = e4->getBinPtrs();
1074 e6binPtrs = e6->getBinPtrs();
1090 auto e2bins = e2->getBins();
1091 auto e4bins = e4->getBins();
1092 auto e6bins = e6->getBins();
1093 auto e8bins = e8->getBins();
1094 auto binx = e2->getBinX();
1095 if (binx.size() - 1 != e2bins.size()){
1096 cout <<
"cnEightInt: Bin size (x,y) differs!" << endl;
1099 if (binx != e4->getBinX() || binx != e6->getBinX() ||
1100 binx != e8->getBinX()) {
1101 cout <<
"Error in cnEightInt: Correlator x-binning differs!" << endl;
1104 vector<CorBinBase*> e2binPtrs;
1105 vector<CorBinBase*> e4binPtrs;
1106 vector<CorBinBase*> e6binPtrs;
1107 vector<CorBinBase*> e8binPtrs;
1108 auto cn = [&] (
int i ) {
1109 double e22 = e2binPtrs[i]->mean() * e2binPtrs[i]->mean();
1110 double e24 = e22 * e22;
1111 double e42 = e4binPtrs[i]->mean() * e4binPtrs[i]->mean();
1112 return e8binPtrs[i]->mean() - 16. * e6binPtrs[i]->mean() *
1113 e2binPtrs[i]->mean() - 18. * e42 + 144. * e4binPtrs[i]->mean()*e22 - 144. * e24;
1116 vector<pair<double, double> > yErr;
1117 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1118 e2binPtrs = e2bins[j].getBinPtrs();
1119 e4binPtrs = e4bins[j].getBinPtrs();
1120 e6binPtrs = e6bins[j].getBinPtrs();
1121 e8binPtrs = e8bins[j].getBinPtrs();
1125 e2binPtrs = e2->getBinPtrs();
1126 e4binPtrs = e4->getBinPtrs();
1127 e6binPtrs = e6->getBinPtrs();
1128 e8binPtrs = e8->getBinPtrs();
1136 nthPow(h, 1./8., -1./33.);
1142 auto e2bins = e2Dif->getBins();
1143 auto ref = e2Dif->getReference();
1144 auto binx = e2Dif->getBinX();
1145 if (binx.size() -1 != e2bins.size()) {
1146 cout <<
"vnTwoDif: Bin size (x,y) differs!" << endl;
1149 vector<CorBinBase*> e2binPtrs;
1150 vector<CorBinBase*> refPtrs;
1151 auto vn = [&] (
int i) {
1153 if (ref.mean() <= 0)
return 0.;
1154 return e2binPtrs[i]->mean() / sqrt(ref.mean());
1157 auto vnerr = [&] (
int i) {
1159 if (refPtrs[i]->
mean() <=0)
return 0.;
1160 return e2binPtrs[i]->mean() / sqrt(refPtrs[i]->
mean());
1163 vector<pair<double, double> > yErr;
1164 refPtrs = ref.getBinPtrs();
1165 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1166 e2binPtrs = e2bins[j].getBinPtrs();
1170 e2binPtrs = e2Dif->getBinPtrs();
1177 auto e2bins = e2Dif->getBins();
1178 auto e4bins = e4Dif->getBins();
1179 auto ref2 = e2Dif->getReference();
1180 auto ref4 = e4Dif->getReference();
1181 auto binx = e2Dif->getBinX();
1182 if (binx.size() - 1 != e2bins.size()){
1183 cout <<
"vnFourDif: Bin size (x,y) differs!" << endl;
1186 if (binx != e4Dif->getBinX()) {
1187 cout <<
"Error in vnFourDif: Correlator x-binning differs!" << endl;
1190 vector<CorBinBase*> e2binPtrs;
1191 vector<CorBinBase*> e4binPtrs;
1192 vector<CorBinBase*> ref2Ptrs;
1193 vector<CorBinBase*> ref4Ptrs;
1194 double denom = 2 * ref2.mean() * ref2.mean() - ref4.mean();
1195 auto vn = [&] (
int i) {
1197 if (denom <= 0 )
return 0.;
1198 return ((2 * ref2.mean() * e2bins[i].mean() - e4bins[i].mean()) / pow(denom, 0.75));
1201 auto vnerr = [&] (
int i) {
1202 double denom2 = 2 * ref2Ptrs[i]->mean() * ref2Ptrs[i]->mean() -
1203 ref4Ptrs[i]->mean();
1205 if (denom2 <= 0)
return 0.;
1206 return ((2 * ref2Ptrs[i]->
mean() * e2binPtrs[i]->mean() - e4binPtrs[i]->mean()) / pow(denom2, 0.75));
1209 vector<pair<double, double> > yErr;
1210 ref2Ptrs = ref2.getBinPtrs();
1211 ref4Ptrs = ref4.getBinPtrs();
1212 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1213 e2binPtrs = e2bins[j].getBinPtrs();
1214 e4binPtrs = e4bins[j].getBinPtrs();
1218 e2binPtrs = e2Dif->getBinPtrs();
1219 e4binPtrs = e4Dif->getBinPtrs();
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:64
double sumW2() const
Get the sum of squared event weights seen (via the analysis handler).
double sumW() const
Get the sum of event weights seen (via the analysis handler).
Projection for calculating correlators for flow measurements.
Definition: Correlators.hh:38
const vector< pair< double, double > > pTBinnedCorrelatorsGap(const Correlators &other, vector< int > n1, vector< int > n2, bool overflow=false) const
pT differential correlators of n1 harmonic, for number n1.size()
CmpState compare(const Projection &p) const
Definition: Correlators.hh:145
void project(const Event &e)
const vector< pair< double, double > > pTBinnedCorrelators(vector< int > n, bool overflow=false) const
pT differential correlator of n harmonic, for number of powers n.size()
const pair< double, double > intCorrelator(vector< int > n) const
Integrated correlator of n harmonic, with the number of powers being the size of n....
Correlators(const ParticleFinder &fsp, int nMaxIn=2, int pMaxIn=0, vector< double > pTbinEdgesIn={})
const pair< double, double > intCorrelatorGap(const Correlators &other, vector< int > n1, vector< int > n2) const
Integrated correlator of n1 harmonic, for number of powers n1.size()
static vector< int > hVec(int n, int m)
Construct a harmonic vectors from n harmonics and m number of particles.
Definition: Correlators.hh:106
static pair< int, int > getMaxValues(vector< vector< int > > &hList)
Return the maximal values for n, p to be used in the constructor of Correlators(xxx,...
Definition: Correlators.hh:121
A helper class to calculate all event averages of correlators.
Definition: Correlators.hh:392
vector< double > getBinX() const
Get a copy of the bin x-values.
Definition: Correlators.hh:493
void setProfs(vector< string > prIn)
Set the prIn list of profile histograms associated with the internal bins.
Definition: Correlators.hh:521
void setReference(CorBin refIn)
Replace reference flow bin with another, e.g. calculated in another phase space or with other pid.
Definition: Correlators.hh:508
ECorrelator(vector< int > h, vector< double > binIn)
Constructor. Takes as argument the desired harmonic and number of correlated particles as a generic f...
Definition: Correlators.hh:409
void fill(const Correlators &c1, const Correlators &c2, const double &weight=1.0)
Fill bins with the appropriate correlator, and a rapidity gap between two Correlators.
Definition: Correlators.hh:462
vector< CorBin > getBins() const
Get a copy of the bin contents.
Definition: Correlators.hh:481
vector< int > getH2() const
Get a copy of the h2 harmonic vector.
Definition: Correlators.hh:503
ECorrelator(vector< int > h1In, vector< int > h2In, vector< double > binIn)
Constructor for gapped correlator.
Definition: Correlators.hh:417
void fill(const double &obs, const Correlators &c, double weight=1.0)
Fill the appropriate bin given an input (per event) observable, e.g. centrality.
Definition: Correlators.hh:422
bool fillFromProfile(YODA::AnalysisObjectPtr yao, string name)
Fill bins with content from preloaded histograms.
Definition: Correlators.hh:526
void fill(const double &obs, const Correlators &c1, const Correlators &c2, double weight=1.0)
Fill the appropriate bin given an input (per event) observable, e.g. centrality, with a rapidity gap ...
Definition: Correlators.hh:431
CorBin getReference() const
Extract the reference flow from a differential event averaged correlator.
Definition: Correlators.hh:513
void fill(const Correlators &c, const double &weight=1.0)
Fill the bins with the appropriate correlator.
Definition: Correlators.hh:445
vector< int > getH1() const
Get a copy of the h1 harmonic vector.
Definition: Correlators.hh:498
vector< CorBinBase * > getBinPtrs()
Return the bins as pointers to the base class.
Definition: Correlators.hh:486
Tools for flow analyses.
Definition: Correlators.hh:221
void vnTwoDiff(Scatter2DPtr h, ECorrPtr e2Dif) const
Two particle differential vn.
Definition: Correlators.hh:1141
void vnSixInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6) const
Six particle integrated vn.
Definition: Correlators.hh:1080
ECorrPtr bookECorrelator(const string name, const vector< int > &h1, const vector< int > &h2, vector< double > &binIn)
Book a gapped ECorrelator with two harmonic vectors.
Definition: Correlators.hh:624
void vnFourDiff(Scatter2DPtr h, ECorrPtr e2Dif, ECorrPtr e4Dif) const
Four particle differential vn.
Definition: Correlators.hh:1176
ECorrPtr bookECorrelator(const string name, vector< double > binIn)
Templated version of correlator booking which takes N desired harmonic and M number of particles,...
Definition: Correlators.hh:664
const pair< double, double > sampleError(T func) const
Selection method for which sample error to use, given in the constructor.
Definition: Correlators.hh:887
const pair< int, int > getMaxValues() const
Get the correct max N and max P for the set of booked correlators.
Definition: Correlators.hh:579
void cnSixInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6) const
Six particle integrated cn.
Definition: Correlators.hh:1041
ECorrPtr bookECorrelatorGap(const string name, const YODA::Scatter2D &hIn)
Templated version of gapped correlator booking which takes N desired harmonic and M number of particl...
Definition: Correlators.hh:682
CumulantAnalysis(const string &n)
Constructor.
Definition: Correlators.hh:702
void vnFourInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4) const
Four particle integrated vn.
Definition: Correlators.hh:1034
void fillScatter(Scatter2DPtr h, vector< double > &binx, F func, vector< pair< double, double > > &yErr) const
Helper method for turning correlators into Scatter2Ds with error estimates.
Definition: Correlators.hh:745
static void fillScatter(Scatter2DPtr h, vector< double > &binx, T func)
Helper method for turning correlators into Scatter2Ds.
Definition: Correlators.hh:714
ECorrPtr bookECorrelator(const string name, const vector< int > &h1, const vector< int > &h2, const YODA::Scatter2D &hIn)
Book a gapped ECorrelator with two harmonic vectors.
Definition: Correlators.hh:640
void corrPlot(Scatter2DPtr h, ECorrPtr e) const
Put an event-averaged correlator into a Scatter2D.
Definition: Correlators.hh:929
void cnTwoInt(Scatter2DPtr h, ECorrPtr e2) const
Two-particle integrated cn.
Definition: Correlators.hh:897
static pair< double, double > sampleVariance(T func)
Calculate the bootstrapped sample variance.
Definition: Correlators.hh:850
static pair< double, double > sampleEnvelope(T func)
Calculate the bootstrapped sample envelope.
Definition: Correlators.hh:868
static void nthPow(Scatter2DPtr hOut, const Scatter2DPtr hIn, const double &n, const double &k=1.0)
Take the n th power of all points in hIn and put the result in hOut.
Definition: Correlators.hh:777
ECorrPtr bookECorrelatorGap(const string name, const vector< int > &h, const YODA::Scatter2D &hIn)
Definition: Correlators.hh:652
ECorrPtr bookECorrelator(const string name, const YODA::Scatter2D &hIn)
Templated version of correlator booking which takes N desired harmonic and M number of particles.
Definition: Correlators.hh:673
ECorrPtr bookECorrelator(const string name, const vector< int > &h, vector< double > &binIn)
Book an ECorrelator in the same way as a histogram.
Definition: Correlators.hh:609
static void nthPow(Scatter2DPtr h, const double &n, const double &k=1.0)
Take the n th power of all points in h, and put the result back in the same Scatter2D.
Definition: Correlators.hh:815
ECorrPtr bookECorrelator(const string name, const vector< int > &h, const YODA::Scatter2D &hIn)
Book an ECorrelator in the same way as a histogram.
Definition: Correlators.hh:600
void rawHookOut(vector< MultiweightAOPtr > raos, size_t iW) final
Transform RAW ECorrelator Profiles to have content before writing them. Overloaded method from Analys...
Definition: Correlators.hh:946
void vnTwoInt(Scatter2DPtr h, ECorrPtr e2) const
Two particle integrated vn.
Definition: Correlators.hh:920
void vnEightInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6, ECorrPtr e8) const
Eight particle integrated vn.
Definition: Correlators.hh:1134
shared_ptr< ECorrelator > ECorrPtr
Typedef of shared pointer to ECorrelator.
Definition: Correlators.hh:596
void cnEightInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6, ECorrPtr e8) const
Eight particle integrated cn.
Definition: Correlators.hh:1088
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
Base class for projections which return subsets of an event's particles.
Definition: ParticleFinder.hh:11
Particle representation, either from a HepMC::GenEvent or reconstructed.
Definition: Particle.hh:53
Base class for all Rivet projections.
Definition: Projection.hh:29
Cmp< Projection > mkPCmp(const Projection &otherparent, const std::string &pname) const
CounterPtr & book(CounterPtr &, const std::string &name)
Book a counter.
double pT(const ParticleBase &p)
Unbound function access to pT.
Definition: ParticleBaseUtils.hh:656
double p(const ParticleBase &p)
Unbound function access to p.
Definition: ParticleBaseUtils.hh:653
Definition: MC_Cent_pPb.hh:10
std::enable_if< std::is_arithmetic< NUM1 >::value &&std::is_arithmetic< NUM2 >::value, int >::type binIndex(NUM1 val, std::initializer_list< NUM2 > binedges, bool allow_overflow=false)
Return the bin index of the given value, val, given a vector of bin edges.
Definition: MathUtils.hh:416
static constexpr double DBL_NAN
Convenient const for getting the double NaN value.
Definition: Utils.hh:46
std::enable_if< std::is_arithmetic< NUM >::value, double >::type mean(const vector< NUM > &sample)
Definition: MathUtils.hh:458