infid.cxx File Reference

#include "DataUtil/infid.h"
#include <iostream>
#include <cassert>
#include "RVersion.h"
#include "TInterpreter.h"
#include "TMath.h"
#include "TROOT.h"
#include "TSystem.h"
#include "TString.h"

Go to the source code of this file.

Namespaces

namespace  FidVol

Functions

bool FidVol::infid_near_z (SimFlag::SimFlag_t simflg, double z)
bool FidVol::infid_far_z (SimFlag::SimFlag_t simflg, double z)
bool FidVol::infid_near_circle_z (double x, double y)
bool FidVol::infid_near_circle_beam (double x, double y, double z)
bool FidVol::infid_far_coil (double x, double y)
bool FidVol::infid_far_circle (double x, double y)
bool FidVol::infid_far_octagon (double x, double y)
bool FidVol::load_setter_script (std::string name)
bool FidVol::know_setter (std::string funcname)
bool FidVol::legal_indx (int indx, int size)
bool infid (Detector::Detector_t det, SimFlag::SimFlag_t simflg, double x, double y, double z)
void print_infid ()
void choose_infid_set (std::string setname, bool doassert)

Variables

static std::string FidVol::gName = "Default"
static bool FidVol::gNearFollowBeam = true
static double FidVol::gNearR = 1.0
static double FidVol::gNearZData [2] = { 1.01080, 4.99059 }
static double FidVol::gNearZMC [2] = { 1.01080, 4.99059 }
static double FidVol::gBeamAngleRad = 3.34321 * TMath::DegToRad()
static double FidVol::gNearDyDz = TMath::Tan(-gBeamAngleRad)
static double FidVol::gNearX0Beam = 1.4828
static double FidVol::gNearY0Beam = 0.2384
static double FidVol::gNearX0Z = 1.4885
static double FidVol::gNearY0Z = 0.1397
static bool FidVol::gFarOctagon = false
static bool FidVol::gFarCoilCut = true
static double FidVol::gFarRinner = 0.5
static double FidVol::gFarRouter = TMath::Sqrt(14.0)
static double FidVol::gFarZData [4] = { 0.49080, 14.29300, 16.27110, 27.98270}
static double FidVol::gFarZMC [4] = { 0.47692, 14.27860, 16.26470, 27.97240}
static double FidVol::gEvtVtxZOffset = 0.0
static double FidVol::gTrkVtxZOffset = 0.0392
static double FidVol::gShwVtxZOffset = 0.0
const double FidVol::r_sqrt2 = 7.07106781186547462e-01

Function Documentation

void choose_infid_set ( std::string  setname,
bool  doassert 
)

Definition at line 192 of file infid.cxx.

References done(), Form(), FidVol::know_setter(), FidVol::load_setter_script(), and print_infid().

Referenced by NuAnalysis::DemoInfidSRInterface(), MadScanDisplay::DrawTextBox(), MadScanDisplay::InFidNoTrk(), MadScanDisplay::InFidTrk(), NuCut::InFidVol(), NuCut::InFidVolEvt(), NuCut::InFidVolTrueEvt(), MadQuantities::IsFid_2008(), NuCuts::IsInFidVol(), MadAbID::MakeRecoVariables(), and NuCut::SetFidVol().

00193 {
00194   //
00195   // Call function that will configure "infid" parameters
00196   // Function name could be any of:
00197   //    infid_set_<setname>()
00198   //    <setname>()
00199   // And can be defined in any of:
00200   //    infid_sets.C
00201   //    infid_set_<setname>.C
00202   //    <setname>.C
00203   // Found in any of the directories (searched in this order):
00204   //     . ~ $SRT_PRIVATE_CONTEXT/DataUtil $SRT_PUBLIC_CONTEXT/DataUtil
00205   // If doassert is true and function can't be found, then assert()
00206   //
00207   // std::cout << "choose_infid_set(\"" << setname << "\")" << std::endl;
00208   // one-time load of generic macro that that has infid setter functions
00209   static bool loadGeneric = FidVol::load_setter_script("infid_sets.C");
00210   if ( ! loadGeneric ) {
00211     std::cout << "failed to find \"infid_sets.C\"" << std::endl;
00212   }
00213 
00214   const char* patterns[] = { "infid_set_%s", "%s" };
00215   int npatterns = sizeof(patterns)/sizeof(const char*);
00216   bool done = false;
00217 
00218   for (int i = 0; i < npatterns; ++i) {
00219     std::string funcname = Form(patterns[i],setname.c_str());
00220     if ( ! FidVol::know_setter(funcname) ) {
00221       // not known, try loading script if one can be found
00222       FidVol::load_setter_script(funcname);
00223     }
00224     if ( FidVol::know_setter(funcname) ) {
00225       funcname += "();";
00226       int psuccess = 0;
00227       gROOT->ProcessLine(funcname.c_str(),&psuccess);
00228       if ( psuccess == 0 ) {
00229         std::cout << "Successfully ran function \"" << funcname 
00230                   << "\" for set \"" << setname << "\"" << std::endl;
00231         done = true;
00232         break; // exit loop
00233       } else {
00234         std::cout << "Failed running macro \"" << funcname << "\" for set \"" 
00235                   << setname << "\"" << std::endl;
00236         if (doassert) assert(0);
00237       }
00238     } else {
00239       std::cout << "Found no setter function " << funcname 
00240                 << "() for \"" << setname << "\"" << std::endl;
00241     }
00242   } // end loop over patterns
00243   if ( ! done ) {
00244     if ( doassert ) assert(0);
00245     else {
00246       std::cout << "choose_infid_set(\"" << setname << "\") FAILED" 
00247                 << ", but user chose not to assert()" << std::endl;
00248     }
00249   }
00250   print_infid();
00251 }

bool infid ( Detector::Detector_t  det,
SimFlag::SimFlag_t  simflg,
double  x,
double  y,
double  z 
)

Definition at line 84 of file infid.cxx.

References FidVol::gFarCoilCut, FidVol::gFarOctagon, FidVol::gNearFollowBeam, FidVol::infid_far_circle(), FidVol::infid_far_coil(), FidVol::infid_far_octagon(), FidVol::infid_far_z(), FidVol::infid_near_circle_beam(), FidVol::infid_near_circle_z(), FidVol::infid_near_z(), Detector::kFar, and Detector::kNear.

Referenced by NuAnalysis::DemoInfidSRInterface(), MadScanDisplay::DrawTextBox(), Anp::FillBasic::Fill(), NuCutImps::ChairSound::GetRegion(), infid(), MadScanDisplay::InFidNoTrk(), MadScanDisplay::InFidTrk(), NuCut::InFidVol(), NuCut::InFidVolEvt(), NuCut::InFidVolTrueEvt(), MadQuantities::IsFid_2008(), NuCuts::IsInFidVol(), NueAnalysisCuts::IsInsideFarFiducial(), NueAnalysisCuts::IsInsideNearFiducial(), MadAbID::MakeRecoVariables(), NueStandard::PassesSelection(), and Anp::FillTruth::Run().

00086 {
00087   if      ( Detector::kNear == det ) {
00088     // test z
00089     if ( ! FidVol::infid_near_z(simflg,z) ) return false;
00090     // test transverse
00091     if ( FidVol::gNearFollowBeam ) return FidVol::infid_near_circle_beam(x,y,z);
00092     else                           return FidVol::infid_near_circle_z(x,y);
00093   }
00094   else if ( Detector::kFar == det ) {
00095     // test z
00096     if ( ! FidVol::infid_far_z(simflg,z) ) return false;
00097     // test coil cut (if requested)
00098     if ( FidVol::gFarCoilCut && ! FidVol::infid_far_coil(x,y) ) return false;
00099     // test transverse
00100     if ( FidVol::gFarOctagon ) return FidVol::infid_far_octagon(x,y);
00101     else                       return FidVol::infid_far_circle(x,y);
00102   }
00103   // unknown detector
00104   return true;
00105 }

void print_infid (  ) 

Definition at line 109 of file infid.cxx.

References Form(), FidVol::gBeamAngleRad, FidVol::gEvtVtxZOffset, FidVol::gFarCoilCut, FidVol::gFarOctagon, FidVol::gFarRinner, FidVol::gFarRouter, FidVol::gFarZData, FidVol::gFarZMC, FidVol::gName, FidVol::gNearDyDz, FidVol::gNearFollowBeam, FidVol::gNearR, FidVol::gNearX0Beam, FidVol::gNearX0Z, FidVol::gNearY0Beam, FidVol::gNearY0Z, FidVol::gNearZData, FidVol::gNearZMC, FidVol::gShwVtxZOffset, and FidVol::gTrkVtxZOffset.

Referenced by choose_infid_set().

00110 {
00111   std::cout << "Current infid settings: \"" << FidVol::gName 
00112             << "\"" << std::endl;
00113   std::cout << "Near:";
00114   std::cout << " cylinder radius " << FidVol::gNearR;
00115   if ( FidVol::gNearFollowBeam ) {
00116     std::cout << ", x0=" << FidVol::gNearX0Beam 
00117               << ", y0=" << FidVol::gNearY0Beam
00118               << ", follow beam" << std::endl;
00119     std::cout << "      dy/dz " << FidVol::gNearDyDz
00120               << " (angle " << FidVol::gBeamAngleRad << " radians)" 
00121               << std::endl;
00122   } else {
00123     std::cout << ", x0=" << FidVol::gNearX0Z 
00124               << ", y0=" << FidVol::gNearY0Z 
00125               << ", along z axis" << std::endl;
00126   }
00127   std::cout << "      z limits data: " 
00128             << Form("%8.5f",FidVol::gNearZData[0]) << " " 
00129             << Form("%8.5f",FidVol::gNearZData[1]) << std::endl
00130             << "                 MC: " 
00131             << Form("%8.5f",FidVol::gNearZMC[0]) << " " 
00132             << Form("%8.5f",FidVol::gNearZMC[1]) << std::endl;
00133 
00134   std::cout << "Far:";
00135   std::cout << "  " << (FidVol::gFarOctagon?"octagon inscribed":"circle") 
00136             << " radius " << FidVol::gFarRouter << ", ";
00137   if ( FidVol::gFarCoilCut ) 
00138     std::cout << "coil cut " << FidVol::gFarRinner;
00139   else
00140     std::cout << "no coil cut";     
00141   std::cout << std::endl;
00142   std::cout << "      z limits data: " 
00143             << Form("%8.5f",FidVol::gFarZData[0]) << " " 
00144             << Form("%8.5f",FidVol::gFarZData[1]) << " "
00145             << Form("%8.5f",FidVol::gFarZData[2]) << " "
00146             << Form("%8.5f",FidVol::gFarZData[3]) << std::endl
00147             << "                 MC: " 
00148             << Form("%8.5f",FidVol::gFarZMC[0]) << " " 
00149             << Form("%8.5f",FidVol::gFarZMC[1]) << " "
00150             << Form("%8.5f",FidVol::gFarZMC[2]) << " " 
00151             << Form("%8.5f",FidVol::gFarZMC[3]) << std::endl;
00152 
00153   std::cout << "Evt/Trk/Shw vertex offsets:"
00154             << " " << Form("%8.5f",FidVol::gEvtVtxZOffset)
00155             << "/" << Form("%8.5f",FidVol::gTrkVtxZOffset)
00156             << "/" << Form("%8.5f",FidVol::gShwVtxZOffset)
00157             << std::endl;
00158 
00159 }


Generated on 20 Feb 2018 for loon by  doxygen 1.6.1