10 #include <JANA/JVersion.h>
16 #include <sys/types.h>
45 pthread_mutex_init(&
mutex, NULL);
49 TObject::SetObjectStat(kFALSE);
51 TF1::DefaultAddToGlobalList(kFALSE);
54 const char *bms_osname = getenv(
"BMS_OSNAME");
55 string sbms_osname(bms_osname==NULL ?
"":bms_osname);
57 if(
const char *ptr = getenv(
"DANA_PLUGIN_PATH")){
58 AddPluginPath(
string(ptr));
60 if(
const char *ptr = getenv(
"HALLD_MY")){
61 AddPluginPath(
string(ptr) +
"/" + sbms_osname +
"/plugins");
62 AddPluginPath(
string(ptr) +
"/lib/" + sbms_osname);
64 if(
const char *ptr = getenv(
"HALLD_RECON_HOME")){
65 AddPluginPath(
string(ptr) +
"/" + sbms_osname +
"/plugins");
66 AddPluginPath(
string(ptr) +
"/lib/" + sbms_osname);
80 map<string,string> parmap;
81 JParameterManager *pm = GetJParameterManager();
82 pm->GetParameters(parmap,
"THREAD_TIMEOUT");
84 pm->SetParameter(
"THREAD_TIMEOUT",
"30 seconds");
93 bool HDDM_ENABLE =
true;
94 pm->SetDefaultParameter(
"HDDM:ENABLE", HDDM_ENABLE,
"Enable the HDDM source readers. If set to 0, input files are assumed to never be of an HDDM format.");
106 if(JVersion::minor<5)
Init();
115 this->JApplication::Init();
119 GetJParameterManager()->SetDefaultParameter(
"ROOT_ERROR_LEVEL_SUPRESS", ROOT_ERROR_LEVEL_SUPRESS);
127 #if USE_SIMD || USE_SSE2 || USE_SSE3
131 unsigned int cpeinfo;
134 asm(
"mov $0x01, %%eax\ncpuid\n"
135 :
"=d" (cpeinfo),
"=c" (cpsse3)
149 #endif // USE_SIMD || USE_SSE2 || USE_SSE3
152 int sse = ((cpeinfo >> 25) & 0x1 );
154 jerr<<
"DApplication::Init error - application was built"
155 <<
" to run only on machines" << endl
156 <<
"supporting the SSE processor extensions."
157 <<
" Please run on a processor that" << endl
158 <<
"supports SSE, or rebuild with DISABLE_SIMD=yes."
160 return UNRECOVERABLE_ERROR;
165 int sse2 = ((cpeinfo >> 26) & 0x1 );
167 jerr<<
"DApplication::Init error - application was built"
168 <<
" to run only on machines" << endl
169 <<
"supporting the SSE2 processor extensions."
170 <<
" Please run on a processor that" << endl
171 <<
"supports SSE2, or rebuild with DISABLE_SSE2=yes."
173 return UNRECOVERABLE_ERROR;
178 int sse3 = ((cpsse3 ) & 0x1 );
180 jerr<<
"DApplication::Init error - application was built"
181 <<
" to run only on machines" << endl
182 <<
"supporting the SSE3 processor extensions."
183 <<
" Please run on a processor that" << endl
184 <<
"supports SSE3, or rebuild with DISABLE_SSE3=yes."
186 return UNRECOVERABLE_ERROR;
259 JGeometry *jgeom = GetJGeometry(run_number);
261 _DBG_<<
"ERROR: Unable get geometry for run "<<run_number<<
"!"<<endl;
262 _DBG_<<
"Make sure you JANA_GEOMETRY_URL environment variable is set."<<endl;
263 _DBG_<<
"It should be set to something like:"<<endl;
265 _DBG_<<
" xmlfile://${HALLD_RECON_HOME}/src/programs/Simulation/hdds/main_HDDS.xml"<<endl;
267 _DBG_<<
"Exiting now."<<endl;
276 for(
unsigned int i=0; i<
geometries.size(); i++){
284 jout<<
"Creating DGeometry:"<<endl;
285 jout<<
" Run requested:"<<jgeom->GetRunRequested()<<
" found:"<<jgeom->GetRunFound()<<endl;
286 jout<<
" Run validity range: "<<jgeom->GetRunMin()<<
"-"<<jgeom->GetRunMax()<<endl;
287 jout<<
" URL=\""<<jgeom->GetURL()<<
"\""<<
" context=\""<<jgeom->GetContext()<<
"\""<<endl;
288 jout<<
" Type=\""<<jgeom->
className()<<
"\""<<endl;
306 const char *ccdb_help =
308 " Could not load the solenoid field map from the CCDB!\n"
309 " Please specify the solenoid field map to use on the command line, e.g.:\n"
311 " -PBFIELD_MAP=Magnets/Solenoid/solenoid_1200A_poisson_20140520\n"
313 " -PBFIELD_TYPE=NoField\n";
315 pthread_mutex_lock(&
mutex);
319 pthread_mutex_unlock(&
mutex);
326 string bfield_type =
"FineMesh";
327 string bfield_map =
"";
328 GetJParameterManager()->SetDefaultParameter(
"BFIELD_TYPE", bfield_type);
329 if( GetJParameterManager()->Exists(
"BFIELD_MAP") ) {
330 bfield_map = GetJParameterManager()->GetParameter(
"BFIELD_MAP")->GetValue();
332 if(bfield_type==
"CalibDB"|| bfield_type==
"FineMesh"){
334 if( bfield_map !=
"" ) {
339 JCalibration *jcalib = GetJCalibration(run_number);
340 map<string,string> bfield_map_name;
341 if(jcalib->GetCalib(
"/Magnets/Solenoid/solenoid_map", bfield_map_name)) {
343 jerr << ccdb_help << endl;
346 if( bfield_map_name.find(
"map_name") != bfield_map_name.end() ) {
347 if( bfield_map_name[
"map_name"] ==
"NoField" )
353 jerr << ccdb_help << endl;
358 string subclass =
"<none>";
359 if(dynamic_cast<DMagneticFieldMapFineMesh*>(
bfield)) subclass =
"DMagneticFieldMapFineMesh";
360 if(dynamic_cast<DMagneticFieldMapNoField*>(
bfield)) subclass =
"DMagneticFieldMapNoField";
361 jout<<
"Created Magnetic field map of type " << subclass <<endl;
362 }
else if(bfield_type==
"Const"){
364 jout<<
"Created Magnetic field map of type DMagneticFieldMapConst."<<endl;
372 }
else if (bfield_type==
"NoField"){
374 jout <<
"Created Magnetic field map with B=(0,0,0) everywhere." <<endl;
376 _DBG_<<
" Unknown DMagneticFieldMap subclass \"DMagneticFieldMap"<<bfield_type<<
"\" !!"<<endl;
380 pthread_mutex_unlock(&
mutex);
390 pthread_mutex_lock(&
mutex);
394 pthread_mutex_unlock(&
mutex);
401 pthread_mutex_unlock(&
mutex);
411 pthread_mutex_lock(&
mutex);
415 pthread_mutex_unlock(&
mutex);
423 pthread_mutex_unlock(&
mutex);
434 JParameterManager *pm = GetJParameterManager();
435 if(! pm->Exists(
"SQLITE_TO_LOCAL") )
return;
438 pm->SetDefaultParameter(
"SQLITE_TO_LOCAL", tmp);
440 string JANA_CALIB_URL;
441 if( pm->Exists(
"JANA_CALIB_URL" ) ){
442 pm->GetParameter(
"JANA_CALIB_URL", JANA_CALIB_URL);
444 auto url_env = getenv(
"JANA_CALIB_URL");
445 if( url_env != NULL) JANA_CALIB_URL = url_env;
447 if( JANA_CALIB_URL.empty() )
return;
449 if( JANA_CALIB_URL.find(
"sqlite://") != 0 ){
450 jout <<
"WARNING: SQLITE_TO_LOCAL specified but JANA_CALIB_URL does not specify a" << endl;
451 jout <<
" SQLite source. SQLITE_TO_LOCAL will be ignored." << endl;
457 pm->GetParameter(
"SQLITE_TO_LOCAL", dest);
458 string src = JANA_CALIB_URL.substr(10);
461 if( access(src.c_str(), R_OK) == -1 ){
462 jout <<
"WARNING: SQLITE_TO_LOCAL specified but sqlite file specified in JANA_CALIB_URL:" << endl;
463 jout <<
" " << src <<
" does not exist. SQLITE_TO_LOCAL will be ignored." << endl;
468 bool copy_sqlite_file =
true;
469 if( access(dest.c_str(), R_OK) != -1 ){
472 ifstream ifsrc(src.c_str());
473 ifsrc.seekg(0, ifsrc.end);
474 auto size_src = ifsrc.tellg();
476 ifstream ifdest(dest.c_str());
477 ifdest.seekg(0, ifdest.end);
478 auto size_dest = ifdest.tellg();
481 if( size_src == size_dest ){
484 struct stat src_result;
485 struct stat dest_result;
486 stat(src.c_str(), &src_result);
487 stat(dest.c_str(), &dest_result);
488 if( src_result.st_mtime < dest_result.st_mtime ){
489 jout <<
"Modification time of " << src <<
" is older than " << dest << endl;
490 jout <<
"so file will not be copied" << endl;
491 copy_sqlite_file =
false;
497 if( copy_sqlite_file ){
498 jout <<
"Copying " << src <<
" -> " << dest << endl;
499 unlink(dest.c_str());
500 std::ifstream ifs(src.c_str(), std::ios::binary);
501 std::ofstream ofs(dest.c_str(), std::ios::binary);
506 JANA_CALIB_URL =
"sqlite:///" + dest;
507 jout <<
"Overwriting JANA_CALIB_URL with: " << JANA_CALIB_URL << endl;
508 pm->SetParameter(
"JANA_CALIB_URL", JANA_CALIB_URL);
516 pthread_mutex_lock(&
mutex);
520 pthread_mutex_unlock(&
mutex);
527 pthread_mutex_unlock(&
mutex);
DApplication(int narg, char *argv[])
The DApplication class extends the JApplication class by adding the default event source generators a...
DLorentzDeflections * lorentz_def
DMagneticFieldMap * GetBfield(unsigned int run_number=1)
DLorentzDeflections * GetLorentzDeflections(unsigned int run_number=1)
static int ROOT_ERROR_LEVEL_SUPRESS
void CopySQLiteToLocalDisk(void)
DRootGeom * GetRootGeom(unsigned int run_number)
DMagneticFieldMap * bfield
JEventSourceGenerator * event_source_generator
DGeometry * GetDGeometry(unsigned int run_number)
vector< DGeometry * > geometries
JFactoryGenerator * factory_generator
DDIRCLutReader * GetDIRCLut(unsigned int run_number)
static void SetStatusBitDescriptions(jana::JApplication *japp)
void InitDANARootErrorHandler(int my_ROOT_ERROR_LEVEL_SUPRESS)
virtual const char * className(void)
Implements JEventSourceGenerator for REST files.