20 #include "art/Framework/Core/EDAnalyzer.h"
21 #include "art/Framework/Core/ModuleMacros.h"
22 #include "art/Framework/Principal/Event.h"
23 #include "art/Framework/Services/Registry/ServiceHandle.h"
24 #include "art_root_io/TFileService.h"
25 #include "canvas/Persistency/Common/FindManyP.h"
26 #include "messagefacility/MessageLogger/MessageLogger.h"
43 #include "range/v3/view.hpp"
128 , fSptalgTime(pset.
get<fhicl::ParameterSet>("SpacePointAlgTime"))
129 , fSptalgSep(pset.
get<fhicl::ParameterSet>("SpacePointAlgSep"))
130 , fSptalgDefault(pset.
get<fhicl::ParameterSet>("SpacePointAlgDefault"))
131 , fHitModuleLabel(pset.
get<
std::
string>("HitModuleLabel"))
132 , fUseClusterHits(pset.
get<
bool>("UseClusterHits"))
133 , fClusterModuleLabel(pset.
get<
std::
string>("ClusterModuleLabel"))
134 , fUseMC(pset.
get<
bool>("UseMC"))
135 , fMinX(pset.
get<
double>("MinX", -1.
e10))
136 , fMaxX(pset.
get<
double>("MaxX", 1.e10))
137 , fMinY(pset.
get<
double>("MinY", -1.e10))
138 , fMaxY(pset.
get<
double>("MaxY", 1.e10))
139 , fMinZ(pset.
get<
double>("MinZ", -1.e10))
140 , fMaxZ(pset.
get<
double>("MaxZ", 1.e10))
179 mf::LogInfo(
"SpacePointAna") <<
"SpacePointAna configured with the following parameters:\n"
180 <<
" HitModuleLabel = " << fHitModuleLabel <<
"\n"
181 <<
" UseClusterHits = " << fUseClusterHits <<
"\n"
182 <<
" ClusterModuleLabel = " << fClusterModuleLabel <<
"\n"
183 <<
" UseMC = " << fUseMC;
192 art::ServiceHandle<geo::Geometry const> geom;
193 art::ServiceHandle<art::TFileService>
tfs;
194 art::TFileDirectory
dir = tfs->mkdir(
"sptana",
"SpacePointAna histograms");
196 unsigned int nwiresU = 0, nwiresV = 0, nwiresW = 0;
202 for (
unsigned int cstat = 0; cstat < geom->Ncryostats(); ++cstat) {
205 unsigned int const ntpc = cryogeom.
NTPC();
207 for (
unsigned int tpc = 0; tpc < ntpc; ++tpc) {
210 unsigned int const nplane = tpcgeom.
Nplanes();
212 for (
unsigned int plane = 0; plane < nplane; ++plane) {
215 unsigned int nwires = pgeom.
Nwires();
228 fHDTUE = dir.make<TH1F>(
"MCDTUE",
"U-Drift Electrons Time Difference", 100, -5., 5.);
229 fHDTVE = dir.make<TH1F>(
"MCDTVE",
"V-Drift Electrons Time Difference", 100, -5., 5.);
230 fHDTWE = dir.make<TH1F>(
"MCDTWE",
"W-Drift Electrons Time Difference", 100, -5., 5.);
231 fHDTUPull = dir.make<TH1F>(
"MCDTUPull",
"U-Drift Electrons Time Pull", 100, -50., 50.);
232 fHDTVPull = dir.make<TH1F>(
"MCDTVPull",
"V-Drift Electrons Time Pull", 100, -50., 50.);
233 fHDTWPull = dir.make<TH1F>(
"MCDTWPull",
"W-Drift Electrons Time Pull", 100, -50., 50.);
236 fHDTUV = dir.make<TH1F>(
"DTUV",
"U-V time difference", 100, -20., 20.);
237 fHDTVW = dir.make<TH1F>(
"DTVW",
"V-W time difference", 100, -20., 20.);
238 fHDTWU = dir.make<TH1F>(
"DTWU",
"W-U time difference", 100, -20., 20.);
240 "DTUVU",
"U-V time difference vs. U", 100, 0., double(nwiresU), 100, -20., 20.);
242 "DTUVV",
"U-V time difference vs. V", 100, 0., double(nwiresV), 100, -20., 20.);
244 "DTVWV",
"V-W time difference vs. V", 100, 0., double(nwiresV), 100, -20., 20.);
246 "DTVWW",
"V-W time difference vs. W", 100, 0., double(nwiresW), 100, -20., 20.);
248 "DTWUW",
"W-U time difference vs. W", 100, 0., double(nwiresW), 100, -20., 20.);
250 "DTWUU",
"W-U time difference vs. U", 100, 0., double(nwiresU), 100, -20., 20.);
251 fHS = dir.make<TH1F>(
"DS",
"Spatial Separation", 100, -2., 2.);
253 fHchisq = dir.make<TH1F>(
"chisq",
"Chisquare", 100, 0., 20.);
255 fHx = dir.make<TH1F>(
"xpos",
"X Position", 100, 0., 2. * geom->DetHalfWidth());
257 dir.make<TH1F>(
"ypos",
"Y Position", 100, -geom->DetHalfHeight(), geom->DetHalfHeight());
258 fHz = dir.make<TH1F>(
"zpos",
"Z Position", 100, 0., geom->DetLength());
259 fHAmpU = dir.make<TH1F>(
"ampU",
"U Hit Amplitude", 50, 0., 50.);
260 fHAmpV = dir.make<TH1F>(
"ampV",
"V Hit Amplitude", 50, 0., 50.);
261 fHAmpW = dir.make<TH1F>(
"ampW",
"W Hit Amplitude", 50, 0., 50.);
262 fHAreaU = dir.make<TH1F>(
"areaU",
"U Hit Area", 100, 0., 500.);
263 fHAreaV = dir.make<TH1F>(
"areaV",
"V Hit Area", 100, 0., 500.);
264 fHAreaW = dir.make<TH1F>(
"areaW",
"W Hit Area", 100, 0., 500.);
265 fHSumU = dir.make<TH1F>(
"sumU",
"U Hit Sum ADC", 100, 0., 500.);
266 fHSumV = dir.make<TH1F>(
"sumV",
"V Hit Sum ADC", 100, 0., 500.);
267 fHSumW = dir.make<TH1F>(
"sumW",
"W Hit Sum ADC", 100, 0., 500.);
269 fHMCdx = dir.make<TH1F>(
"MCdx",
"X MC Residual", 100, -1., 1.);
270 fHMCdy = dir.make<TH1F>(
"MCdy",
"Y MC Residual", 100, -1., 1.);
271 fHMCdz = dir.make<TH1F>(
"MCdz",
"Z MC Residual", 100, -1., 1.);
272 fHMCxpull = dir.make<TH1F>(
"MCxpull",
"X MC Pull", 100, -50., 50.);
273 fHMCypull = dir.make<TH1F>(
"MCypull",
"Y MC Pull", 100, -50., 50.);
274 fHMCzpull = dir.make<TH1F>(
"MCzpull",
"Z MC Pull", 100, -50., 50.);
286 bool mc = !evt.isRealData();
291 art::ServiceHandle<geo::Geometry const> geom;
295 art::PtrVector<recob::Hit> hits;
301 art::Handle<std::vector<recob::Cluster>> clusterh;
307 if (clusterh.isValid()) {
308 int nclus = clusterh->size();
310 for (
int i = 0; i < nclus; ++i) {
311 art::Ptr<recob::Cluster> pclus(clusterh, i);
312 std::vector<art::Ptr<recob::Hit>> clushits = fm.at(i);
313 int nhits = clushits.size();
314 hits.reserve(hits.size() + nhits);
316 for (
std::vector<art::Ptr<recob::Hit>>::const_iterator ihit = clushits.begin();
317 ihit != clushits.end();
319 hits.push_back(*ihit);
328 art::Handle<std::vector<recob::Hit>> hith;
330 if (hith.isValid()) {
331 int nhits = hith->size();
334 for (
int i = 0; i < nhits; ++i)
335 hits.push_back(art::Ptr<recob::Hit>(hith, i));
341 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
343 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
347 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
351 for (
auto const& hitPtr : hits) {
360 std::vector<double> hitxyz = bt_serv->HitToXYZ(clockData, hit);
364 catch (cet::exception&
x) {
369 fHDTUE->Fill(tpeak - tav);
373 fHDTVE->Fill(tpeak - tav);
377 fHDTWE->Fill(tpeak - tav);
381 throw cet::exception(
"SpacePointAna") <<
"Bad view = " << hit.
View() <<
"\n";
386 std::vector<recob::SpacePoint> spts1;
387 std::vector<recob::SpacePoint> spts2;
388 std::vector<recob::SpacePoint> spts3;
401 MF_LOG_DEBUG(
"SpacePointAna")
402 <<
"Found " << spts1.size() <<
" space points using special time cut.";
416 MF_LOG_DEBUG(
"SpacePointAna")
417 <<
"Found " << spts2.size() <<
" space points using special seperation cut.";
429 MF_LOG_DEBUG(
"SpacePointAna") <<
"Found " << spts3.size()
430 <<
" space points using default cuts.";
436 for (
auto const& spt : spts1) {
437 if (spt.XYZ()[0] <
fMinX || spt.XYZ()[0] >
fMaxX || spt.XYZ()[1] <
fMinY ||
449 unsigned int tpc1 = hit1WireID.
TPC;
450 unsigned int plane1 = hit1WireID.
Plane;
451 unsigned int wire1 = hit1WireID.
Wire;
458 unsigned int tpc2 = hit2WireID.
TPC;
459 unsigned int plane2 = hit2WireID.
Plane;
460 unsigned int wire2 = hit2WireID.
Wire;
464 if (tpc1 == tpc2 && plane1 != plane2) {
472 fHDTUVU->Fill(
double(wire1), t1 - t2);
473 fHDTUVV->Fill(
double(wire2), t1 - t2);
477 fHDTWUW->Fill(
double(wire2), t2 - t1);
478 fHDTWUU->Fill(
double(wire1), t2 - t1);
484 fHDTVWV->Fill(
double(wire1), t1 - t2);
485 fHDTVWW->Fill(
double(wire2), t1 - t2);
489 fHDTUVU->Fill(
double(wire2), t2 - t1);
490 fHDTUVV->Fill(
double(wire1), t2 - t1);
496 fHDTWUW->Fill(
double(wire1), t1 - t2);
497 fHDTWUU->Fill(
double(wire2), t1 - t2);
501 fHDTVWV->Fill(
double(wire2), t2 - t1);
502 fHDTVWW->Fill(
double(wire1), t2 - t1);
512 for (
auto const& spt : spts2) {
513 if (spt.XYZ()[0] <
fMinX || spt.XYZ()[0] >
fMaxX || spt.XYZ()[1] <
fMinY ||
530 for (
auto const& spt : spts3) {
531 if (spt.XYZ()[0] <
fMinX || spt.XYZ()[0] >
fMaxX || spt.XYZ()[1] <
fMinY ||
536 fHx->Fill(spt.XYZ()[0]);
537 fHy->Fill(spt.XYZ()[1]);
538 fHz->Fill(spt.XYZ()[2]);
542 std::vector<art::Ptr<recob::Hit>> spthits;
544 for (
auto const& ptr : av_spthits) {
545 spthits.push_back(ptr);
550 for (
auto const& hitPtr : spthits) {
574 art::ServiceHandle<cheat::BackTrackerService const> bt_serv;
577 std::vector<double> mcxyz = bt_serv->SpacePointHitsToWeightedXYZ(clockData, spthits);
578 fHMCdx->Fill(spt.XYZ()[0] - mcxyz[0]);
579 fHMCdy->Fill(spt.XYZ()[1] - mcxyz[1]);
580 fHMCdz->Fill(spt.XYZ()[2] - mcxyz[2]);
581 if (spt.ErrXYZ()[0] > 0.)
582 fHMCxpull->Fill((spt.XYZ()[0] - mcxyz[0]) / std::sqrt(spt.ErrXYZ()[0]));
583 if (spt.ErrXYZ()[2] > 0.)
584 fHMCypull->Fill((spt.XYZ()[1] - mcxyz[1]) / std::sqrt(spt.ErrXYZ()[2]));
585 if (spt.ErrXYZ()[5] > 0.)
586 fHMCzpull->Fill((spt.XYZ()[2] - mcxyz[2]) / std::sqrt(spt.ErrXYZ()[5]));
588 catch (cet::exception&) {
bool merge() const noexcept
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
constexpr to_element_t to_element
process_name opflash particleana ie x
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
geo::WireID WireID() const
unsigned int Nplanes() const
Number of planes in this tpc.
Declaration of signal hit object.
Geometry information for a single TPC.
CryostatID_t Cryostat
Index of cryostat.
Planes which measure Z direction.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
geo::View_t View() const
View for the plane of the hit.
WireID_t Wire
Index of the wire within its plane.
Geometry information for a single cryostat.
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
const SpacePointAlg fSptalgSep
float PeakAmplitude() const
The estimated amplitude of the hit at its peak, in ADC units.
void makeMCTruthSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
double separation(const art::PtrVector< recob::Hit > &hits) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
View_t View() const
Which coordinate does this plane measure.
std::string fHitModuleLabel
void makeSpacePoints(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::PtrVector< recob::Hit > &hits, std::vector< recob::SpacePoint > &spts) const
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
void analyze(const art::Event &evt) override
unsigned int NTPC() const
Number of TPCs in this cryostat.
PlaneID_t Plane
Index of the plane within its TPC.
double correctedTime(detinfo::DetectorPropertiesData const &detProp, const recob::Hit &hit) const
Declaration of cluster object.
float PeakTime() const
Time of the signal peak, in tick units.
SpacePointAna(fhicl::ParameterSet const &pset)
Encapsulate the construction of a single detector plane.
const SpacePointAlg fSptalgTime
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
unsigned int Nwires() const
Number of wires in this plane.
void bookHistograms(bool mc)
float SummedADC() const
The sum of calibrated ADC counts of the hit (0. by default)
const SpacePointAlg fSptalgDefault
constexpr WireID()=default
Default constructor: an invalid TPC ID.
then echo ***************************************echo Variable FHICL_FILE_PATH not found echo You porbably haven t set up larsoft echo Try setup uboonecode vXX_XX_XX q e10
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
2D representation of charge deposited in the TDC/wire plane
art::ServiceHandle< art::TFileService > tfs
TPCID_t TPC
Index of the TPC within its cryostat.
Algorithm for generating space points from hits.
std::string fClusterModuleLabel
art framework interface to geometry description
Encapsulate the construction of a single detector plane.