Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-27 09:45:35

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