Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-06-01 07:07:14

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2023 Duane Byer
0003 
0004 #pragma once
0005 
0006 #include <memory>
0007 #include <initializer_list>
0008 #include <vector>
0009 
0010 #include "Kinematics.h"
0011 
0012 // Interface for all weight providers.
0013 class Weights : public TNamed
0014 {
0015   public:
0016     Weights() { }
0017     // Return how an event should be weighted based on its kinematics.
0018     virtual Double_t GetWeight(const Kinematics&) const = 0;
0019   private:
0020   ClassDef(Weights,1);
0021 };
0022 
0023 // Provide a constant weight to all events.
0024 class WeightsUniform : public Weights
0025 {
0026   public:
0027     WeightsUniform(Double_t weight = 1.) : weight(weight) { }
0028     Double_t GetWeight(const Kinematics&) const override {
0029         return weight;
0030     }
0031   private:
0032     Double_t weight;
0033   ClassDefOverride(WeightsUniform,1);
0034 };
0035 
0036 // Inject a Sivers asymmetry.
0037 class WeightsSivers : public Weights
0038 {
0039   public:
0040     Double_t GetWeight(const Kinematics& kin) const override;
0041     virtual Double_t Asymmetry(Double_t x, Double_t z, Double_t Q2, Double_t pt) const = 0;
0042   private:
0043   ClassDefOverride(WeightsSivers,1);
0044 };
0045 
0046 // Inject a Collins asymmetry.
0047 class WeightsCollins : public Weights
0048 {
0049   public:
0050     Double_t GetWeight(const Kinematics& kin) const override;
0051     virtual Double_t Asymmetry(Double_t x, Double_t z, Double_t Q2, Double_t pt) const = 0;
0052 
0053   private:
0054   ClassDefOverride(WeightsCollins,1);
0055 };
0056 
0057 // Product of weights. Useful for products of acceptances.
0058 class WeightsProduct : public Weights
0059 {
0060   public:
0061     WeightsProduct(std::initializer_list<Weights const*> weights);
0062 
0063     Double_t GetWeight(const Kinematics& kin) const override;
0064     WeightsProduct& Multiply(Weights const* rhs);
0065 
0066   private:
0067     std::vector<Weights const*> weights;
0068   ClassDefOverride(WeightsProduct,1);
0069 };
0070 
0071 // Sum of weights. Useful for adding asymmetries together.
0072 class WeightsSum : public Weights
0073 {
0074   public:
0075     WeightsSum(std::initializer_list<Weights const*> weights);
0076 
0077     Double_t GetWeight(const Kinematics& kin) const override;
0078     WeightsSum& Add(Weights const* rhs);
0079 
0080   private:
0081     std::vector<Weights const*> weights;
0082   ClassDefOverride(WeightsSum,1);
0083 };