Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-29 08:24:33

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