Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:13:12

0001 #ifndef MACRO_FUN4ALLG4SPHENIX_C
0002 #define MACRO_FUN4ALLG4SPHENIX_C
0003 
0004 // -- c++ includes --
0005 #include <fstream>
0006 // c++ includes --
0007 // -- root includes --
0008 #include <TSystem.h>
0009 #include <TROOT.h>
0010 // -- root includes --
0011 
0012 #include <GlobalVariables.C>
0013 #include <DisplayOn.C>
0014 #include <G4_Bbc.C>
0015 #include <G4_CaloTrigger.C>
0016 #include <G4_Centrality.C>
0017 #include <G4_DSTReader.C>
0018 #include <G4_Global.C>
0019 #include <G4_HIJetReco.C>
0020 #include <G4_Input.C>
0021 #include <G4_Jets.C>
0022 #include <G4_KFParticle.C>
0023 #include <G4_ParticleFlow.C>
0024 #include <G4_Production.C>
0025 #include <G4_TopoClusterReco.C>
0026 #include <G4_Tracking.C>
0027 #include <G4_User.C>
0028 #include <QA.C>
0029 
0030 #include <ffamodules/FlagHandler.h>
0031 #include <ffamodules/HeadReco.h>
0032 #include <ffamodules/SyncReco.h>
0033 #include <ffamodules/XploadInterface.h>
0034 
0035 #include <fun4all/Fun4AllDstOutputManager.h>
0036 #include <fun4all/Fun4AllOutputManager.h>
0037 #include <fun4all/Fun4AllServer.h>
0038 
0039 #include <phool/PHRandomSeed.h>
0040 #include <phool/recoConsts.h>
0041 
0042 #include "G4Setup_sPHENIX.C"
0043 #include "../../macro/CEmc_Spacal.C"
0044 
0045 R__LOAD_LIBRARY(libfun4all.so)
0046 R__LOAD_LIBRARY(libffamodules.so)
0047 R__LOAD_LIBRARY(libEMCalPositionDependentCalibration.so)
0048 // For HepMC Hijing
0049 // try inputFile = /sphenix/sim/sim01/sphnxpro/sHijing_HepMC/sHijing_0-12fm.dat
0050 
0051 int Fun4All_G4_sPHENIX(
0052     const int nEvents = 1,
0053     const int seed = 0,
0054     const string &calib_path="CEMC/PositionRecalibrationFull/",
0055     const string &outdir = ".",
0056     const string &inputFile = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
0057     const string &outputFile = "G4sPHENIX.root",
0058     const string &embed_input_file = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root",
0059     const int skip = 0)
0060 {
0061   Fun4AllServer *se = Fun4AllServer::instance();
0062   se->Verbosity(1);
0063 
0064   //Opt to print all random seed used for debugging reproducibility. Comment out to reduce stdout prints.
0065   PHRandomSeed::Verbosity(0);
0066 
0067   // just if we set some flags somewhere in this macro
0068   recoConsts *rc = recoConsts::instance();
0069   // By default every random number generator uses
0070   // PHRandomSeed() which reads /dev/urandom to get its seed
0071   // if the RANDOMSEED flag is set its value is taken as seed
0072   // You can either set this to a random value using PHRandomSeed()
0073   // which will make all seeds identical (not sure what the point of
0074   // this would be:
0075   //  rc->set_IntFlag("RANDOMSEED",PHRandomSeed());
0076   // or set it to a fixed value so you can debug your code
0077   //  rc->set_IntFlag("RANDOMSEED", 12345);
0078 
0079   if(seed > 0) {
0080     rc->set_IntFlag("RANDOMSEED", seed);
0081   }
0082 
0083   //===============
0084   // Input options
0085   //===============
0086   // verbosity setting (applies to all input managers)
0087   Input::VERBOSITY = 0;
0088   // First enable the input generators
0089   // Either:
0090   // read previously generated g4-hits files, in this case it opens a DST and skips
0091   // the simulations step completely. The G4Setup macro is only loaded to get information
0092   // about the number of layers used for the cell reco code
0093   //  Input::READHITS = true;
0094   INPUTREADHITS::filename[0] = inputFile;
0095   // if you use a filelist
0096   // INPUTREADHITS::listfile[0] = inputFile;
0097   // Or:
0098   // Use particle generator
0099   // And
0100   // Further choose to embed newly simulated events to a previous simulation. Not compatible with `readhits = true`
0101   // In case embedding into a production output, please double check your G4Setup_sPHENIX.C and G4_*.C consistent with those in the production macro folder
0102   // E.g. /sphenix/sim//sim01/production/2016-07-21/single_particle/spacal2d/
0103   //  Input::EMBED = true;
0104   INPUTEMBED::filename[0] = embed_input_file;
0105   // if you use a filelist
0106   //INPUTEMBED::listfile[0] = embed_input_file;
0107 
0108   Input::SIMPLE = true;
0109   // Input::SIMPLE_NUMBER = 2; // if you need 2 of them
0110   // Input::SIMPLE_VERBOSITY = 1;
0111 
0112   //  Input::PYTHIA6 = true;
0113 
0114   // Input::PYTHIA8 = true;
0115 
0116   //  Input::GUN = true;
0117   //  Input::GUN_NUMBER = 3; // if you need 3 of them
0118   // Input::GUN_VERBOSITY = 1;
0119 
0120   //D0 generator
0121   //Input::DZERO = false;
0122   //Input::DZERO_VERBOSITY = 0;
0123   //Lambda_c generator //Not ready yet
0124   //Input::LAMBDAC = false;
0125   //Input::LAMBDAC_VERBOSITY = 0;
0126   // Upsilon generator
0127   //Input::UPSILON = true;
0128   //Input::UPSILON_NUMBER = 3; // if you need 3 of them
0129   //Input::UPSILON_VERBOSITY = 0;
0130 
0131   //  Input::HEPMC = true;
0132   INPUTHEPMC::filename = inputFile;
0133 
0134   // Event pile up simulation with collision rate in Hz MB collisions.
0135   //Input::PILEUPRATE = 100e3;
0136 
0137   //-----------------
0138   // Initialize the selected Input/Event generation
0139   //-----------------
0140   // This creates the input generator(s)
0141   InputInit();
0142 
0143   //--------------
0144   // Set generator specific options
0145   //--------------
0146   // can only be set after InputInit() is called
0147 
0148   // Simple Input generator:
0149   // if you run more than one of these Input::SIMPLE_NUMBER > 1
0150   // add the settings for other with [1], next with [2]...
0151   if (Input::SIMPLE)
0152   {
0153     // particle id: https://pdg.lbl.gov/2020/reviews/rpp2020-rev-monte-carlo-numbering.pdf
0154     // photon id: 22
0155     INPUTGENERATOR::SimpleEventGenerator[0]->add_particles(22, 1);
0156     if (Input::HEPMC || Input::EMBED)
0157     {
0158       INPUTGENERATOR::SimpleEventGenerator[0]->set_reuse_existing_vertex(true);
0159       INPUTGENERATOR::SimpleEventGenerator[0]->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0160     }
0161     else
0162     {
0163       INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_function(PHG4SimpleEventGenerator::Gaus,
0164                                                                                 PHG4SimpleEventGenerator::Gaus,
0165                                                                                 PHG4SimpleEventGenerator::Gaus);
0166       INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_mean(0., 0., 0.);
0167       INPUTGENERATOR::SimpleEventGenerator[0]->set_vertex_distribution_width(0.01, 0.01, 5.);
0168     }
0169     INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(0, 1.1);
0170     INPUTGENERATOR::SimpleEventGenerator[0]->set_phi_range(-M_PI/32.0 - 0.02, M_PI/32.0 + 0.02);
0171     INPUTGENERATOR::SimpleEventGenerator[0]->set_pt_range(20, 21.);
0172 
0173     // for testing use full range
0174     // INPUTGENERATOR::SimpleEventGenerator[0]->set_eta_range(-1, 1);
0175     // INPUTGENERATOR::SimpleEventGenerator[0]->set_phi_range(-M_PI, M_PI);
0176     // INPUTGENERATOR::SimpleEventGenerator[0]->set_pt_range(5, 5);
0177   }
0178   // Upsilons
0179   // if you run more than one of these Input::UPSILON_NUMBER > 1
0180   // add the settings for other with [1], next with [2]...
0181   if (Input::UPSILON)
0182   {
0183     INPUTGENERATOR::VectorMesonGenerator[0]->add_decay_particles("e", 0);
0184     INPUTGENERATOR::VectorMesonGenerator[0]->set_rapidity_range(-1, 1);
0185     INPUTGENERATOR::VectorMesonGenerator[0]->set_pt_range(0., 10.);
0186     // Y species - select only one, last one wins
0187     INPUTGENERATOR::VectorMesonGenerator[0]->set_upsilon_1s();
0188     if (Input::HEPMC || Input::EMBED)
0189     {
0190       INPUTGENERATOR::VectorMesonGenerator[0]->set_reuse_existing_vertex(true);
0191       INPUTGENERATOR::VectorMesonGenerator[0]->set_existing_vertex_offset_vector(0.0, 0.0, 0.0);
0192     }
0193   }
0194   // particle gun
0195   // if you run more than one of these Input::GUN_NUMBER > 1
0196   // add the settings for other with [1], next with [2]...
0197   if (Input::GUN)
0198   {
0199     INPUTGENERATOR::Gun[0]->AddParticle("pi-", 0, 1, 0);
0200     INPUTGENERATOR::Gun[0]->set_vtx(0, 0, 0);
0201   }
0202 
0203   // pythia6
0204   if (Input::PYTHIA6)
0205   {
0206     //! apply sPHENIX nominal beam parameter with 2mrad crossing as defined in sPH-TRG-2020-001
0207     Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia6);
0208   }
0209   // pythia8
0210   if (Input::PYTHIA8)
0211   {
0212     //! apply sPHENIX nominal beam parameter with 2mrad crossing as defined in sPH-TRG-2020-001
0213     Input::ApplysPHENIXBeamParameter(INPUTGENERATOR::Pythia8);
0214   }
0215 
0216   //--------------
0217   // Set Input Manager specific options
0218   //--------------
0219   // can only be set after InputInit() is called
0220 
0221   if (Input::HEPMC)
0222   {
0223     //! apply sPHENIX nominal beam parameter with 2mrad crossing as defined in sPH-TRG-2020-001
0224     Input::ApplysPHENIXBeamParameter(INPUTMANAGER::HepMCInputManager);
0225 
0226     // optional overriding beam parameters
0227     //INPUTMANAGER::HepMCInputManager->set_vertex_distribution_width(100e-4, 100e-4, 8, 0);  //optional collision smear in space, time
0228     //    INPUTMANAGER::HepMCInputManager->set_vertex_distribution_mean(0,0,0,0);//optional collision central position shift in space, time
0229     // //optional choice of vertex distribution function in space, time
0230     //INPUTMANAGER::HepMCInputManager->set_vertex_distribution_function(PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus, PHHepMCGenHelper::Gaus);
0231     //! embedding ID for the event
0232     //! positive ID is the embedded event of interest, e.g. jetty event from pythia
0233     //! negative IDs are backgrounds, .e.g out of time pile up collisions
0234     //! Usually, ID = 0 means the primary Au+Au collision background
0235     //INPUTMANAGER::HepMCInputManager->set_embedding_id(Input::EmbedID);
0236     if (Input::PILEUPRATE > 0)
0237     {
0238       // Copy vertex settings from foreground hepmc input
0239       INPUTMANAGER::HepMCPileupInputManager->CopyHelperSettings(INPUTMANAGER::HepMCInputManager);
0240       // and then modify the ones you want to be different
0241       // INPUTMANAGER::HepMCPileupInputManager->set_vertex_distribution_width(100e-4,100e-4,8,0);
0242     }
0243   }
0244   if (Input::PILEUPRATE > 0)
0245   {
0246     //! apply sPHENIX nominal beam parameter with 2mrad crossing as defined in sPH-TRG-2020-001
0247     Input::ApplysPHENIXBeamParameter(INPUTMANAGER::HepMCPileupInputManager);
0248   }
0249   // register all input generators with Fun4All
0250   InputRegister();
0251 
0252   if (! Input::READHITS)
0253   {
0254     rc->set_IntFlag("RUNNUMBER",1);
0255 
0256     SyncReco *sync = new SyncReco();
0257     se->registerSubsystem(sync);
0258 
0259     HeadReco *head = new HeadReco();
0260     se->registerSubsystem(head);
0261   }
0262 // Flag Handler is always needed to read flags from input (if used)
0263 // and update our rc flags with them. At the end it saves all flags
0264 // again on the DST in the Flags node under the RUN node
0265   FlagHandler *flag = new FlagHandler();
0266   se->registerSubsystem(flag);
0267 
0268   // set up production relatedstuff
0269   //   Enable::PRODUCTION = true;
0270 
0271   //======================
0272   // Write the DST
0273   //======================
0274 
0275   //Enable::DSTOUT = true;
0276   Enable::DSTOUT_COMPRESS = false;
0277   DstOut::OutputDir = outdir;
0278   DstOut::OutputFile = outputFile;
0279 
0280   //Option to convert DST to human command readable TTree for quick poke around the outputs
0281   //  Enable::DSTREADER = true;
0282 
0283   // turn the display on (default off)
0284    //Enable::DISPLAY = true;
0285 
0286   //======================
0287   // What to run
0288   //======================
0289 
0290   // QA, main switch
0291   Enable::QA = false;
0292 
0293   // Global options (enabled for all enables subsystems - if implemented)
0294   //  Enable::ABSORBER = true;
0295   //  Enable::OVERLAPCHECK = true;
0296   //  Enable::VERBOSITY = 1;
0297 
0298   // Enable::BBC = true;
0299   // Enable::BBC_SUPPORT = true; // save hist in bbc support structure
0300   Enable::BBCFAKE = true;  // Smeared vtx and t0, use if you don't want real BBC in simulation
0301 
0302   Enable::PIPE = true;
0303   Enable::PIPE_ABSORBER = true;
0304 
0305   // central tracking
0306   Enable::MVTX = false;
0307   Enable::MVTX_CELL = Enable::MVTX && true;
0308   Enable::MVTX_CLUSTER = Enable::MVTX_CELL && true;
0309   Enable::MVTX_QA = Enable::MVTX_CLUSTER && Enable::QA && true;
0310 
0311   Enable::INTT = false;
0312 //  Enable::INTT_ABSORBER = true; // enables layerwise support structure readout
0313 //  Enable::INTT_SUPPORT = true; // enable global support structure readout
0314   Enable::INTT_CELL = Enable::INTT && true;
0315   Enable::INTT_CLUSTER = Enable::INTT_CELL && true;
0316   Enable::INTT_QA = Enable::INTT_CLUSTER && Enable::QA && true;
0317 
0318   Enable::TPC = false;
0319   Enable::TPC_ABSORBER = true;
0320   Enable::TPC_CELL = Enable::TPC && true;
0321   Enable::TPC_CLUSTER = Enable::TPC_CELL && true;
0322   Enable::TPC_QA = Enable::TPC_CLUSTER && Enable::QA && true;
0323 
0324   Enable::MICROMEGAS = false;
0325   Enable::MICROMEGAS_CELL = Enable::MICROMEGAS && true;
0326   Enable::MICROMEGAS_CLUSTER = Enable::MICROMEGAS_CELL && true;
0327   Enable::MICROMEGAS_QA = Enable::MICROMEGAS_CLUSTER && Enable::QA && true;
0328 
0329   Enable::TRACKING_TRACK = (Enable::MICROMEGAS_CLUSTER && Enable::TPC_CLUSTER && Enable::INTT_CLUSTER && Enable::MVTX_CLUSTER) && true;
0330   Enable::TRACKING_EVAL = Enable::TRACKING_TRACK && true;
0331   Enable::TRACKING_QA = Enable::TRACKING_TRACK && Enable::QA && true;
0332 
0333   //  cemc electronics + thin layer of W-epoxy to get albedo from cemc
0334   //  into the tracking, cannot run together with CEMC
0335   //  Enable::CEMCALBEDO = true;
0336 
0337   Enable::CEMC = true;
0338   Enable::CEMC_ABSORBER = true;
0339   Enable::CEMC_CELL = Enable::CEMC && true;
0340   Enable::CEMC_TOWER = Enable::CEMC_CELL && true;
0341   Enable::CEMC_CLUSTER = Enable::CEMC_TOWER && false;
0342   Enable::CEMC_CLUSTER_FULL = Enable::CEMC_TOWER && true;
0343   Enable::CEMC_EVAL = Enable::CEMC_CLUSTER && false;
0344   Enable::CEMC_EVAL_POSITION_CORRECTION = Enable::CEMC_CLUSTER_FULL && true;
0345   Enable::CEMC_QA = (Enable::CEMC_CLUSTER || Enable::CEMC_CLUSTER_FULL) && Enable::QA && true;
0346 
0347   Enable::HCALIN = false;
0348   Enable::HCALIN_ABSORBER = true;
0349   Enable::HCALIN_CELL = Enable::HCALIN && true;
0350   Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true;
0351   Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true;
0352   Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && true;
0353   Enable::HCALIN_QA = Enable::HCALIN_CLUSTER && Enable::QA && true;
0354 
0355   Enable::MAGNET = true;
0356   Enable::MAGNET_ABSORBER = true;
0357 
0358   Enable::HCALOUT = false;
0359   Enable::HCALOUT_ABSORBER = true;
0360   Enable::HCALOUT_CELL = Enable::HCALOUT && true;
0361   Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true;
0362   Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true;
0363   Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && true;
0364   Enable::HCALOUT_QA = Enable::HCALOUT_CLUSTER && Enable::QA && true;
0365 
0366   Enable::EPD = true;
0367 
0368   Enable::BEAMLINE = true;
0369 //  Enable::BEAMLINE_ABSORBER = true;  // makes the beam line magnets sensitive volumes
0370 //  Enable::BEAMLINE_BLACKHOLE = true; // turns the beamline magnets into black holes
0371   Enable::ZDC = true;
0372 //  Enable::ZDC_ABSORBER = true;
0373 //  Enable::ZDC_SUPPORT = true;
0374   Enable::ZDC_TOWER = Enable::ZDC && true;
0375   Enable::ZDC_EVAL = Enable::ZDC_TOWER && true;
0376 
0377   //! forward flux return plug door. Out of acceptance and off by default.
0378   //Enable::PLUGDOOR = true;
0379   Enable::PLUGDOOR_ABSORBER = true;
0380 
0381   Enable::GLOBAL_RECO = (Enable::BBCFAKE || Enable::TRACKING_TRACK) && true;
0382   //Enable::GLOBAL_FASTSIM = true;
0383 
0384   //Enable::KFPARTICLE = true;
0385   //Enable::KFPARTICLE_VERBOSITY = 1;
0386   //Enable::KFPARTICLE_TRUTH_MATCH = true;
0387   //Enable::KFPARTICLE_SAVE_NTUPLE = true;
0388 
0389   Enable::CALOTRIGGER = Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER && false;
0390 
0391   Enable::JETS = (Enable::GLOBAL_RECO || Enable::GLOBAL_FASTSIM) && false;
0392   Enable::JETS_EVAL = Enable::JETS && true;
0393   Enable::JETS_QA = Enable::JETS && Enable::QA && true;
0394 
0395   // HI Jet Reco for p+Au / Au+Au collisions (default is false for
0396   // single particle / p+p-only simulations, or for p+Au / Au+Au
0397   // simulations which don't particularly care about jets)
0398   Enable::HIJETS = Enable::JETS && Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER && false;
0399 
0400   // 3-D topoCluster reconstruction, potentially in all calorimeter layers
0401   Enable::TOPOCLUSTER = Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER && false;
0402   // particle flow jet reconstruction - needs topoClusters!
0403   Enable::PARTICLEFLOW = Enable::TOPOCLUSTER && true;
0404   // centrality reconstruction
0405   Enable::CENTRALITY = true;
0406 
0407   // new settings using Enable namespace in GlobalVariables.C
0408   Enable::BLACKHOLE = true;
0409   //Enable::BLACKHOLE_SAVEHITS = false; // turn off saving of bh hits
0410   //Enable::BLACKHOLE_FORWARD_SAVEHITS = false; // disable forward/backward hits
0411   //BlackHoleGeometry::visible = true;
0412 
0413   // run user provided code (from local G4_User.C)
0414   //Enable::USER = true;
0415 
0416   //===============
0417   // conditions DB flags
0418   //===============
0419   //Enable::XPLOAD = true;
0420   // tag
0421   rc->set_StringFlag("XPLOAD_TAG",XPLOAD::tag);
0422   // database config
0423   rc->set_StringFlag("XPLOAD_CONFIG",XPLOAD::config);
0424   // 64 bit timestamp
0425   rc->set_uint64Flag("TIMESTAMP",XPLOAD::timestamp);
0426 
0427   //---------------
0428   // World Settings
0429   //---------------
0430   //  G4WORLD::PhysicsList = "FTFP_BERT"; //FTFP_BERT_HP best for calo
0431   //  G4WORLD::WorldMaterial = "G4_AIR"; // set to G4_GALACTIC for material scans
0432 
0433   //---------------
0434   // Magnet Settings
0435   //---------------
0436 
0437   //  G4MAGNET::magfield =  string(getenv("CALIBRATIONROOT"))+ string("/Field/Map/sphenix3dbigmapxyz.root");  // default map from the calibration database
0438   //  G4MAGNET::magfield = "1.5"; // alternatively to specify a constant magnetic field, give a float number, which will be translated to solenoidal field in T, if string use as fieldmap name (including path)
0439 //  G4MAGNET::magfield_rescale = 1.;  // make consistent with expected Babar field strength of 1.4T
0440 
0441   //---------------
0442   // Pythia Decayer
0443   //---------------
0444   // list of decay types in
0445   // $OFFLINE_MAIN/include/g4decayer/EDecayType.hh
0446   // default is All:
0447   // G4P6DECAYER::decayType = EDecayType::kAll;
0448 
0449   // Initialize the selected subsystems
0450   G4Init();
0451 
0452   //---------------------
0453   // GEANT4 Detector description
0454   //---------------------
0455   if (!Input::READHITS)
0456   {
0457     G4Setup();
0458   }
0459 
0460   //------------------
0461   // Detector Division
0462   //------------------
0463 
0464   if (Enable::BBC || Enable::BBCFAKE) Bbc_Reco();
0465 
0466   if (Enable::MVTX_CELL) Mvtx_Cells();
0467   if (Enable::INTT_CELL) Intt_Cells();
0468   if (Enable::TPC_CELL) TPC_Cells();
0469   if (Enable::MICROMEGAS_CELL) Micromegas_Cells();
0470 
0471   if (Enable::CEMC_CELL) CEMC_Cells();
0472 
0473   if (Enable::HCALIN_CELL) HCALInner_Cells();
0474 
0475   if (Enable::HCALOUT_CELL) HCALOuter_Cells();
0476 
0477   //-----------------------------
0478   // CEMC towering and clustering
0479   //-----------------------------
0480 
0481   if (Enable::CEMC_TOWER) CEMC_Towers();
0482   if (Enable::CEMC_CLUSTER) CEMC_Clusters();
0483   if (Enable::CEMC_CLUSTER_FULL) CEMC_Clusters_Full(calib_path);
0484 
0485   //-----------------------------
0486   // HCAL towering and clustering
0487   //-----------------------------
0488 
0489   if (Enable::HCALIN_TOWER) HCALInner_Towers();
0490   if (Enable::HCALIN_CLUSTER) HCALInner_Clusters();
0491 
0492   if (Enable::HCALOUT_TOWER) HCALOuter_Towers();
0493   if (Enable::HCALOUT_CLUSTER) HCALOuter_Clusters();
0494 
0495   // if enabled, do topoClustering early, upstream of any possible jet reconstruction
0496   if (Enable::TOPOCLUSTER) TopoClusterReco();
0497 
0498   //--------------
0499   // SVTX tracking
0500   //--------------
0501   if(Enable::TRACKING_TRACK)
0502     {
0503       TrackingInit();
0504     }
0505   if (Enable::MVTX_CLUSTER) Mvtx_Clustering();
0506   if (Enable::INTT_CLUSTER) Intt_Clustering();
0507   if (Enable::TPC_CLUSTER) TPC_Clustering();
0508   if (Enable::MICROMEGAS_CLUSTER) Micromegas_Clustering();
0509 
0510   if (Enable::TRACKING_TRACK)
0511   {
0512     Tracking_Reco();
0513   }
0514   //-----------------
0515   // Global Vertexing
0516   //-----------------
0517 
0518   if (Enable::GLOBAL_RECO && Enable::GLOBAL_FASTSIM)
0519   {
0520     cout << "You can only enable Enable::GLOBAL_RECO or Enable::GLOBAL_FASTSIM, not both" << endl;
0521     gSystem->Exit(1);
0522   }
0523   if (Enable::GLOBAL_RECO)
0524   {
0525     Global_Reco();
0526   }
0527   else if (Enable::GLOBAL_FASTSIM)
0528   {
0529     Global_FastSim();
0530   }
0531 
0532   //-----------------
0533   // Centrality Determination
0534   //-----------------
0535 
0536   if (Enable::CENTRALITY)
0537   {
0538       Centrality();
0539   }
0540 
0541   //-----------------
0542   // Calo Trigger Simulation
0543   //-----------------
0544 
0545   if (Enable::CALOTRIGGER)
0546   {
0547     CaloTrigger_Sim();
0548   }
0549 
0550   //---------
0551   // Jet reco
0552   //---------
0553 
0554   if (Enable::JETS) Jet_Reco();
0555   if (Enable::HIJETS) HIJetReco();
0556 
0557   if (Enable::PARTICLEFLOW) ParticleFlow();
0558 
0559   //----------------------
0560   // Simulation evaluation
0561   //----------------------
0562   string outputroot = outputFile;
0563   string remove_this = ".root";
0564   size_t pos = outputroot.find(remove_this);
0565   if (pos != string::npos)
0566   {
0567     outputroot.erase(pos, remove_this.length());
0568   }
0569 
0570   if (Enable::TRACKING_EVAL) Tracking_Eval(outputroot + "_g4svtx_eval.root");
0571 
0572   if (Enable::CEMC_EVAL) CEMC_Eval(outputroot + "_g4cemc_eval.root");
0573 
0574   if (Enable::CEMC_EVAL_POSITION_CORRECTION) CEMC_Eval_Position_Correction(outputroot + "_g4cemc_eval.root");
0575 
0576   if (Enable::HCALIN_EVAL) HCALInner_Eval(outputroot + "_g4hcalin_eval.root");
0577 
0578   if (Enable::HCALOUT_EVAL) HCALOuter_Eval(outputroot + "_g4hcalout_eval.root");
0579 
0580   if (Enable::JETS_EVAL) Jet_Eval(outputroot + "_g4jet_eval.root");
0581 
0582   if (Enable::DSTREADER) G4DSTreader(outputroot + "_DSTReader.root");
0583 
0584   if (Enable::USER) UserAnalysisInit();
0585 
0586   //======================
0587   // Run KFParticle on evt
0588   //======================
0589   if (Enable::KFPARTICLE && Input::UPSILON) KFParticle_Upsilon_Reco();
0590   if (Enable::KFPARTICLE && Input::DZERO) KFParticle_D0_Reco();
0591 
0592   //----------------------
0593   // Standard QAs
0594   //----------------------
0595 
0596   if (Enable::CEMC_QA) CEMC_QA();
0597   if (Enable::HCALIN_QA) HCALInner_QA();
0598   if (Enable::HCALOUT_QA) HCALOuter_QA();
0599 
0600   if (Enable::JETS_QA) Jet_QA();
0601 
0602   if (Enable::MVTX_QA) Mvtx_QA();
0603   if (Enable::INTT_QA) Intt_QA();
0604   if (Enable::TPC_QA) TPC_QA();
0605   if (Enable::MICROMEGAS_QA) Micromegas_QA();
0606   if (Enable::TRACKING_QA) Tracking_QA();
0607 
0608   if (Enable::TRACKING_QA && Enable::CEMC_QA && Enable::HCALIN_QA && Enable::HCALOUT_QA) QA_G4CaloTracking();
0609 
0610   //--------------
0611   // Set up Input Managers
0612   //--------------
0613 
0614   InputManagers();
0615 
0616   if (Enable::PRODUCTION)
0617   {
0618     Production_CreateOutputDir();
0619   }
0620 
0621   if (Enable::DSTOUT)
0622   {
0623     string FullOutFile = DstOut::OutputDir + "/" + DstOut::OutputFile;
0624     Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", FullOutFile);
0625     if (Enable::DSTOUT_COMPRESS)
0626     {
0627       ShowerCompress();
0628       DstCompress(out);
0629     }
0630     se->registerOutputManager(out);
0631   }
0632   //-----------------
0633   // Event processing
0634   //-----------------
0635   if (Enable::DISPLAY)
0636   {
0637     DisplayOn();
0638 
0639     gROOT->ProcessLine("Fun4AllServer *se = Fun4AllServer::instance();");
0640     gROOT->ProcessLine("PHG4Reco *g4 = (PHG4Reco *) se->getSubsysReco(\"PHG4RECO\");");
0641 
0642     cout << "-------------------------------------------------" << endl;
0643     cout << "You are in event display mode. Run one event with" << endl;
0644     cout << "se->run(1)" << endl;
0645     cout << "Run Geant4 command with following examples" << endl;
0646     gROOT->ProcessLine("displaycmd()");
0647 
0648     return 0;
0649   }
0650 
0651   // if we use a negative number of events we go back to the command line here
0652   if (nEvents < 0)
0653   {
0654     return 0;
0655   }
0656   // if we run the particle generator and use 0 it'll run forever
0657   // for embedding it runs forever if the repeat flag is set
0658   if (nEvents == 0 && !Input::HEPMC && !Input::READHITS && INPUTEMBED::REPEAT)
0659   {
0660     cout << "using 0 for number of events is a bad idea when using particle generators" << endl;
0661     cout << "it will run forever, so I just return without running anything" << endl;
0662     return 0;
0663   }
0664 
0665   se->skip(skip);
0666   se->run(nEvents);
0667 
0668   //-----
0669   // QA output
0670   //-----
0671 
0672   if (Enable::QA) QA_Output(outputroot + "_qa.root");
0673 
0674   //-----
0675   // Exit
0676   //-----
0677 
0678   se->End();
0679   std::cout << "All done" << std::endl;
0680   delete se;
0681   if (Enable::PRODUCTION)
0682   {
0683     Production_MoveOutput();
0684   }
0685 
0686   gSystem->Exit(0);
0687   return 0;
0688 }
0689 #endif