Commit 4ec9cf14 authored by Scott Snyder's avatar Scott Snyder Committed by Graeme Stewart
Browse files

Fix signaature of EventShapeEvent::retrieve. (EventShapeEvent-00-00-14)

parent f9060863
// -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EVENTSHAPEEVENT_EVENTETDENSITY_H
#define EVENTSHAPEEVENT_EVENTETDENSITY_H
#include "fastjet/RangeDefinition.hh"
#include <cmath>
class EventEtDensity
{
public:
/*! @brief Constructor
*
* Generates empty @c EventEtDensity structure - generally not very
* useful.
*/
EventEtDensity();
/*! @brief Constructor
*
* Generates loaded @c EventEtDensity structure.
*
* @param[in] rho event transverse energy density
* @param[in] sigma event transverse energy fluctuation (default 0. -
* optional argument from e.g. @c fastjet )
* @param[in] area total area in range occupied by probe jets with
* @f$ p_T > 0 @f$ (default no jets, i.e.
* @f$ \Delta\eta \times 2\pi$ @f$ - optional argument from
* e.g. @c fastjet )
* @param[in] etaLow lower limit @f$ \eta_L @f$ of @f$ \eta @f$ range in
* which density is evaluated (default: ATLAS coverage
* @f$ \eta_L = -5. @f$ - optional argument )
* @param[in] etaHigh upper limit @f$ \eta_H @f$ of @f$ \eta @f$ range in
* which density is evaluated (default: ATLAS coverage
* @f$ \eta_H = 5. @f$ - optional argument )
*/
EventEtDensity(double rho,double sigma=0.,double area=40*asin(1.),
double etaLow=-5.,double etaHigh=5.);
/*! @brief Constructor
*
* Generates loaded @c EventEtDensity structure.
*
* @param[in] rho event transverse energy density
* @param[in] sigma event transverse energy fluctuation (typically from
* @c fastjet )
* @param[in] area total area in range occupied by probe jets with
* @f$ p_T > 0 @f$ (typically from @c fastjet )
* @param[in] range range in which density is to be evaluated, presented
* as @c fastjet::Rangedefinition
*/
EventEtDensity(double rho,double sigma,double area,
const fastjet::RangeDefinition& range);
/*! @brief Copy constructor */
EventEtDensity(const EventEtDensity& data);
/*! @brief Destructor */
~EventEtDensity();
/*! @brief Data indices in external vectors
*
* Deines the order in an external vector, as e.g. used in the @c copyData
* function.
*/
enum DataIndex { RHOVALUE = 2,
RHOSIGMA = 3,
AREAVALUE = 4,
ETARANGELOW = 0,
ETARANGEHIGH = 1,
MAXINDEX = 5,
INVALIDINDEX = -1 };
/*! @brief Access to event transverse energy density @f$ \rho @f$ */
double rhoValue;
/*! @brief Access to spread of transverse energy density @f$ \sigma @f$ */
double rhoSigma;
/*! @brief Access to total area occupied by @f$ p_T > 0. @f$ probe jets */
double areaValue;
/*! @brief Access to lower @f$ \eta @f$ range limit */
double etaRangeLow;
/*! @brief Access to upper @f$ \eta @f$ range limit */
double etaRangeHigh;
/**/
static size_t capacity();
/*! @brief Convert @f$ \eta @f$ range into @c fastjet::RangeDefinition */
fastjet::RangeDefinition range() const;
/*! @brief Convert @f$ \eta @f$ range into @c fastjet::RangeDefinition */
static fastjet::RangeDefinition range(const EventEtDensity& data);
/*! @brief Fill @c EventEtDensity from a vector
*
* @param[in] lparm @c const reference to non-modifiable list of density
* variables (needs to contain at least @c MAXINDEX
* variables)
* @param[out] data reference to modifiable @c EventEtDensity object
* @param[in] lindx starting index for parameter copy (optional, default
* <code>lindx = 0</code>)
*
* @return Number of values filled - typically the minimum of the vector
* size and the number of storable parameters (5).
*
* This function will make the following assignments (not the actual
* implementation, just to illustrate the behaviour):
*
* <code>
* size_t offset(lindx*(size_t)MAXINDEX);
* data.rhoValue = lparm.at(offset+(size_t)RHOVALUE);
* data.rhoSigma = lparm.at(offset+(size_t)RHOSIGMA);
* data.areaValue = lparm.at(offset+(size_t)AREAVALUE);
* data.etaRangeLow = lparm.at(offset+(size_t)ETARANGELOW);
* data.etaRangeHigh = lparm.at(offset+(size_t)ETARANGEHIGH);
* </code>
*
* Only full blocks of @c MAXINDEX data words are copied. This means that
* only data up to the last full block of @c MAXINDEX numbers is converted.
*/
static bool copyData(const std::vector<double>& lparm,
EventEtDensity& data,
size_t lindx=0);
/*! @brief Fill @c this @c EventEtDensity from a vector
*
* @param[in] lparm @c const reference to non-modifiable list of density
* variables
* @param[in] lindx starting index for parameter copy (optional, default
* <code>lindx = 0</code>)
*
* @return Number of values filled - typically the minimum of the vector
* size and the number of storable parameters (5).
*
* This function will make the following assignments (not the actual
* implementation, just to illustrate the behaviour):
*
* <code>
* size_t offset(lindx*(size_t)MAXINDEX);
* data.rhoValue = lparm.at(offset+(size_t)RHOVALUE);
* data.rhoSigma = lparm.at(offset+(size_t)RHOSIGMA);
* data.areaValue = lparm.at(offset+(size_t)AREAVALUE);
* data.etaRangeLow = lparm.at(offset+(size_t)ETARANGELOW);
* data.etaRangeHigh = lparm.at(offset+(size_t)ETARANGEHIGH);
* </code>
*
* Only full blocks of @c MAXINDEX data words are copied. This means that
* only data up to the last full block of @c MAXINDEX numbers is converted.
*/
bool copyData(const std::vector<double>& lparm,size_t lindx=0);
/**/
static bool extractData(const EventEtDensity& data,
std::vector<double>& lparm,size_t lindx=0);
/**/
bool extractData(std::vector<double>& lparm,size_t lindx=0) const;
/*! @brief Create @c EventEtDensity store
*
*/
static EventEtDensity createStore(const std::vector<double>& lparm,
size_t lindx=0);
/*! @brief Clear @c EventEtDensity store
*
* Sets all data to @c EventFeatureToolBase::invalidValue() .
*/
static void clear(EventEtDensity& data);
/*! @brief Clear @c this @c EventEtDensity store
*
* Sets all data to @c EventFeatureToolBase::invalidValue() .
*/
void clear();
static void reset(EventEtDensity& data);
void reset();
bool inRange(double eta) const;
// private:
// /*! @brief Cached @f$ \rho @f$ */
// double m_rho;
// /*! @brief Cached @f$ \sigma @f$ */
// double m_sigma;
// /*! @brief Cached integrated jet catchment area */
// double m_area;
// /*! @brief Cached lower @f$ \eta @f$ range limit */
// double m_etaLow;
// /*! @brief Cached upper @f$ \eta @f$ range limit */
// double m_etaHigh;
};
/*! @class EventEtDensity
*
* @brief Data container for event Et densities
*
* Allows compact distribution and access to transverse energy event densities
* as provided by @c fastjet
*/
inline EventEtDensity::EventEtDensity()
{
rhoValue = 0.;
rhoSigma = 0.;
etaRangeLow = -5.;
etaRangeHigh = 5.;
areaValue = (etaRangeHigh-etaRangeLow)*4.*asin(1.);
}
inline EventEtDensity::EventEtDensity(double rho,double sigma,double area,
double etaLow,double etaHigh)
{
rhoValue = rho;
rhoSigma = sigma;
areaValue = area;
etaRangeLow = etaLow;
etaRangeHigh = etaHigh;
}
inline EventEtDensity::EventEtDensity(double rho,double sigma,double area,
const fastjet::RangeDefinition& range)
{
rhoValue = rho;
rhoSigma = sigma;
areaValue = area;
range.get_rap_limits(etaRangeLow,etaRangeHigh);
}
inline EventEtDensity::EventEtDensity(const EventEtDensity& data)
{
rhoValue = data.rhoValue;
rhoSigma = data.rhoSigma;
areaValue = data.areaValue;
etaRangeLow = data.etaRangeLow;
etaRangeHigh = data.etaRangeHigh;
}
inline EventEtDensity::~EventEtDensity()
{ }
inline fastjet::RangeDefinition EventEtDensity::range() const
{ return fastjet::RangeDefinition(etaRangeLow,etaRangeHigh); }
inline fastjet::RangeDefinition EventEtDensity::range(const EventEtDensity&
data)
{ return data.range(); }
inline bool
EventEtDensity::copyData(const std::vector<double>& lparm,EventEtDensity& data,
size_t lindx)
{ return data.copyData(lparm,lindx); }
inline
EventEtDensity EventEtDensity::createStore(const std::vector<double>& lparm,
size_t lindx)
{ EventEtDensity data; copyData(lparm,data,lindx); return data; }
inline
bool EventEtDensity::extractData(const EventEtDensity& data,
std::vector<double>& lparm,size_t lindx)
{ return data.extractData(lparm,lindx); }
inline void EventEtDensity::clear(EventEtDensity& data)
{ data.clear(); }
inline size_t EventEtDensity::capacity()
{ return (size_t)MAXINDEX; }
inline void EventEtDensity::reset(EventEtDensity& data)
{ data.reset(); }
inline bool EventEtDensity::inRange(double eta) const
{ return eta >= etaRangeLow && eta <= etaRangeHigh; }
// inline EventEtDensity::EventEtDensity()
// : m_rho(0.), m_sigma(0.), m_area(40.*asin(1.)),
// , m_etaLow(-5.), m_etaHigh(5.)
// { }
// inline EventEtDensity::EventEtDensity(double rho,double sigma,double area,
// double etaLow,double etaHigh)
// : m_rho(rho), m_sigma(sigma), m_area(area),
// , m_etaLow(etaLow), m_etaHigh(etaHigh)
// { }
// inline EventEtDensity::EventEtDensity(double rho,double sigma,double area,
// const fastjet::RangeDefinition range)
// : m_rho(rho), m_sigma(sigma), m_area(area)
// { range.get_rap_limits(m_etaLow,m_etaHigh); }
// inline EventEtDensity::EventEtDensity(const EventEtDensity& data)
// : m_rho(data.m_rho), m_sigma(data.m_sigma), m_area(data.m_area)
// , m_etaLow(data.m_etaLow), m_etaHigh(data.m_etaHigh)
// { }
// inline double EventEtDensity::rho() const
// { return m_rho; }
// inline double EventEtDensity::sigma() const
// { return m_sigma; }
// inline double EventEtDensity::area() const
// { return m_area; }
// inline double EventEtDensity::etaLow() const
// { return m_etaLow; }
// inline double EventEtDensity::etaHigh() const
// { return m_etaHigh; }
#endif
// -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EVENTSHAPEEVENT_EVENTFEATURE_H
#define EVENTSHAPEEVENT_EVENTFEATURE_H
//#include "EventShapeEvent/EventShapes.h"
#include <string>
#include <vector>
#include <algorithm>
#include <map>
class EventFeature
{
public:
/*! @*/
/*! @brief Type enumerators */
enum FeatureType
{ ETDENSITY = 0x1000,
ETDENSITY_JETAREA = 0x1100, /*!< @c FastJet density */
ETDENSITY_JETAREA_ETA = 0x1101, /*!< @c FastJet density, @f$ \eta @f$
dependent */
ETDENSITY_ETA_WINDOWS = 0x1201, /*!< density in sliding @f$ \eta @f$
windows */
ETDENSITY_USER = 0x0010, /*!< User defined density */
UNKNOWN = 0x0000, /*!< Unknown type */
DEFAULT = 0xffff /*!< Default type */
};
/*! @brief Feature structure descriptors
*
* Mostly useful for T/P converter yet public for converter access
*/
enum FeatureStructureMask { NDATAWORDS = 0x0000007f, /*<! Mask for number of
data words/block (max
accomodation 128)*/
NDATABLOCKS = 0x00003f80, /*<! Mask for number of
data blocks (max
accommodation 128)*/
TAGBITS = 0x0000c000, /*<! Mask for additional
tag bits (2 bits)*/
MASKLENGTH = 0x0000ffff, /*<! Mask for total
used bit range (16)*/
BITSHIFT = 0x00000007 }; /*<! Shift step */
/*! @brief Default constructor
*
* Instantiates empty data object, with defaults:
*
* <code> type = EventFeature::UNKNOWN; </code>
* <code> tag = "Default"; </code>
* <code> dataList = std::vector<double>(); </code>
*
* This object also has no internal data structure (0 data words in 0
* blocks).
*/
EventFeature();
/*! @brief Loaded constructor
*
* @param[in] type @c EventFeature type
* @param[in] tag @c string identifier/tag for data
* @param[in] dataList reference to non-modifiable data vector to be copied
* to internal store
*
* @note Flat data structure with @c dataList.size() words in one block.
*
*/
EventFeature(FeatureType type,
const std::string& tag,
const std::vector<double>& dataList);
/*! @brief Loaded constructor
*
* @param[in] type @c EventFeature type
* @param[in] tag @c string identifier/tag for data
* @param[in] data scalar (number) data word to be stored internally
* @param[in] dataList reference to non-modifiable data vector to be copied
* to internal store
*/
EventFeature(FeatureType type,
const std::string& tag,
unsigned int dataStructure,
const std::vector<double>& dataList);
/*! @brief Loaded constructor
*
* @param[in] type @c EventFeature type
* @param[in] tag @c string identifier/tag for data
* @param[in] data scalar (number) data word to be stored internally
*
* @note Internal multiple (vector) store is set to its default value
* (@c std::vector<double>() ).
*
*/
EventFeature(FeatureType type,
const std::string& tag,
unsigned int dataStructure);
/*! @brief Copy constructor */
EventFeature(const EventFeature& feature);
/*! @brief Destructor */
virtual ~EventFeature();
/*! @brief Assignment operator
*
* Copies data content from @c EventFeature source.
*
* @param[in] feature reference to non-modifiable @c EventFeature object
*
*/
EventFeature& operator=(const EventFeature& feature);
/*! @brief Retrieve feature tag
*
* @return @c const reference to non-modifiable feature tag (string).
*/
const std::string& tag() const;
/*! @brief Retrieve feature type
*
* @return Copy of feature type.
*/
FeatureType type() const;
/*! @brief Retrieve data structure descriptor
*
* @return Copy of data structure descriptor
*/
unsigned int featureStructure() const;
/*! @brief Retrieve number of data blocks
*
* @return Number of data blocks
*/
size_t numberDataBlocks() const;
/*! @brief Retrieve number of words in data block
*
* @return Number of words in data block
*/
size_t numberDataWords() const;
/*! @brief Retrieve reference to vector store
*
* @return @c const reference to non-modifiable vector data store.
*/
const std::vector<double>& dataList() const;
/*! @brief Retrieve reference to vector store
*
* @return @c const reference to modifiable vector data store.
*/
std::vector<double>& dataList();
/*! @brief Return one datablock */
bool dataBlock(size_t blockIdx,std::vector<double>& data) const;
/*! @brief Set feature tag
*
* @param[in] tag reference to non-modifiable tag string
*/
void setTag(const std::string& tag);
/*! @brief Set feature type
*
* @param[in] type feature type
*/
void setType(FeatureType type);
/*! @brief Set number of blocks
*
* @param[in] nBlocks number of data blocks
*/
void setNumberDataBlocks(size_t nBlocks);
/*! @brief Set number of data words per block
*
* @param[in] nWords number of data words per block
*/
void setNumberDataWords(size_t nWords);
/*! @brief Set vector data store
*
* @param[in] data reference to non-modifiable data vector
*/
void setDataList(const std::vector<double>& data);
/*! @brief Set one data block */
bool setDataBlock(size_t blockIdx,const std::vector<double>& data,
bool replace=true);
bool addDataBlock(const std::vector<double>& data);
// /*! @brief Binned scalar data model
// *
// * @param[in] lmin minimum
// */
// void setBinnedData(double lmin,double lmax,double data);
/*! @brief Convert feature tag to @c FeatureType */
static FeatureType featureType(const std::string& typeTag);
/*! @brief Default feature type */
static FeatureType featureType();
/*! @brief Convert a @c FeatureType to a tag */
static const std::string& featureTag(FeatureType type);
/*! @brief Default feature tag */
static const std::string& featureTag();
/*! @brief Build compressed feature structure */
unsigned int buildFeatureStructure() const;
private:
typedef std::pair<size_t,size_t> index_t;
// enum FeatureStructure
// { SCALAR = 0x1000,
// SCALAR_BINNED_SPARSE = 0x1001,
// SCALAR_BINNED_CONT = 0x1002,
// VECTOR = 0x0100,
// VECTOR_BINNED_SPARSE = 0x0101,
// VECTOR_BINNED_CONT = 0x0102
// };
//
// b00000000000000000000000001111111 = 0x007f (0...127) N_datawords
// b00000000000000000011111110000000 = 0x03f8 (0...127) N_datablocks
// b0000000000000000________________ = 16 bits
//
/*! @brief Internal cache for feature type */
FeatureType m_type;
/*! @brief Internal cache for feature tag */
std::string m_tag;
/*! @brief Internal cache data structure description (words per block)*/
unsigned int m_dataWords;
/*! @brief Internal cache for data structure descriptor (number of blocks) */
mutable unsigned int m_dataBlocks;
/*! @brief Internal cache for compressed data structure descriptor */
mutable unsigned int m_featureStructure;
/*! @brief Internal cache for vector data */
mutable std::vector<double> m_dataList;
/*! @brief Control flag for setting number of data words
*
* Can only be done once!
*/
bool m_structureFixed;
/*! @brief Lookup for feature type and tag matches */
static std::map<FeatureType,std::string> m_featureTags;
/*! @brief Fill lookup once */
static const std::map<FeatureType,std::string>& fillFeatureTags();
/*! @brief Set/update feature structure */
void setFeatureStructure(bool updateCache=false) const;
/*! */
bool insertDataBlock(size_t startIdx,size_t endIdx,
const std::vector<double>& data);
bool addDataBlock(size_t startIdx,size_t endIdx,const std::vector<double>&
data);
/*! */
bool indexRange(size_t startIdx,index_t& idx) const;
};
/*! @class EventFeature
*
* @brief Basic container for event feature data.
*
* Basic container for event feature data or parameters. Each entry is
* characterized by the type of information, a tag, and possibly scalar
* (number) and/or vector (list of numbers or list of number patterns).
* The possible interpretation of the number patterns depends on the
* feature type and is usually implemented in the tool producing the
* @c EventFeature object.
*/
// Three simple structural patterns are provided by
// * the data object, for convenience:
// *
// * - type <tt>ETDENSITY_JETAREA</tt> implied structure type <tt>SCALAR</tt>
// * - stores one number/event (global event transverse energy density
// * - uses @c m_data cache, @c m_dataList is empty
// * - type <tt>ETDENSITY_JETAREA_ETA</tt> implied structure
// * <tt>SCALAR_BINNED</tt>
// * - type <tt>ETDENSITY_ETA_WINDOWS</tt> implied structure
// * <tt>FUNCTION_PARAMETERS</tt>
// */
inline const std::string& EventFeature::tag() const
{ return m_tag; }<