Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:28:06

0001 // Copyright (C) 2022, 2023, Christopher Dilks, Luigi Dello Stritto
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 // SPDX-License-Identifier: LGPL-3.0-or-later
0005 // Copyright (C) 2024, Dmitry Kalinkin
0006 
0007 #include <DD4hep/DetElement.h>
0008 #include <DD4hep/Detector.h>
0009 #include <Evaluator/DD4hepUnits.h>
0010 #include <JANA/JApplication.h>
0011 #include <JANA/JApplicationFwd.h>
0012 #include <JANA/Utils/JTypeInfo.h>
0013 #include <functional>
0014 #include <map>
0015 #include <memory>
0016 #include <string>
0017 #include <utility>
0018 #include <variant>
0019 #include <vector>
0020 
0021 // algorithm configurations
0022 #include "algorithms/digi/PhotoMultiplierHitDigiConfig.h"
0023 #include "algorithms/pid/IrtCherenkovParticleIDConfig.h"
0024 #include "algorithms/pid/MergeParticleIDConfig.h"
0025 #include "algorithms/tracking/TrackPropagationConfig.h"
0026 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0027 // factories
0028 #include "factories/digi/PhotoMultiplierHitDigi_factory.h"
0029 #include "factories/pid/IrtCherenkovParticleID_factory.h"
0030 #include "factories/pid/MergeCherenkovParticleID_factory.h"
0031 #include "factories/pid/MergeTrack_factory.h"
0032 #include "factories/pid/RichTrack_factory.h"
0033 #include "services/geometry/richgeo/ActsGeo.h"
0034 #include "services/geometry/richgeo/RichGeo.h"
0035 #include "services/geometry/richgeo/RichGeo_service.h"
0036 
0037 extern "C" {
0038 void InitPlugin(JApplication* app) {
0039   InitJANAPlugin(app);
0040 
0041   using namespace eicrecon;
0042 
0043   // configuration parameters ///////////////////////////////////////////////
0044 
0045   // digitization
0046   PhotoMultiplierHitDigiConfig digi_cfg;
0047   digi_cfg.detectorName    = "DRICH";
0048   digi_cfg.readoutClass    = "DRICHHits";
0049   digi_cfg.hitTimeWindow   = 20.0;     // [ns]
0050   digi_cfg.timeResolution  = 1 / 16.0; // [ns]
0051   digi_cfg.speMean         = 80.0;
0052   digi_cfg.speError        = 16.0;
0053   digi_cfg.pedMean         = 200.0;
0054   digi_cfg.pedError        = 3.0;
0055   digi_cfg.enablePixelGaps = true;
0056   digi_cfg.safetyFactor    = 0.7;
0057   digi_cfg.enableNoise     = false;
0058   digi_cfg.noiseRate       = 20000;             // [Hz]
0059   digi_cfg.noiseTimeWindow = 20.0 * dd4hep::ns; // [ns]
0060   digi_cfg.quantumEfficiency.clear();
0061   digi_cfg.quantumEfficiency = {// wavelength units are [nm]
0062                                 {315, 0.00}, {325, 0.04}, {340, 0.10}, {350, 0.20}, {370, 0.30},
0063                                 {400, 0.35}, {450, 0.40}, {500, 0.38}, {550, 0.35}, {600, 0.27},
0064                                 {650, 0.20}, {700, 0.15}, {750, 0.12}, {800, 0.08}, {850, 0.06},
0065                                 {900, 0.04}, {1000, 0.00}};
0066 
0067   // Track propagation
0068   TrackPropagationConfig aerogel_track_cfg;
0069   TrackPropagationConfig gas_track_cfg;
0070 
0071   // get RICH geo service
0072   auto richGeoSvc       = app->GetService<RichGeo_service>();
0073   const auto* dd4hepGeo = richGeoSvc->GetDD4hepGeo();
0074   if (dd4hepGeo->world().children().contains("DRICH")) {
0075     const auto* actsGeo          = richGeoSvc->GetActsGeo("DRICH");
0076     auto aerogel_tracking_planes = actsGeo->TrackingPlanes(richgeo::kAerogel, 5);
0077     auto aerogel_track_point_cut = actsGeo->TrackPointCut(richgeo::kAerogel);
0078     auto gas_tracking_planes     = actsGeo->TrackingPlanes(richgeo::kGas, 10);
0079     auto gas_track_point_cut     = actsGeo->TrackPointCut(richgeo::kGas);
0080     auto filter_surface          = gas_tracking_planes.back();
0081     // track propagation to each radiator
0082     aerogel_track_cfg.filter_surfaces.push_back(filter_surface);
0083     aerogel_track_cfg.target_surfaces = aerogel_tracking_planes;
0084     aerogel_track_cfg.track_point_cut = aerogel_track_point_cut;
0085     gas_track_cfg.filter_surfaces.push_back(filter_surface);
0086     gas_track_cfg.target_surfaces = gas_tracking_planes;
0087     gas_track_cfg.track_point_cut = gas_track_point_cut;
0088   }
0089 
0090   // IRT PID
0091   IrtCherenkovParticleIDConfig irt_cfg;
0092   // - refractive index interpolation
0093   irt_cfg.numRIndexBins = 100;
0094   // - aerogel
0095   irt_cfg.radiators.insert({"Aerogel", RadiatorConfig{}});
0096   irt_cfg.radiators.at("Aerogel").referenceRIndex = 1.0260;
0097   irt_cfg.radiators.at("Aerogel").attenuation     = 48; // [mm]
0098   irt_cfg.radiators.at("Aerogel").smearingMode    = "gaussian";
0099   irt_cfg.radiators.at("Aerogel").smearing        = 2e-3; // [radians]
0100   // - gas
0101   irt_cfg.radiators.insert({"Gas", RadiatorConfig{}});
0102   irt_cfg.radiators.at("Gas").referenceRIndex = 1.00076;
0103   irt_cfg.radiators.at("Gas").attenuation     = 0; // [mm]
0104   irt_cfg.radiators.at("Gas").smearingMode    = "gaussian";
0105   irt_cfg.radiators.at("Gas").smearing        = 5e-3; // [radians]
0106   // - PDG list
0107   irt_cfg.pdgList.insert(irt_cfg.pdgList.end(), {11, 211, 321, 2212});
0108   // - cheat modes
0109   irt_cfg.cheatPhotonVertex = false;
0110   irt_cfg.cheatTrueRadiator = false;
0111 
0112   // Merge PID from radiators
0113   MergeParticleIDConfig merge_cfg;
0114   merge_cfg.mergeMode = MergeParticleIDConfig::kAddWeights;
0115 
0116   // wiring between factories and data ///////////////////////////////////////
0117 
0118   // digitization
0119   app->Add(new JOmniFactoryGeneratorT<PhotoMultiplierHitDigi_factory>(
0120       "DRICHRawHits", {"EventHeader", "DRICHHits"}, {"DRICHRawHits", "DRICHRawHitsAssociations"},
0121       digi_cfg, app));
0122 
0123   // charged particle tracks
0124   app->Add(new JOmniFactoryGeneratorT<RichTrack_factory>(
0125       "DRICHAerogelTracks",
0126       {"CentralCKFTracks", "CentralCKFActsTrajectories", "CentralCKFActsTracks"},
0127       {"DRICHAerogelTracks"}, aerogel_track_cfg, app));
0128   app->Add(new JOmniFactoryGeneratorT<RichTrack_factory>(
0129       "DRICHGasTracks", {"CentralCKFTracks", "CentralCKFActsTrajectories", "CentralCKFActsTracks"},
0130       {"DRICHGasTracks"}, gas_track_cfg, app));
0131 
0132   app->Add(new JOmniFactoryGeneratorT<MergeTrack_factory>("DRICHMergedTracks",
0133                                                           {"DRICHAerogelTracks", "DRICHGasTracks"},
0134                                                           {"DRICHMergedTracks"}, {}, app));
0135 
0136   // PID algorithm
0137   app->Add(new JOmniFactoryGeneratorT<IrtCherenkovParticleID_factory>(
0138       "DRICHIrtCherenkovParticleID",
0139       {"DRICHAerogelTracks", "DRICHGasTracks", "DRICHMergedTracks", "DRICHRawHits",
0140        "DRICHRawHitsAssociations"},
0141       {"DRICHAerogelIrtCherenkovParticleID", "DRICHGasIrtCherenkovParticleID"}, irt_cfg, app));
0142 
0143   // merge aerogel and gas PID results
0144   app->Add(new JOmniFactoryGeneratorT<MergeCherenkovParticleID_factory>(
0145       "DRICHMergedIrtCherenkovParticleID",
0146       {"DRICHAerogelIrtCherenkovParticleID", "DRICHGasIrtCherenkovParticleID"},
0147       {"DRICHMergedIrtCherenkovParticleID"}, merge_cfg, app));
0148 
0149   // clang-format on
0150 }
0151 }