-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathLightPropagationCorrection_module.hh
More file actions
243 lines (203 loc) · 8.24 KB
/
LightPropagationCorrection_module.hh
File metadata and controls
243 lines (203 loc) · 8.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
// art includes
#include "art/Framework/Core/EDProducer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "art/Persistency/Common/PtrMaker.h"
#include "art/Utilities/make_tool.h"
#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "art_root_io/TFileService.h"
#include "canvas/Persistency/Common/FindManyP.h"
#include "canvas/Persistency/Common/FindOneP.h"
// ROOT and C++ includes
#include <TTree.h>
#include <string.h>
// Services
#include "lardataalg/DetectorInfo/DetectorClocksData.h"
#include "lardata/DetectorInfoServices/DetectorClocksService.h"
#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
#include "larcore/Geometry/Geometry.h"
#include "larcore/Geometry/WireReadout.h"
#include "lardata/Utilities/AssociationUtil.h"
// G4 includes
#include "lardataobj/Simulation/SimChannel.h"
#include "lardataobj/Simulation/SimPhotons.h"
#include "lardataobj/Simulation/SimEnergyDeposit.h"
// Reco includes
// PDS
#include "lardataobj/RecoBase/OpFlash.h"
#include "lardataobj/RecoBase/OpHit.h"
#include "lardataobj/RawData/OpDetWaveform.h"
// TPC
#include "lardataobj/RecoBase/Slice.h"
#include "lardataobj/RecoBase/SpacePoint.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RecoBase/PFParticle.h"
#include "nusimdata/SimulationBase/MCTruth.h"
#include "nusimdata/SimulationBase/MCNeutrino.h"
#include "nusimdata/SimulationBase/MCParticle.h"
#include "lardataobj/Simulation/SimEnergyDeposit.h"
#include "lardataobj/Simulation/SimChannel.h"
#include "lardataobj/RawData/RawDigit.h"
#include "lardataobj/RecoBase/Track.h"
#include "lardataobj/RecoBase/Shower.h"
#include "lardataobj/RecoBase/PFParticle.h"
#include "lardataobj/RecoBase/SpacePoint.h"
#include "lardataobj/RecoBase/Cluster.h"
#include "lardataobj/RecoBase/OpFlash.h"
#include "lardataobj/RecoBase/OpHit.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RawData/RawDigit.h"
#include "lardataobj/RecoBase/Wire.h"
#include "lardataobj/RecoBase/Vertex.h"
#include "lardataobj/RecoBase/Slice.h"
#include "lardataobj/AnalysisBase/Calorimetry.h"
#include "lardataobj/AnalysisBase/ParticleID.h"
#include "lardataobj/AnalysisBase/T0.h"
#include "lardataobj/RecoBase/PFParticleMetadata.h"
// CRT
#include "sbnobj/SBND/CRT/CRTTrack.hh"
// Cosmic rejection includes
#include "sbnobj/Common/Reco/OpT0FinderResult.h"
#include "sbnobj/Common/Reco/SimpleFlashMatchVars.h"
#include "sbnobj/Common/Reco/CRUMBSResult.h"
#include "sbnobj/Common/Reco/TPCPMTBarycenterMatch.h"
#include "sbnobj/Common/Reco/CorrectedOpFlashTiming.h"
#include "sbnobj/SBND/Timing/DAQTimestamp.hh"
#include "lardataobj/AnalysisBase/T0.h"
// Geometry and mapping
#include "larcore/Geometry/WireReadout.h"
#include "sbndcode/OpDetSim/sbndPDMapAlg.hh"
#include <iostream>
#include <fstream>
// Flash finder utilities
#include "sbndcode/OpDetReco/OpFlash/FlashFinder/FlashFinderManager.h"
#include "sbndcode/OpDetReco/OpFlash/FlashFinder/FlashFinderFMWKInterface.h"
#include "sbndcode/OpDetReco/OpFlash/FlashFinder/PECalib.h"
#include "sbndcode/OpDetReco/OpFlash/FlashTools/FlashGeoBase.hh"
#include "sbndcode/OpDetReco/OpFlash/FlashTools/FlashT0Base.hh"
#include "sbndcode/OpDetReco/OpFlash/FlashTools/DriftEstimatorBase.hh"
#define fXFidCut1 1.5
#define fXFidCut2 190
#define fYFidCut 190
#define fZFidCut1 10
#define fZFidCut2 490
#define xdet_size 1000
#define ydet_size 1000
#define zmindet_size -500
#define zmaxdet_size 1800
#define fDefaulNeutrinoID 99999
namespace sbnd {
class LightPropagationCorrection;
}
class sbnd::LightPropagationCorrection : public art::EDProducer {
public:
explicit LightPropagationCorrection(fhicl::ParameterSet const& p);
// The compiler-generated destructor is fine for non-base
// classes without bare pointers or other resource use.
// Plugins should not be copied or assigned.
LightPropagationCorrection(LightPropagationCorrection const&) = delete;
LightPropagationCorrection(LightPropagationCorrection&&) = delete;
LightPropagationCorrection& operator=(LightPropagationCorrection const&) = delete;
LightPropagationCorrection& operator=(LightPropagationCorrection&&) = delete;
private:
// Required functions.
void produce(art::Event & e) override;
void endJob() override;
void beginJob() override;
// Selected optional functions.
void ResetEventVars();
void ResetSliceInfo();
size_t HighestOpT0ScoreIdx(const std::vector< art::Ptr<sbn::OpT0Finder> >);
size_t HighestBFMScoreIdx(const std::vector< art::Ptr<sbn::TPCPMTBarycenterMatch> > );
void GetPropagationTimeCorrectionPerChannel();
void CorrectOpHitTime(std::vector<art::Ptr<recob::OpHit>> , std::vector<recob::OpHit> & );
void FillLiteOpHit(std::vector<recob::OpHit> const& , std::vector<::lightana::LiteOpHit_t>& );
void FillCorrectionTree(double & , recob::OpFlash const& , std::vector<recob::OpHit> const& , std::vector<recob::OpHit> const& );
::lightana::LiteOpHitArray_t GetAssociatedLiteHits(::lightana::LiteOpFlash_t , ::lightana::LiteOpHitArray_t );
geo::WireReadoutGeom const& fWireReadout = art::ServiceHandle<geo::WireReadout>()->Get();
opdet::sbndPDMapAlg fPDSMap;
//Flash finder manager
::lightana::FlashFinderManager _mgr;
::lightana::FlashFinderManager _mgr_tpc0;
::lightana::FlashFinderManager _mgr_tpc1;
// Tool for calculating the OpFlash Y and Z centers
std::unique_ptr<lightana::FlashGeoBase> _flashgeo;
// Tool for calculating the OpFlash t0
std::unique_ptr<lightana::FlashT0Base> _flasht0calculator;
//Vector for PMT position
std::vector<double> fOpDetID;
std::vector<double> fOpDetX;
std::vector<double> fOpDetY;
std::vector<double> fOpDetZ;
std::string fReco2Label;
std::string fOpT0FinderModuleLabel;
std::string fTPCPMTBarycenterFMModuleLabel;
std::string fOpFlashLabel_tpc0;
std::string fOpFlashLabel_tpc1;
std::string fSpacePointLabel;
std::string fOpHitsModuleLabel;
std::string fOpFlashNewLabel;
std::string fSPECTDCLabel;
std::string fFlashMatchingTool;
bool fSaveCorrectionTree;
std::vector<double> fTimeCorrectionPerChannel;
double fRecoVx = 0.0;
double fRecoVy = 0.0;
double fRecoVz = 0.0;
//Space Point Variables
std::vector<double> fSpacePointX;
std::vector<double> fSpacePointY;
std::vector<double> fSpacePointZ;
std::vector<double> fSpacePointIntegral;
//Charge Barycenter
std::vector<double> fChargeBarycenterX{0.,0.};
std::vector<double> fChargeBarycenterY{0.,0.};
std::vector<double> fChargeBarycenterZ{0.,0.};
std::vector<double> fChargeWeightX{0.,0.};
std::vector<double> fChargeWeightY{0.,0.};
std::vector<double> fChargeWeightZ{0.,0.};
std::vector<double> fChargeTotalWeight{0.,0.};
double fDriftDistance; // Total Drift Distance
double fSpeedOfLight; // Speed of light in mm/ns
double fVISLightPropTime;
double fKinkDistance;
double fVGroupVUV_I;
double fVGroupVIS;
double fVGroupVUV; // Speed of light in vacuum in mm/ns
double fNuScoreThreshold;
double fFMScoreThreshold;
bool fDebug;
art::ServiceHandle<art::TFileService> tfs;
TTree *fTree;
int fEvent;
int fRun;
int fSubrun;
double _fNuScore;
double _fFMScore;
double fEventTriggerTime=-999999.;
double fRWMTime=-999999.;
std::vector<double> fNuScore;
std::vector<double> fFMScore;
std::vector<double> fOpFlashTimeOld;
std::vector<double> fOpFlashTimeNew;
std::vector<double> fOpFlashXCenter;
std::vector<double> fOpFlashYCenter;
std::vector<double> fOpFlashZCenter;
std::vector<double> fOpFlashPE;
std::vector<double> fSliceVx;
std::vector<double> fSliceVy;
std::vector<double> fSliceVz;
std::vector<std::vector<double>> fSliceSPX;
std::vector<std::vector<double>> fSliceSPY;
std::vector<std::vector<double>> fSliceSPZ;
std::vector<std::vector<double>> fOpHitOldTime;
std::vector<std::vector<double>> fOpHitNewTime;
std::vector<std::vector<double>> fOpHitPE;
std::vector<std::vector<int>> fOpHitOpCh;
};
DEFINE_ART_MODULE(sbnd::LightPropagationCorrection)