Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #pragma once
0002 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,0)
0003 #include <fun4all/SubsysReco.h>
0004 #include <fun4all/Fun4AllServer.h>
0005 #include <fun4all/Fun4AllInputManager.h>
0006 #include <fun4all/Fun4AllDstInputManager.h>
0007 
0008 #include <fun4all/Fun4AllDstOutputManager.h>
0009 #include <fun4all/Fun4AllOutputManager.h>
0010 #include <fun4all/Fun4AllServer.h>
0011 #include <fun4all/Fun4AllUtils.h>
0012 
0013 #include <ffamodules/CDBInterface.h>
0014 #include <fun4all/Fun4AllUtils.h>
0015 #include <fun4all/Fun4AllRunNodeInputManager.h>
0016 
0017 #include <phool/PHRandomSeed.h>
0018 #include <phool/recoConsts.h>
0019 
0020 #include <g4centrality/PHG4CentralityReco.h>
0021 #include <caloreco/RawClusterBuilderTopo.h>
0022 
0023 #include <HIJetReco.C>
0024 //#include "HIJetReco_nosub.C"
0025 #include <JetValidation.h>
0026 
0027 #include <g4mbd/MbdDigitization.h>
0028 #include <mbd/MbdReco.h>
0029 #include <globalvertex/GlobalVertexReco.h>
0030 
0031 #include <stdio.h>
0032 #include <string.h>
0033 
0034 #include<Calo_Calib.C>
0035 
0036 R__LOAD_LIBRARY(libfun4all.so)
0037 R__LOAD_LIBRARY(libg4jets.so)
0038 R__LOAD_LIBRARY(libjetbackground.so)
0039 R__LOAD_LIBRARY(libJetValidation.so)
0040 R__LOAD_LIBRARY(libg4centrality.so)
0041 R__LOAD_LIBRARY(libg4dst.so)
0042 R__LOAD_LIBRARY(libglobalvertex.so)
0043 R__LOAD_LIBRARY(libg4mbd.so)
0044 R__LOAD_LIBRARY(libmbd_io.so)
0045 R__LOAD_LIBRARY(libmbd.so)
0046 
0047 #endif
0048 void Fun4All_JetVal(int nEvents = 100, int seg = 0, int isSim = 0, const char *filelistcalo = "dst_calo_cluster.list", const char *sim_type = "run15", const char *calo_type = "waveform")
0049 {
0050   
0051   Fun4AllServer *se = Fun4AllServer::instance();
0052   int verbosity = 0;
0053 
0054   std::ifstream calolist;
0055   std::string caloline;
0056   std::string mcfilelistcalo;
0057   std::string filelisttruth;
0058   std::string filelistglobal;
0059   std::string filelisttruthparticle;
0060 
0061   int runnumber = 0;
0062   int segment = 0;
0063 
0064   if (!isSim) {
0065     calolist.open(filelistcalo);
0066     for (int i = 0; i < seg + 1; i++) 
0067     {
0068       getline(calolist, caloline);
0069     }
0070     std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(caloline);
0071     runnumber = runseg.first;
0072     segment = runseg.second;
0073   } else {
0074     std::ostringstream sseg;
0075     sseg << std::setw(4) << std::setfill('0') << seg;
0076     std::cout << sseg.str() << std::endl;
0077     if (!strcmp(sim_type,"run11_nopileup")) {
0078       mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/run11_dst_calo_cluster_" + sseg.str() + ".list";
0079       filelisttruth = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/run11_dst_truth_jet_" + sseg.str() + ".list";
0080       filelistglobal = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/run11_dst_global_" + sseg.str() + ".list"; 
0081       filelisttruthparticle = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/dst_truthinfo_" + sseg.str() + ".list";
0082     } else if (!strcmp(sim_type,"detroit")) {
0083       if (!strcmp(calo_type,"cluster")) {
0084         mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_dst_calo_cluster_" + sseg.str() + ".list";
0085       } else if (!strcmp(calo_type,"nozero")) {
0086         mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_dst_calo_nozero_" + sseg.str() + ".list";
0087       } else {
0088         mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_dst_calo_waveform_" + sseg.str() + ".list";
0089       }
0090       filelisttruth = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_dst_truth_jet_" + sseg.str() + ".list";
0091       filelistglobal = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_dst_global_" + sseg.str() + ".list"; 
0092       filelisttruthparticle = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_dst_truthinfo_" + sseg.str() + ".list";
0093     } else if (!strcmp(sim_type,"detroit_jet10")) {
0094       mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_jet10_dst_calo_waveform_" + sseg.str() + ".list";
0095       filelistglobal = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/detroit_jet10_g4hits_" + sseg.str() + ".list";
0096     } else {
0097       if (!strcmp(calo_type,"cluster")) {
0098         mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/dst_calo_cluster_" + sseg.str() + ".list";
0099       } else if (!strcmp(calo_type,"nozero")) {
0100         mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/dst_calo_nozero_" + sseg.str() + ".list";
0101       } else {
0102         mcfilelistcalo = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/dst_calo_waveform_" + sseg.str() + ".list";
0103       }
0104       filelisttruth = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/dst_truth_jet_" + sseg.str() + ".list";
0105       filelistglobal = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/dst_global_" + sseg.str() + ".list"; 
0106       filelisttruthparticle = "/sphenix/user/egm2153/calib_study/JetValidation/macro/dst_files/dst_truthinfo_" + sseg.str() + ".list";
0107     }
0108   }
0109 
0110   std::string outfilename;
0111   if (!isSim) {
0112     outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/output_" + to_string(runnumber) + "_" + to_string(segment) + ".root";
0113     //outfilename = "/sphenix/user/egm2153/calib_study/JetValidation/analysis/output_" + to_string(runnumber) + "_" + to_string(segment) + ".root";
0114   } else {
0115     if (!strcmp(sim_type,"run11_nopileup")) {
0116       outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_run11_nopileup_calo_cluster_output_" + to_string(seg) + ".root";
0117     } else if (!strcmp(sim_type,"detroit")) {
0118       if (!strcmp(calo_type,"cluster")) {
0119         outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_detroit_calo_cluster_output_" + to_string(seg) + ".root";
0120       } else if (!strcmp(calo_type,"nozero")) {
0121         outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_detroit_calo_nozero_output_" + to_string(seg) + ".root";
0122       } else {
0123         outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_detroit_output_" + to_string(seg) + ".root";
0124       }
0125     } else if (!strcmp(sim_type,"detroit_jet10")) { 
0126       outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_detroit_jet10_output_" + to_string(seg) + ".root";
0127     } else {
0128       if (!strcmp(calo_type,"cluster")) {
0129         outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_calo_cluster_output_" + to_string(seg) + ".root";
0130       } else if (!strcmp(calo_type,"nozero")) {
0131         outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_calo_nozero_output_" + to_string(seg) + ".root";
0132       } else {
0133         outfilename = "/sphenix/tg/tg01/jets/egm2153/JetValOutput/sim_output_" + to_string(seg) + ".root";
0134       }
0135     }
0136   }
0137 
0138   // default sim_type is default run 15 with 2Mhz pileup
0139   // default calo_type is calo_waveform dst file 
0140   
0141   se->Verbosity(verbosity);
0142   recoConsts *rc = recoConsts::instance();
0143   if (!isSim) {
0144     rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2024");
0145     rc->set_uint64Flag("TIMESTAMP", runnumber);
0146   } else {
0147     rc->set_StringFlag("CDB_GLOBALTAG", "MDC2");
0148     rc->set_uint64Flag("TIMESTAMP", 6);
0149   }
0150     CDBInterface::instance()->Verbosity(1);
0151   
0152   MbdDigitization* mbddigi = new MbdDigitization();
0153   if (isSim && !strcmp(sim_type,"detroit_jet10")) {
0154     se->registerSubsystem(mbddigi);
0155   }
0156   
0157   MbdReco *mbdreco = new MbdReco();
0158   se->registerSubsystem(mbdreco);
0159 
0160   GlobalVertexReco *gvertex = new GlobalVertexReco();
0161   se->registerSubsystem(gvertex);
0162 
0163   if (!isSim) { Process_Calo_Calib(); }
0164 
0165   PHG4CentralityReco *cent = new PHG4CentralityReco();
0166   cent->Verbosity(verbosity);
0167   cent->GetCalibrationParameters().ReadFromFile("centrality", "xml", 0, 0, string(getenv("CALIBRATIONROOT")) + string("/Centrality/"));
0168   se->registerSubsystem( cent );
0169 
0170   /*
0171   RawClusterBuilderTopo* ClusterBuilder = new RawClusterBuilderTopo("HcalRawClusterBuilderTopo");
0172   ClusterBuilder->Verbosity(verbosity);
0173   ClusterBuilder->set_nodename("TOPOCLUSTER_ALLCALO");
0174   ClusterBuilder->set_enable_HCal(true);
0175   ClusterBuilder->set_enable_EMCal(true);
0176   ClusterBuilder->set_noise(0.0025, 0.006, 0.03);
0177   ClusterBuilder->set_significance(4.0, 2.0, 0.0);
0178   ClusterBuilder->allow_corner_neighbor(true);
0179   ClusterBuilder->set_do_split(true);
0180   ClusterBuilder->set_minE_local_max(1.0, 2.0, 0.5);
0181   ClusterBuilder->set_R_shower(0.025);
0182   ClusterBuilder->set_use_only_good_towers(true);
0183   ClusterBuilder->set_absE(true);
0184   se->registerSubsystem(ClusterBuilder);
0185   */
0186   
0187   Enable::VERBOSITY = verbosity;
0188   HIJetReco();
0189 
0190   JetValidation *myJetVal = new JetValidation("AntiKt_Tower_r04_Sub1", "AntiKt_Truth_r04", outfilename.c_str());
0191   myJetVal->setPtRange(7, 100);
0192   myJetVal->setEtaRange(-1.1, 1.1);
0193   myJetVal->doTruth(0);
0194   //if (isSim) myJetVal->doTruth(1);
0195   myJetVal->doSeeds(0);
0196   myJetVal->doTowers(1);
0197   //myJetVal->doTopoclusters(1);
0198   myJetVal->doEmcalClusters(1);
0199   if (isSim) myJetVal->doTruthParticles(1);
0200   se->registerSubsystem(myJetVal);
0201 
0202   if (!isSim) {
0203     Fun4AllInputManager *in2 = new Fun4AllDstInputManager("DSTcalo");
0204     in2->AddListFile(caloline,1);
0205     se->registerInputManager(in2);
0206 
0207     Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0208     std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0209     intrue2->AddFile(geoLocation);
0210     se->registerInputManager(intrue2);
0211     
0212   } else if (!strcmp(sim_type,"detroit_jet10")) {
0213     Fun4AllInputManager *in2 = new Fun4AllDstInputManager("DSTcalo");
0214     in2->AddListFile(mcfilelistcalo,1);
0215     se->registerInputManager(in2);
0216 
0217     Fun4AllInputManager *in3 = new Fun4AllDstInputManager("DSTglobal");
0218     in3->AddListFile(filelistglobal,1);
0219     se->registerInputManager(in3);
0220 
0221     Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0222     std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0223     intrue2->AddFile(geoLocation);
0224     se->registerInputManager(intrue2);
0225   } else {
0226     Fun4AllInputManager *in2 = new Fun4AllDstInputManager("DSTcalo");
0227     in2->AddListFile(mcfilelistcalo,1);
0228     se->registerInputManager(in2);
0229 
0230     Fun4AllInputManager *intrue = new Fun4AllDstInputManager("DSTtruth");
0231     intrue->AddListFile(filelisttruth,1);
0232     se->registerInputManager(intrue);
0233 
0234     Fun4AllInputManager *in3 = new Fun4AllDstInputManager("DSTglobal");
0235     in3->AddListFile(filelistglobal,1);
0236     se->registerInputManager(in3);
0237 
0238     Fun4AllInputManager *in4 = new Fun4AllDstInputManager("DSTtruthparticle");
0239     in4->AddListFile(filelisttruthparticle,1);
0240     se->registerInputManager(in4);
0241 
0242     Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0243     std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0244     intrue2->AddFile(geoLocation);
0245     se->registerInputManager(intrue2);
0246 
0247   }
0248   
0249   se->run(nEvents);
0250   se->End();
0251   CDBInterface::instance()->Print();  // print used DB files
0252   se->PrintTimer();
0253   gSystem->Exit(0);
0254   return 0;
0255 
0256 }