Functions
SpaceChargeProtoDUNEdp.cxx File Reference
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "math.h"
#include "stdio.h"
#include "dunesim/SpaceCharge/SpaceChargeProtoDUNEdp.h"
#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
#include "larcore/CoreUtils/ServiceUtil.h"
#include "larcore/Geometry/Geometry.h"
#include "cetlib_except/exception.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "TFile.h"
#include "TH3.h"
#include "TTree.h"
#include "TLeaf.h"

Go to the source code of this file.

Functions

bool isWithinHist (geo::Point_t const &point, TH3F *hist)
 
bool isWithinHistOuter (geo::Point_t const &point, TH3F *hist)
 
double ExtrapolateAtEdge (TH3F *hist, double x, double y, double z)
 
bool IsBorder (TAxis *ax, double v)
 
double GetSymmetric (double x, double xc)
 

Function Documentation

double ExtrapolateAtEdge ( TH3F *  hist,
double  x,
double  y,
double  z 
)

Definition at line 318 of file SpaceChargeProtoDUNEdp.cxx.

318  {
319  /*
320  Want to get the value at x, close to the wall
321  |----+----+--+--+---->
322  x c a b
323  c is the center of the voxel (interpolation limit)
324  b is the symetric of x wrt to c
325  a is between c and b
326  ->make linear interpolation from B, A to X
327 
328  */
329 
330  int binx = hist->GetXaxis()->FindBin(x);
331  int biny = hist->GetYaxis()->FindBin(y);
332  int binz = hist->GetZaxis()->FindBin(z);
333 
334 
335  //get coordinate of the center of the voxel
336  double xcenter = IsBorder(hist->GetXaxis(),x) ? hist->GetXaxis()->GetBinCenter(binx) : x;
337  double ycenter = IsBorder(hist->GetYaxis(),y) ? hist->GetYaxis()->GetBinCenter(biny) : y;
338  double zcenter = IsBorder(hist->GetZaxis(),z) ? hist->GetZaxis()->GetBinCenter(binz) : z;
339 
340  int Nx = hist->GetXaxis()->GetNbins();
341  int Ny = hist->GetYaxis()->GetNbins();
342  int Nz = hist->GetZaxis()->GetNbins();
343 
344  /* if (Nz==1){ // when the GAr map is used (only one Z bin at the moment)
345  return InterpolateAtEdge(x,y,z);// LZ
346  }*/
347 
348  //special case when the starting point is at the center of the voxel
349  if(x==xcenter && IsBorder(hist->GetXaxis(),x)){
350  int binx2 = (binx==Nx) ? binx-1 : 2;
351  xcenter = 0.5*(hist->GetXaxis()->GetBinCenter(binx2)+x);
352  }
353  if(y==ycenter&& IsBorder(hist->GetYaxis(),y)){
354  int biny2 = (biny==Ny) ? biny-1 : 2;
355  ycenter = 0.5*(hist->GetYaxis()->GetBinCenter(biny2)+y);
356  }
357  if(z==zcenter&& IsBorder(hist->GetZaxis(), z)){
358  int binz2 = (binz==Nz) ? binz-1 : 2;
359  zcenter = 0.5*(hist->GetZaxis()->GetBinCenter(binz2)+z);
360  }
361 
362 
363  //Get the symmetric of edgy point wrt to center
364  double xb = IsBorder(hist->GetXaxis(),x) ? GetSymmetric(x,xcenter) : x;
365  double yb = IsBorder(hist->GetYaxis(),y) ? GetSymmetric(y,ycenter) : y;
366  double zb = IsBorder(hist->GetZaxis(),z) ? GetSymmetric(z,zcenter) : z;
367 
368  //Get middle point of [symmetric, center]
369  double xa = IsBorder(hist->GetXaxis(),x) ? 0.5*(xcenter+xb) : x;
370  double ya = IsBorder(hist->GetYaxis(),y) ? 0.5*(ycenter+yb) : y;
371  double za = IsBorder(hist->GetZaxis(),z) ? 0.5*(zcenter+zb) : z;
372 
373  double valb = hist->Interpolate(xb, yb, zb); //symmetric point value
374  double vala = hist->Interpolate(xa, ya, za);
375  double val = 0.;
376 
377  double Nedges = 0.;
378  if(IsBorder(hist->GetXaxis(),x)) Nedges = Nedges+1.;
379  if(IsBorder(hist->GetYaxis(),y)) Nedges = Nedges+1.;
380  if(IsBorder(hist->GetZaxis(),z)) Nedges = Nedges+1.;
381 
382 
383 
384  double delta = vala - valb;//
385 
386  double dx = IsBorder(hist->GetXaxis(),x) ? xa-xb : 1;
387  double dy = IsBorder(hist->GetYaxis(),y) ? ya-yb : 1;
388  double dz = IsBorder(hist->GetZaxis(),z) ? za-zb : 1;
389 
390  val = x*delta/dx + (xa*valb - xb*vala)/dx
391  + y*delta/dy + (ya*valb - yb*vala)/dy
392  + z*delta/dz + (za*valb - zb*vala)/dz;
393 
394 
395  val = val/Nedges;
396  return val;
397 
398  }
double GetSymmetric(double x, double xc)
list x
Definition: train.py:276
bool IsBorder(TAxis *ax, double v)
double GetSymmetric ( double  x,
double  xc 
)

Definition at line 314 of file SpaceChargeProtoDUNEdp.cxx.

314  {
315  return xc + (xc-x);
316  }
list x
Definition: train.py:276
bool IsBorder ( TAxis *  ax,
double  v 
)

Definition at line 302 of file SpaceChargeProtoDUNEdp.cxx.

302  {
303 
304  /*
305  In the external half of the first/last bin or outside the range
306  */
307  if( ax->GetNbins()==1) return true;
308  if( v<= ax->GetBinCenter(1) ) return true;
309  //a->GetNbins() or GetNbins()-1..?
310  if( v>= ax->GetBinCenter(ax->GetNbins()) ) return true;
311 
312  return false;
313  }
bool isWithinHist ( geo::Point_t const &  point,
TH3F *  hist 
)

Definition at line 414 of file SpaceChargeProtoDUNEdp.cxx.

415 {
416  if(point.X()> hist->GetXaxis()->GetBinCenter(1) &&
417  point.X()< hist->GetXaxis()->GetBinCenter(hist->GetXaxis()->GetNbins()) &&
418  point.Y()> hist->GetYaxis()->GetBinCenter(1) &&
419  point.Y()< hist->GetYaxis()->GetBinCenter(hist->GetYaxis()->GetNbins()) &&
420  point.Z()> hist->GetZaxis()->GetBinCenter(1) &&
421  point.Z()< hist->GetZaxis()->GetBinCenter(hist->GetZaxis()->GetNbins()) ){
422 
423  return true;}
424  return false;
425 
426 }
bool isWithinHistOuter ( geo::Point_t const &  point,
TH3F *  hist 
)

Definition at line 400 of file SpaceChargeProtoDUNEdp.cxx.

401 {
402  if(point.X()> hist->GetXaxis()->GetBinLowEdge(0) &&
403  point.X()< hist->GetXaxis()->GetBinLowEdge(hist->GetXaxis()->GetNbins()+1) &&
404  point.Y()> hist->GetYaxis()->GetBinLowEdge(0) &&
405  point.Y()< hist->GetYaxis()->GetBinLowEdge(hist->GetYaxis()->GetNbins()+1) &&
406  point.Z()> hist->GetZaxis()->GetBinLowEdge(0) &&
407  point.Z()< hist->GetZaxis()->GetBinLowEdge(hist->GetZaxis()->GetNbins()+1) ){
408 
409  return true;}
410  return false;
411 
412 }