Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include "MbdOutV2.h"
0002 #include "MbdReturnCodes.h"
0003 
0004 #include <TClonesArray.h>
0005 
0006 #include <iostream>
0007 
0008 //______________________________________
0009 void MbdOutV2::Reset()
0010 {
0011   bz = std::numeric_limits<Float_t>::quiet_NaN();
0012   bzerr = std::numeric_limits<Float_t>::quiet_NaN();
0013   bt0 = std::numeric_limits<Float_t>::quiet_NaN();
0014   bt0err = std::numeric_limits<Float_t>::quiet_NaN();
0015   bns = 0.;
0016   bnn = 0.;
0017   bqs = 0.;
0018   bqn = 0.;
0019   bts = std::numeric_limits<Float_t>::quiet_NaN();
0020   btn = std::numeric_limits<Float_t>::quiet_NaN();
0021   evt = -1;
0022   clk = 0;
0023   femclk = 0;
0024 }
0025 
0026 //______________________________________
0027 int MbdOutV2::isValid() const
0028 {
0029   // compatible with old invalid setting of -9999.9
0030   return ((std::isfinite(bt0) && (bt0 > -9999.)) ? 1 : 0);
0031 }
0032 
0033 /*
0034 //______________________________________
0035 void MbdOutV2::Reset()
0036 {
0037   Init();
0038 }
0039 */
0040 
0041 //______________________________________
0042 void MbdOutV2::identify(std::ostream &out) const
0043 {
0044   out << "identify yourself: I am a MbdOutV2 object" << std::endl;
0045   out << "Vertex: " << bz << " Error: " << bzerr << std::endl;
0046   out << "T0: " << bt0 << " Error: " << bt0err << std::endl;
0047 }
0048 
0049 //______________________________________
0050 void MbdOutV2::set_t0(const Float_t t0, const Float_t t0err)
0051 {
0052   bt0 = t0;
0053   bt0err = t0err;
0054 }
0055 
0056 //______________________________________
0057 void MbdOutV2::set_zvtx(const Float_t vtx, const Float_t vtxerr)
0058 {
0059   bz = vtx;
0060   bzerr = vtxerr;
0061 }
0062 
0063 //______________________________________
0064 void MbdOutV2::set_zvtxerr(const Float_t vtxerr)
0065 {
0066   bzerr = vtxerr;
0067 }
0068 
0069 //______________________________________
0070 void MbdOutV2::set_arm(const int iarm, const Short_t npmt, const Float_t charge, const Float_t timing)
0071 {
0072   if (iarm == 0)
0073   {
0074     bns = npmt;
0075     bqs = charge;
0076     bts = timing;
0077   }
0078   else if (iarm == 1)
0079   {
0080     bnn = npmt;
0081     bqn = charge;
0082     btn = timing;
0083   }
0084   else
0085   {
0086     std::cerr << "MbdOutV2::set_arm(): ERROR, invalid arm " << iarm << std::endl;
0087   }
0088 }
0089 
0090 //______________________________________
0091 void MbdOutV2::set_clocks(const Int_t ievt, const UShort_t iclk, const UShort_t ifemclk)
0092 {
0093   evt = ievt;
0094   clk = iclk;
0095   femclk = ifemclk;
0096 }
0097 
0098 //______________________________________
0099 Short_t MbdOutV2::get_npmt(const int iarm) const
0100 {
0101   return (iarm == 0) ? bns : bnn;
0102 }
0103 
0104 //______________________________________
0105 Float_t MbdOutV2::get_q(const int iarm) const
0106 {
0107   return (iarm == 0) ? bqs : bqn;
0108 }
0109 
0110 Float_t MbdOutV2::get_time(const int iarm) const
0111 {
0112   return (iarm == 0) ? bts : btn;
0113 }
0114 
0115 Int_t MbdOutV2::get_evt() const
0116 {
0117   return evt;
0118 }
0119 
0120 UShort_t MbdOutV2::get_clock() const
0121 {
0122   return clk;
0123 }
0124 
0125 UShort_t MbdOutV2::get_femclock() const
0126 {
0127   return femclk;
0128 }
0129 
0130 void MbdOutV2::CopyTo(MbdOut *mbd)
0131 {
0132   mbd->set_t0(bt0, bt0err);
0133   mbd->set_zvtx(bz, bzerr);
0134 
0135   mbd->set_arm(0, bns, bqs, bts);
0136   mbd->set_arm(1, bnn, bqn, btn);
0137   
0138   mbd->set_clocks(evt, clk, femclk);
0139 }