// $Id$ // // File: DApplication.cc // Created: Mon Jul 3 21:46:01 EDT 2006 // Creator: davidl (on Darwin Harriet.local 8.6.0 powerpc) // #include using std::string; #include #include "DApplication.h" #include "HDDM/DEventSourceHDDMGenerator.h" #include "HDGEOMETRY/DMagneticFieldMapCalibDB.h" #include "HDGEOMETRY/DMagneticFieldMapConst.h" #include "HDGEOMETRY/DMagneticFieldMapSpoiled.h" #include "HDGEOMETRY/DLorentzMapCalibDB.h" //#include "HDGEOMETRY/DMaterialMapCalibDB.h" #include "HDGEOMETRY/DRootGeom.h" #include "DFactoryGenerator.h" //--------------------------------- // DApplication (Constructor) //--------------------------------- DApplication::DApplication(int narg, char* argv[]):JApplication(narg, argv) { /// Add DEventSourceHDDMGenerator and /// DFactoryGenerator, which adds the default /// list of Hall-D factories AddEventSourceGenerator(new DEventSourceHDDMGenerator()); AddFactoryGenerator(new DFactoryGenerator()); // Add plugin paths to Hall-D specific binary directories const char *bms = getenv("BMS_OSNAME"); string sbms(bms==NULL ? "":bms); if(const char *ptr = getenv("DANA_PLUGIN_PATH")){ AddPluginPath(string(ptr)); } if(const char *ptr = getenv("HALLD_MY")){ AddPluginPath(string(ptr) + "/lib/" + sbms); } if(const char *ptr = getenv("HALLD_HOME")){ AddPluginPath(string(ptr) + "/lib/" + sbms); } if(JVersion::minor<5)Init(); } //--------------------------------- // Init //--------------------------------- jerror_t DApplication::Init(void) { this->JApplication::Init(); // Create magnetic field object for use by everyone // Allow a trivial homogeneous map to be used if // specified on the command line string bfield_type = "CalibDB"; GetJParameterManager()->SetDefaultParameter("BFIELD_TYPE", bfield_type); if(bfield_type=="CalibDB"){ bfield = new DMagneticFieldMapCalibDB(this); cout<<"Created Magnetic field map of type DMagneticFieldMapCalibDB."<NOT efficient to call this /// method for every event. The pointer should be obtained /// in a brun() method and kept in a local variable if /// needed outside of brun(). // First, get the JGeometry object using our JApplication // base class. Then, use that to find the correct DGeometry // object if it exists. JGeometry *jgeom = GetJGeometry(run_number); if(!jgeom){ _DBG_<<"ERROR: Unable get geometry for run "<GetJGeometry() == jgeom){ DGeometry *dgeom = geometries[i]; Unlock(); return dgeom; } } // Couldn't find a DGeometry object that uses this JGeometry object. // Create one and add it to the list. DGeometry *dgeom = new DGeometry(jgeom, this, run_number); geometries.push_back(dgeom); cout<<"Geometry created:"<GetRunRequested()<<" found:"<GetRunFound()<GetRunMin()<<"-"<GetRunMax()<GetURL()<<"\""<<" context=\""<GetContext()<<"\""<