test_SignalShapingServiceDUNE.cxx
Go to the documentation of this file.
1 // test_SignalShapingServiceDUNE.cxx
2 
3 // David Adams
4 // September 2015
5 //
6 // This test demonstrates how to configure and use the LArSoft signal
7 // service service outside the art framework.
8 
10 #include <string>
11 #include <iostream>
12 #include <fstream>
13 #include <vector>
14 #include <iomanip>
20 #include "TH1.h"
21 
22 using std::string;
23 using std::cout;
24 using std::endl;
25 using std::vector;
26 using std::setw;
27 using std::ofstream;
28 
30  const string myname = "test_SignalShapingServiceDUNE: ";
31  cout << myname << "Starting test" << endl;
32 #ifdef NDEBUG
33  cout << myname << "NDEBUG must be off." << endl;
34  abort();
35 #endif
36  string line = "-----------------------------";
37  string scfg;
38 
39  cout << myname << line << endl;
40  cout << "Prevent Root from managing histograms." << endl;
41  TH1::AddDirectory(kFALSE);
42 
43  string const config{"#include \"services_dune.fcl\"\n"
44  "services: { @table::dune35t_services_legacy }"};
46 
47  cout << myname << line << endl;
48  cout << myname << "Get the geometry service." << endl;
49  // Now because it takes time and makes noise.
51 
52  cout << myname << line << endl;
53  cout << myname << "Get the signal shaping service." << endl;
55 
56  cout << myname << line << endl;
57  cout << myname << "Retrieve shaping parameters." << endl;
59  unsigned int xformSize = pfft->FFTSize();
60  cout << "Transform size: " << xformSize << endl;
61  cout << "Decon norm: " << psss->GetDeconNorm() << endl;
62  cout << "UseFunctionFieldShape: " << psss->GetDeconNorm() << endl;
63  cout << "Decon norm: " << psss->GetDeconNorm() << endl;
64 
65  cout << myname << line << endl;
66  cout << myname << "Create raw data." << endl;
67  unsigned int chan = 450; // Must be a collection plane.
69  for ( int i=0; i<20; ++i ) raw.push_back(0.0);
70  raw.push_back(1.0);
71  raw.push_back(1.0);
72  raw.push_back(2.0);
73  raw.push_back(2.0);
74  raw.push_back(3.0);
75  raw.push_back(4.0);
76  raw.push_back(5.0);
77  raw.push_back(6.0);
78  raw.push_back(8.0);
79  raw.push_back(10.0);
80  raw.push_back(10.0);
81  raw.push_back(13.0);
82  raw.push_back(16.0);
83  raw.push_back(20.0);
84  raw.push_back(25.0);
85  raw.push_back(30.0);
86  raw.push_back(34.0);
87  raw.push_back(33.0);
88  raw.push_back(27.0);
89  raw.push_back(21.0);
90  raw.push_back(14.0);
91  raw.push_back( 8.0);
92  raw.push_back( 3.0);
93  raw.push_back( 2.0);
94  for ( int i=0; i<20; ++i ) raw.push_back(0.0);
95  assert( xformSize > raw.size() );
96 
97  cout << endl;
98  cout << myname << "Deconvolute." << endl;
99  vector<float> decon(xformSize);;
100  for ( unsigned int i=0; i<raw.size(); ++i ) decon[i] = raw[i];
101  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
102  psss->Deconvolute(clockData, chan, decon);
103  cout << " Raw Decon" << endl;
104  for ( int unsigned i=0; i<raw.size(); ++i ) {
105  cout << setw(10) << raw[i] << setw(10) << decon[i] << endl;
106  }
107 
108  cout << myname << line << endl;
109  cout << "Done." << endl;
110  return 0;
111 }
112 
113 int main() {
115  return 0;
116 }
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
std::string string
Definition: nybbler.cc:12
struct vector vector
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
int test_SignalShapingServiceDUNE()
static void load_services(std::string const &config)
art framework interface to geometry description
int FFTSize() const
Definition: LArFFT.h:69
static Config * config
Definition: config.cpp:1054
size_t size
Definition: lodepng.cpp:55
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)