33 #include "Utilities/AssociationUtil.h" 34 #include "Utilities/func/MathUtil.h" 64 std::vector<double>& mcx,
65 std::vector<double>& mcy,
66 std::vector<double>& mcz);
135 this->produces< std::vector<rb::Vertex> >();
136 this->produces< std::vector<rb::Prong> >();
137 this->produces<art::Assns<rb::Vertex, rb::Cluster> >();
138 this->produces<art::Assns<rb::Prong, rb::Cluster> >();
150 "run:subrun:evt:e:nhit:m:sumvia:xf:yf:zf:xmc:ymc:zmc");
153 fHitNt = f->
make<TNtuple>(
"hnt",
"hnt",
"run:subrun:evt:xy:z:view:a:mia:via");
157 ";x(fit) - x(mc) [cm];Events",
160 ";y(fit) - y(mc) [cm];Events",
163 ";z(fit) - z(mc) [cm];Events",
172 #define SET(N) { f##N = p.get<__typeof__(f##N)>(#N); } 181 SET(MaxHoughResults);
192 SET(HoughPeakAsymCut);
193 SET(GridSearchColinear);
195 SET(GridSearchLambda);
202 SET(HoughResultLabel);
205 SET(ObeyPreselection);
241 std::vector<double> dxv;
242 std::vector<double> dyv;
243 std::vector<double> bxv;
244 std::vector<double> byv;
247 if(i < hrx.
fPeak.size()) {
252 if(i < hry.
fPeak.size()) {
270 double dx, bx,
dy, by;
271 for(i = 0; i <
n; ++
i) {
274 for(j = 0; j <
n; ++
j) {
299 std::vector<double>& mcx,
300 std::vector<double>& mcy,
301 std::vector<double>& mcz)
307 mcx.resize(mclist->size());
308 mcy.resize(mclist->size());
309 mcz.resize(mclist->size());
310 for (j=0; j<mclist->size(); ++
j) {
326 std::unique_ptr< std::vector<rb::Vertex> > vtx(
new std::vector<rb::Vertex>);
327 std::unique_ptr< std::vector<rb::Prong> > prg(
new std::vector<rb::Prong>);
328 std::unique_ptr< art::Assns<rb::Vertex, rb::Cluster> >
330 std::unique_ptr< art::Assns<rb::Prong, rb::Cluster> >
344 for(i = 0; i < slice->size(); ++
i) {
364 std::vector<const rb::HoughResult*>
hr = fmhr.at(i);
365 for(j = 0; j < hr.size(); ++
j) {
376 if(hrx == 0 || hry == 0)
continue;
377 if(hrx->
fPeak.size() < 1)
continue;
378 if(hry->
fPeak.size() < 1)
continue;
384 for(j = 0; j < hrx->
fPeak.size(); ++
j) {
388 for(j = 0; j < hry->
fPeak.size(); ++
j) {
391 unsigned int nprong = 1;
392 if(nx > nprong) nprong = nx;
393 if(ny > nprong) nprong = ny;
399 std::vector<double> zs;
400 for (j = 0; j < neighbors.
NCell(); ++
j) {
403 unsigned short p = h->
Plane();
404 unsigned short c = h->
Cell();
409 fGeo->
CellInfo(p, c, &view, xyz, dxyz);
413 zs.push_back(
fBeamBias ? xyz[2] : -xyz[2]);
415 sort(zs.begin(), zs.end());
421 unsigned int ncell = 0, ic = 0;
422 std::vector<double> zstemp;
423 for(j = 0; j < zs.size(); ++
j) {
424 if(zs[j] >= zlo && zs[j] <= zhi){
426 zstemp.push_back(zs[j]);
434 for(j = 0; j < zs.size(); ++
j) {
435 if(zs[j] >= zlo && zs[j] <= zhi){
437 zstemp.push_back(zs[j]);
445 unsigned int nhitx = 0, nhity = 0;
453 for(j = 0; j < neighbors.
NCell(); ++
j) {
456 unsigned short p = h->
Plane();
457 unsigned short c = h->
Cell();
462 fGeo->
CellInfo(p, c, &view, xyz, dxyz);
464 if(xyz[2] >= zlo && xyz[2] <= zhi) {
466 arms.
SetHit(ic++, xyz[2], xyz[0], dxyz[2]/
sqrt(12.), view);
471 if(xyz[2] > maxZ) maxZ =
fBeamBias ? xyz[2] : -xyz[2];
472 if(xyz[2] < minZ) minZ =
fBeamBias ? xyz[2] : -xyz[2];
473 if(xyz[0] > maxX) maxX = xyz[0];
474 if(xyz[0] < minX) minX = xyz[0];
477 arms.
SetHit(ic++, xyz[2], xyz[1], dxyz[2]/
sqrt(12.), view);
479 if(xyz[2] > maxZ) maxZ =
fBeamBias ? xyz[2] : -xyz[2];
480 if(xyz[2] < minZ) minZ =
fBeamBias ? xyz[2] : -xyz[2];
481 if(xyz[1] > maxY) maxY = xyz[1];
482 if(xyz[1] < minY) minY = xyz[1];
491 if(nhitx == 0 || nhity == 0)
continue;
496 this->
FindSeed(minX, maxX, minY, maxY, minZ, maxZ, *hrx, *hry, arms);
523 for(j = 0; j < arms.
fN; ++
j) {
530 for(
unsigned int a = 0;
a < arms.
fM; ++
a) {
548 for(j = 0; j < arms.
fdXds.size(); ++
j) {
559 std::vector<double> xmc;
560 std::vector<double> ymc;
561 std::vector<double> zmc;
564 for(j = 0; j < xmc.size(); ++
j) {
565 double dx = arms.
fX0 - xmc[
j];
566 double dy = arms.
fY0 - ymc[
j];
567 double dz = arms.
fZ0 - zmc[
j];
571 if(
fabs(dx) > 4*4 ||
fabs(dy) > 4*4 ||
fabs(dz) > 4*6) {
572 std::cout <<
"ElasticArmsHS: Blown fit [" 575 << evt.
id().
event() <<
"] dx,dy,dz=(" 589 for(i = 0; i < arms.
fN; ++
i) {
590 for(j = 0; j < arms.
fM; ++
j) {
620 evt.
put(std::move(vtx));
621 evt.
put(std::move(prg));
622 evt.
put(std::move(vAssns));
623 evt.
put(std::move(pAssns));
631 std::vector<int> hit_numNeighbors;
634 double maxGap = 60.0;
636 int iPlane, fPlane, iCell, fCell;
637 double goodCh, totCh;
647 for(
unsigned int i = 0;
i < c.
size();
i++){
648 hit_numNeighbors.push_back(0);
652 for(
unsigned int i = 0;
i < c.
size();
i++){
653 double minDist = 9999.0;
655 if(hit_numNeighbors[
i] > 0)
continue;
656 for(
unsigned int j = 0;
j < c.
size();
j++){
658 if(c[
i]->
View() != c[
j]->View())
continue;
659 double xyz1[3], xyz2[3];
670 if(minCell == -1)
continue;
674 if(c[
i]->Plane() < c[minCell]->Plane()){
675 iPlane = c[
i]->Plane();
676 fPlane = c[minCell]->Plane();
679 iPlane = c[minCell]->Plane();
680 fPlane = c[
i]->Plane();
682 if(c[
i]->Cell() < c[minCell]->Cell()) {
683 iCell = c[
i]->Cell();
684 fCell = c[minCell]->Cell();
687 iCell = c[minCell]->Cell();
688 fCell = c[
i]->Cell();
694 for(
int c = iCell; c <= fCell; c++){
695 for(
int p = iPlane;
p <= fPlane;
p+=2){
697 if(!(badc->
IsBad(
p,c))) ++goodCh;
700 if((minDist*goodCh/totCh) < maxGap){
701 hit_numNeighbors[
i]++;
702 hit_numNeighbors[minCell]++;
707 for(
unsigned int i = 0;
i < c.
size();
i++){
708 if(hit_numNeighbors[
i] > 0){
A 3D position and time representing an interaction vertex.
SubRunNumber_t subRun() const
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
void MCVertex(art::Event &evt, std::vector< double > &mcx, std::vector< double > &mcy, std::vector< double > &mcz)
void AddDirection(double theta, double phi)
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
const simb::MCNeutrino & GetNeutrino() const
void GetCenter(double *xyz, double localz=0.0) const
TNtuple * fSumNt
Summary ntuple.
double fGridSearchColinear
Colinearity cut.
std::map< std::string, double > xmax
fvar< T > fabs(const fvar< T > &x)
void SetAnnealMaxItr(unsigned int i)
double fMinimizeT1
Final temperature for annealing.
double fGridSearchT
Temperature to use for grid search.
double fMinimizeLambda
Noise penalty during minimization.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
unsigned short Plane() const
void SetStandardDirections()
std::vector< HoughPeak > fPeak
List of peaks found in Hough space.
void SetLambda(double lam)
const CellGeo * Cell(int icell) const
double fY0
Vertex y location (cm)
Vertical planes which measure X.
double fZTruncFracLo
z hit to base the window on (fraction)
double fVtxBoxBuffer
Vertex must be this close to hits [cm].
A collection of associated CellHits.
double fGridSearchLambda
Noise penalty for grid search.
double fAnnealFrac
Fractional decrease in temperature.
const PlaneGeo * Plane(unsigned int i) const
double fZ0
Vertex z location (cm)
DEFINE_ART_MODULE(TestTMapFile)
double fZTruncDz2
How far down stream to set window (cm)
void AddVtxPoints(const ElasticArms &arms, const std::vector< double > &mx, const std::vector< double > &bx, const std::vector< double > &my, const std::vector< double > &by, const std::vector< double > &f)
unsigned int fMinHit
Slices must have at least this many hits.
std::string fHoughResultLabel
Module label to output HoughResults.
Horizontal planes which measure Y.
Elastic Arms vertex finding algorithm.
void CellInfo(unsigned int ip, unsigned int ic, View_t *view=0, double *pos=0, double *dpos=0) const
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
void AddHoughIntersections(const rb::HoughResult &hrx, const rb::HoughResult &hry, unsigned int nmx, unsigned int nmh, bool flipped=false)
unsigned int fM
Number of arms.
int fMakeHitNt
Make debugging hit-level ntuple.
ProductID put(std::unique_ptr< PROD > &&product)
const art::ProductToken< std::vector< rb::Cluster > > fSliceToken
unsigned short Cell() const
std::vector< double > fXorY
Transverse hit positions (cm)
void SetHit(unsigned int i, double z, double xory, double sigma, int view)
std::vector< double > fdZds
Track dz/ds.
void SlopeIcept(unsigned int i, double *m, double *b) const
Slope and intercepts of Hough lines.
double fHoughPeakAsymCut
Which x/y hough results to pair?
void push_back(Ptr< U > const &p)
void FindSeed(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, const rb::HoughResult &hrx, const rb::HoughResult &hry, ElasticArms &arms)
unsigned int fMaxHoughResults
Only use the top hough results.
double fMinimizeT0
Initial temperature for annealing.
unsigned int fNhoughMatch
How many lines to check in the other view.
void GetVertex(double &x, double &y, double &z) const
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
double fLambdaV
Distance scale vertex to first hit.
double DetHalfHeight() const
std::vector< double > fGridSearchFz
Fractional locations of z vtx seeds.
unsigned int fN
Data to fit.
double fZTruncFracHi
z hit to base the window on (fraction)
Vertex location in position and time.
Perform a "2 point" Hough transform on a collection of hits.
unsigned int fGridSearchNdir
Number of minimum bias directions to use.
unsigned int fMinHitX
Miniumm hits in x view / slice.
double FindBestVtx(ElasticArms &arms)
void SetAnnealFrac(double f)
std::vector< double > fZ
Z locations of hits (cm)
unsigned int NYCell() const
Number of cells in the y-view.
TH1F * fVtxDz
Distribution of z(fit)-z(mc)
std::string fMCLabel
Module label for MC.
EventNumber_t event() const
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
double Vx(const int i=0) const
A rawdata::RawDigit with channel information decoded.
T * make(ARGS...args) const
double fX0
Model parameters.
A Cluster with defined start position and direction.
double DetHalfWidth() const
void produce(art::Event &e)
Data resulting from a Hough transform on the cell hit positions.
std::vector< double > fdXds
Track dx/ds.
matrix fVia
Strength of association hit i to track a.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
double pythag(double x, double y)
2D Euclidean distance
unsigned int NXCell() const
Number of cells in the x-view.
bool fObeyPreselection
Check rb::IsFiltered?
void reconfigure(const fhicl::ParameterSet &p)
TH1F * fVtxDy
Distribution of y(fit)-y(mc)
ElasticArmsHS(fhicl::ParameterSet const &p)
double fZTruncDz1
How far up stream to set window (cm)
art::PtrVector< rb::CellHit > Scrub(art::PtrVector< rb::CellHit > c)
std::vector< int > fView
Which view is the hit in?
TH1F * fVtxDx
Distribution of x(fit)-x(mc)
bool IsNoise() const
Is the noise flag set?
unsigned int fMinHitY
Minimum hit in y view / slice.
int fMakeSummaryNt
Make a summary ntuple entry for each event.
TNtuple * fHitNt
Debugging hit-level ntuple.
bool getByToken(ProductToken< PROD > const &token, Handle< PROD > &result) const
std::vector< double > fdYds
Track dy/ds.
Summary from a Hough transform applied to a group of cell hits.
Event generator information.
bool IsBad(int plane, int cell)
double fHoughPeakThr
Threshold to accept a peak as good.
ProductToken< T > consumes(InputTag const &)
void SetVertex(double x, double y, double z)
Encapsulate the geometry of one entire detector (near, far, ndos)
unsigned int fAnnealMaxItr
Maximum number of annealing steps.
matrix fMia
Distance^2 hit i to track a (sigma^2)
int fCompareToMC
Should we make a comparison to truth?