Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:17:52

0001 // Copyright 2022, Dmitry Romanov
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 //
0004 
0005 // SPDX-License-Identifier: LGPL-3.0-or-later
0006 // Copyright (C) 2024, Dmitry Kalinkin
0007 
0008 #include <Evaluator/DD4hepUnits.h>
0009 #include <JANA/JApplication.h>
0010 #include <JANA/JApplicationFwd.h>
0011 #include <JANA/Utils/JTypeInfo.h>
0012 #include <TMath.h>
0013 #include <edm4eic/unit_system.h>
0014 #include <edm4hep/SimTrackerHit.h>
0015 #include <cmath>
0016 #include <map>
0017 #include <memory>
0018 #include <string>
0019 #include <vector>
0020 
0021 #include "algorithms/digi/SiliconChargeSharingConfig.h"
0022 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0023 #include "factories/digi/CFDROCDigitization_factory.h"
0024 #include "factories/digi/PulseCombiner_factory.h"
0025 #include "factories/digi/PulseGeneration_factory.h"
0026 #include "factories/digi/SiliconChargeSharing_factory.h"
0027 #include "factories/digi/SiliconPulseDiscretization_factory.h"
0028 #include "factories/digi/SiliconTrackerDigi_factory.h"
0029 #include "factories/tracking/TrackerHitReconstruction_factory.h"
0030 
0031 extern "C" {
0032 void InitPlugin(JApplication* app) {
0033   InitJANAPlugin(app);
0034 
0035   using namespace eicrecon;
0036 
0037   // Digitization
0038   app->Add(new JOmniFactoryGeneratorT<SiliconTrackerDigi_factory>(
0039       "TOFBarrelRawHits", {"EventHeader", "TOFBarrelHits"},
0040       {"TOFBarrelRawHits", "TOFBarrelRawHitAssociations"},
0041       {
0042           .threshold      = 6.0 * dd4hep::keV,
0043           .timeResolution = 0.025, // [ns]
0044       },
0045       app));
0046 
0047   // Convert raw digitized hits into hits with geometry info (ready for tracking)
0048   app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
0049       "TOFBarrelRecHits", {"TOFBarrelRawHits"}, // Input data collection tags
0050       {"TOFBarrelRecHits"},                     // Output data tag
0051       {
0052           .timeResolution = 10,
0053       },
0054       app)); // Hit reco default config for factories
0055 
0056   app->Add(new JOmniFactoryGeneratorT<SiliconChargeSharing_factory>(
0057       "TOFBarrelSharedHits", {"TOFBarrelHits"}, {"TOFBarrelSharedHits"},
0058       {
0059           .sigma_mode     = SiliconChargeSharingConfig::ESigmaMode::rel,
0060           .sigma_sharingx = 1,
0061           .sigma_sharingy = 0.5,
0062           .min_edep       = 0.0 * edm4eic::unit::GeV,
0063           .readout        = "TOFBarrelHits",
0064       },
0065       app));
0066 
0067   // calculation of the extreme values for Landau distribution can be found on lin 514-520 of
0068   // https://root.cern.ch/root/html524/src/TMath.cxx.html#fsokrB Landau reaches minimum for mpv =
0069   // 0 and sigma = 1 at x = -0.22278
0070   const double x_when_landau_min = -0.22278;
0071   const double landau_min        = TMath::Landau(x_when_landau_min, 0, 1, true);
0072   const double sigma_analog      = 0.293951 * edm4eic::unit::ns;
0073   const double Vm                = 3e-4 * dd4hep::GeV;
0074   const double adc_range         = 256;
0075   // gain is set such that pulse reaches a height of adc_range when EDep = Vm
0076   // gain is negative as LGAD voltage is always negative
0077   const double gain = -adc_range / Vm / landau_min * sigma_analog;
0078   const int offset  = 3;
0079   app->Add(new JOmniFactoryGeneratorT<PulseGeneration_factory<edm4hep::SimTrackerHit>>(
0080       "LGADPulseGeneration", {"TOFBarrelSharedHits"}, {"TOFBarrelSmoothPulses"},
0081       {
0082           .pulse_shape_function = "LandauPulse",
0083           .pulse_shape_params   = {gain, sigma_analog, offset},
0084           .ignore_thres         = 0.05 * adc_range,
0085           .timestep             = 0.01 * edm4eic::unit::ns,
0086       },
0087       app));
0088 
0089   app->Add(new JOmniFactoryGeneratorT<PulseCombiner_factory>(
0090       "TOFBarrelPulseCombiner", {"TOFBarrelSmoothPulses"}, {"TOFBarrelCombinedPulses"},
0091       {
0092           .minimum_separation = 25 * edm4eic::unit::ns,
0093       },
0094       app));
0095 
0096   double risetime = 0.45 * edm4eic::unit::ns;
0097   app->Add(new JOmniFactoryGeneratorT<SiliconPulseDiscretization_factory>(
0098       "SiliconPulseDiscretization", {"TOFBarrelCombinedPulses"}, {"TOFBarrelPulses"},
0099       {
0100           .EICROC_period = 25 * edm4eic::unit::ns,
0101           .local_period  = 25 * edm4eic::unit::ns / 1024,
0102           .global_offset = -offset * sigma_analog + risetime,
0103       },
0104       app));
0105 
0106   app->Add(new JOmniFactoryGeneratorT<CFDROCDigitization_factory>(
0107       "CFDROCDigitization", {"TOFBarrelPulses"}, {"TOFBarrelADCTDC"}, {}, app));
0108 }
0109 } // extern "C"