Skip to content

Commit 7205da0

Browse files
Merge branch 'main' into feat-calo-no-merge-radiative-etc
2 parents c1133e1 + be68024 commit 7205da0

File tree

5 files changed

+139
-39
lines changed

5 files changed

+139
-39
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repos:
1010
hooks:
1111
- id: codespell
1212
- repo: https://github.com/pre-commit/mirrors-clang-format
13-
rev: v21.1.2
13+
rev: v21.1.5
1414
hooks:
1515
- id: clang-format
1616
- repo: https://github.com/Lucas-C/pre-commit-hooks

src/detectors/FEMC/FEMC.cc

Lines changed: 90 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
// SPDX-License-Identifier: LGPL-3.0-or-later
2-
// Copyright (C) 2021 - 2025, Chao Peng, Sylvester Joosten, Whitney Armstrong, David Lawrence, Friederike Bock, Wouter Deconinck, Kolja Kauder, Sebouh Paul
2+
// Copyright (C) 2021 - 2025, Chao Peng, Sylvester Joosten, Whitney Armstrong, David Lawrence, Friederike Bock, Wouter Deconinck, Kolja Kauder, Sebouh Paul, Akio Ogawa
33

4+
#include <DD4hep/Detector.h>
45
#include <Evaluator/DD4hepUnits.h>
6+
#include <JANA/JApplication.h>
57
#include <JANA/JApplicationFwd.h>
68
#include <JANA/Utils/JTypeInfo.h>
9+
#include <fmt/core.h>
10+
#include <spdlog/logger.h>
711
#include <cmath>
12+
#include <gsl/pointers>
13+
#include <memory>
814
#include <string>
915
#include <variant>
1016
#include <vector>
@@ -18,41 +24,100 @@
1824
#include "factories/calorimetry/CalorimeterIslandCluster_factory.h"
1925
#include "factories/calorimetry/CalorimeterTruthClustering_factory.h"
2026
#include "factories/calorimetry/TrackClusterMergeSplitter_factory.h"
27+
#include "services/geometry/dd4hep/DD4hep_service.h"
28+
#include "services/log/Log_service.h"
2129

2230
extern "C" {
2331
void InitPlugin(JApplication* app) {
2432

2533
using namespace eicrecon;
2634

2735
InitJANAPlugin(app);
36+
37+
auto log_service = app->GetService<Log_service>();
38+
auto mLog = log_service->logger("FEMC");
39+
2840
// Make sure digi and reco use the same value
2941
decltype(CalorimeterHitDigiConfig::capADC) EcalEndcapP_capADC =
3042
16384; //16384, assuming 14 bits. For approximate HGCROC resolution use 65536
31-
decltype(CalorimeterHitDigiConfig::dyRangeADC) EcalEndcapP_dyRangeADC = 3 * dd4hep::GeV;
43+
decltype(CalorimeterHitDigiConfig::dyRangeADC) EcalEndcapP_dyRangeADC = 100 * dd4hep::GeV;
3244
decltype(CalorimeterHitDigiConfig::pedMeanADC) EcalEndcapP_pedMeanADC = 200;
3345
decltype(CalorimeterHitDigiConfig::pedSigmaADC) EcalEndcapP_pedSigmaADC = 2.4576;
3446
decltype(CalorimeterHitDigiConfig::resolutionTDC) EcalEndcapP_resolutionTDC =
3547
10 * dd4hep::picosecond;
36-
app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
37-
"EcalEndcapPRawHits", {"EventHeader", "EcalEndcapPHits"},
38-
{"EcalEndcapPRawHits", "EcalEndcapPRawHitAssociations"},
39-
{
40-
.eRes = {0.11333 * sqrt(dd4hep::GeV), 0.03,
41-
0.0 * dd4hep::GeV}, // (11.333% / sqrt(E)) \oplus 3%
42-
.tRes = 0.0,
43-
.threshold = 0.0,
44-
// .threshold = 15 * dd4hep::MeV for a single tower, applied on ADC level
45-
.capADC = EcalEndcapP_capADC,
46-
.capTime = 100, // given in ns, 4 samples in HGCROC
47-
.dyRangeADC = EcalEndcapP_dyRangeADC,
48-
.pedMeanADC = EcalEndcapP_pedMeanADC,
49-
.pedSigmaADC = EcalEndcapP_pedSigmaADC,
50-
.resolutionTDC = EcalEndcapP_resolutionTDC,
51-
.corrMeanScale = "0.03",
52-
.readout = "EcalEndcapPHits",
53-
},
54-
app // TODO: Remove me once fixed
55-
));
48+
const double EcalEndcapP_sampFrac = 0.029043; // updated with ratio to ScFi model
49+
decltype(CalorimeterHitDigiConfig::corrMeanScale) EcalEndcapP_corrMeanScale =
50+
fmt::format("{}", 1.0 / EcalEndcapP_sampFrac);
51+
const double EcalEndcapP_nPhotonPerGeV = 1500;
52+
const double EcalEndcapP_PhotonCollectionEff = 0.285;
53+
const unsigned long long EcalEndcapP_totalPixel = 4 * 159565ULL;
54+
55+
int EcalEndcapP_homogeneousFlag = 0;
56+
try {
57+
auto detector = app->GetService<DD4hep_service>()->detector();
58+
EcalEndcapP_homogeneousFlag = detector->constant<int>("EcalEndcapP_Homogeneous_ScFi");
59+
if (EcalEndcapP_homogeneousFlag <= 1) {
60+
mLog->info("Homogeneous geometry loaded");
61+
} else {
62+
mLog->info("ScFi geometry loaded");
63+
}
64+
} catch (...) {
65+
// Variable not present apply legacy homogeneous geometry implementation
66+
EcalEndcapP_homogeneousFlag = 0;
67+
};
68+
69+
if (EcalEndcapP_homogeneousFlag <= 1) {
70+
app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
71+
"EcalEndcapPRawHits", {"EventHeader", "EcalEndcapPHits"},
72+
{"EcalEndcapPRawHits", "EcalEndcapPRawHitAssociations"},
73+
{
74+
.eRes = {0.11333 * sqrt(dd4hep::GeV), 0.03,
75+
0.0 * dd4hep::GeV}, // (11.333% / sqrt(E)) \oplus 3%
76+
.tRes = 0.0,
77+
.threshold =
78+
0.0, // 15MeV threshold for a single tower will be applied on ADC at Reco below
79+
.readoutType = "sipm",
80+
.lightYield = EcalEndcapP_nPhotonPerGeV / EcalEndcapP_PhotonCollectionEff,
81+
.photonDetectionEfficiency = EcalEndcapP_PhotonCollectionEff,
82+
.numEffectiveSipmPixels = EcalEndcapP_totalPixel,
83+
.capADC = EcalEndcapP_capADC,
84+
.capTime = 100, // given in ns, 4 samples in HGCROC
85+
.dyRangeADC = EcalEndcapP_dyRangeADC,
86+
.pedMeanADC = EcalEndcapP_pedMeanADC,
87+
.pedSigmaADC = EcalEndcapP_pedSigmaADC,
88+
.resolutionTDC = EcalEndcapP_resolutionTDC,
89+
.corrMeanScale = "1.0",
90+
.readout = "EcalEndcapPHits",
91+
},
92+
app // TODO: Remove me once fixed
93+
));
94+
} else if (EcalEndcapP_homogeneousFlag == 2) {
95+
app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
96+
"EcalEndcapPRawHits", {"EventHeader", "EcalEndcapPHits"},
97+
{"EcalEndcapPRawHits", "EcalEndcapPRawHitAssociations"},
98+
{
99+
.eRes = {0.0, 0.022, 0.0}, // just constant term 2.2% based on MC data comparison
100+
.tRes = 0.0,
101+
.threshold =
102+
0.0, // 15MeV threshold for a single tower will be applied on ADC at Reco below
103+
.readoutType = "sipm",
104+
.lightYield = EcalEndcapP_nPhotonPerGeV / EcalEndcapP_PhotonCollectionEff,
105+
.photonDetectionEfficiency = EcalEndcapP_PhotonCollectionEff,
106+
.numEffectiveSipmPixels = EcalEndcapP_totalPixel,
107+
.capADC = EcalEndcapP_capADC,
108+
.capTime = 100, // given in ns, 4 samples in HGCROC
109+
.dyRangeADC = EcalEndcapP_dyRangeADC,
110+
.pedMeanADC = EcalEndcapP_pedMeanADC,
111+
.pedSigmaADC = EcalEndcapP_pedSigmaADC,
112+
.resolutionTDC = EcalEndcapP_resolutionTDC,
113+
.corrMeanScale = EcalEndcapP_corrMeanScale,
114+
.readout = "EcalEndcapPHits",
115+
.fields = {"fiber_x", "fiber_y"},
116+
},
117+
app // TODO: Remove me once fixed
118+
));
119+
}
120+
56121
app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
57122
"EcalEndcapPRecHits", {"EcalEndcapPRawHits"}, {"EcalEndcapPRecHits"},
58123
{
@@ -63,8 +128,9 @@ void InitPlugin(JApplication* app) {
63128
.resolutionTDC = EcalEndcapP_resolutionTDC,
64129
.thresholdFactor = 0.0,
65130
.thresholdValue =
66-
2, // The ADC of a 15 MeV particle is adc = 200 + 15 * 0.03 * ( 1.0 + 0) / 3000 * 16384 = 200 + 2.4576
67-
.sampFrac = "0.03",
131+
3, // The ADC of a 15 MeV particle is adc = 200 + 15 * 0.03 * ( 1.0 + 0) / 3000 * 16384 = 200 + 2.4576
132+
// 15 MeV = 2.4576, but adc=llround(dE) and cut off is "<". So 3 here = 15.25MeV
133+
.sampFrac = "1.00", // already taken care in DIGI code above
68134
.readout = "EcalEndcapPHits",
69135
},
70136
app // TODO: Remove me once fixed

src/global/reco/reco.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,12 @@ void InitPlugin(JApplication* app) {
194194

195195
// Backward
196196
app->Add(new JOmniFactoryGeneratorT<TrackClusterMatch_factory>(
197-
"EcalEndcapNBarrelTrackClusterMatches",
198-
{"CalorimeterTrackProjections", "EcalEndcapNClusters"}, {"EcalEndcapNTrackClusterMatches"},
199-
{.calo_id = "EcalEndcapN_ID"}, app));
197+
"EcalEndcapNTrackClusterMatches", {"CalorimeterTrackProjections", "EcalEndcapNClusters"},
198+
{"EcalEndcapNTrackClusterMatches"}, {.calo_id = "EcalEndcapN_ID"}, app));
200199

201200
app->Add(new JOmniFactoryGeneratorT<TrackClusterMatch_factory>(
202-
"HcalEndcapNBarrelTrackClusterMatches",
203-
{"CalorimeterTrackProjections", "HcalEndcapNClusters"}, {"HcalEndcapNTrackClusterMatches"},
204-
{.calo_id = "HcalEndcapN_ID"}, app));
201+
"HcalEndcapNTrackClusterMatches", {"CalorimeterTrackProjections", "HcalEndcapNClusters"},
202+
{"HcalEndcapNTrackClusterMatches"}, {.calo_id = "HcalEndcapN_ID"}, app));
205203

206204
app->Add(new JOmniFactoryGeneratorT<TransformBreitFrame_factory>(
207205
"ReconstructedBreitFrameParticles",

src/tests/algorithms_test/calorimetry_CalorimeterClusterRecoCoG.cc

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,18 @@ TEST_CASE("the calorimeter CoG algorithm runs", "[CalorimeterClusterRecoCoG]") {
8989
0., // double mass
9090
edm4hep::Vector3d(), // edm4hep::Vector3d vertex
9191
edm4hep::Vector3d(), // edm4hep::Vector3d endpoint
92+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 1)
9293
edm4hep::Vector3f(), // edm4hep::Vector3f momentum
9394
edm4hep::Vector3f(), // edm4hep::Vector3f momentumAtEndpoint
94-
edm4hep::Vector3f() // edm4hep::Vector3f spin
95+
#else
96+
edm4hep::Vector3d(), // edm4hep::Vector3d momentum
97+
edm4hep::Vector3d(), // edm4hep::Vector3d momentumAtEndpoint
98+
#endif
99+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 3)
100+
edm4hep::Vector3f() // edm4hep::Vector3f spin
101+
#else
102+
9 // int32_t helicity (9 if unset)
103+
#endif
95104
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 2)
96105
,
97106
edm4hep::Vector2i() // edm4hep::Vector2i colorFlow
@@ -107,9 +116,18 @@ TEST_CASE("the calorimeter CoG algorithm runs", "[CalorimeterClusterRecoCoG]") {
107116
0., // double mass
108117
edm4hep::Vector3d(), // edm4hep::Vector3d vertex
109118
edm4hep::Vector3d(), // edm4hep::Vector3d endpoint
110-
edm4hep::Vector3f(), // edm4hep::Vector3f momentum
111-
edm4hep::Vector3f(), // edm4hep::Vector3f momentumAtEndpoint
112-
edm4hep::Vector3f() // edm4hep::Vector3f spin
119+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 1)
120+
edm4hep::Vector3f(), // edm4hep::Vector3f momentum
121+
edm4hep::Vector3f(), // edm4hep::Vector3f momentumAtEndpoint
122+
#else
123+
edm4hep::Vector3d(), // edm4hep::Vector3d momentum
124+
edm4hep::Vector3d(), // edm4hep::Vector3d momentumAtEndpoint
125+
#endif
126+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 3)
127+
edm4hep::Vector3f() // edm4hep::Vector3f spin
128+
#else
129+
9 // int32_t helicity (9 if unset)
130+
#endif
113131
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 2)
114132
,
115133
edm4hep::Vector2i() // edm4hep::Vector2i colorFlow
@@ -168,9 +186,18 @@ TEST_CASE("the calorimeter CoG algorithm runs", "[CalorimeterClusterRecoCoG]") {
168186
0., // double mass
169187
edm4hep::Vector3d(), // edm4hep::Vector3d vertex
170188
edm4hep::Vector3d(), // edm4hep::Vector3d endpoint
171-
edm4hep::Vector3f(), // edm4hep::Vector3f momentum
172-
edm4hep::Vector3f(), // edm4hep::Vector3f momentumAtEndpoint
173-
edm4hep::Vector3f() // edm4hep::Vector3f spin
189+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 1)
190+
edm4hep::Vector3f(), // edm4hep::Vector3f momentum
191+
edm4hep::Vector3f(), // edm4hep::Vector3f momentumAtEndpoint
192+
#else
193+
edm4hep::Vector3d(), // edm4hep::Vector3d momentum
194+
edm4hep::Vector3d(), // edm4hep::Vector3d momentumAtEndpoint
195+
#endif
196+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 3)
197+
edm4hep::Vector3f() // edm4hep::Vector3f spin
198+
#else
199+
9 // int32_t helicity (9 if unset)
200+
#endif
174201
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 2)
175202
,
176203
edm4hep::Vector2i() // edm4hep::Vector2i colorFlow

src/tests/algorithms_test/pid_lut_PIDLookup.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,18 @@ TEST_CASE("particles acquire PID", "[PIDLookup]") {
7373
0., // double mass
7474
edm4hep::Vector3d(), // edm4hep::Vector3d vertex
7575
edm4hep::Vector3d(), // edm4hep::Vector3d endpoint
76+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 1)
7677
edm4hep::Vector3f(), // edm4hep::Vector3f momentum
7778
edm4hep::Vector3f(), // edm4hep::Vector3f momentumAtEndpoint
78-
edm4hep::Vector3f() // edm4hep::Vector3f spin
79+
#else
80+
edm4hep::Vector3d(), // edm4hep::Vector3d momentum
81+
edm4hep::Vector3d(), // edm4hep::Vector3d momentumAtEndpoint
82+
#endif
83+
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 3)
84+
edm4hep::Vector3f() // edm4hep::Vector3f spin
85+
#else
86+
9 // int32_t helicity (9 if unset)
87+
#endif
7988
#if EDM4HEP_BUILD_VERSION < EDM4HEP_VERSION(0, 99, 2)
8089
,
8190
edm4hep::Vector2i() // edm4hep::Vector2i colorFlow

0 commit comments

Comments
 (0)