Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-30 08:14:28

0001 #include <GlobalVariables.C>
0002 
0003 #include <DisplayOn.C>
0004 #include <G4Setup_sPHENIX.C>
0005 #include <G4_Global.C>
0006 #include <G4_ActsGeom.C>
0007 
0008 #include <Trkr_RecoInit.C>
0009 #include <Trkr_Clustering.C>
0010 #include <Trkr_LaserClustering.C>
0011 
0012 #include <ffamodules/HeadReco.h>
0013 #include <ffamodules/SyncReco.h>
0014 #include <ffamodules/CDBInterface.h>
0015 
0016 #include <fun4all/Fun4AllServer.h>
0017 
0018 #include <phool/PHRandomSeed.h>
0019 #include <phool/recoConsts.h>
0020 
0021 #include <g4tpc/PHG4TpcCentralMembrane.h>
0022 
0023 #include <tpccentralmembraneplotter/TpcCentralMembranePlotter.h>
0024 
0025 void Fun4All_DiffuseLaserSimulations()
0026 {
0027   auto se = Fun4AllServer::instance();
0028   auto rc = recoConsts::instance();
0029 
0030   
0031   Enable::CDB = true;
0032   rc->set_StringFlag("CDB_GLOBALTAG",CDB::global_tag);
0033   rc->set_uint64Flag("TIMESTAMP",CDB::timestamp);
0034   rc->set_IntFlag("RUNNUMBER", 1);
0035 
0036   SyncReco *sync = new SyncReco();
0037   se->registerSubsystem(sync);
0038 
0039   HeadReco *head = new HeadReco();
0040   se->registerSubsystem(head);
0041 
0042   // Build active TPC geometry and create G4HIT_TPC.
0043   
0044   Enable::MVTX = true;
0045   Enable::INTT = true;
0046   Enable::TPC = true;
0047   Enable::MICROMEGAS = true;
0048 
0049   Enable::MVTX_CELL = false;
0050   Enable::INTT_CELL = false;
0051   Enable::TPC_CELL = true;
0052   Enable::MICROMEGAS_CELL = false;
0053 
0054   Enable::TPC_ENDCAP = false;
0055 
0056 
0057   G4TPC::ENABLE_CENTRAL_MEMBRANE_HITS = true;
0058   G4TPC::ENABLE_CENTRAL_MEMBRANE_CLUSTERING = true;
0059 
0060   // Generate central membrane diffuse laser G4 hits.
0061   G4TPC::ENABLE_CENTRAL_MEMBRANE_HITS = true;
0062 
0063   // Enable diffuse laser clustering.
0064   G4TPC::ENABLE_CENTRAL_MEMBRANE_CLUSTERING = true;
0065   G4TPC::LaserClusteringSequential = false;
0066   G4TPC::laserClusterFitting = false;
0067   G4TPC::laser_adc_threshold = 100.0;
0068 
0069 
0070   TRACKING::streaming_mode = true; // need this to allow for long enough readout window to read laser pulse
0071 
0072 
0073   // Configure and register Geant4 detector geometry.
0074   G4Init();
0075   G4Setup();
0076 
0077   auto centralMembrane = new PHG4TpcCentralMembrane;
0078   centralMembrane->setCentralMembraneDelay(4200); // delay 4.2 microseconds to put laser flash in t bin to match data
0079   centralMembrane->setCentralMembraneEventModulo(1);
0080   centralMembrane->set_int_param("electrons_per_stripe", 100);
0081   se->registerSubsystem(centralMembrane);
0082 
0083   auto* padplane = new PHG4TpcPadPlaneReadout;
0084   padplane->Verbosity(0);
0085   padplane->set_int_param("ntpc_phibins_inner", G4TPC::tpc_layer_rphi_count_inner);
0086   //  padplane->SetDriftVelocity(drift_vel);
0087 
0088   auto* edrift = new PHG4TpcElectronDrift;
0089   edrift->Detector("TPC");
0090   edrift->Verbosity(0);
0091 
0092   // if( G4TPC::ENABLE_STATIC_DISTORTIONS && G4TPC::static_distortion_filename.empty() )
0093   // {
0094   //   G4TPC::static_distortion_filename = CDBInterface::instance()->getUrl("TPC_STATIC_DISTORTION");
0095   // }
0096 
0097   // if( G4TPC::ENABLE_TIME_ORDERED_DISTORTIONS && G4TPC::time_ordered_distortion_filename.empty() )
0098   // {
0099   //   G4TPC::time_ordered_distortion_filename = CDBInterface::instance()->getUrl("TPC_TIMEORDERED_DISTORTION");
0100   // }
0101 
0102   // if (G4TPC::ENABLE_STATIC_DISTORTIONS || G4TPC::ENABLE_TIME_ORDERED_DISTORTIONS)
0103   // {
0104   //   auto* distortionMap = new PHG4TpcDistortion;
0105 
0106   //   distortionMap->set_read_phi_as_radians(G4TPC::DISTORTIONS_USE_PHI_AS_RADIANS);
0107 
0108   //   distortionMap->set_do_static_distortions(G4TPC::ENABLE_STATIC_DISTORTIONS);
0109   //   distortionMap->set_static_distortion_filename(G4TPC::static_distortion_filename);
0110 
0111   //   distortionMap->set_do_time_ordered_distortions(G4TPC::ENABLE_TIME_ORDERED_DISTORTIONS);
0112   //   distortionMap->set_time_ordered_distortion_filename(G4TPC::time_ordered_distortion_filename);
0113 
0114   //   distortionMap->set_do_ReachesReadout(G4TPC::ENABLE_REACHES_READOUT);
0115   //   distortionMap->Init();
0116   //   edrift->setTpcDistortion(distortionMap);
0117   // }
0118 
0119   // fudge factors to get drphi 150 microns (in mid and outer Tpc) and dz 500 microns cluster resolution
0120   // They represent effects not due to ideal gas properties and ideal readout plane behavior
0121   // defaults are 0.085 and 0.105, they can be changed here to get a different resolution
0122   edrift->set_double_param("added_smear_trans", 0.085);
0123   edrift->set_double_param("added_smear_long", 0.105);
0124   edrift->set_double_param("added_smear_trans", G4TPC::tpc_added_smear_trans);
0125   edrift->set_double_param("added_smear_long", G4TPC::tpc_added_smear_long);
0126   edrift->set_double_param("diffusion_long", G4TPC::ArCF4Isobutane_diffusion_long);
0127   edrift->set_double_param("diffusion_trans", G4TPC::ArCF4Isobutane_diffusion_trans);
0128   edrift->set_double_param("Ne_frac", G4TPC::ArCF4Isobutane_Ne_frac);
0129   edrift->set_double_param("Ar_frac", G4TPC::ArCF4Isobutane_Ar_frac);
0130   edrift->set_double_param("CF4_frac", G4TPC::ArCF4Isobutane_CF4_frac);
0131   edrift->set_double_param("N2_frac", G4TPC::ArCF4Isobutane_N2_frac);
0132   edrift->set_double_param("isobutane_frac", G4TPC::ArCF4Isobutane_isobutane_frac);
0133 
0134 
0135   edrift->registerPadPlane(padplane);
0136   se->registerSubsystem(edrift);
0137 
0138   // Tpc digitizer
0139   //=========
0140   PHG4TpcDigitizer* digitpc = new PHG4TpcDigitizer();
0141   digitpc->SetTpcMinLayer(G4MVTX::n_maps_layer + G4INTT::n_intt_layer);
0142   double ENC = 670.0;  // standard
0143   digitpc->SetENC(ENC);
0144   double ADC_threshold = 4.0 * ENC;
0145   digitpc->SetADCThreshold(ADC_threshold);  // 4 * ENC seems OK
0146   digitpc->Verbosity(0);
0147   std::cout << " Tpc digitizer: Setting ENC to " << ENC << " ADC threshold to " << ADC_threshold
0148             << " maps+Intt layers set to " << G4MVTX::n_maps_layer + G4INTT::n_intt_layer << std::endl;
0149   digitpc->set_skip_noise_flag(false);
0150   se->registerSubsystem(digitpc);
0151 
0152   
0153 
0154   // Acts geometry must be registered before LaserEventIdentifier.
0155   ACTSGEOM::ActsGeomInit();
0156 
0157   // Identify diffuse laser events from digitized TPC hits.
0158   G4TPC::laser_event_debug_filename = "LaserEventIdentifier_debug.root";
0159   Enable::TPC_VERBOSITY = 2; 
0160   TRACKING::reco_tpc_maxtime_sample = 425;
0161   Tpc_LaserEventIdentifying();
0162 
0163   // Cluster diffuse laser hits into LASER_CLUSTER.
0164   LaserClusterizer *laserClusterizer = new LaserClusterizer;
0165   laserClusterizer->Verbosity(1);
0166   laserClusterizer->set_max_time_samples(TRACKING::reco_tpc_maxtime_sample);
0167   laserClusterizer->set_adc_threshold(0);
0168   laserClusterizer->set_do_sequential(G4TPC::LaserClusteringSequential);
0169   laserClusterizer->set_do_fitting(G4TPC::laserClusterFitting);
0170   se->registerSubsystem(laserClusterizer);
0171 
0172   TString out_DST = "DST_LASER_CLUSTER_SIMULATIONS.root";
0173   std::string theOutDST = out_DST.Data();
0174 
0175   Fun4AllOutputManager *out = new Fun4AllDstOutputManager("out",theOutDST);
0176   out->AddNode("Sync");
0177   out->AddNode("EventHeader");
0178   out->AddNode("GL1RAWHIT");
0179   out->AddNode("LaserEventInfo");
0180   out->AddNode("LASER_CLUSTER");
0181   se->registerOutputManager(out);
0182 
0183   auto centralmembraneplotter = new TpcCentralMembranePlotter;
0184   centralmembraneplotter->Verbosity(0);
0185   centralmembraneplotter->setOutputfile("centralmembraneclusters.root");
0186   se->registerSubsystem(centralmembraneplotter);
0187 
0188   se->run(1);
0189   se->End();
0190 
0191   gSystem->Exit(0);
0192 }