Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:13

0001 void ConfigureInput(TString inputFile) {
0002   const bool hijing = true;
0003   const bool genera = true;
0004 
0005   Fun4AllServer *se = Fun4AllServer::instance();
0006 
0007   if(hijing) {
0008     HepMCNodeReader *hr = new HepMCNodeReader();
0009     //hr->SmearVertex(0.0,0.0,-5.0); // optional
0010     se->registerSubsystem(hr);
0011     Fun4AllInputManager *in = new Fun4AllHepMCInputManager( "DSTIN" );
0012     se->registerInputManager( in );
0013     in->fileopen( inputFile.Data() ); //fileopen only after you register!
0014   }
0015 
0016   if(genera) {
0017     PHG4SimpleEventGenerator *gen = new PHG4SimpleEventGenerator( "PIONS" );
0018     gen->add_particles("pi-",5); // mu+,e+,proton,pi+,Upsilon
0019     gen->add_particles("pi+",5); // mu-,e-,anti_proton,pi-
0020     if(hijing) {
0021       gen->set_reuse_existing_vertex(true);
0022       gen->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0023     } else {
0024       gen->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform,
0025                         PHG4SimpleEventGenerator::Uniform,
0026                         PHG4SimpleEventGenerator::Uniform);
0027       gen->set_vertex_distribution_mean(0.0, 0.0, 0.0);
0028       gen->set_vertex_distribution_width(0.0, 0.0, 0.0);
0029     }
0030     gen->set_vertex_size_function(PHG4SimpleEventGenerator::Uniform);
0031     gen->set_vertex_size_parameters(0.0, 0.0);
0032     gen->set_eta_range(-1.1,+1.1);
0033     gen->set_phi_range(-1.0 * TMath::Pi(), 1.0 * TMath::Pi());
0034     gen->set_pt_range(0.2, 39.0);
0035     gen->Embed(1);
0036     gen->Verbosity(0);
0037 
0038     se->registerSubsystem(gen);
0039   }
0040 }
0041 void RandomSeed() {
0042   // By default every random number generator uses
0043   // PHRandomSeed() which reads /dev/urandom to get its seed
0044   // if the RANDOMSEED flag is set its value is taken as seed
0045   // You ca neither set this to a random value using PHRandomSeed()
0046   // which will make all seeds identical (not sure what the point of
0047   // this would be:
0048   // or set it to a fixed value so you can debug your code
0049 
0050   recoConsts *rc = recoConsts::instance();
0051   //  rc->set_IntFlag("RANDOMSEED",PHRandomSeed());
0052   //  rc->set_IntFlag("RANDOMSEED", 12345);
0053 }
0054 void ConfigureDetectors() {
0055   bool do_magnet = true;
0056   bool do_svtx = true;
0057   bool do_preshower = false;
0058   bool do_cemc = false;
0059   bool do_hcalin = false;
0060   bool do_hcalout = false;
0061   bool do_pipe = true;
0062   G4Init(do_svtx,do_preshower,do_cemc,do_hcalin,do_magnet,do_hcalout,do_pipe);
0063 
0064   int absorberactive = 1; // set to 1 to make all absorbers active volumes
0065   //  const string magfield = "1.5"; // if like float -> solenoidal field in T, if string use as fieldmap name (including path)
0066   const string magfield = "/phenix/upgrades/decadal/fieldmaps/sPHENIX.2d.root"; // if like float -> solenoidal field in T, if string use as fieldmap name (including path)
0067   const float magfield_rescale = 1.4/1.5; // scale the map to a 1.4 T field
0068 
0069   bool do_svtx_cell = do_svtx && true;
0070   bool do_svtx_track = do_svtx_cell && true;
0071   bool do_svtx_eval = do_svtx_track && false;
0072 
0073   bool do_bbc = true;
0074   bool do_cemc_cell = do_cemc && true;
0075   bool do_cemc_twr = do_cemc_cell && true;
0076   bool do_cemc_cluster = do_cemc_twr && true;
0077   bool do_cemc_eval = do_cemc_cluster && true;
0078   bool do_hcalin_cell = do_hcalin && true;
0079   bool do_hcalin_twr = do_hcalin_cell && true;
0080   bool do_hcalin_cluster = do_hcalin_twr && true;
0081   bool do_hcalin_eval = do_hcalin_cluster && true;
0082   bool do_hcalout_cell = do_hcalout && true;
0083   bool do_hcalout_twr = do_hcalout_cell && true;
0084   bool do_hcalout_cluster = do_hcalout_twr && true;
0085   bool do_hcalout_eval = do_hcalout_cluster && true;
0086   bool do_global = true;
0087   bool do_global_fastsim = true;
0088   bool do_jet_reco = false;
0089   bool do_jet_eval = false;
0090   bool do_dst_compress = false;
0091   bool do_DSTReader = false;
0092  
0093   G4Setup(absorberactive, magfield, TPythia6Decayer::kAll,
0094       do_svtx, do_preshower, do_cemc, do_hcalin, do_magnet,
0095       do_hcalout, do_pipe, magfield_rescale);
0096   if (do_bbc) {
0097     gROOT->LoadMacro("G4_Bbc.C");
0098     BbcInit();
0099     Bbc_Reco();
0100   }
0101   if (do_svtx_cell) Svtx_Cells();
0102   if (do_cemc_cell) CEMC_Cells();
0103   if (do_hcalin_cell) HCALInner_Cells();
0104   if (do_hcalout_cell) HCALOuter_Cells();
0105   if (do_cemc_twr) CEMC_Towers();
0106   if (do_cemc_cluster) CEMC_Clusters();
0107   if (do_hcalin_twr) HCALInner_Towers();
0108   if (do_hcalin_cluster) HCALInner_Clusters();
0109   if (do_hcalout_twr) HCALOuter_Towers();
0110   if (do_hcalout_cluster) HCALOuter_Clusters();
0111   if (do_dst_compress) ShowerCompress();
0112   if (do_svtx_track) Svtx_Reco();
0113   if (do_global)  {
0114     gROOT->LoadMacro("G4_Global.C");
0115     Global_Reco();
0116   } else if (do_global_fastsim) {
0117     gROOT->LoadMacro("G4_Global.C");
0118     Global_FastSim();
0119   }
0120   if (do_jet_reco) {
0121     gROOT->LoadMacro("G4_Jets.C");
0122     Jet_Reco();
0123   }
0124   if (do_svtx_eval) Svtx_Eval("g4svtx_eval.root");
0125   if (do_cemc_eval) CEMC_Eval("g4cemc_eval.root");
0126   if (do_hcalin_eval) HCALInner_Eval("g4hcalin_eval.root");
0127   if (do_hcalout_eval) HCALOuter_Eval("g4hcalout_eval.root");
0128   if (do_jet_eval) Jet_Eval("g4jet_eval.root");
0129 
0130 }
0131 void Libraries() {
0132   gSystem->Load("libfun4all.so");
0133   gSystem->Load("libg4detectors.so");
0134   gSystem->Load("libphhepmc.so");
0135   gSystem->Load("libg4testbench.so");
0136   gSystem->Load("libg4hough.so");
0137   gSystem->Load("libg4calo.so");
0138   gSystem->Load("libg4eval.so");
0139   gSystem->Load("libTrackingPerformanceCheck.so");
0140   gROOT->LoadMacro("G4Setup_sPHENIX.C");
0141 }
0142 
0143 int Fun( const int nEvents = 1,
0144      const int nFile = 0 ) {
0145   if(nEvents < 0) return;
0146   TStopwatch time;
0147   time.Start();
0148   Libraries();
0149 
0150   TString inputFile = Form("/gpfs/mnt/gpfs02/phenix/hhj/hhj1/frawley/tracking/stage1_jobs/in/hijing_%05d.txt.bz2",nFile);
0151   //TString outputFile = Form("output/output_%05d.root",nFile);
0152   TString outputFile = Form("output_%05d.root",nFile);
0153 
0154   Fun4AllServer *se = Fun4AllServer::instance();
0155   se->Verbosity(0);
0156 
0157   RandomSeed();
0158   ConfigureInput(inputFile);
0159   ConfigureDetectors();
0160 
0161   //ADDTASKS
0162   TrackingPerformanceCheck *revperf = new TrackingPerformanceCheck();
0163   revperf->SetLayerTPCBegins(7);
0164   revperf->SetReconstructableTPCHits(30);
0165   revperf->SetFairClustersContribution(20);
0166   revperf->SetGoodTrackChi2NDF(2.0);
0167   revperf->SetGoodTrackTPCClusters(20);
0168   se->registerSubsystem(revperf);
0169 
0170   std::cout << "RUNNING..." << std::endl;
0171   //se->Print();
0172   se->run(nEvents);
0173   se->dumpHistos(outputFile.Data());
0174   se->End();
0175   std::cout << "ALL DONE" << std::endl;
0176   time.Stop();
0177   time.Print();
0178   delete se;
0179   gSystem->Exit(0);
0180 }