Functions | Variables
hits.cxx File Reference
#include <gtk/gtk.h>
#include <vector>
#include <algorithm>
#include <stdint.h>
#include "event.h"
#include "drawing.h"
#include "geo.h"
#include "status.h"

Go to the source code of this file.

Functions

static bool by_charge (const hit &a, const hit &b)
 
 __attribute__ ((unused)) static bool by_time(const hit &a
 
static void colorhit (const int32_t adc, float &red, float &green, float &blue, const bool active)
 
void draw_hit (cairo_t *cr, const hit &thishit, GtkWidget **edarea)
 
void draw_hits (cairo_t **cr, const DRAWPARS *const drawpars, GtkWidget **edarea)
 

Variables

std::vector< noeeventtheevents
 
int gevi
 
int pixx
 
int pixy
 
int active_plane
 
int active_cell
 
const hitb
 

Function Documentation

__attribute__ ( (unused)  ) const

Referenced by by_charge().

static bool by_charge ( const hit a,
const hit b 
)
static

Definition at line 15 of file hits.cxx.

References __attribute__(), a, hit::adc, and b.

Referenced by draw_hits().

16 {
17  return a.adc < b.adc;
18 }
int16_t adc
Definition: event.h:3
static void colorhit ( const int32_t  adc,
float &  red,
float &  green,
float &  blue,
const bool  active 
)
static

Definition at line 28 of file hits.cxx.

References rootlogon::blue, rootlogon::green, art::left(), and red().

Referenced by draw_hit().

30 {
31  // Oh so hacky!
32  const float graycut = 60;
33  const float nextcut = 120;
34  if(adc < graycut) red = green = blue = 0.2 + 0.3*adc/graycut;
35  else if(adc < nextcut)
36  blue = 0.5 + 0.5*(adc-graycut)/(nextcut-graycut),
37  red = 0.5 - 0.5*(adc-graycut)/(nextcut-graycut),
38  green = 0.5 - 0.5*(adc-graycut)/(nextcut-graycut);
39  else if(adc < 600) blue = 1, red = green = 0;
40  else if(adc < 800) blue = 1-(adc-600)/200.0,
41  green = (adc-600)/200.0,
42  red = 0;
43  else if(adc < 1200) green = 1, red = blue = 0;
44  else if(adc < 1400) green = 1-(adc-1200)/200.0,
45  red = (adc-1200)/200.0,
46  blue = 0;
47  else red = 1, green = blue = 0;
48 
49  // Brighten this hit while trying to retain some of its original color, but
50  // just make it white if that is what it takes to make a difference.
51  if(active){
52  const float goal = 1.3;
53  const float left = 3 - red - blue - green;
54  if(left < goal){
55  red = blue = green = 1;
56  }
57  else{
58  red += goal*(1 - red)/left;
59  blue += goal*(1 - blue)/left;
60  green += goal*(1 - green)/left;
61  }
62  }
63 }
void red()
Definition: red.C:20
tuple blue
Definition: rootlogon.py:65
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
void draw_hit ( cairo_t *  cr,
const hit thishit,
GtkWidget **  edarea 
)

Definition at line 67 of file hits.cxx.

References active_cell, active_plane, hit::adc, rootlogon::blue, hit::cell, colorhit(), det_to_screen_x(), det_to_screen_y(), rootlogon::green, kX, kY, pixx, pixy, hit::plane, red(), and scintpix_from_pixx().

Referenced by change_highlighted_cell(), and draw_hits().

68 {
69  const noe_view_t V = thishit.plane%2 == 1?kX:kY;
70 
71  // Get position of upper left corner. If the zoom carries this hit entirely
72  // out of the view in screen y, don't waste cycles displaying it.
73  const int screenx = det_to_screen_x(thishit.plane);
74  if(screenx+pixx < 0) return;
75  if(screenx > edarea[V]->allocation.width) return;
76 
77  const int screeny = det_to_screen_y(thishit.plane, thishit.cell);
78  if(screeny+pixy < 0) return;
79  if(screeny > edarea[V]->allocation.height) return;
80 
81  float red, green, blue;
82 
83  colorhit(thishit.adc, red, green, blue,
84  thishit.plane == active_plane && thishit.cell == active_cell);
85 
86  cairo_set_source_rgb(cr, red, green, blue);
87 
88  // If we're representing cells with a very small number of pixels,
89  // draw all the way across to the next plane in the view to be easier
90  // to look at. If cells are visually large, make them closer to the
91  // actual size of the scintillator.
92  // XXX how about a yexpand to show the scintillator size in y?
93  // XXX are tracks correctly aligned with hits in both expanded and unexpanded
94  // styles? (Probably not!)
95  const bool xexpand = pixx <= 3;
96  const int epixx = xexpand?pixx:scintpix_from_pixx(pixx);
97 
98  // This is the only part of drawing an event that takes any time
99  // I have measured drawing a line to be twice as fast as drawing a
100  // rectangle of width 1, so it is totally worth it to have a special
101  // case. This really helps with drawing big events.
102  if(pixy == 1){
103  cairo_move_to(cr, screenx, screeny+0.5);
104  cairo_line_to(cr, screenx+epixx, screeny+0.5);
105  cairo_stroke(cr);
106  }
107  // This is a smaller gain, but it is definitely faster by about 10%.
108  else if(pixy == 2){
109  cairo_move_to(cr, screenx, screeny+0.5);
110  cairo_line_to(cr, screenx+epixx, screeny+0.5);
111  cairo_move_to(cr, screenx, screeny+1.5);
112  cairo_line_to(cr, screenx+epixx, screeny+1.5);
113  cairo_stroke(cr);
114  }
115  else{
116  cairo_rectangle(cr, screenx+0.5, screeny+0.5,
117  epixx-1, pixy-1);
118  cairo_fill(cr);
119  }
120 }
GtkWidget * edarea[kXorY]
Definition: drawing.cxx:20
int pixy
Definition: geo.cxx:24
int pixx
Definition: geo.cxx:24
uint16_t plane
Definition: event.h:2
void red()
Definition: red.C:20
int active_plane
Definition: main.cxx:78
uint16_t cell
Definition: event.h:2
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
tuple blue
Definition: rootlogon.py:65
int16_t adc
Definition: event.h:3
int active_cell
Definition: main.cxx:78
int det_to_screen_y(const int plane, const int cell)
Definition: geo.cxx:119
static void colorhit(const int32_t adc, float &red, float &green, float &blue, const bool active)
Definition: hits.cxx:28
Definition: geo.h:1
int scintpix_from_pixx(const int x)
Definition: geo.cxx:61
int det_to_screen_x(const int plane)
Definition: geo.cxx:100
noe_view_t
Definition: geo.h:1
void draw_hits ( cairo_t **  cr,
const DRAWPARS *const  drawpars,
GtkWidget **  edarea 
)

Definition at line 125 of file hits.cxx.

References by_charge(), draw_hit(), DRAWPARS::firsttick, gevi, hits(), MECModelEnuComparisons::i, kX, kXorY, kY, DRAWPARS::lasttick, hit::plane, set_eventn_status_progress(), hit::tdc, and theevents.

Referenced by draw_event().

126 {
127  if(theevents[gevi].hits.empty()) return;
128 
129  for(int i = 0; i < kXorY; i++) cairo_set_line_width(cr[i], 1.0);
130 
131  std::vector<hit> & THEhits = theevents[gevi].hits;
132 
133  std::sort(THEhits.begin(), THEhits.end(), by_charge);
134 
135  const int big = 100000;
136  const bool bigevent = THEhits.size() > big;
137 
138  int ndrawn = 0;
139  for(unsigned int i = 0; i < THEhits.size(); i++){
140  const hit & thishit = THEhits[i];
141 
142  if(thishit.tdc < drawpars->firsttick ||
143  thishit.tdc > drawpars->lasttick) continue;
144 
145  if(bigevent && (++ndrawn)%big == 0)
146  set_eventn_status_progress(ndrawn, THEhits.size());
147 
148  draw_hit(cr[thishit.plane%2 == 1?kX:kY], thishit, edarea);
149  }
150 }
GtkWidget * edarea[kXorY]
Definition: drawing.cxx:20
static bool by_charge(const hit &a, const hit &b)
Definition: hits.cxx:15
void set_eventn_status_progress(const int nhit, const int tothits)
Definition: status.cxx:182
Definition: geo.h:1
uint16_t plane
Definition: event.h:2
int32_t tdc
Definition: event.h:5
int gevi
Definition: main.cxx:76
const Var kY([](const caf::SRProxy *sr){float tmp=0.f;if(sr->mc.nu.empty()) return tmp;tmp=sr->mc.nu[0].y;return tmp;})
void hits()
Definition: readHits.C:15
std::vector< noeevent > theevents
Definition: noe_module.cc:28
void draw_hit(cairo_t *cr, const hit &thishit, GtkWidget **edarea)
Definition: hits.cxx:67
Definition: event.h:1
Definition: geo.h:1
int32_t firsttick
Definition: drawing.h:4
int32_t lasttick
Definition: drawing.h:4

Variable Documentation

int active_cell

Definition at line 78 of file main.cxx.

Referenced by draw_hit().

int active_plane

Definition at line 78 of file main.cxx.

Referenced by draw_hit().

const hit& b
Initial value:
{
return a.tdc < b.tdc
int32_t tdc
Definition: event.h:5
const double a
const hit & b
Definition: hits.cxx:21

Definition at line 21 of file hits.cxx.

Referenced by AddBin(), evdb::View2D::AddBox(), daqdataformats::VERSION_NAMESPACE::RawDataBlock::addMicroBlock4(), ana::KrigeKernel::AddPoint(), air::AirKalmanAna::analyze(), novaddt::HotMapMaker::AppendCold(), novaddt::HotMapMaker::AppendHot(), novaddt::HotMapMaker::AppendRate(), genie::KNOHadronization::AverageChMult(), art::RangeSet::back(), fnex::CovarianceMatrixMaker::beginJob(), stan::math::beta_rng(), bin_composition_pie_chart(), genie::utils::nuclear::BindEnergy(), cmf::RandomUniverses::BinUncertainties(), by_charge(), vdt::Segment::CalcChi2Line0(), Calculate2DChi2(), genie::COHKinematicsGenerator::CalculateKin_BergerSehgal(), genie::COHKinematicsGenerator::CalculateKin_ReinSehgal(), stan::math::categorical_logit_rng(), stan::math::categorical_rng(), earms::GridSearch::ChooseBestProngDir(), geo::ClosestApproach(), genie::utils::kinematics::CohQ2Lim(), ana::CombineExposures(), boost::python::map_indexing_suite< Container, NoProxy, final_map_derived_policies< Container, NoProxy > >::compare_index(), boost::python::vector_indexing_suite< Container, NoProxy, final_vector_derived_policies< Container, NoProxy > >::compare_index(), compareEvents(), genie::RSHelicityAmplModelCC::Compute(), genie::RSHelicityAmplModelNCn::Compute(), genie::RSHelicityAmplModelNCp::Compute(), stan::math::LDLT_factor< var, R, C >::compute(), genie::alvarezruso::AREikonalSolution::Con(), CLHEP::MixMaxRng::convert1double(), genie::geometry::PlaneParam::ConvertMaster2Top(), ana::CountingExperimentPValue(), ana::CountingExperimentPValueByLL(), fnex::CovarianceBinUtility::CovarianceBinUtility(), cmf::CovarianceBinUtility::CovarianceBinUtility(), genie::utils::nuclear::DensityGaus(), genie::mueloss::gsl::PetrukhinShestakovIntegrand::DoEval(), genie::mueloss::gsl::KokoulinPetrukhinIntegrand::DoEval(), genie::utils::gsl::dXSec_Log_Wrapper::DoEval(), evd::TQPad::Draw(), draw_event(), evd::GeometryDrawer::DrawCells2D(), evd::GeometryDrawer::DrawDCMBoxes(), evd::GeometryDrawer::DrawHighlightCell(), evd::RecoBaseDrawer::DrawHoughResults2D(), fnex::MultiExperiment::DrawParallelPlots(), fnex::CorrectedSpectrum::DrawStacks(), ana::CovMxSurface::DrawSurfacePoint(), DrawSurfacePoint(), stan::mcmc::softabs_metric< Model, BaseRNG >::dtau_dq(), calib::SystematicUncertaintyScaleAna::endJob(), dt::Cand::EstimateStraightLine(), osc::_PMNS< T >::EvalEqn11(), osc::_PMNS< T >::EvalEqn2(), fiducial_mass(), flat::FileListBranchPolicy::FileListBranchPolicy(), fnex::CovarianceFitHelper::FillCovarianceMatrix(), cmf::CovarianceFitHelper::FillCovarianceMatrix(), cmf::CovarianceFitHelper::FillDataSpectrum(), fnex::CovarianceFitHelper::FillEnergySpectra(), cmf::RandomUniverses::FillFDSpectrum(), art::RootInputTree::fillGroups(), fit_thresh_corrs(), fit_thresh_corrs_fb(), trk::WindowTrackingAlg::FitWindow(), fnex::FixedBinning::FixedBinning(), stan::math::fmax(), genie::utils::nuclear::FmI2(), stan::math::fmin(), sn::SNBackgroundRejection::FOM(), FOMCalc(), g4lbneCrossChecks(), g4minervaCrossChecks(), GammaFit(), genie::BBA03ELFormFactorsModel::Gen(), numusand::NumuSandFxs::getAveTrackdEdxLast4Cells(), numusand::NumuSandFxs::getAveTrackdEdxLast6Cells(), numusand::NumuSandFxs::getAveTrackdEdxLast8Cells(), trackinfo::TrackInfoFxs::getAveTrackdEdxLastCells(), DrawUtils::GetBestYRange(), ana::covmx::CovarianceMatrix::GetBinning(), ana::GenericHistAxis< T >::GetBins1D(), ana::covmx::CovarianceMatrix::GetFullBinning(), genie::alvarezruso::AlvarezRusoCOHPiPDXSec::GetLeptonMass(), evg::MCTruthToDk2NuHackItr::GetMCTruthPtr(), novaddt::MichelETrigger::GetSmartPrescale(), LSTME::Png3dVars::getSortedIndices(), SliceLID::Png3dVars::getSortedIndices(), fnex::CorrectedSpectrum::GetStacksCanvasCopy(), Grid(), gsDefaultInterp(), gt(), cheat::BackTracker::HitCollectionEfficiency(), stan::math::hypergeometric_log(), stan::math::hypergeometric_lpmf(), stan::math::inc_beta_dda(), stan::math::inc_beta_ddb(), genie::utils::kinematics::InelYLim_X(), genie::utils::kinematics::electromagnetic::InelYLim_X(), fnex::CovarianceFitHelper::Initialize(), cet::map_vector< Value >::insert(), rb::Track::InterpolateDir(), rb::Track::InterpolateXY(), stan::math::inv_Phi(), stan::math::LDLT_factor< T, R, C >::inverse(), util::ipow(), isCloseEnough(), genie::geometry::PlaneParam::IsValid(), hdf5::Join(), hough::IslandsTH2::LabelIslands(), art::left(), lin_solve(), novaddt::TrackFit::LinFit(), novaddt::NNFastMMTrigger::LinFit(), zcl::FmmTrackerValidation::LinFit(), novaddt::UpMuTrigger::LinFit(), zcl::FastMMStudy::LinFit(), novaddt::UpMuAna::LinFit(), upmuana::UpMuAnalysis::LinFit(), upmuana::UpMuRecoAna::LinFit(), geo::LinFit(), novaddt::UpMuTrigger::LinFitLLR(), novaddt::UpMuAna::LinFitLLR(), upmuana::LlrUpmu::LLR(), upmuana::UpMuAnalysis::LLR(), upmuana::UpMuRecoAna::LLR(), genie::NievesQELCCPXSec::LmunuAnumu(), dbutils::RunHistory::Load(), nerd::NERDEval::load_anchors(), nova::dbi::RunHistory::LoadDAQRunHistory(), g4n::LoadNeutronFates(), ana::LogLikelihood(), lsqr_fprime(), lt(), geo::ltKey(), fnex::CovarianceFitHelper::Make1DSpectra(), cmf::CovarianceFitHelper::Make1DSpectra(), make_extrap_figure(), make_pi0_xcheck(), nerd::NERDProng::MakeCluster(), MakeCovMx(), cmf::CovarianceFitHelper::MakeEnergySpectraFromBins(), evdb::ColorScale::MakeHSVScale(), novaddt::HotMapMaker::MakeMask(), evtsum::EventSummary::MakeOutput(), MakeTestStandPlots_AllRuns(), MakeTestStandPlots_NewRuns(), cmf::RandomUniverses::MakeUniverseHistograms(), stan::math::matrix_exp_2x2(), Eigen::matrix_exp_pade13(), Eigen::matrix_exp_pade3(), Eigen::matrix_exp_pade5(), Eigen::matrix_exp_pade7(), Eigen::matrix_exp_pade9(), std::max(), MAX(), stan::math::mdivide_left(), stan::math::mdivide_left_ldlt(), stan::math::mdivide_left_spd(), stan::math::mdivide_left_tri(), stan::math::mdivide_left_tri_low(), stan::math::mdivide_right(), stan::math::mdivide_right_tri_low(), nl::TimeSeriesData::MeanValue(), mec_tuning(), mec_tuning_fitter_2020(), dt::DiscreteTracker::MergeParasiteTracks(), min(), std::min(), evd::RawDrawingOptions::ModuleList(), evd::RecoDrawingOptions::ModuleList(), hough::MultiHough2P::MultiMap(), genie::geometry::PlaneParam::Normalize(), cmf::CovarianceFitHelper::NormalizeBinContents(), fnex::CovarianceFitHelper::NormalizeHistograms(), nus17_fiducial_mass(), art::operator!=(), stan::math::operator!=(), cet::operator!=(), CLHEP::operator!=(), art::operator&&(), ana::GenericCut< T >::operator&&(), ana::GenericVar< T >::operator*(), stan::math::operator*(), ana::GenericVar< T >::operator+(), stan::math::operator+(), ana::GenericVar< T >::operator-(), stan::math::var::operator->(), ana::GenericVar< T >::operator/(), art::operator<(), stan::math::operator<(), lem::LiteHit::operator<(), nova::database::Column::operator<(), nutools::dbi::Column::operator<(), nova::dbi::Column::operator<(), caf::operator<(), CLHEP::operator<(), art::operator<<(), CLHEP::operator<<(), nova::dbi::operator<<(), nova::database::operator<<(), genie::flux::operator<<(), stan::math::operator<=(), nova::database::Column::operator<=(), nutools::dbi::Column::operator<=(), nova::dbi::Column::operator<=(), CLHEP::operator<=(), art::BoolCache::operator=(), stan::math::operator==(), nova::database::Column::operator==(), CLHEP::operator==(), stan::math::operator>(), nova::database::Column::operator>(), nutools::dbi::Column::operator>(), nova::dbi::Column::operator>(), CLHEP::operator>(), stan::math::operator>=(), nova::database::Column::operator>=(), nutools::dbi::Column::operator>=(), nova::dbi::Column::operator>=(), CLHEP::operator>=(), ana::GenericCut< T >::operator||(), art::operator||(), overlayFBplots(), overlayFBplotsH(), evdb::ParamFrame::ParamFrame(), genie::geometry::PlaneParam::PlaneParam(), plot_3NDvsFD(), plot_3NDvsFD_FHC(), plot_3NDvsFD_RHC(), plot_abstree(), plot_datamc_ND_numu(), plot_datamc_ND_numu_REW(), plot_ND_numu_NOMvsREW(), plot_NDvsFD_REW(), plot_NDvsFD_weights(), plot_NDvsFD_weights_FHC(), plot_NDvsFD_weights_RHC(), plot_pi0_xcheck(), art::DataViewImpl::PMValue::PMValue(), sim::PhotonSignal::PoissonLambda(), calib::Calibrator::postBeginRun(), g4n::NeutronSubstitutionProcess::PostStepDoIt(), ana::GenericCut< caf::SRProxy >::POT(), pots(), genie::P33PaschosLalakulichPXSec::PPiStar(), ana::Kriger::Predict(), caf::SRBranchRegistry::Print(), genie::geometry::PlaneParam::Print(), PrintTableFourBins(), cvntf::CVNCosmicTFFilt::produce(), cvn::CVNCosmicMapper::produce(), fhicl::ParameterSetRegistry::put(), cet::registry_via_id< K, V >::put(), genie::SmithMonizUtils::Q2lim1_SM(), genie::SmithMonizUtils::Q2lim2_SM(), evdb::ScanFrame::RadioButton(), evdb::ParameterSetEditRow::RadioButtonClicked(), art::MixOp< PROD, OPROD >::readFromFile(), ana::RefineSeeds(), HepGeom::Reflect3D::Reflect3D(), refresh(), resolutionplotterbias(), hough::MultiHough2P::ReweightHits(), RunCalibration(), stan::model::rvalue(), BrightnessModelPlots::SchedulePlots(), evdb::ColorScale::SetBounds(), genie::utils::gsl::d5XSecAR::SetFlip(), HepGeom::Transform3D::setIdentity(), nova::dbi::RunHistory::SetIsBad(), evdb::ParameterSetEditRow::SetupCheckButton(), evdb::ParameterSetEditRow::SetupRadioButtons(), calib::DriftCache::SetUseEpochs(), calib::AbsCache::SetUseEpochs(), calib::AttenCache::SetUseEpochs(), show_potential(), slid::ShowerLID::ShowerLID(), ana::SimpleFOM(), hough::Hough2P::SmoothMap(), hough::MultiHough2P::SmoothMap(), solve(), osc::SolveCubic(), ana::MCMCSamples::SortedLLs(), evd::RawDataDrawer::StickFigure(), cet::map_vector< Value >::swap(), art::ValidHandle< T >::swap(), systematics_summary_from_pred_interp(), ana::systsQ3Q0(), TEST(), calib::ThresholdCorrMap::ThresholdCorrAt(), art::detail::throw_if_invalid(), time_wide_plot(), caf::SRBranchRegistry::ToFile(), ana::BayesianMarginal::ToHistogram(), train_dectree_caf(), lem::dec::Forest::TrainSingle(), rb::Track::Trajectory(), ncid::NCNNKeras::TransMomFraction(), earms::ElasticArms::UpdateVia(), uptime(), osc::VacuumHamiltonian(), ana::Var2D(), ana::Var3D(), genie::geometry::PlaneParam::Vd(), genie::geometry::PlaneParam::Vn(), genie::SmithMonizUtils::vQES_SM_lim(), cmf::RandomUniverses::writeResults(), genie::ReinDFRPXSec::XSec(), genie::BergerSehgalFMCOHPiPXSec2015::XSec(), genie::BergerSehgalCOHPiPXSec2015::XSec(), genie::ReinSehgalCOHPiPXSec::XSec(), zheevq3(), rb::Track::ZipWith(), and calib::ThresholdCorrMap::~ThresholdCorrMap().

int gevi

Definition at line 76 of file main.cxx.

Referenced by draw_hits().

int pixx

Definition at line 24 of file geo.cxx.

Referenced by draw_hit().

int pixy

Definition at line 24 of file geo.cxx.

Referenced by draw_hit().

std::vector<noeevent> theevents

Definition at line 28 of file noe_module.cc.

Referenced by draw_hits().