sphenix-software-l AT lists.bnl.gov
Subject: sPHENIX discussion of software
List archive
- From: Hugo Pereira Da Costa <hugo.pereira-da-costa AT cea.fr>
- To: "sphenix-software-l AT lists.bnl.gov" <sphenix-software-l AT lists.bnl.gov>, "Pinkenburg, Christopher" <pinkenbu AT bnl.gov>
- Subject: [Sphenix-software-l] HepMC macro
- Date: Wed, 26 Aug 2020 08:46:14 -0600
Hello Chris, others,
as discussed at yesterday's software and simulation meeting, attached is the (new scheme) macro, that helps reproduce the problem with skipping events when reading HEPMC input and pile-up using two separate input managers. In the current implementation se->skip() does not do any skipping in the Fun4AllHepMCPileupInputManager defined in G4_Input.C
My idea for fixing was to implement a flag in the InputManager (like: force_skip, false by default), and then in the SyncManager to loop over to loop over inputmanagers and skip only for the first input (as done now) and those for which the flag is true. You can then set the flag to true either externally (in the macro) or directly in the constructor of the relevant input managers (essentially, all those that do nothing for synching). With the latter, no further change is involved on the macro file.
That does not fix the issue raised by Jin than for the PileUp manager if you skip say 5 events for the main input, you actually need to skip much more on the pileup manager, to make sure there is no overlap. I do not know how to adress this ...
Hugo
#ifndef MACRO_FUN4ALLG4SPHENIX_C #define MACRO_FUN4ALLG4SPHENIX_C #include "GlobalVariables.C" #include "DisplayOn.C" #include "G4Setup_sPHENIX.C" #include "G4_Bbc.C" #include "G4_CaloTrigger.C" #include "G4_DSTReader.C" #include "G4_Global.C" #include "G4_HIJetReco.C" #include "G4_Input.C" #include "G4_Jets.C" #include "G4_ParticleFlow.C" #include "G4_Production.C" #include "G4_TopoClusterReco.C" #include "G4_Tracking.C" #include <fun4all/Fun4AllDstOutputManager.h> #include <fun4all/Fun4AllOutputManager.h> #include <fun4all/Fun4AllServer.h> #include <phool/PHRandomSeed.h> #include <phool/recoConsts.h> R__LOAD_LIBRARY(libfun4all.so) int Fun4All_G4_sPHENIX_cp( const int nEvents = 1, const string &inputFile = "/sphenix/sim/sim01/sHijing/sHijing_0-12fm.dat", const string &outputFile = "G4sPHENIX.root", const string &embed_input_file = "https://www.phenix.bnl.gov/WWW/publish/phnxbld/sPHENIX/files/sPHENIX_G4Hits_sHijing_9-11fm_00000_00010.root", const int skip = 5, const string &outdir = ".") { Fun4AllServer *se = Fun4AllServer::instance(); se->Verbosity(1); //Opt to print all random seed used for debugging reproducibility. Comment out to reduce stdout prints. PHRandomSeed::Verbosity(1); // just if we set some flags somewhere in this macro recoConsts *rc = recoConsts::instance(); // By default every random number generator uses // PHRandomSeed() which reads /dev/urandom to get its seed // if the RANDOMSEED flag is set its value is taken as seed // You can either set this to a random value using PHRandomSeed() // which will make all seeds identical (not sure what the point of // this would be: // rc->set_IntFlag("RANDOMSEED",PHRandomSeed()); // or set it to a fixed value so you can debug your code // rc->set_IntFlag("RANDOMSEED", 12345); //=============== // Input options //=============== // First enable the input generators // Either: // read previously generated g4-hits files, in this case it opens a DST and skips // the simulations step completely. The G4Setup macro is only loaded to get information // about the number of layers used for the cell reco code // Input::READHITS = true; INPUTREADHITS::filename = inputFile; // Or: // Use particle generator // And // Further choose to embed newly simulated events to a previous simulation. Not compatible with `readhits = true` // 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 // E.g. /sphenix/sim//sim01/production/2016-07-21/single_particle/spacal2d/ // Input::EMBED = true; INPUTEMBED::filename = embed_input_file; //Input::SIMPLE = true; //Input::SIMPLE_VERBOSITY = 1; // Input::PYTHIA6 = true; // Input::PYTHIA8 = true; // Input::GUN = true; //Input::GUN_VERBOSITY = 1; // Upsilon generator // Input::UPSILON = true; Input::UPSILON_VERBOSITY = 0; Input::HEPMC = true; Input::VERBOSITY = 0; INPUTHEPMC::filename = inputFile; // Event pile up simulation with collision rate in Hz MB collisions. Input::PILEUPRATE = 100e3; //----------------- // Initialize the selected Input/Event generation //----------------- // This creates the input generator(s) InputInit(); //-------------- // Set generator specific options //-------------- // can only be set after InputInit() is called // Simple Input generator: if (Input::SIMPLE) { INPUTGENERATOR::SimpleEventGenerator->add_particles("pi-", 5); if (Input::HEPMC || Input::EMBED) { INPUTGENERATOR::SimpleEventGenerator->set_reuse_existing_vertex(true); INPUTGENERATOR::SimpleEventGenerator->set_existing_vertex_offset_vector(0.0, 0.0, 0.0); } else { INPUTGENERATOR::SimpleEventGenerator->set_vertex_distribution_function(PHG4SimpleEventGenerator::Uniform, PHG4SimpleEventGenerator::Uniform, PHG4SimpleEventGenerator::Uniform); INPUTGENERATOR::SimpleEventGenerator->set_vertex_distribution_mean(0., 0., 0.); INPUTGENERATOR::SimpleEventGenerator->set_vertex_distribution_width(0., 0., 5.); } INPUTGENERATOR::SimpleEventGenerator->set_eta_range(-1, 1); INPUTGENERATOR::SimpleEventGenerator->set_phi_range(-M_PI, M_PI); INPUTGENERATOR::SimpleEventGenerator->set_pt_range(0.1, 20.); } // Upsilons if (Input::UPSILON) { INPUTGENERATOR::VectorMesonGenerator->add_decay_particles("e", 0); INPUTGENERATOR::VectorMesonGenerator->set_rapidity_range(-1, 1); INPUTGENERATOR::VectorMesonGenerator->set_pt_range(0., 10.); // Y species - select only one, last one wins INPUTGENERATOR::VectorMesonGenerator->set_upsilon_1s(); } // particle gun if (Input::GUN) { INPUTGENERATOR::Gun->AddParticle("pi-", 0, 1, 0); INPUTGENERATOR::Gun->set_vtx(0, 0, 0); } //-------------- // Set Input Manager specific options //-------------- // can only be set after InputInit() is called if (Input::HEPMC) { INPUTMANAGER::HepMCInputManager->set_vertex_distribution_width(100e-4,100e-4,30,0);//optional collision smear in space, time // INPUTMANAGER::HepMCInputManager->set_vertex_distribution_mean(0,0,0,0);//optional collision central position shift in space, time // //optional choice of vertex distribution function in space, time INPUTMANAGER::HepMCInputManager->set_vertex_distribution_function(PHHepMCGenHelper::Gaus,PHHepMCGenHelper::Gaus,PHHepMCGenHelper::Gaus,PHHepMCGenHelper::Gaus); //! embedding ID for the event //! positive ID is the embedded event of interest, e.g. jetty event from pythia //! negative IDs are backgrounds, .e.g out of time pile up collisions //! Usually, ID = 0 means the primary Au+Au collision background //INPUTMANAGER::HepMCInputManager->set_embedding_id(2); } // register all input generators with Fun4All InputRegister(); // set up production relatedstuff // Enable::PRODUCTION = true; //====================== // Write the DST //====================== // Enable::DSTOUT = true; Enable::DSTOUT_COMPRESS = false; DstOut::OutputDir = outdir; DstOut::OutputFile = outputFile; //Option to convert DST to human command readable TTree for quick poke around the outputs // Enable::DSTREADER = true; // turn the display on (default off) Enable::DISPLAY = false; //====================== // What to run //====================== // Global options (enabled for all enables subsystems - if implemented) // Enable::ABSORBER = true; // Enable::OVERLAPCHECK = true; // Enable::VERBOSITY = 1; Enable::BBC = true; Enable::PIPE = true; Enable::PIPE_ABSORBER = true; //Enable::PSTOF = true; // central tracking Enable::MVTX = true; Enable::MVTX_CELL = Enable::MVTX && true; Enable::MVTX_CLUSTER = Enable::MVTX_CELL && true; Enable::INTT = true; Enable::INTT_CELL = Enable::INTT && true; Enable::INTT_CLUSTER = Enable::INTT_CELL && true; Enable::TPC = true; Enable::TPC_ABSORBER = true; Enable::TPC_CELL = Enable::TPC && true; Enable::TPC_CLUSTER = Enable::TPC_CELL && true; //Enable::MICROMEGAS = true; Enable::MICROMEGAS_CELL = Enable::MICROMEGAS && true; Enable::MICROMEGAS_CLUSTER = Enable::MICROMEGAS_CELL && true; Enable::TRACKING_TRACK = false; Enable::TRACKING_EVAL = Enable::TRACKING_TRACK && true; // cemc electronics + thin layer of W-epoxy to get albedo from cemc // into the tracking, cannot run together with CEMC // Enable::CEMCALBEDO = true; Enable::CEMC = false; Enable::CEMC_ABSORBER = true; Enable::CEMC_CELL = Enable::CEMC && true; Enable::CEMC_TOWER = Enable::CEMC_CELL && false; Enable::CEMC_CLUSTER = Enable::CEMC_TOWER && true; Enable::CEMC_EVAL = Enable::CEMC_CLUSTER && true; Enable::HCALIN = false; Enable::HCALIN_ABSORBER = true; Enable::HCALIN_CELL = Enable::HCALIN && true; Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true; Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true; Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && true; Enable::MAGNET = true; Enable::MAGNET_ABSORBER = true; Enable::HCALOUT = false; Enable::HCALOUT_ABSORBER = true; Enable::HCALOUT_CELL = Enable::HCALOUT && true; Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true; Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true; Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && true; // forward EMC //Enable::FEMC = true; Enable::FEMC_ABSORBER = false; Enable::FEMC_CELL = Enable::FEMC && true; Enable::FEMC_TOWER = Enable::FEMC_CELL && true; Enable::FEMC_CLUSTER = Enable::FEMC_TOWER && true; Enable::FEMC_EVAL = Enable::FEMC_CLUSTER && true; //! forward flux return plug door. Out of acceptance and off by default. //Enable::PLUGDOOR = true; Enable::PLUGDOOR_ABSORBER = true; Enable::GLOBAL_RECO = true; // Enable::GLOBAL_FASTSIM = true; Enable::CALOTRIGGER = Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER && false; Enable::JETS = false; Enable::JETS_EVAL = Enable::JETS && true; // HI Jet Reco for p+Au / Au+Au collisions (default is false for // single particle / p+p-only simulations, or for p+Au / Au+Au // simulations which don't particularly care about jets) Enable::HIJETS = false && Enable::JETS && Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER; // 3-D topoCluster reconstruction, potentially in all calorimeter layers Enable::TOPOCLUSTER = true && Enable::CEMC_TOWER && Enable::HCALIN_TOWER && Enable::HCALOUT_TOWER; // particle flow jet reconstruction - needs topoClusters! Enable::PARTICLEFLOW = true && Enable::TOPOCLUSTER; // new settings using Enable namespace in GlobalVariables.C Enable::BLACKHOLE = true; //Enable::BLACKHOLE_SAVEHITS = false; // turn off saving of bh hits //BlackHoleGeometry::visible = true; //--------------- // World Settings //--------------- // G4WORLD::PhysicsList = "QGSP_BERT"; //FTFP_BERT_HP best for calo // G4WORLD::WorldMaterial = "G4_AIR"; // set to G4_GALACTIC for material scans //--------------- // Magnet Settings //--------------- // const string 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) // G4MAGNET::magfield = string(getenv("CALIBRATIONROOT")) + string("/Field/Map/sPHENIX.2d.root"); // default map from the calibration database G4MAGNET::magfield_rescale = -1.4 / 1.5; // make consistent with expected Babar field strength of 1.4T //--------------- // Pythia Decayer //--------------- // list of decay types in // $OFFLINE_MAIN/include/g4decayer/EDecayType.hh // default is All: // G4P6DECAYER::decayType = EDecayType::kAll; // Initialize the selected subsystems G4Init(); //--------------------- // GEANT4 Detector description //--------------------- if (!Input::READHITS) { G4Setup(); } //--------- // BBC Reco //--------- if (Enable::BBC) { BbcInit(); Bbc_Reco(); } //------------------ // Detector Division //------------------ if (Enable::MVTX_CELL) Mvtx_Cells(); if (Enable::INTT_CELL) Intt_Cells(); if (Enable::TPC_CELL) TPC_Cells(); if (Enable::MICROMEGAS_CELL) Micromegas_Cells(); if (Enable::CEMC_CELL) CEMC_Cells(); if (Enable::HCALIN_CELL) HCALInner_Cells(); if (Enable::HCALOUT_CELL) HCALOuter_Cells(); if (Enable::FEMC_CELL) FEMC_Cells(); //----------------------------- // CEMC towering and clustering //----------------------------- if (Enable::CEMC_TOWER) CEMC_Towers(); if (Enable::CEMC_CLUSTER) CEMC_Clusters(); //----------------------------- // HCAL towering and clustering //----------------------------- if (Enable::HCALIN_TOWER) HCALInner_Towers(); if (Enable::HCALIN_CLUSTER) HCALInner_Clusters(); if (Enable::HCALOUT_TOWER) HCALOuter_Towers(); if (Enable::HCALOUT_CLUSTER) HCALOuter_Clusters(); // if enabled, do topoClustering early, upstream of any possible jet reconstruction if (Enable::TOPOCLUSTER) TopoClusterReco(); if (Enable::FEMC_TOWER) FEMC_Towers(); if (Enable::FEMC_CLUSTER) FEMC_Clusters(); if (Enable::DSTOUT_COMPRESS) ShowerCompress(); //-------------- // SVTX tracking //-------------- if (Enable::MVTX_CLUSTER) Mvtx_Clustering(); if (Enable::INTT_CLUSTER) Intt_Clustering(); if (Enable::TPC_CLUSTER) TPC_Clustering(); if (Enable::MICROMEGAS_CLUSTER) Micromegas_Clustering(); if (Enable::TRACKING_TRACK) { TrackingInit(); Tracking_Reco(); } //----------------- // Global Vertexing //----------------- if (Enable::GLOBAL_RECO && Enable::GLOBAL_FASTSIM) { cout << "You can only enable Enable::GLOBAL_RECO or Enable::GLOBAL_FASTSIM, not both" << endl; gSystem->Exit(1); } if (Enable::GLOBAL_RECO) { Global_Reco(); } else if (Enable::GLOBAL_FASTSIM) { Global_FastSim(); } //----------------- // Calo Trigger Simulation //----------------- if (Enable::CALOTRIGGER) { CaloTrigger_Sim(); } //--------- // Jet reco //--------- if (Enable::JETS) Jet_Reco(); if (Enable::HIJETS) HIJetReco(); if (Enable::PARTICLEFLOW) ParticleFlow(); //---------------------- // Simulation evaluation //---------------------- string outputroot = outputFile; string remove_this = ".root"; size_t pos = outputroot.find(remove_this); if (pos != string::npos) { outputroot.erase(pos, remove_this.length()); } if (Enable::TRACKING_EVAL) Tracking_Eval(outputroot + "_g4svtx_eval.root"); if (Enable::CEMC_EVAL) CEMC_Eval(outputroot + "_g4cemc_eval.root"); if (Enable::HCALIN_EVAL) HCALInner_Eval(outputroot + "_g4hcalin_eval.root"); if (Enable::HCALOUT_EVAL) HCALOuter_Eval(outputroot + "_g4hcalout_eval.root"); if (Enable::FEMC_EVAL) FEMC_Eval(outputroot + "_g4femc_eval.root"); if (Enable::JETS_EVAL) Jet_Eval(outputroot + "_g4jet_eval.root"); if (Enable::DSTREADER) G4DSTreader(outputroot + "_DSTReader.root"); //-------------- // Set up Input Managers //-------------- InputManagers(); if (Enable::PRODUCTION) { Production_CreateOutputDir(); } if (Enable::DSTOUT) { string FullOutFile = DstOut::OutputDir + "/" + DstOut::OutputFile; Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", FullOutFile); if (Enable::DSTOUT_COMPRESS) DstCompress(out); se->registerOutputManager(out); } //----------------- // Event processing //----------------- if (nEvents < 0) { return 0; } // if we run the particle generator and use 0 it'll run forever if (nEvents == 0 && !Input::HEPMC && !Input::READHITS) { cout << "using 0 for number of events is a bad idea when using particle generators" << endl; cout << "it will run forever, so I just return without running anything" << endl; return 0; } if (Enable::DISPLAY) { DisplayOn(); // prevent macro from finishing so can see display int i; cout << "***** Enter any integer to proceed" << endl; cin >> i; } se->skip(skip); se->run(nEvents); //----- // Exit //----- se->End(); std::cout << "All done" << std::endl; delete se; if (Enable::PRODUCTION) { Production_MoveOutput(); } gSystem->Exit(0); return 0; } #endif
- [Sphenix-software-l] HepMC macro, Hugo Pereira Da Costa, 08/26/2020
Archive powered by MHonArc 2.6.24.