From 5973bd7c0f972797c397796dc782b2001004e1f3 Mon Sep 17 00:00:00 2001 From: Scott Snyder <scott.snyder@cern.ch> Date: Sat, 31 May 2014 19:30:52 +0200 Subject: [PATCH] Const fixes. (LArRawEvent-01-07-20) --- .../LArRawEvent/LArAccumulatedCalibDigit.h | 187 +++++++++++++ .../LArAccumulatedCalibDigitContainer.h | 49 ++++ .../LArRawEvent/LArAccumulatedDigit.h | 121 ++++++++ .../LArAccumulatedDigitContainer.h | 45 +++ .../LArRawEvent/LArRawEvent/LArAutoCorr.h | 97 +++++++ .../LArRawEvent/LArRawEvent/LArCalibDigit.h | 73 +++++ .../LArRawEvent/LArCalibDigitContainer.h | 50 ++++ .../LArRawEvent/LArRawEvent/LArDigit.h | 78 ++++++ .../LArRawEvent/LArDigitContainer.h | 51 ++++ .../LArRawEvent/LArFebErrorSummary.h | 62 +++++ .../LArRawEvent/LArRawEvent/LArFebHeader.h | 240 ++++++++++++++++ .../LArRawEvent/LArFebHeaderContainer.h | 43 +++ .../LArRawEvent/LArOFIterResults.h | 194 +++++++++++++ .../LArRawEvent/LArOFIterResultsContainer.h | 20 ++ .../LArRawEvent/LArRawEvent/LArPedestal.h | 87 ++++++ .../LArRawEvent/LArRawEvent/LArRawChannel.h | 180 ++++++++++++ .../LArRawEvent/LArRawChannelContainer.h | 48 ++++ .../LArRawEvent/LArRawEvent/LArRawEventDict.h | 12 + .../LArRawEvent/LArRawEvent/LArTTL1.h | 73 +++++ .../LArRawEvent/LArTTL1Container.h | 49 ++++ .../LArRawEvent/LArRawEvent/selection.xml | 32 +++ LArCalorimeter/LArRawEvent/cmt/requirements | 29 ++ LArCalorimeter/LArRawEvent/doc/mainpage.h | 28 ++ .../src/LArAccumulatedCalibDigit.cxx | 142 ++++++++++ .../src/LArAccumulatedCalibDigitContainer.cxx | 15 + .../LArRawEvent/src/LArAccumulatedDigit.cxx | 263 ++++++++++++++++++ .../src/LArAccumulatedDigitContainer.cxx | 14 + .../LArRawEvent/src/LArAutoCorr.cxx | 185 ++++++++++++ .../LArRawEvent/src/LArCalibDigit.cxx | 16 ++ .../src/LArCalibDigitContainer.cxx | 8 + LArCalorimeter/LArRawEvent/src/LArDigit.cxx | 75 +++++ .../LArRawEvent/src/LArDigitContainer.cxx | 59 ++++ .../LArRawEvent/src/LArFebErrorSummary.cxx | 75 +++++ .../LArRawEvent/src/LArFebHeader.cxx | 73 +++++ .../LArRawEvent/src/LArOFIterResults.cxx | 57 ++++ .../LArRawEvent/src/LArPedestal.cxx | 163 +++++++++++ .../src/LArRawChannelContainer.cxx | 10 + LArCalorimeter/LArRawEvent/src/LArTTL1.cxx | 34 +++ .../LArRawEvent/src/LArTTL1Container.cxx | 13 + 39 files changed, 3050 insertions(+) create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigit.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigitContainer.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigit.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigitContainer.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArAutoCorr.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigit.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigitContainer.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArDigit.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArDigitContainer.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArFebErrorSummary.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeader.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeaderContainer.h create mode 100644 LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResults.h create mode 100644 LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResultsContainer.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArPedestal.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannel.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannelContainer.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArRawEventDict.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1Container.h create mode 100755 LArCalorimeter/LArRawEvent/LArRawEvent/selection.xml create mode 100755 LArCalorimeter/LArRawEvent/cmt/requirements create mode 100755 LArCalorimeter/LArRawEvent/doc/mainpage.h create mode 100755 LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigit.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigitContainer.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArAccumulatedDigit.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArAccumulatedDigitContainer.cxx create mode 100644 LArCalorimeter/LArRawEvent/src/LArAutoCorr.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArCalibDigit.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArCalibDigitContainer.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArDigit.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArDigitContainer.cxx create mode 100644 LArCalorimeter/LArRawEvent/src/LArFebErrorSummary.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArFebHeader.cxx create mode 100644 LArCalorimeter/LArRawEvent/src/LArOFIterResults.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArPedestal.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArRawChannelContainer.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArTTL1.cxx create mode 100755 LArCalorimeter/LArRawEvent/src/LArTTL1Container.cxx diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigit.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigit.h new file mode 100755 index 00000000000..fc91d90abd3 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigit.h @@ -0,0 +1,187 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//Dear emacs, this is -*-c++-*- +/** + +@class LArAccumulatedCalibDigit +@brief Data class for calibration ADC samples preprocessed by the DSP + +@author Sandrine Laplace +@author Isabelle Wingerter-Seez +*/ + +/* modifications : */ +/* +03-12-06, G.Rosenbaum +Added constructor to take an int for isPulsed to store info re: which caliblines +have been pulsed (HEC can be pulsed by up to 4. + +Changed getDelay to get the forst 12 bits of m_delayPulsed +Added functions to get the isPusled info + + +25-08-09 W. Lampl +Remove accumulation in converter, simplify LArAccumulatedDigit class +Contains now only the data of the currently processed substep. + +*/ + + + +#ifndef LARACCUMULATEDCALIBDIGIT_H +#define LARACCUMULATEDCALIBDIGIT_H +#include <vector> + +#include "Identifier/HWIdentifier.h" +#include "CaloIdentifier/CaloGain.h" + +#include "stdint.h" + +class LArAccumulatedCalibDigit { + +private: + + /** @brief Online Identifier */ + HWIdentifier m_hardwareID; + + /** @brief gain */ + CaloGain::CaloGain m_gain; + + /** @brief vector of sample sums */ + std::vector < uint32_t > m_sampleSum; + + /** @brief vector of sample square sums */ + std::vector < uint32_t > m_sample2Sum; + + /** @brief number of samples */ + //uint32_t m_nsamples; + + /** @brief number of trigger step*/ + uint32_t m_nTriggers; + + /** @brief DAC-Value*/ + uint16_t m_DAC; + + /** @brief Delay-Value and isPulsed boolean encoded in this variable*/ + uint16_t m_delayPulsed; + + uint16_t m_nStep; + + uint16_t m_iStep; + +public: + + /** @brief Constructor (initialize everything)*/ + LArAccumulatedCalibDigit(HWIdentifier & channel_value, CaloGain::CaloGain gain_value, + const std::vector < uint32_t >& sampleSum_value, + const std::vector < uint32_t >& sample2Sum_value, + uint32_t nTrigger_value, uint16_t DAC_value=0, uint16_t delay_value=0, + uint16_t isPulsed_value=false, uint16_t nStep_value=0, uint16_t iStep_value=0) : + m_hardwareID(channel_value), m_gain(gain_value), m_sampleSum(sampleSum_value), m_sample2Sum(sample2Sum_value), + m_nTriggers(nTrigger_value), m_DAC(DAC_value), + m_delayPulsed((delay_value & 0xFFF) | (isPulsed_value<<12)), + m_nStep(nStep_value), m_iStep(iStep_value) + {}; + + /** @brief Constructor (initialize for later accumulation) */ + LArAccumulatedCalibDigit(HWIdentifier & channel_value, CaloGain::CaloGain gain_value, + uint32_t nsamples=7, uint16_t DAC_value=0, uint16_t delay_value=0, + uint16_t isPulsed_value=false, uint16_t nStep_value=0, uint16_t iStep_value=0) : + m_hardwareID(channel_value), m_gain(gain_value), + m_nTriggers(0), m_DAC(DAC_value), + m_delayPulsed((delay_value & 0xFFF) | (isPulsed_value<<12)), + m_nStep(nStep_value), m_iStep(iStep_value) + { + m_sampleSum.resize(nsamples); + m_sample2Sum.resize(nsamples); + }; + + /** @brief Destructor */ + virtual ~LArAccumulatedCalibDigit(); + + /** @brief default constructor for persistency */ + LArAccumulatedCalibDigit() : + m_hardwareID(0), m_gain(CaloGain::LARNGAIN), m_nTriggers(0), + m_DAC(0), m_delayPulsed(0), m_nStep(0), m_iStep(0) + {}; + + /** @brief Return HWIdentifier */ + const HWIdentifier & hardwareID() const {return m_hardwareID; } + + /** @brief Return channel ID */ + const HWIdentifier & channelID() const { return m_hardwareID; } + + /** @brief return gain value */ + CaloGain::CaloGain gain() const { return m_gain; } + + /** @brief return number of samples */ + size_t nsamples() const { return m_sampleSum.size(); } + + /** @brief return a reference to a stl vector containing the sample-sums */ + const std::vector < uint32_t > & sampleSum() const { return m_sampleSum; } + + /** @brief return a reference to a stl vector containing the sum of the squares of the sample */ + const std::vector < uint32_t > & sample2Sum() const { return m_sample2Sum; } + + /** @brief return the number of triggers */ + unsigned nTriggers() const {return m_nTriggers;} + + /** @brief return the number of samples */ + //unsigned nSamples() const {return m_nsamples;} + + /** @brief return the setting of the DAC */ + int DAC() const {return static_cast<int>(m_DAC);} + + /** @brief return the setting of the delay */ + int delay() const {return static_cast<int>(m_delayPulsed & 0xFFF);} + + /** @brief Tell if this channel was pulsed */ + bool isPulsed() const {return static_cast<bool>(m_delayPulsed & 0xF000);} + + /** @brief Tell if calib line n was pulsed for this channel (n=1,2,3,4) */ + bool isPulsed(int n) const { + if(n==1) return static_cast<bool>(m_delayPulsed & 0x1000); + if(n==2) return static_cast<bool>(m_delayPulsed & 0x2000); + if(n==3) return static_cast<bool>(m_delayPulsed & 0x4000); + if(n==4) return static_cast<bool>(m_delayPulsed & 0x8000); + return false;//WRITE ERROR MESSAGE + } + + /** @brief get the four bit int that tells which lines pulsed */ + uint16_t getIsPulsedInt() const { return (m_delayPulsed >> 12);} + + /** @brief Calculates and returns the Mean value of each ADC sample */ + std::vector<float> mean() const; + + /** @brief Calculates and returns the RMS value of each ADC sample */ + std::vector<float> RMS() const; + + + /** @brief Calculates and returns the Mean value for one ADC sample */ + float mean(const size_t i) const; + + /** @brief Calculates and returns the RMS value for one ADC sample */ + float RMS(const size_t i) const; + + uint16_t nSteps() const { return m_nStep;} + + uint16_t stepIndex() const {return m_iStep;} + + /** @brief Set the sampleSum */ + void setSampleSum(const std::vector< uint32_t >& sampleSum); + + /** @brief Set the sample2Sum */ + void setSample2Sum(const std::vector< uint32_t >& sample2Sum); + + /** @brief Sum up with another (individual) LArCalibDigit */ + bool setAddDigit(const std::vector<short>& samples); + + /** @brief Sum up with another substep */ + bool setAddSubStep(const std::vector < uint32_t >& sampleSum, const std::vector < uint32_t >& sample2Sum, const uint32_t nTriggerPerStep); + +}; + +#endif //LARDIGIT_H + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigitContainer.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigitContainer.h new file mode 100755 index 00000000000..32c068e81e5 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedCalibDigitContainer.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + +@class LArAccumulatedCalibDigitContainer +@brief Container class for LArAccumulatedCalibDigit + +@author Sandrine Laplace +@author Isabelle Wingerter-Seez + +*/ + +#ifndef LARACCUMULATEDCDIGITCONTAINER_H +#define LARACCUMULATEDCDIGITCONTAINER_H + +#include "DataModel/DataVector.h" +#include "CLIDSvc/CLASS_DEF.h" +#include "LArRawEvent/LArAccumulatedCalibDigit.h" + + +class LArAccumulatedCalibDigitContainer : public DataVector<LArAccumulatedCalibDigit> { + + public : + /** @brief Default Constructor */ + LArAccumulatedCalibDigitContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS ) ; + /** @brief destructor */ + virtual ~LArAccumulatedCalibDigitContainer(); + + /** @brief set the delay Scale */ + void setDelayScale(const double scale) {m_delayScale=scale;} + + /** @brief get the delay Scale */ + inline double getDelayScale() const {return m_delayScale;} + + private: + + /** @brief delayScale */ + double m_delayScale; + + /** @brief SG ownership policy */ + SG::OwnershipPolicy m_ownPolicy ; +}; + + +CLASS_DEF(LArAccumulatedCalibDigitContainer,1157958831,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigit.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigit.h new file mode 100755 index 00000000000..a5be7a5b0cc --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigit.h @@ -0,0 +1,121 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +/** + +@class LArAccumulatedDigit +@brief Data class for ADC samples and autocorr preprocessed by the DSP + +Contains sum of ADC counts and the sum of the s_i*s_{i+j} +adc counts plus gain, number of triggers and samples + +@author Remi Lafaye + +Modifications: +Walter Lampl, 27 Aug 2009: +Remove storage of individual substeps. The class represents now +exactly one substep or the sum of many substeps. + +*/ + +#ifndef LARACCUMULATEDDIGIT_H +#define LARACCUMULATEDDIGIT_H +#include <vector> + +#include "Identifier/HWIdentifier.h" +#include "CaloIdentifier/CaloGain.h" + +#include "stdint.h" + +class LArAccumulatedDigit { + +private: + + /** @brief Online Identifier */ + HWIdentifier m_hardwareID; + + /** @brief gain */ + CaloGain::CaloGain m_gain; + + /** @brief sampleSum over ntrigger*nsamples */ + std::vector<uint64_t> m_sampleSum; + + /** @brief vector(index: j from s_i*s_{i+j}) */ + std::vector<uint64_t> m_sampleSquare; + + /** @brief number of total triggers */ + uint32_t m_nTrigger; + +public: + + /** @brief Constructor (first type)*/ + LArAccumulatedDigit(HWIdentifier & channel_value, + CaloGain::CaloGain gain_value, + const std::vector<uint32_t>& sampleSum_value, + const std::vector<uint32_t>& sampleSquare_value, + uint32_t nTrigger_value); + + /** @brief Constructor (second type)*/ + LArAccumulatedDigit(HWIdentifier & channel_value); + + /** @brief Destructor */ + ~LArAccumulatedDigit(); + + /** @brief default constructor for persistency */ + LArAccumulatedDigit(); + + /** @brief Return HWIdentifier */ + const HWIdentifier & hardwareID() const {return m_hardwareID; } + + /** @brief Return channel ID */ + const HWIdentifier & channelID() const { return m_hardwareID; } + + /** @brief return gain value */ + CaloGain::CaloGain gain() const { return m_gain; } + + /** @brief return number of samples */ + int nsample() const { return m_sampleSquare.size(); } + + /** @brief return the sample-sums */ + const std::vector<uint64_t>& sampleSum() const { return m_sampleSum; }; + + /** @brief return a reference to a stl vector containing the sum of the squares of the sample */ + const std::vector < uint64_t > & sampleSquare() const { return m_sampleSquare; } + + /** @brief return the number of triggers */ + unsigned nTrigger() const {return m_nTrigger;} + + /** @brief Calculates and returns the Mean value of ADC samples */ + float mean() const; + + /** @brief Calculates and returns the RMS value of ADC samples */ + float RMS() const; + + /** @brief Compute the autocorrelation elements */ + //MGV implement switch m_normalize to normalize + void getCov(std::vector<float> &cov, int normalize) const; + + /** @brief Accumulate single digit */ + bool setAddDigit(const std::vector<short>& digit); + + + /** @brief Accumulate new values */ + bool setAddSubStep(const CaloGain::CaloGain gain_value, const HWIdentifier chid, + const std::vector<uint64_t> sampleSum, const std::vector <uint64_t> sampleSquare, + const unsigned nTrigger); + + void setAddSubStep(CaloGain::CaloGain gain_value, std::vector<uint32_t> sampleSum, + std::vector < uint32_t > sampleSquare, unsigned nTrigger); + void setAddSubStep(CaloGain::CaloGain gain_value, std::vector<int32_t> sampleSum, + std::vector < int32_t > sampleSquare, unsigned nTrigger, int32_t base); + + + bool setAddSubStep(const LArAccumulatedDigit& ad) { + return setAddSubStep(ad.gain(), ad.channelID(), ad.sampleSum(),ad.sampleSquare(),ad.nTrigger()); + }; +}; + +#endif //LARACCUMULATEDDIGIT_H + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigitContainer.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigitContainer.h new file mode 100755 index 00000000000..cdb2597cf5c --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAccumulatedDigitContainer.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + +@class LArAccumulatedDigitContainer +@brief Container class for LArAccumulatedDigit + +@author Remi Lafaye +*/ + +#ifndef LARACCUMULATEDDIGITCONTAINER_H +#define LARACCUMULATEDDIGITCONTAINER_H + +#include "DataModel/DataVector.h" +#include "CLIDSvc/CLASS_DEF.h" +#include "CLHEP/Units/SystemOfUnits.h" +#include "LArRawEvent/LArAccumulatedDigit.h" + + +class LArAccumulatedDigitContainer : public DataVector<LArAccumulatedDigit> { + + public : + /** @brief Default Constructor */ + LArAccumulatedDigitContainer(SG::OwnershipPolicy ownPolicy=SG::OWN_ELEMENTS ) ; + /** @brief destructor */ + virtual ~LArAccumulatedDigitContainer(); + + inline void setNStep (unsigned int NStep) { m_NStep=NStep; } + inline void setStepIndex(unsigned int StepIndex) { m_StepIndex=StepIndex; } + inline unsigned int getNStep () const { return m_NStep; } + inline unsigned int getStepIndex() const { return m_StepIndex; } + inline int isLastStep() const { return (m_StepIndex==m_NStep-1); } + //private: + + /** @brief SG ownership policy */ + SG::OwnershipPolicy m_ownPolicy ; + unsigned int m_NStep, m_StepIndex; +}; + + +CLASS_DEF(LArAccumulatedDigitContainer,1185131589,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArAutoCorr.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAutoCorr.h new file mode 100755 index 00000000000..41ae4bddc01 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArAutoCorr.h @@ -0,0 +1,97 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARAUTOCORR_H +#define LARAUTOCORR_H +/******************************************************************** + + NAME: LArAutoCorr.h + PACKAGE: offline/LArCalorimeter/LArRawEvent + + AUTHORS: M. AHARROUCHE + CREATED: Dec. 16, 2003 + + PURPOSE: Intermediate object used to handle data + to be used for calculation of autocorrelation + elements. + + ********************************************************************/ +// Include files +#include <string> +#include <vector> +#include <math.h> + + +class LArAutoCorr +{ + private: + + // Lower bound of window + short m_min; + + // Upper bound of window + short m_max; + + // Sum of components + std::vector<double> m_sum; + + // Sum of squares + std::vector<double> m_matrix; + + // Autocorrelation matrix + std::vector<double> m_cov; + std::vector<double> m_cov_temp; + + // Counter of events + int m_nped; + + public: + + // Constructor + LArAutoCorr() + { + m_min = -1; + m_max = -1; + m_nped = 0; + } + + // Destructor + ~LArAutoCorr(){} + + // Reset m_sum, m_matrix and m_nped + void correl_zero(); + + // Set lower value + void set_min(const short min); + + // Set upper value + void set_max(const short max); + + // Get number of entries + int get_nentries() const; + + // Get mean value + double get_mean() const; + + // Get rms value + double get_rms() const; + + // Get lower value + const short & get_min()const; + + // Get uper value + const short & get_max() const; + + // Fill the m_sum and m_matrix vector + void add(const std::vector<short>& samples, size_t maxnsamples); + + // Compute the autocorrelation elements + //MGV implement switch m_normalize to normalize + const std::vector<double> & get_cov(int m_normalize, int m_phys) ; + + +}; + +#endif + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigit.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigit.h new file mode 100755 index 00000000000..e868d1c8e24 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigit.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARCALIBDIGIT_H +#define LARCALIBDIGIT_H +#include "LArDigit.h" +#include "stdint.h" + +/** + +@class LArCalibDigit +@brief Base class for LArDigits taken during calibration runs + +Additional data members to LArDigits are the DAC value, the delay value +and a bool that tells whether the cell was pulsed or not + +@author Walter Lampl +*/ + +/** + * -------------------------------- + * Modifications: + * 10/02//2004: Move to HWIdentifer (replaces LArSignalChannelID) + * Walter Lampl + */ + + +class LArCalibDigit : public LArDigit { + +private: + + /** @brief DAC-Value*/ + uint16_t m_DAC; + + /** @brief Delay-Value and isPulsed boolean encoded in this variable*/ + uint16_t m_delayPulsed; + +public: + + /** @brief constructor + @param[in] channel_value online channel identifier + @param[in] gain_value Gain + @param[in] sample_values reference to vector of ADC time samples + @param[in] DAC_value DAC + @param[in] delay_value delay + @param[in] isPulsed_value bool to tell if channel is pulse by calibration system + */ + LArCalibDigit(HWIdentifier & channel_value, CaloGain::CaloGain gain_value, const std::vector < short > & sample_values, + uint16_t DAC_value, uint16_t delay_value, bool isPulsed_value) : + LArDigit(channel_value, gain_value, sample_values), m_DAC(DAC_value), + m_delayPulsed((delay_value & 0x7FFF) | ((uint16_t)isPulsed_value<<15 ))//, m_isPulsed(isPulsed_value) + {}; + + /** @return DAC value */ + int DAC() const {return static_cast<int>(m_DAC);} + + /** @return delay value */ + int delay() const {return static_cast<int>(m_delayPulsed & 0x7FFF);} + + /** @return isPulsed flag */ + bool isPulsed() const {return static_cast<bool>(m_delayPulsed & 0x8000);} + + /** @brief Destructor */ + virtual ~LArCalibDigit(); + + /** @brief default constructor for persistency */ + LArCalibDigit(); + +}; + +#endif //LARDIGIT_H + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigitContainer.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigitContainer.h new file mode 100755 index 00000000000..0a8ca6f9aa9 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArCalibDigitContainer.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARCALIBDIGITCONTAINER_H +#define LARCALIBDIGITCONTAINER_H + +#include "DataModel/DataVector.h" +#include "CLIDSvc/CLASS_DEF.h" +#include "CLHEP/Units/SystemOfUnits.h" +#include "LArRawEvent/LArCalibDigit.h" + +/** +@class LArCalibDigitContainer +@brief Container class for LArCalibDigit +@author Walter Lampl +*/ + +class LArCalibDigitContainer : public DataVector<LArCalibDigit> { + + public : + /** + @brief constructor + */ + LArCalibDigitContainer() : DataVector<LArCalibDigit>(),m_delayScale(1*CLHEP::ns) { } + + /** @brief set delay scale + @param[in] scale time in ns between two delay steps + */ + void setDelayScale(const double scale) {m_delayScale=scale;} + /** @brief get delay scale + @return time in ns between two delay steps + */ + inline double getDelayScale() const {return m_delayScale;} + +/** + @brief destructor + */ + virtual ~LArCalibDigitContainer(); +private: + + /** @brief time in ns between two delay step */ + double m_delayScale; + +} ; + + +CLASS_DEF(LArCalibDigitContainer,1204837524,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArDigit.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArDigit.h new file mode 100755 index 00000000000..74f7e74d85e --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArDigit.h @@ -0,0 +1,78 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARDIGIT_H +#define LARDIGIT_H +#include <vector> + +#include "Identifier/Identifier.h" +#include "Identifier/HWIdentifier.h" +#include "CaloIdentifier/CaloGain.h" + +/** + @class LArDigit + @brief Liquid Argon digit base class + + represents the output of the FrontEnd electronics: ADC time samples in a given gain for a readout channel +*/ + +/* modifications : */ +/* 11/05/2002 : channelID transformed into a const method */ +/* 09/19/2002 : move to DataVector, remove ContainedObject, clid, etc*/ +/* 10/02/2004 : Migrate for new HWIdentifier. Old interface is removed. (Walter Lampl) */ + +class LArDigit { + + private: + + /** @brief Online Identifier */ + HWIdentifier m_hardwareID; + + /** @brief gain */ + CaloGain::CaloGain m_gain; + + /** @brief vector of ADC samples */ + std::vector < short > m_samples; + + public: + /** @brief constructor + @param[in] channel_value Online identifier + @param[in] gain_value Gain + @param[in] sample_value Reference of vector with ADC samples + */ + LArDigit(HWIdentifier & channel_value, CaloGain::CaloGain gain_value, const std::vector < short > & sample_values): + m_hardwareID(channel_value), m_gain(gain_value),m_samples(sample_values) {} + + /** @return HWIdentifier */ + const HWIdentifier & hardwareID() const {return m_hardwareID; } + + /** @return channel ID */ + const HWIdentifier & channelID() const { return m_hardwareID; } + + /** @return gain value */ + CaloGain::CaloGain gain() const { return m_gain; } + + /** @return number of samples */ + int nsamples() const { return m_samples.size(); } + + /** @return a reference to a stl vector containing the sample values */ + const std::vector < short > & samples() const { return m_samples; } + + /** @brief Conversion operator to a std::string <br> Can be used in a cast operation : (std::string) digit <br> */ + virtual operator std::string() const; + + /** @brief Set new digits in object. + @param[in] samples vector of ADC time samples + */ + void setSamples( std::vector < short > samples); + + /** @brief Destructor */ + virtual ~LArDigit() { } + + /** @brief default constructor for persistency */ + LArDigit(); +}; + +#endif //LARDIGIT_H + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArDigitContainer.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArDigitContainer.h new file mode 100755 index 00000000000..ccf9f214bd0 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArDigitContainer.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARDIGITCONTAINER_H +#define LARDIGITCONTAINER_H + +#include "DataModel/DataVector.h" +#include "CLIDSvc/CLASS_DEF.h" +#include "LArRawEvent/LArDigit.h" + +/** + @class LArDigitContainer + @brief Container class for LArDigit */ + +/* date of creation : 30/09/2000 */ + +/* modification : 30/06/2001 */ +/* date of last modification : 09/19/2002 HMA + Move to DataVector + */ + +class LArDigitContainer : public DataVector<LArDigit> { + + public : + + /** @brief Constructor */ + LArDigitContainer() : DataVector<LArDigit>() { } + + /** @brief Alternative Construction with ownership policy*/ + LArDigitContainer(SG::OwnershipPolicy ownPolicy) : DataVector<LArDigit>(ownPolicy) { } + +/** + * Conversion operator to a std::string <br><br> + * Can be used in a cast operation : (std::string) digit_container + */ + + virtual operator std::string() const; + +/** + * destructor + */ + virtual ~LArDigitContainer() { } +private: + +} ; + + +CLASS_DEF(LArDigitContainer,2711,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebErrorSummary.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebErrorSummary.h new file mode 100755 index 00000000000..8d7cf0c6577 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebErrorSummary.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARFEBERRORSUMMARY_H +#define LARFEBERRORSUMMARY_H + +#include "Identifier/HWIdentifier.h" +#include "CLIDSvc/CLASS_DEF.h" +#include <stdint.h> +#include <map> + + +/** +@class LArFebErrorSummary +@brief Holds information from the FEB Error Summary + +@author Hong Ma + +*/ + +class LArFebErrorSummary +{ + public: + + enum LArFebErrorType{ + Parity,BCID,SampleHeader,EVTID,ScacStatus,ScaOutOfRange, + GainMismatch,TypeMismatch,NumOfSamples,EmptyDataBlock,DspBlockSize,CheckSum, MissingHeader, BadGain, N_LArFebErrorType + } ; + + /** @brief Constructor with FEB Id*/ + LArFebErrorSummary() ; + + /** @brief Destructor */ + ~LArFebErrorSummary() ; + + /** @brief Add another FEB error record, return true if added successfully */ + bool set_feb_error(unsigned int febid,uint16_t e); + + /** @brief get error for feb */ + uint16_t feb_error(HWIdentifier febid) const ; + + /** @brief get all febs with error */ + const std::map<unsigned int,uint16_t>& get_all_febs() const ; + + /** @brief interpret the error in string */ + static std::string error_to_string( uint16_t error) ; + + /** @brief clear internal map */ + void clear( ) ; + + private: + + /** @brief error is stored in a map with key = feb id */ + std::map<unsigned int,uint16_t> m_feb_errors; + + static std::string m_errorStrings[N_LArFebErrorType] ; +}; + +CLASS_DEF(LArFebErrorSummary,223531796,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeader.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeader.h new file mode 100755 index 00000000000..093bd614bbe --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeader.h @@ -0,0 +1,240 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARFEBHEADER_H +#define LARFEBHEADER_H + +#include "Identifier/HWIdentifier.h" +#include <stdint.h> + + +/** +@class LArFebHeader +@brief Holds information from the FEB Header + +@author Walter Lampl +@author Remi Lafaye +*/ + +class LArFebHeader +{ + public: + + /** @brief Constructor with FEB Id*/ + LArFebHeader(const HWIdentifier febid); + + /** @brief Destructor */ + ~LArFebHeader(); + + /** @brief get the FEBId */ + inline HWIdentifier FEBId() const {return m_FEBId;} + + /** @brief get the format version */ + inline uint32_t FormatVersion() const {return m_RodHeader.FormatVersion;} + + /** @brief get the source Id */ + inline uint32_t SourceId() const {return m_RodHeader.SourceId;} + + /** @brief get the run number */ + inline uint32_t RunNumber() const {return m_RodHeader. RunNumber;} + + /** @brief get the EventID */ + inline uint16_t ELVL1Id() const {return m_RodHeader.ELVL1Id;} + + /** @brief get the Bunch Crossing ID */ + inline uint16_t BCId() const {return m_RodHeader.BCId;} + + /** @brief get the Level1 trigger type ID */ + inline uint32_t LVL1TigType() const {return m_RodHeader.LVL1TigType;} + + /** @brief get the Detector event type ID */ + inline uint32_t DetEventType() const {return m_RodHeader.DetEventType;} + + /** @brief get the version of the DSP code */ + inline uint32_t DspCodeVersion() const {return m_DspHeader.CodeVersion;} + + /** @brief get the Event number counted by the DSP code*/ + inline uint32_t DspEventCounter() const {return m_DspHeader.EventCounter;} + + /** @brief get the FEB Event ID*/ + inline uint16_t FebELVL1Id() const {return m_ELVL1Id;} + + /** @brief get the FEB Bunch Crossing ID*/ + inline uint16_t FebBCId() const {return m_BCId;} + + /** @brief get the ROD block sizes */ + inline uint16_t RodResults1Size() const {return m_Results1Size;} + inline uint16_t RodResults2Size() const {return m_Results2Size;} + inline uint16_t RodRawDataSize() const {return m_RawDataSize;} + + /** @brief get the number of samples and cells above threshold */ + inline uint16_t NbSamples() const {return m_NbSamples;} + inline uint16_t NbSweetCells1() const {return m_NbSweetCells1;} + inline uint16_t NbSweetCells2() const {return m_NbSweetCells2;} + inline uint32_t OnlineChecksum() const { return m_OnlineChecksum; } + inline uint32_t OfflineChecksum() const { return m_OfflineChecksum; } + inline bool ChecksumVerification() const { return m_OnlineChecksum==m_OfflineChecksum; } + + /** @brief get the FEB Control Word #1*/ + inline const std::vector <uint16_t> & FebCtrl1() const {return m_Ctrl1;} + + /** @brief get the FEB Control Word #2*/ + inline const std::vector <uint16_t> & FebCtrl2() const {return m_Ctrl2;} + + /** @brief get the FEB Control Word #3*/ + inline const std::vector <uint16_t> & FebCtrl3() const {return m_Ctrl3;} + + /** @brief get the ROD Status*/ + inline uint32_t RodStatus() const {return m_Status;} + + /** @brief get the SCA's*/ + inline const std::vector <uint16_t> & SCA() const { return m_SCA; } + + /** @brief Check functions: return true if mismatch in Event ID*/ + inline bool CheckErrorELVL1Id() const { return (m_RodHeader.ELVL1Id&0x1f)!=m_ELVL1Id; } + + /** @brief Check functions: return true if mismatch in Bunch Crossing ID*/ + inline bool CheckErrorBCId() const { return m_RodHeader.BCId!=((m_BCId+1)&0xfff); } + + /** @brief set the format version */ + inline void SetFormatVersion(const uint32_t formatVersion) + { m_RodHeader.FormatVersion=formatVersion; return; } + + /** @brief set the source Id */ + inline void SetSourceId(const uint32_t sourceID) + { m_RodHeader.SourceId=sourceID; return; } + + /** @brief set the run number */ + inline void SetRunNumber(const uint32_t runNumber) + { m_RodHeader.RunNumber=runNumber; return; } + + /** @brief set the EventID */ + inline void SetELVL1Id(const uint16_t elvl1Id) + { m_RodHeader.ELVL1Id=elvl1Id; return; } + + /** @brief set the Bunch Crossing ID */ + inline void SetBCId(const uint16_t bcid) + { m_RodHeader.BCId=bcid; return; } + + /** @brief set the ROD block sizes */ + inline void SetRodResults1Size(const uint16_t size) + { m_Results1Size=size; return; } + inline void SetRodResults2Size(const uint16_t size) + { m_Results2Size=size; return; } + inline void SetRodRawDataSize (const uint16_t size) + { m_RawDataSize=size; return; } + + /** @brief set the number of samples and cells above thresholds */ + inline void SetNbSweetCells1(const uint16_t n) + { m_NbSweetCells1=n; return; } + inline void SetNbSweetCells2(const uint16_t n) + { m_NbSweetCells2=n; return; } + inline void SetNbSamples(const uint16_t n) + { m_NbSamples=n; return; } + inline void SetOnlineChecksum(const uint32_t checksum) + { m_OnlineChecksum=checksum; return; } + inline void SetOfflineChecksum(const uint32_t checksum) + { m_OfflineChecksum=checksum; return; } + + /** @brief set the Level1 trigger type ID */ + inline void SetLVL1TigType(const uint32_t lvl1ttype) + { m_RodHeader.LVL1TigType=lvl1ttype; return; } + + /** @brief set the Detector event type ID */ + inline void SetDetEventType(const uint32_t detEvType) + { m_RodHeader.DetEventType=detEvType; return; } + + /** @brief set the version of the DSP code */ + inline void SetDspCodeVersion(const uint32_t codeVersion) + { m_DspHeader.CodeVersion=codeVersion; return; } + + /** @brief set the Event number counted by the DSP code*/ + inline void SetDspEventCounter(const uint32_t eventCounter) + { m_DspHeader.EventCounter=eventCounter; return; } + + /** @brief set the FEB Event ID*/ + inline void SetFebELVL1Id(const uint16_t elvl1Id) + { m_ELVL1Id=elvl1Id; return; } + + /** @brief set the FEB Bunch Crossing ID*/ + inline void SetFebBCId(const uint16_t bcid) + { m_BCId=bcid; return; } + + /** @brief set the FEB Control Word #1*/ + inline void SetFebCtrl1(const uint16_t ctrl1) + { m_Ctrl1.push_back(ctrl1); return; } + + /** @brief set the FEB Control Word #2*/ + inline void SetFebCtrl2(const uint16_t ctrl2) + { m_Ctrl2.push_back(ctrl2); return; } + + /** @brief set the FEB Control Word #3*/ + inline void SetFebCtrl3(const uint16_t ctrl3) + { m_Ctrl3.push_back(ctrl3); return; } + + /** @brief set the ROD Status*/ + inline void SetRodStatus(const uint32_t status) + { m_Status=status; return; } + + /** @brief set the SCA's*/ + inline void SetFebSCA(const uint16_t sca) + { m_SCA.push_back(degray(sca)); return; } + + private: + + /** @brief like explained in: http://mathworld.wolfram.com/GrayCode.html */ + int degray(int x); + + /** @brief Feb Identifier */ + const HWIdentifier m_FEBId; + + /** @brief ROD-Header, always present (is part of the FEB-Header) */ + struct { + uint32_t FormatVersion; + uint32_t SourceId; + uint32_t RunNumber; + uint16_t ELVL1Id; + uint16_t BCId; + uint32_t LVL1TigType; + uint32_t DetEventType; + } m_RodHeader; + + /** @brief DSP-Header (most of it is actually in the DSP-Trailer) */ + struct { + uint32_t CodeVersion; // DSP code version + uint32_t EventCounter; // DSP event counter + } m_DspHeader; + + /** @brief FEB EventId */ + uint16_t m_ELVL1Id; + + /** @brief FEB BCId */ + uint16_t m_BCId; + + uint16_t m_Results1Size; + uint16_t m_Results2Size; + uint16_t m_RawDataSize; + uint16_t m_NbSweetCells1; + uint16_t m_NbSweetCells2; + uint16_t m_NbSamples; + uint32_t m_OnlineChecksum; + uint32_t m_OfflineChecksum; + + /** @brief ROD Status word */ + uint32_t m_Status; + + /** @brief SCA number for each samples */ + std::vector<uint16_t> m_SCA; + + /** @brief FEB Control word 1 */ + std::vector<uint16_t> m_Ctrl1; + + /** @Brief FEB Control word 2 */ + std::vector<uint16_t> m_Ctrl2; + + /** @brief FEB Control word 3 */ + std::vector<uint16_t> m_Ctrl3; +}; + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeaderContainer.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeaderContainer.h new file mode 100755 index 00000000000..0ac4d7fac6c --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArFebHeaderContainer.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARFEBHEADERCONTAINER_H +#define LARFEBHEADERCONTAINER_H + +#include "DataModel/DataVector.h" +#include "CLIDSvc/CLASS_DEF.h" +#include "LArRawEvent/LArFebHeader.h" + +/** + @class LArFebHeaderContainer + @brief Container class for LArFebHeader + * + * Publicly inherits from ATHENA ObjectVector<br> + * @author Walter Lampl + +*/ +class LArFebHeaderContainer : public DataVector<LArFebHeader> { + + public : + + /** @brief Constructor */ + LArFebHeaderContainer() : DataVector<LArFebHeader>() { } + +/** + * destructor + */ + virtual ~LArFebHeaderContainer() { } +private: + + /** @link aggregation + * @supplierCardinality 1..* + * @clientRole holds + * @clientCardinality 1*/ + /*# LArFebHeader lnkLArFebHeader; */ +} ; + + +CLASS_DEF(LArFebHeaderContainer,1295914285,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResults.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResults.h new file mode 100644 index 00000000000..66bf8a6d807 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResults.h @@ -0,0 +1,194 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//Dear emacs, this is -*-c++-*- +#ifndef LAROFITERRESULTS_H +#define LAROFITERRESULTS_H + +#include "Identifier/HWIdentifier.h" +#include "CaloIdentifier/CaloGain.h" + +class LArOFPeakRecoTool; + +class LArOFIterResults { + + public: + friend class LArOFPeakRecoTool; + // Default Constructor + LArOFIterResults(); + + // Useful Constructor + LArOFIterResults( HWIdentifier chid, + CaloGain::CaloGain gain, + bool valid, + bool converged, + int nIterPerf, + float amplitude, + float tau, + unsigned peakSample_init, + unsigned peakSample_final, + float delay_final, + float quality , + unsigned int ofcIndex + ); + + // Destructor + virtual ~LArOFIterResults() {}; + + // Return Functions given below inline + HWIdentifier getChannelID() const; + CaloGain::CaloGain getGain() const; + bool getValid() const; + bool getConverged() const; + int getNIterPerf() const; + float getAmplitude() const; + float getTau() const; + unsigned getPeakSample_init() const; + unsigned getPeakSample_final() const; + float getDelay_final() const; + float getQuality() const; + unsigned getOFCIndex() const; + + // Set Functions given in cxx + void setChannelID( HWIdentifier chid ); + void setGain( CaloGain::CaloGain gain ); + void setValid( bool valid ); + void setConverged( bool converged ); + void setNIterPerf( int nIterPerf ); + void setAmplitude( float amplitude); + void setTau( float tau ); + void setPeakSample_init( unsigned peakSample_init ); + void setPeakSample_final( unsigned peakSample_final ); + void setDelay_final( float delay_final ); + void setQuality( float quality ); + void setOFCIndex(unsigned idx); + + private: + + // Hardware Identifier + HWIdentifier m_chid; + // Gain + CaloGain::CaloGain m_gain; + // Valid (was able to make an OFC computation) + bool m_valid; + // Converged (tau < timeBinWidth) + bool m_converged; + // Number of iterations performed + int m_nIterPerf; + // Amplitude determined by final OFC computation + float m_amplitude; + // Time determined by final OFC computation + float m_tau; + // Initial peakSample - input to LArOFPeakRecoTool::peak + unsigned m_peakSample_init; + // Final peakSample - may be different than initial if shift was required + unsigned m_peakSample_final; + // Final delay + float m_delay_final; + // Quality + float m_quality; + // Final OFC bin chosen by iteration + unsigned m_ofcIndex; + + +}; + +inline +LArOFIterResults::LArOFIterResults() + : + m_chid(0), + m_gain(CaloGain::CaloGain(4)), + m_valid(0), + m_converged(0), + m_nIterPerf(0), + m_amplitude(0), + m_tau(0), + m_peakSample_init(0), + m_peakSample_final(0), + m_delay_final(0), + m_quality(0), + m_ofcIndex(0) + +{} + +inline +LArOFIterResults::LArOFIterResults( HWIdentifier chid, + CaloGain::CaloGain gain, + bool valid, + bool converged, + int nIterPerf, + float amplitude, + float tau, + unsigned peakSample_init, + unsigned peakSample_final, + float delay_final, + float quality, + unsigned idx + ) + : + m_chid(chid), + m_gain(gain), + m_valid(valid), + m_converged(converged), + m_nIterPerf(nIterPerf), + m_amplitude(amplitude), + m_tau(tau), + m_peakSample_init(peakSample_init), + m_peakSample_final(peakSample_final), + m_delay_final(delay_final), + m_quality(quality), + m_ofcIndex(idx) + +{} + +inline +HWIdentifier +LArOFIterResults::getChannelID() const { return m_chid; } + +inline +CaloGain::CaloGain +LArOFIterResults::getGain() const { return m_gain; } + +inline +bool +LArOFIterResults::getValid() const { return m_valid; } + +inline +bool +LArOFIterResults::getConverged() const { return m_converged; } + +inline +int +LArOFIterResults::getNIterPerf() const { return m_nIterPerf; } + +inline +float +LArOFIterResults::getAmplitude() const { return m_amplitude; } + +inline +float +LArOFIterResults::getTau() const { return m_tau; } + +inline +unsigned +LArOFIterResults::getPeakSample_init() const { return m_peakSample_init; } + +inline +unsigned +LArOFIterResults::getPeakSample_final() const { return m_peakSample_final; } + +inline +float +LArOFIterResults::getDelay_final() const { return m_delay_final; } + +inline +float +LArOFIterResults::getQuality() const { return m_quality; } + +inline +unsigned +LArOFIterResults::getOFCIndex() const { return m_ofcIndex; } + + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResultsContainer.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResultsContainer.h new file mode 100644 index 00000000000..14dee5ed33e --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArOFIterResultsContainer.h @@ -0,0 +1,20 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//Dear emacs, this is -*-c++-*- + +#ifndef LAROFITERRESULTCONTAINER_H +#define LAROFITERRESULTCONTAINER_H + +#include <vector> +#include "LArRawEvent/LArOFIterResults.h" +#include "CLIDSvc/CLASS_DEF.h" + +class LArOFIterResultsContainer : public std::vector<LArOFIterResults> { + +}; + +CLASS_DEF(LArOFIterResultsContainer,1208025250,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArPedestal.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArPedestal.h new file mode 100755 index 00000000000..593473ee5c7 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArPedestal.h @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARPEDESTAL_H +#define LARPEDESTAL_H +/******************************************************************** + + NAME: LArPedestal.h + PACKAGE: offline/LArCalorimeter/LArRawEvent + + AUTHORS: M. AHARROUCHE + CREATED: Jan. 12, 2004 + UPDATED: Mar. 10, 2004 by Remi Lafaye + + PURPOSE: Interchanges the data with LArPedestalMaker for + calculation of pedestal and rms. + + ********************************************************************/ +// Include files +#include <string> +#include <vector> +#include <math.h> +#include <stdint.h> + +class LArPedestal +{ + private: + + // Lower bound of window + short m_min; + // Upper bound of window + short m_max; + // Sum of components + std::vector<uint32_t> m_sum; + // Sum of squares + std::vector<uint64_t> m_sumSquares; + // Event counter + uint32_t m_nped; + + public: + + // Constructor + LArPedestal(); + // Destructor + ~LArPedestal(); + + // Reset m_sum, m_matrix and m_nped + void zero(); + + // Set lower value + void set_min(const short min); + + // Set upper value + void set_max(const short max); + + // Get number of entries + inline int get_nentries() const { return m_nped; } + + // Get sum + double get_sum() const; + double get_sum(const unsigned isample) const; + + // Get mean value + double get_mean() const; + double get_mean(const unsigned isample) const; + + // Get rms value + double get_rms() const; + double get_rms(const unsigned isample) const; + + // Get number of samples + inline unsigned get_nsamples() const { return m_sum.size();} + + // Get lower value + inline const short& get_min() const { return m_min; } + + // Get uper value + inline const short& get_max() const { return m_max; } + + // Fill the m_sum and m_matrix vector + void add(const std::vector<short>& samples); + +}; + +#endif + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannel.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannel.h new file mode 100755 index 00000000000..d824feebd25 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannel.h @@ -0,0 +1,180 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LArRawChannel_H +#define LArRawChannel_H + +#include "Identifier/HWIdentifier.h" +#include "CaloIdentifier/CaloGain.h" +#include <stdint.h> + +// Gaudi Class ID + +// static const CLID CLID_LArRawChannel = 2722 ; + +/** +@class LArRawChannel +@brief Liquid Argon ROD output object base class + +This class holds the output of a liquid argon channel when it is +processed through the RODS +* +* Objects of this type are readonly <br> +* @author Kin Yip +* +* ---------------------------- +* move to DataVector +* Hong Ma +* @version 00-00-02 +* +* ----------------------------- +* Add raw channel gain information 25/09/2003 +* G.Unal +* +* ---------------------------- +* Move to HWIdentifier 10/2/2004 +* W. Lampl +* +*/ +class LArRawChannel { + +public: + + /** @brief default constructor for persistenty */ + LArRawChannel(); + + /** @brief useful constructor + @param[in] chan_id Online identifier of channel + @param[in] energy Energy in MeV + @param[in] time time in ps + @param[in] quality Quality from pulse reconstruction + @param[in] provenance Provenance of pulse reconstruction + @param[in] gain Gain + */ + LArRawChannel( HWIdentifier chan_id, + int energy, + int time, + uint16_t quality, + uint16_t provenance, + CaloGain::CaloGain gain); + + + /** @brief destructor */ + virtual ~LArRawChannel() { }; + + /** @return online identifier */ + HWIdentifier identify() const; + + /** @return online identifier */ + HWIdentifier channelID() const; + const HWIdentifier& hardwareID() const; + + /** @return energy in MeV (rounded to integer) */ + int energy() const; + + /** @return time in ps (rounded to integer) */ + int time() const; + + /** @return quality from pulse reconstruction */ + uint16_t quality() const; + + /** @return Provenance of pulse reconstruction */ + uint16_t provenance() const; + + /** @return gain */ + CaloGain::CaloGain gain() const; + +private: + + /** online identifier */ + HWIdentifier m_channelID; + /** energy in MeV */ + int m_energy; + /** time in ps */ + int m_time; + /** quality/provenance from pulse reconstruction */ + +// Reflex doesn't handle unions completely correctly. +// If you have a union as a data member, it will print a warning +// at runtime. So, hide the union from reflex. (Only m_quality is used +// in inlined code.) +#ifdef __REFLEX__ + int m_quality ; +# define m_qualProv ((uint16_t*)&m_quality) +#else + union { + int m_quality ; + uint16_t m_qualProv[2]; + }; +#endif + + /** gain information */ + CaloGain::CaloGain m_gain; + +}; + + +/// inlines + +inline +LArRawChannel::LArRawChannel() + : + m_channelID(0), + m_energy(0), + m_time(0), + m_quality(0), + m_gain(CaloGain::CaloGain(4)) +{ } + +inline +LArRawChannel::LArRawChannel( HWIdentifier chan_id, + int energy, + int time, + uint16_t quality, + uint16_t provenance, + CaloGain::CaloGain gain) + : + m_channelID(chan_id), + m_energy(energy), + m_time(time), + m_gain(gain) +{ m_qualProv[0] = quality; + m_qualProv[1] = provenance; +} + +inline +HWIdentifier +LArRawChannel::identify() const { return m_channelID ; } + +inline +HWIdentifier +LArRawChannel::channelID() const { return m_channelID; } + +inline +const HWIdentifier & +LArRawChannel::hardwareID() const {return m_channelID; } + +inline +int +LArRawChannel::energy() const { return m_energy; } + +inline +int +LArRawChannel::time() const { return m_time; } + +inline +uint16_t +LArRawChannel::quality() const { return m_qualProv[0]; } + +inline +uint16_t +LArRawChannel::provenance() const { return m_qualProv[1]; } + +inline +CaloGain::CaloGain +LArRawChannel::gain() const { return m_gain;} + +#endif + + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannelContainer.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannelContainer.h new file mode 100755 index 00000000000..f09a9095db9 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawChannelContainer.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +//Dear emacs, this is -*-c++-*- + +#ifndef LArRawchannelContainer_H +#define LArRawchannelContainer_H + +#include "LArRawEvent/LArRawChannel.h" +#include "CLIDSvc/CLASS_DEF.h" +#include <vector> + +/** +@class LArRawChannelContainer +@brief Container for LArRawChannel (IDC using LArRawChannelCollection) + * + * The LArRawChannel collections are sorted by FEBs + * @author Kin Yip + * @author Hong Ma + * @author Walter Lampl + * + * Modification Feb 2008: use plain std::vector, no sub-structure any more + */ +class LArRawChannelContainer : public std::vector<LArRawChannel> +{ + + public: + /** constructor */ + LArRawChannelContainer() {} ; + + /** desctructor */ + virtual ~LArRawChannelContainer() { }; + + inline void add (const LArRawChannel& rc) + {this->push_back(rc);} + +}; + +CLASS_DEF(LArRawChannelContainer,2721,0) + + //The following #define should help in the migration from Identifiable LArRawChannelContainer + //to the new version. It's allow frequently changing clients like LArMonTools to have the same + //code compiling against 13.X.Y and 14.0.0 +#define LARRAWCHANNELCONTAINER_IS_NOT_IDENTIFIABLE + + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawEventDict.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawEventDict.h new file mode 100755 index 00000000000..70280fc789f --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArRawEventDict.h @@ -0,0 +1,12 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "LArRawEvent/LArRawChannel.h" +#include "LArRawEvent/LArDigit.h" +#include "LArRawEvent/LArDigitContainer.h" +#include "LArRawEvent/LArTTL1.h" +#include "LArRawEvent/LArTTL1Container.h" +#include "LArRawEvent/LArFebErrorSummary.h" +//#include "LArRawEvent/LArRawChannelContainer.h" diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1.h new file mode 100755 index 00000000000..f2538200db8 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// * author : Fabienne Ledroit * +// * date of creation : 09/01/2003 * +// * last change 05 april 2004 (FL): added offline id and changed double to float * + + +#ifndef LARTTL1_H +#define LARTTL1_H +#include <vector> + +#include "Identifier/Identifier.h" +#include "Identifier/HWIdentifier.h" + + +/** +@class LArTTL1 +@brief Liquid Argon TT L1 sum base class + + * It's a TES object which is readonly + +@author Fabienne Ledroit + * + * sampleValues contains 7 samplings. + */ + +class LArTTL1 { + +public: + + + /** Constructor <br><br> + * Beware that sampleValues is a reference to a STL vector of float's <br> + * which is filled by a series of push_back calls .<br> + * Using another construction method of this vector will fail . <br> + * Now carries both online and offline Id. One is to be removed when we decide which one <br><br> */ + LArTTL1(const HWIdentifier& onlineId, const Identifier& offlineId, const std::vector<float>& sampleValues); + + /** return LArTTChannelID (online Id) */ + const HWIdentifier & ttOnlineID() const; + + /** return TT offline Identifier */ + const Identifier & ttOfflineID() const; + + /** return number of samples */ + short nsamples() const; + + /** return a reference to a stl vector containing the sample values */ + const std::vector<float> & samples() const; + + /** Destructor */ + virtual ~LArTTL1(); + + /** default constructor for persistency */ + LArTTL1(); + +private: + + /** online Id */ + HWIdentifier m_onlineId ; + + /** offline Id (CaloLVL1_ID) */ + Identifier m_offlineId; + + /** vector of samples */ + std::vector <float> m_samples; + +}; + +#endif //LARTTL1_H + diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1Container.h b/LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1Container.h new file mode 100755 index 00000000000..80f4f5d4b20 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/LArTTL1Container.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// * author : Fabienne Ledroit * +// * date of creation : 09/01/2003 * + +#ifndef LARTTL1CONTAINER_H +#define LARTTL1CONTAINER_H + +#include "DataModel/DataVector.h" +#include "CLIDSvc/CLASS_DEF.h" +#include "LArRawEvent/LArTTL1.h" + +//#ifndef CLIDSVC_CLASSDEF_H +//#include "CLIDSvc/CLASS_DEF.h" +//#endif + + +/** +@class LArTTL1Container +@brief Container class for LArTTL1 + * + * Publicly inherits from ATHENA ObjectVector<br> + * @author Fabienne Ledroit + */ + +class LArTTL1Container : public DataVector<LArTTL1> { + + public : +/** + * constructor + */ + + LArTTL1Container(); + +/** + * destructor + */ + virtual ~LArTTL1Container(); + +private: + +} ; + + +CLASS_DEF(LArTTL1Container,2771,0) + +#endif diff --git a/LArCalorimeter/LArRawEvent/LArRawEvent/selection.xml b/LArCalorimeter/LArRawEvent/LArRawEvent/selection.xml new file mode 100755 index 00000000000..785c3bd6150 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/LArRawEvent/selection.xml @@ -0,0 +1,32 @@ +<lcgdict> + +<!-- <class name="DataObject" > + <field name="m_pLinkMgr" transient="true" /> + <field name="m_pRegistry" transient="true" /> + <field name="m_refCount" transient="true" /> + <field name="m_version" transient="true" /> + </class> +--> + + + + <class name="LArDigit" /> + <class name="LArFebErrorSummary" /> + <class name="LArDigitContainer" id="B15FFDA0-206D-4062-8B5F-582A1ECD5502" /> + <class name="DataVector<LArDigit>" /> + <class name="std::vector<LArDigit*>" /> + +<!-- <class name="std::vector<float>" /> --> + <class name="LArTTL1Container" id="38FAECC7-D0C5-4DD8-8FAE-8D35F0542ECD" /> + <class name="DataVector<LArTTL1>" /> + <class name="std::vector<LArTTL1*>" /> + <class name="LArTTL1" > + <field name="m_onlineId" transient="true" /> + </class> + + +<!-- + Comments: +--> + +</lcgdict> diff --git a/LArCalorimeter/LArRawEvent/cmt/requirements b/LArCalorimeter/LArRawEvent/cmt/requirements new file mode 100755 index 00000000000..05d6dfd27ce --- /dev/null +++ b/LArCalorimeter/LArRawEvent/cmt/requirements @@ -0,0 +1,29 @@ +package LArRawEvent + +author Srini Rajagopalan <srinir@bnl.gov> +author Kin Yip <kinyip@bnl.gov> +author Hong Ma <hma@bnl.gov> + +use AtlasPolicy AtlasPolicy-* +use AtlasCLHEP AtlasCLHEP-* External +use CaloIdentifier CaloIdentifier-* Calorimeter +use CLIDSvc CLIDSvc-* Control +use DataModel DataModel-* Control + +use Identifier Identifier-* DetectorDescription + + + +private +use AtlasReflex AtlasReflex-* External +use SGTools SGTools-* Control +end_private + +library LArRawEvent *.cxx +apply_pattern installed_library + +private + +apply_pattern lcgdict dict=LArRawEvent selectionfile=selection.xml \ +headerfiles=" ../LArRawEvent/LArRawEventDict.h" + diff --git a/LArCalorimeter/LArRawEvent/doc/mainpage.h b/LArCalorimeter/LArRawEvent/doc/mainpage.h new file mode 100755 index 00000000000..7e55bcd590a --- /dev/null +++ b/LArCalorimeter/LArRawEvent/doc/mainpage.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + +@mainpage LArRawEvent Package + +This package provides the RAW event data model classes for LArCalorimeter. + +@section LArRawEventDigit Digit related classes + +LArDigit is the output of the FEB (and hence the digitization package) describing the digitized waveform shape. +All LArDigits are stored in a LArDigitContainer <br> +LArCalibDigit is a LArDigit plus some information for electronics calibration data (DAC,delay,isPulsed). +All LArCalibDigits are stored in LArCalibDigitContainer <br> +LArAccumulatedCalibDigit is the result of the accumulation inside the DSP of LArCalibDigit. It saves the sum and the sum of the squares of the ADC counts for the accumulated events with the same calibration settings. All LArAccumulatedCalibDigits are stored in LArAccimulatedCalibDigitContainer <br> + +@section LArRawEventRawChannel Raw Channel related classes +LArRawChannel is the output of the ROD processing and contain the fitted waveform results. All LArRawChannel are stored in a LArRawChannelCollection. +Each LArRawChannelCollection corresponds to data in one ROB. Therefore a collection of LArRawChannelCollection is saved in an IdentifiableContainer called LArRawChannelContainer. + +@section LArRawEventTTL1 L1 trigger related classes +LArTTL1 is a digitized L1 trigger tower for the LAr. All LArTTL1 are stored in a LArTTL1Container. + +@section LArRawEventOther Other LArRawEvent classes + +*/ diff --git a/LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigit.cxx b/LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigit.cxx new file mode 100755 index 00000000000..cf703b2e20b --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigit.cxx @@ -0,0 +1,142 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArAccumulatedCalibDigit.h" +#include <math.h> +#include <iostream> +#include <limits> + +/** Destructor */ +LArAccumulatedCalibDigit::~LArAccumulatedCalibDigit() +{} + + +float LArAccumulatedCalibDigit::mean(const size_t i) const { + + if (i<m_sampleSum.size() && i<m_sample2Sum.size() && m_nTriggers>0) + return ((double)m_sampleSum[i])/((double)m_nTriggers); + else + return 0.0; +} + +float LArAccumulatedCalibDigit::RMS(const size_t i) const { + + if (i<m_sampleSum.size() && i<m_sample2Sum.size() && m_nTriggers>0) { + const double mean=((double)m_sampleSum[i])/((double)m_nTriggers); + const double rms2=((double)m_sample2Sum[i])/((double)m_nTriggers)-mean*mean; + if (rms2<=0.0) return 0.0; //W.L 2010-12-07 protect against FPE due to rounding error + return sqrt(rms2); + } + else + return 0.0; +} + + +std::vector<float> LArAccumulatedCalibDigit::mean() const { + + const size_t nS=m_sampleSum.size(); + std::vector<float> mean; + if (m_nTriggers==0) + return mean; + else { + mean.resize(nS,0.0); + for (size_t i=0;i<nS;++i) + mean[i]=((double)m_sampleSum[i])/((double)m_nTriggers); + return mean; + } +} + +std::vector<float> LArAccumulatedCalibDigit::RMS() const { + std::vector<float> rms; + const size_t nS=m_sampleSum.size(); + if (m_sample2Sum.size()!=nS || m_nTriggers==0) + return rms;// ERROR, return emtpy vector + + double mean=0; + double rms2=0; + rms.resize(nS,0.0); + + for (size_t i=0;i<nS;++i) { + mean=((double)m_sampleSum[i])/((double)m_nTriggers); + rms2=((double)m_sample2Sum[i])/((double)m_nTriggers)-mean*mean; + if (rms2<=0.0) //W.L 2010-12-07 protect against FPE due to rounding error + rms[i]=0.0; + else + rms[i]=sqrt(rms2); + } + return rms; +} + + + +void LArAccumulatedCalibDigit::setSampleSum(const std::vector < uint32_t >& sampleSum) { + m_sampleSum = sampleSum; +} + +void LArAccumulatedCalibDigit::setSample2Sum(const std::vector < uint32_t >& sample2Sum) { + m_sample2Sum = sample2Sum; +} + + +bool LArAccumulatedCalibDigit::setAddDigit(const std::vector<short>& samples) { + const size_t nS=samples.size(); + if (m_sampleSum.size()==0 && m_sample2Sum.size()==0) { + m_sampleSum.resize(nS,0); + m_sample2Sum.resize(nS,0); + } + else + if (m_sampleSum.size() != nS || m_sample2Sum.size() != nS) { + return false; //ERROR, number of samples doesn't match! + } + + for(size_t i=0;i<nS;++i) { + const uint32_t s2=samples[i]*samples[i]; + if (m_sampleSum[i]>=std::numeric_limits<uint32_t>::max()-samples[i]) { + return false; //ERROR, overflow! + } + if (m_sample2Sum[i]>=std::numeric_limits<uint32_t>::max()-s2) { + return false; //ERROR, overflow! + } + + m_sampleSum[i]+=samples[i]; + m_sample2Sum[i]+=s2; + ++m_nTriggers; + } + return true; +} + + + + +bool LArAccumulatedCalibDigit::setAddSubStep(const std::vector < uint32_t >& sampleSum, + const std::vector < uint32_t >& sample2Sum, const uint32_t nTriggerPerStep) { + + + const size_t nS=sampleSum.size(); + + if (m_sampleSum.size()==0 && m_sample2Sum.size()==0) { + m_sampleSum.resize(nS,0); + m_sample2Sum.resize(nS,0); + } + else + if (m_sampleSum.size() != nS || m_sample2Sum.size() != nS || sample2Sum.size() != nS) { + return false; //ERROR, number of samples doesn't match! + } + + for(size_t is=0; is<nS; is++) { + if (m_sampleSum[is]>=std::numeric_limits<uint32_t>::max()-sampleSum[is]) { + return false; //ERROR, overflow! + } + if (m_sample2Sum[is]>=std::numeric_limits<uint32_t>::max()-sample2Sum[is]) { + return false; //ERROR, overflow! + } + + m_sampleSum[is] += sampleSum[is]; + m_sample2Sum[is] += sample2Sum[is]; + } + + m_nTriggers += nTriggerPerStep; + return true; +} + diff --git a/LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigitContainer.cxx b/LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigitContainer.cxx new file mode 100755 index 00000000000..8c132bf26a5 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArAccumulatedCalibDigitContainer.cxx @@ -0,0 +1,15 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArAccumulatedCalibDigitContainer.h" +#include "CLHEP/Units/SystemOfUnits.h" + +LArAccumulatedCalibDigitContainer::LArAccumulatedCalibDigitContainer(SG::OwnershipPolicy ownPolicy ) : + DataVector<LArAccumulatedCalibDigit>(ownPolicy), + m_delayScale(1*CLHEP::ns), + m_ownPolicy(ownPolicy) +{} + +LArAccumulatedCalibDigitContainer::~LArAccumulatedCalibDigitContainer() +{} diff --git a/LArCalorimeter/LArRawEvent/src/LArAccumulatedDigit.cxx b/LArCalorimeter/LArRawEvent/src/LArAccumulatedDigit.cxx new file mode 100755 index 00000000000..ec133665496 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArAccumulatedDigit.cxx @@ -0,0 +1,263 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArAccumulatedDigit.h" +#include <math.h> +#include <iostream> + +/** default constructor for persistency */ +LArAccumulatedDigit::LArAccumulatedDigit() : + m_gain(CaloGain::UNKNOWNGAIN), m_nTrigger(0) +{} + +LArAccumulatedDigit::LArAccumulatedDigit(HWIdentifier & channel_value, + CaloGain::CaloGain gain_value, + const std::vector<uint32_t>& sampleSum_value, + const std::vector< uint32_t >& sampleSquare_value, + uint32_t nTrigger_value) : + m_hardwareID(channel_value), m_gain(gain_value), m_nTrigger(nTrigger_value) { + + const size_t nS=sampleSum_value.size(); + m_sampleSum.resize(nS); + for (size_t i=0;i<nS;++i) + m_sampleSum[i]=(uint64_t)sampleSum_value[i]; + + + const size_t nSS=sampleSquare_value.size(); + m_sampleSquare.resize(nSS); + for (size_t i=0;i<nSS;++i) + m_sampleSquare[i]=(uint64_t)sampleSquare_value[i]; +} + + /** @brief Constructor (second type)*/ +LArAccumulatedDigit::LArAccumulatedDigit(HWIdentifier & channel_value) +{ + m_hardwareID = channel_value; + m_gain = (CaloGain::CaloGain) 0; + m_nTrigger = 0; +} + +/** Destructor */ +LArAccumulatedDigit::~LArAccumulatedDigit() {} + + +float LArAccumulatedDigit::mean() const { + //float mean; + const size_t nS=m_sampleSum.size(); + const double n = nS*m_nTrigger; + if(n<=0) return 0; + uint64_t x=0; + for(size_t i=0;i<nS;i++) { + //std::cout << "Computing mean: " << x << " += " << m_sampleSum[i] << " [" << i << "] "; + x += m_sampleSum[i]; + //std::cout << " = " << x << std::endl; + } + //std::cout << x << " /= " << n << std::endl; + //mean = x/n; + //std::cout << " = " << mean << std::endl; + return x/n; +} + +float LArAccumulatedDigit::RMS() const +{ + const size_t nS=m_sampleSum.size(); + const double n = nS*m_nTrigger; + if(n<=0) return 0; + if(m_sampleSquare.size()<1) return 0; + + uint64_t x=0; + for(size_t i=0;i<nS;i++) + x += m_sampleSum[i]; + double mean2 = x/n; mean2=mean2*mean2; + const double rms2=m_sampleSquare[0]/n - mean2; + if (rms2<0.0) { //W.L 2010-12-07 protect against FPE due to rounding error + //std::cout << "ERROR negative squareroot:" << rms2 << std::endl; + return 0.0; + } + float rms = sqrt(rms2); + return rms; +} + +bool LArAccumulatedDigit::setAddDigit(const std::vector<short>& digit) { + const size_t nS=digit.size(); + if(nS!=m_sampleSum.size() || nS!=m_sampleSquare.size()) { + if (!m_nTrigger) + return false; + m_sampleSquare.resize(nS,0); + m_sampleSum.resize(nS,0); + }// end if object empty + + + for (size_t i=0;i<nS;++i) { + m_sampleSum[i]+=digit[i]; + for (size_t j=i;j<nS;++j) + m_sampleSquare[j]+=digit[i]*digit[j]; + } + ++m_nTrigger; + return true; +} + + + +bool LArAccumulatedDigit::setAddSubStep(const CaloGain::CaloGain gain_value, const HWIdentifier chid, + const std::vector<uint64_t> sampleSum, const std::vector <uint64_t> sampleSquare, + const unsigned nTrigger) +{ + size_t i; + + if(gain_value!=m_gain || chid!=m_hardwareID) { + if(m_nTrigger!=0) + return false; + m_gain=gain_value; + m_hardwareID=chid; + } + + + const size_t n = sampleSquare.size(); + if(n!=sampleSum.size()) + return false; // Can not accumulate if nsamples differs + if(n!=m_sampleSum.size() || n!=m_sampleSquare.size()) { + if(m_nTrigger!=0) + return false; // Can not accumulate if nsamples differs + m_sampleSquare.resize(n,0); + m_sampleSum.resize(n,0); + } + for(i=0;i<n;++i) + m_sampleSum[i] += sampleSum[i]; + + for(i=0;i<n;i++) + m_sampleSquare[i] += sampleSquare[i]; + + m_nTrigger += nTrigger; + return true; +} + + +void LArAccumulatedDigit::setAddSubStep(CaloGain::CaloGain gain_value, std::vector<uint32_t> sampleSum, + std::vector <uint32_t> sampleSquare, unsigned nTrigger) +{ + std::vector<uint64_t> tmpSum; + std::vector<uint64_t> tmpSquare; + unsigned i,n; + const size_t nS=m_sampleSum.size(); + if(gain_value!=m_gain) { + if(m_nTrigger!=0) + return; + m_gain=gain_value; + } + n = sampleSquare.size(); + if(n!=sampleSum.size()) + return; // Can not accumulate if nsamples differs + if(n!=nS) { + if(m_nTrigger!=0) + return; // Can not accumulate if nsamples differs + m_sampleSquare.resize(n,0); + m_sampleSum.resize(n,0); + } + + tmpSum.resize(n,0); + for(i=0;i<n;i++) { + tmpSum[i] = sampleSum[i]; + m_sampleSum[i] += sampleSum[i]; + } + + tmpSquare.resize(n,0); + for(i=0;i<n;i++) { + tmpSquare[i] = sampleSquare[i]; + m_sampleSquare[i] += sampleSquare[i]; + } + + m_nTrigger += nTrigger; + tmpSum.clear(); + tmpSquare.clear(); +} + +void LArAccumulatedDigit::setAddSubStep(CaloGain::CaloGain gain_value, std::vector<int32_t> sampleSum, + std::vector <int32_t> sampleSquare, unsigned nTrigger, + int32_t base) +{ + int64_t tmpBase; + std::vector<uint64_t> tmpSum; + std::vector<uint64_t> tmpSquare; + unsigned i,n; + const size_t nS=m_sampleSum.size(); + if(gain_value!=m_gain) { + if(m_nTrigger!=0) + return; + m_gain=gain_value; + } + n = sampleSquare.size(); + if(n!=sampleSum.size()) + return; // Can not accumulate if nsamples differs + if(n!=nS) { + if(m_nTrigger!=0) + return; // Can not accumulate if nsamples differs + m_sampleSquare.resize(n,0); + m_sampleSum.resize(n,0); + } + tmpBase = base; + tmpSum.resize(n,0); + for(i=0;i<n;i++) { + tmpSum[i] = (uint64_t) (sampleSum[i]+tmpBase); + m_sampleSum[i] += tmpSum[i]; + } + + tmpBase = static_cast<int64_t>(base)*base; + tmpSquare.resize(n,0); + for(i=0;i<n;i++) { + tmpSquare[i] = (uint64_t) (sampleSquare[i]+tmpBase); + m_sampleSquare[i] += tmpSquare[i]; + } + + m_nTrigger += nTrigger; + + tmpSum.clear(); + tmpSquare.clear(); +} + + +void LArAccumulatedDigit::getCov(std::vector<float>& cov, int normalize) const +{ + cov.clear(); + const double n = m_nTrigger; + const size_t nS=m_sampleSum.size(); + if(n<=0) return; + if(m_sampleSquare.size()!=nS) return; + + std::vector<double> mean2; + mean2.resize(nS); + for(size_t i=1;i<nS;i++) { + for(size_t j=i;j<nS;j++) { + mean2[i] += m_sampleSum[j-i]*m_sampleSum[j]; + } + mean2[i]/=n*n*(nS-i); + } + uint64_t temp_mean = 0; + double mean; + for(uint32_t i=0;i<nS;i++) + temp_mean += m_sampleSum[i]; + mean = temp_mean/((double) n*nS); + + if(normalize!=1) { // No mormalization send as is + for(size_t i=1;i<nS;i++) + cov.push_back( m_sampleSquare[i]/(n*(nS-i)) - mean2[i] ); + mean2.clear(); + return; + } + + //Normalize covariance elements if required + const double norm = m_sampleSquare[0]/(n*nS)-mean*mean; + //norm = sqrt(norm*norm); + if (norm==0.0) + cov.assign(nS-1,0.0); + else { + for(uint32_t i=1;i<nS;i++) { + cov.push_back((m_sampleSquare[i]/(n*(nS-i)) - mean2[i])/norm); + } + } + + mean2.clear(); + return; +} + diff --git a/LArCalorimeter/LArRawEvent/src/LArAccumulatedDigitContainer.cxx b/LArCalorimeter/LArRawEvent/src/LArAccumulatedDigitContainer.cxx new file mode 100755 index 00000000000..08ff2f4147b --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArAccumulatedDigitContainer.cxx @@ -0,0 +1,14 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArAccumulatedDigitContainer.h" + + +LArAccumulatedDigitContainer::LArAccumulatedDigitContainer(SG::OwnershipPolicy ownPolicy ) : + DataVector<LArAccumulatedDigit>(ownPolicy), + m_ownPolicy(ownPolicy),m_NStep(0),m_StepIndex(0) +{} + +LArAccumulatedDigitContainer::~LArAccumulatedDigitContainer() +{} diff --git a/LArCalorimeter/LArRawEvent/src/LArAutoCorr.cxx b/LArCalorimeter/LArRawEvent/src/LArAutoCorr.cxx new file mode 100644 index 00000000000..364a680bc53 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArAutoCorr.cxx @@ -0,0 +1,185 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: LArAutoCorr.cxx + PACKAGE: offline/LArCalorimeter/LArRawEvent + + AUTHORS: F.Tarrade + CREATED: Jan. 22th 2009 + + PURPOSE: Intermediate object used to handle data + to be used for calculation of autocorrelation + elements. + +********************************************************************/ +// Include files +#include "LArRawEvent/LArAutoCorr.h" + +//---------------------------------------------------------------------------- +void LArAutoCorr::set_min(const short min) +//---------------------------------------------------------------------------- +{ + m_min = min; +} + +//---------------------------------------------------------------------------- +void LArAutoCorr::set_max(const short max) +//---------------------------------------------------------------------------- +{ + m_max = max; +} + +//---------------------------------------------------------------------------- +int LArAutoCorr::get_nentries() const +//---------------------------------------------------------------------------- +{ + return m_nped; +} + + +//---------------------------------------------------------------------------- +const short & LArAutoCorr::get_min() const +//---------------------------------------------------------------------------- +{ + return m_min; +} + +//---------------------------------------------------------------------------- +const short & LArAutoCorr::get_max() const +//---------------------------------------------------------------------------- +{ + return m_max; +} + + +//---------------------------------------------------------------------------- +double LArAutoCorr::get_mean() const +//---------------------------------------------------------------------------- +{ + double mean = 0; + + int nsamples = m_sum.size(); + for(int i=0; i<nsamples; i++) + mean += m_sum[i]; + mean /= ((double)(nsamples*m_nped)); + + return mean; +} + + +//---------------------------------------------------------------------------- +const std::vector<double> & LArAutoCorr::get_cov(int m_normalize, int m_phys) +//---------------------------------------------------------------------------- +{ + int nsamples = m_sum.size(); + int k =0; + if (m_nped==0) return m_cov; + for(int i=0;i<nsamples;i++){ + for(int j=i;j<nsamples;j++,k++) + m_cov_temp[k]= (double)((m_matrix[k]/(m_nped)) - ((m_sum[i]*m_sum[j])/(m_nped*m_nped))); + } + + //MGV normalize covariance elements if required + if (m_normalize == 1 && m_phys == 0 ){ + k=0; + int si,sj; + si=0; + for(int i=0;i<nsamples;i++){ + sj=si; + for(int j=i;j<nsamples;j++,k++) { + if (m_sum[i]!=.0 && m_sum[j]!=.0) + m_cov_temp[k]= m_cov_temp[k]/(double)sqrt((m_matrix[si]/(m_nped)-(m_sum[i]*m_sum[i])/(m_nped*m_nped))*(m_matrix[sj]/(m_nped)-(m_sum[j]*m_sum[j])/(m_nped*m_nped))); + sj+=nsamples-j; + } + si+=nsamples-i; + } + } + //MGV + + if (m_phys==0) { + double sum; + int s; + for(int diag =1;diag<nsamples;diag++) + { + sum =0; + s = 0; + for(int i=0; i < nsamples-diag;i++) + { + sum += m_cov_temp[s + diag]; + s += nsamples - i; + } + sum = sum/(nsamples-diag); + m_cov[diag-1]= sum; + } + return m_cov; + } + else + return m_cov_temp; +} + +//---------------------------------------------------------------------------- +double LArAutoCorr::get_rms() const +//---------------------------------------------------------------------------- +{ + double x=0, y=0; + int k = 0; + int nsamples = m_sum.size(); + + for(int i=0; i<nsamples; i++) + { + x += m_sum[i]; + y += m_matrix[k]; + k += nsamples - i;// Index of diagonal element + } + + x/= (double) (nsamples*m_nped); + y/=(double) (nsamples*m_nped); + + double noise = sqrt(y- x*x); + + return noise; +} + +//---------------------------------------------------------------------------- +void LArAutoCorr::add(const std::vector<short>& samples, size_t maxnsamples) +//---------------------------------------------------------------------------- +{ + unsigned int nsamples = std::min(samples.size(),maxnsamples); + int k=0; + + if(m_sum.size()<nsamples) + { + + m_cov.resize(nsamples - 1); + m_cov_temp.resize((nsamples*(nsamples+1))/2); + m_sum.resize(nsamples); + m_matrix.resize((nsamples*(nsamples+1))/2); + } + + for(unsigned int i=0; i<nsamples; i++) + { + for(unsigned int j=i; j<nsamples; j++,k++) + m_matrix[k] += ((double)(samples[j]*samples[i])); + + m_sum[i] += ((double) samples[i]); + } + m_nped++; +} + +//---------------------------------------------------------------------------- +void LArAutoCorr::correl_zero() +//---------------------------------------------------------------------------- +{ + int j =0; + int nsamples = m_sum.size(); + for(int l=0; l<nsamples; l++) + { + for(int k=l; k<nsamples; k++,j++) + m_matrix[j] = 0; + m_sum[l]=0; + } + m_nped=0; +} diff --git a/LArCalorimeter/LArRawEvent/src/LArCalibDigit.cxx b/LArCalorimeter/LArRawEvent/src/LArCalibDigit.cxx new file mode 100755 index 00000000000..333254b91d9 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArCalibDigit.cxx @@ -0,0 +1,16 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArCalibDigit.h" + +/** Destructor */ +LArCalibDigit::~LArCalibDigit() +{} + +/** default constructor for persistency */ +LArCalibDigit::LArCalibDigit() + : LArDigit(), + m_DAC(0), + m_delayPulsed(0) +{} diff --git a/LArCalorimeter/LArRawEvent/src/LArCalibDigitContainer.cxx b/LArCalorimeter/LArRawEvent/src/LArCalibDigitContainer.cxx new file mode 100755 index 00000000000..a941415b3c6 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArCalibDigitContainer.cxx @@ -0,0 +1,8 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArCalibDigitContainer.h" + +LArCalibDigitContainer::~LArCalibDigitContainer() +{} diff --git a/LArCalorimeter/LArRawEvent/src/LArDigit.cxx b/LArCalorimeter/LArRawEvent/src/LArDigit.cxx new file mode 100755 index 00000000000..0e85860bdcd --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArDigit.cxx @@ -0,0 +1,75 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include <typeinfo> +#include <stdio.h> + +#include "LArRawEvent/LArDigit.h" + + +// default constructor +LArDigit::LArDigit() : + m_gain(CaloGain:: UNKNOWNGAIN) +{} + +LArDigit::operator std::string() const{ + /* + LArCablingService * cablingService = LArCablingService::getInstance() ; + + if( cablingService == 0 ) { + std::string error_message = "Unable to get cabling Service for printing HardwareID" ; + return error_message ; + } + */ + + char * stSamples = new char[20] ; + char * stGain = new char[20] ; + char * stNumberOfSamples = new char[30] ; + char * classNameOfDigit = new char[48] ; + + const char * stname = typeid( *this ).name() ; + int lname ; + sscanf( stname , "%d%s" , &lname , classNameOfDigit ) ; + + + sprintf( stNumberOfSamples , "# of samples = %d " , this->nsamples() ) ; + sprintf( stGain , "gain = %d " , this->gain() ) ; + + + std::string digitString = classNameOfDigit ; + /* + if( m_ChannelID.id() == 0x80000000 ) { + digitString += " in cell " ; + digitString += this->cellID().getString() ; // convert Identifier + } else { + digitString += " in channel " ; + digitString += cablingService->cnvToString( this->channelID() ) ; // convert LArSignalChannelID + } + digitString += " "; + digitString += stNumberOfSamples ; + digitString += stGain ; + digitString += "samples = " ; + const std::vector<short> & l_samples = this->samples() ; + int l_nsamples = this->nsamples() ; + for(int i = 0 ; i < l_nsamples ; i++ ) { // loop over sample values + sprintf( stSamples , "%d " , l_samples[i] ) ; + digitString += stSamples ; + } + */ + delete[] stSamples ; + delete[] stGain ; + delete[] classNameOfDigit ; + delete[] stNumberOfSamples ; + + return digitString ; + + +} + +// set method +void LArDigit::setSamples(std::vector<short> samples) +{ + m_samples.clear(); + m_samples = samples; +} diff --git a/LArCalorimeter/LArRawEvent/src/LArDigitContainer.cxx b/LArCalorimeter/LArRawEvent/src/LArDigitContainer.cxx new file mode 100755 index 00000000000..114ae10f2f3 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArDigitContainer.cxx @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArDigitContainer.h" +#include "SGTools/BaseInfo.h" +#include <stdio.h> +#include <typeinfo> + + + +LArDigitContainer::operator std::string () const { + + char * stCounter = new char[48] ; + char * nameOfContainer = new char[48] ; + + const char * stname = typeid( *this ).name() ; + int lname ; + sscanf( stname , "%d%s" , &lname , nameOfContainer ) ; + + std::string newline( "\n" ) ; + std::string digitContainerString = nameOfContainer ; + digitContainerString += ": content " ; + digitContainerString += newline ; + + LArDigitContainer::const_iterator it ; + int counter = 0 ; + const LArDigit * digit ; + + for(it = this->begin() ; it != this->end() ; it++ ){ // Loop over Hits + + digit = *it ; + + sprintf( stCounter , "%d" , counter ) ; + + digitContainerString += "LArDigit[" ; + digitContainerString += stCounter ; + digitContainerString += "] = " ; + digitContainerString += (std::string) (*digit) ; + digitContainerString += newline ; + + counter ++ ; + + } + + sprintf( stCounter , "%d" , counter ) ; + digitContainerString += newline ; + digitContainerString += "Number of Digits in this container : " ; + digitContainerString += stCounter ; + + + delete[] stCounter ; + delete[] nameOfContainer ; + + return digitContainerString ; + +} + +SG_ADD_BASE (LArDigitContainer, DataVector<LArDigit> ); diff --git a/LArCalorimeter/LArRawEvent/src/LArFebErrorSummary.cxx b/LArCalorimeter/LArRawEvent/src/LArFebErrorSummary.cxx new file mode 100644 index 00000000000..0ef4c543f59 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArFebErrorSummary.cxx @@ -0,0 +1,75 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArFebErrorSummary.h" + +// static constants +std::string LArFebErrorSummary::m_errorStrings[N_LArFebErrorType] = { + "Parity","BCID","SampleHeader","EVTID","ScacStatus","ScaOutOfRange", + "GainMismatch","TypeMismatch","NumOfSamples","EmptyDataBlock","DspBlockSize","CheckSum", "MissingHeader", + "BadGain" } ; + + +//Constructor +LArFebErrorSummary::LArFebErrorSummary() { + +} + +LArFebErrorSummary::~LArFebErrorSummary() +{} + +uint16_t LArFebErrorSummary::feb_error(HWIdentifier id) const +{ + + std::map<unsigned int ,uint16_t>::const_iterator it = m_feb_errors.find(id.get_identifier32().get_compact() ) ; + + if (it!=m_feb_errors.end() ) { + return (*it).second ; + } + + return 0; + +} + + +bool LArFebErrorSummary::set_feb_error( unsigned int id, uint16_t error) { + + std::map<unsigned int, uint16_t>::const_iterator it = m_feb_errors.find(id) ; + + if (it!=m_feb_errors.end() ) { + return false; + } + + m_feb_errors[id]= error; + + return true ; +} + +const std::map<unsigned int,uint16_t>& LArFebErrorSummary::get_all_febs() const +{ + return m_feb_errors; +} + +void LArFebErrorSummary::clear() +{ + m_feb_errors.clear(); + return; +} + + +std::string LArFebErrorSummary::error_to_string(uint16_t error ) +{ + std::string str_err; + for (int i=0;i<N_LArFebErrorType;i++) + { + if ( error & (1<<i) ) + { + if (str_err!="") str_err+=":" ; + str_err = str_err+m_errorStrings[i]; + } + } + + return str_err; + +} diff --git a/LArCalorimeter/LArRawEvent/src/LArFebHeader.cxx b/LArCalorimeter/LArRawEvent/src/LArFebHeader.cxx new file mode 100755 index 00000000000..1066edd115c --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArFebHeader.cxx @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArFebHeader.h" + +//Constructor +LArFebHeader::LArFebHeader(const HWIdentifier febid):m_FEBId(febid) { + m_RodHeader.FormatVersion=0; + m_RodHeader.SourceId=0; + m_RodHeader.RunNumber=0; + m_RodHeader.ELVL1Id=0; + m_RodHeader.BCId=0; + m_RodHeader.LVL1TigType=0; + m_RodHeader.DetEventType=0; + + m_DspHeader.CodeVersion=0; + m_DspHeader.EventCounter=0; + + m_ELVL1Id=0; + m_BCId=0; + m_Status=0; + + m_Results1Size=0; + m_Results2Size=0; + m_RawDataSize=0; + m_NbSweetCells1=0; + m_NbSweetCells2=0; + m_NbSamples=0; + m_OfflineChecksum=0; + m_OnlineChecksum=1; + return; +} + +LArFebHeader::~LArFebHeader() +{} + +int LArFebHeader::degray(int x) +{ // like explained in: http://mathworld.wolfram.com/GrayCode.html + + int i,j,sum; + + if ( x==138 ) return 141; + else if ( x== 136 ) return 142; + else if ( x== 128 ) return 143; + else { + for (i=0; i<32; i++) + { + sum=0; + for (j=i+1; j<32; j++) + { + sum += (x>>j)&0x1; + } + // printf("x=%8x sum=%d\n",x,sum ); + + if (sum%2) { + if (x&(1<<i)) + { + unsigned int tmp1,tmp2=0; + tmp1 = (x>>(i+1))<<(i+1); + if (i>0) + tmp2 = x & ((1<<i)-1); + // printf("tmp1 =%x tmp2=%x\n",tmp1,tmp2 ); + + x=tmp1|tmp2; + } + else + x |= (1<<i); + } + } + return x; + } +} diff --git a/LArCalorimeter/LArRawEvent/src/LArOFIterResults.cxx b/LArCalorimeter/LArRawEvent/src/LArOFIterResults.cxx new file mode 100644 index 00000000000..8b78bbf5478 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArOFIterResults.cxx @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + + +#include "LArRawEvent/LArOFIterResults.h" + +// Set Methods + +void LArOFIterResults::setChannelID( HWIdentifier chid ){ + m_chid = chid; +} + +void LArOFIterResults::setGain( CaloGain::CaloGain gain ){ + m_gain = gain; +} + +void LArOFIterResults::setValid( bool valid ){ + m_valid = valid; +} + +void LArOFIterResults::setConverged( bool converged ){ + m_converged = converged; +} + +void LArOFIterResults::setNIterPerf( int nIterPerf ){ + m_nIterPerf = nIterPerf; +} + +void LArOFIterResults::setAmplitude( float amplitude){ + m_amplitude = amplitude; +} + +void LArOFIterResults::setTau( float tau ){ + m_tau = tau; +} + +void LArOFIterResults::setPeakSample_init( unsigned peakSample_init ){ + m_peakSample_init = peakSample_init; +} + +void LArOFIterResults::setPeakSample_final( unsigned peakSample_final ){ + m_peakSample_final = peakSample_final; +} + +void LArOFIterResults::setDelay_final( float delay_final ){ + m_delay_final = delay_final; +} + +void LArOFIterResults::setQuality( float quality ){ + m_quality = quality; +} + + +void LArOFIterResults::setOFCIndex(unsigned idx) { + m_ofcIndex = idx; +} diff --git a/LArCalorimeter/LArRawEvent/src/LArPedestal.cxx b/LArCalorimeter/LArRawEvent/src/LArPedestal.cxx new file mode 100755 index 00000000000..e82b7384681 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArPedestal.cxx @@ -0,0 +1,163 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: LArPedestal.cxx + PACKAGE: offline/LArCalorimeter/LArRawEvent + + AUTHORS: M. AHARROUCHE + CREATED: Jan. 12, 2004 + UPDATED: Mar. 09, 2004 Remi Lafaye + + PURPOSE: Interchanges the data with LArPedestalMaker for + calculation of pedestal and rms. + + ********************************************************************/ +#include "CaloIdentifier/CaloGain.h" +#include "LArRawEvent/LArPedestal.h" +#include <iostream> + +//---------------------------------------------------------------------------- +LArPedestal::LArPedestal() +//---------------------------------------------------------------------------- +{ + m_min = -1; + m_max = -1; + m_nped = 0; +} + +//---------------------------------------------------------------------------- +LArPedestal::~LArPedestal() +//---------------------------------------------------------------------------- +{ +} + +//---------------------------------------------------------------------------- +void LArPedestal::set_min(const short min) +//---------------------------------------------------------------------------- +{ + m_min = min; +} + +//---------------------------------------------------------------------------- +void LArPedestal::set_max(const short max) +//---------------------------------------------------------------------------- +{ + m_max = max; +} + +//---------------------------------------------------------------------------- +double LArPedestal::get_sum(const unsigned isample) const +//---------------------------------------------------------------------------- +{ + if (isample>=m_sum.size()) + return 0; + + return m_sum[isample]; +} + +//---------------------------------------------------------------------------- +double LArPedestal::get_sum() const +//---------------------------------------------------------------------------- +{ + double sum = 0; + int nsamples = m_sum.size(); + for(int i=0; i<nsamples; i++) + sum += m_sum[i]; + + return sum; +} + +//---------------------------------------------------------------------------- +double LArPedestal::get_mean(const unsigned isample) const +//---------------------------------------------------------------------------- +{ + if (isample>=m_sum.size() || m_nped==0) + return 0; + double mean = 0; + mean = m_sum[isample]; + mean /= ((double) m_nped); + + return mean; +} + +//---------------------------------------------------------------------------- +double LArPedestal::get_mean() const +//---------------------------------------------------------------------------- +{ + const int nsamples = m_sum.size(); + if (nsamples==0 || m_nped==0) return 0; + uint32_t imean = 0; + for(int i=0; i<nsamples; i++) + imean += m_sum[i]; + + return double(imean)/(nsamples*m_nped); + + +} + + +//---------------------------------------------------------------------------- +double LArPedestal::get_rms(const unsigned isample) const +//---------------------------------------------------------------------------- +{ + if (isample>=m_sum.size() || m_nped==0) + return 0; + //const int nsamples = m_sum.size(); + const double x = m_sum[isample]/double(m_nped); + const double y = m_sumSquares[isample]/double(m_nped);; + return sqrt(y-x*x); +} + +//---------------------------------------------------------------------------- +double LArPedestal::get_rms() const +//---------------------------------------------------------------------------- +{ + const int nsamples = m_sum.size(); + if (nsamples==0 || m_nped==0) return 0; + uint64_t x=0, y=0; + for(int i=0; i<nsamples; i++) { + x+=m_sum[i]; + y+=m_sumSquares[i]; + } + + const double mean=double(x)/(nsamples*m_nped); + const double ss=double(y)/(nsamples*m_nped); + return sqrt(ss-mean*mean); + //double noise=y-x*x + //return sqrt(noise/(m_nped*m_nped*nsamples*nsamples)); +} + +//---------------------------------------------------------------------------- +void LArPedestal::add(const std::vector<short>& samples) +//---------------------------------------------------------------------------- +{ + const size_t nsamples = samples.size(); + + if(m_sum.size()<nsamples) { + m_sum.resize(nsamples); + m_sumSquares.resize(nsamples); + } + + for(size_t i=0; i<nsamples; i++) { + m_sum[i] += samples[i]; + m_sumSquares[i] += (samples[i]*samples[i]); + } + m_nped++; +} + +//---------------------------------------------------------------------------- +void LArPedestal::zero() +//---------------------------------------------------------------------------- +{ + const int nsamples = m_sum.size(); + for(int l=0; l<nsamples; l++) { + m_sumSquares[l] = 0; + m_sum[l]=0; + } + m_nped=0; +} + + diff --git a/LArCalorimeter/LArRawEvent/src/LArRawChannelContainer.cxx b/LArCalorimeter/LArRawEvent/src/LArRawChannelContainer.cxx new file mode 100755 index 00000000000..61dc275d667 --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArRawChannelContainer.cxx @@ -0,0 +1,10 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// implementation of LArRawChannelContainer + +#include "LArRawEvent/LArRawChannelContainer.h" + + + diff --git a/LArCalorimeter/LArRawEvent/src/LArTTL1.cxx b/LArCalorimeter/LArRawEvent/src/LArTTL1.cxx new file mode 100755 index 00000000000..2cc39b9308e --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArTTL1.cxx @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArTTL1.h" + +LArTTL1::LArTTL1(const HWIdentifier& onlineId, const Identifier& offlineId, const std::vector<float>& sampleValues): + m_onlineId(onlineId) , + m_offlineId(offlineId) , + m_samples(sampleValues) + { } + +const HWIdentifier& +LArTTL1::ttOnlineID() const +{ return m_onlineId; } + +const Identifier& +LArTTL1::ttOfflineID() const +{ return m_offlineId; } + +short +LArTTL1::nsamples() const +{ return m_samples.size(); } + +const std::vector<float> & +LArTTL1::samples() const +{ return m_samples; } + +LArTTL1::~LArTTL1() +{ } + +LArTTL1::LArTTL1() +{ } + diff --git a/LArCalorimeter/LArRawEvent/src/LArTTL1Container.cxx b/LArCalorimeter/LArRawEvent/src/LArTTL1Container.cxx new file mode 100755 index 00000000000..ff383804dda --- /dev/null +++ b/LArCalorimeter/LArRawEvent/src/LArTTL1Container.cxx @@ -0,0 +1,13 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArRawEvent/LArTTL1Container.h" + +LArTTL1Container::LArTTL1Container() : +DataVector<LArTTL1>() +{ } + +LArTTL1Container::~LArTTL1Container() +{ } + -- GitLab