All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | List of all members
util::LArPropTest Class Reference
Inheritance diagram for util::LArPropTest:

Public Member Functions

 LArPropTest (fhicl::ParameterSet const &pset)
 

Private Member Functions

void beginJob () override
 
void analyze (const art::Event &evt) override
 

Detailed Description

Definition at line 23 of file LArPropTest_module.cc.

Constructor & Destructor Documentation

util::LArPropTest::LArPropTest ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 34 of file LArPropTest_module.cc.

34 : EDAnalyzer(pset) {}

Member Function Documentation

void util::LArPropTest::analyze ( const art::Event &  evt)
overrideprivate

Definition at line 130 of file LArPropTest_module.cc.

131  {}
void util::LArPropTest::beginJob ( )
overrideprivate

Definition at line 37 of file LArPropTest_module.cc.

38  {
39  // Make sure assert is enabled.
40 
41  bool assert_flag = false;
42  assert((assert_flag = true, assert_flag));
43  if (!assert_flag) {
44  std::cerr << "Assert is disabled" << std::endl;
45  abort();
46  }
47 
48  // Get services.
49 
50  detinfo::LArProperties const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
51  auto const detprop =
52  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataForJob();
53 
54  // Test (default) accessors.
55 
56  std::cout << "Density = " << detprop.Density() << " g/cm^3" << std::endl;
57  std::cout << "Drift velocity = " << detprop.DriftVelocity() << " cm/usec" << std::endl;
58  std::cout << "Efield = " << detprop.Efield() << " kV/cm" << std::endl;
59  std::cout << "Temperature = " << detprop.Temperature() << " Kelvin" << std::endl;
60  std::cout << "Electron lifetime = " << detprop.ElectronLifetime() << " usec" << std::endl;
61  std::cout << "Radiation Length = " << larprop->RadiationLength() << " g/cm^2" << std::endl;
62  std::cout << "Radiation Length = " << larprop->RadiationLength() / detprop.Density() << " cm"
63  << std::endl;
64 
65  // Make sure default values are acting correctly.
66 
67  assert(detprop.Density() == detprop.Density(detprop.Temperature()));
68  assert(detprop.Density() != detprop.Density(detprop.Temperature() + 0.1));
69  assert(detprop.DriftVelocity() == detprop.DriftVelocity(detprop.Efield()));
70  assert(detprop.DriftVelocity() ==
71  detprop.DriftVelocity(detprop.Efield(), detprop.Temperature()));
72 
73  // Drift velocity vs. electric field.
74 
75  std::cout << "\nDrift Velocity vs. Electric Field.\n"
76  << " E (kV/cm) v (cm/us)" << std::fixed << std::endl;
77  for (int i = 0; i < 3; ++i) {
78  double e = 0.5;
79  if (i == 1)
80  e = 0.666667;
81  else if (i == 2)
82  e = 0.8;
83  double v = detprop.DriftVelocity(e);
84  std::cout << std::setprecision(3) << std::setw(15) << e << std::setprecision(4)
85  << std::setw(15) << v << std::endl;
86  }
87 
88  // dE/dx.
89 
90  std::cout
91  << "\nCompare "
92  "http://pdg.lbl.gov/2011/AtomicNuclearProperties/MUON_ELOSS_TABLES/muonloss_289.dat\n"
93  << std::endl;
94 
95  double mass = 0.10565839; // Muon.
96  double fact[16] = {
97  1.0, 1.2, 1.4, 1.7, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 7.0, 8.0, 9.0};
98 
99  std::ios_base::fmtflags flags = std::cout.flags();
100  std::cout << " T p Ionization dE/dx|_R\n"
101  << " [MeV] [MeV/c] ---[MeV cm^2/g]----\n"
102  << std::scientific << std::setprecision(3);
103 
104  // Loop over kinetic energy.
105 
106  for (double tbase = 1.; tbase <= 1.e9; tbase *= 10.) {
107  for (int i = 0; i < 16; ++i) {
108 
109  // T in MeV.
110 
111  double t = tbase * fact[i];
112  if (t > 1.e9) break;
113 
114  // Calculate momentum in GeV/C
115 
116  double p = std::sqrt(1.e-6 * t * t + 2.e-3 * t * mass);
117 
118  // Calculate restricted and unrestricted dE/dx.
119 
120  double dedxr = detprop.Eloss(p, mass, 0.05) / detprop.Density(); // Restricted.
121  double dedx = detprop.Eloss(p, mass, 0.) / detprop.Density(); // Unrestricted.
122  std::cout << std::setw(10) << t << std::setw(10) << 1000. * p << std::setw(10) << dedx
123  << std::setw(10) << dedxr << std::endl;
124  }
125  }
126  std::cout.flags(flags);
127  }
BEGIN_PROLOG could also be cerr
pdgs p
Definition: selectors.fcl:22
float mass
Definition: dedx.py:47
do i e
virtual double RadiationLength() const =0
BEGIN_PROLOG could also be cout

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