12 constexpr
double K0 = 1.584;
13 constexpr
double Re_K1 = -0.792;
14 constexpr
double Im_K1 = -0.115;
16 constexpr
double chargeScaleFactor = 1 / 0.411819;
18 constexpr
double mmIonFlowTime = 150.;
22 m_peakTime(peakTime), m_lowerTimeWindow(lowerTimeWindow), m_upperTimeWindow(upperTimeWindow), m_timeStep(0.1) {
34 m_k1_abs = std::sqrt(Re_K1 * Re_K1 + Im_K1 * Im_K1);
35 m_argK1 = std::atan2(Im_K1, Re_K1);
51 for (
unsigned int i_electron = 0; i_electron < effectiveCharge.size(); i_electron++) {
52 if (
time < electronsTime.at(i_electron))
continue;
53 double t = (
time - electronsTime.at(i_electron));
65 const double electronicsThreshold,
double &litudeFirstPeak,
double &timeFirstPeak)
const {
66 double t_peak =
findPeak(effectiveCharge, electronsTime, electronicsThreshold);
68 if (t_peak == -9999)
return false;
70 amplitudeFirstPeak =
vmmResponse(effectiveCharge, electronsTime, t_peak);
71 timeFirstPeak = t_peak;
76 const double electronicsThreshold,
double &litudeAtFirstPeak,
double &timeAtThreshold)
const {
79 if (effectiveCharge.empty())
return false;
81 double minElectronTime = *std::min_element(electronsTime.begin(), electronsTime.end());
86 double tmpTimeAtThreshold = -9999;
90 if (
vmmResponse(effectiveCharge, electronsTime,
time) <= electronicsThreshold)
continue;
94 if (
vmmResponse(effectiveCharge, electronsTime, fineTime) >= electronicsThreshold)
continue;
95 tmpTimeAtThreshold = fineTime + 0.5 *
m_timeStep;
101 if (tmpTimeAtThreshold == -9999) {
105 if (
vmmResponse(effectiveCharge, electronsTime,
time) >= electronicsThreshold) {
106 tmpTimeAtThreshold =
time;
112 if (tmpTimeAtThreshold == -9999)
return false;
114 double t_peak =
findPeak(effectiveCharge, electronsTime, electronicsThreshold);
115 if (t_peak == -9999)
return false;
117 timeAtThreshold = tmpTimeAtThreshold;
118 amplitudeAtFirstPeak =
vmmResponse(effectiveCharge, electronsTime, t_peak);
122 double VMM_Shaper::findPeak(
const std::vector<float> &effectiveCharge,
const std::vector<float> &electronsTime,
123 const double electronicsThreshold)
const {
124 if (effectiveCharge.empty())
return -9999;
126 double minElectronTime = *std::min_element(electronsTime.begin(), electronsTime.end());
133 double oldResponse = 0;
136 double timeStepScaleFactor = 5.0;
146 int searchWindow = 5;
148 std::vector<double> tmpTime, tmpResponse;
150 tmpTime.reserve(2 * timeStepScaleFactor);
151 tmpResponse.reserve(2 * timeStepScaleFactor);
155 tmpTime.push_back(fineTime);
156 tmpResponse.push_back(
vmmResponse(effectiveCharge, electronsTime, fineTime));
159 int nBins = tmpTime.size();
161 for (
int i_time = 1; i_time <
nBins - 1; i_time++) {
162 if (tmpResponse.at(i_time) < tmpResponse.at(i_time + 1))
continue;
164 if (tmpResponse.at(i_time) < electronicsThreshold)
break;
166 bool checkTimeWindow =
false;
167 for (
int i_timeOfPeak = i_time - searchWindow + 1; i_timeOfPeak <= i_time + searchWindow; i_timeOfPeak++) {
168 if (i_timeOfPeak < 1 || i_timeOfPeak ==
nBins - 1)
continue;
170 double oldDerivative = (tmpResponse.at(i_time) - tmpResponse.at(i_time - 1));
171 double newDerivative = (tmpResponse.at(i_time + 1) - tmpResponse.at(i_time));
172 if (newDerivative > oldDerivative) {
173 checkTimeWindow =
false;
176 checkTimeWindow =
true;
179 if (checkTimeWindow)
return tmpTime.at(i_time);
186 const double electronicsThreshold)
const {
189 if (effectiveCharge.empty())
return false;
191 double minElectronTime = *std::min_element(electronsTime.begin(), electronsTime.end());
199 if (
vmmResponse(effectiveCharge, electronsTime,
time) >= electronicsThreshold) {
return true; }
205 const double electronicsThreshold)
const {
208 for (
unsigned int i_elec = 0; i_elec < effectiveCharge.size(); i_elec++) {
213 return chargeSum >= electronicsThreshold;