#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 | infid_near_z (SimFlag::SimFlag_t simflg, double z) |
| bool | infid_far_z (SimFlag::SimFlag_t simflg, double z) |
| bool | infid_near_circle_z (double x, double y) |
| bool | infid_near_circle_beam (double x, double y, double z) |
| bool | infid_far_coil (double x, double y) |
| bool | infid_far_circle (double x, double y) |
| bool | infid_far_octagon (double x, double y) |
| bool | load_setter_script (std::string name) |
| bool | know_setter (std::string funcname) |
| bool | 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 | |
| std::string | gName = "Default" |
| bool | gNearFollowBeam = true |
| double | gNearR = 1.0 |
| double | gNearZData [2] = { 1.01080, 4.99059 } |
| double | gNearZMC [2] = { 1.01080, 4.99059 } |
| double | gBeamAngleRad = 3.34321 * TMath::DegToRad() |
| double | gNearDyDz = TMath::Tan(-gBeamAngleRad) |
| double | gNearX0Beam = 1.4828 |
| double | gNearY0Beam = 0.2384 |
| double | gNearX0Z = 1.4885 |
| double | gNearY0Z = 0.1397 |
| bool | gFarOctagon = false |
| bool | gFarCoilCut = true |
| double | gFarRinner = 0.5 |
| double | gFarRouter = TMath::Sqrt(14.0) |
| double | gFarZData [4] = { 0.49080, 14.29300, 16.27110, 27.98270} |
| double | gFarZMC [4] = { 0.47692, 14.27860, 16.26470, 27.97240} |
| double | gEvtVtxZOffset = 0.0 |
| double | gTrkVtxZOffset = 0.0392 |
| double | gShwVtxZOffset = 0.0 |
| const double | r_sqrt2 = 7.07106781186547462e-01 |
|
||||||||||||
|
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 }
|
|
||||||||||||||||||||||||
|
Definition at line 84 of file infid.cxx. References 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(), and FidVol::infid_near_z(). Referenced by NueStandard::PassesSelection(). 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 }
|
|
||||||||||||
|
Definition at line 314 of file infid.cxx. References FidVol::gFarRouter. Referenced by infid(). 00315 {
00316 double r2 = x*x + y*y;
00317 if ( r2 > gFarRouter*gFarRouter ) return false;
00318 return true;
00319 }
|
|
||||||||||||
|
Definition at line 307 of file infid.cxx. References FidVol::gFarRinner. Referenced by infid(). 00308 {
00309 double r2 = x*x + y*y;
00310 if ( r2 < gFarRinner*gFarRinner ) return false;
00311 return true;
00312 }
|
|
||||||||||||
|
Definition at line 321 of file infid.cxx. Referenced by infid(). 00322 {
00323 if ( TMath::Abs(x) > gFarRouter ) return false;
00324 if ( TMath::Abs(y) > gFarRouter ) return false;
00325
00326 double u = ( x + y ) * r_sqrt2;
00327 double v = ( -x + y ) * r_sqrt2;
00328
00329 if ( TMath::Abs(u) > gFarRouter ) return false;
00330 if ( TMath::Abs(v) > gFarRouter ) return false;
00331
00332 return true;
00333 }
|
|
||||||||||||
|
Definition at line 265 of file infid.cxx. Referenced by infid(). 00266 {
00267 double* zcuts = gFarZData;
00268 if ( SimFlag::kMC == simflg ) zcuts = gFarZMC;
00269 if ( z < zcuts[0] ) return false;
00270 if ( z > zcuts[3] ) return false;
00271 if ( z > zcuts[1] && z < zcuts[2] ) return false;
00272 return true;
00273 }
|
|
||||||||||||||||
|
Definition at line 298 of file infid.cxx. References FidVol::gNearR, and FidVol::gNearY0Beam. Referenced by infid(). 00299 {
00300 double xx = x - gNearX0Beam;
00301 double yy = y - gNearY0Beam - z*gNearDyDz;
00302 double r2 = xx*xx + yy*yy;
00303 if ( r2 > gNearR*gNearR ) return false;
00304 return true;
00305 }
|
|
||||||||||||
|
Definition at line 289 of file infid.cxx. References FidVol::gNearR. Referenced by infid(). 00290 {
00291 double xx = x - gNearX0Z;
00292 double yy = y - gNearY0Z;
00293 double r2 = xx*xx + yy*yy;
00294 if ( r2 > gNearR*gNearR ) return false;
00295 return true;
00296 }
|
|
||||||||||||
|
Definition at line 256 of file infid.cxx. Referenced by infid(). 00257 {
00258 double* zcuts = gNearZData;
00259 if ( SimFlag::kMC == simflg ) zcuts = gNearZMC;
00260 if ( z < zcuts[0] ) return false;
00261 if ( z > zcuts[1] ) return false;
00262 return true;
00263 }
|
|
|
Definition at line 184 of file infid.cxx. Referenced by choose_infid_set(). 00185 {
00186 // determine if we know how to call this function
00187 TInterpreter* interp = gROOT->GetInterpreter();
00188 void* func = interp->GetInterfaceMethod(0,funcname.c_str(),"");
00189 return ( (func) ? true : false );
00190 }
|
|
||||||||||||
|
Definition at line 74 of file infid.cxx. Referenced by FidVol::getFarZData(), FidVol::getFarZMC(), FidVol::getNearZData(), FidVol::getNearZMC(), FidVol::setFarZData(), FidVol::setFarZMC(), FidVol::setNearZData(), and FidVol::setNearZMC(). 00074 { return (indx>=0 && indx<size); }
|
|
|
Definition at line 161 of file infid.cxx. References gSystem(). Referenced by choose_infid_set(). 00162 {
00163 const char* paths =
00164 ".:~:$SRT_PRIVATE_CONTEXT/DataUtil:$SRT_PUBLIC_CONTEXT/DataUtil";
00165
00166 if ( script.find(".C") == std::string::npos ) script += ".C";
00167 const char* filename = gSystem->Which(paths,script.c_str());
00168 if ( filename ) {
00169 //std::cout << "found " << filename << std::endl;
00170 int errcode = gROOT->LoadMacro(filename);
00171 // gSystem->Which() returns allocated space, give it back when done
00172 delete [] filename;
00173 if ( errcode == 0 ) {
00174 //std::cout << "load macro" << filename << std::endl;
00175 return true;
00176 } else {
00177 std::cout << "failed loading " << script
00178 << ", status = " << filename << std::endl;
00179 }
00180 }
00181 return false;
00182 }
|
|
|
Definition at line 109 of file infid.cxx. References Form(). 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 }
|
|
|
Definition at line 30 of file infid.cxx. Referenced by FidVol::setBeamAngleRad(), and FidVol::setNearDyDz(). |
|
|
Definition at line 54 of file infid.cxx. Referenced by FidVol::setEvtVtxZOffset(). |
|
|
Definition at line 41 of file infid.cxx. Referenced by FidVol::setFarCoilCut(). |
|
|
Definition at line 40 of file infid.cxx. Referenced by FidVol::setFarOctagon(). |
|
|
Definition at line 42 of file infid.cxx. Referenced by FidVol::infid_far_coil(), and FidVol::setFarRinner(). |
|
|
Definition at line 43 of file infid.cxx. Referenced by FidVol::infid_far_circle(), and FidVol::setFarRouter(). |
|
|
Definition at line 46 of file infid.cxx. Referenced by FidVol::getFarZData(), and FidVol::setFarZData(). |
|
|
Definition at line 47 of file infid.cxx. Referenced by FidVol::getFarZMC(), and FidVol::setFarZMC(). |
|
|
Definition at line 19 of file infid.cxx. Referenced by FidVol::setName(). |
|
|
Definition at line 31 of file infid.cxx. Referenced by FidVol::setBeamAngleRad(), and FidVol::setNearDyDz(). |
|
|
Definition at line 22 of file infid.cxx. Referenced by FidVol::setNearFollowBeam(). |
|
|
Definition at line 23 of file infid.cxx. Referenced by FidVol::infid_near_circle_beam(), FidVol::infid_near_circle_z(), and FidVol::setNearR(). |
|
|
Definition at line 32 of file infid.cxx. Referenced by FidVol::setNearX0Beam(). |
|
|
Definition at line 36 of file infid.cxx. Referenced by FidVol::setNearX0Z(). |
|
|
Definition at line 33 of file infid.cxx. Referenced by FidVol::infid_near_circle_beam(), FidVol::infid_near_radius(), and FidVol::setNearY0Beam(). |
|
|
Definition at line 37 of file infid.cxx. Referenced by FidVol::setNearY0Z(). |
|
|
Definition at line 26 of file infid.cxx. Referenced by FidVol::getNearZData(), and FidVol::setNearZData(). |
|
|
Definition at line 27 of file infid.cxx. Referenced by FidVol::getNearZMC(), and FidVol::setNearZMC(). |
|
|
Definition at line 56 of file infid.cxx. Referenced by FidVol::setShwVtxZOffset(). |
|
|
Definition at line 55 of file infid.cxx. Referenced by FidVol::setTrkVtxZOffset(). |
|
|
|
1.3.9.1