All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LightPath.cxx
Go to the documentation of this file.
1 #ifndef LightPath_CXX
2 #define LightPath_CXX
3 
4 #include "LightPath.h"
5 
6 namespace flashmatch {
7 
9 
10  LightPath::LightPath(const std::string name)
11  : BaseAlgorithm(kCustomAlgo, name)
12  , _gap ( 0.5 )
13  , _light_yield ( 40000. )
14  , _dEdxMIP ( 2.07 ) //1.42[Mev*cm^2*g]*1.4[g/cm^3]=2.004MeV/cm
15  {}
16 
17  void LightPath::_Configure_(const Config_t &pset)
18  {
19  _gap = pset.get< double > ( "SegmentSize" );
20  _light_yield = pset.get< double > ( "LightYield" );
21  _dEdxMIP = pset.get< double > ( "MIPdEdx" );
22  }
23 
24  void LightPath::MakeQCluster(const ::geoalgo::Vector& pt_1,
25  const ::geoalgo::Vector& pt_2,
26  QCluster_t& Q_cluster,
27  double dedx) const {
28 
29  if(dedx < 0) dedx = _dEdxMIP;
30 
31  double dist = pt_1.Dist(pt_2);
32  QPoint_t q_pt;
33  FLASH_INFO() << "Filling points between (" << pt_1[0] << "," << pt_1[1] << "," << pt_1[2] << ")"
34  << " => (" << pt_2[0] << "," << pt_2[1] << "," << pt_2[2] << ") ... dist="<<dist<<std::endl;
35  if (dist <= _gap) {
36  ::geoalgo::Vector mid_pt((pt_1 + pt_2) / 2.);
37  q_pt.x = mid_pt[0];
38  q_pt.y = mid_pt[1];
39  q_pt.z = mid_pt[2];
40  q_pt.q = _light_yield * _dEdxMIP * dist;
41  FLASH_DEBUG() << "Smaller than gap threshold (" << _gap << ")" << std::endl
42  << "Traj pt (" << q_pt.x << "," << q_pt.y << "," << q_pt.z << ") q=" << q_pt.q << std::endl;
43  Q_cluster.emplace_back(q_pt);
44  return;
45  }
46 
47  int num_div = int(dist / _gap);
48 
49  ::geoalgo::Vector direct = (pt_1 - pt_2).Dir();
50 
51  Q_cluster.reserve(Q_cluster.size() + num_div);
52 
53  for (int div_index = 0; div_index < num_div + 1; div_index++) {
54  if (div_index < num_div) {
55  auto const mid_pt = pt_2 + direct * (_gap * div_index + _gap / 2.);
56  q_pt.x = mid_pt[0] ;
57  q_pt.y = mid_pt[1];
58  q_pt.z = mid_pt[2];
59  q_pt.q = _light_yield * _dEdxMIP * _gap;
60  FLASH_DEBUG() << "Traj pt (" << q_pt.x << "," << q_pt.y << "," << q_pt.z << ") q=" << q_pt.q << std::endl;
61  Q_cluster.emplace_back(q_pt);
62  }
63  else {
64  double weight = (dist - int(dist / _gap) * _gap);
65  auto const mid_pt = pt_2 + direct * (_gap * div_index + weight / 2.);
66  q_pt.x = mid_pt[0] ;
67  q_pt.y = mid_pt[1];
68  q_pt.z = mid_pt[2];
69  q_pt.q = _light_yield * _dEdxMIP * weight;
70  FLASH_DEBUG() << "Traj pt (" << q_pt.x << "," << q_pt.y << "," << q_pt.z << ") q=" << q_pt.q << std::endl;
71  Q_cluster.emplace_back(q_pt);
72  }//Last segment less than gap
73  }
74  }
75 
76  QCluster_t LightPath::MakeQCluster(const ::geoalgo::Trajectory& trj) const {
77 
78  QCluster_t result;
79  result.clear();
80 
81  for (size_t i = 0; i < trj.size() - 1; i++) {
82  auto const& this_loc(trj[i]);
83  auto const& last_loc(trj[i + 1]);
84  LightPath::MakeQCluster(this_loc, last_loc, result);
85  }
86 
87  // Trimming Q_cluster
88  auto const& bbox = DetectorSpecs::GetME().ActiveVolume();
89  double _vol_xmax = bbox.Max()[0];
90  double _vol_ymax = bbox.Max()[1];
91  double _vol_zmax = bbox.Max()[2];
92 
93  double _vol_xmin = bbox.Min()[0];
94  double _vol_ymin = bbox.Min()[1];
95  double _vol_zmin = bbox.Min()[2];
96  FLASH_INFO() << result << std::endl;
97  QCluster_t final_result;
98  final_result.clear();
99  for (size_t idx = 0; idx < result.size(); ++idx) {
100  auto pt = result[idx];
101  if (pt.x >= _vol_xmin && pt.x <= _vol_xmax && pt.y >= _vol_ymin && pt.y <= _vol_ymax && pt.z >= _vol_zmin && pt.z <= _vol_zmax) {
102  final_result.push_back(pt);
103  }
104  }
105  FLASH_INFO() << final_result << std::endl;
106 
107  return final_result;
108  }
109 
110 }
111 
112 
113 #endif
const geoalgo::AABox & ActiveVolume() const
Detector active volume.
Definition: FMWKInterface.h:54
Struct to represent an energy deposition point in 3D space.
double z
Spatial position in [cm].
#define FLASH_INFO()
Compiler macro for INFO message.
Class def header for a class LightPath.
fhicl::ParameterSet Config_t
Configuration object.
Definition: FMWKInterface.h:31
static DetectorSpecs & GetME(std::string filename="detector_specs.cfg")
Definition: FMWKInterface.h:44
flashmatch::QCluster_t MakeQCluster(const ::geoalgo::Trajectory &trj) const
Definition: LightPath.cxx:76
LightPath(const std::string name="LightPath")
Default constructor.
Definition: LightPath.cxx:10
static LightPathFactory __global_LightPathFactory__
Definition: LightPath.cxx:8
Collection of charge deposition 3D point (cluster)
Algorithm type that does not play a role in the framework execution but inherits from BaseAlgorithm...
#define FLASH_DEBUG()
Compiler macro for DEBUG message.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
const Point_t & Max() const
Maximum point getter.
then echo fcl name
void _Configure_(const Config_t &pset)
Definition: LightPath.cxx:17