Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-09 07:53:28

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