Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:22:00

0001 #include "RawTower_Prototype2.h"
0002 
0003 #include "PROTOTYPE2_FEM.h"
0004 
0005 #include <calobase/RawTower.h>  // for RawTower
0006 #include <calobase/RawTowerDefs.h>
0007 
0008 #include <algorithm>
0009 #include <cassert>
0010 #include <cmath>
0011 #include <iostream>
0012 #include <vector>  // for vector
0013 
0014 using namespace std;
0015 
0016 RawTower_Prototype2::RawTower_Prototype2()
0017   : towerid(~0)
0018   ,  // initialize all bits on
0019   energy(0)
0020   , time(NAN)
0021   , HBD_channel(-1)
0022 {
0023   fill_n(signal_samples, NSAMPLES, -9999);
0024 }
0025 
0026 RawTower_Prototype2::RawTower_Prototype2(const RawTower &tower)
0027 {
0028   towerid = (tower.get_id());
0029   energy = (tower.get_energy());
0030   time = (tower.get_time());
0031   HBD_channel = -1;
0032   fill_n(signal_samples, NSAMPLES, -9999);
0033 }
0034 
0035 RawTower_Prototype2::RawTower_Prototype2(RawTowerDefs::keytype id)
0036   : towerid(id)
0037   , energy(0)
0038   , time(NAN)
0039   , HBD_channel(-1)
0040 {
0041   fill_n(signal_samples, NSAMPLES, -9999);
0042 }
0043 
0044 RawTower_Prototype2::RawTower_Prototype2(const unsigned int icol,
0045                                          const unsigned int irow)
0046   : towerid(0)
0047   , energy(0)
0048   , time(NAN)
0049   , HBD_channel(-1)
0050 {
0051   towerid = RawTowerDefs::encode_towerid(RawTowerDefs::NONE, icol, irow);
0052   fill_n(signal_samples, NSAMPLES, -9999);
0053 }
0054 
0055 RawTower_Prototype2::RawTower_Prototype2(
0056     const RawTowerDefs::CalorimeterId caloid, const unsigned int ieta,
0057     const unsigned int iphi)
0058   : towerid(0)
0059   , energy(0)
0060   , time(NAN)
0061   , HBD_channel(-1)
0062 {
0063   towerid = RawTowerDefs::encode_towerid(caloid, ieta, iphi);
0064   fill_n(signal_samples, NSAMPLES, -9999);
0065 }
0066 
0067 void RawTower_Prototype2::Reset()
0068 {
0069   energy = 0;
0070   time = NAN;
0071   fill_n(signal_samples, NSAMPLES, -9999);
0072 }
0073 
0074 int RawTower_Prototype2::isValid() const { return get_energy() != 0; }
0075 
0076 void RawTower_Prototype2::identify(std::ostream &os) const
0077 {
0078   os << "RawTower_Prototype2: etabin: " << get_bineta()
0079      << ", phibin: " << get_binphi() << " energy=" << get_energy() << std::endl;
0080 }
0081 
0082 void RawTower_Prototype2::set_signal_samples(
0083     int i, RawTower_Prototype2::signal_type sig)
0084 {
0085   assert(i >= 0);
0086   assert(i < NSAMPLES);
0087   signal_samples[i] = sig;
0088 }
0089 
0090 RawTower_Prototype2::signal_type
0091 RawTower_Prototype2::get_signal_samples(int i) const
0092 {
0093   assert(i >= 0);
0094   assert(i < NSAMPLES);
0095   return signal_samples[i];
0096 }
0097 
0098 double RawTower_Prototype2::get_energy_power_law_exp(int verbosity)
0099 {
0100   double peak = NAN;
0101   double peak_sample = NAN;
0102   double pedstal = NAN;
0103 
0104   vector<double> vec_signal_samples;
0105   for (int i = 0; i < NSAMPLES; i++)
0106   {
0107     vec_signal_samples.push_back(signal_samples[i]);
0108   }
0109 
0110   PROTOTYPE2_FEM::SampleFit_PowerLawExp(vec_signal_samples, peak, peak_sample,
0111                                         pedstal, verbosity);
0112 
0113   return peak;
0114 }