test_GeoApaChannelGroupService.cxx
Go to the documentation of this file.
1 // test_GeoApaChannelGroupService.cxx
2 
3 // David Adams
4 // October 2016
5 //
6 // Test GeoApaChannelGroupService.
7 
8 #include "../GeoApaChannelGroupService.h"
9 #include <string>
10 #include <iostream>
11 #include <sstream>
12 #include <fstream>
13 #include <iomanip>
15 
16 using std::string;
17 using std::cout;
18 using std::endl;
19 using std::istringstream;
20 using std::ostringstream;
21 using std::ofstream;
22 using std::setw;
23 using std::vector;
24 using art::ServiceHandle;
25 
26 #undef NDEBUG
27 #include <cassert>
28 
30  const string myname = "test_GeoApaChannelGroupService: ";
31 #ifdef NDEBUG
32  cout << myname << "NDEBUG must be off." << endl;
33  abort();
34 #endif
35  const string line = "-----------------------------";
36 
37  cout << myname << line << endl;
38  cout << myname << "Create fcl file." << endl;
39  std::ostringstream oss;
40  oss << "#include \"geometry.fcl\"" << endl;
41  oss << "services: @local::" << sgeo << "_geometry_services" << endl;
42  oss << "services.ChannelGroupService: {" << endl;
43  oss << " service_provider: \"GeoApaChannelGroupService\"" << endl;
44  oss << " LogLevel: 1" << endl;
45  oss << " ApaRops: []" << endl;
46  oss << "}" << endl;
48 
49  cout << myname << line << endl;
50  cout << myname << "Fetch ChannelGroupService." << endl;
52  hcgs->print(cout, myname);
53 
54  cout << myname << line << endl;
55  cout << myname << "Geometry: " << sgeo << endl;
56 
57 
58  cout << myname << line << endl;
59  unsigned int napa = hcgs->size();
60  cout << myname << "Check APA count: " << napa << endl;
61  if ( sgeo == "lartpcdetector" ) {
62  assert( napa == 1 );
63  } else if ( sgeo == "bo" ) {
64  assert( napa == 1 );
65  } else {
66  cout << myname << "Unknown geometry" << endl;
67  }
68 
69  cout << myname << line << endl;
70  cout << myname << "APA names and channels:" << endl;
71  for ( unsigned int iapa=0; iapa<napa; ++iapa ) {
72  string name = hcgs->name(iapa);
73  const vector<ChannelGroupService::Index> chans = hcgs->channels(iapa);
74  cout << myname << " " << setw(10) << name << ": ["
75  << setw(6) << chans.front() << ", "
76  << setw(6) << chans.back() << "]" << endl;
77  assert( name.size() );
78  assert( name != "NoSuchApa" );
79  assert( chans.size() );
80  }
81 
82  cout << myname << line << endl;
83  cout << myname << "Done." << endl;
84  return 0;
85 }
86 
87 int main(int argc, char* argv[]) {
88  string sgeo = "lartpcdetector";
89  if ( argc > 1 ) {
90  sgeo = argv[1];
91  if ( sgeo == "-h" ) {
92  cout << "Usage: " << argv[0] << endl;
93  cout << " " << argv[0] << " lartpcdetector";
94  cout << " " << argv[0] << " bo" << endl;
95  return 0;
96  }
97  }
98  return test_GeoApaChannelGroupService(sgeo);
99 }
100 
101 
102 //******************************************************************************
103 //*** Big configuration chunks
104 //***
105 
106 // this is a copy of the "standard" LArProperties configuration
108  service_provider: "LArPropertiesServiceStandard"
109 
110  # For following parameters, see http://pdg.lbl.gov/AtomicNuclearProperties/
111  RadiationLength: 19.55 # g/cm^2
112  AtomicNumber: 18 # Ar atomic number.
113  AtomicMass: 39.948 # Ar atomic mass (g/mol).
114  ExcitationEnergy: 188.0 # Ar mean excitation energy (eV).
115 
116 # realistic Argon 39 decays
117 # Argon39DecayRate: 0.00141 # decays per cm^3 per second. Assumes 1.01 Bq/kg and a density of 1.396 g/cc
118 # switch them off for faster simulation
119  Argon39DecayRate: 0.0
120 
121  # Optical properties
122  # Fast and slow scintillation emission spectra, from [J Chem Phys vol 91 (1989) 1469]
123  FastScintEnergies: [ 6.0, 6.7, 7.1, 7.4, 7.7, 7.9, 8.1, 8.4, 8.5, 8.6, 8.8, 9.0, 9.1, 9.4, 9.8, 10.4, 10.7]
124  SlowScintEnergies: [ 6.0, 6.7, 7.1, 7.4, 7.7, 7.9, 8.1, 8.4, 8.5, 8.6, 8.8, 9.0, 9.1, 9.4, 9.8, 10.4, 10.7]
125  FastScintSpectrum: [ 0.0, 0.04, 0.12, 0.27, 0.44, 0.62, 0.80, 0.91, 0.92, 0.85, 0.70, 0.50, 0.31, 0.13, 0.04, 0.01, 0.0]
126  SlowScintSpectrum: [ 0.0, 0.04, 0.12, 0.27, 0.44, 0.62, 0.80, 0.91, 0.92, 0.85, 0.70, 0.50, 0.31, 0.13, 0.04, 0.01, 0.0]
127  ScintResolutionScale: 1. # resolution factor used by G4 scintillation
128  ScintFastTimeConst: 6. # fast scintillation time constant (ns)
129  ScintSlowTimeConst: 1590. # slow scintillation time constant (ns)
130  ScintBirksConstant: 0.069 # birks constant for LAr (1/MeV cm)
131  ScintYield: 24000. # total scintillation yield (ph/Mev)
132  ScintPreScale: 0.03 # Scale factor to reduce number of photons simulated
133  # Later QE should be corrected for this scale
134  ScintYieldRatio: 0.3 # fast / slow scint ratio (needs revisitting)
135  ScintByParticleType: false # whether to use different yields and
136  # quenching per particle in fast op sim
137  EnableCerenkovLight: true # whether to switch on cerenkov light (slow)
138 
139 
140 
141 
142  # Scintillation yields and fast/slow ratios per particle type
143  MuonScintYield: 24000
144  MuonScintYieldRatio: 0.23
145  PionScintYield: 24000
146  PionScintYieldRatio: 0.23
147  ElectronScintYield: 20000
148  ElectronScintYieldRatio: 0.27
149  KaonScintYield: 24000
150  KaonScintYieldRatio: 0.23
151  ProtonScintYield: 19200
152  ProtonScintYieldRatio: 0.29
153  AlphaScintYield: 16800
154  AlphaScintYieldRatio: 0.56
155 
156 
157  # Refractive index as a function of energy (eV) from arXiv:1502.04213v1
158  RIndexEnergies: [ 1.900, 2.934, 3.592, 5.566, 6.694, 7.540, 8.574, 9.044, 9.232, 9.420, 9.514, 9.608, 9.702, 9.796, 9.890, 9.984, 10.08, 10.27, 10.45, 10.74, 10.92 ]
159  RIndexSpectrum: [ 1.232, 1.236, 1.240, 1.261, 1.282, 1.306, 1.353, 1.387, 1.404, 1.423, 1.434, 1.446, 1.459, 1.473, 1.488, 1.505, 1.524, 1.569, 1.627, 1.751, 1.879 ]
160 
161  # absorption length as function of energy
162  AbsLengthEnergies: [ 4, 5, 6, 7, 8, 9, 10, 11 ]
163  AbsLengthSpectrum: [ 2000., 2000., 2000., 2000., 2000., 2000., 2000., 2000.]
164 
165  # Rayleigh scattering length (cm) @ 90K as a function of energy (eV) from arXiv:1502.04213
166  RayleighEnergies: [ 2.80, 3.00, 3.50, 4.00, 5.00, 6.00, 7.00, 8.00, 8.50, 9.00, 9.20, 9.40, 9.50, 9.60, 9.70, 9.80, 9.90, 10.0, 10.2, 10.4, 10.6, 10.8 ]
167  RayleighSpectrum: [ 47923., 35981., 18825., 10653., 3972., 1681., 750.9, 334.7, 216.8, 135.0, 109.7, 88.06, 78.32, 69.34, 61.06, 53.46, 46.50, 40.13, 28.91, 19.81, 12.61, 7.20 ]
168 
169  # Surface reflectivity data - vector of energy spectrum per
170  # surface type
171  ReflectiveSurfaceEnergies: [ 7, 9, 10 ]
172  ReflectiveSurfaceNames: [ "STEEL_STAINLESS_Fe7Cr2Ni" ]
173  ReflectiveSurfaceReflectances: [ [ 0.25, 0.25, 0.25 ] ]
174  ReflectiveSurfaceDiffuseFractions: [ [ 0.5, 0.5, 0.5 ] ]
175 )cfg"};
176 
177 
178 // this is a copy of the "standard" DetectorProperties configuration
180 service_provider: "DetectorPropertiesServiceStandard"
181 
182 # Drift properties
183 SternheimerA: 0.1956 # Ar Sternheimer parameter a.
184 SternheimerK: 3.0000 # Ar Sternheimer parameter k.
185 SternheimerX0: 0.2000 # Ar Sternheimer parameter x0.
186 SternheimerX1: 3.0000 # Ar Sternheimer parameter x0.
187 SternheimerCbar: 5.2146 # Ar Sternheimer parameter Cbar.
188 
189 Temperature: 87
190 Electronlifetime: 3.0e3
191 Efield: [0.5,0.666,0.8] #(predicted for microBooNE)
192 ElectronsToADC: 6.8906513e-3 # 1fC = 43.008 ADC counts for DUNE fd
193 NumberTimeSamples: 4492 # drift length/drift velocity*sampling rate = (359.4 cm)/(0.16 cm/us)*(2 MHz)
194 ReadOutWindowSize: 4492 # drift length/drift velocity*sampling rate = (359.4 cm)/(0.16 cm/us)*(2 MHz)
195 TimeOffsetU: 0.
196 TimeOffsetV: 0.
197 TimeOffsetZ: 0.
198 DriftVelFudgeFactor: 1.
199 
200 SimpleBoundaryProcess: true #enable opticalBoundaryProcessSimple instead of G4 default
201 
202 )cfg"};
static QCString name
Definition: declinfo.cpp:673
virtual Index size() const =0
const std::string LArPropertiesServiceConfigurationString
std::string string
Definition: nybbler.cc:12
struct vector vector
static void load_services(std::string const &config)
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
virtual const ChannelVector & channels(Index igrp) const =0
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
const std::string DetectorPropertiesServiceConfigurationString
virtual Name name(Index igrp) const =0
void line(double t, double *p, double &x, double &y, double &z)
int main(int argc, char *argv[])
int test_GeoApaChannelGroupService(string sgeo)
QTextStream & endl(QTextStream &s)