File indexing completed on 2025-01-18 09:57:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef __FASTJET_CONTRIB_CONSTITUENTSUBTRACTOR_RESCALINGCLASSES_HH__
0024 #define __FASTJET_CONTRIB_CONSTITUENTSUBTRACTOR_RESCALINGCLASSES_HH__
0025
0026
0027
0028 #include <fastjet/FunctionOfPseudoJet.hh>
0029 #include <iostream>
0030 #include <vector>
0031
0032 FASTJET_BEGIN_NAMESPACE
0033
0034 namespace contrib{
0035
0036
0037 template<class T>
0038 class BackgroundRescalingYFromRoot : public FunctionOfPseudoJet<double> {
0039 public:
0040
0041
0042 BackgroundRescalingYFromRoot(): _hist(0) {}
0043 BackgroundRescalingYFromRoot(T* hist=0) {_hist = hist;}
0044
0045
0046 virtual double result(const PseudoJet & particle) const {
0047 if (!_hist){
0048 throw Error("BackgroundRescalingYFromRoot (from ConstituentSubtractor) The histogram for rescaling not defined! ");
0049 }
0050 double rap = particle.rap();
0051 if (rap<_hist->GetXaxis()->GetBinLowEdge(1)) return _hist->GetBinContent(1);
0052 if (rap>=_hist->GetXaxis()->GetBinUpEdge(_hist->GetNbinsX())) return _hist->GetBinContent(_hist->GetNbinsX());
0053 int bin=_hist->FindBin(rap);
0054 return _hist->GetBinContent(bin);
0055 }
0056
0057 private:
0058 T* _hist;
0059 };
0060
0061
0062
0063 template<class T>
0064 class BackgroundRescalingYPhiFromRoot : public FunctionOfPseudoJet<double> {
0065 public:
0066
0067
0068 BackgroundRescalingYPhiFromRoot(): _hist(0) {}
0069 BackgroundRescalingYPhiFromRoot(T* hist=0) {_hist = hist;}
0070
0071
0072 virtual double result(const PseudoJet & particle) const {
0073 if (!_hist){
0074 throw Error("BackgroundRescalingYPhiFromRoot (from ConstituentSubtractor) The histogram for rescaling not defined! ");
0075 }
0076 double rap = particle.rap();
0077 double phi = particle.phi();
0078 int xbin=1;
0079 if (rap<_hist->GetXaxis()->GetBinLowEdge(1)) xbin=1;
0080 else if (rap>=_hist->GetXaxis()->GetBinUpEdge(_hist->GetNbinsX())) xbin=_hist->GetNbinsX();
0081 else xbin=_hist->GetXaxis()->FindBin(rap);
0082 int ybin=1;
0083 if (phi<_hist->GetYaxis()->GetBinLowEdge(1) || phi>_hist->GetYaxis()->GetBinUpEdge(_hist->GetNbinsY())){
0084 throw Error("BackgroundRescalingYPhiFromRoot (from ConstituentSubtractor) The phi range of the histogram does not correspond to the phi range of the particles! Change the phi range of the histogram.");
0085 }
0086 else ybin=_hist->GetYaxis()->FindBin(phi);
0087 return _hist->GetBinContent(xbin,ybin);
0088 }
0089
0090 private:
0091 T* _hist;
0092 };
0093
0094
0095
0096
0097
0098 template<class T>
0099 class BackgroundRescalingYFromRootPhi : public FunctionOfPseudoJet<double> {
0100 public:
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111 BackgroundRescalingYFromRootPhi(): _v2(0), _v3(0), _v4(0), _psi(0), _use_rap(false), _use_phi(false), _hist(0) {}
0112 BackgroundRescalingYFromRootPhi(double v2, double v3, double v4, double psi, T* hist=0){
0113 _v2=v2;
0114 _v3=v3;
0115 _v4=v4;
0116 _psi=psi;
0117 _hist=hist;
0118 _use_phi=true;
0119 if (!_hist){
0120 std::cout << std::endl << std::endl << "ConstituentSubtractor::BackgroundRescalingYFromRootPhi WARNING: The histogram for rapidity rescaling is not defined!!! Not performing rapidity rescaling." << std::endl << std::endl << std::endl;
0121 _use_rap=false;
0122 }
0123 else _use_rap=true;
0124 }
0125
0126
0127
0128 void use_rap_term(bool use_rap){
0129 _use_rap=use_rap;
0130 if (!_hist && _use_rap){
0131 throw Error("BackgroundRescalingYFromRootPhi (from ConstituentSubtractor) Requested rapidity rescaling, but the histogram for rescaling is not defined!");
0132 }
0133 }
0134
0135
0136
0137 void use_phi_term(bool use_phi){
0138 _use_phi=use_phi;
0139 }
0140
0141
0142
0143 virtual double result(const PseudoJet & particle) const{
0144 double phi_term=1;
0145 if (_use_phi){
0146 double phi=particle.phi();
0147 phi_term=1 + 2*_v2*_v2*cos(2*(phi-_psi)) + 2*_v3*_v3*cos(3*(phi-_psi)) + 2*_v4*_v4*cos(4*(phi-_psi));
0148 }
0149 double rap_term=1;
0150 if (_use_rap){
0151 double y=particle.rap();
0152 int bin=_hist->FindBin(y);
0153 rap_term=_hist->GetBinContent(bin);
0154 }
0155
0156 return phi_term*rap_term;
0157 }
0158
0159 private:
0160 double _v2, _v3, _v4, _psi;
0161 bool _use_rap, _use_phi;
0162 T* _hist;
0163 };
0164
0165
0166
0167
0168
0169
0170 class BackgroundRescalingYPhi : public FunctionOfPseudoJet<double> {
0171 public:
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189 BackgroundRescalingYPhi(): _v2(0), _v3(0), _v4(0), _psi(0), _a1(1), _sigma1(1000), _a2(0), _sigma2(1000), _use_rap(false), _use_phi(false) {}
0190 BackgroundRescalingYPhi(double v2, double v3, double v4, double psi, double a1, double sigma1, double a2, double sigma2);
0191
0192 void use_rap_term(bool use_rap);
0193 void use_phi_term(bool use_phi);
0194
0195
0196 virtual double result(const PseudoJet & particle) const;
0197 private:
0198 double _v2, _v3, _v4, _psi, _a1, _sigma1, _a2, _sigma2;
0199 bool _use_rap, _use_phi;
0200 };
0201
0202
0203
0204 class BackgroundRescalingYPhiUsingVectorForY : public FunctionOfPseudoJet<double> {
0205 public:
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224 BackgroundRescalingYPhiUsingVectorForY(): _v2(0), _v3(0), _v4(0), _psi(0), _values(0), _rap_binning(0), _use_rap(false), _use_phi(false) {}
0225 BackgroundRescalingYPhiUsingVectorForY(double v2, double v3, double v4, double psi, std::vector<double> values, std::vector<double> rap_binning);
0226
0227 void use_rap_term(bool use_rap);
0228 void use_phi_term(bool use_phi);
0229
0230
0231 virtual double result(const PseudoJet & particle) const;
0232 private:
0233 double _v2, _v3, _v4, _psi;
0234 std::vector<double> _values;
0235 std::vector<double> _rap_binning;
0236 bool _use_rap, _use_phi;
0237 };
0238
0239
0240
0241 class BackgroundRescalingYPhiUsingVectors : public FunctionOfPseudoJet<double> {
0242 public:
0243
0244
0245
0246
0247 BackgroundRescalingYPhiUsingVectors(): _values(0), _rap_binning(0), _phi_binning(0) {}
0248 BackgroundRescalingYPhiUsingVectors(std::vector<std::vector<double> > values, std::vector<double> rap_binning, std::vector<double> phi_binning);
0249
0250 void use_rap_term(bool use_rap);
0251 void use_phi_term(bool use_phi);
0252
0253
0254 virtual double result(const PseudoJet & particle) const;
0255 private:
0256 std::vector<std::vector<double> > _values;
0257 std::vector<double> _rap_binning;
0258 std::vector<double> _phi_binning;
0259 bool _use_rap, _use_phi;
0260 };
0261
0262
0263
0264 }
0265
0266 FASTJET_END_NAMESPACE
0267
0268
0269 #endif