Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-02 08:28:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 // Class template for accumulable values handled by Geant4 analysis
0028 //
0029 // Author: Ivana Hrivnacova, IJCLab IN2P3/CNRS, 07/09/2015
0030 
0031 #ifndef G4AccValue_h
0032 #define G4AccValue_h 1
0033 
0034 #include "G4VAccumulable.hh"
0035 #include "G4MergeMode.hh"
0036 
0037 #include "globals.hh"
0038 
0039 template <typename T>
0040 class G4AccValue : public G4VAccumulable
0041 {
0042   public:
0043     G4AccValue(const G4String& name, T initValue,
0044                   G4MergeMode mergeMode = G4MergeMode::kAddition);
0045     G4AccValue(T initValue = 0,
0046                   G4MergeMode mergeMode = G4MergeMode::kAddition);
0047     G4AccValue(const G4AccValue& rhs);
0048     G4AccValue(G4AccValue&& rhs) noexcept;
0049     ~G4AccValue() override = default;
0050 
0051     // Operators
0052     G4AccValue<T>& operator= (const G4AccValue<T>& rhs);
0053     G4AccValue<T>& operator=(G4AccValue<T>&& rhs) noexcept;
0054     G4AccValue<T>& operator+=(const G4AccValue<T>& rhs);
0055     G4AccValue<T>& operator*=(const G4AccValue<T>& rhs);
0056     G4AccValue<T>  operator++(int); // postfix increment
0057     G4AccValue<T>& operator++();    // prefix increment
0058 
0059     G4AccValue<T>& operator= (const T& rhs);
0060     G4AccValue<T>& operator+=(const T& rhs);
0061     G4AccValue<T>& operator*=(const T& rhs);
0062 
0063     // Methods
0064     void Merge(const G4VAccumulable& other) final;
0065     void Reset() final;
0066     using G4VAccumulable::Print;
0067     void Print(G4PrintOptions options = G4PrintOptions()) const final;
0068 
0069     // using G4VAccumulable::SetMergeMode;
0070     void SetMergeMode(G4MergeMode value) final;
0071 
0072     G4AccType GetType() const final { return G4AccType::kValue; }
0073 
0074     // Get methods
0075     T  GetValue() const;
0076 
0077   private:
0078     // Data members
0079     T  fValue = 0;
0080     T  fInitValue = 0;
0081     G4MergeFunction<T> fMergeFunction;
0082  };
0083 
0084 // inline functions
0085 
0086 #include "G4AccValue.icc"
0087 
0088 #endif