Skip to content
Snippets Groups Projects
Select Git revision
  • 871937483365b220fa706f72d974b145caa2f3f2
  • master default protected
2 results

compact_geo_test.cxx

Blame
  • compact_geo_test.cxx 1.59 KiB
    #include "UTIL/LCTOOLS.h"
    #include "UTIL/Operators.h"
    #include <UTIL/CellIDDecoder.h>
    //#include "DD4hep/LCDD.h"
    //#include "DD4hep/DD4hepUnits.h"
    // check directory
    #include <sys/stat.h>
    #include <TROOT.h>
    #include <TFile.h>
    #include <TH1D.h>
    #include "TMath.h"
    #include"time.h"
    #include <dirent.h>
    #include <string>
    #include <vector>
    #include <map>
    struct stat sb;
    
    std::vector<std::string> get_files_in_directory(std::string path = "data/.") {
      std::vector<std::string> files;
      if (stat(path.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) { 
        DIR*    dir;
        dirent* pdir;
        dir = opendir(path.c_str());
        while( pdir = readdir(dir) ){
            string rfile=path + "/" + pdir->d_name;
            if (rfile.find(".slcio") != std::string::npos) 
                 files.push_back(rfile); 
        }
        } else {
            cout << "Directory " << path << " does not exist!!" << endl;
            std::exit(0); 
            }
        return files;
    }
    //______________________________________________________________________________
    
    
    void compact_geo_test(
        const char* DIRNAME            = "data/electrons",
        const char* result_file_prefix = "SID_1T",
        const char* compact_file       = "detectors/SiD/compact/sid_working/sidloi3_v00.xml")
    {
    
      DD4hep::Geometry::LCDD& lcdd = DD4hep::Geometry::LCDD::getInstance();
      lcdd.fromCompact(compact_file);
      const double position[3]={0,0,0}; // position to calculate magnetic field at (the origin in this case)
      double bField[3]={0,0,0}; 
      lcdd.field().magneticField(position,bField); 
      _Bz = bField[2]/dd4hep::tesla; 
    
      std::cout << " Magnetic Field Bz = " << _Bz << std::endl;
      return;
    
    }