Classes | Functions
photrans Namespace Reference

This slightly less simple photon transport uses a template for photon collection in time and in distance along the fiber. More...

Classes

class  BrightnessLevel
 
class  FiberBrightness
 
class  ImprovedTransport
 a class for transporting photons in a roughly realistic way More...
 
class  PhotonSystRewriter
 
class  PhotonTransport
 a class for transporting photons in a roughly realistic way More...
 
struct  RateInfo
 a struct to hold collection rate info More...
 

Functions

static double line_efficiency (TH2D *themap, const double Xa, const double Ya, const double Xb, const double Yb)
 
void load_hset (TFile *f, const char *name, const char *humanname, std::vector< TH2D * > &hold, const bool verbose)
 

Detailed Description

This slightly less simple photon transport uses a template for photon collection in time and in distance along the fiber.

This slightly less simple photon transport doesn't propagate individual photons (thus "simple"), but the model is gaining some realism.

Author
auris.nosp@m.ano@.nosp@m.fnal..nosp@m.gov transport simulation
rbpat.nosp@m.ter@.nosp@m.calte.nosp@m.ch.e.nosp@m.du

Function Documentation

static double photrans::line_efficiency ( TH2D *  themap,
const double  Xa,
const double  Ya,
const double  Xb,
const double  Yb 
)
static

Definition at line 429 of file ImprovedTransport_module.cc.

References om::cerr, dx, dy, nd_projection_maker::eff, cet::hypot(), cet::sqlite::max(), fillBadChanDBTables::step, sum, submit_syst::x, and submit_syst::y.

Referenced by photrans::ImprovedTransport::GetPosCorr().

432  {
433  double sum = 0, dem = 0;
434 
435  // This is a dumb method which just takes little steps across and finds
436  // the average, but the performance is fine, so we'll go with it.
437  const double stepsize = 0.01; // cm
438 
439  const double dy = Yb - Ya;
440  const double dx = Xb - Xa;
441  const double seglen = hypot(dx, dy);
442  const int nstep = std::max(1, int(seglen/stepsize));
443  const double thisstepsize = seglen/nstep;
444  const double thisstepstart = thisstepsize/2;
445 
446  for(int step = 0; step < nstep; step++){
447  const double s = thisstepstart + step*thisstepsize;
448  const double sfrac = seglen == 0? 0: s/seglen;
449 
450  // Flip the x coordinate here because of an artifact in how I generated
451  // the efficiency maps. It only matters for horizontals where we want
452  // the fibers to be at the bottom (and air to be at the top). Local +x
453  // is global -y, where fibers should fall, but I generated the maps the
454  // other way around.
455  const double x = -(Xa + sfrac*dx);
456 
457  const double y = Ya + sfrac*dy;
458 
459  double eff = themap->GetBinContent(themap->FindBin(x, y));
460 
461  // There are some zero bins in the corners since the bins are square and
462  // were evaluated at the bin centers. Use any non-zero adjacent bin in
463  // this case.
464  int binx = 0, biny = 0;
465  if(eff <= 0){
466  int binz = 0;
467  themap->GetBinXYZ(themap->FindBin(x, y), binx, biny, binz);
468  eff = themap->GetBinContent(binx+1, biny);
469  }
470  if(eff <= 0) eff = themap->GetBinContent(binx-1, biny);
471  if(eff <= 0) eff = themap->GetBinContent(binx, biny+1);
472  if(eff <= 0) eff = themap->GetBinContent(binx, biny-1);
473 
474  if(eff <= 0) std::cerr << "GetPosCorr should not happen: " << eff
475  << " efficiency with " << themap->GetName()
476  << " point " << -x << " " << y
477  << " from path " << Xa << " " << Ya << " " << Xb << " " << Yb
478  << " length " << seglen << "\n";
479 
480  // Handle the case of zero step size, even though in all cases I've seen,
481  // these particles also have zero energy, so it doesn't matter.
482  sum += thisstepsize == 0? eff: thisstepsize*eff;
483  dem += thisstepsize;
484  }
485 
486  // If the length is zero, return the single efficiency stored in "sum". If
487  // somehow denominator is zero, prevent a NaN, but that shouldn't happen.
488  return seglen == 0? sum: dem == 0? 0: sum/dem;
489  }
std::enable_if_t< std::is_arithmetic< T >::value, T > hypot(T x, T y)
Definition: hypot.h:60
OStream cerr
Definition: OStream.cxx:7
const XML_Char * s
Definition: expat.h:262
double dy[NP][NC]
double dx[NP][NC]
Double_t sum
Definition: plot.C:31
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
void photrans::load_hset ( TFile *  f,
const char *  name,
const char *  humanname,
std::vector< TH2D * > &  hold,
const bool  verbose 
)

Definition at line 491 of file ImprovedTransport_module.cc.

References om::cout, make_syst_table_plots::h, and getGoodRuns4SAM::n.

Referenced by photrans::ImprovedTransport::LoadPosCorrHists().

493  {
494  for(int n = 1; ; n++){
495  TH2D * h = dynamic_cast<TH2D *>(f->Get(Form("%s_%d", name, n)));
496  if(h == NULL) break;
497  h->SetDirectory(NULL);
498  hold.push_back(h);
499  }
500 
501  if(verbose) std::cout << "ImprovedTransport: using "
502  << hold.size() << " " << humanname << "\n";
503 
504  if(hold.empty())
505  throw cet::exception("NoPosCorrHists")
506  << "ImprovedTransport: No " << humanname << "\n";
507  }
const XML_Char * name
Definition: expat.h:151
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
OStream cout
Definition: OStream.cxx:6