LegacyPulseShaper.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \brief Code to shape pulses without the effect of the pre-amplifier
3 /// and energy dependent fall times.
4 /// \author aurisaam@ucmail.uc.edu
5 /// \date
6 ////////////////////////////////////////////////////////////////////////
7 #include <cmath>
8 #include <iterator>
9 #include <algorithm>
10 
11 #include "LegacyPulseShaper.h"
12 #include "Utilities/func/MathUtil.h"
13 
14 namespace rsim{
15 
17  IPulseShaper(pset),
18  fR( pset.get< double >("ASICRiseLegacy")),
19  fF( pset.get< double >("ASICFallLegacy"))
20  {
23  }
24 
25  std::vector<double> LegacyPulseShaper::CreateTrace( std::list< std::pair<double,double> >& ADCPulsesIn, std::list< std::pair<double,double> >& SaggedPulses )
26  {
27  ClusterPulses( ADCPulsesIn, SaggedPulses );
28 
29  std::vector<double> trace(fNumClockticksInSpill, 0.0);
31 
32  if (fClusteredPulses.size() == 0) return trace;
33 
36 
37  for (auto it = fClusteredPulses.begin(); it != fClusteredPulses.end(); ++it) {
38  double hitTime = it->first;
39  double ADC = it->second;
40 
41  // No point simulating curve before the hit (causality)
42  int tickBegin = std::max(int(hitTime/fClocktick), fPhase);
43  // Back up to the previous properly aligned point
44  while(tickBegin%fNumClockticksPerDigitization != fPhase) --tickBegin;
45  // After seven fall times we're making a 0.1% mistake by not including the rest
46  const int tickEnd = std::min(int((hitTime+7*fF)/fClocktick), fNumClockticksInSpill);
47 
48  bool firstTime(true);
49  double expoRise(0.0), expoFall(0.0);
50  for(int iClocktick = tickBegin; iClocktick < tickEnd; iClocktick += fNumClockticksPerDigitization){
51  double tickTime = iClocktick*fClocktick; // time of the clocktick, relative to start of spill
52  if (tickTime - hitTime < 0.0) continue;
53  else if ( firstTime ) {
54  expoRise = exp(-(tickTime-hitTime)/fR);
55  expoFall = exp(-(tickTime-hitTime)/fF);
56  firstTime = false;
57  }
58  else {
59  expoRise *= riseFactor;
60  expoFall *= fallFactor;
61  }
62  trace[iClocktick] += ADC*(expoFall - expoRise)*(fF/(fF-fR));
63  }
64  }
65  return trace;
66  }
67 
68 }
69 
T max(const caf::Proxy< T > &a, T b)
LegacyPulseShaper(const fhicl::ParameterSet &pset)
set< int >::iterator it
Common configuration params for SimpleReadout, FPGAAlgorithms, NoiseMaker.
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
int fNumClockticksPerDigitization
Definition: IPulseShaper.h:38
T ipow(T x, unsigned int n)
More efficient exponentiation function than pow(x,n) for small n.
Definition: MathUtil.h:29
T trace(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
Definition: trace.hpp:19
std::list< std::pair< double, double > > fClusteredPulses
Definition: IPulseShaper.h:33
T min(const caf::Proxy< T > &a, T b)
std::vector< double > CreateTrace(std::list< std::pair< double, double > > &ADCPulses, std::list< std::pair< double, double > > &SaggedPulses)
void ClusterPulses(std::list< std::pair< double, double > > &ADCPulses, std::list< std::pair< double, double > > &SaggedPulses)