Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DTAGHGeometry.cc
Go to the documentation of this file.
1 //
2 // File: DTAGHGeometry.cc
3 // Created: Sat Jul 5 10:18:56 EST 2014
4 // Creator: jonesrt on gluey.phys.uconn.edu
5 //
6 
7 #include <stdlib.h>
8 #include <iostream>
9 #include <map>
10 
11 #include <JANA/JApplication.h>
12 #include <JANA/JEvent.h>
13 #include "DTAGHGeometry.h"
14 
15 const unsigned int DTAGHGeometry::kCounterCount = 274;
16 
17 //---------------------------------
18 // DTAGHGeometry (Constructor)
19 //---------------------------------
21 {
22  /* read tagger set endpoint energy from calibdb */
23  std::map<string,double> result1;
24  loop->GetCalib("/PHOTON_BEAM/endpoint_energy", result1);
25  if (result1.find("PHOTON_BEAM_ENDPOINT_ENERGY") == result1.end()) {
26  std::cerr << "Error in DTAGHGeometry constructor: "
27  << "failed to read photon beam endpoint energy "
28  << "from calibdb at /PHOTON_BEAM/endpoint_energy" << std::endl;
30  }
31  else {
32  m_endpoint_energy_GeV = result1["PHOTON_BEAM_ENDPOINT_ENERGY"];
33  }
34 
35  /* read hodoscope counter energy bounds from calibdb */
36  std::vector<std::map<string,double> > result2;
37  loop->GetCalib("/PHOTON_BEAM/hodoscope/scaled_energy_range", result2);
38  if (result2.size() != kCounterCount) {
39  jerr << "Error in DTAGHGeometry constructor: "
40  << "failed to read photon beam scaled_energy_range table "
41  << "from calibdb at /PHOTON_BEAM/hodoscope/scaled_energy_range" << std::endl;
42  for (unsigned int i=0; i <= TAGH_MAX_COUNTER; ++i) {
43  m_counter_xlow[i] = 0;
44  m_counter_xhigh[i] = 0;
45  }
46  }
47  else {
48  for (unsigned int i=0; i < result2.size(); ++i) {
49  int ctr = (result2[i])["counter"];
50  m_counter_xlow[ctr] = (result2[i])["xlow"];
51  m_counter_xhigh[ctr] = (result2[i])["xhigh"];
52  }
53  }
54 }
55 
57 
58 bool DTAGHGeometry::E_to_counter(double E, unsigned int &counter) const
59 {
60  double x = E/m_endpoint_energy_GeV;
61  for (counter=1; counter <= kCounterCount; ++counter) {
62  if ( x >= m_counter_xlow[counter] &&
63  x <= m_counter_xhigh[counter] )
64  {
65  return true;
66  }
67  }
68  return false;
69 }
70 
71 double DTAGHGeometry::getElow(unsigned int counter) const
72 {
73  if (counter > 0 && counter <= kCounterCount)
75  else
76  return 0;
77 }
78 
79 double DTAGHGeometry::getEhigh(unsigned int counter) const
80 {
81  if (counter > 0 && counter <= kCounterCount)
83  else
84  return 0;
85 }
double getElow(unsigned int counter) const
#define TAGH_MAX_COUNTER
Definition: DTAGHGeometry.h:18
Double_t x[NCHANNELS]
Definition: st_tw_resols.C:39
double m_counter_xhigh[TAGH_MAX_COUNTER+1]
Definition: DTAGHGeometry.h:42
double counter
Definition: FitGains.C:151
double getEhigh(unsigned int counter) const
double m_counter_xlow[TAGH_MAX_COUNTER+1]
Definition: DTAGHGeometry.h:41
double m_endpoint_energy_GeV
Definition: DTAGHGeometry.h:40
static const unsigned int kCounterCount
Definition: DTAGHGeometry.h:28
bool E_to_counter(double E, unsigned int &counter) const
DTAGHGeometry(JEventLoop *loop)