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);
62 using Projection::operator =;
79 bool overflow =
false)
const;
90 vector<int> n1, vector<int> n2)
const;
103 const vector<pair<double,double>>
110 static vector<int>
hVec(
int n,
int m) {
112 cout <<
"Harmonic Vector: Number of particles must be an even number." << endl;
115 vector<int> ret = {};
116 for (
int i = 0; i < m; ++i) {
117 if (i < m/2) ret.push_back(n);
118 else ret.push_back(-n);
126 int nMax = 0, pMax = 0;
127 for (vector<int> h : hList) {
128 int tmpN = 0, tmpP = 0;
129 for (
int i = 0; i < int(h.size()); ++i) {
133 if (tmpN > nMax) nMax = tmpN;
134 if (tmpP > pMax) pMax = tmpP;
136 return make_pair(nMax,pMax);
151 if (nMax != other->nMax)
return CmpState::NEQ;
152 if (pMax != other->pMax)
return CmpState::NEQ;
153 if (pTbinEdges != other->pTbinEdges)
return CmpState::NEQ;
158 void fillCorrelators(
const Particle&
p,
const double& weight);
161 const complex<double> getQ(
int n,
int p)
const {
162 bool isNeg = (n < 0);
163 if (isNeg)
return conj( qVec[abs(n)][
p] );
164 else return qVec[n][
p];
168 const complex<double> getP(
int n,
int p,
double pT = 0.)
const {
169 bool isNeg = (n < 0);
170 map<double, Vec2D>::const_iterator pTitr = pVec.lower_bound(
pT);
171 if (pTitr == pVec.end())
return DBL_NAN;
172 if (isNeg)
return conj( pTitr->second[abs(n)][
p] );
173 else return pTitr->second[n][
p];
182 const complex<double> recCorr(
int order, vector<int> n,
183 vector<int>
p,
bool useP,
double pT = 0.)
const;
189 const complex<double> twoPartCorr(
int n1,
int n2,
int p1 = 1,
190 int p2 = 1,
double pT = 0.,
bool useP =
false)
const;
196 const complex<double> _ZERO = {0., 0.};
197 const double _TINY = 1e-10;
200 typedef vector< vector<complex<double>> > Vec2D;
204 map<double, Vec2D> pVec;
210 vector<double> pTbinEdges;
231 static const int BOOT_BINS = 9;
248 virtual ~CorBinBase() {};
250 virtual void fill(
const pair<double, double>& cor,
const double& weight = 1.0) = 0;
251 virtual double mean()
const = 0;
260 class CorSingleBin :
public CorBinBase {
265 : _sumWX(0.), _sumW(0.), _sumW2(0.), _numEntries(0.)
274 void fill(
const pair<double, double>& cor,
const double& weight = 1.0) {
276 if (cor.second < 1e-10)
return;
279 _sumWX += cor.first * weight;
280 _sumW += weight * cor.second;
281 _sumW2 += weight * weight * cor.second * cor.second;
286 double mean()
const {
287 if (_sumW < 1e-10)
return 0;
288 return _sumWX / _sumW;
292 double sumW()
const {
297 double sumW2()
const {
302 double sumWX()
const {
307 double numEntries()
const {
312 void addContent(
double ne,
double sw,
double sw2,
double swx) {
322 double _sumWX, _sumW, _sumW2, _numEntries;
331 class CorBin :
public CorBinBase {
339 CorBin() :
binIndex(0), nBins(BOOT_BINS) {
340 for(
size_t i = 0; i < nBins; ++i) bins.push_back(CorSingleBin());
347 void fill(
const pair<double, double>& cor,
const double& weight = 1.0) {
349 if (cor.second < 1e-10)
return;
357 double mean()
const {
360 for (
auto b : bins) {
361 if (b.sumW() < 1e-10)
continue;
369 vector<CorSingleBin> getBins()
const {
374 template<
class T=CorBinBase>
375 vector<T*> getBinPtrs() {
376 vector<T*> ret(bins.size());
377 transform(bins.begin(), bins.end(), ret.begin(), [](CorSingleBin& b) {return &b;});
383 vector<CorSingleBin> bins;
414 : h1(h), h2({}), binX(binIn), binContent(binIn.size() - 1), reference()
421 ECorrelator(vector<int> h1In, vector<int> h2In, vector<double> binIn)
422 : h1(h1In), h2(h2In), binX(binIn), binContent(binIn.size() - 1), reference()
427 int index = getBinIndex(obs);
428 if (index < 0)
return;
437 cout <<
"Trying to fill gapped correlator, but harmonics behind the gap (h2) are not given!" << endl;
440 int index = getBinIndex(obs);
441 if (index < 0)
return;
452 if (diffCorr.size() != binX.size() - 1)
453 cout <<
"Tried to fill event with wrong binning (ungapped)" << endl;
454 for (
size_t i = 0; i < diffCorr.size(); ++i) {
455 int index = getBinIndex(binX[i]);
456 if (index < 0)
return;
457 binContent[index].fill(diffCorr[i], weight);
468 cout <<
"Trying to fill gapped correlator, but harmonics behind "
469 "the gap (h2) are not given!" << endl;
474 if (diffCorr.size() != binX.size() - 1)
475 cout <<
"Tried to fill event with wrong binning (gapped)" << endl;
476 for (
size_t i = 0; i < diffCorr.size(); ++i) {
477 int index = getBinIndex(binX[i]);
478 if (index < 0)
return;
479 binContent[index].fill(diffCorr[i], weight);
491 vector<CorBinBase*> ret(binContent.size());
492 transform(binContent.begin(), binContent.end(), ret.begin(), [](CorBin& b) {return &b;});
518 if (reference.mean() < 1e-10)
519 cout <<
"Warning: ECorrelator, reference bin is zero." << endl;
531 auto refs = reference.getBinPtrs<CorSingleBin>();
532 for (
size_t i = 0; i < profs.size(); ++i) {
533 if (yao->path() ==
"/RAW/"+
name+
"/TMP/"+profs[i]) {
534 YODA::Profile1DPtr pPtr = dynamic_pointer_cast<YODA::Profile1D>(yao);
535 for (
size_t j = 0; j < binX.size() - 1; ++j) {
536 const YODA::ProfileBin1D& pBin = pPtr->binAt(binX[j]);
537 auto tmp = binContent[j].getBinPtrs<CorSingleBin>();
538 tmp[i]->addContent(pBin.numEntries(), pBin.sumW(), pBin.sumW2(),
542 const YODA::Dbn2D& uBin = pPtr->underflow();
543 refs[i]->addContent(uBin.numEntries(), uBin.sumW(), uBin.sumW2(),
554 int getBinIndex(
const double& obs)
const {
557 if (obs >= binX.back())
return -1;
559 if (obs < binX[0])
return -1;
561 for (
int i = 0, N = binX.size() - 1; i < N; ++i, ++index)
562 if (obs >= binX[i] && obs < binX[i + 1])
break;
572 vector<CorBin> binContent;
577 vector <string> profs;
584 vector< vector<int>> harmVecs;
585 for (
auto eItr = eCorrPtrs.begin(); eItr != eCorrPtrs.end(); ++eItr) {
586 vector<int> h1 = (*eItr)->getH1();
587 vector<int> h2 = (*eItr)->getH2();
588 if (h1.size() > 0) harmVecs.push_back(h1);
589 if (h2.size() > 0) harmVecs.push_back(h2);
591 if (harmVecs.size() == 0) {
592 cout <<
"Warning: You tried to extract max values from harmonic "
593 "vectors, but have not booked any." << endl;
594 return pair<int,int>();
605 vector<double> binIn;
606 for (
auto b : hIn.points()) binIn.push_back(b.xMin());
607 binIn.push_back(hIn.points().back().xMax());
615 vector<string> eCorrProfs;
616 for (
int i = 0; i < BOOT_BINS; ++i) {
618 book(tmp,
"TMP/"+
name+
"-"+to_string(i),binIn);
619 eCorrProfs.push_back(
name+
"-"+to_string(i));
621 ecPtr->setProfs(eCorrProfs);
622 eCorrPtrs.push_back(ecPtr);
629 const vector<int>& h2, vector<double>& binIn) {
631 vector<string> eCorrProfs;
632 for (
int i = 0; i < BOOT_BINS; ++i) {
634 book(tmp,
"TMP/"+
name+
"-"+to_string(i),binIn);
635 eCorrProfs.push_back(
name+
"-"+to_string(i));
637 ecPtr->setProfs(eCorrProfs);
638 eCorrPtrs.push_back(ecPtr);
645 const vector<int>& h2,
const YODA::Scatter2D& hIn ) {
646 vector<double> binIn;
647 for (
auto b : hIn.points()) binIn.push_back(b.xMin());
648 binIn.push_back(hIn.points().back().xMax());
657 const YODA::Scatter2D& hIn) {
658 const vector<int> h1(h.begin(), h.begin() + h.size() / 2);
659 const vector<int> h2(h.begin() + h.size() / 2, h.end());
667 template<
unsigned int N,
unsigned int M>
676 template<
unsigned int N,
unsigned int M>
685 template<
unsigned int N,
unsigned int M>
688 const vector<int> h1(h.begin(), h.begin() + h.size() / 2);
689 const vector<int> h2(h.begin() + h.size() / 2, h.end());
697 list<ECorrPtr> eCorrPtrs;
707 :
Analysis(n), errorMethod(VARIANCE)
718 static void fillScatter(Scatter2DPtr h, vector<double>& binx, T func) {
719 vector<YODA::Point2D> points;
721 bool hasBins = (h->points().size() > 0);
722 for (
int i = 0, N = binx.size() - 1; i < N; ++i) {
723 double xMid = (binx[i] + binx[i + 1]) / 2.0;
724 double xeMin = fabs(xMid - binx[i]);
725 double xeMax = fabs(xMid - binx[i + 1]);
727 xMid = h->points()[i].x();
728 xeMin = h->points()[i].xErrMinus();
729 xeMax = h->points()[i].xErrPlus();
731 double yVal = func(i);
732 if (std::isnan(yVal)) yVal = 0.;
734 points.push_back(YODA::Point2D(xMid, yVal, xeMin, xeMax, yErr, yErr));
738 for (
int i = 0, N = points.size(); i < N; ++i) h->addPoint(points[i]);
750 vector<pair<double, double> >& yErr)
const {
751 vector<YODA::Point2D> points;
753 bool hasBins = (h->points().size() > 0);
754 for (
int i = 0, N = binx.size() - 1; i < N; ++i) {
755 double xMid = (binx[i] + binx[i + 1]) / 2.0;
756 double xeMin = fabs(xMid - binx[i]);
757 double xeMax = fabs(xMid - binx[i + 1]);
759 xMid = h->points()[i].x();
760 xeMin = h->points()[i].xErrMinus();
761 xeMax = h->points()[i].xErrPlus();
763 double yVal = func(i);
764 if (std::isnan(yVal))
765 points.push_back(YODA::Point2D(xMid, 0., xeMin, xeMax,0., 0.));
767 points.push_back(YODA::Point2D(xMid, yVal, xeMin, xeMax,
768 yErr[i].first, yErr[i].second));
773 for (
int i = 0, N = points.size(); i < N; ++i)
774 h->addPoint(points[i]);
781 static void nthPow(Scatter2DPtr hOut,
const Scatter2DPtr hIn,
const double& n,
const double& k = 1.0) {
782 if (n == 0 || n == 1) {
783 cout <<
"Error: Do not take the 0th or 1st power of a Scatter2D,"
784 " use scale instead." << endl;
787 if (hIn->points().size() != hOut->points().size()) {
788 cout <<
"nthRoot: Scatterplots: " << hIn->name() <<
" and " <<
789 hOut->name() <<
" not initialized with same length." << endl;
792 vector<YODA::Point2D> points;
794 double eFac = pow(k,1./n)/n;
795 for (
auto b : hIn->points()) {
796 double yVal = pow(k * b.y(),n);
797 if (std::isnan(yVal))
798 points.push_back(YODA::Point2D(b.x(), 0., b.xErrMinus(),
799 b.xErrPlus(), 0, 0 ));
801 double yemin = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrMinus();
802 if (std::isnan(yemin)) yemin = b.yErrMinus();
803 double yemax = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrPlus();
804 if (std::isnan(yemax)) yemax = b.yErrPlus();
805 points.push_back(YODA::Point2D(b.x(), yVal, b.xErrMinus(),
806 b.xErrPlus(), yemin, yemax ));
810 hOut->points().clear();
811 for (
int i = 0, N = points.size(); i < N; ++i)
812 hOut->addPoint(points[i]);
819 static void nthPow(Scatter2DPtr h,
const double& n,
const double& k = 1.0) {
820 if (n == 0 || n == 1) {
821 cout <<
"Error: Do not take the 0th or 1st power of a Scatter2D,"
822 " use scale instead." << endl;
825 vector<YODA::Point2D> points;
826 vector<YODA::Point2D> pIn = h->points();
828 double eFac = pow(k,1./n)/n;
830 double yVal = pow(k * b.y(),n);
831 if (std::isnan(yVal))
832 points.push_back(YODA::Point2D(b.x(), 0., b.xErrMinus(),
833 b.xErrPlus(), 0, 0 ));
835 double yemin = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrMinus();
836 if (std::isnan(yemin)) yemin = b.yErrMinus();
837 double yemax = abs(eFac * pow(yVal,1./(n - 1.))) * b.yErrPlus();
838 if (std::isnan(yemax)) yemax = b.yErrPlus();
839 points.push_back(YODA::Point2D(b.x(), yVal, b.xErrMinus(),
840 b.xErrPlus(), yemin, yemax ));
845 for (
int i = 0, N = points.size(); i < N; ++i) h->addPoint(points[i]);
857 for (
int i = 0; i < BOOT_BINS; ++i) avg += func(i);
858 avg /= double(BOOT_BINS);
861 for (
int i = 0; i < BOOT_BINS; ++i) var += pow(func(i) - avg, 2.);
862 var /= (double(BOOT_BINS) - 1);
863 return pair<double, double>(var, var);
875 for (
int i = 0; i < BOOT_BINS; ++i) avg += func(i);
876 avg /= double(BOOT_BINS);
880 for (
int i = 0; i < BOOT_BINS; ++i) {
881 double yVal = func(i);
882 if (yMin > yVal) yMin = yVal;
883 else if (yMax < yVal) yMax = yVal;
885 return pair<double, double>(fabs(avg - yMin), fabs(yMax - avg));
895 cout <<
"Error: Error method not found!" << endl;
896 return pair<double, double>(0.,0.);
902 vector<CorBin> bins = e2->getBins();
903 vector<double> binx = e2->getBinX();
905 if (binx.size() - 1 != bins.size()){
906 cout <<
"cnTwoInt: Bin size (x,y) differs!" << endl;
909 vector<CorBinBase*> binPtrs;
911 auto cn = [&] (
int i) {
return binPtrs[i]->mean(); };
913 vector<pair<double, double> > yErr;
914 for (
int j = 0, N = bins.size(); j < N; ++j) {
915 binPtrs = bins[j].getBinPtrs();
918 binPtrs = e2->getBinPtrs();
941 void rawHookIn(YODA::AnalysisObjectPtr yao)
final {
943 for (
auto ec : eCorrPtrs) if(ec->fillFromProfile(yao,
name())) break;;
950 void rawHookOut(vector<MultiweightAOPtr> raos,
size_t iW)
final {
952 for (
auto ec : eCorrPtrs) {
953 vector<CorBin> corBins = ec->getBins();
954 vector<double> binx = ec->getBinX();
955 auto ref = ec->getReference();
956 auto refBins = ref.getBinPtrs<CorSingleBin>();
958 if (binx.size() - 1 != corBins.size()){
959 cout <<
"corrPlot: Bin size (x,y) differs!" << endl;
963 for (
int i = 0, N = ec->profs.size(); i < N; ++i) {
964 for (
auto rao : raos) {
965 if (rao->path() ==
"/"+
name()+
"/TMP/"+ec->profs[i]) {
967 rao.get()->setActiveWeightIdx(iW);
968 YODA::Profile1DPtr pPtr = dynamic_pointer_cast<YODA::Profile1D>(
969 rao.get()->activeYODAPtr());
971 vector<YODA::ProfileBin1D> profBins;
973 double ne = 0., sow = 0., sow2 = 0.;
974 for (
size_t j = 0, N = binx.size() - 1; j < N; ++j) {
975 vector<CorSingleBin*> binPtrs =
976 corBins[j].getBinPtrs<CorSingleBin>();
980 profBins.push_back( YODA::ProfileBin1D(pPtr->bin(j).xEdges(),
981 YODA::Dbn2D( binPtrs[i]->numEntries(), binPtrs[i]->
sumW(),
982 binPtrs[i]->
sumW2(), 0., 0., binPtrs[i]->sumWX(), 0, 0)));
983 ne += binPtrs[i]->numEntries();
984 sow += binPtrs[i]->sumW();
985 sow2 += binPtrs[i]->sumW2();
989 pPtr->bins().clear();
991 pPtr->addBins(profBins);
993 pPtr->setTotalDbn(YODA::Dbn2D(ne,sow,sow2,0.,0.,0.,0.,0.));
995 pPtr->setUnderflow(YODA::Dbn2D(refBins[i]->numEntries(),
996 refBins[i]->sumW(), refBins[i]->sumW2(), 0., 0.,
997 refBins[i]->sumWX(), 0., 0.));
1006 auto e2bins = e2->getBins();
1007 auto e4bins = e4->getBins();
1008 auto binx = e2->getBinX();
1009 if (binx.size() - 1 != e2bins.size()){
1010 cout <<
"cnFourInt: Bin size (x,y) differs!" << endl;
1013 if (binx != e4->getBinX()) {
1014 cout <<
"Error in cnFourInt: Correlator x-binning differs!" << endl;
1017 vector<CorBinBase*> e2binPtrs;
1018 vector<CorBinBase*> e4binPtrs;
1019 auto cn = [&] (
int i) {
1020 double e22 = e2binPtrs[i]->mean() * e2binPtrs[i]->mean();
1021 return e4binPtrs[i]->mean() - 2. * e22;
1024 vector<pair<double, double> > yErr;
1025 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1026 e2binPtrs = e2bins[j].getBinPtrs();
1027 e4binPtrs = e4bins[j].getBinPtrs();
1031 e2binPtrs = e2->getBinPtrs();
1032 e4binPtrs = e4->getBinPtrs();
1039 cnFourInt(h, e2, e4);
1047 auto e2bins = e2->getBins();
1048 auto e4bins = e4->getBins();
1049 auto e6bins = e6->getBins();
1050 auto binx = e2->getBinX();
1051 if (binx.size() - 1 != e2bins.size()){
1052 cout <<
"cnSixInt: Bin size (x,y) differs!" << endl;
1055 if (binx != e4->getBinX() || binx != e6->getBinX()) {
1056 cout <<
"Error in cnSixInt: Correlator x-binning differs!" << endl;
1059 vector<CorBinBase*> e2binPtrs;
1060 vector<CorBinBase*> e4binPtrs;
1061 vector<CorBinBase*> e6binPtrs;
1062 auto cn = [&] (
int i) {
1063 double e23 = pow(e2binPtrs[i]->
mean(), 3.0);
1064 return e6binPtrs[i]->mean() - 9.*e2binPtrs[i]->mean()*e4binPtrs[i]->mean() +
1068 vector<pair<double, double> > yErr;
1069 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1070 e2binPtrs = e2bins[j].getBinPtrs();
1071 e4binPtrs = e4bins[j].getBinPtrs();
1072 e6binPtrs = e6bins[j].getBinPtrs();
1076 e2binPtrs = e2->getBinPtrs();
1077 e4binPtrs = e4->getBinPtrs();
1078 e6binPtrs = e6->getBinPtrs();
1094 auto e2bins = e2->getBins();
1095 auto e4bins = e4->getBins();
1096 auto e6bins = e6->getBins();
1097 auto e8bins = e8->getBins();
1098 auto binx = e2->getBinX();
1099 if (binx.size() - 1 != e2bins.size()){
1100 cout <<
"cnEightInt: Bin size (x,y) differs!" << endl;
1103 if (binx != e4->getBinX() || binx != e6->getBinX() ||
1104 binx != e8->getBinX()) {
1105 cout <<
"Error in cnEightInt: Correlator x-binning differs!" << endl;
1108 vector<CorBinBase*> e2binPtrs;
1109 vector<CorBinBase*> e4binPtrs;
1110 vector<CorBinBase*> e6binPtrs;
1111 vector<CorBinBase*> e8binPtrs;
1112 auto cn = [&] (
int i ) {
1113 double e22 = e2binPtrs[i]->mean() * e2binPtrs[i]->mean();
1114 double e24 = e22 * e22;
1115 double e42 = e4binPtrs[i]->mean() * e4binPtrs[i]->mean();
1116 return e8binPtrs[i]->mean() - 16. * e6binPtrs[i]->mean() *
1117 e2binPtrs[i]->mean() - 18. * e42 + 144. * e4binPtrs[i]->mean()*e22 - 144. * e24;
1120 vector<pair<double, double> > yErr;
1121 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1122 e2binPtrs = e2bins[j].getBinPtrs();
1123 e4binPtrs = e4bins[j].getBinPtrs();
1124 e6binPtrs = e6bins[j].getBinPtrs();
1125 e8binPtrs = e8bins[j].getBinPtrs();
1129 e2binPtrs = e2->getBinPtrs();
1130 e4binPtrs = e4->getBinPtrs();
1131 e6binPtrs = e6->getBinPtrs();
1132 e8binPtrs = e8->getBinPtrs();
1140 nthPow(h, 1./8., -1./33.);
1146 auto e2bins = e2Dif->getBins();
1147 auto ref = e2Dif->getReference();
1148 auto binx = e2Dif->getBinX();
1149 if (binx.size() -1 != e2bins.size()) {
1150 cout <<
"vnTwoDif: Bin size (x,y) differs!" << endl;
1153 vector<CorBinBase*> e2binPtrs;
1154 vector<CorBinBase*> refPtrs;
1155 auto vn = [&] (
int i) {
1157 if (ref.mean() <= 0)
return 0.;
1158 return e2binPtrs[i]->mean() / sqrt(ref.mean());
1161 auto vnerr = [&] (
int i) {
1163 if (refPtrs[i]->
mean() <=0)
return 0.;
1164 return e2binPtrs[i]->mean() / sqrt(refPtrs[i]->
mean());
1167 vector<pair<double, double> > yErr;
1168 refPtrs = ref.getBinPtrs();
1169 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1170 e2binPtrs = e2bins[j].getBinPtrs();
1174 e2binPtrs = e2Dif->getBinPtrs();
1181 auto e2bins = e2Dif->getBins();
1182 auto e4bins = e4Dif->getBins();
1183 auto ref2 = e2Dif->getReference();
1184 auto ref4 = e4Dif->getReference();
1185 auto binx = e2Dif->getBinX();
1186 if (binx.size() - 1 != e2bins.size()){
1187 cout <<
"vnFourDif: Bin size (x,y) differs!" << endl;
1190 if (binx != e4Dif->getBinX()) {
1191 cout <<
"Error in vnFourDif: Correlator x-binning differs!" << endl;
1194 vector<CorBinBase*> e2binPtrs;
1195 vector<CorBinBase*> e4binPtrs;
1196 vector<CorBinBase*> ref2Ptrs;
1197 vector<CorBinBase*> ref4Ptrs;
1198 double denom = 2 * ref2.mean() * ref2.mean() - ref4.mean();
1199 auto vn = [&] (
int i) {
1201 if (denom <= 0 )
return 0.;
1202 return ((2 * ref2.mean() * e2bins[i].mean() - e4bins[i].mean()) / pow(denom, 0.75));
1205 auto vnerr = [&] (
int i) {
1206 double denom2 = 2 * ref2Ptrs[i]->mean() * ref2Ptrs[i]->mean() -
1207 ref4Ptrs[i]->mean();
1209 if (denom2 <= 0)
return 0.;
1210 return ((2 * ref2Ptrs[i]->
mean() * e2binPtrs[i]->mean() - e4binPtrs[i]->mean()) / pow(denom2, 0.75));
1213 vector<pair<double, double> > yErr;
1214 ref2Ptrs = ref2.getBinPtrs();
1215 ref4Ptrs = ref4.getBinPtrs();
1216 for (
int j = 0, N = e2bins.size(); j < N; ++j) {
1217 e2binPtrs = e2bins[j].getBinPtrs();
1218 e4binPtrs = e4bins[j].getBinPtrs();
1222 e2binPtrs = e2Dif->getBinPtrs();
1223 e4binPtrs = e4Dif->getBinPtrs();
This is the base class of all analysis classes in Rivet.
Definition Analysis.hh:65
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:149
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:110
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:125
A helper class to calculate all event averages of correlators.
Definition Correlators.hh:396
vector< double > getBinX() const
Get a copy of the bin x-values.
Definition Correlators.hh:497
void setProfs(vector< string > prIn)
Set the prIn list of profile histograms associated with the internal bins.
Definition Correlators.hh:525
void setReference(CorBin refIn)
Replace reference flow bin with another, e.g. calculated in another phase space or with other pid.
Definition Correlators.hh:512
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:413
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:466
vector< CorBin > getBins() const
Get a copy of the bin contents.
Definition Correlators.hh:485
vector< int > getH2() const
Get a copy of the h2 harmonic vector.
Definition Correlators.hh:507
ECorrelator(vector< int > h1In, vector< int > h2In, vector< double > binIn)
Constructor for gapped correlator.
Definition Correlators.hh:421
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:426
bool fillFromProfile(YODA::AnalysisObjectPtr yao, string name)
Fill bins with content from preloaded histograms.
Definition Correlators.hh:530
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:435
CorBin getReference() const
Extract the reference flow from a differential event averaged correlator.
Definition Correlators.hh:517
void fill(const Correlators &c, const double &weight=1.0)
Fill the bins with the appropriate correlator.
Definition Correlators.hh:449
vector< int > getH1() const
Get a copy of the h1 harmonic vector.
Definition Correlators.hh:502
vector< CorBinBase * > getBinPtrs()
Return the bins as pointers to the base class.
Definition Correlators.hh:490
Tools for flow analyses.
Definition Correlators.hh:225
void vnTwoDiff(Scatter2DPtr h, ECorrPtr e2Dif) const
Two particle differential vn.
Definition Correlators.hh:1145
void vnSixInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6) const
Six particle integrated vn.
Definition Correlators.hh:1084
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:628
void vnFourDiff(Scatter2DPtr h, ECorrPtr e2Dif, ECorrPtr e4Dif) const
Four particle differential vn.
Definition Correlators.hh:1180
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:668
const pair< double, double > sampleError(T func) const
Selection method for which sample error to use, given in the constructor.
Definition Correlators.hh:891
const pair< int, int > getMaxValues() const
Get the correct max N and max P for the set of booked correlators.
Definition Correlators.hh:583
void cnSixInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6) const
Six particle integrated cn.
Definition Correlators.hh:1045
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:686
CumulantAnalysis(const string &n)
Constructor.
Definition Correlators.hh:706
void vnFourInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4) const
Four particle integrated vn.
Definition Correlators.hh:1038
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:749
static void fillScatter(Scatter2DPtr h, vector< double > &binx, T func)
Helper method for turning correlators into Scatter2Ds.
Definition Correlators.hh:718
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:644
void corrPlot(Scatter2DPtr h, ECorrPtr e) const
Put an event-averaged correlator into a Scatter2D.
Definition Correlators.hh:933
void cnTwoInt(Scatter2DPtr h, ECorrPtr e2) const
Two-particle integrated cn.
Definition Correlators.hh:901
static pair< double, double > sampleVariance(T func)
Calculate the bootstrapped sample variance.
Definition Correlators.hh:854
static pair< double, double > sampleEnvelope(T func)
Calculate the bootstrapped sample envelope.
Definition Correlators.hh:872
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:781
ECorrPtr bookECorrelatorGap(const string name, const vector< int > &h, const YODA::Scatter2D &hIn)
Definition Correlators.hh:656
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:677
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:613
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:819
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:604
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:950
void vnTwoInt(Scatter2DPtr h, ECorrPtr e2) const
Two particle integrated vn.
Definition Correlators.hh:924
void vnEightInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6, ECorrPtr e8) const
Eight particle integrated vn.
Definition Correlators.hh:1138
shared_ptr< ECorrelator > ECorrPtr
Typedef of shared pointer to ECorrelator.
Definition Correlators.hh:600
void cnEightInt(Scatter2DPtr h, ECorrPtr e2, ECorrPtr e4, ECorrPtr e6, ECorrPtr e8) const
Eight particle integrated cn.
Definition Correlators.hh:1092
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:687
double p(const ParticleBase &p)
Unbound function access to p.
Definition ParticleBaseUtils.hh:684
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:456
static constexpr double DBL_NAN
Convenient const for getting the double NaN value.
Definition Utils.hh:37
std::enable_if< std::is_arithmetic< NUM >::value, double >::type mean(const vector< NUM > &sample)
Definition MathUtils.hh:498