DDTHelpers.cxx
Go to the documentation of this file.
1 #include "DDTTools/DDTHelpers.h"
2 
3 #include "Geometry/Geometry.h"
5 
7 
8 #include <boost/format.hpp>
9 
10 
11 
13 (std::vector<art::Ptr<rb::CellHit> > const& hits,
14  int32_t t_start, int32_t t_end, int16_t adc_cut)
15 {
17 
18  for (auto const& hit : hits)
19  if (hit->TDC() >= t_start &&
20  hit->TDC() <= t_end &&
21  hit->ADC() >= adc_cut)
22  result.Add(hit);
23 
24  return result;
25 }
26 
27 
28 
30 (novaddt::DAQHit const& ddthit, art::Ptr<rb::CellHit> const& cellhit,
31  novaddt::TDC const& event_time)
32 {
33  int64_t ddt_time = ddthit.TDC().val - event_time;
34 
35  if (ddt_time != cellhit->TDC())
36  return false;
37 
38  if (ddthit.ADC().val != cellhit->ADC())
39  return false;
40 
41  if (ddthit.Plane().val != cellhit->Plane())
42  return false;
43 
44  if (ddthit.Cell().val != cellhit->Cell())
45  return false;
46 
47  return true;
48 }
49 
50 
51 
53 (novaddt::DAQHit const& ddthit, rawdata::RawDigit const& digit,
54  novaddt::TDC const& event_time)
55 {
56  int64_t ddt_time = ddthit.TDC().val - event_time;
57 
58  if (ddt_time != digit.TDC())
59  return false;
60 
61  if (ddthit.ADC().val != digit.ADC(0))
62  return false;
63 
64  return true;
65 }
66 
67 
68 
70 (novaddt::DAQHit const& lhs, novaddt::DAQHit const& rhs)
71 {
72  if (lhs.TDC().val != rhs.TDC().val)
73  return false;
74 
75  if (lhs.ADC().val != rhs.ADC().val)
76  return false;
77 
78  return true;
79 }
80 
81 
82 
84 (novaddt::DAQHit const& h, unsigned long long const& event_time)
85 {
86  int64_t relative_time =
87  static_cast<int64_t>(h.TDC().val) - static_cast<int64_t>(event_time);
88 
89  double time_in_us = static_cast<double>(relative_time) / 64.0e6 * 1.0e6;
90 
93  view = "xz";
95  view = "yz";
96  else
97  view = "bad";
98 
100  TVector3 position;
101  geom->Plane(h.Plane().val)->Cell(h.Cell().val)->GetCenter(position);
102 
103  boost::format form("(%2s, %3u, %3u) (%6.2f, %6.2f, %6.2f) "
104  "%5u ADC %20u TDC = %6.2f us");
105  std::cout <<
106  form % view % h.Plane().val % h.Cell().val %
107  position.X() % position.Y() % position.Z() %
108  h.ADC().val % relative_time % time_in_us
109  << std::endl;
110 }
111 
112 
113 
115 {
116  boost::format form("%7s %4u %4u %5u %20u");
117 
119  if (h->View() == geo::View_t::kX)
120  view = "xz";
121  else if (h->View() == geo::View_t::kY)
122  view = "yz";
123  else
124  view = "bad";
125 
126  std::cout <<
127  form % view % h->Plane() % h->Cell() %
128  h->ADC() % h->TDC()
129  << std::endl;
130 }
131 
132 
133 
135 {
136  boost::format form("%7s %4u %4u %5u %20u");
137 
138  std::cout <<
139  form % "?" % 0 % 0 %
140  h.ADC(0) % h.TDC()
141  << std::endl;
142 }
143 
144 
145 
146 void ddthelpers::print(std::vector<novaddt::TriggerDecision> const& decisions)
147 {
148  boost::format form("%20u %6u %6u");
149 
150  for (auto const& d : decisions)
151  std::cout <<
152  form % d.start() % (d.start() + d.duration()) % d.duration()
153  << std::endl;
154 }
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
value_type val
Definition: BaseProducts.h:34
rb::Cluster cluster_hits(std::vector< art::Ptr< rb::CellHit > > const &hits, int32_t t_start, int32_t t_end, int16_t adc_cut=0)
Definition: DDTHelpers.cxx:13
novaddt::Plane const & Plane() const
Definition: DAQHit.h:70
unsigned short Plane() const
Definition: CellHit.h:39
geo::View_t View() const
Definition: CellHit.h:41
novaddt::TDC const & TDC() const
Definition: DAQHit.h:74
value_type val
Definition: BaseProducts.h:109
A collection of associated CellHits.
Definition: Cluster.h:47
const PlaneGeo * Plane(unsigned int i) const
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Definition: Cluster.cxx:84
Identifier for the Y measuring view of the detector (side)
unsigned short Cell() const
Definition: CellHit.h:40
void hits()
Definition: readHits.C:15
void print(novaddt::DAQHit const &h, unsigned long long const &event_time=0)
Definition: DDTHelpers.cxx:84
novaddt::ADC const & ADC() const
Definition: DAQHit.h:73
novaddt::View const & View() const
Definition: DAQHit.h:72
Identifier for the X measuring view of the detector (top)
Float_t d
Definition: plot.C:236
value_type val
Definition: BaseProducts.h:84
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
int16_t ADC(uint32_t i) const
Definition: RawDigit.cxx:58
Definition: structs.h:12
void geom(int which=0)
Definition: geom.C:163
Definition: geo.h:1
value_type val
Definition: BaseProducts.h:137
novaddt::Cell const & Cell() const
Definition: DAQHit.h:71
value_type val
Definition: BaseProducts.h:65
Encapsulate the geometry of one entire detector (near, far, ndos)
bool is_equal(novaddt::DAQHit const &ddthit, art::Ptr< rb::CellHit > const &cellhit, novaddt::TDC const &event_time)
Definition: DDTHelpers.cxx:30