Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-27 07:03:04

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 - 2024 David Lawrence, Derek Anderson, Wouter Deconinck
0003 
0004 #include <edm4eic/EDM4eicVersion.h>
0005 #include <Evaluator/DD4hepUnits.h>
0006 #include <JANA/JApplication.h>
0007 #include <memory>
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/CalorimeterHitDigi_factory.h"
0014 #include "factories/calorimetry/CalorimeterHitReco_factory.h"
0015 #include "factories/calorimetry/CalorimeterIslandCluster_factory.h"
0016 #include "factories/calorimetry/CalorimeterTruthClustering_factory.h"
0017 #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h"
0018 
0019 extern "C" {
0020 
0021     void InitPlugin(JApplication *app) {
0022 
0023         using namespace eicrecon;
0024 
0025         InitJANAPlugin(app);
0026 
0027         // Make sure digi and reco use the same value
0028         decltype(CalorimeterHitDigiConfig::capADC)        HcalBarrel_capADC = 65536; //65536,  16bit ADC
0029         decltype(CalorimeterHitDigiConfig::dyRangeADC)    HcalBarrel_dyRangeADC = 1.0 * dd4hep::GeV;
0030         decltype(CalorimeterHitDigiConfig::pedMeanADC)    HcalBarrel_pedMeanADC = 300;
0031         decltype(CalorimeterHitDigiConfig::pedSigmaADC)   HcalBarrel_pedSigmaADC = 2;
0032         decltype(CalorimeterHitDigiConfig::resolutionTDC) HcalBarrel_resolutionTDC = 1 * dd4hep::picosecond;
0033 
0034         // Set default adjacency matrix. Magic constants:
0035         //  320 - number of tiles per row
0036         decltype(CalorimeterIslandClusterConfig::adjacencyMatrix) HcalBarrel_adjacencyMatrix =
0037           "("
0038           // check for vertically adjacent tiles
0039           "  ( (abs(eta_1 - eta_2) == 1) && (abs(phi_1 - phi_2) == 0) ) ||"
0040           // check for horizontally adjacent tiles
0041           "  ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == 1) ) ||"
0042           // check for horizontally adjacent tiles at wraparound
0043           "  ( (abs(eta_1 - eta_2) == 0) && (abs(phi_1 - phi_2) == (320 - 1)) )"
0044           ") == 1";
0045 
0046         app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0047           "HcalBarrelRawHits",
0048           {"HcalBarrelHits"},
0049 #if EDM4EIC_VERSION_MAJOR >= 7
0050           {"HcalBarrelRawHits", "HcalBarrelRawHitAssociations"},
0051 #else
0052           {"HcalBarrelRawHits"},
0053 #endif
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         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         app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0087           "HcalBarrelTruthProtoClusters", {"HcalBarrelRecHits", "HcalBarrelHits"}, {"HcalBarrelTruthProtoClusters"},
0088           app   // TODO: Remove me once fixed
0089         ));
0090         app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0091           "HcalBarrelIslandProtoClusters", {"HcalBarrelRecHits"}, {"HcalBarrelIslandProtoClusters"},
0092           {
0093             .adjacencyMatrix = HcalBarrel_adjacencyMatrix,
0094             .readout = "HcalBarrelHits",
0095             .sectorDist = 5.0 * dd4hep::cm,
0096             .splitCluster = false,
0097             .minClusterHitEdep = 5.0 * dd4hep::MeV,
0098             .minClusterCenterEdep = 30.0 * dd4hep::MeV,
0099             .transverseEnergyProfileMetric = "globalDistEtaPhi",
0100             .transverseEnergyProfileScale = 1.,
0101           },
0102           app   // TODO: Remove me once fixed
0103         ));
0104 
0105         app->Add(
0106           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0107              "HcalBarrelClusters",
0108             {"HcalBarrelIslandProtoClusters",  // edm4eic::ProtoClusterCollection
0109 #if EDM4EIC_VERSION_MAJOR >= 7
0110              "HcalBarrelRawHitAssociations"},  // edm4eic::MCRecoCalorimeterHitAssociationCollection
0111 #else
0112              "HcalBarrelHits"},                // edm4hep::SimCalorimeterHitCollection
0113 #endif
0114             {"HcalBarrelClusters",             // edm4eic::Cluster
0115              "HcalBarrelClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0116             {
0117               .energyWeight = "log",
0118               .sampFrac = 1.0,
0119               .logWeightBase = 6.2,
0120               .enableEtaBounds = false
0121             },
0122             app   // TODO: Remove me once fixed
0123           )
0124         );
0125 
0126         app->Add(
0127           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0128              "HcalBarrelTruthClusters",
0129             {"HcalBarrelTruthProtoClusters",        // edm4eic::ProtoClusterCollection
0130 #if EDM4EIC_VERSION_MAJOR >= 7
0131              "HcalBarrelRawHitAssociations"},       // edm4eic::MCRecoCalorimeterHitAssociationCollection
0132 #else
0133              "HcalBarrelHits"},                     // edm4hep::SimCalorimeterHitCollection
0134 #endif
0135             {"HcalBarrelTruthClusters",             // edm4eic::Cluster
0136              "HcalBarrelTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0137             {
0138               .energyWeight = "log",
0139               .sampFrac = 1.0,
0140               .logWeightBase = 6.2,
0141               .enableEtaBounds = false
0142             },
0143             app   // TODO: Remove me once fixed
0144           )
0145         );
0146 
0147         app->Add(
0148           new JOmniFactoryGeneratorT<TrackClusterMergeSplitter_factory>(
0149             "HcalBarrelSplitMergeProtoClusters",
0150             {"HcalBarrelIslandProtoClusters",
0151              "CalorimeterTrackProjections"},
0152             {"HcalBarrelSplitMergeProtoClusters"},
0153             {
0154               .idCalo = "HcalBarrel_ID",
0155               .minSigCut = -2.0,
0156               .avgEP = 0.50,
0157               .sigEP = 0.25,
0158               .drAdd = 0.40,
0159               .sampFrac = 1.0,
0160               .transverseEnergyProfileScale = 1.0
0161             },
0162             app   // TODO: remove me once fixed
0163           )
0164         );
0165 
0166         app->Add(
0167           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0168              "HcalBarrelSplitMergeClusters",
0169             {"HcalBarrelSplitMergeProtoClusters",        // edm4eic::ProtoClusterCollection
0170              "HcalBarrelHits"},                          // edm4hep::SimCalorimeterHitCollection
0171             {"HcalBarrelSplitMergeClusters",             // edm4eic::Cluster
0172              "HcalBarrelSplitMergeClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0173             {
0174               .energyWeight = "log",
0175               .sampFrac = 1.0,
0176               .logWeightBase = 6.2,
0177               .enableEtaBounds = false
0178             },
0179             app   // TODO: Remove me once fixed
0180           )
0181         );
0182     }
0183 }