Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-02 08:12:56

0001 #ifndef __MBD_MBDRAWHITV2_H__
0002 #define __MBD_MBDRAWHITV2_H__
0003 
0004 #include "MbdRawHit.h"
0005 
0006 #include <cmath>
0007 #include <iostream>
0008 #include <limits>
0009 
0010 class MbdRawHitV2 : public MbdRawHit
0011 {
0012  public:
0013   MbdRawHitV2() = default;
0014   ~MbdRawHitV2() override = default;
0015 
0016   //! Just does a clear
0017   void Reset() override;
0018 
0019   //! Clear is used by TClonesArray to reset the tower to initial state without calling destructor/constructor
0020   void Clear(Option_t* = "") override;
0021 
0022   //! PMT number
0023   Short_t get_pmt() const override { return bpmt; }
0024 
0025   //! ADC
0026   Float_t get_adc() const override { return badc; }
0027 
0028   //! TDC from time channel
0029   Float_t get_ttdc() const override { return bttdc; }
0030 
0031   //! TDC from charge channel
0032   Float_t get_qtdc() const override { return bqtdc; }
0033 
0034   //! Chi2/NDF from charge channel waveform fit
0035   Float_t get_chi2ndf() const override { return (fitstat&0xfff)/100.; }
0036 
0037   //! Info about charge channel waveform fit
0038   UShort_t get_fitinfo() const override { return (fitstat>>12); }
0039 
0040   //! Set PMT data values
0041   void set_pmt(const Short_t pmt, const Float_t a, const Float_t tt, const Float_t tq) override
0042   {
0043     bpmt = pmt;
0044     badc = a;
0045     bttdc = tt;
0046     bqtdc = tq;
0047   }
0048 
0049   //! Store chi2/ndf (encoded in fitstat)
0050   void set_chi2ndf(const Double_t chi2ndf) override
0051   {
0052     UShort_t us_chi2ndf = 0;
0053     if (std::isfinite(chi2ndf) && chi2ndf > 0.)
0054     {
0055       const Double_t clipped = (chi2ndf > 40.95) ? 40.95 : chi2ndf;
0056       us_chi2ndf = static_cast<UShort_t>(clipped * 100.);
0057     }
0058     fitstat &= 0xf000;
0059     fitstat |= us_chi2ndf;
0060   }
0061 
0062   //! Store fitinfo (encoded in fitstat)
0063   void set_fitinfo(const UShort_t fitinfo) override
0064   {
0065     fitstat &= 0xfff;
0066     fitstat |= (fitinfo<<12);
0067   }
0068 
0069   //! Prints out exact identity of object
0070   void identify(std::ostream& out = std::cout) const override;
0071 
0072   //! isValid returns non zero if object contains valid data
0073   virtual int isValid() const override
0074   {
0075     if (std::isnan(get_ttdc())) return 0;
0076     return 1;
0077   }
0078 
0079  private:
0080   Short_t  bpmt;
0081   UShort_t fitstat; //waveform fit status
0082   Float_t  badc;
0083   Float_t  bttdc;
0084   Float_t  bqtdc;
0085 
0086   ClassDefOverride(MbdRawHitV2, 1)
0087 };
0088 
0089 #endif