22 #include "DAQChannelMap/DAQChannelMap.h" 171 produces< std::vector<novaddt::TriggerDecision>>();
172 produces< art::Assns<novaddt::TriggerDecision, novaddt::HitList> >();
184 <<
event.id().event()
187 std::unique_ptr<std::vector<novaddt::TriggerDecision>> trigger_decisions(
new std::vector<novaddt::TriggerDecision>);
199 assert(find_tracks.isValid());
202 for(
size_t i_slice = 0; i_slice < slices->size(); ++i_slice){
206 std::cout<<
"\tslice[" << i_slice <<
"]: " << hit_list.size() <<
" hits" <<
std::endl;
208 for(
size_t i_hit = 0; i_hit < hit_list.size(); ++i_hit){
213 <<
"]: TDC: " << hit.
TDC().
val 214 <<
", ADC: " << hit.
ADC().
val 229 for(
unsigned int j = 0;
j < hit_list.size(); ++
j){
232 xz_hits.push_back(hit);
234 yz_hits.push_back(hit);
237 TVector3 slice_start(0,0,0);
238 TVector3 slice_end(0,0,0);
262 std::vector< art::Ptr<novaddt::Track3D> > tracks = find_tracks.at(i_slice);
264 if (!tracks.size() ){
273 assert(fohl.size() == tracks.size());
275 double longest_length = -9;
276 unsigned int i_longest = 0;
277 bool track_found =
false;
279 for(
size_t i_track = 0; i_track < tracks.size(); ++i_track){
285 double this_length =
std::abs(length.Mag());
288 <<
"]\t view: " << track->
View()
289 <<
", hits: " << this_hit_list->size()
290 <<
", X: " << track->
Start().X() <<
" - " << track->
End().X()
291 <<
", Y: " << track->
Start().Y() <<
" - " << track->
End().Y()
292 <<
", Z: " << track->
Start().Z() <<
" - " << track->
End().Z()
293 <<
", length: " << this_length
312 if (!track->
Is3D())
continue;
315 if (this_length > longest_length){
316 longest_length = this_length;
332 <<
"], hits: " << hits_on_track->size()
333 <<
", x: " << track.
Start().X() <<
" - " << track.
End().X()
334 <<
", y: " << track.
Start().Y() <<
" - " << track.
End().Y()
335 <<
", z: " << track.
Start().Z() <<
" - " << track.
End().Z()
340 unsigned int x_hits = 0;
341 unsigned int y_hits = 0;
342 for(
size_t i_hit = 0; i_hit < hits_on_track->size(); ++i_hit){
403 double scaled_dZ = (dZ * 6.7) / 4.;
406 double CosBeam = ( scaled_dZ/
std::sqrt(dX*dX+dY*dY+scaled_dZ*scaled_dZ) );
422 TVector3 track_3d = TVector3();
423 track_3d.SetXYZ(dX,dY,scaled_dZ);
424 double dY_unit = track_3d.Unit().Y();
425 double cosmic_pid = ((minCellsToEdge/100.)*(minCellsToEdge/100.)) +
429 <<
", from nCells: " << minCellsToEdge
430 <<
", cos(beam): " << CosBeam
431 <<
", dY unit: " << dY_unit
472 double angle_var = (CosBeam*CosBeam) - (dY_unit*dY_unit);
488 uint64_t min_tdc = hit_list.front().TDC().val;
489 uint64_t max_tdc = hit_list.back().TDC().val;
490 for(
size_t i_hit = 0; i_hit < hit_list.size(); ++i_hit){
491 if (hit_list[i_hit].
TDC().
val < min_tdc) min_tdc = hit_list[i_hit].
TDC().
val;
492 if (hit_list[i_hit].
TDC().
val > max_tdc) max_tdc = hit_list[i_hit].
TDC().
val;
505 art::ProductID td_id = this->getProductID<std::vector<novaddt::TriggerDecision> >();
509 assn->addSingle(td_ptr, slice_ptr);
512 << trigger_decisions->back().start()
513 <<
", duration: " << trigger_decisions->back().duration()
519 bool goodTrigger = (trigger_decisions->size() > 0);
520 if (
_verbose)
std::cout <<
"=== end of novaddt::NuMuTrigger filter. Trigger decision: " << goodTrigger
521 <<
" from " << trigger_decisions->size()
522 <<
" passes (associations: " << assn->size()
525 event.put(std::move(trigger_decisions));
526 event.put(std::move(assn));
544 if (xz_hits.size() > 0){
545 xz_z_min = xz_hits[0].Plane().val;
546 xz_z_max = xz_hits[0].Plane().val;
547 xz_x_min = xz_hits[0].Cell().val;
548 xz_x_max = xz_hits[0].Cell().val;
550 for (
auto const&
hit : xz_hits){
551 if (
hit.Plane().val < xz_z_min) xz_z_min =
hit.Plane().val;
552 if (
hit.Plane().val > xz_z_max) xz_z_max =
hit.Plane().val;
553 if (
hit.Cell().val < xz_x_min) xz_x_min =
hit.Cell().val;
554 if (
hit.Cell().val > xz_x_max) xz_x_max =
hit.Cell().val;
561 if (yz_hits.size() > 0){
562 yz_z_min = yz_hits[0].Plane().val;
563 yz_z_max = yz_hits[0].Plane().val;
564 yz_y_min = yz_hits[0].Cell().val;
565 yz_y_max = yz_hits[0].Cell().val;
567 for (
auto const&
hit : yz_hits){
568 if (
hit.Plane().val < yz_z_min) yz_z_min =
hit.Plane().val;
569 if (
hit.Plane().val > yz_z_max) yz_z_max =
hit.Plane().val;
570 if (
hit.Cell().val < yz_y_min) yz_y_min =
hit.Cell().val;
571 if (
hit.Cell().val > yz_y_max) yz_y_max =
hit.Cell().val;
574 int z_min =
std::min(xz_z_min,yz_z_min);
575 int z_max =
std::max(xz_z_max,yz_z_max);
577 start.SetXYZ(
double (xz_x_min),
580 end.SetXYZ(
double (xz_x_max),
613 TVector3 trajectory = TVector3(max_X - min_X,
616 TVector3
dir = trajectory.Unit();
618 double xlow, xhigh, ylow, yhigh, zlow, zhigh;
644 if (min_X<=xlow) min_X = xlow;
645 if (max_X>=xhigh) max_X = xhigh;
646 if (min_Y<=ylow) min_Y = ylow;
647 if (max_Y>=yhigh) max_Y = yhigh;
648 if (min_Z<=zlow) min_Z = zlow;
649 if (max_Z>=zhigh) max_Z = zhigh;
652 if (entering) zlow = -999;
659 dx =
std::min( ((xhigh - max_X)/dir.X()),
660 ((min_X - xlow) /dir.X())
662 dy =
std::min( ((yhigh - max_Y)/dir.Y()),
663 ((min_Y - ylow) /dir.Y())
665 dz =
std::min( ((zhigh - max_Z)/dir.Z()),
670 if (dx<dy && dx<dz) d =
dx;
671 else if (dy<dz && dy<dx) d =
dy;
672 else if (dz<dx && dz<dy) d =
dz;
675 TVector3
distance = TVector3(dir.X()*
d, dir.Y()*
d, dir.Z()*
d);
703 return distance.Mag();
double _trackBoxYMin
lower y track box fiducial cut
T max(const caf::Proxy< T > &a, T b)
unsigned int _minCellsPerView
minimum number of cells per view for a good track
std::string _sliceInstanceLabel
instance label making the HitList
fvar< T > fabs(const fvar< T > &x)
double _sliceBoxXMax
upper x slice box fiducial cut
NuMuTrigger(fhicl::ParameterSet const &p)
novaddt::Plane const & Plane() const
novaddt::TDC const & TDC() const
std::vector< DAQHit > HitList
double _minCellsToEdge
containment cut based on minimum number of cell projected to the edge of the detector ...
double _angularCut
cosmic rejection cut on angle
double n3DCellsToEdge(novaddt::Track3D &track, bool entering)
std::string _sliceModuleLabel
label of module making the HitList
double _trackBoxXMin
lower x track box fiducial cut
DEFINE_ART_MODULE(TestTMapFile)
unsigned distance(const T &t1, const T &t2)
double _trackBoxZMax
upper z track box fiducial cut
unsigned int _nPass_3DTracks
TVector3 const & End() const
unsigned int _nPass_cosmic_PID
bool filter(art::Event &e) override
bool _checkBoxContainment
bool _checkLowZContainment
void findBoundingBox(novaddt::HitList &xz_hits, novaddt::HitList &yz_hits, TVector3 &start, TVector3 &end)
bool _checkSliceContainment
unsigned int _nPass_entering
double _sliceBoxXMin
lower x slice box fiducial cut
novaddt::ADC const & ADC() const
novaddt::View const & View() const
Identifier for the X measuring view of the detector (top)
unsigned int _prescale
prescale factor (1 out of every this many passes are issued as real triggers)
TVector3 const & Start() const
unsigned int _nPass_angle
bool const & Is3D() const
std::string _trackInstanceLabel
instance label making the Tracks
unsigned int _nPass_box_containment
std::string _trackModuleLabel
label of module making the Tracks
double _trackBoxZMin
lower z track box fiducial cut
unsigned int _prescaled_trigger_counts
unsigned int _nPass_slice_containment
unsigned int _nPass_angle_var
double _trackBoxYMax
upper y track box fiducial cut
std::string _trackToSliceInstanceLabel
instance of track to slice association produced by track module
double _cosmicPIDCut
cosmic pid (MinCellsToEdge/100)^2 + cos(beam)^2 - (dY_unit*4)^2
unsigned int _nPass_projection_containment
novaddt::Cell const & Cell() const
double _enteringCut
minimum plane crossed to be defined as entering
assert(nhit_max >=nhit_nbins)
double _sliceBoxZMin
lower z slice box fiducial cut
bool _checkProjectionContainment
double _sliceBoxYMax
upper y slice box fiducial cut
T min(const caf::Proxy< T > &a, T b)
double _angleVarCut
cosmic rejection cut on angle: cos(beam)^2 - (dY_unit)^2
unsigned int _minPlanesCrossed
minimum planes crossed for a track to be used
double _sliceBoxYMin
lower y slice box fiducial cut
unsigned int _trigger_counts
double _trackBoxXMax
upper x track box fiducial cut
double _sliceBoxZMax
upper z slice box fiducial cut