All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRTHitConverter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: CRTHitConverter
3 // Plugin Type: producer (art v3_02_06)
4 // File: CRTHitConverter_module.cc
5 //
6 // Generated at Wed Feb 19 17:38:21 2020 by Gray Putnam using cetskelgen
7 // from cetlib version v3_07_02.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDProducer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
20 
21 //#include "Products/CRTHit.hh"
24 
25 #include <memory>
26 
27 namespace sbn {
28  class CRTHitConverter;
29 }
30 
31 
32 class sbn::CRTHitConverter : public art::EDProducer {
33 public:
34  explicit CRTHitConverter(fhicl::ParameterSet const& p);
35  // The compiler-generated destructor is fine for non-base
36  // classes without bare pointers or other resource use.
37 
38  // Plugins should not be copied or assigned.
39  CRTHitConverter(CRTHitConverter const&) = delete;
40  CRTHitConverter(CRTHitConverter&&) = delete;
41  CRTHitConverter& operator=(CRTHitConverter const&) = delete;
43 
44  // Required functions.
45  void produce(art::Event& e) override;
46 
47 private:
48 
49  art::InputTag fCRTHitLabel;
50  std::string fExperiment;
51 
52 };
53 
55  sbn::crt::CRTHit ret;
56 
57  ret.peshit = inp.peshit;
58  ret.ts0_s = inp.ts0_s;
59  ret.ts0_s_corr = inp.ts0_s_corr;
60  ret.ts0_ns = inp.ts0_ns;
61  ret.ts0_ns_corr = inp.ts0_ns_corr;
62  ret.ts1_ns = inp.ts1_ns;
63  ret.plane = inp.plane;
64  ret.x_pos = inp.x_pos;
65  ret.x_err = inp.x_err;
66  ret.y_pos = inp.y_pos;
67  ret.y_err = inp.y_err;
68  ret.z_pos = inp.z_pos;
69  ret.z_err = inp.z_err;
70  ret.tagger = inp.tagger;
71 
72  return ret;
73 }
74 
76  sbn::crt::CRTHit ret;
77  ret.feb_id = inp.feb_id;
78  ret.pesmap = inp.pesmap;
79  // convert ADC -> PE's
80  // TODO: fix -- hardcoded for now as temporary hack
81  unsigned n_strip = 2;
82  double baseline = 63.6; // ADC
83  double gain = 70; // ADC / PE
84  ret.peshit = (inp.peshit - n_strip*baseline) / (gain * n_strip);
85  ret.ts0_s = inp.ts0_s;
86  ret.ts0_s_corr = inp.ts0_s_corr;
87  ret.ts0_ns = inp.ts0_ns;
88  ret.ts0_ns_corr = inp.ts0_ns_corr;
89 
90  ret.ts1_ns = inp.ts1_ns;
91 
92  ret.plane = inp.plane;
93  ret.x_pos = inp.x_pos;
94  ret.x_err = inp.x_err;
95  ret.y_pos = inp.y_pos;
96  ret.y_err = inp.y_err;
97  ret.z_pos = inp.z_pos;
98  ret.z_err = inp.z_err;
99  ret.tagger = inp.tagger;
100  return ret;
101 }
102 
103 
104 sbn::CRTHitConverter::CRTHitConverter(fhicl::ParameterSet const& p)
105  : EDProducer{p},
106  fCRTHitLabel(p.get<std::string>("CRTHitLabel", "crthit")),
107  fExperiment(p.get<std::string>("Experiment"))
108 {
109  if (fExperiment != "SBND" && fExperiment != "ICARUS") {
110  std::cerr << "ERROR: Bad experiment configuration (" << fExperiment << "). Experiment must be one of 'SBND' or 'ICARUS'";
111  }
112 
113  produces< std::vector<sbn::crt::CRTHit> >();
114 }
115 
117 {
118 
119  std::unique_ptr<std::vector<sbn::crt::CRTHit>> crthits(new std::vector<sbn::crt::CRTHit>);
120 
121  if (fExperiment == "SBND") {
122  art::Handle<std::vector<sbnd::crt::CRTHit>> crthit_handle;
123  e.getByLabel(fCRTHitLabel, crthit_handle);
124  if (crthit_handle.isValid()) {
125  for (const sbnd::crt::CRTHit &sbndhit: *crthit_handle) {
126  crthits->push_back(SBNDCRTHit(sbndhit));
127  }
128  }
129  }
130  else if (fExperiment == "ICARUS") {
131  art::Handle<std::vector<icarus::crt::CRTHit>> crthit_handle;
132  e.getByLabel(fCRTHitLabel, crthit_handle);
133  if (crthit_handle.isValid()) {
134  for (const icarus::crt::CRTHit &icarushit: *crthit_handle) {
135  crthits->push_back(ICARUSCRTHit(icarushit));
136  }
137  }
138  }
139 
140  e.put(std::move(crthits));
141 
142 }
143 
144 DEFINE_ART_MODULE(sbn::CRTHitConverter)
float z_err
position uncertainty in z-direction (cm).
Definition: CRTHit.hh:43
CRTHitConverter(fhicl::ParameterSet const &p)
float x_err
position uncertainty in x-direction (cm).
Definition: CRTHit.hh:39
std::map< uint8_t, std::vector< std::pair< int, float > > > pesmap
Saves signal hit information (FEB, local-channel and PE) .
Definition: CRTHit.hh:26
std::vector< uint8_t > feb_id
FEB address.
Definition: CRTHit.hh:25
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
Definition: CRTHit.hh:34
BEGIN_PROLOG could also be cerr
int plane
Name of the CRT wall (in the form of numbers).
Definition: CRTHit.hh:36
float peshit
Total photo-electron (PE) in a crt hit.
Definition: CRTHit.hh:27
float y_err
position uncertainty in y-direction (cm).
Definition: CRTHit.hh:41
pdgs p
Definition: selectors.fcl:22
double ts0_ns_corr
[Honestly, not sure at this point, it was there since long time (BB)]
Definition: CRTHit.hh:33
sbn::crt::CRTHit ICARUSCRTHit(const icarus::crt::CRTHit &inp)
double ts0_s_corr
[Honestly, not sure at this point, it was there since long time (BB)]
Definition: CRTHit.hh:30
uint64_t ts0_s
Second-only part of timestamp T0.
Definition: CRTHit.hh:29
float z_pos
position in z-direction (cm).
Definition: CRTHit.hh:42
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
Definition: CRTHit.hh:32
std::map< uint8_t, std::vector< std::pair< int, float > > > pesmap
CRTHitConverter & operator=(CRTHitConverter const &)=delete
BEGIN_PROLOG baseline
void produce(art::Event &e) override
float y_pos
position in y-direction (cm).
Definition: CRTHit.hh:40
float x_pos
position in x-direction (cm).
Definition: CRTHit.hh:38
do i e
sbn::crt::CRTHit SBNDCRTHit(const sbnd::crt::CRTHit &inp)
std::string tagger
Name of the CRT wall (in the form of strings).
Definition: CRTHit.hh:45
std::string tagger
std::vector< uint8_t > feb_id