Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 07:53:40

0001 // Copyright 2022, Dmitry Romanov
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 //
0004 //
0005 
0006 #include <Evaluator/DD4hepUnits.h>
0007 #include <JANA/JApplication.h>
0008 #include <JANA/JException.h>
0009 #include <stdexcept>
0010 #include <string>
0011 
0012 #include "algorithms/interfaces/WithPodConfig.h"
0013 #include "extensions/jana/JOmniFactoryGeneratorT.h"
0014 #include "factories/digi/MPGDTrackerDigi_factory.h"
0015 #include "factories/digi/SiliconTrackerDigi_factory.h"
0016 #include "factories/tracking/TrackerHitReconstruction_factory.h"
0017 
0018 // 2D-STRIP DIGITIZATION = DEFAULT
0019 // - Is produced by "MPGDTrackerDigi".
0020 // - Relies on "MultiSegmentation" <readout> in "compact" geometry file.
0021 // PIXEL DIGITIZATION = BROUGHT INTO PLAY BY OPTION "MPGD:SiFactoryPattern".
0022 // - Is produced by "SiliconTrackerDigi".
0023 
0024 extern "C" {
0025 void InitPlugin(JApplication* app) {
0026   InitJANAPlugin(app);
0027 
0028   using namespace eicrecon;
0029 
0030   // PIXEL DIGITIZATION?
0031   // It's encoded in bit pattern "SiFactoryPattern": 0x1=CyMBaL, 0x2=OuterBarrel, ...
0032   // unsigned int SiFactoryPattern = 0x0; // no SiliconTrackerDigi
0033   unsigned int SiFactoryPattern = 0x3; // using SiliconTrackerDigi
0034   std::string SiFactoryPattern_str;
0035   app->SetDefaultParameter("MPGD:SiFactoryPattern", SiFactoryPattern_str,
0036                            "Hexadecimal Pattern of MPGDs digitized via \"SiliconTrackerDigi\"");
0037   if (!SiFactoryPattern_str.empty()) {
0038     try {
0039       SiFactoryPattern = std::stoul(SiFactoryPattern_str, nullptr, 16);
0040     } catch (const std::invalid_argument& e) {
0041       throw JException(
0042           R"(Option "MPGD:SiFactoryPattern": Error ("%s") parsing input
0043         string: '%s')",
0044           e.what(), SiFactoryPattern_str.c_str());
0045     }
0046   }
0047 
0048   // ***** "MPGDBarrel" (=CyMBaL)
0049   // Digitization
0050   if ((SiFactoryPattern & 0x1) != 0U) {
0051     app->Add(new JOmniFactoryGeneratorT<SiliconTrackerDigi_factory>(
0052         "MPGDBarrelRawHits", {"MPGDBarrelHits"},
0053         {"MPGDBarrelRawHits", "MPGDBarrelRawHitAssociations"},
0054         {
0055             .threshold      = 100 * dd4hep::eV,
0056             .timeResolution = 10,
0057         },
0058         app));
0059   } else {
0060     app->Add(new JOmniFactoryGeneratorT<MPGDTrackerDigi_factory>(
0061         "MPGDBarrelRawHits", {"MPGDBarrelHits"},
0062         {"MPGDBarrelRawHits", "MPGDBarrelRawHitAssociations"},
0063         {
0064             .readout        = "MPGDBarrelHits",
0065             .threshold      = 100 * dd4hep::eV,
0066             .timeResolution = 10,
0067         },
0068         app));
0069   }
0070 
0071   // Convert raw digitized hits into hits with geometry info (ready for tracking)
0072   app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
0073       "MPGDBarrelRecHits", {"MPGDBarrelRawHits"}, // Input data collection tags
0074       {"MPGDBarrelRecHits"},                      // Output data tag
0075       {
0076           .timeResolution = 10,
0077       },
0078       app));
0079 
0080   // ***** OuterMPGDBarrel
0081   // Digitization
0082   if ((SiFactoryPattern & 0x2) != 0U) {
0083     app->Add(new JOmniFactoryGeneratorT<SiliconTrackerDigi_factory>(
0084         "OuterMPGDBarrelRawHits", {"OuterMPGDBarrelHits"},
0085         {"OuterMPGDBarrelRawHits", "OuterMPGDBarrelRawHitAssociations"},
0086         {
0087             .threshold      = 100 * dd4hep::eV,
0088             .timeResolution = 10,
0089         },
0090         app));
0091   } else {
0092     app->Add(new JOmniFactoryGeneratorT<MPGDTrackerDigi_factory>(
0093         "OuterMPGDBarrelRawHits", {"OuterMPGDBarrelHits"},
0094         {"OuterMPGDBarrelRawHits", "OuterMPGDBarrelRawHitAssociations"},
0095         {
0096             .readout        = "OuterMPGDBarrelHits",
0097             .threshold      = 100 * dd4hep::eV,
0098             .timeResolution = 10,
0099         },
0100         app));
0101   }
0102 
0103   // Convert raw digitized hits into hits with geometry info (ready for tracking)
0104   app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
0105       "OuterMPGDBarrelRecHits", {"OuterMPGDBarrelRawHits"}, // Input data collection tags
0106       {"OuterMPGDBarrelRecHits"},                           // Output data tag
0107       {
0108           .timeResolution = 10,
0109       },
0110       app));
0111 
0112   // ***** "BackwardMPGDEndcap"
0113   // Digitization
0114   app->Add(new JOmniFactoryGeneratorT<SiliconTrackerDigi_factory>(
0115       "BackwardMPGDEndcapRawHits", {"BackwardMPGDEndcapHits"},
0116       {"BackwardMPGDEndcapRawHits", "BackwardMPGDEndcapRawHitAssociations"},
0117       {
0118           .threshold      = 100 * dd4hep::eV,
0119           .timeResolution = 10,
0120       },
0121       app));
0122 
0123   // Convert raw digitized hits into hits with geometry info (ready for tracking)
0124   app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
0125       "BackwardMPGDEndcapRecHits", {"BackwardMPGDEndcapRawHits"}, // Input data collection tags
0126       {"BackwardMPGDEndcapRecHits"},                              // Output data tag
0127       {
0128           .timeResolution = 10,
0129       },
0130       app));
0131 
0132   // ""ForwardMPGDEndcap"
0133   // Digitization
0134   app->Add(new JOmniFactoryGeneratorT<SiliconTrackerDigi_factory>(
0135       "ForwardMPGDEndcapRawHits", {"ForwardMPGDEndcapHits"},
0136       {"ForwardMPGDEndcapRawHits", "ForwardMPGDEndcapRawHitAssociations"},
0137       {
0138           .threshold      = 100 * dd4hep::eV,
0139           .timeResolution = 10,
0140       },
0141       app));
0142 
0143   // Convert raw digitized hits into hits with geometry info (ready for tracking)
0144   app->Add(new JOmniFactoryGeneratorT<TrackerHitReconstruction_factory>(
0145       "ForwardMPGDEndcapRecHits", {"ForwardMPGDEndcapRawHits"}, // Input data collection tags
0146       {"ForwardMPGDEndcapRecHits"},                             // Output data tag
0147       {
0148           .timeResolution = 10,
0149       },
0150       app));
0151 }
0152 } // extern "C"