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