Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:53

0001 #ifndef MICROMEGAS_MICROMEGASCALIBRATIONDATA_H
0002 #define MICROMEGAS_MICROMEGASCALIBRATIONDATA_H
0003 
0004 /*!
0005  * \file MicromegasCalibrationData.h
0006  * \author Hugo Pereira Da Costa <hugo.pereira-da-costa@cea.fr>
0007  */
0008 
0009 #include <trackbase/TrkrDefs.h>
0010 
0011 #include <array>
0012 #include <map>
0013 #include <string>
0014 
0015 /// micromegas calibration data
0016 class MicromegasCalibrationData
0017 {
0018   public:
0019 
0020   /// constructor
0021   MicromegasCalibrationData() = default;
0022 
0023   ///@name modifiers
0024   //@{
0025 
0026   /// read calibration from file
0027   void read( const std::string& /*filename*/ );
0028 
0029   /// set pedestal for a given channel
0030   void set_pedestal( int /*fee*/, int /*channel*/, double /*value*/ );
0031 
0032   /// set rms for a given channel
0033   void set_rms( int /*fee*/, int /*channel*/, double /*value*/ );
0034 
0035   //@}
0036 
0037   //!@name accessors
0038   //@{
0039 
0040   /// write calibration to file
0041   void write( const std::string& /*filename*/ ) const;
0042 
0043   /// get pedestal for a given feeid and channel
0044   double get_pedestal( int /*fee*/, int /*channel*/ ) const;
0045 
0046   /// get rms for a given feeid and channel
0047   double get_rms( int /*fee*/, int /*channel*/ ) const;
0048 
0049   /// get pedestal for a given hitsetkey and strip
0050   double get_pedestal_mapped( TrkrDefs::hitsetkey /*hitsetkey*/, int /*strip*/ ) const;
0051 
0052   /// get rms for a given hitsetkey and strip
0053   double get_rms_mapped( TrkrDefs::hitsetkey /*hitsetkey*/, int /*strip*/ ) const;
0054 
0055   //@}
0056 
0057   private:
0058 
0059   /// simple structure to store calibration data
0060   class calibration_data_t
0061   {
0062     public:
0063 
0064     calibration_data_t() = default;
0065 
0066     calibration_data_t( double pedestal, double rms ):
0067       m_pedestal( pedestal ),
0068       m_rms( rms )
0069     {}
0070 
0071     double m_pedestal = 0;
0072     double m_rms = 0;
0073   };
0074 
0075   static constexpr int m_nchannels_fee = 256;
0076   using calibration_vector_t = std::array<calibration_data_t,m_nchannels_fee>;
0077 
0078   /// map fee id to channel based calibration vector
0079   using raw_calibration_map_t = std::map<int, calibration_vector_t>;
0080   raw_calibration_map_t m_raw_calibration_map;
0081 
0082   /// map hitset key to strip based calibration vector
0083   using mapped_calibration_map_t = std::map<TrkrDefs::hitsetkey,calibration_vector_t>;
0084   mapped_calibration_map_t m_mapped_calibration_map;
0085 
0086   friend std::ostream& operator << (std::ostream&, const MicromegasCalibrationData& );
0087 
0088 };
0089 
0090 #endif