24 #include "art_root_io/TFileService.h" 25 #include "canvas/Persistency/Common/FindManyP.h" 43 #include "range/v3/view.hpp" 46 using ranges::views::transform;
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" 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) {
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());
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.);
308 int nclus = clusterh->size();
310 for (
int i = 0; i < nclus; ++i) {
312 std::vector<art::Ptr<recob::Hit>> clushits = fm.at(i);
313 int nhits = clushits.size();
317 ihit != clushits.end();
331 int nhits = hith->size();
334 for (
int i = 0; i < nhits; ++i)
351 for (
auto const& hitPtr : hits) {
360 std::vector<double> hitxyz = bt_serv->
HitToXYZ(clockData, hit);
361 tav = detProp.ConvertXToTicks(
369 fHDTUE->Fill(tpeak - tav);
373 fHDTVE->Fill(tpeak - tav);
377 fHDTWE->Fill(tpeak - tav);
386 std::vector<recob::SpacePoint> spts1;
387 std::vector<recob::SpacePoint> spts2;
388 std::vector<recob::SpacePoint> spts3;
402 <<
"Found " << spts1.size() <<
" space points using special time cut.";
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 ||
447 for (
auto const& hit1 : spthits | transform(
to_element)) {
449 unsigned int tpc1 = hit1WireID.
TPC;
450 unsigned int plane1 = hit1WireID.
Plane;
451 unsigned int wire1 = hit1WireID.
Wire;
456 for (
auto const& hit2 : spthits | transform(
to_element)) {
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) {
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]));
void reserve(size_type n)
constexpr to_element_t to_element
geo::Length_t DetHalfWidth(geo::TPCID const &tpcid) const
Returns the half width of the active volume of the specified TPC.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
geo::WireID WireID() const
unsigned int Nplanes() const
Number of planes in this tpc.
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.
std::vector< double > HitToXYZ(detinfo::DetectorClocksData const &clockData, const recob::Hit &hit) const
Geometry information for a single cryostat.
EDAnalyzer(fhicl::ParameterSet const &pset)
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
const SpacePointAlg fSptalgSep
art framework interface to geometry description
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
bool isValid() const noexcept
View_t View() const
Which coordinate does this plane measure.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
#define DEFINE_ART_MODULE(klass)
std::string fHitModuleLabel
void push_back(Ptr< U > const &p)
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.
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
bool merge() const noexcept
PlaneID_t Plane
Index of the plane within its TPC.
double correctedTime(detinfo::DetectorPropertiesData const &detProp, const recob::Hit &hit) const
Detector simulation of raw signals on wires.
float PeakTime() const
Time of the signal peak, in tick units.
Declaration of signal hit object.
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.
std::vector< double > SpacePointHitsToWeightedXYZ(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> const &hits) const
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.
static constexpr double fm
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
auto const & get(AssnsNode< L, R, D > const &r)
TPCID_t TPC
Index of the TPC within its cryostat.
Algorithm for generating space points from hits.
std::string fClusterModuleLabel
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane.