Skip to content

Commit

Permalink
Merge pull request #30 from maureeungaro/main
Browse files Browse the repository at this point in the history
1.4 tag PR
  • Loading branch information
maureeungaro authored Apr 26, 2023
2 parents f1639ae + fbe23e8 commit 48e943f
Show file tree
Hide file tree
Showing 41 changed files with 472 additions and 159 deletions.
6 changes: 3 additions & 3 deletions eventDispenser/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from init_env import init_environment

# load needed environment for this library
env = init_environment('glibrary geant4')
env = init_environment('glibrary geant4 clhep')

# we build the library in ../lib
# by default, targets outside the current tree are not selected.
Expand All @@ -20,5 +20,5 @@ env.Append(LIBS = 'eventDispenser')
# builds the example
example = env.Program(source = 'example.cc', target = 'example')

# example(s) depend on the library existance
Depends(example, lib);
# example(s) depend on the library existence
Requires(example, lib);
2 changes: 1 addition & 1 deletion eventDispenser/eventDispenser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ int EventDispenser::processEvents()
int ntotalSubRuns = ( lastSubRunNEvents > 0 ? nsubRuns + 1 : nsubRuns);
for ( int s = 0; s < nsubRuns; s++ ) {
if(verbosity >= GVERBOSITY_SUMMARY) {
int upToNevents = totalSoFar + nEventBuffer;
// int upToNevents = totalSoFar + nEventBuffer;
string log = " " + string(EVENTDISPENSERLOGMSGITEM) + " Sub run: " + to_string(s+1) + "/" + to_string(ntotalSubRuns)
+ ", processing events " + to_string(totalSoFar) + "" + to_string(totalSoFar);
gLogMessage(log);
Expand Down
3 changes: 3 additions & 0 deletions g4system/g4objectsFactories/cad/buildPhysical.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// TODO: print everything about this volume if verbosity
G4VPhysicalVolume* G4CadSystemFactory::buildPhysical(GOptions* gopt, GVolume *s, map<string, G4Volume*> *g4s)
{
if ( ! s->getExistence() ) {
return nullptr;
}
string g4name = s->getG4Name();
bool verbosity = getVerbosity(gopt, g4name);

Expand Down
3 changes: 3 additions & 0 deletions g4system/g4objectsFactories/g4native/buildPhysical.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// TODO: print everything about this volume if verbosity
G4VPhysicalVolume* G4NativeSystemFactory::buildPhysical(GOptions* gopt, GVolume *s, map<string, G4Volume*> *g4s)
{
if ( ! s->getExistence() ) {
return nullptr;
}
string g4name = s->getG4Name();
bool verbosity = getVerbosity(gopt, g4name);

Expand Down
2 changes: 1 addition & 1 deletion g4system/g4objectsFactories/geant4Dependencies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
bool G4ObjectsFactory::checkSolidDependencies(bool verbosity, GVolume *s, map<string, G4Volume*> *g4s)
{
// checking if it's a copy, replica or solid operation
// they are mutually exclusve
// they are mutually exclusive
string copyOf = s->getCopyOf();
string replicaOf = s->getReplicaOf();
string solidsOpr = s->getSolidsOpr();
Expand Down
16 changes: 9 additions & 7 deletions g4system/g4world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,20 @@ G4World::G4World(GWorld *gworld, GOptions* gopts) {
string factory = s.second->getFactoryName();
string g4Factory = g4FactoryNameFromSystemFactory(factory);

if(factory == GSYSTEMTEXTFACTORY || factory == GSYSTEMMYSQLTFACTORY) {
// registering factories
if(factory == GSYSTEMTEXTFACTORYLABEL || factory == GSYSTEMSQLITETFACTORYLABEL || factory == GSYSTEMMYSQLTFACTORYLABEL || factory == GSYSTEMJSONFACTORYLABEL) {
// if factory not found, registering it in the manager and loading it into the map
if(g4systemFactory.find(g4Factory) == g4systemFactory.end()) {
g4SystemManager.RegisterObjectFactory<G4NativeSystemFactory>(g4Factory);
}
} else if(factory == GSYSTEMCADTFACTORY) {
} else if(factory == GSYSTEMCADTFACTORYLABEL) {
// if factory not found, registering it in the manager and loading it into the map
if(g4systemFactory.find(G4SYSTEMCADFACTORY) == g4systemFactory.end()) {
if(g4systemFactory.find(GSYSTEMCADTFACTORYLABEL) == g4systemFactory.end()) {
g4SystemManager.RegisterObjectFactory<G4CadSystemFactory>(g4Factory);
}
}


// factories are registered, creating them
if ( g4systemFactory.find(g4Factory) == g4systemFactory.end() ) {
g4systemFactory[g4Factory] = g4SystemManager.CreateObject<G4ObjectsFactory>(g4Factory);
}
Expand Down Expand Up @@ -116,7 +118,7 @@ G4World::G4World(GWorld *gworld, GOptions* gopts) {
// calling loadG4System
// if a new system cannot be loaded, false is returned and the volumes added to thisIterationRemainingVolumes
if(g4systemFactory[g4Factory]->loadG4System(gopts, gvolume, g4volumesMap) == false) {
thisIterationRemainingVolumes.push_back(gvolume);
if ( gvolume->getExistence() ) { thisIterationRemainingVolumes.push_back(gvolume); }
}
} else {
G4cerr << FATALERRORL << "g4systemFactory factory <" << g4Factory << "> not found in map." << endl;
Expand Down Expand Up @@ -177,9 +179,9 @@ G4World::G4World(GWorld *gworld, GOptions* gopts) {


string G4World::g4FactoryNameFromSystemFactory(string factory) {
if ( factory == GSYSTEMTEXTFACTORY || factory == GSYSTEMMYSQLTFACTORY ) {
if(factory == GSYSTEMTEXTFACTORYLABEL || factory == GSYSTEMSQLITETFACTORYLABEL || factory == GSYSTEMMYSQLTFACTORYLABEL || factory == GSYSTEMJSONFACTORYLABEL) {
return G4SYSTEMNATFACTORY;
} else if ( factory == GSYSTEMCADTFACTORY ) {
} else if ( factory == GSYSTEMCADTFACTORYLABEL ) {
return G4SYSTEMCADFACTORY;
} else {
cerr << FATALERRORL << "g4systemFactory factory <" << factory << "> not found in g4FactoryNameFromSystemFactory." << endl;
Expand Down
4 changes: 3 additions & 1 deletion g4system/todo
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
- lot of code in common in buildSolid and buildLogical between the factories
- refine gopt->getString("logVolume");


- modifier for volumes in cad import: json file similar to GModifier?
4 changes: 2 additions & 2 deletions gdata/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ lib = SConscript('SConscript', exports='env')
env.Append(LIBS = 'gdata')

# builds the example
#example = env.Program(source = 'example.cc', target = 'example')
example = env.Program(source = 'example.cc', target = 'example')

# example(s) depend on the library existance
#Depends(example, lib);
Requires(example, lib);
2 changes: 1 addition & 1 deletion gdata/example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int argc, char* argv[])

// calling gheader with verbosity 1 for debugging purposes
GEventDataCollectionHeader *gheader = new GEventDataCollectionHeader(evn, evn, 1);
GEventDataCollection *eventData = new GEventDataCollection(gheader, 1);
//GEventDataCollection *eventData = new GEventDataCollection(gheader, 1);

// hit with null G4Step (not used)
// a bitset
Expand Down
3 changes: 3 additions & 0 deletions gdynamicDigitization/ctofRoutinesExample.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "ctofRoutinesExample.h"

#include <iostream>
using namespace std;

bool CTofRoutineExample::defineReadoutSpecs() {

float timeWindow = 10; // electronic readout time-window of the detector
Expand Down
9 changes: 9 additions & 0 deletions gdynamicDigitization/gdynamicdigitization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ GTrueInfoData* GDynamicDigitization::collectTrueInformation(GHit *ghit, size_t h
{
GTrueInfoData* trueInfoData = new GTrueInfoData(ghit);


vector<GIdentifier> identities = ghit->getGID();

// loop over all identities
for ( auto& identity: identities ) {
trueInfoData->includeVariable(identity.getName(), identity.getValue() );
}


// notices:
// we do each var hitbit group loop separately in case some are not filled

Expand Down
6 changes: 3 additions & 3 deletions goptions/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ structuredExample = env.Program(source = 'examples/structureExample.cc'
cumulativeStructureExample = env.Program(source = 'examples/cumulativeStructureExample.cc', target = 'cumulativeStructureExample')

# example(s) depend on the library existance
Depends(simpleExample, lib);
Depends(structuredExample, simpleExample);
Depends(cumulativeStructureExample, structuredExample);
Requires(simpleExample, lib);
Requires(structuredExample, simpleExample);
Requires(cumulativeStructureExample, structuredExample);
2 changes: 1 addition & 1 deletion gparticle/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ env.Append(LIBS = 'gparticle')
example = env.Program(source = 'example.cc', target = 'example/example')

# example(s) depend on the library existance
Depends(example, lib);
Requires(example, lib);
9 changes: 7 additions & 2 deletions gsystem/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Import('env')
env.Append(CXXFLAGS=['-std=c++20'])

env.Append(CPPPATH = [Dir('gsystemFactories'), Dir('gsystemFactories/cad'), Dir('gsystemFactories/text'), Dir('gsystemFactories/gdml'), Dir('gsystemFactories/mysql')])
env.Append(CPPPATH = [Dir('gsystemFactories'), Dir('gsystemFactories/cad'), Dir('gsystemFactories/text'), Dir('gsystemFactories/gdml'), Dir('gsystemFactories/sqlite')])

sources = [
'gvolume.cc',
Expand All @@ -19,8 +19,13 @@ sources = [
'gsystemFactories/cad/loadGeometry.cc',
'gsystemFactories/gdml/systemGdmlFactory.cc',
'gsystemFactories/gdml/loadMaterials.cc',
'gsystemFactories/gdml/loadGeometry.cc'
'gsystemFactories/gdml/loadGeometry.cc',
'gsystemFactories/sqlite/systemSqliteFactory.cc',
'gsystemFactories/sqlite/loadMaterials.cc',
'gsystemFactories/sqlite/loadGeometry.cc'
]

env.Append(LIBS = 'sqlite3')

# destination library is one dir up - relative to this SConscript
lib = env.Library(source = sources, target='../lib/gsystem')
10 changes: 8 additions & 2 deletions gsystem/gmaterial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ GMaterial::GMaterial(string s, vector<string> pars) : system(s)
int i=0;

name = removeAllSpacesFromString(pars[i++]);
description = pars[i++];
density = stod(removeAllSpacesFromString(pars[i++]));

// sets components and amounts
setComponentsFromString(pars[i++]);

// description
description = pars[i++];

// optical properties
getMaterialPropertyFromString(pars[i++], "photonEnergy");
getMaterialPropertyFromString(pars[i++], "indexOfRefraction");
getMaterialPropertyFromString(pars[i++], "absorptionLength");
getMaterialPropertyFromString(pars[i++], "reflectivity");
getMaterialPropertyFromString(pars[i++], "efficiency");

// scintillation properties
getMaterialPropertyFromString(pars[i++], "fastcomponent");
getMaterialPropertyFromString(pars[i++], "slowcomponent");

Expand All @@ -42,6 +47,7 @@ GMaterial::GMaterial(string s, vector<string> pars) : system(s)
yieldratio = stod(removeLeadingAndTrailingSpacesFromString(pars[i++]));
birkConstant = stod(removeLeadingAndTrailingSpacesFromString(pars[i++]));

// other optical processes
getMaterialPropertyFromString(pars[i++], "rayleigh");

}
Expand All @@ -52,7 +58,6 @@ ostream &operator<<(ostream &stream, GMaterial gMat)
{
stream << endl;
stream << " - Material: " << gMat.name << " in system " << gMat.system << ": " << endl;
stream << " " << gMat.description << endl;
stream << " Density: " << gMat.density << endl;
if ( gMat.components.size() > 0 ) {
stream << " Composition: " << endl;
Expand All @@ -61,6 +66,7 @@ ostream &operator<<(ostream &stream, GMaterial gMat)
stream << "" << gMat.components[m] << quantity << " " << gMat.amounts[m] << endl;
}
}
stream << " Description: " << gMat.description << endl;
stream << endl;

return stream;
Expand Down
2 changes: 1 addition & 1 deletion gsystem/gmodifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GModifier
cout << GSYSTEMLOGHEADER << "volume " << name << " modified with:";
if ( shift != GSYSTEMNOMODIFIER) cout << " - shift: " << shift ;
if ( tilts != GSYSTEMNOMODIFIER) cout << " - tilts: " << tilts ;
if ( !isPresent ) cout << " - existance: " << isPresent ;
if ( !isPresent ) cout << " - existence: " << isPresent ;
cout << endl;
}
}
Expand Down
17 changes: 12 additions & 5 deletions gsystem/gsystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
using namespace std;

// init system based on name, factory, variation and run number
GSystem::GSystem(string n, string f, string v, int verbosity) :
GSystem::GSystem(string n, string f, string v, int verbosity, int r, string notes, string sqlf):
factoryName(f),
variation(v) {

variation(v),
runno(r),
annotations(notes),
sqlite_file(sqlf)
{
path = gutilities::getDirFromPath(n);
name = gutilities::getFileFromPath(n);

Expand All @@ -38,6 +41,9 @@ variation(v) {
// build and add a gvolume to the map from system parameters
void GSystem::addGVolume(vector<string> pars, int verbosity) {

pars.push_back(variation);
pars.push_back(to_string(runno));

string voumeName = pars[0];

if(gvolumesMap->find(voumeName) == gvolumesMap->end()) {
Expand All @@ -46,6 +52,7 @@ void GSystem::addGVolume(vector<string> pars, int verbosity) {
cout << GSYSTEMLOGHEADER << "Adding gVolume <" << voumeName << "> to gvolumesMap with name as key"<< endl;
}
(*gvolumesMap)[voumeName] = new GVolume(name, pars);

if(verbosity >= GVERBOSITY_DETAILS) {
cout << *(*gvolumesMap)[voumeName] ;
}
Expand Down Expand Up @@ -77,10 +84,10 @@ void GSystem::addVolumeFromFile(string importType, string filename, int verbosit

// order is defined in gvolume.cc
pars.push_back(gvolumeName); // 01 name
pars.push_back(ROOTWORLDGVOLUMENAME); // 02 mother: by default is ROOTWORLDGVOLUMENAME
pars.push_back(importType); // 03 type
pars.push_back(UNINITIALIZEDSTRINGQUANTITY); // 04 parameters
pars.push_back("G4_AIR"); // 05 material: default is air
pars.push_back(ROOTWORLDGVOLUMENAME); // 02 mother: by default is ROOTWORLDGVOLUMENAME
pars.push_back("0*cm, 0*cm, 0*cm"); // 06 pos
pars.push_back("0*deg, 0*deg, 0*deg"); // 07 rot
pars.push_back(UNINITIALIZEDSTRINGQUANTITY); // 08 emfield
Expand Down Expand Up @@ -112,7 +119,7 @@ GVolume* GSystem::getGVolume(string volumeName) const {

// MARK: GMATERIALS

// add gmaterial using parameters (TEXT or MYSQL factories)
// add gmaterial using parameters (TEXT or SQL factories)
void GSystem::addGMaterial(vector<string> pars, int verbosity) {

string materialName = pars[0];
Expand Down
13 changes: 11 additions & 2 deletions gsystem/gsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class GSystem

public:
// constructor, from command line or jcard
GSystem(string givenname, string factory, string variation, int verbosity);
GSystem(string givenname, string factory, string variation, int verbosity,
int runno = 0,
string annotations = "none",
string sqlite_file = "none");

private:

Expand All @@ -25,11 +28,14 @@ class GSystem
string path; // Absolute/relative path
string factoryName; // Name of actory that builds the detector
string variation = "default"; // Variation of the detector. Default is "default"
int runno; // Run number
string annotations; // Annotations of the detector. "mats_only" means that only materials are loaded.
string sqlite_file; // database

// map containing the volumes
// the key is system + volume name;
// the names must be unique in each system
// each system name must be unique
// name must be unique
map<string, GVolume*> *gvolumesMap;

// materials are part of a system and cannot be shared among systems
Expand All @@ -41,6 +47,9 @@ class GSystem
inline const string getFactoryName() const { return factoryName; }
inline const string getVariation() const { return variation; }
inline const string getFilePath() const { return path + "/" + name; }
inline const string getAnnotations() const { return annotations; }
inline const int getRunno() const { return runno; }
inline const string getSqliteFile() const { return sqlite_file; }


// MARK: GVOLUMES
Expand Down
20 changes: 10 additions & 10 deletions gsystem/gsystemConventions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// The volumes and materials in each system must have an unique name

// number of database pars defining a gvolume and a gmaterial
#define GVOLUMENUMBEROFPARS 19
#define GVOLUMENUMBEROFPARS 21
#define GMATERIALNUMBEROFPARS 18

// must match the API definitions
Expand All @@ -24,23 +24,23 @@
#define EC__GMATERIALOPTICALPROPERTYMISMATCH 206
#define EC__GMATERIALNOTFOUND 207
#define EC__GVOLUMENAMECONTAINSINVALID 208
#define EC__GSQLITEERROR 209

#define GSYSTEMLOGHEADER " ❖ GSystem ▸ "
#define GSYSTEMNOMODIFIER "noModifier"

#define GEMCDB_ENV "GEMCDB_ENV"
#define GSYSTEMTXTFACTORY "GSystemTEXTFactory"
#define GSYSTEMCADFACTORY "GSystemCADFactory"
#define GSYSTEMGDMLFACTORY "GSystemGDMLFactory"
#define GSYSTEMYSQLFACTORY "GSystemMYSQLFactory"
#define GEMCDB_ENV "GEMCDB_ENV"

#define ROOTWORLDGVOLUMENAME "root"
#define MOTHEROFUSALL "akasha"
#define GSYSTEM_DELIMITER "/"

#define GSYSTEMTEXTFACTORY "text"
#define GSYSTEMCADTFACTORY "cad"
#define GSYSTEMGDMLTFACTORY "gdml"
#define GSYSTEMMYSQLTFACTORY "mysql"
// factory labels
#define GSYSTEMTEXTFACTORYLABEL "TEXT"
#define GSYSTEMJSONFACTORYLABEL "JSON"
#define GSYSTEMCADTFACTORYLABEL "CAD"
#define GSYSTEMGDMLTFACTORYLABEL "GDML"
#define GSYSTEMMYSQLTFACTORYLABEL "MYSQL"
#define GSYSTEMSQLITETFACTORYLABEL "SQLITE"

#endif
Loading

0 comments on commit 48e943f

Please sign in to comment.