Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:17:52

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", "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", "HcalBarrelHits"},
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           "HcalBarrelRawHitAssociations"   // edm4eic::MCRecoCalorimeterHitAssociationCollection
0130       },
0131       {"HcalBarrelClustersWithoutShapes",             // edm4eic::Cluster
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", "HcalBarrelClusterAssociationsWithoutShapes"},
0140       {"HcalBarrelClusters", "HcalBarrelClusterAssociations"},
0141       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0142 
0143   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0144       "HcalBarrelTruthClustersWithoutShapes",
0145       {
0146           "HcalBarrelTruthProtoClusters", // edm4eic::ProtoClusterCollection
0147           "HcalBarrelRawHitAssociations"  // edm4eic::MCRecoCalorimeterHitAssociationCollection
0148       },
0149       {"HcalBarrelTruthClustersWithoutShapes",             // edm4eic::Cluster
0150        "HcalBarrelTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0151       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
0152       app // TODO: Remove me once fixed
0153       ));
0154 
0155   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0156       "HcalBarrelTruthClusters",
0157       {"HcalBarrelTruthClustersWithoutShapes", "HcalBarrelTruthClusterAssociationsWithoutShapes"},
0158       {"HcalBarrelTruthClusters", "HcalBarrelTruthClusterAssociations"},
0159       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0160 
0161   app->Add(new JOmniFactoryGeneratorT<TrackClusterMergeSplitter_factory>(
0162       "HcalBarrelSplitMergeProtoClusters",
0163       {"HcalBarrelIslandProtoClusters", "CalorimeterTrackProjections"},
0164       {"HcalBarrelSplitMergeProtoClusters"},
0165       {.idCalo                       = "HcalBarrel_ID",
0166        .minSigCut                    = -2.0,
0167        .avgEP                        = 0.50,
0168        .sigEP                        = 0.25,
0169        .drAdd                        = 0.40,
0170        .sampFrac                     = 1.0,
0171        .transverseEnergyProfileScale = 1.0},
0172       app // TODO: remove me once fixed
0173       ));
0174 
0175   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0176       "HcalBarrelSplitMergeClustersWithoutShapes",
0177       {
0178           "HcalBarrelSplitMergeProtoClusters", // edm4eic::ProtoClusterCollection
0179           "HcalBarrelRawHitAssociations"       // edm4eic::MCRecoCalorimeterHitAssociationCollection
0180       },
0181       {"HcalBarrelSplitMergeClustersWithoutShapes",             // edm4eic::Cluster
0182        "HcalBarrelSplitMergeClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0183       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = false},
0184       app // TODO: Remove me once fixed
0185       ));
0186 
0187   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0188       "HcalBarrelSplitMergeClusters",
0189       {"HcalBarrelSplitMergeClustersWithoutShapes",
0190        "HcalBarrelSplitMergeClusterAssociationsWithoutShapes"},
0191       {"HcalBarrelSplitMergeClusters", "HcalBarrelSplitMergeClusterAssociations"}, {}, app));
0192 }
0193 }