All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TimeCompatMatch.cxx
Go to the documentation of this file.
1 #ifndef OPT0FINDER_TIMECOMPATMATCH_CXX
2 #define OPT0FINDER_TIMECOMPATMATCH_CXX
3 
4 #include "TimeCompatMatch.h"
5 
6 #ifndef USING_LARSOFT
7 #define USING_LARSOFT 1
8 #endif
9 
10 namespace flashmatch {
11 
13 
15  : BaseProhibitAlgo(name)
16  {}
17 
19  {
20  _time_buffer = pset.get<double>("TimeBuffer");
21  }
22 
23  bool TimeCompatMatch::MatchCompatible(const QCluster_t& clus, const Flash_t& flash)
24  {
25  if(clus.empty()) {
26  FLASH_INFO() << "QCluster_t is empty." << std::endl;
27  return false;
28  }
29 
30  // get time of flash
31  auto flash_time = flash.time;
32 
33  // get time of cluster by looking at the range of x-positions
34  // FIXME: 1036?
35  double clus_x_min = 1036.; // cm
36  double clus_x_max = -1036.; // cm
37  for (auto const& pt : clus){
38  if (pt.x > clus_x_max) { clus_x_max = pt.x; }
39  if (pt.x < clus_x_min) { clus_x_min = pt.x; }
40  }
41 
42  FLASH_INFO() << "Cluster x min: " << clus_x_min << ", x max: " << clus_x_max << std::endl;
43 
44  // Earliest flash time => assume clus_x_max is @ detector X-max boundary
45  #if USING_LARSOFT == 1
46  double xmax = DetectorSpecs::GetME().ActiveVolume().Max()[0];
47  double clus_t_min = (clus_x_max - xmax) / DetectorSpecs::GetME().DriftVelocity();
48  double clus_t_max = clus_x_min / DetectorSpecs::GetME().DriftVelocity();
49  #else
50  double xmax = DetectorSpecs::GetME().ActiveVolume().Max()[0];
51  double clus_t_min = (clus_x_max - xmax) / DetectorSpecs::GetME().DriftVelocity();
52  double clus_t_max = clus_x_min / DetectorSpecs::GetME().DriftVelocity();
53  #endif
54  FLASH_INFO() << "Cluster xmax: " << xmax << ", clus_t_min: " << clus_t_min
55  << ", clus_t_max: " << clus_t_max
56  << ", flash_time: " << flash_time << std::endl;
57 
58  /*
59  std::cout<< "Inspecting TPC object @ " << clus.time << std::endl;
60  std::cout<< "xmin = " << clus_x_min << " ... xmax = " << clus_x_max << std::endl;
61  std::cout<< "tmin = " << clus_t_min << " ... tmax = " << clus_t_max << std::endl;
62  std::cout<< "Flash time @ " << flash_time << std::endl;
63  */
64  return ((clus_t_min - _time_buffer) < flash_time && flash_time < (clus_t_max + _time_buffer));
65 
66  }
67 
68 
69 }
70 #endif
double _time_buffer
Buffer time to allow some uncertainty [us].
const geoalgo::AABox & ActiveVolume() const
Detector active volume.
Definition: FMWKInterface.h:54
Class def header for a class TimeCompatMatch.
static TimeCompatMatchFactory __global_TimeCompatMatchFactory__
#define FLASH_INFO()
Compiler macro for INFO message.
fhicl::ParameterSet Config_t
Configuration object.
Definition: FMWKInterface.h:31
static DetectorSpecs & GetME(std::string filename="detector_specs.cfg")
Definition: FMWKInterface.h:44
Struct to represent an optical flash.
TimeCompatMatch(const std::string name="TimeCompatMatch")
Default constructor.
Collection of charge deposition 3D point (cluster)
bool MatchCompatible(const QCluster_t &clus, const Flash_t &flash)
CORE FUNCTION: determines if a flash and cluster are at all compatible (bool return) ...
const Point_t & Max() const
Maximum point getter.
then echo fcl name
double DriftVelocity() const
Drift velocity.
Definition: FMWKInterface.h:63
double time
Flash timing, a candidate T0.
void _Configure_(const Config_t &pset)