Back to home page

sPhenix code displayed by LXR

 
 

    


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

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