Import Geant4 10.3.0 source tree
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
|
||||
// Class template for accumulables handled by Geant4 analysis
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 07/09/2015 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4Accumulable_h
|
||||
#define G4Accumulable_h 1
|
||||
|
||||
#include "G4VAccumulable.hh"
|
||||
#include "G4MergeMode.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
template <typename T>
|
||||
class G4Accumulable : public G4VAccumulable
|
||||
{
|
||||
public:
|
||||
G4Accumulable(const G4String& name, T initValue,
|
||||
G4MergeMode mergeMode = G4MergeMode::kAddition);
|
||||
G4Accumulable(T initValue,
|
||||
G4MergeMode mergeMode = G4MergeMode::kAddition);
|
||||
G4Accumulable(const G4Accumulable& rhs);
|
||||
G4Accumulable() = delete;
|
||||
virtual ~G4Accumulable();
|
||||
|
||||
// operators
|
||||
G4Accumulable<T>& operator= (const G4Accumulable<T>& rhs);
|
||||
G4Accumulable<T>& operator+=(const G4Accumulable<T>& rhs);
|
||||
G4Accumulable<T>& operator*=(const G4Accumulable<T>& rhs);
|
||||
G4Accumulable<T> operator++(int); // postfix increment
|
||||
G4Accumulable<T>& operator++(); // prefix increment
|
||||
|
||||
G4Accumulable<T>& operator= (const T& rhs);
|
||||
G4Accumulable<T>& operator+=(const T& rhs);
|
||||
G4Accumulable<T>& operator*=(const T& rhs);
|
||||
|
||||
// methods
|
||||
virtual void Merge(const G4VAccumulable& other) final;
|
||||
virtual void Reset() final;
|
||||
|
||||
// get methods
|
||||
T GetValue() const;
|
||||
G4MergeMode GetMergeMode() const;
|
||||
|
||||
private:
|
||||
// data members
|
||||
T fValue;
|
||||
T fInitValue;
|
||||
G4MergeMode fMergeMode;
|
||||
G4MergeFunction<T> fMergeFunction;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
#include "G4Accumulable.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,186 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
|
||||
//
|
||||
// utilities
|
||||
//
|
||||
|
||||
//
|
||||
// public functions
|
||||
//
|
||||
|
||||
using namespace G4Accumulables;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>::G4Accumulable(const G4String& name, T initValue, G4MergeMode mergeMode)
|
||||
: G4VAccumulable(name),
|
||||
fValue(initValue),
|
||||
fInitValue(initValue),
|
||||
fMergeMode(mergeMode),
|
||||
fMergeFunction(GetMergeFunction<T>(mergeMode))
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>::G4Accumulable(T initValue, G4MergeMode mergeMode)
|
||||
: G4VAccumulable(),
|
||||
fValue(initValue),
|
||||
fInitValue(initValue),
|
||||
fMergeMode(mergeMode),
|
||||
fMergeFunction(GetMergeFunction<T>(mergeMode))
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>::G4Accumulable(const G4Accumulable& rhs)
|
||||
: G4VAccumulable(rhs),
|
||||
fValue(rhs.fValue),
|
||||
fInitValue(rhs.fInitValue),
|
||||
fMergeMode(rhs.fMergeMode),
|
||||
fMergeFunction(rhs.fMergeFunction)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>::~G4Accumulable()
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>&
|
||||
G4Accumulable<T>::operator=(const G4Accumulable<T>& rhs)
|
||||
{
|
||||
// check assignment to self
|
||||
if (this == &rhs) return *this;
|
||||
|
||||
// base class assignment
|
||||
G4VAccumulable::operator=(rhs);
|
||||
|
||||
// this class data assignment
|
||||
fValue = rhs.fValue;
|
||||
fInitValue = rhs.fInitValue;
|
||||
fMergeMode = rhs.fMergeMode;
|
||||
fMergeFunction = rhs.fMergeFunction;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>&
|
||||
G4Accumulable<T>::operator+=(const G4Accumulable<T>& rhs)
|
||||
{
|
||||
// only update the value from rhs
|
||||
fValue += rhs.fValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>&
|
||||
G4Accumulable<T>::operator*=(const G4Accumulable<T>& rhs)
|
||||
{
|
||||
// only update the value from rhs
|
||||
fValue *= rhs.fValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>&
|
||||
G4Accumulable<T>::operator=(const T& value)
|
||||
{
|
||||
// only update the value
|
||||
fValue = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>&
|
||||
G4Accumulable<T>::operator+=(const T& value)
|
||||
{
|
||||
// only update the value
|
||||
fValue += value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>&
|
||||
G4Accumulable<T>::operator*=(const T& value)
|
||||
{
|
||||
// only update the value from rhs
|
||||
fValue *= value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>
|
||||
G4Accumulable<T>::operator++(int)
|
||||
{
|
||||
// postfix increment
|
||||
G4Accumulable<T> temp = *this;
|
||||
fValue++;
|
||||
return temp;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>&
|
||||
G4Accumulable<T>::operator++()
|
||||
{
|
||||
// prefix increment
|
||||
fValue++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
void G4Accumulable<T>::Merge(const G4VAccumulable& other)
|
||||
{
|
||||
// G4cout << "Merging other: " << other.GetName() << " " << static_cast<const G4Accumulable<T>&>(other).fValue << G4endl;
|
||||
// G4cout << " to master: " << fName << " " << fValue << G4endl;
|
||||
fValue = fMergeFunction(fValue, static_cast<const G4Accumulable<T>&>(other).fValue);
|
||||
// G4cout << " new value: " << fName << " " << fValue << G4endl;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
void G4Accumulable<T>::Reset()
|
||||
{
|
||||
fValue = fInitValue;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
T G4Accumulable<T>::GetValue() const
|
||||
{
|
||||
return fValue;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4AccumulableManager.hh 91012 2015-06-15 10:38:07Z ihrivnac $
|
||||
|
||||
// The common implementation of analysis manager classes.
|
||||
|
||||
// Author: Ivana Hrivnacova, 07/09/2015 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4AccumulableManager_h
|
||||
#define G4AccumulableManager_h 1
|
||||
|
||||
#include "G4Accumulable.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class G4AnalysisManagerState;
|
||||
class G4VAccumulable;
|
||||
|
||||
class G4AccumulableManager
|
||||
{
|
||||
public:
|
||||
virtual ~G4AccumulableManager();
|
||||
|
||||
// static methods
|
||||
static G4AccumulableManager* Instance();
|
||||
|
||||
// Methods
|
||||
|
||||
// Create accumulables
|
||||
//
|
||||
template <typename T>
|
||||
G4Accumulable<T>*
|
||||
CreateAccumulable(const G4String& name, T value,
|
||||
G4MergeMode mergeMode = G4MergeMode::kAddition);
|
||||
|
||||
template <typename T>
|
||||
G4Accumulable<T>*
|
||||
CreateAccumulable(T value,
|
||||
G4MergeMode mergeMode = G4MergeMode::kAddition);
|
||||
|
||||
// Register existing accumulables
|
||||
//
|
||||
// templated accumulable
|
||||
template <typename T>
|
||||
G4bool RegisterAccumulable(G4Accumulable<T>& accumulable);
|
||||
// user defined accumulable
|
||||
G4bool RegisterAccumulable(G4VAccumulable* accumulable);
|
||||
|
||||
// Access registered accumulables
|
||||
//
|
||||
// Via name
|
||||
// templated accumulable
|
||||
template <typename T>
|
||||
G4Accumulable<T>* GetAccumulable(const G4String& name, G4bool warn = true) const;
|
||||
// user defined accumulable
|
||||
G4VAccumulable* GetAccumulable(const G4String& name, G4bool warn = true) const;
|
||||
|
||||
// Via id (in the order of registering)
|
||||
// templated accumulable
|
||||
template <typename T>
|
||||
G4Accumulable<T>* GetAccumulable(G4int id, G4bool warn = true) const;
|
||||
// user defined accumulable
|
||||
G4VAccumulable* GetAccumulable(G4int id, G4bool warn = true) const;
|
||||
G4int GetNofAccumulables() const;
|
||||
|
||||
// Via vector iterators
|
||||
std::vector<G4VAccumulable*>::iterator Begin();
|
||||
std::vector<G4VAccumulable*>::iterator End();
|
||||
std::vector<G4VAccumulable*>::const_iterator BeginConst() const;
|
||||
std::vector<G4VAccumulable*>::const_iterator EndConst() const;
|
||||
|
||||
// Methods applied to all accumulables
|
||||
void Merge();
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
// hide ctor requiring master/worker specification
|
||||
G4AccumulableManager(G4bool isMaster);
|
||||
|
||||
// metods
|
||||
// Generate generic accumulable name: accumulableN, where N is the actual number of accumulables
|
||||
G4String GenerateName() const;
|
||||
// Check if a name is already used in a map and print a warning
|
||||
G4bool CheckName(const G4String& name, const G4String& where) const;
|
||||
|
||||
template <typename T>
|
||||
G4Accumulable<T>* GetAccumulable(G4VAccumulable* accumulable, G4bool warn) const;
|
||||
|
||||
// constants
|
||||
const G4String kBaseName = "accumulable";
|
||||
|
||||
// static data members
|
||||
static G4AccumulableManager* fgMasterInstance;
|
||||
static G4ThreadLocal G4AccumulableManager* fgInstance;
|
||||
|
||||
// data members
|
||||
std::vector<G4VAccumulable*> fVector;
|
||||
std::map<G4String, G4VAccumulable*> fMap;
|
||||
std::vector<G4VAccumulable*> fAccumulablesToDelete;
|
||||
};
|
||||
|
||||
#include "G4AccumulableManager.icc"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4AccumulableManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>*
|
||||
G4AccumulableManager::GetAccumulable(G4VAccumulable* accumulable, G4bool warn) const
|
||||
{
|
||||
// Do not check type if nullptr
|
||||
if ( ! accumulable ) return nullptr;
|
||||
|
||||
// check type
|
||||
G4Accumulable<T>* taccumulable = dynamic_cast<G4Accumulable<T>*>(accumulable);
|
||||
if ( ! taccumulable && warn ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "Accumulable " << accumulable->GetName()
|
||||
<< " has different type";
|
||||
G4Exception("G4AccumulableManager::GetAccumulable<T>",
|
||||
"Analysis_W011", JustWarning, description);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return taccumulable;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>*
|
||||
G4AccumulableManager::CreateAccumulable(
|
||||
const G4String& name, T value, G4MergeMode mergeMode)
|
||||
{
|
||||
// do not accept name if it is already used
|
||||
if ( ! CheckName(name, "CreateAccumulable") ) return 0;
|
||||
|
||||
// create accumulable
|
||||
auto accumulable = new G4Accumulable<T>(name, value, mergeMode);
|
||||
|
||||
// register accumulable in the map and vector
|
||||
RegisterAccumulable(accumulable);
|
||||
fAccumulablesToDelete.push_back(accumulable);
|
||||
|
||||
return accumulable;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>*
|
||||
G4AccumulableManager::CreateAccumulable(
|
||||
T value, G4MergeMode mergeMode)
|
||||
{
|
||||
return CreateAccumulable(G4String(), value, mergeMode);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4bool G4AccumulableManager::RegisterAccumulable(G4Accumulable<T>& accumulable)
|
||||
{
|
||||
return RegisterAccumulable(&accumulable);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>*
|
||||
G4AccumulableManager::GetAccumulable(const G4String& name, G4bool warn) const
|
||||
{
|
||||
// get G4VParammeter from the map
|
||||
auto accumulable = GetAccumulable(name, warn);
|
||||
return GetAccumulable<T>(accumulable, warn);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4Accumulable<T>*
|
||||
G4AccumulableManager::GetAccumulable(G4int id, G4bool warn) const
|
||||
{
|
||||
// get G4VParammeter from the map
|
||||
auto accumulable = GetAccumulable(id, warn);
|
||||
return GetAccumulable<T>(accumulable, warn);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline G4int G4AccumulableManager::GetNofAccumulables() const
|
||||
{
|
||||
return fVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline std::vector<G4VAccumulable*>::iterator G4AccumulableManager::Begin()
|
||||
{
|
||||
return fVector.begin();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline std::vector<G4VAccumulable*>::iterator G4AccumulableManager::End()
|
||||
{
|
||||
return fVector.end();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline std::vector<G4VAccumulable*>::const_iterator
|
||||
G4AccumulableManager::BeginConst() const
|
||||
{
|
||||
return fVector.begin();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline std::vector<G4VAccumulable*>::const_iterator
|
||||
G4AccumulableManager::EndConst() const
|
||||
{
|
||||
return fVector.end();
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
|
||||
// Author: Ivana Hrivnacova, 04/07/2012 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4MergeMode_h
|
||||
#define G4MergeMode_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
#include <functional>
|
||||
#include <cmath>
|
||||
|
||||
// Enumeration for definition available binning schemes
|
||||
|
||||
enum class G4MergeMode {
|
||||
kAddition, // "Or" if boolean type
|
||||
kMultiplication, // "And" if boolean type
|
||||
kMaximum, // "Or" if boolean type
|
||||
kMinimum // "And" if boolean type
|
||||
};
|
||||
|
||||
// Generic merge function
|
||||
template <typename T>
|
||||
using G4MergeFunction = std::function<T(const T&, const T&)>;
|
||||
|
||||
// Utility functions
|
||||
namespace G4Accumulables {
|
||||
|
||||
G4MergeMode GetMergeMode(const G4String& mergeModeName);
|
||||
|
||||
template <typename T>
|
||||
G4MergeFunction<T> GetMergeFunction(G4MergeMode mergeMode)
|
||||
{
|
||||
switch ( mergeMode ) {
|
||||
case G4MergeMode::kAddition:
|
||||
// return std::bind([](const T& x, const T& y) { return x + y; });
|
||||
return [](const T& x, const T& y) { return x + y; };
|
||||
|
||||
case G4MergeMode::kMultiplication:
|
||||
return [](const T& x, const T& y) { return x * y; };
|
||||
|
||||
case G4MergeMode::kMaximum:
|
||||
// return std::bind([](const T& x, const T& y) { return std::max(x,y);});
|
||||
return [](const T& x, const T& y) { return std::max(x,y); };
|
||||
|
||||
case G4MergeMode::kMinimum:
|
||||
// return std::bind([](const T& x, const T& y) { return std::min(x,y);});
|
||||
return [](const T& x, const T& y) { return std::min(x,y); };
|
||||
}
|
||||
}
|
||||
|
||||
template <G4bool>
|
||||
G4MergeFunction<G4bool> GetMergeFunction(G4MergeMode mergeMode)
|
||||
{
|
||||
switch ( mergeMode ) {
|
||||
case G4MergeMode::kAddition:
|
||||
case G4MergeMode::kMaximum:
|
||||
// return std::bind([](const T& x, const T& y) { return x + y; });
|
||||
return [](const G4bool& x, const G4bool& y) { return x || y; };
|
||||
|
||||
case G4MergeMode::kMultiplication:
|
||||
case G4MergeMode::kMinimum:
|
||||
return [](const G4bool& x, const G4bool& y) { return x && y; };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4CsvNtupleManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
// Value type independent base class for accumulables handled by Geant4 analysis
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 04/09/2015 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4VAccumulable_h
|
||||
#define G4VAccumulable_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
|
||||
class G4VAccumulable
|
||||
{
|
||||
// To allow G4AccumulableManager set name if not defined by user
|
||||
friend class G4AccumulableManager;
|
||||
|
||||
public:
|
||||
G4VAccumulable(const G4String& name = "");
|
||||
G4VAccumulable(const G4VAccumulable& rhs);
|
||||
virtual ~G4VAccumulable() {}
|
||||
|
||||
// operators
|
||||
G4VAccumulable& operator=(const G4VAccumulable& rhs);
|
||||
|
||||
// methods
|
||||
virtual void Merge(const G4VAccumulable& other) = 0;
|
||||
virtual void Reset() = 0;
|
||||
|
||||
// get methods
|
||||
G4String GetName() const;
|
||||
|
||||
protected:
|
||||
G4String fName;
|
||||
};
|
||||
|
||||
#include "G4VAccumulable.icc"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4AccumulableManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline G4VAccumulable::G4VAccumulable(const G4String& name)
|
||||
: fName(name)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline G4VAccumulable::G4VAccumulable(const G4VAccumulable& rhs)
|
||||
: fName(rhs.fName)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline G4VAccumulable& G4VAccumulable::operator=(const G4VAccumulable& rhs)
|
||||
{
|
||||
fName = rhs.fName;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline G4String G4VAccumulable::GetName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
Reference in New Issue
Block a user