Public Member Functions | Private Types | Private Attributes | List of all members
AdcThresholdSignalFinder Class Reference

#include <AdcThresholdSignalFinder.h>

Inheritance diagram for AdcThresholdSignalFinder:
TpcDataTool AdcChannelTool

Public Member Functions

 AdcThresholdSignalFinder (fhicl::ParameterSet const &ps)
 
DataMap view (const AdcChannelData &acd) const override
 
DataMap update (AdcChannelData &acd) const override
 
- Public Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Public Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap updateMap (AdcChannelDataMap &acds) const
 
virtual DataMap viewMap (const AdcChannelDataMap &acds) const
 
virtual bool updateWithView () const
 
virtual bool viewWithUpdate () const
 
virtual DataMap beginEvent (const DuneEventInfo &) const
 
virtual DataMap endEvent (const DuneEventInfo &) const
 
virtual DataMap close (const DataMap *dmin=nullptr)
 

Private Types

using Name = std::string
 

Private Attributes

int m_LogLevel
 
ParFormulam_Threshold
 
unsigned int m_BinsBefore
 
unsigned int m_BinsAfter
 
bool m_FlagPositive
 
bool m_FlagNegative
 
RunDataToolm_prdtool
 

Additional Inherited Members

- Public Types inherited from AdcChannelTool
using Index = unsigned int
 
- Static Public Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 37 of file AdcThresholdSignalFinder.h.

Member Typedef Documentation

Definition at line 49 of file AdcThresholdSignalFinder.h.

Constructor & Destructor Documentation

AdcThresholdSignalFinder::AdcThresholdSignalFinder ( fhicl::ParameterSet const &  ps)

Definition at line 29 of file AdcThresholdSignalFinder.cc.

30 : m_LogLevel(ps.get<int>("LogLevel")),
31  m_Threshold(new RootParFormula("Threshold", ps.get<Name>("Threshold"))),
32  m_BinsBefore(ps.get<unsigned int>("BinsBefore")),
33  m_BinsAfter(ps.get<unsigned int>("BinsAfter")),
34  m_FlagPositive(ps.get<bool>("FlagPositive")),
35  m_FlagNegative(ps.get<bool>("FlagNegative")),
36  m_prdtool(nullptr) {
37  const string myname = "AdcThresholdSignalFinder::ctor: ";
39  if ( pdtm == nullptr ) {
40  cout << myname << "ERROR: Unable to retrieve tool manager." << endl;
41  } else {
42  string stnam = "runDataTool";
43  if ( m_Threshold->npar() ) {
44  m_prdtool = pdtm->getShared<RunDataTool>(stnam);
45  if ( m_prdtool == nullptr ) {
46  cout << myname << "ERROR: RunDataTool " << stnam
47  << " not found. Scale factor formula will not be evaluated." << endl;
48  } else {
49  cout << myname << "RunDataTool retrieved." << endl;
50  }
51  }
52  }
53  if ( m_LogLevel >= 1 ) {
54  cout << myname << "Configuration parameters:" << endl;
55  cout << myname << " LogLevel: " << m_LogLevel << endl;
56  cout << myname << " Threshold: " << m_Threshold->formulaString() << endl;
57  cout << myname << " BinsBefore: " << m_BinsBefore << endl;
58  cout << myname << " BinsAfter: " << m_BinsAfter << endl;
59  cout << myname << " FlagPositive: " << boolToString(m_FlagPositive) << endl;
60  cout << myname << " FlagNegative: " << boolToString(m_FlagNegative) << endl;
61  }
62 }
virtual Name formulaString() const =0
ChannelGroupService::Name Name
virtual Index npar() const
Definition: ParFormula.h:44
static constexpr double ps
Definition: Units.h:99
static DuneToolManager * instance(std::string fclname="", int dbg=1)
T * getShared(std::string name)
QTextStream & endl(QTextStream &s)

Member Function Documentation

DataMap AdcThresholdSignalFinder::update ( AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 66 of file AdcThresholdSignalFinder.cc.

66  {
67  const string myname = "AdcThresholdSignalFinder::update: ";
68  DataMap ret;
69  AdcIndex nsam = acd.samples.size();
70  if ( nsam == 0 ) {
71  cout << myname << "ERROR: No samples found in channel " << acd.channel() << endl;
72  acd.signal.clear();
73  acd.rois.clear();
74  return ret.setStatus(1);
75  }
76  if ( m_prdtool != nullptr ) {
77  RunData rdat = m_prdtool->runData(acd.run());
78  if ( ! rdat.isValid() ) cout << myname << "WARNING: RunData not found." << endl;
79  else rdat.setFormulaPars(*m_Threshold);
80  }
81  if ( ! m_Threshold->ready() ) {
82  cout << myname << "WARNING: Using default scale factor " << m_Threshold->defaultEval() << endl;
83  }
84  float thr = m_Threshold->eval();
85  if ( m_LogLevel >= 2 ) cout << myname << "Finding ROIs for channel " << acd.channel() << endl;
86  AdcIndex nsamlo = m_BinsBefore;
87  AdcIndex nsamhi = m_BinsAfter;
88  acd.signal.clear();
89  acd.signal.resize(nsam, false);
90  AdcIndex nbinAbove = 0;
91  AdcIndex isamUnknown = 0; // First sample which is not known to be inside or ouside a ROI.
92  for ( AdcIndex isam=0; isam<nsam; ++isam ) {
93  float val = acd.samples[isam];
94  bool keep = ( m_FlagPositive && val > thr ) ||
95  ( m_FlagNegative && val < -thr );
96  if ( keep ) {
97  ++nbinAbove;
98  AdcIndex jsam1 = isam > nsamlo ? isam - nsamlo : 0;
99  if ( jsam1 < isamUnknown ) jsam1 = isamUnknown;
100  AdcIndex jsam2 = isam + nsamhi + 1;
101  if ( jsam2 > nsam ) jsam2 = nsam;
102  if ( m_LogLevel >= 4 ) cout << myname << "Trigger: sample[" << isam
103  << "] = " << val << " ==> range: ["
104  << jsam1 << ", " << jsam2 << ")" << endl;
105  for ( AdcIndex jsam=jsam1; jsam<jsam2; ++jsam ) acd.signal[jsam] = true;
106  isamUnknown = jsam2;
107  }
108  }
109  acd.roisFromSignal();
110  if ( m_LogLevel >= 3 ) {
111  cout << myname << " # ticks above threshold: " << nbinAbove << endl;
112  cout << myname << " # ROI: " << acd.rois.size() << endl;
113  }
114  ret.setFloat("threshold", thr);
115  ret.setInt("nThresholdBins", nbinAbove);
116  ret.setInt("nroi", acd.rois.size());
117  return ret;
118 }
void setFloat(Name name, float val)
Definition: DataMap.h:133
G4double thr[100]
Definition: G4S2Light.cc:59
DataMap & setStatus(int stat)
Definition: DataMap.h:130
virtual double eval(const Values &vars) const =0
virtual bool ready() const
Definition: ParFormula.h:56
bool isValid() const
Definition: RunData.h:48
AdcRoiVector rois
AdcIndex run() const
void setInt(Name name, int val)
Definition: DataMap.h:131
virtual RunData runData(Index run, Index subRun=0) const =0
unsigned int AdcIndex
Definition: AdcTypes.h:15
Channel channel() const
AdcFilterVector signal
virtual Value defaultEval() const
Definition: ParFormula.h:59
SetStat setFormulaPars(TFormula *form)
Definition: RunData.h:87
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
DataMap AdcThresholdSignalFinder::view ( const AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 122 of file AdcThresholdSignalFinder.cc.

122  {
123  AdcChannelData acdtmp;
124  acdtmp.samples = acd.samples;
125  return update(acdtmp);
126 }
DataMap update(AdcChannelData &acd) const override
AdcSignalVector samples

Member Data Documentation

unsigned int AdcThresholdSignalFinder::m_BinsAfter
private

Definition at line 55 of file AdcThresholdSignalFinder.h.

unsigned int AdcThresholdSignalFinder::m_BinsBefore
private

Definition at line 54 of file AdcThresholdSignalFinder.h.

bool AdcThresholdSignalFinder::m_FlagNegative
private

Definition at line 57 of file AdcThresholdSignalFinder.h.

bool AdcThresholdSignalFinder::m_FlagPositive
private

Definition at line 56 of file AdcThresholdSignalFinder.h.

int AdcThresholdSignalFinder::m_LogLevel
private

Definition at line 52 of file AdcThresholdSignalFinder.h.

RunDataTool* AdcThresholdSignalFinder::m_prdtool
private

Definition at line 60 of file AdcThresholdSignalFinder.h.

ParFormula* AdcThresholdSignalFinder::m_Threshold
private

Definition at line 53 of file AdcThresholdSignalFinder.h.


The documentation for this class was generated from the following files: