diff --git a/Calorimeter/CaloConditions/CaloConditions/Array.h b/Calorimeter/CaloConditions/CaloConditions/Array.h new file mode 100755 index 0000000000000000000000000000000000000000..824a42fe5e1ae1144d31a51941421158d6ae644d --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/Array.h @@ -0,0 +1,17 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: Array.h,v 1.2 2009-04-07 04:30:07 ssnyder Exp $ +/** + * @file Array.h + * @author scott snyder <snyder@bnl.gov> + * @date June, 2004 + * @brief Simple multidimensional arrays. + */ + + +// Temporary forwarding header... +#include "CxxUtils/Array.h" diff --git a/Calorimeter/CaloConditions/CaloConditions/Arrayrep.h b/Calorimeter/CaloConditions/CaloConditions/Arrayrep.h new file mode 100755 index 0000000000000000000000000000000000000000..e399a0cc06603ec5614deee3ee0ea6d3419d784c --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/Arrayrep.h @@ -0,0 +1,17 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: Arrayrep.h,v 1.3 2009-04-07 04:30:07 ssnyder Exp $ +/** + * @file Arrayrep.h + * @author scott snyder <snyder@bnl.gov> + * @date June, 2004 + * @brief Representation class for Array's. + */ + + +// Temporary forwarding header... +#include "CxxUtils/Arrayrep.h" diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloAffectedRegionInfo.h b/Calorimeter/CaloConditions/CaloConditions/CaloAffectedRegionInfo.h new file mode 100644 index 0000000000000000000000000000000000000000..3549fd45df1e735f3dce449a24854d0c223f0d93 --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloAffectedRegionInfo.h @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CaloAffectedRegionInfo_H +#define CaloAffectedRegionInfo_H + +/** + * @file CaloAffectedRegionInfo.h + * @author M.Escalier, G.Unal + * @date June, 2009 + * @brief object to store information about affected regions in calorimeter + */ + + +class CaloAffectedRegionInfo { + public: + + /** @brief enum to classify different problems */ + enum type_problem { + missingReadout=0, // missing readout + HVaffected=1, // HV not nominal + HVdead=2, // 0 HV on both sides of electrodes + CalibrationProblem=3, // region potentially badly calibrated + ReadoutErrors=4, // region with severe readout errors + ReadoutWarnings=5, // region with readout warnings + Unknown=-1 + }; + + /** + * @brief default constructor + * Creates empty list + */ + CaloAffectedRegionInfo(void); + + /** + * @brief constructor with parameters + * @param parameter_eta_min, parameter_eta_max eta range of affected region + * @param parameter_phi_min, parameter_phi_max phi range of affected region + * @param parameter_layer_min, parameter_layer_max range of layer affected (could be one or several) + * @param current_problem type of problem in the affected region, according to enum + * @param rate rate of problem (1 = all the events affected) + */ + CaloAffectedRegionInfo(float parameter_eta_min,float parameter_eta_max,float parameter_phi_min,float parameter_phi_max,int parameter_layer_min,int parameter_layer_max,type_problem current_problem,float parameter_rate=1.); + + + /** + * @brief modify settings of affected region + * @param parameter_eta_min, parameter_eta_max eta range of affected region + * @param parameter_phi_min, parameter_phi_max phi range of affected region + * @param parameter_layer_min, parameter_layer_max range of layer affected (could be one or several) + * @param current_problem type of problem in the affected region, according to enum + * @param rate rate of problem (1 = all the events affected) + */ + void FillCaloAffectedRegionInfo(float parameter_eta_min ,float parameter_eta_max,float parameter_phi_min ,float parameter_phi_max,int parameter_layer_min,int parameter_layer_max ,type_problem current_problem, float parameter_rate=1.); + + /** + * @brief print info + */ + void PrintInfo(void) const; + + /** @brief get eta min of region */ + float get_eta_min() const; + /** @brief get eta max of region */ + float get_eta_max() const; + /** @brief get phi min of region */ + float get_phi_min() const; + /** @brief get phi max of region */ + float get_phi_max() const; + /** @brief get layer min of region */ + int get_layer_min() const; + /** @brief get layer max of region */ + int get_layer_max() const; + /** @brief get problem type */ + int get_problem() const; + /** @brief get rate of problem */ + float get_rate() const; + + private: + float m_eta_min,m_eta_max; + float m_phi_min,m_phi_max; + float m_rate; + int m_layer_min,m_layer_max; + enum type_problem m_problem; +}; + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloAffectedRegionInfoVec.h b/Calorimeter/CaloConditions/CaloConditions/CaloAffectedRegionInfoVec.h new file mode 100644 index 0000000000000000000000000000000000000000..1b5bf10a603364c9c963ebe9d7cf7ff82a88096d --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloAffectedRegionInfoVec.h @@ -0,0 +1,18 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CaloAffectedRegionInfoVec_H +#define CaloAffectedRegionInfoVec_H + +#include <vector> +#include "CaloConditions/CaloAffectedRegionInfo.h" + +typedef std::vector<CaloAffectedRegionInfo> CaloAffectedRegionInfoVec; + +#ifndef CLIDSVC_CLASSDEF_H +# include "CLIDSvc/CLASS_DEF.h" +#endif +CLASS_DEF( CaloAffectedRegionInfoVec , 36372397, 1 ) + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloBadChannel.h b/Calorimeter/CaloConditions/CaloConditions/CaloBadChannel.h new file mode 100644 index 0000000000000000000000000000000000000000..404b32114d9f626dc91f26a6269968b74a8a48e3 --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloBadChannel.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CaloBadChannel_H +#define CaloBadChannel_H + +class CaloBadChannel { + public: + + typedef unsigned int PosType; + typedef unsigned int BitWord; + + enum ProblemType {deadBit=0, noisyBit=1, affectedBit=2}; + + CaloBadChannel( BitWord rawStatus) : m_word(rawStatus) {} + CaloBadChannel() : m_word(0) {} + + CaloBadChannel(const CaloBadChannel& rBad) {m_word=rBad.m_word;} + CaloBadChannel(const CaloBadChannel* pBad) {m_word=pBad->m_word;} + CaloBadChannel& operator= (const CaloBadChannel& rBad) { + m_word = rBad.m_word; + return *this; + } + + bool statusOK( ProblemType pb) const { + BitWord mask = 1 << (PosType) pb; + return ((m_word & mask) == 0); // OK means bit is not set + } + + bool dead() const {return !statusOK( deadBit);} + bool noisy() const {return !statusOK( noisyBit);} + bool affected() const {return !statusOK( affectedBit);} + + BitWord packedData() const {return m_word;} + + /// Sets the bit corresponding to "pb" inside the word passed as second argument to "value". + /// This static method provides a convenient way of setting the bits of a CaloBadChannel, + /// without compromizing the const interface of the class. The Bits should be set in a BitWord, + /// and then the BitWord passed to the constructor of CaloBadChannel. + static void setBit( ProblemType pb, BitWord& word, bool value=true) { + BitWord mask = 1 << static_cast<PosType>(pb); // all at 0 axcept pb bit + if (value) word |= mask; + else word &= ~mask; + } + + private: + + BitWord m_word; + +}; + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloCellFactor.h b/Calorimeter/CaloConditions/CaloConditions/CaloCellFactor.h new file mode 100755 index 0000000000000000000000000000000000000000..ab4e1ac612ddd7c205e0350a81362ae6f3b04ef3 --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloCellFactor.h @@ -0,0 +1,66 @@ +// Dear emacs, this is -*- c++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file CaloCellFactor.h + * @author Walter Lampl <walter.lampl@cern.ch> + * @date Dec 21, 2006 + * @brief Container for a cell-level rescaling-factors, typically obtained by Z->ee intercalibration + */ + + +#ifndef CALOREC_CALOCELLSCALE_H +#define CALOREC_CALOCELLSCALE_H + + +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> + +namespace CaloRec { + +/** + * @class CaloCellFactor + * @brief Container for a cell-level rescaling-factors, typically obtained by Z->ee intercalibration + * + */ +class CaloCellFactor + { + public: + typedef std::vector<float> contType; + typedef contType::size_type size_type; + + //** Default Constructor + CaloCellFactor() {}; + + //** Standard constructor, resize vector and set elements on 1.0 + CaloCellFactor(const size_type& size); + + + //** non-const access + inline float& operator[](const size_type& hashID) + {return m_cellFactor[hashID];} + + + //** const access + inline const float& operator[](const size_type& hashID) const + {return m_cellFactor[hashID];} + + //** resize underlying vector (new elements will be 1.0) + void resize(const size_type& size); + + size_type size() const + {return m_cellFactor.size();} + + private: + contType m_cellFactor; + + + };//end class +}// end namespace + +CLASS_DEF(CaloRec::CaloCellFactor,206274732,1) + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloCellPositionShift.h b/Calorimeter/CaloConditions/CaloConditions/CaloCellPositionShift.h new file mode 100755 index 0000000000000000000000000000000000000000..3685f2445819f2eda8acfd80f3c21ce01619cd9b --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloCellPositionShift.h @@ -0,0 +1,79 @@ +// Dear emacs, this is -*- c++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file CaloCellPositionShift.h + * @author G.Unal + * @date June 11, 2009 + * @brief Container for a cell-level position corrections to account for distorsion of calo shape in reconstruction geometry + */ + + +#ifndef CALOREC_CALOCELLPOSITIONSHIFT_H +#define CALOREC_CALOCELLPOSITIONSHIFT_H + + +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> + +namespace CaloRec { + +/** + * @class CaloCellPositionShift + * @brief Container for a cell-level rescaling-factors, typically obtained by Z->ee intercalibration + * + */ +class CaloCellPositionShift + { + public: + typedef std::vector<float> contType; + typedef contType::size_type size_type; + + //** Default Constructor + CaloCellPositionShift() {}; + + //** Standard constructor, resize vector and set elements to 0. + CaloCellPositionShift(const size_type& size); + + + //** access to shift in X + inline float deltaX(const size_type& hashID) const + {return m_deltaX[hashID];} + //** access to shift in Y + inline float deltaY(const size_type& hashID) const + {return m_deltaY[hashID];} + //** access to shift in Z + inline float deltaZ(const size_type& hashID) const + {return m_deltaZ[hashID];} + + //** set dx shift + inline void set_deltaX(const size_type& hashID,float dx) + {if(hashID<m_deltaX.size()) m_deltaX[hashID]=dx;} + //** set dy shift + inline void set_deltaY(const size_type& hashID,float dy) + {if(hashID<m_deltaY.size()) m_deltaY[hashID]=dy;} + //** set dz shift + inline void set_deltaZ(const size_type& hashID,float dz) + {if(hashID<m_deltaZ.size()) m_deltaZ[hashID]=dz;} + + //** resize underlying vector (new elements will be 1.0) + void resize(const size_type& size); + + size_type size() const + {return m_deltaX.size();} + + private: + contType m_deltaX; + contType m_deltaY; + contType m_deltaZ; + + + };//end class +}// end namespace + +CLASS_DEF(CaloRec::CaloCellPositionShift,96609121,1) + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloConditionsDict.h b/Calorimeter/CaloConditions/CaloConditions/CaloConditionsDict.h new file mode 100755 index 0000000000000000000000000000000000000000..74b34509ea65757b934846a57392fd44e7e3fd8f --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloConditionsDict.h @@ -0,0 +1,17 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CALOCONDITIONSDICT_H +#define CALOCONDITIONSDICT_H + +#include "CaloConditions/ToolConstants.h" +#include "CaloConditions/CaloCellFactor.h" +#include "CaloConditions/CaloCellPositionShift.h" +#include "CaloConditions/CaloHadWeight.h" +#include "CaloConditions/CaloEMFrac.h" +#include "CaloConditions/CaloHadDMCoeff.h" +#include "CaloConditions/CaloHadDMCoeff2.h" +#include "CaloConditions/CaloLocalHadCoeff.h" + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloEMFrac.h b/Calorimeter/CaloConditions/CaloConditions/CaloEMFrac.h new file mode 100755 index 0000000000000000000000000000000000000000..158f6435894e217686bd3b7500666d7df2035565 --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloEMFrac.h @@ -0,0 +1,219 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: CaloEMFrac.h,v 1.2 2007-10-26 01:47:22 ssnyder Exp $ +/** + * @file CaloConditions/CaloEMFrac.h + * @brief Hold binned EM fraction data. + */ + +#ifndef CALOCONDITIONS_CALOEMFRAC_H +#define CALOCONDITIONS_CALOEMFRAC_H + + +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> + + +/** + * @brief Hold binned EM fraction data. + * + * This class holds data on the average EM fraction of EM clusters. + * These data are binned along four axes: + * - The (absolute value of the) cluster eta. + * - The (log10 of the) cluster energy. + * - The (log10 of the) cluster energy density. + * (In later versions, this is normalized by the cluster energy.) + * - The (log10 of the) cluster depth. + * + * In each bin, we store the mean EM fraction in the bin, plus information + * about distribution width and number of entries. + */ +class CaloEMFrac { + +public: + + /** + * @brief Per-bin data. + */ + struct EMFracData { + /// The mean EM fraction in the bin. + float m_fraction; + + /// Number of entries populating the bin. + /// ??? FIXME: Someone check that this comment is correct. + float m_entries; + + /// Width of the distribution. + /// ??? FIXME: Someone check that this comment is correct. + float m_error; + + /// Constructor. + EMFracData() : m_fraction(0),m_entries(0),m_error(0) {}; + }; + + + /** + * @brief Default Constructor. (Only intended for use by persistency.) + */ + CaloEMFrac() {}; + + + /** + * @brief Constructor. + * @param nBinEta Number of bins in eta. + * @param MinEta Minimum eta for the first bin. + * @param MaxEta Maximum eta for the last bin. + * @param nBinLogEClus Number of bins in log10(cluster energy). + * @param MinLogEClus Minimum log10(cluster energy) for the first bin. + * @param MaxLogEClus Maximum log10(cluster energy) for the last bin. + * @param nBinLogEDens Number of bins in log10(cluster energy density). + * @param MinLogEDens Minimum log10(cluster energy density) for the first bin. + * @param MaxLogEDens Maximum log10(cluster energy density) for the last bin. + * @param nBinLogDepth Number of bins in log10(cluster depth). + * @param MinLogDepth Minimum log10(cluster depth) for the first bin. + * @param MaxLogDepth Maximum log10(cluster depth) for the last bin. + */ + CaloEMFrac(int nBinEta, + float MinEta, + float MaxEta, + int nBinLogEClus, + float MinLogEClus, + float MaxLogEClus, + int nBinLogEDens, + float MinLogEDens, + float MaxLogEDens, + int nBinLogDepth, + float MinLogDepth, + float MaxLogDepth + ); + + + /// Return the number of bins in eta. + int getNbinsEta() const {return m_nBinEta;} + /// Return the minimum eta for the first bin. + float getEtaMin() const {return m_MinEta;} + /// Return the maximum eta for the last bin. + float getEtaMax() const {return m_MaxEta;} + + /// Return the number of bins in log10(cluster energy). + int getNbinsLogEClus() const {return m_nBinLogEClus;} + /// Return the minimum log10(cluster energy) for the first bin. + float getLogEClusMin() const {return m_MinLogEClus;} + /// Return the maximum log10(cluster energy) for the last bin. + float getLogEClusMax() const {return m_MaxLogEClus;} + + /// Return the number of bins in log10(cluster energy density). + int getNbinsLogEDens() const {return m_nBinLogEDens;} + /// Return the minimum log10(cluster energy density) for the first bin. + float getLogEDensMin() const {return m_MinLogEDens;} + /// Return the maximum log10(cluster energy density) for the last bin. + float getLogEDensMax() const {return m_MaxLogEDens;} + + /// Return the number of bins in log10(cluster depth). + int getNbinsLogDepth() const {return m_nBinLogDepth;} + /// Return the minimum log10(cluster depth) for the first bin. + float getLogDepthMin() const {return m_MinLogDepth;} + /// Return the maximum log10(cluster depth) for the last bin. + float getLogDepthMax() const {return m_MaxLogDepth;} + + + /** + * @brief Return EM fraction data for one bin. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @param logEDens log10(cluster energy density) (possibly normalized) + * @param logDepth log10(cluster depth) + * @returns Pointer to the bin data, or 0 if out of range. + * + * The pointer may be invalidated by a subsequent setEMFracData call. + */ + const struct EMFracData * getEMFracData(float eta, + float logEClus, + float logEDens, + float logDepth) const; + + + /** + * @brief Set EM fraction data for one bin. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @param logEDens log10(cluster energy density) (possibly normalized) + * @param logDepth log10(cluster depth) + * @param theData The bin data. + * + * This will overwrite any earlier data for the same bin. + * If the coordinates are out of range, this is a no-op. + */ + void setEMFracData(float eta, + float logEClus, + float logEDens, + float logDepth, + const struct EMFracData & theData); + + +private: + + /// Number of eta bins. + int m_nBinEta; + /// Number of log10(cluster energy) bins. + int m_nBinLogEClus; + /// Number of log10(cluster energy density) bins. + int m_nBinLogEDens; + /// Number of log10(cluster depth) bins. + int m_nBinLogDepth; + + /// Minimum eta for the first bin. + float m_MinEta; + /// Minimum log10(cluster energy) for the first bin. + float m_MinLogEClus; + /// Minimum log10(cluster energy density) for the first bin. + float m_MinLogEDens; + /// Minimum log10(cluster depth) for the first bin. + float m_MinLogDepth; + + /// Maximum eta for the last bin. + float m_MaxEta; + /// Maximum log10(cluster energy) for the last bin. + float m_MaxLogEClus; + /// Maximum log10(cluster energy density) for the last bin. + float m_MaxLogEDens; + /// Maximum log10(cluster depth) for the last bin. + float m_MaxLogDepth; + + /// The table. + /// Binned in the following order, least-rapidly varying first: + /// eta, logEClus, logEDens, logDepth. + std::vector<struct EMFracData> m_data; + + + /** + * @brief Find the eta/logEClus bin number. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @returns Bin number in the eta/logEClus subspace, or -1 if out of range. + */ + int getEtaLogEClusBin(float eta, float logEClus) const; + + + /** + * @brief Find a bin number. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @param logEDens log10(cluster energy density) (possibly normalized) + * @param logDepth log10(cluster depth) + * @returns The bin number, or -1 if out of range. + */ + int getBin(float eta, float logEClus, float logEDens, float logDepth) const; + + +};//end class + + +CLASS_DEF(CaloEMFrac,42479507,1) + + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloHadDMCoeff.h b/Calorimeter/CaloConditions/CaloConditions/CaloHadDMCoeff.h new file mode 100755 index 0000000000000000000000000000000000000000..a44fd3f32635097802f175423d45b95fdf7e99ae --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloHadDMCoeff.h @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CALOCONDITIONS_CALOHADDMCOEFF_H +#define CALOCONDITIONS_CALOHADDMCOEFF_H + +/*! +\file CaloHadDMCoeff.h +\author Guennadi.Pospelov@cern.ch +\date March 2006 + +\class DeadMaterialCorrectionTool +\brief Local cluster correction tool for Dead Material correction + in hadronic clusters. +*/ + +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> +#include <string> +#include <cstdio> + +class CaloHadDMCoeff { + public: + struct HadDMArea { + std::string m_title; + int m_indx; + int m_is_on; + float m_MinFrac; + float m_MaxFrac; + std::vector<float> m_FracBins; + float m_MinEner; + float m_MaxEner; + std::vector<float> m_EnerBins; + float m_MinEta; + float m_MaxEta; + std::vector<float> m_EtaBins; + int m_nPars; + int m_offset; + HadDMArea() : m_indx(0), m_is_on(0), m_MinFrac(0.0), m_MaxFrac(0.0), + m_MinEner(0.0), m_MaxEner(0.0), m_MinEta(0.0), m_MaxEta(0.0), + m_nPars(0), m_offset(0) {}; + }; + typedef std::vector<float> HadDMCoeff; + + /// Default Constructor + CaloHadDMCoeff(); + CaloHadDMCoeff(const CaloHadDMCoeff &other); + CaloHadDMCoeff& operator= (const CaloHadDMCoeff& other); + + const HadDMCoeff * getHadDMCoeff(const int & dm_area, const float & cls_emfrac, const float & cls_ener, const float & cls_eta) const; + inline const HadDMCoeff * getHadDMCoeff(const int & iBin) const + { + if ( iBin > -1 && iBin < (int)m_DMCoeffSet.size() ) { + return (& m_DMCoeffSet[iBin]); + }else{ + return 0; + } + } + + const HadDMArea * getHadDMArea(int n_area) const; + void addHadDMCoeff(const HadDMCoeff & theData); + void setHadDMCoeff(const int iBin, const HadDMCoeff & theData); + void addHadDMArea(const HadDMArea & theArea); + void setHadDMArea(const int n_area, const HadDMArea & theArea); + void PrintData(FILE *fout = stdout) const; + + inline int getSizeDMAreaSet() const {return (int)m_DMAreaSet.size();} + inline int getSizeDMCoeffSet() const {return (int)m_DMCoeffSet.size();} + int getBinFrac(const int dm_area, const float & cls_frac) const; + int getBinEner(const int dm_area, const float & cls_ener) const; + int getBinEta(const int dm_area, const float & cls_eta) const; + int getBin(const int & n_dm_area, const float & cls_frac, const float & cls_ener, const float & cls_eta) const; + int getBin(const int & n_dm_area, const int & ifrac, const int & iener, const int & ieta) const; + + private: + std::vector<HadDMCoeff> m_DMCoeffSet; + std::vector<HadDMArea> m_DMAreaSet; +}; +//Class Identifier obtained by +//'clid CaloHadDMCoeff' +CLASS_DEF(CaloHadDMCoeff,227697804,1) + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloHadDMCoeff2.h b/Calorimeter/CaloConditions/CaloConditions/CaloHadDMCoeff2.h new file mode 100755 index 0000000000000000000000000000000000000000..c30eac3b53f69d628af1d7506a8feea1c95176ed --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloHadDMCoeff2.h @@ -0,0 +1,94 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CALOCONDITIONS_CALOHADDMCOEFF2_H +#define CALOCONDITIONS_CALOHADDMCOEFF2_H + +/** + * @class CaloHadDMCoeff2 + * @author Gennady Pospelov <guennadi.pospelov@cern.ch> + * @date 21-November-2007 + * @brief Dead material correction coefficients + * + * Holds dead material correction coefficients for using in Local Hadronic + * Correction Procedure (DeadMaterialCorrrection tool) */ + + +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> +#include <string> +#include <fstream> + +class CaloHadDMCoeff2 { + public: + enum key_dim_type { kDIM_FLAT, kDIM_HAND }; + enum key_area_type { kAREA_PROF, kAREA_LOOKUP, kAREA_SMPW}; + struct HadDMDimension { + std::string m_title; + int m_type; + int m_nbins; + float m_vMin; + float m_vMax; + float m_bin_size; + int xloc; + std::vector<float > m_vBins; + + HadDMDimension() : m_type(0), m_nbins(0), m_vMin(0.0), m_vMax(0.0), m_bin_size(0.0), xloc(0) {}; + }; + struct HadDMArea { + std::string m_title; + int m_indx; + int m_is_on; + int m_type; + int m_nPars; + int m_offset; + int m_length; + HadDMDimension m_dimFrac; + HadDMDimension m_dimEner; + HadDMDimension m_dimLambda; + HadDMDimension m_dimEta; + + HadDMArea() : m_indx(0), m_is_on(0), m_type(0), m_nPars(0), m_offset(0), m_length(0) {}; + }; + typedef std::vector<float> HadDMCoeff; + + // Default Constructor + CaloHadDMCoeff2(); + CaloHadDMCoeff2(const CaloHadDMCoeff2 &other); + CaloHadDMCoeff2& operator= (const CaloHadDMCoeff2& other); + + // methods to deal with DM areas + inline int getSizeDMAreaSet() const { return (int)m_DMAreaSet.size(); } + void addHadDMArea(const HadDMArea & theArea); + void setHadDMArea(const int n_area, const HadDMArea & theArea); + const HadDMArea * getHadDMArea(int n_area) const; + + // methods to deal with DM coefficients + inline int getSizeDMCoeffSet() const { return (int)m_DMCoeffSet.size(); } + void addHadDMCoeff(const HadDMCoeff & theData); + void setHadDMCoeff(const int iBin, const HadDMCoeff & theData); + const HadDMCoeff * getHadDMCoeff(const int & iBin) const; + const HadDMCoeff * getHadDMCoeff(const int & n_area, const float & cls_emfrac, const float & cls_ener, const float & cls_lambda, const float & cls_eta) const; + + // methods to get DM coefficients bin number + int getBinFrac(const int dm_area, const float & cls_frac) const; + int getBinEner(const int dm_area, const float & cls_ener) const; + int getBinLambda(const int dm_area, const float & cls_lambda) const; + int getBinEta(const int dm_area, const float & cls_eta) const; + int getBin(const int n_area, const float &cls_em_frac, const float &cls_energy, const float &cls_lambda, const float &cls_eta) const; + + // Accessories + void PrintData(std::ostream &ff) const; + int bin2indexes(const int iBin, std::vector<int> &v_dim_indx) const; + + private: + std::vector<HadDMCoeff> m_DMCoeffSet; + std::vector<HadDMArea> m_DMAreaSet; + std::vector<int > m_area_offsets; +}; +//Class Identifier obtained by +//'clid CaloHadDMCoeff2' +CLASS_DEF(CaloHadDMCoeff2, 249025083,1) + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloHadWeight.h b/Calorimeter/CaloConditions/CaloConditions/CaloHadWeight.h new file mode 100755 index 0000000000000000000000000000000000000000..d9cf7e0094a917786294d75b5da3052b45fd77ec --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloHadWeight.h @@ -0,0 +1,101 @@ +// Dear emacs, this is -*- c++ -*- + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +#ifndef CALOCONDITIONS_CALOHADWEIGHT_H +#define CALOCONDITIONS_CALOHADWEIGHT_H + + +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> + +/** + * @class CaloHadWeight + * + */ +class CaloHadWeight { + +public: + + struct HadData { + float m_weight; + float m_entries; + float m_error; + HadData() : m_weight(0),m_entries(0),m_error(0) {}; + }; + + //** Default Constructor + CaloHadWeight() {}; + + CaloHadWeight(const int & nBinEta, + const float & MinEta, + const float & MaxEta, + const int & nBinSampling, + const int & MinSampling, + const int & MaxSampling, + const int & nBinLogEClus, + const float & MinLogEClus, + const float & MaxLogEClus, + const int & nBinLogEDensCell, + const float & MinLogEDensCell, + const float & MaxLogEDensCell + ); + + // access methods + + inline const int & getNbinsEta() const {return m_nBinEta;} + inline const float & getEtaMin() const {return m_MinEta;} + inline const float & getEtaMax() const {return m_MaxEta;} + + inline const int & getNbinsSampling() const {return m_nBinSampling;} + inline const int & getSamplingMin() const {return m_MinSampling;} + inline const int & getSamplingMax() const {return m_MaxSampling;} + + inline const int & getNbinsLogEClus() const {return m_nBinLogEClus;} + inline const float & getLogEClusMin() const {return m_MinLogEClus;} + inline const float & getLogEClusMax() const {return m_MaxLogEClus;} + + inline const int & getNbinsLogEDensCell() const {return m_nBinLogEDensCell;} + inline const float & getLogEDensCellMin() const {return m_MinLogEDensCell;} + inline const float & getLogEDensCellMax() const {return m_MaxLogEDensCell;} + + const struct HadData * getHadData(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell) const; + + // set methods + + void setHadData(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell, const struct HadData & theData); + + +private: + + int m_nBinEta; + int m_nBinSampling; + int m_nBinLogEClus; + int m_nBinLogEDensCell; + + float m_MinEta; + int m_MinSampling; + float m_MinLogEClus; + float m_MinLogEDensCell; + + float m_MaxEta; + int m_MaxSampling; + float m_MaxLogEClus; + float m_MaxLogEDensCell; + + std::vector<int> m_indexEtaSampling; + std::vector<struct HadData> m_data; + + int getEtaSamplingBin(const float & eta, const int & sampling) const; + + int getBin(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell) const; + + +};//end class + +CLASS_DEF(CaloHadWeight,124150759,1) + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloLocalHadCoeff.h b/Calorimeter/CaloConditions/CaloConditions/CaloLocalHadCoeff.h new file mode 100644 index 0000000000000000000000000000000000000000..68be1aa40a4b176731757e9b1d9aaff16fd14dea --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloLocalHadCoeff.h @@ -0,0 +1,307 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CALOCONDITIONS_CALOLOCALHADCOEFF_H +#define CALOCONDITIONS_CALOLOCALHADCOEFF_H + +/** + * @class CaloLocalHadCoeff + * @author Gennady Pospelov <guennadi.pospelov@cern.ch>, Pavol Strizenec <pavol@mail.cern.ch> + * @date 20-July-2009 + * @brief Hold binned correction data for local hadronic calibration procedure + * + * This class holds binned correction data in multi-dimensional space for + * classification, weighting, out-of-cluster or dead material correction tools. + * Data are holded as vector of floats for each bin defined, thereby + * that at the end they appear to be vector of vector of float. One data + * set (one CaloLocalHadCoeff) serve for one correction tool. + * + * Binning definition is done via conception of 'correction areas'. One area has + * fixed number of dimenensions, fixed way how these dimensions have been binned + * and fixed number of correction parameters for each bin. + * + * For example, em/had classification tool requires following setup: + * 3 correction coefficients (em fraction of bin, number of entries in bin, some + * error in bin) are binned in 4 dimensions: cluster eta, log10(cluster energy), + * log10(cluster energy density), log10(cluter depth). + * + * There could be more, than one, correction area defined for one correction tool. + * For example, dead material correction have 8 different areas defined for different + * kind of dead material energy depositions (before presamplers, between emec and hec, + * before FCAL, etc) + */ + + +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> +#include <string> +#include <fstream> + +class CaloLocalHadCoeff { + public: + + /** + * @brief Class defines binning for user dimension + */ + class LocalHadDimension { + public: + /** + * @brief Default Constructor. + */ + LocalHadDimension() : m_type(0), m_nbins(0), m_xmin(0.0), m_xmax(0.0), m_dx(0.0) {}; + + /** + * @brief Constructor to define equidistant binning + * @param title Dimension title + * @param type Dimension type + * @param xmin Minimum value for the first bin + * @param xmax Maximum value for the last bin + */ + LocalHadDimension(const char *title, unsigned int typ, int nbins, float xmin, float xmax) : + m_title(title), m_type(typ), m_nbins(nbins), m_xmin(xmin), m_xmax(xmax) + { + m_xbins.resize(0); + m_dx = (m_xmax-m_xmin)/float(m_nbins); + } + + /** + * @brief Constructor to define arbitrary binning + * @param title Dimension title + * @param type Dimension type + * @param xbins Bins borders, vector of size m_nbins+1 + */ + LocalHadDimension(const char *title, unsigned int typ, std::vector<float > &xbins) : + m_title(title), m_type(typ), m_dx(0.0) + { + m_xbins = xbins; + m_xmin = xbins.front(); + m_xmax = xbins.back(); + m_nbins = xbins.size() -1; + } + /** + * @brief Copy constructor + */ + LocalHadDimension(const LocalHadDimension &other); + LocalHadDimension& operator= (const LocalHadDimension &other); + + // access methods + + /// return dimension type + inline unsigned int getType() const {return m_type;} + + /// return number of bins + inline int getNbins() const {return m_nbins;} + + /// return minimum value for the first bin + inline float getXmin() const {return m_xmin;} + + /// return maximum value for the last bin + inline float getXmax() const {return m_xmax;} + + /// return size of bin + inline float getDx() const {return m_dx;} + + /// return bin number + int getBin(float &x) const; + + int getBinAdjusted(float &x, float &xadj) const; + + /// return dimension name + std::string getTitle() const {return m_title;} + + private: + /// dimensions title (e.g. "eta", "energy", "lambda", "blabla", etc) + std::string m_title; + + /// dimension type + unsigned int m_type; + + /// number of bins + int m_nbins; + + /// minimum value for the first bin + float m_xmin; + + /// maximum value for the last bin + float m_xmax; + + /// bin size (in the case of equidistant binning) + float m_dx; + + /// bins borders (if dimension has non-equidistant binning), vector of size m_nbins+1 + std::vector<float > m_xbins; + }; + + /** + * @brief Definition of correction area + * + */ + class LocalHadArea { + public: + /** + * @brief Default Constructor. + */ + LocalHadArea() : m_type(0), m_npars(0), m_offset(0), m_length(0) {}; + /** + * @brief Constructor. + * @param title Name of the area + * @param typ Type of area + * @param npars Number of correction parameters + */ + LocalHadArea(const char *title, int typ, int npars) : m_title(title), m_type(typ), m_npars(npars), m_offset(0), m_length(0) + { + m_dims.resize(0); + m_dims_loc.resize(0); + }; + /** + * @brief Copy constructor + */ + LocalHadArea(const LocalHadArea &other); + LocalHadArea& operator= (const LocalHadArea &other); + + /// return area type + inline unsigned int getType() const { return m_type; } + /// return number of parameters + inline int getNpars() const { return m_npars; } + /// return area offset + inline int getOffset() const { return m_offset; } + /// return area length + inline int getLength() const { return m_length; } + /// get number of dimensions + inline int getNdim() const { return (int) m_dims.size(); } + /// get dimension locator coefficient + inline int getDimLoc(int i_dim) const { return m_dims_loc[i_dim]; } + /// return name + std::string getTitle() const {return m_title;} + + /// set area offset + void setOffset(int offset) { m_offset = offset; } + /// set area length + void setLength(int length) { m_length = length; } + /// to add new dimension + void addDimension(LocalHadDimension &dim); + /// to get dimension + const CaloLocalHadCoeff::LocalHadDimension *getDimension(int n_dim) const { return &(m_dims[n_dim]); } + + private: + /// area title + std::string m_title; + + /// area type + unsigned int m_type; + + /// number of correction parameters + int m_npars; + + /// offset for the data in global vector (if more than one area is defined) + int m_offset; + + /// length of area data block (product of m_nbins over all dimensions defined) + int m_length; + + /// vector of defined dimensions + std::vector<LocalHadDimension > m_dims; + + /// locator index for dimensions + std::vector<int > m_dims_loc; + }; + + /** + * @brief Correction parameters for one general bin + */ + typedef std::vector<float> LocalHadCoeff; + + /** + * @brief Default constructor. + */ + CaloLocalHadCoeff(); + + /** + * @brief Copy constructor. + */ + CaloLocalHadCoeff(const CaloLocalHadCoeff &other); + CaloLocalHadCoeff& operator= (const CaloLocalHadCoeff &other); + + // + // general access methods + /// return name + std::string getTitle() const {return m_title;} + + /// set name + void setTitle(const std::string &title) {m_title = title; } + + // + // access methods for areas + + /// return number of areas defined for this data set + inline int getSizeAreaSet() const { return (int)m_AreaSet.size(); } + + /// add new area + void addArea(LocalHadArea & theArea); + + /// replace existing area with another one + void setArea(const int n_area, const LocalHadArea & theArea); + + /// return area + const LocalHadArea *getArea(int n_area) const; + + /// return area defined for given general iBin + const LocalHadArea *getAreaFromBin(int iBin) const; + + /// return area (and area index) defined for given general iBin + const LocalHadArea *getAreaFromBin(int iBin, int &i_area) const; + + // + // access methods for parameters + + /// return total number of coefficient sets + inline int getSizeCoeffSet() const { return (int)m_CoeffSet.size(); } + + /// set new data + void setCoeff(const int iBin, const LocalHadCoeff & theCoeff); + + /// get data for given general bin number + const LocalHadCoeff * getCoeff(const int & iBin) const; + + /// get data for given area and list of cluster variables + const LocalHadCoeff * getCoeff(const int & n_area, std::vector<float> &vars) const; + + // + // access method for bins + + /// calculate general bin from vector of input cluster variables + int getBin(const int n_area, std::vector<float> &vars) const; + + /// calculate general bin from known bins in dimensions + int getBin(const int n_area, std::vector<int> &v_indexes) const; + + /// expand general bin into vector of bins for defined dimensions + int bin2indexes(const int iBin, std::vector<int> &v_dim_indx) const; + + /// are this bins is neighbour to this indexes vector (any of their indexes differ per one ?) + bool isNeighbour(const int iBinx, std::vector<int> &v_indx) const; + + /// check if general bin is filled + bool isFilled(const int iBin) const; + + /// for interpolation, build the vector of relative x, and global bins for interpolated array + /// for area n_area and list of dimensions (all in case dim is empty) + bool getInterpArrays(const int n_area, const std::vector<int> &dim, std::vector<float> &x, + std::vector<double> &xadj, std::vector<unsigned int> &gbin) const; + + private: + + /// title of data set + std::string m_title; + + /// vector of correction coefficients + std::vector<LocalHadCoeff> m_CoeffSet; + + /// vector of correction areas + std::vector<LocalHadArea> m_AreaSet; +}; +//Class Identifier obtained by 'clid CaloLocalHadCoeff' +CLASS_DEF(CaloLocalHadCoeff, 29079131, 1) + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/CaloLocalHadDefs.h b/Calorimeter/CaloConditions/CaloConditions/CaloLocalHadDefs.h new file mode 100644 index 0000000000000000000000000000000000000000..56b2630c78e7cd62e17571bba0e1bea3f8b0e6be --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/CaloLocalHadDefs.h @@ -0,0 +1,79 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef CALOCONDITIONS_CALOLOCALHADDEFS_H +#define CALOCONDITIONS_CALOLOCALHADDEFS_H + +/** + * @struct CaloLocalHadCoeff + * @author Gennady Pospelov <guennadi.pospelov@cern.ch> + * @date 18-August-2009 + * @brief defines enums and data types of @c CaloLocalHadCoeff + * + */ + + +struct CaloLocalHadDefs { + /** @brief enums to identify different area types corrected with different approaches */ + enum LocalHadAreaType { + AREA_STD = 0, // Standard area, lookup table + AREA_DMFIT = 101, // dead material area corrected with polynom fit + AREA_DMLOOKUP = 102, // dead material area corrected with lookup table approach + AREA_DMSMPW = 103 // dead material area corrected with new calo sampling weights + }; + + /** @brief enums to identify different types of correction coefficients */ + enum LocalHadCoeffType { + BIN_WEIGHT = 0, // weight stored in one lookup table bin + BIN_ENTRIES = 1, // number of entries in one lookup table bin + BIN_ERROR = 2, // error stored in one lookup table bin + BIN_P0 = 0, // polynomial coefficients in p0+p1*x+p2*x*x + BIN_P1 = 1, // polynomial coefficients in p0+p1*x+p2*x*x + BIN_P2 = 2 // polynomial coefficients in p0+p1*x+p2*x*x + }; + + /** @brief enums to identify user dimensions types */ + enum LocalHadDimensionType { + DIM_LOG = 1<<0, // logarithmic scale + DIM_WRAP = 1<<1, // phi-like dimension + DIM_EQUI = 1<<2 // equidistant binning + }; + + /** @brief enums to identify user dimensions id number + * DIMC_* - classification, DIMW_*-weighting, DIMO_* - out-of-cluser, DIMD_* - dead material */ + enum LocalHadDimensionId { + // classification + DIMC_SIDE = 0, + DIMC_ETA = 1, + DIMC_PHI = 2, + DIMC_ENER = 3, + DIMC_EDENS = 4, + DIMC_LAMBDA = 5, + // weighting + DIMW_SIDE = 0, + DIMW_ETA = 1, + DIMW_PHI = 2, + DIMW_ENER = 3, + DIMW_EDENS = 4, + // out-of-cluster + DIMO_SIDE = 0, + DIMO_PHI = 1, + DIMO_ENER = 2, + DIMO_ETA = 3, + DIMO_LAMBDA = 4, + // dead material + DIMD_EMFRAC = 0, + DIMD_SIDE = 1, + DIMD_ETA = 2, + DIMD_PHI = 3, + DIMD_ENER = 4, + DIMD_LAMBDA = 5, + // unknown + DIMU_UNKNOWN = 99 + }; + +}; + + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/ICaloBadChanTool.h b/Calorimeter/CaloConditions/CaloConditions/ICaloBadChanTool.h new file mode 100644 index 0000000000000000000000000000000000000000..4aa9304052aff3b0c4ec4f319c03c80af7496791 --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/ICaloBadChanTool.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef ICaloBadChanTool_H +#define ICaloBadChanTool_H + +#include "Identifier/Identifier.h" +#include "CaloConditions/CaloBadChannel.h" +#include "GaudiKernel/IAlgTool.h" + +class ICaloBadChanTool : public virtual IAlgTool { +public: + + virtual ~ICaloBadChanTool() {} + + virtual CaloBadChannel caloStatus( Identifier id) const = 0; + + static const InterfaceID& interfaceID() { + static const InterfaceID id("ICaloBadChanTool", 1 , 0); + return id; + } + +}; + +#endif diff --git a/Calorimeter/CaloConditions/CaloConditions/ToolConstants.h b/Calorimeter/CaloConditions/CaloConditions/ToolConstants.h new file mode 100755 index 0000000000000000000000000000000000000000..8f964d519bc546a7ce448745d09c95e248e2be9c --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/ToolConstants.h @@ -0,0 +1,147 @@ +// This file's extension implies that it's C, but it's really -*- C++ -*-. + +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: ToolConstants.h,v 1.5 2009-04-09 14:41:17 ssnyder Exp $ +/** + * @file ToolConstants.h + * @author scott snyder <snyder@bnl.gov> + * @date June, 2004 + * @brief Container for the tool constants managed by @c ToolWithConstants. + */ + + +#ifndef CALOREC_TOOLCONSTANTS_H +#define CALOREC_TOOLCONSTANTS_H + + +#include "CLIDSvc/CLASS_DEF.h" +#include "CxxUtils/Array.h" +#include <string> +#include <map> + +namespace CaloRec { + + +/** + * @class ToolConstants + * @brief Container for the tool constants managed by @c ToolWithConstants. + * + * This is just a simple map from constant name to @c Arrayrep. + */ +class ToolConstants +{ +public: + /// Type of the map from keys to values. + typedef std::map<std::string, CxxUtils::Arrayrep> Maptype; + + /// Default constructor. + ToolConstants(); + + + /** + * @brief Make a new entry. + * @param context The context name, for error reporting. + * @param key The key of the new entry. + * @param val The value of the new entry, as a string. + * + * Converts @a val to an @c Arrayrep and stores it. + * Raises an exception if the key already exists or if there's + * a conversion error. + */ + const CxxUtils::Arrayrep& newrep (const std::string& context, + const std::string& key, + const std::string& val); + + /** + * @brief Look up an entry. + * @param context The context name, for error reporting. + * @param key The key of the new entry. + * + * Looks up @a key and returns its @c Arrayrep. + * Raises an exception if @a key isn't found. + */ + const CxxUtils::Arrayrep& getrep (const std::string& context, + const std::string& key) const; + + + /** + * @brief Set an entry. + * @param key The key of the entry to set. + * @param rep The value of the new entry. + */ + void setrep (const std::string& key, + const CxxUtils::Arrayrep& rep); + + + /** + * @brief Test to see if a given key is present. + */ + bool hasrep (const std::string& key) const; + + /** + * @brief Writes out constants in a python-like format + * @param stream Stream to which to write (file or cout) + * @param name Name of the Maker-Algorithm (used only for output) + */ + void writeConstants(std::ostream& stream, const std::string& name) const; + + + /** + * @brief Return the name of the C++ class that operates on these constants. + */ + const std::string& clsname() const; + + + /** + * @brief Set the name of the C++ class that operates on these constants. + */ + void clsname (const std::string& name); + + + /** + * @brief Return the version of the C++ class that operates + * on these constants. + */ + int version() const; + + + /** + * @brief Set the version of the C++ class that operates on these constants. + */ + void version (int version); + + + /// Return the key -> value map. + const Maptype& map() const; + + +private: + /** + * @brief Report an error. + * @param context Context string for the error. + * @param key Key involved in the error. + * @param msg Error message. + */ + static void error (const std::string& context, + const std::string& key, + const std::string& msg); + + /// The map of keys to values. + Maptype m_map; + + /// Name of the C++ class that operates on these constants. + std::string m_clsname; + + /// Version number of the C++ class that operates on these constants. + int m_version; +}; + + +} // namespace CaloRec + + +CLASS_DEF(CaloRec::ToolConstants,250904980 ,1) +#endif // not CALOREC_TOOLCONSTANTS_H diff --git a/Calorimeter/CaloConditions/CaloConditions/selection.xml b/Calorimeter/CaloConditions/CaloConditions/selection.xml new file mode 100755 index 0000000000000000000000000000000000000000..a8f2d50a8da5b4c2ebb28eef677a45ace511ab13 --- /dev/null +++ b/Calorimeter/CaloConditions/CaloConditions/selection.xml @@ -0,0 +1,34 @@ +<lcgdict> + + <class name="CaloRec::ToolConstants" id="5A73ABF8-5095-405B-A296-3435BB52A5FD" /> + <class name="CaloRec::Arrayrep" /> + <class name="std::map<std::string, CaloRec::Arrayrep>" /> + + + <class name="CaloRec::CaloCellFactor" id="F2906C3B-DB35-4026-8AA4-D57E4B41288D" /> + + <class name="CaloRec::CaloCellPositionShift" id="3B3CCC72-7238-468E-B25E-6F85BA5C9D64" /> + + <class name="CaloHadWeight" id="5E5F2C06-92C6-45F2-845C-382C41B55371" /> + <class name="CaloHadWeight::HadData" /> + <class name="std::vector<CaloHadWeight::HadData>" /> + + <class name="CaloEMFrac" id="AC5F494A-E4A3-DB11-9C2D-000E0C4D352F" /> + <class name="CaloEMFrac::EMFracData" /> + <class name="std::vector<CaloEMFrac::EMFracData>" /> + + <class name="CaloHadDMCoeff" id="4380AD7F-25C1-4F1B-A904-314022EED7C6" /> + <class name="CaloHadDMCoeff::HadDMArea" /> + <class name="std::vector<CaloHadDMCoeff::HadDMArea>" /> + + <class name="CaloHadDMCoeff2" id="96D130ED-3098-DC11-8AC1-001641AD5E73" /> + <class name="CaloHadDMCoeff2::HadDMDimension" /> + <class name="CaloHadDMCoeff2::HadDMArea" /> + <class name="std::vector<CaloHadDMCoeff2::HadDMArea>" /> + + <class name="CaloLocalHadCoeff" id="2CCE709B-6B70-4172-B30C-FA999BD0091D" /> + <class name="CaloLocalHadCoeff::LocalHadDimension" /> + <class name="CaloLocalHadCoeff::LocalHadArea" /> + <class name="std::vector<CaloLocalHadCoeff::LocalHadArea>" /> + <class name="std::vector<CaloLocalHadCoeff::LocalHadDimension >" /> +</lcgdict> diff --git a/Calorimeter/CaloConditions/cmt/requirements b/Calorimeter/CaloConditions/cmt/requirements new file mode 100755 index 0000000000000000000000000000000000000000..6f7777bfc32407afdd926e48feff28f18a8e99d7 --- /dev/null +++ b/Calorimeter/CaloConditions/cmt/requirements @@ -0,0 +1,32 @@ +package CaloConditions + +author Walter Lampl <walter.lampl@cern.ch> + +use AtlasPolicy AtlasPolicy-* +use GaudiInterface GaudiInterface-* External +use CLIDSvc CLIDSvc-* Control +use CxxUtils CxxUtils-* Control +use Identifier Identifier-* DetectorDescription + + +private +use AtlasBoost AtlasBoost-* External +end_private + + +library CaloConditions *.cxx +apply_pattern installed_library + +apply_pattern declare_joboptions files="*.py" + +private +use AtlasReflex AtlasReflex-* External -no_auto_imports +use TestPolicy TestPolicy-* + +apply_pattern lcgdict dict=CaloConditions selectionfile=selection.xml headerfiles="../CaloConditions/CaloConditionsDict.h" +end_private + + +private +use TestTools TestTools-* AtlasTest +apply_pattern UnitTest_run unit_test=ToolConstants diff --git a/Calorimeter/CaloConditions/share/CaloConditions_jobOptions.py b/Calorimeter/CaloConditions/share/CaloConditions_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..fd180da7c3dc950d5cb878031cb8d371ce6ebde0 --- /dev/null +++ b/Calorimeter/CaloConditions/share/CaloConditions_jobOptions.py @@ -0,0 +1,24 @@ +include.block ( "CaloConditions/CaloConditions_jobOptions.py" ) + +############################################################################ +# +# Job options file for initializing CaloTriggerTowerService's +# (from CaloTriggerTool package) maps: +# TT-cell map, online-offline TT ids + some auxiliary maps . +# +# To be included in Comissioning and MD jobs; CTB jobs not supported in all versions. +# +# Created 2007-APR-06 by F. Ledroit +#========================================================================== + +from AthenaCommon.JobProperties import jobproperties +DGeo = jobproperties.Global.DetGeo() + +# LArTTCellMap (maintained by F. Ledroit) + +if (DGeo == "ctbh8"): + print " No trigger mapping needed for CTB simulation" +else: + include( "CaloConditions/LArTTCellMap_ATLAS_jobOptions.py") + # TT online-offline & online-attributes maps (maintained by D. Prieur) + include( "CaloConditions/CaloTTIdMap_ATLAS_jobOptions.py") diff --git a/Calorimeter/CaloConditions/share/CaloTTIdMap_ATLAS_jobOptions.py b/Calorimeter/CaloConditions/share/CaloTTIdMap_ATLAS_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..d837d055b3784cca1b5464571c30c997276763cf --- /dev/null +++ b/Calorimeter/CaloConditions/share/CaloTTIdMap_ATLAS_jobOptions.py @@ -0,0 +1,34 @@ +include.block ( "CaloConditions/CaloTTIdMap_ATLAS_jobOptions.py" ) + +################################################################### +# +# Job options file for initializing CaloTriggerTowerService's +# This jo is called by CaloConditions_jobOptions.py which is the +# main jo to be used to initialize the CaloTriggerTowerService +# +# Created 2007-APR-25 by D. Prieur +#================================================================== + +#------------------------------------------------------------------ +# Add the TTOnOffIdMap & TTOnAttrIdMap Maps COOL folders to IOVDbSvc +#------------------------------------------------------------------du + +from IOVDbSvc.CondDB import conddb +from AthenaCommon.GlobalFlags import globalflags +if globalflags.DataSource()=='data': + CaloDB = "CALO" + FolderPrefix="/CALO/" +else: + CaloDB = "CALO_OFL" + FolderPrefix="/CALO/Ofl/" + +# add the DB folders to be opened +TTIdMapFolderNameList = [ FolderPrefix+"Identifier/CaloTTOnOffIdMapAtlas" ] +TTIdMapFolderNameList += [ FolderPrefix+"Identifier/CaloTTOnAttrIdMapAtlas" ] +TTIdMapFolderNameList += [ FolderPrefix+"Identifier/CaloTTPpmRxIdMapAtlas" ] + + +#------------------------------------------------------------------ + +for FolderName in TTIdMapFolderNameList: + conddb.addFolder(CaloDB,FolderName) diff --git a/Calorimeter/CaloConditions/share/LArTTCellMap_ATLAS_jobOptions.py b/Calorimeter/CaloConditions/share/LArTTCellMap_ATLAS_jobOptions.py new file mode 100755 index 0000000000000000000000000000000000000000..c0bea566d845d211391d989395769a9c8ac9c15b --- /dev/null +++ b/Calorimeter/CaloConditions/share/LArTTCellMap_ATLAS_jobOptions.py @@ -0,0 +1,37 @@ +include.block ( "CaloConditions/LArTTCellMap_ATLAS_jobOptions.py" ) + +################################################################### +# +# Job options file for setting up TT-Cell Map in POOL/COOL +# +#================================================================== + +from PoolSvc.PoolSvcConf import PoolSvc +ServiceMgr += PoolSvc() +if not "prfile:poolcond/PoolCat_oflcond.xml" in ServiceMgr.PoolSvc.ReadCatalog : + ServiceMgr.PoolSvc.ReadCatalog+= [ "prfile:poolcond/PoolCat_oflcond.xml" ] + +from AthenaCommon.Logging import logging +logger = logging.getLogger( 'LArTTCellMap_ATLAS_jobOptions.py' ) + +if "LArDBConnection" not in dir() : + LArDBConnection= "" + +from AthenaCommon.GlobalFlags import globalflags +if globalflags.DataSource()=='data': + LArDB = "LAR" +else: + LArDB = "LAR_OFL" + +if LArDBConnection!="" : + LArDB="" + +from IOVDbSvc.CondDB import conddb +conddb.addFolder(LArDB,"/LAR/Identifier/LArTTCellMapAtlas"+LArDBConnection ) + +# read correct mapping for old geometries where information cannot be found from global tag +DetDescr = globalflags.DetDescrVersion() +if DetDescr.startswith("ATLAS-CSC-01") or DetDescr.startswith("ATLAS-DC"): + conddb.addOverride("/LAR/Identifier/LArTTCellMapAtlas","LARIdentifierLArTTCellMapAtlas-DC3-02") + + diff --git a/Calorimeter/CaloConditions/share/LArTTCellMap_H8_jobOptions.py b/Calorimeter/CaloConditions/share/LArTTCellMap_H8_jobOptions.py new file mode 100644 index 0000000000000000000000000000000000000000..c7e41b976a9a4a7a3ebaf86179c88b5d818cc3ff --- /dev/null +++ b/Calorimeter/CaloConditions/share/LArTTCellMap_H8_jobOptions.py @@ -0,0 +1,21 @@ +include.block ( "CaloConditions/LArTTCellMap_H8_jobOptions.py" ) + +################################################################### +# +# Job options file for setting up TT-Cell Map in H8 +# +#================================================================== + +from PoolSvc.PoolSvcConf import PoolSvc +ServiceMgr += PoolSvc() +if not ( hasattr(PoolSvc.ReadCatalog,'__len__') and "prfile:poolcond/PoolCat_tbcond.xml" in PoolSvc.ReadCatalog ): + ServiceMgr.PoolSvc.ReadCatalog+= [ "prfile:poolcond/PoolCat_tbcond.xml" ] + +if not hasattr(ServiceMgr, "CondProxyProvider"): + from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import CondProxyProvider + ServiceMgr += CondProxyProvider() + +# LArTTCellMap +ServiceMgr.CondProxyProvider.InputCollections +=["LFN:tbcond.000002.conditions.recon.pool.v0000._0004.pool.root"] + + diff --git a/Calorimeter/CaloConditions/share/ToolConstants_test.ref b/Calorimeter/CaloConditions/share/ToolConstants_test.ref new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Calorimeter/CaloConditions/src/CaloAffectedRegionInfo.cxx b/Calorimeter/CaloConditions/src/CaloAffectedRegionInfo.cxx new file mode 100644 index 0000000000000000000000000000000000000000..60da3dda57d952fc72e5a682f0a8f5b446541424 --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloAffectedRegionInfo.cxx @@ -0,0 +1,76 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CaloConditions/CaloAffectedRegionInfo.h" + +#include <iostream> + +CaloAffectedRegionInfo::CaloAffectedRegionInfo(void) +{ + m_eta_min=m_eta_max=m_phi_min=m_phi_max=m_rate=0.; + m_layer_min=m_layer_max=0; + m_problem = CaloAffectedRegionInfo::Unknown; +} + +CaloAffectedRegionInfo::CaloAffectedRegionInfo(float parameter_eta_min,float parameter_eta_max,float parameter_phi_min,float parameter_phi_max,int parameter_layer_min,int parameter_layer_max,type_problem current_problem, float parameter_rate) +{ + m_eta_min=parameter_eta_min; + m_eta_max=parameter_eta_max; + m_phi_min=parameter_phi_min; + m_phi_max=parameter_phi_max; + m_layer_min=parameter_layer_min; + m_layer_max=parameter_layer_max; + m_problem=current_problem; + m_rate = parameter_rate; +} + +float CaloAffectedRegionInfo::get_eta_min() const { + return m_eta_min; +} + +float CaloAffectedRegionInfo::get_eta_max() const { + return m_eta_max; +} + +float CaloAffectedRegionInfo::get_phi_min() const { + return m_phi_min; +} + +float CaloAffectedRegionInfo::get_phi_max() const { + return m_phi_max; +} + +int CaloAffectedRegionInfo::get_problem() const { + return m_problem; +} + +int CaloAffectedRegionInfo::get_layer_min() const { + return m_layer_min; +} + +int CaloAffectedRegionInfo::get_layer_max() const { + return m_layer_max; +} + +float CaloAffectedRegionInfo::get_rate() const{ + return m_rate; +} + +void CaloAffectedRegionInfo::FillCaloAffectedRegionInfo(float parameter_eta_min,float parameter_eta_max,float parameter_phi_min,float parameter_phi_max,int parameter_layer_min,int parameter_layer_max,type_problem current_problem, float parameter_rate) +{ + m_eta_min=parameter_eta_min; + m_eta_max=parameter_eta_max; + m_phi_min=parameter_phi_min; + m_phi_max=parameter_phi_max; + m_layer_min=parameter_layer_min; + m_layer_max=parameter_layer_max; + m_problem=current_problem; + m_rate = parameter_rate; +} + +void CaloAffectedRegionInfo::PrintInfo(void) const +{ + std::cout << "eta range : [" << m_eta_min << " ; " << m_eta_max << " ], phi range : [" << m_phi_min << " ; " << m_phi_max << " ], layer range : [" << m_layer_min << " ; " << m_layer_max << " ]" <<", problem=" << m_problem << ", rate " << m_rate << std::endl; +} + diff --git a/Calorimeter/CaloConditions/src/CaloCellFactor.cxx b/Calorimeter/CaloConditions/src/CaloCellFactor.cxx new file mode 100755 index 0000000000000000000000000000000000000000..8fb4dfdb1d58a263fcaa78bcf18d6e88655dbb56 --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloCellFactor.cxx @@ -0,0 +1,17 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CaloConditions/CaloCellFactor.h" + +namespace CaloRec { + +CaloCellFactor::CaloCellFactor(const size_type& size) : m_cellFactor(size,1.0) +{} + +void CaloCellFactor::resize(const size_type& size) { + m_cellFactor.resize(size,1.0); + return; +} + +}//end namespace diff --git a/Calorimeter/CaloConditions/src/CaloCellPositionShift.cxx b/Calorimeter/CaloConditions/src/CaloCellPositionShift.cxx new file mode 100755 index 0000000000000000000000000000000000000000..aef01b544322a5287d8bdb272c63bba3a287e257 --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloCellPositionShift.cxx @@ -0,0 +1,19 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CaloConditions/CaloCellPositionShift.h" + +namespace CaloRec { + +CaloCellPositionShift::CaloCellPositionShift(const size_type& size) : m_deltaX(size,0.),m_deltaY(size,0.),m_deltaZ(size,0.) +{} + +void CaloCellPositionShift::resize(const size_type& size) { + m_deltaX.resize(size,0.0); + m_deltaY.resize(size,0.0); + m_deltaZ.resize(size,0.0); + return; +} + +}//end namespace diff --git a/Calorimeter/CaloConditions/src/CaloEMFrac.cxx b/Calorimeter/CaloConditions/src/CaloEMFrac.cxx new file mode 100755 index 0000000000000000000000000000000000000000..18e723f08a58b7805f33a9c04ab598527fb137c6 --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloEMFrac.cxx @@ -0,0 +1,166 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: CaloEMFrac.cxx,v 1.2 2007-10-26 01:47:23 ssnyder Exp $ +/** + * @file CaloConditions/src/CaloEMFrac.cxx + * @brief Hold binned EM fraction data. + */ + + +#include "CaloConditions/CaloEMFrac.h" + + +/** + * @brief Constructor. + * @param nBinEta Number of bins in eta. + * @param MinEta Minimum eta for the first bin. + * @param MaxEta Maximum eta for the last bin. + * @param nBinLogEClus Number of bins in log10(cluster energy). + * @param MinLogEClus Minimum log10(cluster energy) for the first bin. + * @param MaxLogEClus Maximum log10(cluster energy) for the last bin. + * @param nBinLogEDens Number of bins in log10(cluster energy density). + * @param MinLogEDens Minimum log10(cluster energy density) for the first bin. + * @param MaxLogEDens Maximum log10(cluster energy density) for the last bin. + * @param nBinLogDepth Number of bins in log10(cluster depth). + * @param MinLogDepth Minimum log10(cluster depth) for the first bin. + * @param MaxLogDepth Maximum log10(cluster depth) for the last bin. + */ +CaloEMFrac::CaloEMFrac( + int nBinEta, + float MinEta, + float MaxEta, + int nBinLogEClus, + float MinLogEClus, + float MaxLogEClus, + int nBinLogEDens, + float MinLogEDens, + float MaxLogEDens, + int nBinLogDepth, + float MinLogDepth, + float MaxLogDepth + ) : m_nBinEta (nBinEta), + m_nBinLogEClus (nBinLogEClus), + m_nBinLogEDens (nBinLogEDens), + m_nBinLogDepth (nBinLogDepth), + m_MinEta (MinEta), + m_MinLogEClus (MinLogEClus), + m_MinLogEDens (MinLogEDens), + m_MinLogDepth (MinLogDepth), + m_MaxEta (MaxEta), + m_MaxLogEClus (MaxLogEClus), + m_MaxLogEDens (MaxLogEDens), + m_MaxLogDepth (MaxLogDepth) +{ +} + + +/** + * @brief Return EM fraction data for one bin. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @param logEDens log10(cluster energy density) (possibly normalized) + * @param logDepth log10(cluster depth) + * @returns Pointer to the bin data, or 0 if out of range. + * + * The pointer may be invalidated by a subsequent setEMFracData call. + */ +const struct CaloEMFrac::EMFracData * +CaloEMFrac::getEMFracData(float eta, + float logEClus, + float logEDens, + float logDepth) const +{ + int iBin = getBin(eta,logEClus,logEDens,logDepth); + if ( iBin > -1 && iBin < (int)m_data.size() ) + return (& m_data[iBin]); + else + return 0; +} + + + +/** + * @brief Set EM fraction data for one bin. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @param logEDens log10(cluster energy density) (possibly normalized) + * @param logDepth log10(cluster depth) + * @param theData The bin data. + * + * This will overwrite any earlier data for the same bin. + * If the coordinates are out of range, this is a no-op. + */ +void CaloEMFrac::setEMFracData(float eta, + float logEClus, + float logEDens, + float logDepth, + const struct EMFracData & theData) +{ + const int iEtaLogEClus = getEtaLogEClusBin(eta, logEClus); + if ( iEtaLogEClus > -1 ) { + const int iFilledEntries = m_data.size()/(m_nBinLogEDens*m_nBinLogDepth); + if ( iEtaLogEClus >= iFilledEntries ) + m_data.resize((iFilledEntries+1)*(m_nBinLogEDens*m_nBinLogDepth)); + const int iBin = getBin(eta,logEClus,logEDens,logDepth); + if ( iBin > -1 ) { + m_data[iBin] = theData; + } + } +} + + +/** + * @brief Find the eta/logEClus bin number. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @returns Bin number in the eta/logEClus subspace, or -1 if out of range. + */ +int CaloEMFrac::getEtaLogEClusBin(float eta, float logEClus) const +{ + int iEta,iLogEClus; + + iEta = (int)((eta-m_MinEta)/(m_MaxEta-m_MinEta)*m_nBinEta); + if ( iEta >= 0 && iEta < m_nBinEta ) { + iLogEClus = (int)((logEClus-m_MinLogEClus)/(m_MaxLogEClus-m_MinLogEClus)*m_nBinLogEClus); + if ( iLogEClus >= 0 && iLogEClus < m_nBinLogEClus ) { + return (iEta*m_nBinLogEClus+iLogEClus); + } + } + return (-1); + +} + + +/** + * @brief Find a bin number. + * @param eta Cluster eta. + * @param logEClus log10(cluster energy) + * @param logEDens log10(cluster energy density) (possibly normalized) + * @param logDepth log10(cluster depth) + * @returns The bin number, or -1 if out of range. + */ +int CaloEMFrac::getBin(float eta, + float logEClus, + float logEDens, + float logDepth) const +{ + int iLogEDens,iLogDepth; + + const int iEtaLogEClus = getEtaLogEClusBin(eta, logEClus); + if ( iEtaLogEClus > -1 ) { + iLogEDens = (int)((logEDens-m_MinLogEDens)/(m_MaxLogEDens-m_MinLogEDens)*m_nBinLogEDens); + if ( iLogEDens >= 0 && iLogEDens < m_nBinLogEDens ) { + iLogDepth = (int)((logDepth-m_MinLogDepth)/(m_MaxLogDepth-m_MinLogDepth)*m_nBinLogDepth); + if ( iLogDepth >= 0 && iLogDepth < m_nBinLogDepth ) { + return (iLogDepth + m_nBinLogDepth * + (iLogEDens + m_nBinLogEDens * + iEtaLogEClus)); + } + } + } + return -1; +} + + diff --git a/Calorimeter/CaloConditions/src/CaloHadDMCoeff.cxx b/Calorimeter/CaloConditions/src/CaloHadDMCoeff.cxx new file mode 100755 index 0000000000000000000000000000000000000000..75f819133dded95f2263290fe58a10916ecbe5a1 --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloHadDMCoeff.cxx @@ -0,0 +1,194 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CaloConditions/CaloHadDMCoeff.h" + + +CaloHadDMCoeff::CaloHadDMCoeff() +{ + +} + + +CaloHadDMCoeff::CaloHadDMCoeff(const CaloHadDMCoeff &other) + : m_DMCoeffSet (other.m_DMCoeffSet), + m_DMAreaSet (other.m_DMAreaSet) +{ +} + + +CaloHadDMCoeff& CaloHadDMCoeff::operator= (const CaloHadDMCoeff& other) +{ + if (this != &other) { + m_DMCoeffSet = other.m_DMCoeffSet; + m_DMAreaSet = other.m_DMAreaSet; + } + return *this; +} + + +const CaloHadDMCoeff::HadDMCoeff * CaloHadDMCoeff::getHadDMCoeff(const int & n_area, const float & cls_emfrac, const float & cls_ener, const float & cls_eta) const +{ + int iBin = getBin(n_area, cls_emfrac, cls_ener, cls_eta); + return getHadDMCoeff(iBin); +} + + +const CaloHadDMCoeff::HadDMArea * CaloHadDMCoeff::getHadDMArea(int n_area) const +{ + if(n_area >= 0 && n_area<(int)m_DMAreaSet.size() ) { + return &(m_DMAreaSet[n_area]); + } else { + return 0; + } +} + + +void CaloHadDMCoeff::addHadDMCoeff(const HadDMCoeff & theData) +{ + m_DMCoeffSet.push_back(theData); +} + + +void CaloHadDMCoeff::setHadDMCoeff(const int iBin, const HadDMCoeff & theData) +{ + m_DMCoeffSet[iBin] = theData; +} + + +void CaloHadDMCoeff::addHadDMArea(const HadDMArea & theArea) +{ + m_DMAreaSet.push_back(theArea); +} + + +void CaloHadDMCoeff::setHadDMArea(const int n_area, const HadDMArea & theArea) +{ + m_DMAreaSet[n_area] = theArea; +} + + +/* ***************************************************************************** +get EM fraction bin +***************************************************************************** */ +int CaloHadDMCoeff::getBinFrac(const int n_area, const float & cls_emfrac) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_area]; + if(cls_emfrac < dmArea->m_MinFrac || cls_emfrac >= dmArea->m_MaxFrac) return -1; + int ifrac; + int nfrac = dmArea->m_FracBins.size(); + for (ifrac=0; ifrac<nfrac; ifrac++) { + if( cls_emfrac < dmArea->m_FracBins[ifrac] ) break; + if( cls_emfrac >= dmArea->m_FracBins[ifrac] && (ifrac == nfrac-1 || cls_emfrac < dmArea->m_FracBins[ifrac+1]) ) break; + } + return ifrac; +} + + +/* ***************************************************************************** +To get energy bin +***************************************************************************** */ +int CaloHadDMCoeff::getBinEner(const int n_area, const float & cls_ener) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_area]; + if(cls_ener < dmArea->m_MinEner || cls_ener >= dmArea->m_MaxEner) return (-1); + int iener; + int nener = (int)dmArea->m_EnerBins.size(); + for (iener=0; iener<nener; iener++) { + if( cls_ener < dmArea->m_EnerBins[iener] ) break; + if( cls_ener >= dmArea->m_EnerBins[iener] && (iener == nener-1 || cls_ener < dmArea->m_EnerBins[iener+1]) ) break; + } + return iener; +} + + +/* ***************************************************************************** +get eta bin +***************************************************************************** */ +int CaloHadDMCoeff::getBinEta(const int n_area, const float & cls_eta) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_area]; + if(cls_eta < dmArea->m_MinEta || cls_eta >= dmArea->m_MaxEta) return (-1); + int neta = (int)dmArea->m_EtaBins.size(); + int ieta = (int)((cls_eta - dmArea->m_MinEta)/(dmArea->m_MaxEta - dmArea->m_MinEta)*neta); + return ieta; +} + + +/* ***************************************************************************** +get common bin +***************************************************************************** */ +int CaloHadDMCoeff::getBin(const int & n_dm_area, const float & cls_emfrac, const float & cls_ener, const float & cls_eta) const +{ + if(n_dm_area < 0 || n_dm_area >= (int)m_DMAreaSet.size()) { + std::cout << " WARNING CaloHadDMCoeff::getBin -> wrong n_area: " << n_dm_area << std::endl; + return (-1); + } + int ifrac = getBinFrac(n_dm_area, cls_emfrac); + int iener = getBinEner(n_dm_area, cls_ener); + int ieta = getBinEta(n_dm_area, cls_eta); + int iBin = getBin(n_dm_area, ifrac, iener, ieta); + return iBin; +} + + +int CaloHadDMCoeff::getBin(const int & n_dm_area, const int & ifrac, const int & iener, const int & ieta) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_dm_area]; + int iBin = -1; + if(ifrac!=-1 && iener !=-1 && ieta!=-1) { + iBin = ieta + iener*(int)dmArea->m_EtaBins.size() + ifrac*(int)dmArea->m_EnerBins.size()*(int)dmArea->m_EtaBins.size() + dmArea->m_offset; + } + return iBin; +} + + +void CaloHadDMCoeff::PrintData(FILE *fout) const +{ + + const char *comments={ + "# Coeffs for Dead Material corrections in CaloClusterLocalCalib algorithm.\n" + "# Author: Guennadi Pospelov <pospelov@mppmu.mpg.de>\n" + "#\n" + "#\n" + "# dm_id is_ON dm_title\n" + "# nFrac FracMin FracMax\n" + "# nEner EnerMin EnerMax\n" + "# nEta EtaMin EtaMax\n" + "# Npars\n" + "# indx ifrac iener ieta frac ener eta pars[]\n" + "#\n\n"}; + fprintf(fout,"%s",comments); + int m_indx = 0; + for(int i_zone=0; i_zone < (int)m_DMAreaSet.size(); i_zone++){ + const HadDMArea *area = &m_DMAreaSet[i_zone]; + fprintf(fout," %d %d %s\n",area->m_indx, area->m_is_on, area->m_title.data()); + fprintf(fout,"%2d %6.3f %6.3f\n", (int)area->m_FracBins.size(), area->m_MinFrac, area->m_MaxFrac); + fprintf(fout,"%2d %6.3g %6.3g\n", (int)area->m_EnerBins.size(), area->m_MinEner, area->m_MaxEner); + fprintf(fout,"%2d %6.3f %6.3f\n", (int)area->m_EtaBins.size(), area->m_MinEta, area->m_MaxEta); + fprintf(fout,"%2d\n", area->m_nPars); + for(int i_frac=0; i_frac<(int)area->m_FracBins.size(); i_frac++){ + for(int i_ener=0; i_ener<(int)area->m_EnerBins.size(); i_ener++){ + for(int i_eta=0; i_eta<(int)area->m_EtaBins.size(); i_eta++){ + float cls_emfrac = area->m_FracBins[i_frac]; + float cls_ener = area->m_EnerBins[i_ener]; + float cls_eta = area->m_EtaBins[i_eta]+0.01; + const HadDMCoeff *vv = getHadDMCoeff(i_zone, cls_emfrac, cls_ener, cls_eta); + fprintf(fout,"%4d %2d %2d %2d %6.3f %6.3g %6.3f ", + m_indx, i_frac,i_ener, i_eta, area->m_FracBins[i_frac], area->m_EnerBins[i_ener], area->m_EtaBins[i_eta]); + for(int i_par=0; i_par<area->m_nPars; i_par++){ + if(area->m_indx!=10) { + fprintf(fout,"%10.4f ",(*vv)[i_par]); + } else{ + fprintf(fout,"%10.7f ",(*vv)[i_par]); + } + } // i_par + m_indx++; + fprintf(fout,"\n"); + } // i_eta + } // i_ener + } // i_frac + fprintf(fout,"\n"); + } +} diff --git a/Calorimeter/CaloConditions/src/CaloHadDMCoeff2.cxx b/Calorimeter/CaloConditions/src/CaloHadDMCoeff2.cxx new file mode 100755 index 0000000000000000000000000000000000000000..1e177c9179cd6b2200b23219bdff8ca1a7c39f55 --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloHadDMCoeff2.cxx @@ -0,0 +1,264 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CaloConditions/CaloHadDMCoeff2.h" + +#include "boost/io/ios_state.hpp" + +#include <sstream> +#include <iomanip> +#include <math.h> + +/* *************************************************************************** +c-tor +*************************************************************************** */ +CaloHadDMCoeff2::CaloHadDMCoeff2() +{ + +} + + +CaloHadDMCoeff2::CaloHadDMCoeff2(const CaloHadDMCoeff2 &other) + : m_DMCoeffSet (other.m_DMCoeffSet), + m_DMAreaSet (other.m_DMAreaSet), + m_area_offsets (other.m_area_offsets) +{ +} + + +CaloHadDMCoeff2& CaloHadDMCoeff2::operator= (const CaloHadDMCoeff2& other) +{ + if (this != &other) { + m_DMCoeffSet = other.m_DMCoeffSet; + m_DMAreaSet = other.m_DMAreaSet; + m_area_offsets = other.m_area_offsets; + } + return *this; +} + + +/* *************************************************************************** +methods to deal with DM areas +*************************************************************************** */ +void CaloHadDMCoeff2::addHadDMArea(const HadDMArea & theArea) +{ + m_DMAreaSet.push_back(theArea); + m_area_offsets.push_back(theArea.m_offset); +} + +void CaloHadDMCoeff2::setHadDMArea(const int n_area, const HadDMArea & theArea) +{ + m_DMAreaSet[n_area] = theArea; +} + +const CaloHadDMCoeff2::HadDMArea * CaloHadDMCoeff2::getHadDMArea(int n_area) const +{ + if(n_area >= 0 && n_area<(int)m_DMAreaSet.size() ) { + return &(m_DMAreaSet[n_area]); + } else { + return 0; + } +} + + +/* *************************************************************************** +methods to deal with DM coefficients +*************************************************************************** */ +void CaloHadDMCoeff2::addHadDMCoeff(const HadDMCoeff & theData) +{ + m_DMCoeffSet.push_back(theData); +} + +void CaloHadDMCoeff2::setHadDMCoeff(const int iBin, const HadDMCoeff & theData) +{ + m_DMCoeffSet[iBin] = theData; +} + +const CaloHadDMCoeff2::HadDMCoeff * CaloHadDMCoeff2::getHadDMCoeff(const int & iBin) const +{ + if ( iBin > -1 && iBin < (int)m_DMCoeffSet.size() ) { + return (& m_DMCoeffSet[iBin]); + }else{ + return 0; + } +} + + +/* *************************************************************************** +methods to get DM coefficients bin number +*************************************************************************** */ + +// get EM fraction bin number +int CaloHadDMCoeff2::getBinFrac(const int n_area, const float & cls_emfrac) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_area]; + if(cls_emfrac < dmArea->m_dimFrac.m_vMin || cls_emfrac >= dmArea->m_dimFrac.m_vMax) return (-1); + return (int)((cls_emfrac - dmArea->m_dimFrac.m_vMin)/dmArea->m_dimFrac.m_bin_size); +} + +// get energy bin number +int CaloHadDMCoeff2::getBinEner(const int n_area, const float & cls_ener) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_area]; + if( cls_ener < dmArea->m_dimEner.m_vMin || cls_ener >= dmArea->m_dimEner.m_vMax ) return (-1); + int iener; + for (iener=0; iener<dmArea->m_dimEner.m_nbins; iener++) { + if( cls_ener < dmArea->m_dimEner.m_vBins[iener] ) break; + if( cls_ener >= dmArea->m_dimEner.m_vBins[iener] && (iener == dmArea->m_dimEner.m_nbins-1 || cls_ener < dmArea->m_dimEner.m_vBins[iener+1]) ) break; + } + return iener; +} + +// get lambda bin number +int CaloHadDMCoeff2::getBinLambda(const int n_area, const float & cls_lambda) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_area]; + if(cls_lambda < dmArea->m_dimLambda.m_vMin || cls_lambda >= dmArea->m_dimLambda.m_vMax) return (-1); + return (int)((cls_lambda - dmArea->m_dimLambda.m_vMin)/dmArea->m_dimLambda.m_bin_size); +} + +// get eta bin number +int CaloHadDMCoeff2::getBinEta(const int n_area, const float & cls_eta) const +{ + const HadDMArea *dmArea = &m_DMAreaSet[n_area]; + float cls_abseta = fabs(cls_eta); + if(cls_abseta < dmArea->m_dimEta.m_vMin || cls_abseta >= dmArea->m_dimEta.m_vMax) return (-1); + return (int)((cls_abseta - dmArea->m_dimEta.m_vMin)/dmArea->m_dimEta.m_bin_size); +} + +// get general bin number +int CaloHadDMCoeff2::getBin(const int n_dm_area, const float &cls_emfrac, const float &cls_ener, const float &cls_lambda, const float &cls_eta) const +{ + if(n_dm_area < 0 || n_dm_area >= (int)m_DMAreaSet.size()) { + std::cout << " WARNING CaloHadDMCoeff::getBin -> wrong n_area: " << n_dm_area << std::endl; + return (-1); + } + int iBin = -1; + const HadDMArea *dmArea = &m_DMAreaSet[n_dm_area]; + int ifrac = -1, iener = -1, ilambda = -1, ieta = -1; + ifrac = getBinFrac(n_dm_area, cls_emfrac); + if( ifrac != -1 ) { + iener = getBinEner(n_dm_area, cls_ener); + if( iener != -1 ) { + ilambda = getBinLambda(n_dm_area, cls_lambda); + if( ilambda != -1 ) { + ieta = getBinEta(n_dm_area, cls_eta); + if ( ieta != -1 ) { + iBin = ieta + ilambda*dmArea->m_dimEta.m_nbins + + iener*dmArea->m_dimEta.m_nbins*dmArea->m_dimLambda.m_nbins + + ifrac*dmArea->m_dimEta.m_nbins*dmArea->m_dimLambda.m_nbins*dmArea->m_dimEner.m_nbins + + dmArea->m_offset; + } // ieta + }// ilambda + } // iener + } // ifrac + return iBin; +} + + +const CaloHadDMCoeff2::HadDMCoeff * CaloHadDMCoeff2::getHadDMCoeff(const int & n_area, const float & cls_emfrac, const float & cls_ener, const float & cls_lambda, const float & cls_eta) const +{ + int iBin = getBin(n_area, cls_emfrac, cls_ener, cls_lambda, cls_eta); + return getHadDMCoeff(iBin); +} + + + +/* *************************************************************************** + +Accessories + +*************************************************************************** */ +int CaloHadDMCoeff2::bin2indexes(const int iBin, std::vector<int> &v_dim_indx) const +{ + int i_area = 0; + int narea = (int)m_area_offsets.size(); + for(i_area=0; i_area<narea; i_area++) { + if( iBin < m_area_offsets[i_area] ) break; + if( iBin >= m_area_offsets[i_area] && (i_area == narea-1 || iBin < m_area_offsets[i_area+1]) ) break; + } + const HadDMArea *theArea = &m_DMAreaSet[i_area]; + std::vector<HadDMDimension > v_dims; + v_dims.resize(4); + v_dims[0] = theArea->m_dimFrac; + v_dims[1] = theArea->m_dimEner; + v_dims[2] = theArea->m_dimLambda; + v_dims[3] = theArea->m_dimEta; + int ndim = (int) v_dims.size(); + v_dim_indx.resize(ndim,0); + for(int i_dim=0; i_dim<ndim; i_dim++){ + int x0 = 0; + for(int j=0; j<i_dim; j++){ + x0 += v_dim_indx[j]*v_dims[j].xloc; + } + v_dim_indx[i_dim] = (iBin-theArea->m_offset-x0)/v_dims[i_dim].xloc; + } + return 0; +} + + +/* *************************************************************************** +for printing DM correction coefficients into text file +*************************************************************************** */ +void CaloHadDMCoeff2::PrintData(std::ostream &fout) const +{ + const char *comments = + { + "# Coeffs for Dead Material corrections in DeadMaterialCorrectionTool2 tool.\n\n" + }; + fout << comments << std::endl; + char line[1024]; + + // loop over DM areas + for(int i_zone=0; i_zone < (int)m_DMAreaSet.size(); i_zone++){ + const HadDMArea *area = &m_DMAreaSet[i_zone]; + fout << "zone " << area->m_indx << " " << area->m_is_on << " " << area->m_title << std::endl; + std::vector<CaloHadDMCoeff2::HadDMDimension > v_dims; + v_dims.resize(4); + v_dims[0] = area->m_dimFrac; + v_dims[1] = area->m_dimEner; + v_dims[2] = area->m_dimLambda; + v_dims[3] = area->m_dimEta; + for(unsigned int i_dim=0; i_dim<v_dims.size(); i_dim++){ + CaloHadDMCoeff2::HadDMDimension dim = v_dims[i_dim]; + sprintf(line,"%-6s %2d %6.3f %12.3f ",dim.m_title.c_str(), dim.m_nbins, dim.m_vMin, dim.m_vMax); + std::string sline(line); + if(dim.m_type == CaloHadDMCoeff2::kDIM_FLAT) { + sline += "flat"; + }else if(dim.m_type == CaloHadDMCoeff2::kDIM_HAND) { + sline += "hand"; + } else { + std::cout << "CaloHadDMCoeff2::PrintData2() -> Error! p1." << std::endl; + } + fout << sline; + if(dim.m_type == CaloHadDMCoeff2::kDIM_HAND) { + for(unsigned int i=0; i<dim.m_vBins.size(); i++){ + fout << " " << dim.m_vBins[i]; + } + } + fout << std::endl; + } + fout << "npars " << area->m_nPars << std::endl; + // now printing the data + for(int i_data=0; i_data<area->m_length; i_data++) { + int indx = area->m_offset + i_data; + const HadDMCoeff *pars = getHadDMCoeff(indx); + fout << std::setw(5) << indx << " "; + std::vector<int > v_dim_indexes; + bin2indexes(indx, v_dim_indexes); + for(unsigned int i_dim=0; i_dim<v_dim_indexes.size(); i_dim++){ + fout << std::setw(4) << v_dim_indexes[i_dim] << " "; + } + fout << " "; + for(int i_par=0; i_par<area->m_nPars; i_par++){ + boost::io::ios_base_all_saver foutsave (fout); + fout << std::fixed << std::setprecision(5) << std::setw(12) << (*pars)[i_par] << " "; + } + fout << std::endl; + } + // end of DM area + fout << std::endl; + } + // printing title strin +} diff --git a/Calorimeter/CaloConditions/src/CaloHadWeight.cxx b/Calorimeter/CaloConditions/src/CaloHadWeight.cxx new file mode 100755 index 0000000000000000000000000000000000000000..7eb73f774f0cb536da9c934b6514375c16c129ca --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloHadWeight.cxx @@ -0,0 +1,99 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CaloConditions/CaloHadWeight.h" + + +CaloHadWeight::CaloHadWeight( + const int & nBinEta, + const float & MinEta, + const float & MaxEta, + const int & nBinSampling, + const int & MinSampling, + const int & MaxSampling, + const int & nBinLogEClus, + const float & MinLogEClus, + const float & MaxLogEClus, + const int & nBinLogEDensCell, + const float & MinLogEDensCell, + const float & MaxLogEDensCell + ) : m_nBinEta (nBinEta), + m_nBinSampling (nBinSampling), + m_nBinLogEClus (nBinLogEClus), + m_nBinLogEDensCell (nBinLogEDensCell), + m_MinEta (MinEta), + m_MinSampling (MinSampling), + m_MinLogEClus (MinLogEClus), + m_MinLogEDensCell (MinLogEDensCell), + m_MaxEta (MaxEta), + m_MaxSampling (MaxSampling), + m_MaxLogEClus (MaxLogEClus), + m_MaxLogEDensCell (MaxLogEDensCell) +{ + m_indexEtaSampling.resize(m_nBinEta*m_nBinSampling,-1); +} + +const struct CaloHadWeight::HadData * CaloHadWeight::getHadData(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell) const +{ + int iBin = getBin(eta,sampling,logEClus,logEDensCell); + if ( iBin > -1 && iBin < (int)m_data.size() ) + return (& m_data[iBin]); + else + return 0; +} + + + // set methods + +void CaloHadWeight::setHadData(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell, const struct HadData & theData) { + + const int iEtaSampling = getEtaSamplingBin(eta, sampling); + if ( iEtaSampling > -1 ) { + if ( m_indexEtaSampling[iEtaSampling] == -1 ) { + const int iFilledSamplings = m_data.size()/(m_nBinLogEClus*m_nBinLogEDensCell); + m_indexEtaSampling[iEtaSampling] = iFilledSamplings; + m_data.resize((iFilledSamplings+1)*(m_nBinLogEClus*m_nBinLogEDensCell)); + } + const int iBin = getBin(eta,sampling,logEClus,logEDensCell); + if ( iBin > -1 ) { + m_data[iBin] = theData; + } + } +} + + +int CaloHadWeight::getEtaSamplingBin(const float & eta, const int & sampling) const +{ + int iEta,iSampling; + + iEta = (int)((eta-m_MinEta)/(m_MaxEta-m_MinEta)*m_nBinEta); + if ( iEta >= 0 && iEta < m_nBinEta ) { + iSampling = sampling-m_MinSampling; + if ( iSampling >= 0 && iSampling < m_nBinSampling ) { + return (iEta*m_nBinSampling+iSampling); + } + } + return (-1); +} + +int CaloHadWeight::getBin(const float & eta, const int & sampling, const float & logEClus, const float & logEDensCell) const +{ + int iLogEClus,iLogEDensCell; + + const int iEtaSampling = getEtaSamplingBin(eta, sampling); + if ( iEtaSampling > -1 && m_indexEtaSampling[iEtaSampling] > -1 ) { + iLogEClus = (int)((logEClus-m_MinLogEClus)/(m_MaxLogEClus-m_MinLogEClus)*m_nBinLogEClus); + if ( iLogEClus >= 0 && iLogEClus < m_nBinLogEClus ) { + iLogEDensCell = (int)((logEDensCell-m_MinLogEDensCell)/(m_MaxLogEDensCell-m_MinLogEDensCell)*m_nBinLogEDensCell); + if ( iLogEDensCell >= 0 && iLogEDensCell < m_nBinLogEDensCell ) { + return (iLogEDensCell + m_nBinLogEDensCell * + (iLogEClus + m_nBinLogEClus * + m_indexEtaSampling[iEtaSampling])); + } + } + } + return -1; +} + + diff --git a/Calorimeter/CaloConditions/src/CaloLocalHadCoeff.cxx b/Calorimeter/CaloConditions/src/CaloLocalHadCoeff.cxx new file mode 100644 index 0000000000000000000000000000000000000000..1911d2091c80561101851337ecbdee4d03016d10 --- /dev/null +++ b/Calorimeter/CaloConditions/src/CaloLocalHadCoeff.cxx @@ -0,0 +1,449 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + * @file CaloConditions/src/CaloLocalHadCoeff.cxx + * @brief Hold binned correction data for local hadronic calibration procedure + */ +//#include "CaloConditions/CaloLocalHadCoeff.h" +#include "CaloConditions/CaloLocalHadCoeff.h" +#include "CaloConditions/CaloLocalHadDefs.h" +#include <sstream> +#include <iomanip> +#include <math.h> +#include <iostream> + + + +/* *************************************************************************** +LocalHadDimension -> +*************************************************************************** */ + +// copy constructor +CaloLocalHadCoeff::LocalHadDimension::LocalHadDimension(const CaloLocalHadCoeff::LocalHadDimension &other) + : m_title (other.m_title), + m_type (other.m_type), + m_nbins (other.m_nbins), + m_xmin (other.m_xmin), + m_xmax (other.m_xmax), + m_dx (other.m_dx), + m_xbins (other.m_xbins) +{ +} + +CaloLocalHadCoeff::LocalHadDimension& +CaloLocalHadCoeff::LocalHadDimension::operator= (const CaloLocalHadCoeff::LocalHadDimension &other) +{ + if (this != &other) { + m_title = other.m_title; + m_type = other.m_type; + m_nbins = other.m_nbins; + m_xmin = other.m_xmin; + m_xmax = other.m_xmax; + m_dx = other.m_dx; + m_xbins = other.m_xbins; + } + return *this; +} + +// return bin number for cluster variable +int CaloLocalHadCoeff::LocalHadDimension::getBin(float &x) const +{ + if( x<m_xmin ) { + return -1; + } + if( x>=m_xmax ) { + return -100; + } + int i_bin = -1; + if( !m_xbins.size() ) { // flat binning + i_bin = (int)((x - m_xmin)/m_dx); + }else{ // user binning + for(i_bin=0; i_bin<(int)m_xbins.size(); i_bin++){ + if( x < m_xbins[i_bin] ) break; + } + } + return i_bin; +} + +// return two bins +int CaloLocalHadCoeff::LocalHadDimension::getBinAdjusted(float &x, float &xadj) const +{ + if (x < m_xmin) { + xadj=0.; + return 0; + } + +// int i_bin = (int)((x - m_xmin)/m_dx); + int i_bin = getBin(x); + + if(i_bin<-10) { + i_bin=m_nbins-1; + xadj=1.0; + } else if(i_bin<0) { + i_bin=0; + xadj=0.0; + }else{ + xadj = fmod( (x-m_xmin)/m_dx, 1); + if(xadj <= 0.5) { + if(i_bin > 0 ){ + --i_bin; + xadj += 0.5; + } else { + xadj=0.; + } + }else{ +// if(i_bin > 0){ + xadj -= 0.5; +// } + } + } + return i_bin; +} + +// return true, if this general bin is neighbour of the bin given by indexes vector +bool CaloLocalHadCoeff::isNeighbour(const int iBinx, std::vector<int> &v_indx) const { + // Sanity check + if(iBinx < 0 || iBinx >= (int) m_CoeffSet.size()) return false; + if((int)v_indx.size() != getAreaFromBin(iBinx)->getNdim()) { + std::cout<<"CaloLocalHadCoeff::LocalHadDimension::getBinAdjusted() -> Error! Wrong indexes vector size in isNeighbour: "<< v_indx.size()<<std::endl; + return false; + } + std::vector<int> xidx; + bin2indexes(iBinx, xidx); + for(unsigned int i=0; i<xidx.size(); ++i) { + if(abs(v_indx[i]-xidx[i]) == 1) return true; + } + return false; +} + + +// return true, if bin was filled with data, depending on type of area +bool CaloLocalHadCoeff::isFilled(const int bin) const +{ + if( bin<0 || bin >= (int)m_CoeffSet.size() ) { + return false; + } + switch(getAreaFromBin(bin)->getType()) { + case CaloLocalHadDefs::AREA_DMLOOKUP: case CaloLocalHadDefs::AREA_STD: { + int ient = CaloLocalHadDefs::BIN_ENTRIES; + if(m_CoeffSet[bin][ient] == 0) return false; + else return true; + } + case CaloLocalHadDefs::AREA_DMFIT:{ + if(m_CoeffSet[bin][CaloLocalHadDefs::BIN_P0] == 0 && + m_CoeffSet[bin][CaloLocalHadDefs::BIN_P1] == 0 && + m_CoeffSet[bin][CaloLocalHadDefs::BIN_P2] == 0) return false; + else return true; + } + case CaloLocalHadDefs::AREA_DMSMPW:{ + bool bf=false; + for(unsigned int i=0; i<m_CoeffSet[bin].size(); ++i) if(m_CoeffSet[bin][i] != 0) bf=true; + return bf; + } + default:{ + std::cout<<"CaloLocalHadCoeff::isFilled() -> Error! Unknown area typ: "<<getAreaFromBin(bin)->getType()<<" in isFilled !!"<<std::endl; + return false; + } + } + // should not come here, but syntax need it: + return false; +} + + + +/* *************************************************************************** +LocalHadArea -> +*************************************************************************** */ +// copy constructor +CaloLocalHadCoeff::LocalHadArea::LocalHadArea(const CaloLocalHadCoeff::LocalHadArea &other) + : m_title (other.m_title), + m_type (other.m_type), + m_npars (other.m_npars), + m_offset (other.m_offset), + m_length (other.m_length), + m_dims (other.m_dims), + m_dims_loc (other.m_dims_loc) +{ +} + +CaloLocalHadCoeff::LocalHadArea& +CaloLocalHadCoeff::LocalHadArea::operator=(const CaloLocalHadCoeff::LocalHadArea &other) +{ + if (this != &other) { + m_title = other.m_title; + m_type = other.m_type; + m_npars = other.m_npars; + m_offset = other.m_offset; + m_length = other.m_length; + m_dims = other.m_dims; + m_dims_loc = other.m_dims_loc; + } + return *this; +} + +// add new dimension to the area +void CaloLocalHadCoeff::LocalHadArea::addDimension(CaloLocalHadCoeff::LocalHadDimension &dim) +{ + m_dims.push_back(dim); + // recalculation of length of the area (product of bins numbers of each dimension) + m_length = 1; + int ndim = (int)m_dims.size(); + for(int i=0; i<ndim; i++){ + m_length = m_length*m_dims[i].getNbins(); + } + // calculation of dimension locator coefficient for fast calculation of global bin number + m_dims_loc.resize(ndim, 0); + for(int i_dim=0; i_dim<ndim; i_dim++){ + int xloc = 1; + for(int j=i_dim+1; j<ndim; j++){ + xloc = xloc*m_dims[j].getNbins(); + } + m_dims_loc[i_dim] = xloc; + } +} + + + +/* *************************************************************************** +CaloLocalHadCoeff +*************************************************************************** */ + +// default constructor +CaloLocalHadCoeff::CaloLocalHadCoeff() +{ + +} + +// copy constructor +CaloLocalHadCoeff::CaloLocalHadCoeff(const CaloLocalHadCoeff &other) + : m_title (other.m_title), + m_CoeffSet (other.m_CoeffSet), + m_AreaSet (other.m_AreaSet) +{ +} + + + +CaloLocalHadCoeff& CaloLocalHadCoeff::operator=(const CaloLocalHadCoeff &other) +{ + if (this != &other) { + m_AreaSet = other.m_AreaSet; + m_CoeffSet = other.m_CoeffSet; + m_title = other.m_title; + } + return *this; +} + + + +/* *************************************************************************** +CaloLocalHadCoeff: area's methods +*************************************************************************** */ + +// to add new area definition +void CaloLocalHadCoeff::addArea(LocalHadArea & theArea) +{ + // calculating offset for coefficients of this area using previous areas defined + int offset = 0; + for(unsigned int i_area=0; i_area<m_AreaSet.size(); i_area++){ + offset += m_AreaSet[i_area].getLength(); + } + theArea.setOffset(offset); + // adding zero coefficients + CaloLocalHadCoeff::LocalHadCoeff pars; + pars.resize(theArea.getNpars(), 0.0); + for(int i_size=0; i_size<theArea.getLength(); i_size++){ + m_CoeffSet.push_back(pars); + } + // adding area + m_AreaSet.push_back(theArea); +} + +// to set new area +void CaloLocalHadCoeff::setArea(const int n_area, const LocalHadArea & theArea) +{ + m_AreaSet[n_area] = theArea; +} + +// return area +const CaloLocalHadCoeff::LocalHadArea * CaloLocalHadCoeff::getArea(int n_area) const +{ + if(n_area >= 0 && n_area<(int)m_AreaSet.size() ) { + return &(m_AreaSet[n_area]); + } else { + return 0; + } +} + +// return area for given global bin number +const CaloLocalHadCoeff::LocalHadArea *CaloLocalHadCoeff::getAreaFromBin(int iBin) const +{ + int i_area = 0; + int narea = m_AreaSet.size(); + for(i_area=0; i_area<narea; i_area++) { + if( iBin < m_AreaSet[i_area].getOffset() ) break; + if( iBin >= m_AreaSet[i_area].getOffset() + && (i_area == narea-1 || iBin < m_AreaSet[i_area+1].getOffset()) ) break; + } + return &(m_AreaSet[i_area]); +} + +// return area for given global bin number +const CaloLocalHadCoeff::LocalHadArea *CaloLocalHadCoeff::getAreaFromBin(int iBin, int &i_area) const +{ + i_area = 0; + int narea = m_AreaSet.size(); + for(i_area=0; i_area<narea; i_area++) { + if( iBin < m_AreaSet[i_area].getOffset() ) break; + if( iBin >= m_AreaSet[i_area].getOffset() + && (i_area == narea-1 || iBin < m_AreaSet[i_area+1].getOffset()) ) break; + } + return &(m_AreaSet[i_area]); +} + + + +/* *************************************************************************** +CaloLocalHadCoeff: coefficients methods +*************************************************************************** */ + +// set coefficient +void CaloLocalHadCoeff::setCoeff(const int iBin, const LocalHadCoeff & theCoeff) +{ + m_CoeffSet[iBin] = theCoeff; +} + +// return coefficient for given global bin number +const CaloLocalHadCoeff::LocalHadCoeff * CaloLocalHadCoeff::getCoeff(const int & iBin) const +{ + if ( iBin >= 0 && iBin < (int)m_CoeffSet.size() ) { + return (& m_CoeffSet[iBin]); + }else{ + return 0; + } +} + +// return coefficient for given area number and list of cluster variables +const CaloLocalHadCoeff::LocalHadCoeff * CaloLocalHadCoeff::getCoeff(const int &n_area, std::vector<float> &vars) const +{ + int iBin = getBin(n_area, vars); + return getCoeff(iBin); +} + + + +/* *************************************************************************** +CaloLocalHadCoeff: bin's methods +*************************************************************************** */ + +// return global bin number for given area and list of cluster variables +// size of input vector must be equal to the number of dimensions defined for this area +int CaloLocalHadCoeff::getBin(const int n_area, std::vector<float> &vars) const +{ + const LocalHadArea *area = &m_AreaSet[n_area]; + // loop over dimensions + int iBin = area->getOffset(); + for(int i_dim=0; i_dim<area->getNdim(); i_dim++){ + int i_bin_dim = area->getDimension(i_dim)->getBin( vars[i_dim] ); + if(i_bin_dim < 0) return -1; + iBin += i_bin_dim*area->getDimLoc(i_dim); + } + return iBin; +} + +// returns general iBin for given area and vector of bin numbers for each dimension +// size of input vector must be equal to the number of dimensions defined for this area +int CaloLocalHadCoeff::getBin(const int n_area, std::vector<int> &v_indexes) const +{ + const LocalHadArea *area = &m_AreaSet[n_area]; + // loop over dimensions + int iBin = area->getOffset(); + for(int i_dim=0; i_dim<area->getNdim(); i_dim++){ + if(v_indexes[i_dim] < 0) return -1; + iBin += v_indexes[i_dim]*area->getDimLoc(i_dim); + } + return iBin; +} + +// convert general iBin to vector of bins for each dimension +int CaloLocalHadCoeff::bin2indexes(const int iBin, std::vector<int> &v_dim_indx) const +{ + const LocalHadArea *theArea = getAreaFromBin(iBin); + v_dim_indx.resize(theArea->getNdim(),0); + for(int i_dim=0; i_dim<theArea->getNdim(); i_dim++){ + int x0 = 0; + for(int j=0; j<i_dim; j++){ + x0 += v_dim_indx[j]*theArea->getDimLoc(j); + } + v_dim_indx[i_dim] = (iBin-theArea->getOffset()-x0)/theArea->getDimLoc(i_dim); + } + return 0; +} + +// return and arrays needed for interpolation for a given area (n_area), given list of dimensions (dim) and given phase space point (x) +// for speed reason, no check on dimensions !!!!!!!! +bool CaloLocalHadCoeff::getInterpArrays(const int n_area, const std::vector<int> &dim, std::vector<float> &x, + std::vector<double> &xadj, std::vector<unsigned int> &gbin) const { + // sanity check + if(n_area<0 || n_area > (int)m_AreaSet.size()) return false; + const LocalHadArea *area=&(m_AreaSet[n_area]); + if(!dim.size()) { + std::cout << "CaloLocalHadCoeff::getInterpArrays() -> Error! Empty dimension list" << std::endl; + return false; + }else if( (int)dim.size() > area->getNdim()) { + std::cout << "CaloLocalHadCoeff::getInterpArrays() -> Error! Vector of dimensions to interpolate exceed defined in area." << std::endl; + return false; + } + int ndim = dim.size(); + + if((int)x.size()!= area->getNdim()) { + std::cout<<"CaloLocalHadCoeff::getInterpArrays() -> Error! Wrong size of phase space point !!!"<<std::endl; + return false; + } + + xadj.resize(ndim); + unsigned int ncorners = (1<<ndim); + gbin.resize(ncorners); + + float xa; + int ibin, i; + unsigned int i_len;; + std::vector<int> vTmp; + std::vector<int> vIdx(area->getNdim()); + std::vector<std::vector<int> > vpW; + for(i=0; i<ndim; i++){ + ibin = (area->getDimension(dim[i]))->getBinAdjusted(x[dim[i]],xa); + //if(xadj<0) printf("%d x:%6.3f xadj:%6.3f ibin:%d ibin+1:%d \n",i, x[i], xadj, ibin, ibin+1); + xadj[i] = xa; + vTmp.clear(); + vTmp.push_back(ibin); + if(ibin< (area->getDimension(dim[i]))->getNbins()-1) vTmp.push_back(ibin+1); + else vTmp.push_back(ibin); + vpW.push_back(vTmp); + } + // fill the vIdx for dimensions we are not interpolating over + for(i=0; i<area->getNdim(); ++i){ + if(std::find(dim.begin(),dim.end(),i) != dim.end()) continue; + vIdx[i] = area->getDimension(i)->getBin(x[i]); + } + + // now find the global bin for all corners + //vTmp.clear(); + //vTmp.resize(ndim); + for(i_len=0; i_len<ncorners; ++i_len){ + for( i=0; i<ndim; i++){ + //std::cout<<"Sec. idx: "<<int(i_len/int(pow(2,i)))%int(pow(2,i))<<std::endl; + if(i==0) vIdx[dim[i]] = vpW[i][i_len%2]; + else vIdx[dim[i]] = vpW[i][int(i_len/int(pow(2,i)))%int(pow(2,i))]; + //if(i==2) std::cout<< vTmp[i] <<" "; + //std::cout<< vTmp[i] <<" "; + } + // std::cout<<std::endl; + ibin = getBin(n_area,vIdx); + gbin[i_len] = ibin; + } + return true; +} + diff --git a/Calorimeter/CaloConditions/src/ToolConstants.cxx b/Calorimeter/CaloConditions/src/ToolConstants.cxx new file mode 100755 index 0000000000000000000000000000000000000000..13854e5c0ccbd36926cc71655beda4efcb6b4618 --- /dev/null +++ b/Calorimeter/CaloConditions/src/ToolConstants.cxx @@ -0,0 +1,167 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: ToolConstants.cxx,v 1.5 2009-04-09 14:41:17 ssnyder Exp $ +/** + * @file ToolConstants.cxx + * @author scott snyder <snyder@bnl.gov> + * @date June, 2004 + * @brief Container for the tool constants managed by @c ToolWithConstants. + */ + + +#include "CaloConditions/ToolConstants.h" +#include "GaudiKernel/GaudiException.h" + + +namespace CaloRec { + + +/** + * @brief Default constructor. + */ +ToolConstants::ToolConstants() + : m_version (0) +{ +} + + +/** + * @brief Make a new entry. + * @param context The context name, for error reporting. + * @param key The key of the new entry. + * @param val The value of the new entry, as a string. + * + * Converts @a val to an @c Arrayrep and stores it. + * Raises an exception if the key already exists or if there's + * a conversion error. + */ +const CxxUtils::Arrayrep& +ToolConstants::newrep (const std::string& context, + const std::string& key, + const std::string& val) +{ + Maptype::const_iterator i = m_map.find (key); + if (i != m_map.end()) + error (context, key, "Duplicate key"); + return m_map[key] = CxxUtils::Arrayrep (val, context+":"+key); +} + +/** + * @brief Look up an entry. + * @param context The context name, for error reporting. + * @param key The key of the new entry. + * + * Looks up @a key and returns its @c Arrayrep. + * Raises an exception if @a key isn't found. + */ +const CxxUtils::Arrayrep& +ToolConstants::getrep (const std::string& context, + const std::string& key) const +{ + Maptype::const_iterator i = m_map.find (key); + if (i == m_map.end()) + error (context, key, "Can't find key"); + return i->second; +} + + +/** + * @brief Set an entry. + * @param key The key of the entry to set. + * @param rep The value of the new entry. + */ +void ToolConstants::setrep (const std::string& key, + const CxxUtils::Arrayrep& rep) +{ + m_map[key] = rep; +} + + +/** + * @brief Test to see if a given key is present. + */ +bool ToolConstants::hasrep (const std::string& key) const +{ + return m_map.find (key) != m_map.end(); +} + + +/** + * @brief Report an error. + * @param context Context string for the error. + * @param key Key involved in the error. + * @param msg Error message. + */ +void ToolConstants::error (const std::string& context, + const std::string& key, + const std::string& msg) +{ + throw GaudiException (msg, context+":"+key, StatusCode::FAILURE); +} + +/** + * @brief Writes out constants in a python-like format + * @param stream Stream to wirte to (file or cout) + * @param name Name of the Maker-Algorithm (used only for output) + */ +void ToolConstants::writeConstants(std::ostream& stream, + const std::string& name) const +{ + Maptype::const_iterator it=m_map.begin(); + Maptype::const_iterator it_e=m_map.end(); + for (;it!=it_e;it++) { + stream << name << "." << it->first << " = "; + it->second.write_array(stream); + } + stream << std::endl; +} + + +/** + * @brief Return the name of the C++ class that operates on these constants. + */ +const std::string& ToolConstants::clsname() const +{ + return m_clsname; +} + + +/** + * @brief Set the name of the C++ class that operates on these constants. + */ +void ToolConstants::clsname (const std::string& name) +{ + m_clsname = name; +} + + +/** + * @brief Return the version of the C++ class that operates on these constants. + */ +int ToolConstants::version() const +{ + return m_version; +} + + +/** + * @brief Set the version of the C++ class that operates on these constants. + */ +void ToolConstants::version (int version) +{ + m_version = version; +} + + +/** + * @brief Return the key -> value map. + */ +const ToolConstants::Maptype& ToolConstants::map() const +{ + return m_map; +} + + +} // namespace CaloRec diff --git a/Calorimeter/CaloConditions/test/CaloConditions.xml b/Calorimeter/CaloConditions/test/CaloConditions.xml new file mode 100755 index 0000000000000000000000000000000000000000..d0f991a0e685677acde0a0b969ffbcbf9842ab58 --- /dev/null +++ b/Calorimeter/CaloConditions/test/CaloConditions.xml @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<atn> + <TEST name="CaloConditionsTests" type="makecheck"> + <package>Calorimeter/CaloConditions</package> + <author> scott snyder </author> + <mailto> snyder@bnl.gov </mailto> + <expectations> + <errorMessage>Athena exited abnormally</errorMessage> + <errorMessage>differ</errorMessage> + <warningMessage> # WARNING_MESSAGE : post.sh> ERROR</warningMessage> + <successMessage>check ok</successMessage> + <returnValue>0</returnValue> + </expectations> + </TEST> +</atn> diff --git a/Calorimeter/CaloConditions/test/ToolConstants_test.cxx b/Calorimeter/CaloConditions/test/ToolConstants_test.cxx new file mode 100755 index 0000000000000000000000000000000000000000..e3e295c250b8af03f6693211e8a197b56f553d09 --- /dev/null +++ b/Calorimeter/CaloConditions/test/ToolConstants_test.cxx @@ -0,0 +1,82 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// $Id: ToolConstants_test.cxx,v 1.4 2009-04-09 14:41:17 ssnyder Exp $ +/** + * @file ToolConstants_test.cxx + * @author scott snyder <snyder@bnl.gov> + * @date June, 2004 + * @brief Regression tests for the ToolConstants class. + */ + +#undef NDEBUG + +#include "CaloConditions/ToolConstants.h" +#include "GaudiKernel/GaudiException.h" +#include <stdexcept> +#include <cassert> +#include <iostream> + + +using namespace CaloRec; +using namespace CxxUtils; + + +#define EXPECT_EXCEPTION(s) \ + { \ + bool caught = false; \ + try { \ + Arrayrep xx (s); \ + } catch (std::runtime_error& c) { \ + caught = true; \ + } catch (GaudiException& c) { \ + caught = true; \ + c.code().ignore(); \ + } \ + assert (caught); \ + } + + +void test1() +{ + ToolConstants tc; + Array<0> a1 (tc.newrep ("foo", "a", "1.25")); + assert (a1 == 1.25); + + assert (!tc.hasrep ("xxx")); + assert (tc.hasrep ("a")); + + assert (tc.map().size() == 1); + assert (tc.map().begin()->first == "a"); + + Array<2> a2 (tc.newrep ("foo", "b", "[[1,2],[3,4]]")); + assert (a2.size() == 2); + assert (a2[0][1] == 2); + + Array<0> a3 (tc.getrep ("foo", "a")); + assert (a3 == 1.25); + + EXPECT_EXCEPTION( tc.newrep ("foo", "a", "2.0") ); + EXPECT_EXCEPTION( tc.newrep ("foo", "z", "asdasd") ); + EXPECT_EXCEPTION( tc.getrep ("foo", "x") ); + + tc.setrep ("fee", tc.getrep ("foo", "a")); + Array<0> a4 (tc.getrep ("foo", "fee")); + assert (a4 == 1.25); + + assert (tc.clsname() == ""); + tc.clsname ("abc"); + assert (tc.clsname() == "abc"); + + assert (tc.version() == 0); + tc.version (10); + assert (tc.version() == 10); +} + + +int main() +{ + test1(); + return 0; +}