Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-08 07:51:24

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 - 2025 Sylvester Joosten, Chao, Chao Peng, Whitney Armstrong, David Lawrence, Friederike Bock, Nathan Brei, Wouter Deconinck, Dmitry Kalinkin, Derek Anderson
0003 
0004 #include <Evaluator/DD4hepUnits.h>
0005 #include <JANA/JApplicationFwd.h>
0006 #include <edm4eic/EDM4eicVersion.h>
0007 #include <JANA/Utils/JTypeInfo.h>
0008 #include <string>
0009 #include <variant>
0010 #include <vector>
0011 
0012 #include "algorithms/calorimetry/CalorimeterHitDigiConfig.h"
0013 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0014 #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h"
0015 #include "factories/calorimetry/CalorimeterClusterShape_factory.h"
0016 #include "factories/calorimetry/CalorimeterHitDigi_factory.h"
0017 #include "factories/calorimetry/CalorimeterHitReco_factory.h"
0018 #include "factories/calorimetry/CalorimeterHitsMerger_factory.h"
0019 #include "factories/calorimetry/CalorimeterIslandCluster_factory.h"
0020 #include "factories/calorimetry/CalorimeterTruthClustering_factory.h"
0021 #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h"
0022 
0023 extern "C" {
0024 void InitPlugin(JApplication* app) {
0025 
0026   using namespace eicrecon;
0027 
0028   InitJANAPlugin(app);
0029   // Make sure digi and reco use the same value
0030   decltype(CalorimeterHitDigiConfig::capADC) HcalEndcapN_capADC =
0031       32768; // assuming 15 bit ADC like FHCal
0032   decltype(CalorimeterHitDigiConfig::dyRangeADC) HcalEndcapN_dyRangeADC =
0033       200 * dd4hep::MeV; // to be verified with simulations
0034   decltype(CalorimeterHitDigiConfig::pedMeanADC) HcalEndcapN_pedMeanADC   = 10;
0035   decltype(CalorimeterHitDigiConfig::pedSigmaADC) HcalEndcapN_pedSigmaADC = 2;
0036   decltype(CalorimeterHitDigiConfig::resolutionTDC) HcalEndcapN_resolutionTDC =
0037       10 * dd4hep::picosecond;
0038 
0039   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0040       "HcalEndcapNRawHits", {"EventHeader", "HcalEndcapNHits"},
0041       {"HcalEndcapNRawHits",
0042 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0043        "HcalEndcapNRawHitLinks",
0044 #endif
0045        "HcalEndcapNRawHitAssociations"},
0046       {
0047           .eRes{},
0048           .tRes          = 0.0 * dd4hep::ns,
0049           .capADC        = HcalEndcapN_capADC,
0050           .capTime       = 100, // given in ns, 4 samples in HGCROC
0051           .dyRangeADC    = HcalEndcapN_dyRangeADC,
0052           .pedMeanADC    = HcalEndcapN_pedMeanADC,
0053           .pedSigmaADC   = HcalEndcapN_pedSigmaADC,
0054           .resolutionTDC = HcalEndcapN_resolutionTDC,
0055           .corrMeanScale = "1.0",
0056           .readout       = "HcalEndcapNHits",
0057       },
0058       app // TODO: Remove me once fixed
0059       ));
0060   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
0061       "HcalEndcapNRecHits", {"HcalEndcapNRawHits"}, {"HcalEndcapNRecHits"},
0062       {
0063           .capADC          = HcalEndcapN_capADC,
0064           .dyRangeADC      = HcalEndcapN_dyRangeADC,
0065           .pedMeanADC      = HcalEndcapN_pedMeanADC,
0066           .pedSigmaADC     = HcalEndcapN_pedSigmaADC,
0067           .resolutionTDC   = HcalEndcapN_resolutionTDC,
0068           .thresholdFactor = 0.0,
0069           .thresholdValue =
0070               41.0, // 0.1875 MeV deposition out of 200 MeV max (per layer) --> adc = 10 + 0.1875 / 200 * 32768 == 41
0071           .sampFrac =
0072               "0.0095", // from latest study - implement at level of reco hits rather than clusters
0073           .readout = "HcalEndcapNHits",
0074       },
0075       app // TODO: Remove me once fixed
0076       ));
0077   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitsMerger_factory>(
0078       "HcalEndcapNMergedHits", {"HcalEndcapNRecHits"}, {"HcalEndcapNMergedHits"},
0079       {.readout = "HcalEndcapNHits", .fieldTransformations = {"layer:4", "slice:0"}},
0080       app // TODO: Remove me once fixed
0081       ));
0082   app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0083       "HcalEndcapNTruthProtoClusters", {"HcalEndcapNMergedHits", "HcalEndcapNHits"},
0084       {"HcalEndcapNTruthProtoClusters"},
0085       app // TODO: Remove me once fixed
0086       ));
0087   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0088       "HcalEndcapNIslandProtoClusters", {"HcalEndcapNMergedHits"},
0089       {"HcalEndcapNIslandProtoClusters"},
0090       {
0091           .adjacencyMatrix{},
0092           .peakNeighbourhoodMatrix{},
0093           .readout{},
0094           .sectorDist  = 5.0 * dd4hep::cm,
0095           .localDistXY = {15 * dd4hep::cm, 15 * dd4hep::cm},
0096           .localDistXZ{},
0097           .localDistYZ{},
0098           .globalDistRPhi{},
0099           .globalDistEtaPhi{},
0100           .dimScaledLocalDistXY{},
0101           .splitCluster                  = true,
0102           .minClusterHitEdep             = 0.0 * dd4hep::MeV,
0103           .minClusterCenterEdep          = 30.0 * dd4hep::MeV,
0104           .transverseEnergyProfileMetric = "globalDistEtaPhi",
0105           .transverseEnergyProfileScale  = 1.,
0106           .transverseEnergyProfileScaleUnits{},
0107       },
0108       app // TODO: Remove me once fixed
0109       ));
0110   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0111       "HcalEndcapNTruthClustersWithoutShapes",
0112       {
0113           "HcalEndcapNTruthProtoClusters", // edm4eic::ProtoClusterCollection
0114 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0115           "HcalEndcapNRawHitLinks", // edm4eic::MCRecoCalorimeterHitLink
0116 #endif
0117           "HcalEndcapNRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0118       },
0119       {"HcalEndcapNTruthClustersWithoutShapes",
0120 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0121        "HcalEndcapNTruthClusterLinksWithoutShapes",
0122 #endif
0123        "HcalEndcapNTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0124       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
0125       app // TODO: Remove me once fixed
0126       ));
0127   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0128       "HcalEndcapNTruthClusters",
0129       {"HcalEndcapNTruthClustersWithoutShapes", "HcalEndcapNTruthClusterAssociationsWithoutShapes"},
0130       {"HcalEndcapNTruthClusters",
0131 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0132        "HcalEndcapNTruthClusterLinks",
0133 #endif
0134        "HcalEndcapNTruthClusterAssociations"},
0135       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0136   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0137       "HcalEndcapNClustersWithoutShapes",
0138       {
0139           "HcalEndcapNIslandProtoClusters", // edm4eic::ProtoClusterCollection
0140 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0141           "HcalEndcapNRawHitLinks", // edm4eic::MCRecoCalorimeterHitLink
0142 #endif
0143           "HcalEndcapNRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0144       },
0145       {"HcalEndcapNClustersWithoutShapes",
0146 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0147        "HcalEndcapNClusterLinksWithoutShapes",
0148 #endif
0149        "HcalEndcapNClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0150       {
0151           .energyWeight    = "log",
0152           .sampFrac        = 1.0,
0153           .logWeightBase   = 6.2,
0154           .enableEtaBounds = false,
0155       },
0156       app // TODO: Remove me once fixed
0157       ));
0158   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0159       "HcalEndcapNClusters",
0160       {"HcalEndcapNClustersWithoutShapes", "HcalEndcapNClusterAssociationsWithoutShapes"},
0161       {"HcalEndcapNClusters",
0162 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0163        "HcalEndcapNClusterLinks",
0164 #endif
0165        "HcalEndcapNClusterAssociations"},
0166       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0167   app->Add(new JOmniFactoryGeneratorT<TrackClusterMergeSplitter_factory>(
0168       "HcalEndcapNSplitMergeProtoClusters",
0169       {"HcalEndcapNIslandProtoClusters", "CalorimeterTrackProjections"},
0170       {"HcalEndcapNSplitMergeProtoClusters"},
0171       {.idCalo                       = "HcalEndcapN_ID",
0172        .minSigCut                    = -2.0,
0173        .avgEP                        = 0.60,
0174        .sigEP                        = 0.40,
0175        .drAdd                        = 0.40,
0176        .sampFrac                     = 1.0,
0177        .transverseEnergyProfileScale = 1.0},
0178       app // TODO: remove me once fixed
0179       ));
0180   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0181       "HcalEndcapNSplitMergeClustersWithoutShapes",
0182       {
0183           "HcalEndcapNSplitMergeProtoClusters", // edm4eic::ProtoClusterCollection
0184 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0185           "HcalEndcapNRawHitLinks", // edm4eic::MCRecoCalorimeterHitLink
0186 #endif
0187           "HcalEndcapNRawHitAssociations" // edm4hep::MCRecoCalorimeterHitAssociationCollection
0188       },
0189       {"HcalEndcapNSplitMergeClustersWithoutShapes",
0190 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0191        "HcalEndcapNSplitMergeClusterLinksWithoutShapes",
0192 #endif
0193        "HcalEndcapNSplitMergeClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0194       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
0195       app // TODO: Remove me once fixed
0196       ));
0197   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0198       "HcalEndcapNSplitMergeClusters",
0199       {"HcalEndcapNSplitMergeClustersWithoutShapes",
0200        "HcalEndcapNSplitMergeClusterAssociationsWithoutShapes"},
0201       {"HcalEndcapNSplitMergeClusters",
0202 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0203        "HcalEndcapNSplitMergeClusterLinks",
0204 #endif
0205        "HcalEndcapNSplitMergeClusterAssociations"},
0206       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0207 }
0208 }