Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-31 07:52:06

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 - 2024 David Lawrence, Derek Anderson, Wouter Deconinck
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 "algorithms/calorimetry/CalorimeterIslandClusterConfig.h"
0014 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0015 #include "factories/calorimetry/CalorimeterClusterRecoCoG_factory.h"
0016 #include "factories/calorimetry/CalorimeterClusterShape_factory.h"
0017 #include "factories/calorimetry/CalorimeterHitDigi_factory.h"
0018 #include "factories/calorimetry/CalorimeterHitReco_factory.h"
0019 #include "factories/calorimetry/CalorimeterHitsMerger_factory.h"
0020 #include "factories/calorimetry/CalorimeterIslandCluster_factory.h"
0021 #include "factories/calorimetry/CalorimeterTruthClustering_factory.h"
0022 #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h"
0023 
0024 extern "C" {
0025 
0026 void InitPlugin(JApplication* app) {
0027 
0028   using namespace eicrecon;
0029 
0030   InitJANAPlugin(app);
0031 
0032   // Make sure digi and reco use the same value
0033   decltype(CalorimeterHitDigiConfig::capADC) HcalBarrel_capADC         = 65536; //65536,  16bit ADC
0034   decltype(CalorimeterHitDigiConfig::dyRangeADC) HcalBarrel_dyRangeADC = 1.0 * dd4hep::GeV;
0035   decltype(CalorimeterHitDigiConfig::pedMeanADC) HcalBarrel_pedMeanADC = 300;
0036   decltype(CalorimeterHitDigiConfig::pedSigmaADC) HcalBarrel_pedSigmaADC = 2;
0037   decltype(CalorimeterHitDigiConfig::resolutionTDC) HcalBarrel_resolutionTDC =
0038       1 * dd4hep::picosecond;
0039 
0040   // Set default adjacency matrix. Magic constants:
0041   //  320 - number of tiles per row
0042   decltype(CalorimeterIslandClusterConfig::adjacencyMatrix) HcalBarrel_adjacencyMatrix =
0043       "("
0044       // check for vertically adjacent tiles
0045       "  ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||"
0046       // check for horizontally adjacent tiles
0047       "  ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == 1) ) ||"
0048       // check for horizontally adjacent tiles at wraparound
0049       "  ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == (320 - 1)) )"
0050       ") == 1";
0051 
0052   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0053       "HcalBarrelRawHits", {"EventHeader", "HcalBarrelHits"},
0054       {"HcalBarrelRawHits",
0055 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0056        "HcalBarrelRawHitLinks",
0057 #endif
0058        "HcalBarrelRawHitAssociations"},
0059       {
0060           .eRes          = {},
0061           .tRes          = 0.0 * dd4hep::ns,
0062           .threshold     = 0.0, // Use ADC cut instead
0063           .capADC        = HcalBarrel_capADC,
0064           .capTime       = 100, // given in ns, 4 samples in HGCROC
0065           .dyRangeADC    = HcalBarrel_dyRangeADC,
0066           .pedMeanADC    = HcalBarrel_pedMeanADC,
0067           .pedSigmaADC   = HcalBarrel_pedSigmaADC,
0068           .resolutionTDC = HcalBarrel_resolutionTDC,
0069           .corrMeanScale = "1.0",
0070           .readout       = "HcalBarrelHits",
0071       },
0072       app // TODO: Remove me once fixed
0073       ));
0074 
0075   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
0076       "HcalBarrelRecHits", {"HcalBarrelRawHits"}, {"HcalBarrelRecHits"},
0077       {
0078           .capADC          = HcalBarrel_capADC,
0079           .dyRangeADC      = HcalBarrel_dyRangeADC,
0080           .pedMeanADC      = HcalBarrel_pedMeanADC,
0081           .pedSigmaADC     = HcalBarrel_pedSigmaADC, // not used; relying on energy cut
0082           .resolutionTDC   = HcalBarrel_resolutionTDC,
0083           .thresholdFactor = 0.0,     // not used; relying on flat ADC cut
0084           .thresholdValue  = 33,      // pedSigmaADC + thresholdValue = half-MIP (333 ADC)
0085           .sampFrac        = "0.033", // average, from sPHENIX simulations
0086           .readout         = "HcalBarrelHits",
0087           .layerField      = "",
0088           .sectorField     = "",
0089       },
0090       app // TODO: Remove me once fixed
0091       ));
0092 
0093   // --------------------------------------------------------------------
0094   // If needed, merge adjacent phi tiles into towers. By default,
0095   // NO merging will be done. This can be changed at runtime.
0096   // --------------------------------------------------------------------
0097   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitsMerger_factory>(
0098       "HcalBarrelMergedHits", {"HcalBarrelRecHits"}, {"HcalBarrelMergedHits"},
0099       {.readout = "HcalBarrelHits", .fieldTransformations = {"phi:phi"}},
0100       app // TODO: Remove me once fixed
0101       ));
0102 
0103   app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0104       "HcalBarrelTruthProtoClusters", {"HcalBarrelRecHits", "HcalBarrelHits"},
0105       {"HcalBarrelTruthProtoClusters"},
0106       app // TODO: Remove me once fixed
0107       ));
0108 
0109   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0110       "HcalBarrelIslandProtoClusters", {"HcalBarrelRecHits"}, {"HcalBarrelIslandProtoClusters"},
0111       {.adjacencyMatrix = HcalBarrel_adjacencyMatrix,
0112        .peakNeighbourhoodMatrix{},
0113        .readout    = "HcalBarrelHits",
0114        .sectorDist = 5.0 * dd4hep::cm,
0115        .localDistXY{},
0116        .localDistXZ{},
0117        .localDistYZ{},
0118        .globalDistRPhi{},
0119        .globalDistEtaPhi{},
0120        .dimScaledLocalDistXY{},
0121        .splitCluster                  = false,
0122        .minClusterHitEdep             = 5.0 * dd4hep::MeV,
0123        .minClusterCenterEdep          = 30.0 * dd4hep::MeV,
0124        .transverseEnergyProfileMetric = "globalDistEtaPhi",
0125        .transverseEnergyProfileScale  = 1.,
0126        .transverseEnergyProfileScaleUnits{}},
0127       app // TODO: Remove me once fixed
0128       ));
0129 
0130   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0131       "HcalBarrelClustersWithoutShapes",
0132       {
0133           "HcalBarrelIslandProtoClusters", // edm4eic::ProtoClusterCollection
0134 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0135           "HcalBarrelRawHitLinks", // edm4eic::MCRecoCalorimeterHitLink
0136 #endif
0137           "HcalBarrelRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0138       },
0139       {"HcalBarrelClustersWithoutShapes",
0140 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0141        "HcalBarrelClusterLinksWithoutShapes",
0142 #endif
0143        "HcalBarrelClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0144       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
0145       app // TODO: Remove me once fixed
0146       ));
0147 
0148   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0149       "HcalBarrelClusters",
0150       {"HcalBarrelClustersWithoutShapes", "HcalBarrelClusterAssociationsWithoutShapes"},
0151       {"HcalBarrelClusters",
0152 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0153        "HcalBarrelClusterLinks",
0154 #endif
0155        "HcalBarrelClusterAssociations"},
0156       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0157 
0158   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0159       "HcalBarrelTruthClustersWithoutShapes",
0160       {
0161           "HcalBarrelTruthProtoClusters", // edm4eic::ProtoClusterCollection
0162 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0163           "HcalBarrelRawHitLinks", // edm4eic::MCRecoCalorimeterHitLink
0164 #endif
0165           "HcalBarrelRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0166       },
0167       {"HcalBarrelTruthClustersWithoutShapes",
0168 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0169        "HcalBarrelTruthClusterLinksWithoutShapes",
0170 #endif
0171        "HcalBarrelTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0172       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
0173       app // TODO: Remove me once fixed
0174       ));
0175 
0176   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0177       "HcalBarrelTruthClusters",
0178       {"HcalBarrelTruthClustersWithoutShapes", "HcalBarrelTruthClusterAssociationsWithoutShapes"},
0179       {"HcalBarrelTruthClusters",
0180 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0181        "HcalBarrelTruthClusterLinks",
0182 #endif
0183        "HcalBarrelTruthClusterAssociations"},
0184       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0185 
0186   app->Add(new JOmniFactoryGeneratorT<TrackClusterMergeSplitter_factory>(
0187       "HcalBarrelSplitMergeProtoClusters",
0188       {"HcalBarrelTrackClusterMatches", "HcalBarrelClustersWithoutShapes",
0189        "CalorimeterTrackProjections"},
0190       {"HcalBarrelSplitMergeProtoClusters",
0191 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0192        "HcalBarrelTrackSplitMergeProtoClusterLinks"
0193 #elif EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 4, 0)
0194        "HcalBarrelTrackSplitMergeProtoClusterMatches"
0195 #endif
0196       },
0197       {.minSigCut                    = -2.0,
0198        .avgEP                        = 0.50,
0199        .sigEP                        = 0.25,
0200        .drAdd                        = 0.40,
0201        .surfaceToUse                 = 1,
0202        .transverseEnergyProfileScale = 1.0},
0203       app // TODO: remove me once fixed
0204       ));
0205 
0206   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0207       "HcalBarrelSplitMergeClustersWithoutShapes",
0208       {
0209           "HcalBarrelSplitMergeProtoClusters", // edm4eic::ProtoClusterCollection
0210 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0211           "HcalBarrelRawHitLinks", // edm4eic::MCRecoCalorimeterHitLink
0212 #endif
0213           "HcalBarrelRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0214       },
0215       {"HcalBarrelSplitMergeClustersWithoutShapes",
0216 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0217        "HcalBarrelSplitMergeClusterLinksWithoutShapes",
0218 #endif
0219        "HcalBarrelSplitMergeClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0220       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
0221       app // TODO: Remove me once fixed
0222       ));
0223 
0224   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0225       "HcalBarrelSplitMergeClusters",
0226       {"HcalBarrelSplitMergeClustersWithoutShapes",
0227        "HcalBarrelSplitMergeClusterAssociationsWithoutShapes"},
0228       {"HcalBarrelSplitMergeClusters",
0229 #if EDM4EIC_BUILD_VERSION >= EDM4EIC_VERSION(8, 7, 0)
0230        "HcalBarrelSplitMergeClusterLinks",
0231 #endif
0232        "HcalBarrelSplitMergeClusterAssociations"},
0233       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0234 }
0235 }