1 #ifndef SBN_FLASHMATCH_FLASHPREDICT_HH
2 #define SBN_FLASHMATCH_FLASHPREDICT_HH
4 #include "art/Framework/Core/EDProducer.h"
5 #include "art/Framework/Core/ModuleMacros.h"
6 #include "art/Framework/Principal/Event.h"
7 #include "art/Framework/Principal/Handle.h"
8 #include "art/Framework/Principal/Run.h"
9 #include "art/Framework/Principal/SubRun.h"
10 #include "art/Persistency/Common/PtrMaker.h"
11 #include "art/Utilities/make_tool.h"
12 #include "art_root_io/TFileService.h"
14 #include "canvas/Persistency/Common/Ptr.h"
15 #include "canvas/Persistency/Common/PtrVector.h"
16 #include "canvas/Persistency/Common/Assns.h"
17 #include "canvas/Persistency/Common/FindManyP.h"
18 #include "canvas/Persistency/Provenance/ProductID.h"
19 #include "canvas/Utilities/InputTag.h"
21 #include "fhiclcpp/ParameterSet.h"
22 #include "messagefacility/MessageLogger/MessageLogger.h"
39 #include "nusimdata/SimulationBase/MCParticle.h"
51 #include "nusimdata/SimulationBase/MCParticle.h"
52 #include "nusimdata/SimulationBase/MCTruth.h"
91 const art::Ptr<recob::PFParticle>& pfp_ptr_,
93 const std::set<unsigned>& tpcWithHits_) :
98 const art::Ptr<recob::PFParticle>& pfp_ptr_,
100 const std::set<unsigned>& tpcWithHits_,
101 const double mcT0_) :
108 using OpHitIt = std::vector<recob::OpHit>::iterator;
115 double maxpeak_time_) :
126 double q_,
bool metric_ok_) :
133 std::ostringstream
stream;
135 <<
" x: " <<
x <<
"\n"
136 <<
" x_gl: " <<
x_gl <<
"\n"
137 <<
" y: " <<
y <<
"\n"
138 <<
" z: " <<
z <<
"\n"
139 <<
" q: " <<
q <<
"\n"
151 FlashMetrics(
double x_,
double x_gl_,
double y_,
double yb_,
double z_,
double zb_,
152 double rr_,
double pe_,
double unpe_,
double ratio_,
double time_,
153 double h_x_,
double h_xerr_,
double h_xrr_,
double h_xratio_,
154 double y_skew_,
double z_skew_,
156 x(x_),
x_gl(x_gl_),
y(y_),
yb(yb_),
z(z_),
zb(zb_),
171 std::ostringstream
stream;
173 <<
" x: " <<
x <<
"\n"
174 <<
" x_gl: " <<
x_gl <<
"\n"
175 <<
" y: " <<
y <<
"\n"
176 <<
" yb: " <<
yb <<
"\n"
177 <<
" z: " <<
z <<
"\n"
178 <<
" zb: " <<
zb <<
"\n"
179 <<
" rr: " <<
rr <<
"\n"
180 <<
" pe: " <<
pe <<
"\n"
181 <<
" unpe: " <<
unpe <<
"\n"
182 <<
" ratio: " <<
ratio <<
"\n"
183 <<
" time: " <<
time <<
"\n"
184 <<
" h_x: " <<
h_x <<
"\n"
185 <<
" h_xerr: " <<
h_xerr <<
"\n"
186 <<
" h_xrr: " <<
h_xrr <<
"\n"
188 <<
" y_skew: " <<
y_skew <<
"\n"
189 <<
" z_skew: " <<
z_skew <<
"\n"
190 <<
" metric_ok: " << std::boolalpha <<
metric_ok <<
"\n";
209 const std::vector<art::Ptr<simb::MCParticle>>& mcParticles);
215 const std::set<unsigned>& tpcWithHits,
216 const int pdgc)
const;
218 double flash_rr,
double flash_ratio)
const;
220 double flash_rr,
double flash_ratio)
const;
222 double metric_value,
const TH2D* metric_h2)
const;
224 const art::Event& evt,
225 const art::ValidHandle<std::vector<recob::PFParticle>>& pfps_h);
226 void addDaughters(
const std::unordered_map<size_t, size_t>& pfpMap,
227 const art::Ptr<recob::PFParticle>& pfp_ptr,
228 const art::ValidHandle<std::vector<recob::PFParticle>>& pfps_h,
229 std::vector<art::Ptr<recob::PFParticle>>& pfp_v)
const;
230 unsigned trueNus(art::Event& evt)
const;
234 inline double scoreTerm(
const double m,
const double n,
235 const double mean,
const double spread)
const;
237 const double mean,
const double spread)
const;
239 const art::ValidHandle<std::vector<recob::PFParticle>>& pfps_h)
const;
241 std::vector<recob::OpHit>& opHits,
242 const art::Handle<std::vector<recob::OpHit>>& ophit_h)
const;
244 std::vector<recob::OpHit>& opHits,
245 std::vector<recob::OpHit>& opHitsRght,
246 std::vector<recob::OpHit>& opHitsLeft)
const;
248 std::vector<recob::OpHit>& opHits)
const;
250 const std::vector<recob::OpHit>& opHits,
251 std::vector<recob::OpHit>& opHitsRght,
252 std::vector<recob::OpHit>& opHitsLeft,
253 std::unique_ptr<TH1D>& opHitsTimeHist,
254 std::unique_ptr<TH1D>& opHitsTimeHistRght,
255 std::unique_ptr<TH1D>& opHitsTimeHistLeft)
const;
257 const std::vector<recob::OpHit>& opHits,
258 std::unique_ptr<TH1D>& opHitsTimeHist)
const;
260 std::vector<SimpleFlash>& simpleFlashes,
261 std::vector<recob::OpHit>& opHits,
262 const unsigned ophsInVolume,
263 std::unique_ptr<TH1D>& opHitsTimeHist)
const;
264 inline std::string
detectorName(
const std::string detName)
const;
267 const std::set<unsigned>& tpcWithHits)
const;
274 double flashXGl(
const double hypo_x,
const double flash_x)
const;
275 double foldXGl(
const double x_gl)
const;
277 template <
typename Stream>
280 template <
typename Stream>
285 const std::set<unsigned>& tpcWithHits,
330 static constexpr
unsigned kRght = 0;
331 static constexpr
unsigned kLeft = 1;
341 std::unique_ptr<TF1>
f;
347 const std::array<std::string, 3>
kSuffixes{
"l",
"h",
"m"};
348 static constexpr
double kEps = 1
e-4;
389 #endif //SBN_FLASHMATCH_FLASHPREDICT_HH
const bool fForceConcurrence
static constexpr int kNoPFPInEvt
double cheatMCT0(const std::vector< art::Ptr< recob::Hit >> &hits, const std::vector< art::Ptr< simb::MCParticle >> &mcParticles)
std::vector< double > fdZMeans
std::vector< double > fRRSpreads
ChargeDigest(const size_t pId_, const int pfpPDGC_, const art::Ptr< recob::PFParticle > &pfp_ptr_, const flashmatch::QCluster_t &qClusters_, const std::set< unsigned > &tpcWithHits_)
detinfo::DetectorClocksData const fClockData
double foldXGl(const double x_gl) const
static constexpr unsigned kActivityInRght
flashmatch::QCluster_t qClusters
static constexpr int kNotANuScr
static constexpr unsigned kRght
void printMetrics(const std::string metric, const ChargeMetrics &charge, const FlashMetrics &flash, const int pdgc, const std::set< unsigned > &tpcWithHits, const double term, Stream &&out) const
const std::string fDetector
bool isPDInCryo(const int pdChannel) const
process_name opflash particleana ie x
const double fBeamWindowStart
bool isSBNDPDRelevant(const int pdChannel, const std::set< unsigned > &tpcWithHits) const
unsigned driftVolume(const double x) const
const double fTermThreshold
Declaration of signal hit object.
const art::ServiceHandle< geo::Geometry > fGeometry
const std::array< std::string, 3 > kSuffixes
void updateChargeMetrics(const ChargeMetrics &chargeMetrics)
static constexpr unsigned kLeft
BEGIN_PROLOG or score(default)}sbnd_crttrackmatchingalg_crID
static constexpr int kNoChrgScr
void copyOpHitsInBeamWindow(std::vector< recob::OpHit > &opHits, const art::Handle< std::vector< recob::OpHit >> &ophit_h) const
const art::InputTag fOpHitARAProducer
const art::InputTag fPandoraProducer
static constexpr unsigned kActivityInBoth
Score computeScore(const ChargeMetrics &charge, const FlashMetrics &flash, const std::set< unsigned > &tpcWithHits, const int pdgc) const
std::string detectorName(const std::string detName) const
FlashPredict & operator=(FlashPredict const &)=delete
bool pfpNeutrinoOnEvent(const art::ValidHandle< std::vector< recob::PFParticle >> &pfps_h) const
static constexpr double kNoScrQ
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
std::string dumpMetrics() const
std::vector< double > fRatioMeans
SimpleFlash(unsigned flashId_, unsigned ophsInVolume_, OpHitIt opH_beg_, OpHitIt opH_end_, double maxpeak_time_)
ChargeMetrics(double x_, double x_gl_, double y_, double z_, double q_, bool metric_ok_)
std::tuple< double, double > xEstimateAndRMS(double metric_value, const TH2D *metric_h2) const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Access the description of detector geometry.
static constexpr int kQNoOpHScr
const std::list< double > fWiresX_gl
const double fBeamWindowEnd
unsigned trueNus(art::Event &evt) const
This is the interface class for a tool to handle PD mapping in SBN detectors, used for flash matching...
const double fMinParticleQ
Utilities for matching a recob::Hit or vector of recob::Hit to the ID of the most significantly contr...
void printBookKeeping(Stream &&out)
std::vector< double > fdYMeans
const bool fUseUncoatedPMT
const std::string fInputFilename
static constexpr int kNoSlcInEvt
std::string dumpMetrics() const
std::tuple< double, double, double, double > hypoFlashX_fits(double flash_rr, double flash_ratio) const
TTree * _flashmatch_nuslice_tree
std::array< Fits, 3 > fRRFits
unsigned icarusPDinTPC(const int pdChannel) const
const std::string fRR_TF1_fit
Collection of charge deposition 3D point (cluster)
static constexpr double kEps
unsigned fTPCPerDriftVolume
double driftDistance() const
static constexpr double kNoScrTime
std::tuple< double, double, double, double > hypoFlashX_H2(double flash_rr, double flash_ratio) const
ChargeDigestMap makeChargeDigest(const art::Event &evt, const art::ValidHandle< std::vector< recob::PFParticle >> &pfps_h)
double scoreTerm(const double m, const double n, const double mean, const double spread) const
std::vector< SimpleFlash > makeSimpleFlashes(std::vector< recob::OpHit > &opHits, std::vector< recob::OpHit > &opHitsRght, std::vector< recob::OpHit > &opHitsLeft) const
ChargeDigest(const size_t pId_, const int pfpPDGC_, const art::Ptr< recob::PFParticle > &pfp_ptr_, const flashmatch::QCluster_t &qClusters_, const std::set< unsigned > &tpcWithHits_, const double mcT0_)
std::vector< double > fdZSpreads
bool findSimpleFlashes(std::vector< SimpleFlash > &simpleFlashes, std::vector< recob::OpHit > &opHits, const unsigned ophsInVolume, std::unique_ptr< TH1D > &opHitsTimeHist) const
FlashPredict(fhicl::ParameterSet const &p)
void produce(art::Event &evt) override
Encapsulate the geometry of a wire.
std::list< double > wiresXGl() const
double wallXWithMaxPE(const OpHitIt opH_beg, const OpHitIt opH_end) const
const bool fSelectNeutrino
static constexpr unsigned kActivityInLeft
const double fMinSpacePointQ
ChargeMetrics computeChargeMetrics(const flashmatch::QCluster_t &qClusters) const
const double fDriftDistance
void updateFlashMetrics(const FlashMetrics &flashMetrics)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
std::array< Fits, 3 > fRatioFits
void updateScore(const Score &score)
bool createOpHitsTimeHist(const std::vector< recob::OpHit > &opHits, std::vector< recob::OpHit > &opHitsRght, std::vector< recob::OpHit > &opHitsLeft, std::unique_ptr< TH1D > &opHitsTimeHist, std::unique_ptr< TH1D > &opHitsTimeHistRght, std::unique_ptr< TH1D > &opHitsTimeHistLeft) const
std::vector< double > fRRMeans
const art::InputTag fSpacePointProducer
static constexpr bool kNoScr
Contains all timing reference information for the detector.
std::map< double, ChargeDigest, std::greater< double >> ChargeDigestMap
static constexpr double kNoScrPE
const double fChargeToNPhotonsTrack
std::vector< double > fdYSpreads
const art::InputTag fOpHitProducer
const unsigned fOpDetNormalizer
const bool fOnlyCollectionWires
const std::string fRatio_TF1_fit
FlashMetrics computeFlashMetrics(const SimpleFlash &simpleFlash) const
double flashXGl(const double hypo_x, const double flash_x) const
std::vector< double > fRatioSpreads
std::set< unsigned > tpcWithHits
const bool fStoreCheatMCT0
std::vector< recob::OpHit >::iterator OpHitIt
static constexpr int kNoOpHInEvt
static constexpr unsigned kMinEntriesInProjection
const std::unique_ptr< opdet::PDMapAlg > fPDMapAlgPtr
static constexpr int k0VUVPEScr
const bool fNoAvailableMetrics
art::Ptr< recob::PFParticle > pfp_ptr
void addDaughters(const std::unordered_map< size_t, size_t > &pfpMap, const art::Ptr< recob::PFParticle > &pfp_ptr, const art::ValidHandle< std::vector< recob::PFParticle >> &pfps_h, std::vector< art::Ptr< recob::PFParticle >> &pfp_v) const
const std::unique_ptr< geo::CryostatGeo > fGeoCryo
const bool fUseOppVolMetric
helper function for LArPandoraInterface producer module
unsigned sbndPDinTPC(const int pdChannel) const
art framework interface to geometry description
const double fChargeToNPhotonsShower
const unsigned fMaxFlashes
FlashMetrics(double x_, double x_gl_, double y_, double yb_, double z_, double zb_, double rr_, double pe_, double unpe_, double ratio_, double time_, double h_x_, double h_xerr_, double h_xrr_, double h_xratio_, double y_skew_, double z_skew_, bool metric_ok_)