Skip to content

Commit a6dae27

Browse files
pre-commit-ci[bot]Minjung Kim
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b4ddc9b commit a6dae27

File tree

7 files changed

+128
-141
lines changed

7 files changed

+128
-141
lines changed

src/algorithms/digi/RandomNoise.cc

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -124,35 +124,32 @@ namespace {
124124
}
125125
}
126126

127-
/* -------------------------------------------------------------- */
128-
/* PolarGridRPhi (uniform ΔR, Δφ) */
129-
/* -------------------------------------------------------------- */
130-
template <typename POLAR_UNI>
131-
void scanPolarUniform(const POLAR_UNI& seg,
132-
const TGeoBBox* box,
133-
std::set<dd4hep::CellID>& unique)
134-
{
127+
/* -------------------------------------------------------------- */
128+
/* PolarGridRPhi (uniform ΔR, Δφ) */
129+
/* -------------------------------------------------------------- */
130+
template <typename POLAR_UNI>
131+
void scanPolarUniform(const POLAR_UNI& seg, const TGeoBBox* box,
132+
std::set<dd4hep::CellID>& unique) {
135133
const double dR = seg.gridSizeR();
136134
const double dPhi = seg.gridSizePhi();
137135
const double offR = seg.offsetR();
138136
const double offPhi = seg.offsetPhi();
139137

140-
141138
const double Rmax = std::hypot(box->GetDX(), box->GetDY());
142139

143140
const std::size_t nR = std::max<std::size_t>(1, std::ceil((Rmax - offR) / dR));
144141
const std::size_t nPhi = std::max<std::size_t>(1, std::round(2 * M_PI / dPhi));
145142

146143
for (std::size_t iR = 0; iR < nR; ++iR) {
147-
const double r = offR + (iR + 0.5) * dR;
148-
for (std::size_t iP = 0; iP < nPhi; ++iP) {
149-
const double phi = offPhi + (iP + 0.5) * dPhi;
150-
const double x = r * std::cos(phi);
151-
const double y = r * std::sin(phi);
152-
unique.insert(seg.cellID({x, y, 0}, {x, y, 0}, 0));
153-
}
144+
const double r = offR + (iR + 0.5) * dR;
145+
for (std::size_t iP = 0; iP < nPhi; ++iP) {
146+
const double phi = offPhi + (iP + 0.5) * dPhi;
147+
const double x = r * std::cos(phi);
148+
const double y = r * std::sin(phi);
149+
unique.insert(seg.cellID({x, y, 0}, {x, y, 0}, 0));
150+
}
154151
}
155-
}
152+
}
156153

157154
/* Monte-Carlo fallback */
158155
void scanGeneric(const dd4hep::Segmentation& seg, const TGeoBBox* box,
@@ -366,7 +363,7 @@ RandomNoise::ComponentBounds RandomNoise::ScanComponent(dd4hep::DetElement de,
366363
} else if (auto* pol2 = dynamic_cast<const dd4hep::DDSegmentation::PolarGridRPhi2*>(ptr)) {
367364
scanPolarRPhi(*pol2, unique); // ← 새 함수
368365
} else if (auto* pol1 = dynamic_cast<const dd4hep::DDSegmentation::PolarGridRPhi*>(ptr)) {
369-
scanPolarUniform(*pol1, box, unique);
366+
scanPolarUniform(*pol1, box, unique);
370367
} else {
371368
scanGeneric(seg, box, unique);
372369
}
@@ -394,7 +391,7 @@ RandomNoise::ComponentBounds RandomNoise::ScanComponent(dd4hep::DetElement de,
394391
void RandomNoise::add_noise_hits(
395392
std::unordered_map<std::uint64_t, edm4eic::MutableRawTrackerHit>& cell_hit_map,
396393
const dd4hep::DetElement& det) const {
397-
if (!m_cfg.addNoise ||!m_dd4hepGeo)
394+
if (!m_cfg.addNoise || !m_dd4hepGeo)
398395
return;
399396

400397
auto idPaths = ScanDetectorElement(det);
@@ -485,7 +482,7 @@ void RandomNoise::inject_noise_hits(
485482
static thread_local std::mt19937_64 rng{0xBADA55u};
486483
std::poisson_distribution<std::size_t> pois(m_cfg.n_noise_hits_per_system);
487484
std::size_t nNoise = nNoise = pois(rng);
488-
nNoise = std::min<std::size_t>(nNoise, nChannels);
485+
nNoise = std::min<std::size_t>(nNoise, nChannels);
489486
if (nNoise == 0)
490487
return;
491488

@@ -495,7 +492,6 @@ void RandomNoise::inject_noise_hits(
495492
* 2) RNGs
496493
* ---------------------------------------------------------------- */
497494

498-
499495
std::uniform_int_distribution<std::size_t> pickSensor(0, nSensors - 1);
500496

501497
struct Dist {
@@ -549,7 +545,7 @@ void RandomNoise::inject_noise_hits(
549545
hitMap.emplace(cid, h);
550546
++created;
551547

552-
/* if (dbgPrint--) {
548+
/* if (dbgPrint--) {
553549
std::cout << "[DBG] noise hit " << created << " CellID=0x" << std::hex << cid << std::dec
554550
<< " { ";
555551
bool first = true;
@@ -563,4 +559,4 @@ void RandomNoise::inject_noise_hits(
563559
*/
564560
}
565561
}
566-
} // namespace eicrecon
562+
} // namespace eicrecon

src/algorithms/digi/RandomNoise.h

Lines changed: 58 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include <unordered_set>
4545
#include <vector>
4646

47-
class TGeoNode; // forward declaration (ROOT geometry node)
47+
class TGeoNode; // forward declaration (ROOT geometry node)
4848

4949
namespace eicrecon {
5050

@@ -55,95 +55,82 @@ using PlacementPath = std::vector<TGeoNode*>;
5555

5656
/* One bit-field of the read-out and the discrete values seen in a scan. */
5757
struct FieldInfo {
58-
std::string name; ///< Bit-field name as in ID encoding
59-
std::vector<int> values; ///< Values found in this component
58+
std::string name; ///< Bit-field name as in ID encoding
59+
std::vector<int> values; ///< Values found in this component
6060
};
6161

6262
/* Quick handle for the EICrecon algorithm template. */
6363
using RandomNoiseAlgorithm =
64-
algorithms::Algorithm< algorithms::Input <edm4eic::RawTrackerHitCollection>,
65-
algorithms::Output<edm4eic::RawTrackerHitCollection> >;
64+
algorithms::Algorithm<algorithms::Input<edm4eic::RawTrackerHitCollection>,
65+
algorithms::Output<edm4eic::RawTrackerHitCollection>>;
6666

6767
//-------------------------------------------------------------------------
6868
// Main class
6969
//-------------------------------------------------------------------------
70-
class RandomNoise : public RandomNoiseAlgorithm,
71-
public WithPodConfig<RandomNoiseConfig>
72-
{
70+
class RandomNoise : public RandomNoiseAlgorithm, public WithPodConfig<RandomNoiseConfig> {
7371
public:
74-
/* Map field-name → (min,max) returned by ScanComponent. */
75-
using ComponentBounds = std::map<std::string, std::pair<long,long>>;
72+
/* Map field-name → (min,max) returned by ScanComponent. */
73+
using ComponentBounds = std::map<std::string, std::pair<long, long>>;
7674

77-
/* One complete volID path (field-name → value) and a list thereof. */
78-
using VolIDMap = std::unordered_map<std::string,int>;
79-
using VolIDMapArray = std::vector<VolIDMap>;
75+
/* One complete volID path (field-name → value) and a list thereof. */
76+
using VolIDMap = std::unordered_map<std::string, int>;
77+
using VolIDMapArray = std::vector<VolIDMap>;
8078

81-
explicit RandomNoise(std::string_view name)
82-
: RandomNoiseAlgorithm{
83-
name,
84-
{"inputRawHitCollection"}, // default input tag
85-
{"outputRawHitCollection"}, // default output tag
86-
"Injects random noise hits into a RawTrackerHitCollection." }
87-
{}
79+
explicit RandomNoise(std::string_view name)
80+
: RandomNoiseAlgorithm{name,
81+
{"inputRawHitCollection"}, // default input tag
82+
{"outputRawHitCollection"}, // default output tag
83+
"Injects random noise hits into a RawTrackerHitCollection."} {}
8884

89-
/* Called once – stores pointer to DD4hep geometry. */
90-
void init(const dd4hep::Detector* detector);
85+
/* Called once – stores pointer to DD4hep geometry. */
86+
void init(const dd4hep::Detector* detector);
9187

92-
/* Override default input tag (needed by factory). */
93-
void setInputCollectionName(const std::string& name)
94-
{ m_input_collection_name = name; }
88+
/* Override default input tag (needed by factory). */
89+
void setInputCollectionName(const std::string& name) { m_input_collection_name = name; }
9590

96-
/* Framework entry point – executed for every event. */
97-
void process(const Input&, const Output&) const final;
91+
/* Framework entry point – executed for every event. */
92+
void process(const Input&, const Output&) const final;
9893

99-
//-------------------------------------------------------------------------
100-
// Geometry helpers (public for unit tests, otherwise used internally)
101-
//-------------------------------------------------------------------------
102-
/* Return all ID-paths from ‘de’ to its *sensitive* leaves.
94+
//-------------------------------------------------------------------------
95+
// Geometry helpers (public for unit tests, otherwise used internally)
96+
//-------------------------------------------------------------------------
97+
/* Return all ID-paths from ‘de’ to its *sensitive* leaves.
10398
If keepDeepestOnly==true (default) only the longest paths are kept. */
104-
VolIDMapArray ScanDetectorElement(dd4hep::DetElement de,
105-
bool keepDeepestOnly=true) const;
99+
VolIDMapArray ScanDetectorElement(dd4hep::DetElement de, bool keepDeepestOnly = true) const;
106100

107-
/* Determine min / max of every local segmentation field that appears
101+
/* Determine min / max of every local segmentation field that appears
108102
inside ‘de’. Parameter ‘name’ is reserved for future filters. */
109-
ComponentBounds ScanComponent(dd4hep::DetElement de,
110-
std::string name="") const;
103+
ComponentBounds ScanComponent(dd4hep::DetElement de, std::string name = "") const;
111104

112105
private:
113-
//=====================================================================
114-
// Noise generation helpers
115-
//=====================================================================
116-
117-
/* Add noise hits belonging to one DetElement to the global hit-map. */
118-
void add_noise_hits(
119-
std::unordered_map<std::uint64_t, edm4eic::MutableRawTrackerHit>& hitMap,
120-
const dd4hep::DetElement& det) const;
121-
122-
/* Core routine that creates the actual RawTrackerHits. */
123-
void inject_noise_hits(
124-
std::unordered_map<std::uint64_t, edm4eic::MutableRawTrackerHit>& map,
125-
const dd4hep::DetElement& det,
126-
const VolIDMapArray& idPaths,
127-
const ComponentBounds& bounds) const;
128-
129-
//=====================================================================
130-
// Recursive helper used by ScanDetectorElement
131-
//=====================================================================
132-
void PrintVolIDsRecursive(const dd4hep::PlacedVolume& pv,
133-
VolIDMapArray& result,
134-
VolIDMap& current,
135-
int depth) const;
136-
137-
/* True if every key in ‘keys’ exists in map ‘m’. */
138-
static bool hasAllKeys(const VolIDMap& m,
139-
const std::vector<std::string>& keys);
140-
141-
//-------------------------------------------------------------------------
142-
// Data members
143-
//-------------------------------------------------------------------------
144-
mutable TRandom3 m_random{0}; ///< ROOT RNG (not used atm)
145-
const dd4hep::Detector* m_dd4hepGeo = nullptr;///< DD4hep geometry handle
146-
std::string m_input_collection_name; ///< Input tag override
106+
//=====================================================================
107+
// Noise generation helpers
108+
//=====================================================================
109+
110+
/* Add noise hits belonging to one DetElement to the global hit-map. */
111+
void add_noise_hits(std::unordered_map<std::uint64_t, edm4eic::MutableRawTrackerHit>& hitMap,
112+
const dd4hep::DetElement& det) const;
113+
114+
/* Core routine that creates the actual RawTrackerHits. */
115+
void inject_noise_hits(std::unordered_map<std::uint64_t, edm4eic::MutableRawTrackerHit>& map,
116+
const dd4hep::DetElement& det, const VolIDMapArray& idPaths,
117+
const ComponentBounds& bounds) const;
118+
119+
//=====================================================================
120+
// Recursive helper used by ScanDetectorElement
121+
//=====================================================================
122+
void PrintVolIDsRecursive(const dd4hep::PlacedVolume& pv, VolIDMapArray& result,
123+
VolIDMap& current, int depth) const;
124+
125+
/* True if every key in ‘keys’ exists in map ‘m’. */
126+
static bool hasAllKeys(const VolIDMap& m, const std::vector<std::string>& keys);
127+
128+
//-------------------------------------------------------------------------
129+
// Data members
130+
//-------------------------------------------------------------------------
131+
mutable TRandom3 m_random{0}; ///< ROOT RNG (not used atm)
132+
const dd4hep::Detector* m_dd4hepGeo = nullptr; ///< DD4hep geometry handle
133+
std::string m_input_collection_name; ///< Input tag override
147134
};
148135

149-
} // namespace eicrecon
136+
} // namespace eicrecon

src/algorithms/digi/RandomNoiseConfig.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct RandomNoiseConfig {
1919
// This will be used as the mean for a Poisson distribution.
2020
int n_noise_hits_per_system = 100;
2121

22-
std::string readout_name="VertexBarrelHits";
22+
std::string readout_name = "VertexBarrelHits";
2323
};
2424

25-
} // namespace eicrecon
25+
} // namespace eicrecon

src/detectors/BTRK/BTRK.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ void InitPlugin(JApplication* app) {
3030
app));
3131

3232
app->Add(new JOmniFactoryGeneratorT<RandomNoise_factory>(
33-
"NoisySiBarrelRawHits", // 1. The name of the plugin instance
34-
{"SiBarrelRawHits"}, // 2. The input collection tag
35-
{"NoisySiBarrelRawHits"}, // 3. The output collection tag
36-
{.addNoise = false, .n_noise_hits_per_system = 3784, .readout_name = "SiBarrelHits"}, // 4. Use default config from your .yaml file
37-
app));
38-
33+
"NoisySiBarrelRawHits", // 1. The name of the plugin instance
34+
{"SiBarrelRawHits"}, // 2. The input collection tag
35+
{"NoisySiBarrelRawHits"}, // 3. The output collection tag
36+
{.addNoise = false,
37+
.n_noise_hits_per_system = 3784,
38+
.readout_name = "SiBarrelHits"}, // 4. Use default config from your .yaml file
39+
app));
40+
3941
// Convert raw digitized hits into hits with geometry info (ready for tracking)
4042
app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
4143
"SiBarrelTrackerRecHits", {"NoisySiBarrelRawHits"}, {"SiBarrelTrackerRecHits"},

src/detectors/BVTX/BVTX.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ void InitPlugin(JApplication* app) {
2828
.threshold = 0.54 * dd4hep::keV,
2929
},
3030
app));
31-
app->Add(new JOmniFactoryGeneratorT<RandomNoise_factory>(
32-
"NoisySiBarrelVertexRawHits", // 1. The name of the plugin instance
33-
{"SiBarrelVertexRawHits"}, // 2. The input collection tag
34-
{"NoisySiBarrelVertexRawHits"}, // 3. The output collection tag
35-
{.addNoise = false, .n_noise_hits_per_system = 433, .readout_name = "VertexBarrelHits"}, // 4. Use default config from your .yaml file
36-
app));
37-
31+
app->Add(new JOmniFactoryGeneratorT<RandomNoise_factory>(
32+
"NoisySiBarrelVertexRawHits", // 1. The name of the plugin instance
33+
{"SiBarrelVertexRawHits"}, // 2. The input collection tag
34+
{"NoisySiBarrelVertexRawHits"}, // 3. The output collection tag
35+
{.addNoise = false,
36+
.n_noise_hits_per_system = 433,
37+
.readout_name = "VertexBarrelHits"}, // 4. Use default config from your .yaml file
38+
app));
39+
3840
// Convert raw digitized hits into hits with geometry info (ready for tracking)
3941
app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
4042
"SiBarrelVertexRecHits", {"NoisySiBarrelVertexRawHits"}, {"SiBarrelVertexRecHits"},

src/detectors/ECTRK/ECTRK.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ void InitPlugin(JApplication* app) {
2929
},
3030
app));
3131

32-
app->Add(new JOmniFactoryGeneratorT<RandomNoise_factory>(
33-
"NoisySiEndcapTrackerRawHits", // 1. The name of the plugin instance
34-
{"SiEndcapTrackerRawHits"}, // 2. The input collection tag
35-
{"NoisySiEndcapTrackerRawHits"}, // 3. The output collection tag
36-
{.addNoise = false, .n_noise_hits_per_system = 11820, .readout_name = "TrackerEndcapHits"}, // 4. Use default config from your .yaml file
37-
app));
32+
app->Add(new JOmniFactoryGeneratorT<RandomNoise_factory>(
33+
"NoisySiEndcapTrackerRawHits", // 1. The name of the plugin instance
34+
{"SiEndcapTrackerRawHits"}, // 2. The input collection tag
35+
{"NoisySiEndcapTrackerRawHits"}, // 3. The output collection tag
36+
{.addNoise = false,
37+
.n_noise_hits_per_system = 11820,
38+
.readout_name = "TrackerEndcapHits"}, // 4. Use default config from your .yaml file
39+
app));
3840
// Convert raw digitized hits into hits with geometry info (ready for tracking)
3941
app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
4042
"SiEndcapTrackerRecHits", {"NoisySiEndcapTrackerRawHits"}, {"SiEndcapTrackerRecHits"},

0 commit comments

Comments
 (0)