Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:12:44

0001 #ifndef MACRO_FUN4ALLG4SPHENIX_C
0002 #define MACRO_FUN4ALLG4SPHENIX_C
0003 
0004 #include <GlobalVariables.C>
0005 #include <G4_Input.C>         // global variable "Input"
0006 #include <G4_TrkrVariables.C> // global variable "Input"
0007 #include <G4_ActsGeom.C>      // global variable "ACTSGEOM"
0008 #include <G4_Global.C>
0009 #include <Trkr_Reco.C>
0010 
0011 #include <ffamodules/FlagHandler.h>
0012 #include <ffamodules/HeadReco.h>
0013 #include <ffamodules/SyncReco.h>
0014 #include <ffamodules/CDBInterface.h>
0015 
0016 #include <fun4all/Fun4AllServer.h>
0017 #include <fun4all/Fun4AllDstInputManager.h>
0018 #include <fun4all/Fun4AllRunNodeInputManager.h>
0019 #include <fun4all/Fun4AllDstOutputManager.h>
0020 #include <fun4all/Fun4AllOutputManager.h>
0021 #include <fun4all/Fun4AllUtils.h>
0022 
0023 #include <siliconseedsana/SiliconCaloMatching.h>
0024 #include <siliconseedsana/SiliconSeedsAna.h>
0025 #include <siliconseedsana/ChargeRecalc.h>
0026 
0027 #include <calotrigger/TriggerRunInfoReco.h>
0028 #include <mbd/MbdReco.h>
0029 #include <caloreco/RawClusterBuilderTopo.h>
0030 
0031 #include <phool/recoConsts.h>
0032 
0033 #include <sys/stat.h>
0034 #include <limits.h> // PATH_MAX
0035 #include <unistd.h>
0036 
0037 #include "Calo_Calib.C"
0038 
0039 #pragma GCC diagnostic push
0040 
0041 #pragma GCC diagnostic ignored "-Wundefined-internal"
0042 
0043 #pragma GCC diagnostic pop
0044 
0045 //--R__LOAD_LIBRARY(libkfparticle_sphenix.so)
0046 R__LOAD_LIBRARY(libphool.so)
0047 R__LOAD_LIBRARY(libfun4all.so)
0048 R__LOAD_LIBRARY(libfun4allraw.so)
0049 //--R__LOAD_LIBRARY(libffamodules.so)
0050 //--R__LOAD_LIBRARY(libcdbobjects.so)
0051 //--R__LOAD_LIBRARY(libmvtx.so)
0052 //--R__LOAD_LIBRARY(libintt.so)
0053 //--R__LOAD_LIBRARY(libtpc.so)
0054 //--R__LOAD_LIBRARY(libmicromegas.so)
0055 // R__LOAD_LIBRARY(libTrackingDiagnostics.so)
0056 // R__LOAD_LIBRARY(libtrackingqa.so)
0057 // R__LOAD_LIBRARY(libtpcqa.so)
0058 // R__LOAD_LIBRARY(libtrack_to_calo.so)
0059 //--R__LOAD_LIBRARY(libtrack_reco.so)
0060 //--R__LOAD_LIBRARY(libcalo_reco.so)
0061 R__LOAD_LIBRARY(libcalotrigger.so)
0062 // R__LOAD_LIBRARY(libcentrality.so)
0063 R__LOAD_LIBRARY(libmbd.so)
0064 R__LOAD_LIBRARY(libepd.so)
0065 R__LOAD_LIBRARY(libzdcinfo.so)
0066 
0067 R__LOAD_LIBRARY(libsiliconseedsana.so)
0068 
0069 bool useTopologicalCluster = false;
0070 
0071 int Fun4All_DataDST_SiliconSeedAna_run3pp(
0072     const int nEvents = 1000
0073     , const string inlst_dst_strk = "list/test/run53879_seed_0.list"
0074     , const string inlst_dst_calo = "list/test/run53879_calo_0.list"
0075     , const string out_root = "/sphenix/tg/tg01/commissioning/INTT/work/mahiro/SIliconCalo/run24pp/ana/newgeo/calocalib/recalc_charge/ana_53879_1000evt.root"
0076     , const int startnumber = 0)
0077 {
0078 
0079   std::cout << "inlst_dst_trk  : " << inlst_dst_strk << endl;
0080   std::cout << "inlst_dst_calo : " << inlst_dst_calo << endl;
0081   // std::cout << "std::cout << "Input DST: " << in_dst      <<std::endl;
0082   // std::cout << "out  ROOT: " << out_root    <<std::endl;
0083   std::cout << "Nevent   : " << nEvents << std::endl;
0084   std::cout << "#start   : " << startnumber << std::endl;
0085 
0086   // gSystem->ListLibraries();
0087     
0088 
0089   std::ifstream fin(inlst_dst_strk.c_str());
0090   std::string filename;
0091   fin>>filename;
0092   std::cout<<"Filename : "<<filename<<std::endl;
0093   fin.close();
0094 
0095   std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(filename);
0096   int runnumber = runseg.first;
0097   int segment = runseg.second;
0098     
0099     
0100     
0101 
0102   G4TRACKING::SC_CALIBMODE = false;
0103   
0104   //Enable::MVTX_APPLYMISALIGNMENT = true;
0105   //ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0106   //
0107   TRACKING::pp_mode = true;
0108 
0109   Fun4AllServer *se = Fun4AllServer::instance();
0110   // se->Verbosity(10);
0111 
0112   recoConsts *rc = recoConsts::instance();
0113   Input::VERBOSITY = 0;
0114 
0115   //int runnum = 79516;
0116   std::cout<<"Run : "<<runnumber<<std::endl;
0117   // Tracking setup
0118   Enable::CDB = true;
0119   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0120   rc->set_uint64Flag("TIMESTAMP", runnumber);
0121 
0122   std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0123   Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0124   ingeo->AddFile(geofile);
0125   se->registerInputManager(ingeo);
0126 
0127   // this assume Geometory data is in the DST
0128   ACTSGEOM::ActsGeomInit();
0129 
0130   //--input
0131   Fun4AllInputManager *in_calo = new Fun4AllDstInputManager("DSTCalo");
0132   in_calo->AddListFile(inlst_dst_calo.c_str());
0133   // in->Verbosity(2);
0134   se->registerInputManager(in_calo);
0135 
0136   //--Fun4AllInputManager *in_clus = new Fun4AllDstInputManager("DSTTrkrClus");
0137   //--in_clus->AddListFile(inlst_dst_clus.c_str());
0138   //--// in->Verbosity(2);
0139   //--se->registerInputManager(in_clus);
0140 
0141   Fun4AllInputManager *in_strk = new Fun4AllDstInputManager("DSTTrkrTrack");
0142   in_strk->AddListFile(inlst_dst_strk.c_str());
0143   // in->Verbosity(2);
0144   se->registerInputManager(in_strk);
0145 
0146 ///////////////////////////////
0147   TriggerRunInfoReco *triggerruninforeco = new TriggerRunInfoReco();
0148   se->registerSubsystem(triggerruninforeco);
0149 
0150   // MBD/BBC Reconstruction
0151   MbdReco *mbdreco = new MbdReco();
0152   se->registerSubsystem(mbdreco);
0153 
0154 ///////////////////////////////
0155 
0156   //Process_Calo_Calib_Mahirochan();
0157   Process_Calo_Calib();
0158 
0159   //////////////////////////////
0160   //TopoClusterReco(); // too slow
0161   //topo clusters for EMCal and HCal (layer 0 - iHCal, layer 1 - oHCal, layer 2 - EMCal)
0162   RawClusterBuilderTopo* ClusterBuilder2 = new RawClusterBuilderTopo("SiHCalRawClusterBuilderTopo");
0163   //ClusterBuilder2->Verbosity(11);
0164   ClusterBuilder2->set_nodename("TOPOCLUSTER_ALLCALO");
0165   ClusterBuilder2->set_enable_HCal(true);
0166   ClusterBuilder2->set_enable_EMCal(true);
0167   //ClusterBuilder2->set_noise(0.0025, 0.006, 0.03);
0168   //ClusterBuilder2->set_noise(0.01, 0.03, 0.03);
0169   ClusterBuilder2->set_noise(0.002, 0.01, 0.03); //From Emma (1 sigma)
0170   //ClusterBuilder2->set_noise(0.004, 0.02, 0.06); //From Emma (2 sigma)
0171   // ClusterBuilder2->set_noise(0.006, 0.03, 0.09); //From Emma (3 sigma)
0172   ClusterBuilder2->set_significance(4.0, 2.0, 1.0); // seed threshold, grow threshold, perimeter threshold in unit of noise sigma
0173   ClusterBuilder2->allow_corner_neighbor(true);
0174   ClusterBuilder2->set_do_split(true);
0175   ClusterBuilder2->set_minE_local_max(1.0, 2.0, 0.5);
0176   ClusterBuilder2->set_R_shower(0.025);
0177   //ClusterBuilder2->set_use_only_good_towers(false);
0178   se->registerSubsystem(ClusterBuilder2);
0179 
0180   //////////////////////////////
0181 
0182 
0183   auto converter = new TrackSeedTrackMapConverter;
0184   // SiliconTrackSeedContainer or TpcTrackSeedContainer
0185   converter->setTrackSeedName("SiliconTrackSeedContainer");
0186   converter->setClusterMapName("TRKR_CLUSTER_SEED");
0187   converter->setFieldMap(G4MAGNET::magfield_tracking);
0188   // converter->Verbosity(10);
0189   se->registerSubsystem(converter);
0190 
0191   PHSimpleVertexFinder *finder = new PHSimpleVertexFinder;
0192   finder->Verbosity(0);
0193   finder->setTrkrClusterContainerName("TRKR_CLUSTER_SEED");
0194   finder->setDcaCut(0.1);
0195   finder->setTrackPtCut(0.);
0196   finder->setBeamLineCut(1);
0197   finder->setTrackQualityCut(20);
0198   finder->setNmvtxRequired(3);
0199   finder->setOutlierPairCut(0.1);
0200   se->registerSubsystem(finder);
0201 
0202   Global_Reco();
0203 
0204   // --- charge recalculation (before projection) ---
0205   auto chrecalc = new ChargeRecalc("ChargeRecalc");
0206   chrecalc->setVerbosity(0);
0207   chrecalc->setClusterContainerName("TRKR_CLUSTER_SEED");
0208   se->registerSubsystem(chrecalc);
0209 
0210   // track projection CALO
0211   auto projection = new PHActsTrackProjection("CaloProjection");
0212   // float emcal_radius = 104.5; // set by my self due to emcal geometry was cahnged
0213   // projection->setLayerRadius(SvtxTrack::CEMC, emcal_radius);
0214   se->registerSubsystem(projection);
0215 
0216 
0217 
0218   // Si-Calo Matching
0219   SiliconCaloMatching* sicalomatch = new SiliconCaloMatching();
0220   //sicalomatch->Verbosity(1);
0221   sicalomatch->setClusterContainerName("TRKR_CLUSTER_SEED");
0222   sicalomatch->setEMCalClusterContainerName("CLUSTERINFO_CEMC");
0223   sicalomatch->setEmcalLowEcut(0.2);
0224   sicalomatch->setTrackLowpTcut(0.2);
0225   se->registerSubsystem(sicalomatch);
0226 
0227   auto siana = new SiliconSeedsAna("SiliconSeedsAna");
0228   // siana->setMC(true);
0229   siana->setVtxSkip(true);
0230   siana->setClusterContainerName("TRKR_CLUSTER_SEED");
0231   siana->setEMCalClusterContainerName("CLUSTERINFO_CEMC");
0232   siana->setTopoCluster(useTopologicalCluster);
0233   // siana->setEMcalRadius(emcal_radius); // set new emcal radius for silicon track production to emcal
0234   siana->setOutputFileName(out_root.c_str());
0235 
0236   siana->setStartEventNumber(startnumber);
0237 
0238   se->registerSubsystem(siana);
0239 
0240   se->run(nEvents);
0241 
0242   //-----
0243   // Exit
0244   //-----
0245 
0246   //  CDBInterface::instance()->Print(); // print used DB files
0247   se->End();
0248   std::cout << "All done" << std::endl;
0249   delete se;
0250 
0251   gSystem->Exit(0);
0252   return 0;
0253 }
0254 #endif