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) 2021 - 2024, Chao Peng, Sylvester Joosten, Whitney Armstrong, David Lawrence, Friederike Bock, Wouter Deconinck, Kolja Kauder, Sebouh Paul
0003 
0004 #include <edm4eic/EDM4eicVersion.h>
0005 #include <Evaluator/DD4hepUnits.h>
0006 #include <JANA/JApplication.h>
0007 #include <math.h>
0008 #include <string>
0009 
0010 #include "algorithms/calorimetry/CalorimeterHitDigiConfig.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     void InitPlugin(JApplication *app) {
0021 
0022         using namespace eicrecon;
0023 
0024         InitJANAPlugin(app);
0025         // Make sure digi and reco use the same value
0026         decltype(CalorimeterHitDigiConfig::capADC)        EcalEndcapP_capADC = 16384; //16384, assuming 14 bits. For approximate HGCROC resolution use 65536
0027         decltype(CalorimeterHitDigiConfig::dyRangeADC)    EcalEndcapP_dyRangeADC = 3 * dd4hep::GeV;
0028         decltype(CalorimeterHitDigiConfig::pedMeanADC)    EcalEndcapP_pedMeanADC = 200;
0029         decltype(CalorimeterHitDigiConfig::pedSigmaADC)   EcalEndcapP_pedSigmaADC = 2.4576;
0030         decltype(CalorimeterHitDigiConfig::resolutionTDC) EcalEndcapP_resolutionTDC = 10 * dd4hep::picosecond;
0031         app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0032           "EcalEndcapPRawHits",
0033           {"EcalEndcapPHits"},
0034 #if EDM4EIC_VERSION_MAJOR >= 7
0035           {"EcalEndcapPRawHits", "EcalEndcapPRawHitAssociations"},
0036 #else
0037           {"EcalEndcapPRawHits"},
0038 #endif
0039           {
0040             .eRes = {0.11333 * sqrt(dd4hep::GeV), 0.03, 0.0 * dd4hep::GeV}, // (11.333% / sqrt(E)) \oplus 3%
0041             .tRes = 0.0,
0042             .threshold = 0.0,
0043              // .threshold = 15 * dd4hep::MeV for a single tower, applied on ADC level
0044             .capADC = EcalEndcapP_capADC,
0045             .capTime =  100, // given in ns, 4 samples in HGCROC
0046             .dyRangeADC = EcalEndcapP_dyRangeADC,
0047             .pedMeanADC = EcalEndcapP_pedMeanADC,
0048             .pedSigmaADC = EcalEndcapP_pedSigmaADC,
0049             .resolutionTDC = EcalEndcapP_resolutionTDC,
0050             .corrMeanScale = "0.03",
0051             .readout = "EcalEndcapPHits",
0052           },
0053           app   // TODO: Remove me once fixed
0054         ));
0055         app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
0056           "EcalEndcapPRecHits", {"EcalEndcapPRawHits"}, {"EcalEndcapPRecHits"},
0057           {
0058             .capADC = EcalEndcapP_capADC,
0059             .dyRangeADC = EcalEndcapP_dyRangeADC,
0060             .pedMeanADC = EcalEndcapP_pedMeanADC,
0061             .pedSigmaADC = EcalEndcapP_pedSigmaADC,
0062             .resolutionTDC = EcalEndcapP_resolutionTDC,
0063             .thresholdFactor = 0.0,
0064             .thresholdValue = 2, // The ADC of a 15 MeV particle is adc = 200 + 15 * 0.03 * ( 1.0 + 0) / 3000 * 16384 = 200 + 2.4576
0065             .sampFrac  = "0.03",
0066             .readout = "EcalEndcapPHits",
0067           },
0068           app   // TODO: Remove me once fixed
0069         ));
0070         app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0071           "EcalEndcapPTruthProtoClusters", {"EcalEndcapPRecHits", "EcalEndcapPHits"}, {"EcalEndcapPTruthProtoClusters"},
0072           app   // TODO: Remove me once fixed
0073         ));
0074         app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0075           "EcalEndcapPIslandProtoClusters", {"EcalEndcapPRecHits"}, {"EcalEndcapPIslandProtoClusters"},
0076           {
0077             .sectorDist = 5.0 * dd4hep::cm,
0078             .dimScaledLocalDistXY = {1.5,1.5},
0079             .splitCluster = false,
0080             .minClusterHitEdep = 0.0 * dd4hep::MeV,
0081             .minClusterCenterEdep = 60.0 * dd4hep::MeV,
0082             .transverseEnergyProfileMetric = "dimScaledLocalDistXY",
0083             .transverseEnergyProfileScale = 1.,
0084           },
0085           app   // TODO: Remove me once fixed
0086         ));
0087 
0088         app->Add(
0089           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0090              "EcalEndcapPTruthClusters",
0091             {"EcalEndcapPTruthProtoClusters",        // edm4eic::ProtoClusterCollection
0092 #if EDM4EIC_VERSION_MAJOR >= 7
0093              "EcalEndcapPRawHitAssociations"},       // edm4eic::MCRecoCalorimeterHitAssociationCollection
0094 #else
0095              "EcalEndcapPHits"},                     // edm4hep::SimCalorimeterHitCollection
0096 #endif
0097             {"EcalEndcapPTruthClusters",             // edm4eic::Cluster
0098              "EcalEndcapPTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0099             {
0100               .energyWeight = "log",
0101               .sampFrac = 1.0,
0102               .logWeightBase = 6.2,
0103               .enableEtaBounds = true
0104             },
0105             app   // TODO: Remove me once fixed
0106           )
0107         );
0108 
0109         app->Add(
0110           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0111              "EcalEndcapPClusters",
0112             {"EcalEndcapPIslandProtoClusters",  // edm4eic::ProtoClusterCollection
0113 #if EDM4EIC_VERSION_MAJOR >= 7
0114              "EcalEndcapPRawHitAssociations"},  // edm4eic::MCRecoCalorimeterHitAssociationCollection
0115 #else
0116              "EcalEndcapPHits"},                // edm4hep::SimCalorimeterHitCollection
0117 #endif
0118             {"EcalEndcapPClusters",             // edm4eic::Cluster
0119              "EcalEndcapPClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0120             {
0121               .energyWeight = "log",
0122               .sampFrac = 1.0,
0123               .logWeightBase = 3.6,
0124               .enableEtaBounds = false,
0125             },
0126             app   // TODO: Remove me once fixed
0127           )
0128         );
0129 
0130         app->Add(
0131           new JOmniFactoryGeneratorT<TrackClusterMergeSplitter_factory>(
0132             "EcalEndcapPSplitMergeProtoClusters",
0133             {"EcalEndcapPIslandProtoClusters",
0134              "CalorimeterTrackProjections"},
0135             {"EcalEndcapPSplitMergeProtoClusters"},
0136             {
0137               .idCalo = "EcalEndcapP_ID",
0138               .minSigCut = -2.0,
0139               .avgEP = 1.0,
0140               .sigEP = 0.10,
0141               .drAdd = 0.30,
0142               .sampFrac = 1.0,
0143               .transverseEnergyProfileScale = 1.0
0144             },
0145             app   // TODO: remove me once fixed
0146           )
0147         );
0148 
0149         app->Add(
0150           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0151              "EcalEndcapPSplitMergeClusters",
0152             {"EcalEndcapPSplitMergeProtoClusters",        // edm4eic::ProtoClusterCollection
0153              "EcalEndcapPHits"},                          // edm4hep::SimCalorimeterHitCollection
0154             {"EcalEndcapPSplitMergeClusters",             // edm4eic::Cluster
0155              "EcalEndcapPSplitMergeClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0156             {
0157               .energyWeight = "log",
0158               .sampFrac = 1.0,
0159               .logWeightBase = 3.6,
0160               .enableEtaBounds = false
0161             },
0162             app   // TODO: Remove me once fixed
0163           )
0164         );
0165 
0166         // Insert is identical to regular Ecal
0167         app->Add(new JOmniFactoryGeneratorT<CalorimeterHitDigi_factory>(
0168           "EcalEndcapPInsertRawHits",
0169           {"EcalEndcapPInsertHits"},
0170 #if EDM4EIC_VERSION_MAJOR >= 7
0171           {"EcalEndcapPInsertRawHits", "EcalEndcapPInsertRawHitAssociations"},
0172 #else
0173           {"EcalEndcapPInsertRawHits"},
0174 #endif
0175           {
0176             .eRes = {0.11333 * sqrt(dd4hep::GeV), 0.03, 0.0 * dd4hep::GeV}, // (11.333% / sqrt(E)) \oplus 3%
0177             .tRes = 0.0,
0178             .threshold = 0.0,
0179              // .threshold = 15 * dd4hep::MeV for a single tower, applied on ADC level
0180             .capADC = EcalEndcapP_capADC,
0181             .capTime =  100, // given in ns, 4 samples in HGCROC
0182             .dyRangeADC = EcalEndcapP_dyRangeADC,
0183             .pedMeanADC = EcalEndcapP_pedMeanADC,
0184             .pedSigmaADC = EcalEndcapP_pedSigmaADC,
0185             .resolutionTDC = EcalEndcapP_resolutionTDC,
0186             .corrMeanScale = "0.03",
0187             .readout = "EcalEndcapPInsertHits",
0188           },
0189           app   // TODO: Remove me once fixed
0190         ));
0191         app->Add(new JOmniFactoryGeneratorT<CalorimeterHitReco_factory>(
0192           "EcalEndcapPInsertRecHits", {"EcalEndcapPInsertRawHits"}, {"EcalEndcapPInsertRecHits"},
0193           {
0194             .capADC = EcalEndcapP_capADC,
0195             .dyRangeADC = EcalEndcapP_dyRangeADC,
0196             .pedMeanADC = EcalEndcapP_pedMeanADC,
0197             .pedSigmaADC = EcalEndcapP_pedSigmaADC,
0198             .resolutionTDC = EcalEndcapP_resolutionTDC,
0199             .thresholdFactor = 0.0,
0200             .thresholdValue = 2, // The ADC of a 15 MeV particle is adc = 200 + 15 * 0.03 * ( 1.0 + 0) / 3000 * 16384 = 200 + 2.4576
0201             .sampFrac = "0.03",
0202             .readout = "EcalEndcapPInsertHits",
0203           },
0204           app   // TODO: Remove me once fixed
0205         ));
0206         app->Add(new JOmniFactoryGeneratorT<CalorimeterTruthClustering_factory>(
0207           "EcalEndcapPInsertTruthProtoClusters", {"EcalEndcapPInsertRecHits", "EcalEndcapPInsertHits"}, {"EcalEndcapPInsertTruthProtoClusters"},
0208           app   // TODO: Remove me once fixed
0209         ));
0210         app->Add(new JOmniFactoryGeneratorT<CalorimeterIslandCluster_factory>(
0211           "EcalEndcapPInsertIslandProtoClusters", {"EcalEndcapPInsertRecHits"}, {"EcalEndcapPInsertIslandProtoClusters"},
0212           {
0213             .sectorDist = 5.0 * dd4hep::cm,
0214             .dimScaledLocalDistXY = {1.5,1.5},
0215             .splitCluster = false,
0216             .minClusterHitEdep = 0.0 * dd4hep::MeV,
0217             .minClusterCenterEdep = 60.0 * dd4hep::MeV,
0218             .transverseEnergyProfileMetric = "dimScaledLocalDistXY",
0219             .transverseEnergyProfileScale = 1.,
0220           },
0221           app   // TODO: Remove me once fixed
0222         ));
0223 
0224         app->Add(
0225           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0226              "EcalEndcapPInsertTruthClusters",
0227             {"EcalEndcapPInsertTruthProtoClusters",        // edm4eic::ProtoClusterCollection
0228 #if EDM4EIC_VERSION_MAJOR >= 7
0229              "EcalEndcapPInsertRawHitAssociations"},       // edm4eic::MCRecoCalorimeterHitCollection
0230 #else
0231              "EcalEndcapPInsertHits"},                     // edm4hep::SimCalorimeterHitCollection
0232 #endif
0233             {"EcalEndcapPInsertTruthClusters",             // edm4eic::Cluster
0234              "EcalEndcapPInsertTruthClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0235             {
0236               .energyWeight = "log",
0237               .sampFrac = 1.0,
0238               .logWeightBase = 6.2,
0239               .enableEtaBounds = true
0240             },
0241             app   // TODO: Remove me once fixed
0242           )
0243         );
0244 
0245         app->Add(
0246           new JOmniFactoryGeneratorT<CalorimeterClusterRecoCoG_factory>(
0247              "EcalEndcapPInsertClusters",
0248             {"EcalEndcapPInsertIslandProtoClusters",  // edm4eic::ProtoClusterCollection
0249 #if EDM4EIC_VERSION_MAJOR >= 7
0250              "EcalEndcapPInsertRawHitAssociations"},  // edm4eic::MCRecoCalorimeterHitCollection
0251 #else
0252              "EcalEndcapPInsertHits"},                // edm4hep::SimCalorimeterHitCollection
0253 #endif
0254             {"EcalEndcapPInsertClusters",             // edm4eic::Cluster
0255              "EcalEndcapPInsertClusterAssociations"}, // edm4eic::MCRecoClusterParticleAssociation
0256             {
0257               .energyWeight = "log",
0258               .sampFrac = 1.0,
0259               .logWeightBase = 3.6,
0260               .enableEtaBounds = false,
0261             },
0262             app   // TODO: Remove me once fixed
0263           )
0264         );
0265 
0266     }
0267 }