Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:17:05

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2021 - 2025, Chao Peng, Sylvester Joosten, Whitney Armstrong, David Lawrence, Friederike Bock, Wouter Deconinck, Kolja Kauder, Sebouh Paul
0003 
0004 #include <Evaluator/DD4hepUnits.h>
0005 #include <JANA/JApplicationFwd.h>
0006 #include <JANA/Utils/JTypeInfo.h>
0007 #include <cmath>
0008 #include <string>
0009 #include <variant>
0010 #include <vector>
0011 
0012 #include "algorithms/calorimetry/CalorimeterHitDigiConfig.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/CalorimeterIslandCluster_factory.h"
0019 #include "factories/calorimetry/CalorimeterTruthClustering_factory.h"
0020 #include "factories/calorimetry/TrackClusterMergeSplitter_factory.h"
0021 
0022 extern "C" {
0023 void InitPlugin(JApplication* app) {
0024 
0025   using namespace eicrecon;
0026 
0027   InitJANAPlugin(app);
0028   // Make sure digi and reco use the same value
0029   decltype(CalorimeterHitDigiConfig::capADC) EcalEndcapP_capADC =
0030       16384; //16384, assuming 14 bits. For approximate HGCROC resolution use 65536
0031   decltype(CalorimeterHitDigiConfig::dyRangeADC) EcalEndcapP_dyRangeADC   = 3 * dd4hep::GeV;
0032   decltype(CalorimeterHitDigiConfig::pedMeanADC) EcalEndcapP_pedMeanADC   = 200;
0033   decltype(CalorimeterHitDigiConfig::pedSigmaADC) EcalEndcapP_pedSigmaADC = 2.4576;
0034   decltype(CalorimeterHitDigiConfig::resolutionTDC) EcalEndcapP_resolutionTDC =
0035       10 * dd4hep::picosecond;
0036   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0037       "EcalEndcapPRawHits", {"EventHeader", "EcalEndcapPHits"},
0038       {"EcalEndcapPRawHits", "EcalEndcapPRawHitAssociations"},
0039       {
0040           .eRes      = {0.11333 * sqrt(dd4hep::GeV), 0.03,
0041                         0.0 * dd4hep::GeV}, // (11.333% / sqrt(E)) \oplus 3%
0042           .tRes      = 0.0,
0043           .threshold = 0.0,
0044           // .threshold = 15 * dd4hep::MeV for a single tower, applied on ADC level
0045           .capADC        = EcalEndcapP_capADC,
0046           .capTime       = 100, // given in ns, 4 samples in HGCROC
0047           .dyRangeADC    = EcalEndcapP_dyRangeADC,
0048           .pedMeanADC    = EcalEndcapP_pedMeanADC,
0049           .pedSigmaADC   = EcalEndcapP_pedSigmaADC,
0050           .resolutionTDC = EcalEndcapP_resolutionTDC,
0051           .corrMeanScale = "0.03",
0052           .readout       = "EcalEndcapPHits",
0053       },
0054       app // TODO: Remove me once fixed
0055       ));
0056   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
0057       "EcalEndcapPRecHits", {"EcalEndcapPRawHits"}, {"EcalEndcapPRecHits"},
0058       {
0059           .capADC          = EcalEndcapP_capADC,
0060           .dyRangeADC      = EcalEndcapP_dyRangeADC,
0061           .pedMeanADC      = EcalEndcapP_pedMeanADC,
0062           .pedSigmaADC     = EcalEndcapP_pedSigmaADC,
0063           .resolutionTDC   = EcalEndcapP_resolutionTDC,
0064           .thresholdFactor = 0.0,
0065           .thresholdValue =
0066               2, // The ADC of a 15 MeV particle is adc = 200 + 15 * 0.03 * ( 1.0 + 0) / 3000 * 16384 = 200 + 2.4576
0067           .sampFrac = "0.03",
0068           .readout  = "EcalEndcapPHits",
0069       },
0070       app // TODO: Remove me once fixed
0071       ));
0072   app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0073       "EcalEndcapPTruthProtoClusters", {"EcalEndcapPRecHits", "EcalEndcapPHits"},
0074       {"EcalEndcapPTruthProtoClusters"},
0075       app // TODO: Remove me once fixed
0076       ));
0077   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0078       "EcalEndcapPIslandProtoClusters", {"EcalEndcapPRecHits"}, {"EcalEndcapPIslandProtoClusters"},
0079       {.adjacencyMatrix{},
0080        .peakNeighbourhoodMatrix{},
0081        .readout{},
0082        .sectorDist = 5.0 * dd4hep::cm,
0083        .localDistXY{},
0084        .localDistXZ{},
0085        .localDistYZ{},
0086        .globalDistRPhi{},
0087        .globalDistEtaPhi{},
0088        .dimScaledLocalDistXY          = {1.5, 1.5},
0089        .splitCluster                  = false,
0090        .minClusterHitEdep             = 0.0 * dd4hep::MeV,
0091        .minClusterCenterEdep          = 60.0 * dd4hep::MeV,
0092        .transverseEnergyProfileMetric = "dimScaledLocalDistXY",
0093        .transverseEnergyProfileScale  = 1.,
0094        .transverseEnergyProfileScaleUnits{}},
0095       app // TODO: Remove me once fixed
0096       ));
0097 
0098   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0099       "EcalEndcapPTruthClustersWithoutShapes",
0100       {
0101           "EcalEndcapPTruthProtoClusters", // edm4eic::ProtoClusterCollection
0102           "EcalEndcapPRawHitAssociations"  // edm4eic::MCRecoCalorimeterHitAssociationCollection
0103       },
0104       {"EcalEndcapPTruthClustersWithoutShapes",             // edm4eic::Cluster
0105        "EcalEndcapPTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0106       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 6.2, .enableEtaBounds = true},
0107       app // TODO: Remove me once fixed
0108       ));
0109 
0110   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0111       "EcalEndcapPTruthClusters",
0112       {"EcalEndcapPTruthClustersWithoutShapes", "EcalEndcapPTruthClusterAssociationsWithoutShapes"},
0113       {"EcalEndcapPTruthClusters", "EcalEndcapPTruthClusterAssociations"},
0114       {.energyWeight = "log", .logWeightBase = 6.2}, app));
0115 
0116   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0117       "EcalEndcapPClustersWithoutShapes",
0118       {
0119           "EcalEndcapPIslandProtoClusters", // edm4eic::ProtoClusterCollection
0120           "EcalEndcapPRawHitAssociations"   // edm4eic::MCRecoCalorimeterHitAssociationCollection
0121       },
0122       {"EcalEndcapPClustersWithoutShapes",             // edm4eic::Cluster
0123        "EcalEndcapPClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0124       {
0125           .energyWeight    = "log",
0126           .sampFrac        = 1.0,
0127           .logWeightBase   = 3.6,
0128           .enableEtaBounds = false,
0129       },
0130       app // TODO: Remove me once fixed
0131       ));
0132 
0133   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0134       "EcalEndcapPClusters",
0135       {"EcalEndcapPClustersWithoutShapes", "EcalEndcapPClusterAssociationsWithoutShapes"},
0136       {"EcalEndcapPClusters", "EcalEndcapPClusterAssociations"},
0137       {.energyWeight = "log", .logWeightBase = 3.6}, app));
0138 
0139   app->Add(new JOmniFactoryGeneratorT<TrackClusterMergeSplitter_factory>(
0140       "EcalEndcapPSplitMergeProtoClusters",
0141       {"EcalEndcapPIslandProtoClusters", "CalorimeterTrackProjections"},
0142       {"EcalEndcapPSplitMergeProtoClusters"},
0143       {.idCalo                       = "EcalEndcapP_ID",
0144        .minSigCut                    = -2.0,
0145        .avgEP                        = 1.0,
0146        .sigEP                        = 0.10,
0147        .drAdd                        = 0.30,
0148        .sampFrac                     = 1.0,
0149        .transverseEnergyProfileScale = 1.0},
0150       app // TODO: remove me once fixed
0151       ));
0152 
0153   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0154       "EcalEndcapPSplitMergeClustersWithoutShapes",
0155       {
0156           "EcalEndcapPSplitMergeProtoClusters", // edm4eic::ProtoClusterCollection
0157           "EcalEndcapPRawHitAssociations" // edm4hep::MCRecoCalorimeterHitAssociationCollection
0158       },
0159       {"EcalEndcapPSplitMergeClustersWithoutShapes",             // edm4eic::Cluster
0160        "EcalEndcapPSplitMergeClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0161       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 3.6, .enableEtaBounds = false},
0162       app // TODO: Remove me once fixed
0163       ));
0164 
0165   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0166       "EcalEndcapPSplitMergeClusters",
0167       {"EcalEndcapPSplitMergeClustersWithoutShapes",
0168        "EcalEndcapPSplitMergeClusterAssociationsWithoutShapes"},
0169       {"EcalEndcapPSplitMergeClusters", "EcalEndcapPSplitMergeClusterAssociations"},
0170       {.energyWeight = "log", .logWeightBase = 3.6}, app));
0171 }
0172 }