All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbndcode/sbndcode/CRT/CRTUtils/CRTHitRecoAlg.h
Go to the documentation of this file.
1 #ifndef CRTHITRECOALG_H_SEEN
2 #define CRTHITRECOALG_H_SEEN
3 
4 
5 ///////////////////////////////////////////////
6 // CRTHitRecoAlg.h
7 //
8 // Functions for CRT hit reconstruction
9 // T Brooks (tbrooks@fnal.gov), November 2018
10 ///////////////////////////////////////////////
11 
12 // framework
13 #include "art/Framework/Principal/Event.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "fhiclcpp/ParameterSet.h"
16 #include "art/Framework/Principal/Handle.h"
17 #include "canvas/Persistency/Common/Ptr.h"
18 #include "canvas/Persistency/Common/PtrVector.h"
19 #include "art/Framework/Services/Registry/ServiceHandle.h"
20 #include "messagefacility/MessageLogger/MessageLogger.h"
21 #include "canvas/Persistency/Common/FindManyP.h"
22 
23 // LArSoft
27 namespace detinfo {
28  class DetectorClocksData;
29  class DetectorPropertiesData;
30 }
31 
32 // Utility libraries
33 #include "messagefacility/MessageLogger/MessageLogger.h"
34 #include "fhiclcpp/ParameterSet.h"
35 #include "fhiclcpp/types/Table.h"
36 #include "fhiclcpp/types/Atom.h"
37 #include "cetlib/pow.h" // cet::sum_of_squares()
38 
44 
45 // c++
46 #include <iostream>
47 #include <stdio.h>
48 #include <sstream>
49 #include <vector>
50 #include <map>
51 #include <utility>
52 #include <cmath>
53 #include <memory>
54 
55 // ROOT
56 #include "TVector3.h"
57 #include "TGeoManager.h"
58 
59 
60 namespace sbnd{
61 
62  struct CRTStrip {
63  double t0; // [us]
64  uint32_t channel;
65  double x; // [cm]
66  double ex; // [cm]
67  double pes;
68  std::pair<std::string, unsigned> tagger;
69  size_t dataID;
70  };
71 
72 
73  class CRTHitRecoAlg {
74  public:
75 
76  struct Config {
77  using Name = fhicl::Name;
78  using Comment = fhicl::Comment;
79 
80  fhicl::Atom<bool> UseReadoutWindow {
81  Name("UseReadoutWindow"),
82  Comment("Only reconstruct hits within readout window")
83  };
84 
85  fhicl::Atom<double> QPed {
86  Name("QPed"),
87  Comment("Pedestal offset [ADC]")
88  };
89 
90  fhicl::Atom<double> QSlope {
91  Name("QSlope"),
92  Comment("Pedestal slope [ADC/photon]")
93  };
94 
95  fhicl::Atom<double> NpeScaleShift {
96  Name("NpeScaleShift"),
97  Comment("Parameter for correcting for distance along strip")
98  };
99 
100  fhicl::Atom<double> TimeCoincidenceLimit {
101  Name("TimeCoincidenceLimit"),
102  Comment("Minimum time between two overlapping hit crt strips")
103  };
104 
105  fhicl::Atom<double> ClockSpeedCRT {
106  Name("ClockSpeedCRT"),
107  Comment("Clock speed of the CRT system [MHz]")
108  };
109 
110  fhicl::Atom<double> TimeOffset {
111  Name("TimeOffset"),
112  Comment("The global time offset to use for the CRT times")
113  };
114  fhicl::Atom<bool> UseG4RefTimeOffset {
115  Name("UseG4RefTimeOffset"),
116  Comment("Wheater or not to use the G4RefTime as GlobalT0Offset"),
117  };
118  fhicl::Atom<double> PropDelay {
119  Name("PropDelay"),
120  Comment("Delay in pulse arrival time [ns/m]"),
121  };
122  fhicl::Atom<double> TDelayNorm {
123  Name("TDelayNorm"),
124  Comment("Time delay fit: Gaussian normalization"),
125  };
126  fhicl::Atom<double> TDelayShift {
127  Name("TDelayShift"),
128  Comment("Time delay fit: Gaussian x shift"),
129  };
130  fhicl::Atom<double> TDelaySigma {
131  Name("TDelaySigma"),
132  Comment("Time delay fit: Gaussian width"),
133  };
134  fhicl::Atom<double> TDelayOffset {
135  Name("TDelayOffset"),
136  Comment("Time delay fit: Gaussian baseline offset"),
137  };
138 
139 
140  };
141 
142  CRTHitRecoAlg(const Config& config, double g4RefTime);
143 
144  CRTHitRecoAlg(const fhicl::ParameterSet& pset, double g4RefTime) :
145  CRTHitRecoAlg(fhicl::Table<Config>(pset, {})(), g4RefTime) {}
146 
147  CRTHitRecoAlg();
148 
149  ~CRTHitRecoAlg();
150 
151  void reconfigure(const Config& config);
152 
153  std::map<std::pair<std::string, unsigned>, std::vector<CRTStrip>> CreateTaggerStrips(detinfo::DetectorClocksData const& clockData,
155  std::vector<art::Ptr<sbnd::crt::CRTData>> data);
156 
157  CRTStrip CreateCRTStrip(art::Ptr<sbnd::crt::CRTData> sipm1, art::Ptr<sbnd::crt::CRTData> sipm2, size_t ind);
158 
159  std::pair<double, double> DistanceBetweenSipms(art::Ptr<sbnd::crt::CRTData> sipm1, art::Ptr<sbnd::crt::CRTData> sipm2);
160 
161  std::vector<std::pair<sbn::crt::CRTHit, std::vector<int>>> CreateCRTHits(std::map<std::pair<std::string, unsigned>, std::vector<CRTStrip>> taggerStrips);
162 
163  // Function to calculate the strip position limits in real space from channel
164  std::vector<double> ChannelToLimits(CRTStrip strip);
165 
166  // Function to calculate the overlap between two crt strips
167  std::vector<double> CrtOverlap(std::vector<double> strip1, std::vector<double> strip2);
168 
169  // Function to return the CRT tagger name and module position from the channel ID
170  std::pair<std::string,unsigned> ChannelToTagger(uint32_t channel);
171 
172  // Function to check if a CRT strip overlaps with a perpendicular module
173  bool CheckModuleOverlap(uint32_t channel);
174 
175  // Function to make filling a CRTHit a bit faster
176  sbn::crt::CRTHit FillCrtHit(std::vector<uint8_t> tfeb_id, std::map<uint8_t,
177  std::vector<std::pair<int,float>>> tpesmap, float peshit, double time, int plane,
178  double x, double ex, double y, double ey, double z, double ez, std::string tagger);
179 
180  // Function to correct number of photoelectrons by distance down strip
181  double CorrectNpe(CRTStrip strip1, CRTStrip strip2, TVector3 position);
182 
183  // Function to correct the time by distance down strip
184  double CorrectTime(CRTStrip strip1, CRTStrip strip2, TVector3 position);
185 
186  private:
187 
190 
192  double fQPed;
193  double fQSlope;
197  double fTimeOffset;
199  double fPropDelay;
200  double fTDelayNorm;
201  double fTDelayShift;
202  double fTDelaySigma;
204 
205  };
206 
207 }
208 
209 #endif
process_name opflash particleana ie ie ie z
process_name opflash particleana ie x
Declaration of signal hit object.
CRTStrip CreateCRTStrip(art::Ptr< sbnd::crt::CRTData > sipm1, art::Ptr< sbnd::crt::CRTData > sipm2, size_t ind)
std::pair< std::string, unsigned > tagger
std::pair< double, double > DistanceBetweenSipms(art::Ptr< sbnd::crt::CRTData > sipm1, art::Ptr< sbnd::crt::CRTData > sipm2)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
process_name opflash particleana ie ie y
CRTHitRecoAlg(const fhicl::ParameterSet &pset, double g4RefTime)
std::map< std::pair< std::string, unsigned >, std::vector< CRTStrip > > CreateTaggerStrips(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< sbnd::crt::CRTData >> data)
double CorrectNpe(CRTStrip strip1, CRTStrip strip2, TVector3 position)
BEGIN_PROLOG vertical distance to the surface Name
std::vector< std::pair< sbn::crt::CRTHit, std::vector< int > > > CreateCRTHits(std::map< std::pair< std::string, unsigned >, std::vector< CRTStrip >> taggerStrips)
std::pair< std::string, unsigned > ChannelToTagger(uint32_t channel)
Provides recob::Track data product.
sbn::crt::CRTHit FillCrtHit(std::vector< uint8_t > tfeb_id, std::map< uint8_t, std::vector< std::pair< int, float >>> tpesmap, float peshit, double time, int plane, double x, double ex, double y, double ey, double z, double ez, std::string tagger)
Contains all timing reference information for the detector.
std::vector< double > CrtOverlap(std::vector< double > strip1, std::vector< double > strip2)
std::vector< double > ChannelToLimits(CRTStrip strip)
stream1 can override from command line with o or output services user sbnd
double CorrectTime(CRTStrip strip1, CRTStrip strip2, TVector3 position)
auto const detProp
CRTHitRecoAlg(const Config &config, double g4RefTime)