Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-15 08:16:19

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/JApplicationFwd.h>
0010 #include <TMath.h>
0011 #include <edm4eic/unit_system.h>
0012 #include <memory>
0013 
0014 #include "algorithms/interfaces/WithPodConfig.h"
0015 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0016 #include "factories/digi/EICROCDigitization_factory.h"
0017 #include "factories/digi/PulseCombiner_factory.h"
0018 #include "factories/digi/SiliconChargeSharing_factory.h"
0019 #include "factories/digi/SiliconPulseDiscretization_factory.h"
0020 #include "factories/digi/SiliconPulseGeneration_factory.h"
0021 #include "factories/digi/SiliconTrackerDigi_factory.h"
0022 #include "factories/tracking/TrackerHitReconstruction_factory.h"
0023 
0024 extern "C" {
0025 void InitPlugin(JApplication* app) {
0026   InitJANAPlugin(app);
0027 
0028   using namespace eicrecon;
0029 
0030   // Digitization
0031   app->Add(new JOmniFactoryGeneratorT<SiliconTrackerDigi_factory>(
0032       "TOFBarrelRawHits", {"TOFBarrelHits"}, {"TOFBarrelRawHits", "TOFBarrelRawHitAssociations"},
0033       {
0034           .threshold      = 6.0 * dd4hep::keV,
0035           .timeResolution = 0.025, // [ns]
0036       },
0037       app));
0038 
0039   // Convert raw digitized hits into hits with geometry info (ready for tracking)
0040   app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
0041       "TOFBarrelRecHits", {"TOFBarrelRawHits"}, // Input data collection tags
0042       {"TOFBarrelRecHits"},                     // Output data tag
0043       {
0044           .timeResolution = 10,
0045       },
0046       app)); // Hit reco default config for factories
0047 
0048   app->Add(new JOmniFactoryGeneratorT<SiliconChargeSharing_factory>(
0049       "TOFBarrelSharedHits", {"TOFBarrelHits"}, {"TOFBarrelSharedHits"},
0050       {
0051           .sigma_sharingx = 0.1 * dd4hep::cm,
0052           .sigma_sharingy = 0.5 * dd4hep::cm,
0053           .min_edep       = 0.0 * edm4eic::unit::GeV,
0054           .readout        = "TOFBarrelHits",
0055       },
0056       app));
0057 
0058   // calculation of the extreme values for Landau distribution can be found on lin 514-520 of
0059   // https://root.cern.ch/root/html524/src/TMath.cxx.html#fsokrB Landau reaches minimum for mpv =
0060   // 0 and sigma = 1 at x = -0.22278
0061   const double x_when_landau_min = -0.22278;
0062   const double landau_min        = TMath::Landau(x_when_landau_min, 0, 1, true);
0063   const double sigma_analog      = 0.293951 * edm4eic::unit::ns;
0064   const double Vm                = 1e-4 * dd4hep::GeV;
0065   const double adc_range         = 256;
0066   // gain is set such that pulse reaches a height of adc_range when EDep = Vm
0067   // gain is negative as LGAD voltage is always negative
0068   const double gain = -adc_range / Vm / landau_min;
0069   const int offset  = 3;
0070   app->Add(new JOmniFactoryGeneratorT<SiliconPulseGeneration_factory>(
0071       "LGADPulseGeneration", {"TOFBarrelSharedHits"}, {"TOFBarrelSmoothPulses"},
0072       {
0073           .pulse_shape_function = "LandauPulse",
0074           .pulse_shape_params   = {gain, sigma_analog, offset * sigma_analog},
0075           .ignore_thres         = 0.05 * adc_range,
0076           .timestep             = 0.01 * edm4eic::unit::ns,
0077       },
0078       app));
0079 
0080   app->Add(new JOmniFactoryGeneratorT<PulseCombiner_factory>(
0081       "TOFBarrelPulseCombiner", {"TOFBarrelSmoothPulses"}, {"TOFBarrelCombinedPulses"},
0082       {
0083           .minimum_separation = 25 * edm4eic::unit::ns,
0084       },
0085       app));
0086 
0087   double risetime = 0.45 * edm4eic::unit::ns;
0088   app->Add(new JOmniFactoryGeneratorT<SiliconPulseDiscretization_factory>(
0089       "SiliconPulseDiscretization", {"TOFBarrelCombinedPulses"}, {"TOFBarrelPulses"},
0090       {
0091           .EICROC_period = 25 * edm4eic::unit::ns,
0092           .local_period  = 25 * edm4eic::unit::ns / 1024,
0093           .global_offset = -offset * sigma_analog + risetime,
0094       },
0095       app));
0096 
0097   app->Add(new JOmniFactoryGeneratorT<EICROCDigitization_factory>(
0098       "EICROCDigitization", {"TOFBarrelPulses"}, {"TOFBarrelADCTDC"}, {}, app));
0099 }
0100 } // extern "C"