Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:14:00

0001 #include "TowerInfov5.h"
0002 #include "TowerInfo.h"
0003 
0004 #include <phool/phool.h>
0005 
0006 #include <TSystem.h>
0007 
0008 #include <algorithm>
0009 #include <cstdlib>
0010 #include <iostream>
0011 
0012 void TowerInfov5::Reset()
0013 {
0014   TowerInfov2::Reset();
0015   std::ranges::fill(_waveform, 0);
0016 }
0017 
0018 void TowerInfov5::set_nsample(int nsample)
0019 {
0020   if (nsample > 0)
0021   {
0022     _waveform.resize(nsample, 0);
0023     return;
0024   }
0025   std::cout << PHWHERE << " invalid number of samples: " << nsample << std::endl;
0026   gSystem->Exit(1);
0027   exit(1);
0028 }
0029 
0030 int16_t TowerInfov5::get_waveform_value(int index) const
0031 {
0032   if (index >= 0 && index < get_nsample())
0033   {
0034     return _waveform[index];
0035   }
0036   return 0;
0037 }
0038 
0039 void TowerInfov5::set_waveform_value(int index, int16_t value)
0040 {
0041   if (index >= 0 && index < get_nsample())
0042   {
0043     _waveform[index] = value;
0044   }
0045   return;
0046 }
0047 
0048 void TowerInfov5::copy_tower(TowerInfo* tower)
0049 {
0050   TowerInfov2::copy_tower(tower);
0051   const int nsamples = tower->get_nsample();
0052   if (nsamples <= 0)
0053   {
0054     _waveform.clear();
0055     return;
0056   }
0057   set_nsample(nsamples);
0058   for (int i = 0; i < nsamples; ++i)
0059   {
0060     _waveform[i] = tower->get_waveform_value(i);
0061   }
0062   return;
0063 }
0064 
0065 void TowerInfov5::identify(std::ostream& os) const
0066 {
0067   os << "TowerInfov5" << std::endl;
0068   for (int i = 0; i < get_nsample(); ++i)
0069   {
0070     os << "sample " << i << ": " << get_waveform_value(i) << std::endl;
0071   }
0072   return;
0073 }