Commit 2f9dd4de authored by Walter Lampl's avatar Walter Lampl Committed by Graeme Stewart
Browse files

disable autovectorization (LWHists-00-06-06)

parent 30c6c4f6
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class LWHist //
// //
// Description: Base class for the light weight histogram //
// classes. //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: March 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef LWHIST_H
#define LWHIST_H
class TH1;
class TAxis;
class LWHist {
public:
static void safeDelete(LWHist*);//Use this rather than a simple delete.
//Use methods with names similar to the ones found in TH1F (although
//not exactly the same signature):
void SetName(const char*);
void SetTitle(const char*);
void SetNameTitle(const char*name,const char*title);
const char* GetName() const;
const char* GetTitle() const;
virtual unsigned GetEntries() const = 0;//returns double in ROOT
virtual void SetEntries(unsigned) = 0;
virtual void Reset() = 0;//Clears accumulated contents and statistics
//We even support some of the most popular decoration-style things,
//for easier migration from ROOT classes:
class LWHistAxis;
LWHistAxis * GetXaxis() const;
LWHistAxis * GetYaxis() const;
LWHistAxis * GetZaxis() const;
short GetMarkerColor() const;
short GetMarkerStyle() const;
float GetMarkerSize() const;
void SetMarkerColor( short c = 1);
void SetMarkerStyle( short s = 1 );
void SetMarkerSize( float sz = 1);
void SetXTitle(const char *);
void SetYTitle(const char *);
void SetZTitle(const char *);
void SetMinimum(const double& minimum = -1111 );
void SetMaximum(const double& maximum = -1111 );
void SetOption(const char* option=" ");//Simply passes the options on to the ROOT hist. YMMV.
virtual double Integral() const = 0;
//Methods for the monitoring framework:
//For convenience it is possible to assign custom data to an LWHist
//[NB: used by the AthenaMonitoring framework]:
void setCustomData(void*data) { m_customData = data; }
void * getCustomData() const { return m_customData; }
virtual TH1* getROOTHistBase() = 0;
bool usingROOTBackend() const { return m_usingROOTBackend; }
bool ownsROOTHisto() const { return m_ownsRootHisto; }
void setOwnsROOTHisto(bool b) { m_ownsRootHisto = b; }
protected:
LWHist(const char* name, const char* title, bool rootbackend);
virtual ~LWHist();
virtual bool apply(TH1*) const;
virtual void clearKeptROOTHist() = 0;
virtual TH1* getROOTHistBaseNoAlloc() const = 0;
virtual void clear();//releases all held memory, apart from any held ROOT histograms.
virtual double actualGetBinCenterX(int bin) const = 0;
virtual double actualGetBinCenterY(int bin) const = 0;
virtual unsigned actualFindBinX(const double&) const = 0;
virtual unsigned actualFindBinY(const double&) const = 0;
virtual unsigned actualGetNBinsX() const = 0;
virtual unsigned actualGetNBinsY() const = 0;
unsigned short m_nBytesFromPool;//0 when histogram new'ed normally,
//otherwise set to number of bytes.
private:
const bool m_usingROOTBackend;
bool m_ownsRootHisto;
// It is illegal to copy/assign these histograms:
LWHist( const LWHist & );
LWHist & operator= ( const LWHist & );
char* m_name;
char* m_title;
class LWHistDecorations;
LWHistDecorations * m_decorations;
void * m_customData;
void ensureInitDecorations();
};
class LWBinLabels;
class LWHist::LWHistAxis {
public:
void SetLabelSize(float size=0.04);
void SetTitle(const char*);
float GetLabelSize() const { return m_labelSize; }
const char* GetTitle() const { return m_title; }
double GetBinCenter(int bin) const;//int rather than unsigned for this one
const char * GetBinLabel(unsigned bin) const;//0 if not set
void SetBinLabel(unsigned bin, const char* label);
unsigned GetNbins() const;
unsigned FindBin(const double& x);
private:
LWHistAxis( const LWHistAxis & );
LWHistAxis & operator= ( const LWHistAxis & );
friend class LWHist;
friend class LWPools;
LWHistAxis(const LWHist *);
~LWHistAxis();
TAxis * rootAxis() const;
bool isXAxis() const;
bool isYAxis() const;
const LWHist * m_hist;
float m_labelSize;
char * m_title;
LWBinLabels * m_binLabels;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class LWHist1D //
// //
// Description: Common base for light-weight 1D histograms //
// //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: March 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef LWHIST1D_H
#define LWHIST1D_H
#include "LWHists/LWHist.h"
class LWHist1D : public LWHist {
public:
virtual void Fill(const double& x) = 0;
virtual void Fill(const double& x, const double& w) = 0;
virtual unsigned GetNbinsX() const = 0;
//Using ROOT convention for bins in the calls below:
// bin = 0; underflow bin
// bin = 1; first bin with low-edge xlow INCLUDED
// bin = nbins; last bin with upper-edge xup EXCLUDED
// bin = nbins+1; overflow bin
virtual double GetBinContent(unsigned bin) const = 0;
virtual double GetBinError(unsigned bin) const = 0;
virtual void SetBinContent(unsigned bin, const double& ) = 0;
virtual void SetBinError(unsigned bin, const double& ) = 0;
virtual void SetBins(unsigned nbins,double xmin,double xmax) = 0;
//Extensions:
virtual void GetBinContentAndError(unsigned bin,double& content, double&error) const = 0;
virtual void SetBinContentAndError(unsigned bin,const double& content, const double& error) = 0;
virtual void resetActiveBinLoop() = 0;
virtual bool getNextActiveBin(unsigned& bin, double& content, double& error) = 0;
virtual double getXMin() const = 0;
virtual double getXMax() const = 0;
virtual void getSums( double& sumW, double& sumW2,
double& sumWX,double& sumWX2 ) const = 0;
virtual void setSums( const double& sumW,const double&sumW2,
const double& sumWX,const double& sumWX2 ) = 0;
virtual void scaleContentsAndErrors( const double& fact ) = 0;//Scales all contents and errors by the
//factor (like changing unit on the weights).
//Triggers separate bookkeeping of errors if
//not already present.
protected:
LWHist1D( const char* n, const char* t, bool rb ) : LWHist(n,t,rb) {}
virtual ~LWHist1D() {}
friend class LWHist::LWHistAxis;
virtual bool apply(TH1*) const;
virtual double actualGetBinCenterY(int) const { return 0; }
virtual unsigned actualFindBinY(const double&) const { return 0; }
virtual unsigned actualGetNBinsX() const { return GetNbinsX(); }
virtual unsigned actualGetNBinsY() const { return 0; }
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class LWHist2D //
// //
// Description: Common base for light-weight 2D histograms //
// //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: March 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef LWHIST2D_H
#define LWHIST2D_H
#include "LWHists/LWHist.h"
class TH2;
class LWHist2D : public LWHist {
public:
virtual void Fill(const double& x, const double& y) = 0;
virtual void Fill(const double& x, const double& y, const double& w) = 0;
virtual unsigned GetNbinsX() const = 0;
virtual unsigned GetNbinsY() const = 0;
//Using ROOT convention for bins in the calls below:
// bin = 0; underflow bin
// bin = 1; first bin with low-edge xlow INCLUDED
// bin = nbins; last bin with upper-edge xup EXCLUDED
// bin = nbins+1; overflow bin
virtual double GetBinContent(unsigned binx,unsigned biny) const = 0;
virtual double GetBinError(unsigned binx, unsigned biny) const = 0;
virtual void SetBinContent(unsigned binx, unsigned biny, const double& ) = 0;
virtual void SetBinError(unsigned binx, unsigned biny, const double& ) = 0;
virtual void SetBins(unsigned nbinsx,double xmin,double xmax,
unsigned nbinsy,double ymin,double ymax) = 0;
//Extensions:
virtual void GetBinContentAndError(unsigned binx, unsigned biny,double& content, double&error) const = 0;
virtual void SetBinContentAndError(unsigned binx, unsigned biny,const double& content, const double& error) = 0;
virtual void resetActiveBinLoop() = 0;
virtual bool getNextActiveBin(unsigned& binx, unsigned& biny, double& content, double& error) = 0;
virtual double getXMin() const = 0;
virtual double getXMax() const = 0;
virtual double getYMin() const = 0;
virtual double getYMax() const = 0;
virtual void getSums( double& sumW, double& sumW2,
double& sumWX,double& sumWX2,
double& sumWY, double& sumWY2,
double& sumWXY) const = 0;
virtual void setSums( const double& sumW, const double& sumW2,
const double& sumWX, const double& sumWX2,
const double& sumWY, const double& sumWY2,
const double& sumWXY ) = 0;
virtual void scaleContentsAndErrors( const double& fact ) = 0;//C.f. comment in LWHist1D.h
protected:
LWHist2D( const char* n, const char* t, bool rb ) : LWHist(n,t,rb) {}
virtual ~LWHist2D() {}
friend class LWHist::LWHistAxis;
virtual unsigned actualGetNBinsX() const { return GetNbinsX(); }
virtual unsigned actualGetNBinsY() const { return GetNbinsY(); }
virtual bool apply(TH1*) const;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class LWHistControls //
// //
// Description: Static methods for controlling and //
// monitoring various aspects related to the //
// light-weight histograms (in particular //
// memory management. Typical clients should //
// not worry about these. //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: April 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef LWHISTCONTROLS_H
#define LWHISTCONTROLS_H
class LWHistControls {
public:
//Whether or not calls to the various ::getROOTHist..() should
//trigger a cleanup of the internal data structures apart from the
//held ROOT histogram (i.e. effectively disallow further usage of
//the LW histogram itself). Default is true:
static bool cleanupOnGetROOT();
static void setCleanupOnGetROOT(bool);
//As absurd as it is to use ROOT histograms as the backend of LW
//histograms, this is exactly what we will have to do when running
//in the online environment (in that case getROOTHist will return
//the backend - which is only deleted along with the LW histogram):
static bool hasROOTBackend();
static void setROOTBackend(bool);
//For statistics (bytes):
static long long getTotalPoolMemAllocated();//Obsolete! Use LWHistStats method instead
static long long getTotalPoolMemUsed();//Obsolete! Use LWHistStats method instead
//Not more info, but for convenience:
static long long getMemUnusedButAllocatedInPools();//Obsolete! Use LWHistStats method instead
static double poolWasteFraction();//0: perfect, 1: very bad//Obsolete! Use LWHistStats method instead
//Call at the end of the job for a happy valgrind:
static void releaseAllHeldMemory();
private:
LWHistControls(){}
~LWHistControls(){}
class Imp;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class LWHistStats //
// //
// Description: Access to various statistics //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: October 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef LWHISTSTATS_H
#define LWHISTSTATS_H
class LWHistStats {
public:
static long nActiveLWHists() { return s_nActiveHists; }
static long long getTotalPoolMemAllocated();
static long long getTotalPoolMemUsed();
//Not more info, but for convenience:
static long long getMemUnusedButAllocatedInPools();
static double poolWasteFraction();//0: perfect, 1: very bad
private:
LWHistStats(){}
~LWHistStats(){}
static long s_nActiveHists;
friend class LWHist;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class TH1D_LW //
// //
// Description: LightWeight version of TH1D. //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: March 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef TH1D_LW_H
#define TH1D_LW_H
#include "LWHists/LWHist1D.h"
class TH1D;
class TH1D_LW : public LWHist1D {
public:
//To allocate from pool - remember to delete with LWHist::safeDelete(..):
static TH1D_LW * create( const char* name, const char* title,
unsigned nbinsx, const double& xlow, const double& xup );
static TH1D_LW * create( const char* name, const char* title, unsigned nbinsx, const double* xbins );
static TH1D_LW * create( const char* name, const char* title, unsigned nbinsx, const float* xbins );
void Fill(const double& x);
void Fill(const double& x, const double& w);
unsigned GetNbinsX() const;
double GetBinContent(unsigned bin) const;
double GetBinError(unsigned bin) const;
void SetBinContent(unsigned bin, const double& );
void SetBinError(unsigned bin, const double& );
unsigned GetEntries() const;
void SetEntries(unsigned);
void SetBins(unsigned nbins,double xmin,double xmax);
void Reset();
double getXMin() const;
double getXMax() const;
void GetBinContentAndError(unsigned bin,double& content, double&error) const;
void SetBinContentAndError(unsigned bin,const double& content, const double& error);
void getSums( double& sumW, double& sumW2,
double& sumWX,double& sumWX2 ) const;
void setSums( const double& sumW,const double&sumW2,
const double& sumWX,const double& sumWX2 );
TH1D* getROOTHist();
TH1* getROOTHistBase();
double Integral() const;
//For fast looping, skipping bins where (content,error)==(0,0):
void resetActiveBinLoop();
bool getNextActiveBin(unsigned& bin, double& content, double& error);
void scaleContentsAndErrors( const double& fact );//C.f. comment in LWHist1D.h
private:
friend class LWHistInt;
friend class LWHistVal;
void clear();
unsigned actualFindBinX(const double&) const;
double actualGetBinCenterX(int bin) const;
TH1* getROOTHistBaseNoAlloc() const;
void clearKeptROOTHist();//Does nothing if root-backend.
const float * getVarBins() const;//null if fixed bin-widths
TH1D_LW( const char* name, const char* title,
unsigned nbinsx, const double& xlow, const double& xup, bool rootbackend );
TH1D_LW( const char* name, const char* title, unsigned nbinsx, const double* xbins, bool rootbackend );
TH1D_LW( const char* name, const char* title, unsigned nbinsx, const float* xbins, bool rootbackend );
virtual ~TH1D_LW();
TH1D_LW( const TH1D_LW & );
TH1D_LW & operator= ( const TH1D_LW & );
void * m_flexHisto;
TH1D * m_rootHisto;
unsigned m_rootbackend_fastloopbin;
bool m_ownsRootSumw2;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class TH1F_LW //
// //
// Description: LightWeight version of TH1F. //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: March 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef TH1F_LW_H
#define TH1F_LW_H
#include "LWHists/LWHist1D.h"
class TH1F;
class TH1F_LW : public LWHist1D {
public:
//To allocate from pool - remember to delete with LWHist::safeDelete(..):
static TH1F_LW * create( const char* name, const char* title,
unsigned nbinsx, const double& xlow, const double& xup );
static TH1F_LW * create( const char* name, const char* title, unsigned nbinsx, const double* xbins );
static TH1F_LW * create( const char* name, const char* title, unsigned nbinsx, const float* xbins );
void Fill(const double& x);
void Fill(const double& x, const double& w);
unsigned GetNbinsX() const;
double GetBinContent(unsigned bin) const;
double GetBinError(unsigned bin) const;
void SetBinContent(unsigned bin, const double& );
void SetBinError(unsigned bin, const double& );
unsigned GetEntries() const;
void SetEntries(unsigned);
void SetBins(unsigned nbins,double xmin,double xmax);
void Reset();
double getXMin() const;
double getXMax() const;
void GetBinContentAndError(unsigned bin,double& content, double&error) const;
void SetBinContentAndError(unsigned bin,const double& content, const double& error);
void getSums( double& sumW, double& sumW2,
double& sumWX,double& sumWX2 ) const;
void setSums( const double& sumW,const double&sumW2,
const double& sumWX,const double& sumWX2 );
TH1F* getROOTHist();
TH1* getROOTHistBase();
double Integral() const;
//For fast looping, skipping bins where (content,error)==(0,0):
void resetActiveBinLoop();
bool getNextActiveBin(unsigned& bin, double& content, double& error);
void scaleContentsAndErrors( const double& fact );//C.f. comment in LWHist1D.h
private:
friend class LWHistInt;
friend class LWHistVal;
void clear();
unsigned actualFindBinX(const double&) const;
double actualGetBinCenterX(int bin) const;
TH1* getROOTHistBaseNoAlloc() const;
void clearKeptROOTHist();//Does nothing if root-backend.
const float * getVarBins() const;//null if fixed bin-widths
TH1F_LW( const char* name, const char* title,
unsigned nbinsx, const double& xlow, const double& xup, bool rootbackend );
TH1F_LW( const char* name, const char* title, unsigned nbinsx, const double* xbins, bool rootbackend );
TH1F_LW( const char* name, const char* title, unsigned nbinsx, const float* xbins, bool rootbackend );
virtual ~TH1F_LW();
TH1F_LW( const TH1F_LW & );
TH1F_LW & operator= ( const TH1F_LW & );
void * m_flexHisto;
TH1F * m_rootHisto;
unsigned m_rootbackend_fastloopbin;
bool m_ownsRootSumw2;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
////////////////////////////////////////////////////////////////
// //
// Header file for class TH1I_LW //
// //
// Description: LightWeight version of TH1I. //
// //
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
// Initial version: March 2009 //
// //
////////////////////////////////////////////////////////////////
#ifndef TH1I_LW_H
#define TH1I_LW_H
#include "LWHists/LWHist1D.h"
class TH1I;
class TH1I_LW : public LWHist1D {
public:
//To allocate from pool - remember to delete with LWHist::safeDelete(..):
static TH1I_LW * create( const char* name, const char* title,
unsigned nbinsx, const double& xlow, const double& xup );
static TH1I_LW * create( const char* name, const char* title, unsigned nbinsx, const double* xbins );
static TH1I_LW * create( const char* name, const char* title, unsigned nbinsx, const float* xbins );
void Fill(const double& x);
void Fill(const double& x, const double& w);
unsigned GetNbinsX() const;
double GetBinContent(unsigned bin) const;
double GetBinError(unsigned bin) const;
void SetBinContent(unsigned bin, const double& );
void SetBinError(unsigned bin, const double& );
unsigned GetEntries() const;