Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:12

0001 /**
0002  * @file trackbase/TrkrHitSetTpc.cc
0003  * @author D. McGlinchey
0004  * @date June 2018
0005  * @brief Implementation of TrkrHitSetTpc
0006  */
0007 #include "TrkrHitSetTpc.h"
0008 #include "TrkrHit.h"
0009 
0010 #include <algorithm>
0011 #include <cassert>
0012 #include <cstdlib>  // for exit
0013 #include <iostream>
0014 #include <type_traits>  // for __decay_and_strip<>::__type
0015 
0016 void TrkrHitSetTpc::identify(std::ostream& os) const
0017 {
0018   os
0019       << "TrkrHitSetTpc: "
0020       << "       hitsetkey " << getHitSetKey()
0021       << std::endl;
0022 }
0023 
0024 TpcDefs::ADCDataType& TrkrHitSetTpc::getTpcADC(TrkrDefs::hitkey key)
0025 {
0026   std::pair<uint16_t, uint16_t> local_phi_t = getLocalPhiTBin(key);
0027 
0028   return getTpcADC(local_phi_t.first, local_phi_t.second);
0029 }
0030 
0031 const TpcDefs::ADCDataType& TrkrHitSetTpc::getTpcADC(TrkrDefs::hitkey key) const
0032 {
0033   std::pair<uint16_t, uint16_t> local_phi_t = getLocalPhiTBin(key);
0034 
0035   return getTpcADC(local_phi_t.first, local_phi_t.second);
0036 }
0037 
0038 std::pair<uint16_t, uint16_t> TrkrHitSetTpc::getLocalPhiTBin(TrkrDefs::hitkey key) const
0039 {
0040   const uint16_t pad = TpcDefs ::getPad(key);
0041   const uint16_t tbin = TpcDefs ::getTBin(key);
0042   const uint16_t side = TpcDefs::getSide(getHitSetKey());
0043 
0044   uint16_t local_pad = 0;
0045   uint16_t local_tbin = 0;
0046 
0047   if (side == 0)
0048   {
0049     local_pad = pad - getPadIndexStart();
0050     local_tbin = tbin - getTBinIndexStart();
0051   }
0052   else
0053   {
0054     local_pad = getNPads() - 1 - pad + getPadIndexStart();
0055     local_tbin = -tbin + getTBinIndexStart();
0056   }
0057 
0058   if (local_pad >= getNPads())
0059   {
0060     std::cout << __PRETTY_FUNCTION__ << " fatal error local_pad >= getNPads()"
0061               << " getHitSetKey() = " << getHitSetKey()
0062               << " pad = " << pad
0063               << " tbin = " << tbin
0064               << " side = " << side
0065               << " local_pad = " << local_pad
0066               << " local_tbin = " << local_tbin
0067               << " getPadIndexStart() = " << getPadIndexStart()
0068               << " getTBinIndexStart() = " << getTBinIndexStart()
0069               << std::endl;
0070     identify();
0071   }
0072   assert(local_pad < getNPads());
0073 
0074   if (local_tbin >= getNTBins())
0075   {
0076     std::cout << __PRETTY_FUNCTION__ << " fatal error local_tbin >= getNTBins()"
0077               << " getHitSetKey() = " << getHitSetKey()
0078               << " pad = " << pad
0079               << " tbin = " << tbin
0080               << " side = " << side
0081               << " local_pad = " << local_pad
0082               << " local_tbin = " << local_tbin
0083               << " getPadIndexStart() = " << getPadIndexStart()
0084               << " getTBinIndexStart() = " << getTBinIndexStart()
0085               << std::endl;
0086     identify();
0087   }
0088   assert(local_tbin < getNTBins());
0089 
0090   return std::make_pair(local_pad, local_tbin);
0091 }
0092 
0093 TrkrDefs::hitkey TrkrHitSetTpc::getHitKeyfromLocalBin(
0094     const uint16_t local_pad,
0095     const uint16_t local_tbin)
0096     const
0097 {
0098   const uint8_t side = TpcDefs::getSide(getHitSetKey());
0099 
0100   if (side == 0)
0101   {
0102     const uint16_t pad = local_pad + getPadIndexStart();
0103     const uint16_t tbin = local_tbin + getTBinIndexStart();
0104 
0105     return TpcDefs::genHitKey(pad, tbin);
0106   }
0107   else
0108   {
0109     const uint16_t pad = getNPads() - 1 - local_pad + getPadIndexStart();
0110     const uint16_t tbin = -local_tbin + getTBinIndexStart();
0111 
0112     return TpcDefs::genHitKey(pad, tbin);
0113   }
0114 }