Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 08:26:11

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, Nathan Brei, Sebouh Paul, Dmitry Kalinkin, Barak Schmookler
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/HEXPLITConfig.h"
0012 #include "algorithms/calorimetry/ImagingTopoClusterConfig.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/HEXPLIT_factory.h"
0021 #include "factories/calorimetry/ImagingTopoCluster_factory.h"
0022 
0023 extern "C" {
0024 void InitPlugin(JApplication* app) {
0025 
0026   using namespace eicrecon;
0027 
0028   InitJANAPlugin(app);
0029 
0030   // LYSO part of the ZDC
0031   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0032       "EcalFarForwardZDCRawHits", {"EventHeader", "EcalFarForwardZDCHits"},
0033       {"EcalFarForwardZDCRawHits", "EcalFarForwardZDCRawHitLinks",
0034        "EcalFarForwardZDCRawHitAssociations"},
0035       {
0036           .eRes{},
0037           .tRes          = 0.0 * dd4hep::ns,
0038           .capADC        = 32768,
0039           .dyRangeADC    = 2000 * dd4hep::MeV,
0040           .pedMeanADC    = 400,
0041           .pedSigmaADC   = 3.2,
0042           .resolutionTDC = 10 * dd4hep::picosecond,
0043           .corrMeanScale = "1.0",
0044           .readout       = "EcalFarForwardZDCHits",
0045       },
0046       app // TODO: Remove me once fixed
0047       ));
0048   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
0049       "EcalFarForwardZDCRecHits", {"EcalFarForwardZDCRawHits"}, {"EcalFarForwardZDCRecHits"},
0050       {
0051           .capADC          = 32768,
0052           .dyRangeADC      = 2000. * dd4hep::MeV,
0053           .pedMeanADC      = 400,
0054           .pedSigmaADC     = 3.2,
0055           .resolutionTDC   = 10 * dd4hep::picosecond,
0056           .thresholdFactor = 4.0,
0057           .thresholdValue  = 0.0,
0058           .sampFrac        = "1.0",
0059           .readout         = "EcalFarForwardZDCHits",
0060       },
0061       app // TODO: Remove me once fixed
0062       ));
0063   app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0064       "EcalFarForwardZDCTruthProtoClusters",
0065       {"EcalFarForwardZDCRecHits", "EcalFarForwardZDCRawHitLinks"},
0066       {"EcalFarForwardZDCTruthProtoClusters"},
0067       app // TODO: Remove me once fixed
0068       ));
0069   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0070       "EcalFarForwardZDCIslandProtoClusters", {"EcalFarForwardZDCRecHits"},
0071       {"EcalFarForwardZDCIslandProtoClusters"},
0072       {
0073           .adjacencyMatrix{},
0074           .peakNeighbourhoodMatrix{},
0075           .readout{},
0076           .sectorDist  = 5.0 * dd4hep::cm,
0077           .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm},
0078           .localDistXZ{},
0079           .localDistYZ{},
0080           .globalDistRPhi{},
0081           .globalDistEtaPhi{},
0082           .dimScaledLocalDistXY{},
0083           .splitCluster                  = true,
0084           .minClusterHitEdep             = 0.1 * dd4hep::MeV,
0085           .minClusterCenterEdep          = 3.0 * dd4hep::MeV,
0086           .transverseEnergyProfileMetric = "globalDistEtaPhi",
0087           .transverseEnergyProfileScale  = 1.,
0088           .transverseEnergyProfileScaleUnits{},
0089       },
0090       app // TODO: Remove me once fixed
0091       ));
0092 
0093   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0094       "EcalFarForwardZDCTruthClustersWithoutShapes",
0095       {
0096           "EcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection
0097           "EcalFarForwardZDCRawHitLinks",        // edm4eic::MCRecoCalorimeterHitLink
0098           "EcalFarForwardZDCRawHitAssociations"  // edm4eic::MCRecoCalorimeterHitAssociation
0099       },
0100       {"EcalFarForwardZDCTruthClustersWithoutShapes",
0101        "EcalFarForwardZDCTruthClusterLinksWithoutShapes",
0102        "EcalFarForwardZDCTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0103       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 3.6, .enableEtaBounds = false},
0104       app // TODO: Remove me once fixed
0105       ));
0106 
0107   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0108       "EcalFarForwardZDCTruthClusters",
0109       {"EcalFarForwardZDCTruthClustersWithoutShapes",
0110        "EcalFarForwardZDCTruthClusterLinksWithoutShapes"},
0111       {"EcalFarForwardZDCTruthClusters", "EcalFarForwardZDCTruthClusterLinks",
0112        "EcalFarForwardZDCTruthClusterAssociations"},
0113       {.longitudinalShowerInfoAvailable = true, .energyWeight = "log", .logWeightBase = 3.6}, app));
0114 
0115   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0116       "EcalFarForwardZDCClustersWithoutShapes",
0117       {
0118           "EcalFarForwardZDCIslandProtoClusters", // edm4eic::ProtoClusterCollection
0119           "EcalFarForwardZDCRawHitLinks",         // edm4eic::MCRecoCalorimeterHitLink
0120           "EcalFarForwardZDCRawHitAssociations"   // edm4eic::MCRecoCalorimeterHitAssociation
0121       },
0122       {"EcalFarForwardZDCClustersWithoutShapes", "EcalFarForwardZDCClusterLinksWithoutShapes",
0123        "EcalFarForwardZDCClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0124       {
0125           .energyWeight    = "log",
0126           .sampFrac        = 1.0,
0127           .logWeightBase   = 6.2,
0128           .enableEtaBounds = false,
0129       },
0130       app // TODO: Remove me once fixed
0131       ));
0132 
0133   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0134       "EcalFarForwardZDCClusters",
0135       {"EcalFarForwardZDCClustersWithoutShapes", "EcalFarForwardZDCClusterLinksWithoutShapes"},
0136       {"EcalFarForwardZDCClusters", "EcalFarForwardZDCClusterLinks",
0137        "EcalFarForwardZDCClusterAssociations"},
0138       {.longitudinalShowerInfoAvailable = true, .energyWeight = "log", .logWeightBase = 6.2}, app));
0139 
0140   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0141       "HcalFarForwardZDCRawHits", {"EventHeader", "HcalFarForwardZDCHits"},
0142       {"HcalFarForwardZDCRawHits", "HcalFarForwardZDCRawHitLinks",
0143        "HcalFarForwardZDCRawHitAssociations"},
0144       {
0145           .eRes{},
0146           .tRes          = 0.0 * dd4hep::ns,
0147           .capADC        = 65536,
0148           .dyRangeADC    = 1000. * dd4hep::MeV,
0149           .pedMeanADC    = 400,
0150           .pedSigmaADC   = 2,
0151           .resolutionTDC = 10 * dd4hep::picosecond,
0152           .corrMeanScale = "1.0",
0153           .readout       = "HcalFarForwardZDCHits",
0154       },
0155       app // TODO: Remove me once fixed
0156       ));
0157 
0158   app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
0159       "HcalFarForwardZDCRecHits", {"HcalFarForwardZDCRawHits"}, {"HcalFarForwardZDCRecHits"},
0160       {
0161           .capADC          = 65536,
0162           .dyRangeADC      = 1000. * dd4hep::MeV,
0163           .pedMeanADC      = 400,
0164           .pedSigmaADC     = 2,
0165           .resolutionTDC   = 10 * dd4hep::picosecond,
0166           .thresholdFactor = 3.0,
0167           .thresholdValue  = 0.0,
0168           .sampFrac        = "1.0",
0169           .readout         = "HcalFarForwardZDCHits",
0170           .layerField      = "layer",
0171           .sectorField     = "system",
0172       },
0173       app // TODO: Remove me once fixed
0174       ));
0175 
0176   app->Add(new JOmniFactoryGeneratorT<HEXPLIT_factory>(
0177       "HcalFarForwardZDCSubcellHits", {"HcalFarForwardZDCRecHits"},
0178       {"HcalFarForwardZDCSubcellHits"},
0179       {
0180           .MIP           = 630. * dd4hep::keV,
0181           .Emin_in_MIPs  = 0.5,
0182           .delta_in_MIPs = 0.01,
0183           .tmax          = 269 * dd4hep::ns,
0184           .stag_type     = HEXPLITConfig::StaggerType::S2,
0185       },
0186       app // TODO: Remove me once fixed
0187       ));
0188 
0189   double side_length = 48.8 * dd4hep::mm;
0190   app->Add(new JOmniFactoryGeneratorT<ImagingTopoCluster_factory>(
0191       "HcalFarForwardZDCImagingProtoClusters", {"HcalFarForwardZDCSubcellHits"},
0192       {"HcalFarForwardZDCImagingProtoClusters"},
0193       {
0194           .neighbourLayersRange = 1,
0195           .sameLayerDistXY      = {side_length * 0.75, side_length * 0.75},
0196           .diffLayerDistXY      = {side_length * 0.75, side_length * 0.75},
0197           .sameLayerMode        = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
0198           .diffLayerMode        = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
0199           .sectorDist           = 10.0 * dd4hep::cm,
0200           .minClusterHitEdep    = 315.0 * dd4hep::keV,
0201           .minClusterCenterEdep = 25 * dd4hep::MeV,
0202           .minClusterEdep       = 50.0 * dd4hep::MeV,
0203           .minClusterNhits      = 10,
0204       },
0205       app));
0206 
0207   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0208       "HcalFarForwardZDCIslandProtoClusters", {"HcalFarForwardZDCSubcellHits"},
0209       {"HcalFarForwardZDCIslandProtoClusters"},
0210       {.adjacencyMatrix{},
0211        .peakNeighbourhoodMatrix{},
0212        .readout{},
0213        .sectorDist  = 1.5 * dd4hep::cm,
0214        .localDistXY = {"0.55 * HcalFarForwardZDC_SiPMonTile_SquareSideLength",
0215                        "0.55 * HcalFarForwardZDC_SiPMonTile_SquareSideLength"},
0216        .localDistXZ{},
0217        .localDistYZ{},
0218        .globalDistRPhi{},
0219        .globalDistEtaPhi{},
0220        .dimScaledLocalDistXY{},
0221        .splitCluster         = false,
0222        .minClusterHitEdep    = 100.0 * dd4hep::keV,
0223        .minClusterCenterEdep = 1.0 * dd4hep::MeV,
0224        .transverseEnergyProfileMetric{}, // = "globalDistEtaPhi",
0225        .transverseEnergyProfileScale{},  // = 1.,
0226        .transverseEnergyProfileScaleUnits{}},
0227       app));
0228 
0229   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0230       "HcalFarForwardZDCClustersWithoutShapes",
0231       {
0232           "HcalFarForwardZDCImagingProtoClusters", // edm4eic::ProtoClusterCollection
0233           "HcalFarForwardZDCRawHitLinks",          // edm4eic::MCRecoCalorimeterHitLink
0234           "HcalFarForwardZDCRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0235       },
0236       {"HcalFarForwardZDCClustersWithoutShapes", "HcalFarForwardZDCClusterLinksWithoutShapes",
0237        "HcalFarForwardZDCClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0238       {.energyWeight        = "log",
0239        .sampFrac            = 0.0273,
0240        .logWeightBaseCoeffs = {5.8, 0.65, 0.31},
0241        .logWeightBase_Eref  = 50 * dd4hep::GeV},
0242       app // TODO: Remove me once fixed
0243       ));
0244 
0245   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0246       "HcalFarForwardZDCClusters",
0247       {"HcalFarForwardZDCClustersWithoutShapes", "HcalFarForwardZDCClusterLinksWithoutShapes"},
0248       {"HcalFarForwardZDCClusters", "HcalFarForwardZDCClusterLinks",
0249        "HcalFarForwardZDCClusterAssociations"},
0250       {.longitudinalShowerInfoAvailable = true,
0251        .energyWeight                    = "log",
0252        .sampFrac                        = 0.0273,
0253        .logWeightBaseCoeffs             = {5.8, 0.65, 0.31},
0254        .logWeightBase_Eref              = 50 * dd4hep::GeV},
0255       app));
0256 
0257   app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0258       "HcalFarForwardZDCTruthProtoClusters",
0259       {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCRawHitLinks"},
0260       {"HcalFarForwardZDCTruthProtoClusters"},
0261       app // TODO: Remove me once fixed
0262       ));
0263 
0264   //Clusters with the baseline algorithm (no HEXPLIT)
0265   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0266       "HcalFarForwardZDCIslandProtoClustersBaseline", {"HcalFarForwardZDCRecHits"},
0267       {"HcalFarForwardZDCIslandProtoClustersBaseline"},
0268       {.adjacencyMatrix{},
0269        .peakNeighbourhoodMatrix{},
0270        .readout{},
0271        .sectorDist  = 5.0 * dd4hep::cm,
0272        .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm},
0273        .localDistXZ{},
0274        .localDistYZ{},
0275        .globalDistRPhi{},
0276        .globalDistEtaPhi{},
0277        .dimScaledLocalDistXY{},
0278        .splitCluster                  = true,
0279        .minClusterHitEdep             = 0.1 * dd4hep::MeV,
0280        .minClusterCenterEdep          = 3.0 * dd4hep::MeV,
0281        .transverseEnergyProfileMetric = "globalDistEtaPhi",
0282        .transverseEnergyProfileScale  = 1.,
0283        .transverseEnergyProfileScaleUnits{}},
0284       app // TODO: Remove me once fixed
0285       ));
0286 
0287   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0288       "HcalFarForwardZDCTruthClustersWithoutShapes",
0289       {
0290           "HcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection
0291           "HcalFarForwardZDCRawHitLinks",        // edm4eic::MCRecoCalorimeterHitLink
0292           "HcalFarForwardZDCRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0293       },
0294       {"HcalFarForwardZDCTruthClustersWithoutShapes",
0295        "HcalFarForwardZDCTruthClusterLinksWithoutShapes",
0296        "HcalFarForwardZDCTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0297       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 3.6, .enableEtaBounds = false},
0298       app // TODO: Remove me once fixed
0299       ));
0300 
0301   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0302       "HcalFarForwardZDCTruthClusters",
0303       {"HcalFarForwardZDCTruthClustersWithoutShapes",
0304        "HcalFarForwardZDCTruthClusterLinksWithoutShapes"},
0305       {"HcalFarForwardZDCTruthClusters", "HcalFarForwardZDCTruthClusterLinks",
0306        "HcalFarForwardZDCTruthClusterAssociations"},
0307       {.longitudinalShowerInfoAvailable = true, .energyWeight = "log", .logWeightBase = 3.6}, app));
0308 
0309   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0310       "HcalFarForwardZDCClustersBaselineWithoutShapes",
0311       {
0312           "HcalFarForwardZDCIslandProtoClustersBaseline", // edm4eic::ProtoClusterCollection
0313           "HcalFarForwardZDCRawHitLinks",                 // edm4eic::MCRecoCalorimeterHitLink
0314           "HcalFarForwardZDCRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0315       },
0316       {"HcalFarForwardZDCClustersBaselineWithoutShapes", // edm4eic::Cluster
0317        "HcalFarForwardZDCClusterLinksBaselineWithoutShapes",
0318        "HcalFarForwardZDCClusterAssociationsBaselineWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0319       {
0320           .energyWeight    = "log",
0321           .sampFrac        = 0.0273,
0322           .logWeightBase   = 6.2,
0323           .enableEtaBounds = false,
0324       },
0325       app // TODO: Remove me once fixed
0326       ));
0327 
0328   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0329       "HcalFarForwardZDCClustersBaseline",
0330       {"HcalFarForwardZDCClustersBaselineWithoutShapes",
0331        "HcalFarForwardZDCClusterLinksBaselineWithoutShapes"},
0332       {"HcalFarForwardZDCClustersBaseline", "HcalFarForwardZDCClusterLinksBaseline",
0333        "HcalFarForwardZDCClusterAssociationsBaseline"},
0334       {.longitudinalShowerInfoAvailable = true,
0335        .energyWeight                    = "log",
0336        .sampFrac                        = 0.0273,
0337        .logWeightBase                   = 6.2},
0338       app));
0339 }
0340 }