Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ssdetlab committed Nov 6, 2024
1 parent c956e4d commit bd0ded9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class JsonTrackParamsLookupReader final : public ITrackParamsLookupReader {
std::pair<std::size_t, std::size_t> bins;
};

JsonTrackParamsLookupReader(const Config& config) : m_cfg(config){};
JsonTrackParamsLookupReader(const Config& config) : m_cfg(config) {};

~JsonTrackParamsLookupReader() override = default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class JsonTrackParamsLookupWriter final : public ITrackParamsLookupWriter {
/// Constructor
///
/// @param config The configuration struct of the writer
JsonTrackParamsLookupWriter(const Config& config) : m_cfg(config){};
JsonTrackParamsLookupWriter(const Config& config) : m_cfg(config) {};

/// Virtual destructor
~JsonTrackParamsLookupWriter() override = default;
Expand Down
23 changes: 11 additions & 12 deletions Examples/Python/src/Json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,17 @@ void addJson(Context& ctx) {
}

{
mex.def(
"readDetectorFromJson",
[](const Acts::GeometryContext& gctx,
const std::string& fileName) -> auto{
auto in = std::ifstream(fileName,
std::ifstream::in | std::ifstream::binary);
nlohmann::json jDetectorIn;
in >> jDetectorIn;
in.close();

return Acts::DetectorJsonConverter::fromJson(gctx, jDetectorIn);
});
mex.def("readDetectorFromJson",
[](const Acts::GeometryContext& gctx,
const std::string& fileName) -> auto {
auto in = std::ifstream(
fileName, std::ifstream::in | std::ifstream::binary);
nlohmann::json jDetectorIn;
in >> jDetectorIn;
in.close();

return Acts::DetectorJsonConverter::fromJson(gctx, jDetectorIn);
});
}
}
} // namespace Acts::Python
43 changes: 25 additions & 18 deletions Examples/Scripts/Python/telescope_track_params_lookup_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def estimateLookup(
# Fatras simulation of muons
rnd = acts.examples.RandomNumbers(seed=42)

s = acts.examples.Sequencer(events=numEvents, numThreads=1, logLevel=acts.logging.INFO)
s = acts.examples.Sequencer(
events=numEvents, numThreads=1, logLevel=acts.logging.INFO
)

vertexGen=acts.examples.GaussianVertexGenerator(
stddev=acts.Vector4(0, 0, 0, 0),
mean=acts.Vector4(0, 9, 0, 0)
stddev=acts.Vector4(0, 0, 0, 0), mean=acts.Vector4(0, 9, 0, 0)
)

addParticleGun(
Expand All @@ -41,7 +42,7 @@ def estimateLookup(
particleConfig=ParticleConfig(1, acts.PdgParticle.eMuon, False),
multiplicity=1,
rnd=rnd,
vtxGen = vertexGen
vtxGen=vertexGen,
)

addFatras(
Expand All @@ -51,13 +52,11 @@ def estimateLookup(
inputParticles="particles_input",
outputSimHits="sim_hits",
rnd=rnd,
preSelectParticles=None
preSelectParticles=None,
)

# Set up the track lookup grid writer
jsonWriterConfig = acts.examples.JsonTrackParamsLookupWriter.Config(
path=outputPath
)
jsonWriterConfig = acts.examples.JsonTrackParamsLookupWriter.Config(path=outputPath)
jsonWriter = acts.examples.JsonTrackParamsLookupWriter(jsonWriterConfig)

# Set up the track estimation algorithm
Expand All @@ -66,26 +65,37 @@ def estimateLookup(
refGeometryId = refSurface.geometryId()

trackEstConfig = acts.examples.TrackParamsLookupEstimation.Config(
refLayers={refGeometryId : refSurface},
refLayers={refGeometryId: refSurface},
bins=(1, 1000),
inputHits="sim_hits",
inputParticles="particles_input",
trackLookupGridWriters = [jsonWriter]
trackLookupGridWriters = [jsonWriter],
)
trackEstAlg = acts.examples.TrackParamsLookupEstimation(
trackEstConfig, acts.logging.INFO
)
trackEstAlg = acts.examples.TrackParamsLookupEstimation(trackEstConfig, acts.logging.INFO)

s.addAlgorithm(trackEstAlg)

s.run()


if __name__ == "__main__":
p = argparse.ArgumentParser()

p.add_argument(
"-n", "--events", type=int, default=100000, help="Number of events for lookup estimation"
"-n",
"--events",
type=int,
default=100000,
help="Number of events for lookup estimation",
)
p.add_argument(
"-o", "--output", type=str, default="lookup.json", help="Output lookup file name"
"-o",
"--output",
type=str,
default="lookup.json",
help="Output lookup file name",
)

args = p.parse_args()
Expand All @@ -96,12 +106,9 @@ def estimateLookup(
positions=[30, 60, 90],
stereos=[0, 0, 0],
binValue=2,
surfaceType=0
surfaceType=0,
)

# Estimate the lookup
estimateLookup(
trackingGeometry,
args.events,
args.output)
estimateLookup(trackingGeometry, args.events, args.output)

0 comments on commit bd0ded9

Please sign in to comment.