All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Typedefs | Functions | Variables
crt_detsimalg_test.cxx File Reference
#include <iostream>
#include <string>
#include <memory>
#include <utility>
#include <map>
#include <type_traits>
#include <stdexcept>
#include "larcorealg/TestUtils/unit_test_base.h"
#include "CLHEP/Random/JamesRandom.h"
#include "sbndcode/CRT/CRTSimulation/CRTDetSimAlg.h"
#include "sbndcode/CRT/CRTSimulation/CRTDetSimParams.h"

Go to the source code of this file.

Typedefs

using Parameters = fhicl::Table< sbnd::crt::CRTDetSimParams >
 

Functions

Parameters get_parameters (int argc, char const **argv)
 
int main (int argc, char const **argv)
 

Variables

constexpr long SEED = 0
 Basic unit tests for the CRT detector simulation. More...
 

Typedef Documentation

using Parameters = fhicl::Table<sbnd::crt::CRTDetSimParams>

Definition at line 22 of file crt_detsimalg_test.cxx.

Function Documentation

Parameters get_parameters ( int  argc,
char const **  argv 
)

Definition at line 24 of file crt_detsimalg_test.cxx.

24  {
25 
26  int iParam = 0;
27 
28  // first argument: configuration file (mandatory)
29  std::string config_path;
30  if (++iParam < argc) config_path = argv[iParam];
31 
32 
33  char const* fhicl_env = getenv("FHICL_FILE_PATH");
34  std::string search_path = fhicl_env? std::string(fhicl_env) + ":": ".:";
36 
37  fhicl::intermediate_table table;
38  table = fhicl::parse_document(argv[iParam], policy);
39 
40  // translate into a parameter set
41  fhicl::ParameterSet params;
42  params = fhicl::ParameterSet::make(table);
43 
44  fhicl::ParameterSet p = params.get<fhicl::ParameterSet>("testcrtsim");
45 
46  // std::cout << "p " << p.to_string() << std::endl;
47 
48  Parameters detsim_params(p.template get<fhicl::ParameterSet>("DetSimParams"));
49 
50  return detsim_params;
51 }
pdgs p
Definition: selectors.fcl:22
fhicl::Table< sbnd::crt::CRTDetSimParams > Parameters
int main ( int  argc,
char const **  argv 
)

Definition at line 53 of file crt_detsimalg_test.cxx.

53  {
54 
55  int errors = 0;
56 
57  //
58  // Read parameters
59  //
60  Parameters detsim_params = get_parameters(argc, argv);
61 
62 
63  //
64  // Create DetSimAlg class
65  //
66  CLHEP::HepJamesRandom engine(SEED);
67 
68  sbnd::crt::CRTDetSimAlg detsim_alg(detsim_params,
69  engine,
70  0.);
71 
72  //
73  // Time response
74  //
75  uint32_t ts = detsim_alg.getChannelTriggerTicks(10000, // true time, ns
76  30, // PEs
77  50); // distance to readout
78 
79  std::cout << "ts " << ts << std::endl;
80 
81  // if (ts) {
82  // std::cout << "Signal saturated with a 1.5 MeV deposited energy?" << std::endl;
83  // errors++;
84  // }
85 
86 
87  //
88  // Charge response
89  //
90  long npe0, npe1;
91  double q0, q1;
92  detsim_alg.ChargeResponse(1.5*1e-3, // 1.5 MeV deposited energy
93  5, // 5 cm distance to fiber 0
94  5, // 5 cm distance to fiber 1
95  50, // 50 cm distance to readout
96  npe0, npe1, q0, q1);
97 
98  std::cout << "npe0 " << npe0
99  << "\nnpe1 " << npe1
100  << "\nq0 " << q0
101  << "\nq1 " << q1 << std::endl;
102 
103  if (q0 == detsim_alg.Params().AdcSaturation() or q1 == detsim_alg.Params().AdcSaturation()) {
104  std::cout << "Signal saturated with a 1.5 MeV deposited energy?" << std::endl;
105  errors++;
106  }
107 
108  if (q0 < 0 or q1 < 0) {
109  std::cout << "Predicted ADCs are negative?" << std::endl;
110  errors++;
111  }
112 
113 
114  //
115  // Waveform emulation
116  //
117 
118  double original_adc = 2000;
119  uint16_t adc = detsim_alg.WaveformEmulation(10, // time delay
120  original_adc); // adc
121 
122  std::cout << "original_adc " << original_adc
123  << "\nadc " << adc << std::endl;
124 
125  if (adc > static_cast<uint16_t>(original_adc)) {
126  std::cout << "ADC value after waveform emulation is larger?" << std::endl;
127  errors++;
128  }
129 
130 
131 
132 
133  return errors;
134 
135 }
Parameters get_parameters(int argc, char const **argv)
fhicl::Table< sbnd::crt::CRTDetSimParams > Parameters
do i e
constexpr long SEED
Basic unit tests for the CRT detector simulation.
BEGIN_PROLOG could also be cout

Variable Documentation

constexpr long SEED = 0

Basic unit tests for the CRT detector simulation.

Author
Marco Del Tutto

Definition at line 20 of file crt_detsimalg_test.cxx.