Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-09 09:33:25

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           .stag_type     = HEXPLITConfig::StaggerType::S2,
0184       },
0185       app // TODO: Remove me once fixed
0186       ));
0187 
0188   double side_length = 48.8 * dd4hep::mm;
0189   app->Add(new JOmniFactoryGeneratorT<ImagingTopoCluster_factory>(
0190       "HcalFarForwardZDCImagingProtoClusters", {"HcalFarForwardZDCSubcellHits"},
0191       {"HcalFarForwardZDCImagingProtoClusters"},
0192       {
0193           .neighbourLayersRange = 1,
0194           .sameLayerDistXY      = {side_length * 0.75, side_length * 0.75},
0195           .diffLayerDistXY      = {side_length * 0.75, side_length * 0.75},
0196           .sameLayerMode        = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
0197           .diffLayerMode        = eicrecon::ImagingTopoClusterConfig::ELayerMode::xy,
0198           .sectorDist           = 10.0 * dd4hep::cm,
0199           .minClusterHitEdep    = 315.0 * dd4hep::keV,
0200           .minClusterCenterEdep = 25 * dd4hep::MeV,
0201           .minClusterEdep       = 50.0 * dd4hep::MeV,
0202           .minClusterNhits      = 10,
0203       },
0204       app));
0205 
0206   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0207       "HcalFarForwardZDCIslandProtoClusters", {"HcalFarForwardZDCSubcellHits"},
0208       {"HcalFarForwardZDCIslandProtoClusters"},
0209       {.adjacencyMatrix{},
0210        .peakNeighbourhoodMatrix{},
0211        .readout{},
0212        .sectorDist  = 1.5 * dd4hep::cm,
0213        .localDistXY = {"0.55 * HcalFarForwardZDC_SiPMonTile_SquareSideLength",
0214                        "0.55 * HcalFarForwardZDC_SiPMonTile_SquareSideLength"},
0215        .localDistXZ{},
0216        .localDistYZ{},
0217        .globalDistRPhi{},
0218        .globalDistEtaPhi{},
0219        .dimScaledLocalDistXY{},
0220        .splitCluster         = false,
0221        .minClusterHitEdep    = 100.0 * dd4hep::keV,
0222        .minClusterCenterEdep = 1.0 * dd4hep::MeV,
0223        .transverseEnergyProfileMetric{}, // = "globalDistEtaPhi",
0224        .transverseEnergyProfileScale{},  // = 1.,
0225        .transverseEnergyProfileScaleUnits{}},
0226       app));
0227 
0228   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0229       "HcalFarForwardZDCClustersWithoutShapes",
0230       {
0231           "HcalFarForwardZDCImagingProtoClusters", // edm4eic::ProtoClusterCollection
0232           "HcalFarForwardZDCRawHitLinks",          // edm4eic::MCRecoCalorimeterHitLink
0233           "HcalFarForwardZDCRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0234       },
0235       {"HcalFarForwardZDCClustersWithoutShapes", "HcalFarForwardZDCClusterLinksWithoutShapes",
0236        "HcalFarForwardZDCClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0237       {.energyWeight        = "log",
0238        .sampFrac            = 0.0273,
0239        .logWeightBaseCoeffs = {5.8, 0.65, 0.31},
0240        .logWeightBase_Eref  = 50 * dd4hep::GeV},
0241       app // TODO: Remove me once fixed
0242       ));
0243 
0244   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0245       "HcalFarForwardZDCClusters",
0246       {"HcalFarForwardZDCClustersWithoutShapes", "HcalFarForwardZDCClusterLinksWithoutShapes"},
0247       {"HcalFarForwardZDCClusters", "HcalFarForwardZDCClusterLinks",
0248        "HcalFarForwardZDCClusterAssociations"},
0249       {.longitudinalShowerInfoAvailable = true,
0250        .energyWeight                    = "log",
0251        .sampFrac                        = 0.0273,
0252        .logWeightBaseCoeffs             = {5.8, 0.65, 0.31},
0253        .logWeightBase_Eref              = 50 * dd4hep::GeV},
0254       app));
0255 
0256   app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0257       "HcalFarForwardZDCTruthProtoClusters",
0258       {"HcalFarForwardZDCRecHits", "HcalFarForwardZDCRawHitLinks"},
0259       {"HcalFarForwardZDCTruthProtoClusters"},
0260       app // TODO: Remove me once fixed
0261       ));
0262 
0263   //Clusters with the baseline algorithm (no HEXPLIT)
0264   app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0265       "HcalFarForwardZDCIslandProtoClustersBaseline", {"HcalFarForwardZDCRecHits"},
0266       {"HcalFarForwardZDCIslandProtoClustersBaseline"},
0267       {.adjacencyMatrix{},
0268        .peakNeighbourhoodMatrix{},
0269        .readout{},
0270        .sectorDist  = 5.0 * dd4hep::cm,
0271        .localDistXY = {50 * dd4hep::cm, 50 * dd4hep::cm},
0272        .localDistXZ{},
0273        .localDistYZ{},
0274        .globalDistRPhi{},
0275        .globalDistEtaPhi{},
0276        .dimScaledLocalDistXY{},
0277        .splitCluster                  = true,
0278        .minClusterHitEdep             = 0.1 * dd4hep::MeV,
0279        .minClusterCenterEdep          = 3.0 * dd4hep::MeV,
0280        .transverseEnergyProfileMetric = "globalDistEtaPhi",
0281        .transverseEnergyProfileScale  = 1.,
0282        .transverseEnergyProfileScaleUnits{}},
0283       app // TODO: Remove me once fixed
0284       ));
0285 
0286   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0287       "HcalFarForwardZDCTruthClustersWithoutShapes",
0288       {
0289           "HcalFarForwardZDCTruthProtoClusters", // edm4eic::ProtoClusterCollection
0290           "HcalFarForwardZDCRawHitLinks",        // edm4eic::MCRecoCalorimeterHitLink
0291           "HcalFarForwardZDCRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0292       },
0293       {"HcalFarForwardZDCTruthClustersWithoutShapes",
0294        "HcalFarForwardZDCTruthClusterLinksWithoutShapes",
0295        "HcalFarForwardZDCTruthClusterAssociationsWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0296       {.energyWeight = "log", .sampFrac = 1.0, .logWeightBase = 3.6, .enableEtaBounds = false},
0297       app // TODO: Remove me once fixed
0298       ));
0299 
0300   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0301       "HcalFarForwardZDCTruthClusters",
0302       {"HcalFarForwardZDCTruthClustersWithoutShapes",
0303        "HcalFarForwardZDCTruthClusterLinksWithoutShapes"},
0304       {"HcalFarForwardZDCTruthClusters", "HcalFarForwardZDCTruthClusterLinks",
0305        "HcalFarForwardZDCTruthClusterAssociations"},
0306       {.longitudinalShowerInfoAvailable = true, .energyWeight = "log", .logWeightBase = 3.6}, app));
0307 
0308   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0309       "HcalFarForwardZDCClustersBaselineWithoutShapes",
0310       {
0311           "HcalFarForwardZDCIslandProtoClustersBaseline", // edm4eic::ProtoClusterCollection
0312           "HcalFarForwardZDCRawHitLinks",                 // edm4eic::MCRecoCalorimeterHitLink
0313           "HcalFarForwardZDCRawHitAssociations" // edm4eic::MCRecoCalorimeterHitAssociationCollection
0314       },
0315       {"HcalFarForwardZDCClustersBaselineWithoutShapes", // edm4eic::Cluster
0316        "HcalFarForwardZDCClusterLinksBaselineWithoutShapes",
0317        "HcalFarForwardZDCClusterAssociationsBaselineWithoutShapes"}, // edm4eic::MCRecoClusterParticleAssociation
0318       {
0319           .energyWeight    = "log",
0320           .sampFrac        = 0.0273,
0321           .logWeightBase   = 6.2,
0322           .enableEtaBounds = false,
0323       },
0324       app // TODO: Remove me once fixed
0325       ));
0326 
0327   app->Add(new JOmniFactoryGeneratorT<CalorimeterClusterShape_factory>(
0328       "HcalFarForwardZDCClustersBaseline",
0329       {"HcalFarForwardZDCClustersBaselineWithoutShapes",
0330        "HcalFarForwardZDCClusterLinksBaselineWithoutShapes"},
0331       {"HcalFarForwardZDCClustersBaseline", "HcalFarForwardZDCClusterLinksBaseline",
0332        "HcalFarForwardZDCClusterAssociationsBaseline"},
0333       {.longitudinalShowerInfoAvailable = true,
0334        .energyWeight                    = "log",
0335        .sampFrac                        = 0.0273,
0336        .logWeightBase                   = 6.2},
0337       app));
0338 }
0339 }