Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:21:01

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 <fun4allraw/Fun4AllPrdfInputManager.h>
0007 #include <fun4all/Fun4AllDstInputManager.h>
0008 //#include <calotowerbuilder/RawWaveformTowerBuilder.h>
0009 #include <fun4all/Fun4AllDstOutputManager.h>
0010 #include <litecaloeval/LiteCaloEval.h>
0011 
0012 #include <calib_emc_pi0/CaloCalibEmc_Pi0.h>
0013 
0014 #include <caloreco/RawClusterBuilderGraph.h>
0015 #include <caloreco/RawClusterBuilderTemplate.h>
0016 #include <caloreco/RawClusterPositionCorrection.h>
0017 #include <caloreco/RawTowerCalibration.h>
0018 
0019 
0020 R__LOAD_LIBRARY(libfun4all.so)
0021 //R__LOAD_LIBRARY(libfun4allraw.so)
0022 R__LOAD_LIBRARY(libcalo_reco.so)
0023 R__LOAD_LIBRARY(libcalibCaloEmc_pi0.so)
0024 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
0025 
0026 
0027 #endif
0028 
0029 // void Fun4All_TowerBuilder(const char *fname = "/sphenix/data/data02/sphenix/cemc/combinedEvents/EmCalSEB01-000000222-0000_x.prdf", const char *outfile = "trees/0.root")
0030 void srundst_mdc2_clustest(
0031                const int nEvents = 5,
0032                  const string &outputFile = "secoutput4_raw",
0033                  const string &inputFile0 = "ongoing/dstnewoutput5_calo5.root"
0034                //const string &inputFile1 = "DST_VERTEX_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000004-10000.root",
0035                //              const int mdc2_4_file_num = 1,
0036                  )
0037 {
0038 
0039   //  gSystem->Load("libg4dst");
0040 
0041   Fun4AllServer *se = Fun4AllServer::instance();
0042 
0043 /*
0044    string inputFile0 = "DST_CALO_CLUSTER_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000062-";
0045    string inputFile1 = "DST_VERTEX_sHijing_0_20fm_50kHz_bkg_0_20fm-0000000062-";
0046 
0047    
0048    int ynum_int = 100000+ mdc2_4_file_num;
0049    TString yn_tstr = "";
0050    yn_tstr += ynum_int;
0051    yn_tstr.Remove(0,1);
0052    inputFile0 += yn_tstr.Data();
0053    inputFile1 += yn_tstr.Data();
0054 
0055    inputFile0 += ".root";
0056    inputFile1 += ".root";
0057    
0058    cout << "running over these files" << endl;
0059    cout << inputFile0 << endl;
0060    cout << inputFile1 << endl;
0061 */
0062 
0063   // CaloWaveFormSim *ca = new CaloWaveFormSim("CALOWAVEFORMSIM",outfile);
0064   // ca->Detector("CEMC");
0065   // se->registerSubsystem(ca);
0066 
0067   // Fun4AllInputManager *in = new Fun4AllPrdfInputManager("in");
0068   // in->fileopen(fname);
0069 
0070 Fun4AllInputManager *in = new Fun4AllDstInputManager("in");
0071 
0072 //  in->fileopen(inputFile0.c_str());
0073 //  in->fileopen(inputFile1.c_str());
0074   in->AddFile(inputFile0.c_str());
0075 //in->AddFile(inputFile1.c_str());
0076 
0077   //CaloTowerBuilder *ca = new CaloTowerBuilder();
0078   //  RawWaveformTowerBuilder *rw = new RawWaveformTowerBuilder();
0079 
0080   //  rw->set_detector_type(RawWaveformTowerBuilder::CEMC);
0081   //  se->registerSubsystem(rw);
0082 /////
0083 
0084 
0085 
0086 ////////
0087   // in->AddListFile("g4hits.list");
0088 
0089 
0090 
0091 // Fun4All
0092   se->registerInputManager(in);
0093 
0094 
0095     RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
0096     ClusterBuilder->Detector("CEMC");
0097 //    ClusterBuilder->Verbosity(verbosity);
0098     ClusterBuilder->set_threshold_energy(0.030);  // This threshold should be the same as in CEMCprof_Thresh**.root file below
0099     std::string emc_prof = getenv("CALIBRATIONROOT");
0100     emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
0101     ClusterBuilder->LoadProfile(emc_prof);
0102     se->registerSubsystem(ClusterBuilder);
0103 
0104 
0105   RawClusterPositionCorrection *clusterCorrection = new RawClusterPositionCorrection("CEMC");
0106 
0107   clusterCorrection->Get_eclus_CalibrationParameters().ReadFromFile("CEMC_RECALIB", "xml", 0, 0,
0108                                                                       //raw location
0109                                                                       string(getenv("CALIBRATIONROOT")) + string("/CEMC/PositionRecalibration_EMCal_9deg_tilt/"));
0110   clusterCorrection->Get_ecore_CalibrationParameters().ReadFromFile("CEMC_ECORE_RECALIB", "xml", 0, 0,
0111                                                                       //raw location
0112                                                                       string(getenv("CALIBRATIONROOT")) + string("/CEMC/PositionRecalibration_EMCal_9deg_tilt/"));
0113   
0114 
0115 //clusterCorrection->Verbosity(verbosity);
0116   se->registerSubsystem(clusterCorrection);
0117 
0118 
0119 
0120     RawClusterBuilderTemplate *ClusterBuilder2 = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate2");
0121     ClusterBuilder2->Detector("CEMC");
0122     //    ClusterBuilder2->Verbosity(verbosity);
0123     ClusterBuilder2->set_threshold_energy(0.030);  // This threshold should be the same as in CEMCprof_Thresh**.root file below
0124     std::string emc_prof2 = getenv("CALIBRATIONROOT");
0125     emc_prof2 += "/EmcProfile/CEMCprof_Thresh30MeV.root";
0126     ClusterBuilder2->LoadProfile(emc_prof2);
0127     ClusterBuilder2->set_UseTowerInfo(1);
0128     se->registerSubsystem(ClusterBuilder2);
0129 
0130   RawClusterPositionCorrection *clusterCorrection2 = new RawClusterPositionCorrection("CEMC");
0131 
0132   clusterCorrection2->set_UseTowerInfo(1);
0133   if (false)
0134   {
0135     clusterCorrection2->Get_eclus_CalibrationParameters().ReadFromCDB("CEMCRECALIB");
0136     clusterCorrection2->Get_ecore_CalibrationParameters().ReadFromCDB("CEMC_ECORE_RECALIB");
0137   }
0138   else
0139   {
0140     clusterCorrection2->Get_eclus_CalibrationParameters().ReadFromFile("CEMC_RECALIB", "xml", 0, 0,
0141                                                                       //raw location
0142                                                                       string(getenv("CALIBRATIONROOT")) + string("/CEMC/PositionRecalibration_EMCal_9deg_tilt/"));
0143     clusterCorrection2->Get_ecore_CalibrationParameters().ReadFromFile("CEMC_ECORE_RECALIB", "xml", 0, 0,
0144                                                                       //raw location
0145                                                                       string(getenv("CALIBRATIONROOT")) + string("/CEMC/PositionRecalibration_EMCal_9deg_tilt/"));
0146   }
0147 
0148   //  clusterCorrection2->Verbosity(verbosity);
0149   se->registerSubsystem(clusterCorrection2);
0150     
0151 
0152 
0153   string outputFile2 = outputFile.c_str();
0154   outputFile2 = outputFile2 + ".root";
0155   string outputfile5 = outputFile2 + "_cemc_eval5.root";
0156   string outputFile3 = outputFile2 + "_cemc_eval3.root";
0157 
0158 
0159 
0160   LiteCaloEval *eval5 = new LiteCaloEval("CEMCEVALUATOR2", "CEMC", outputfile5.c_str());
0161   //  eval->Verbosity(verbosity);
0162   eval5->CaloType(LiteCaloEval::CEMC);
0163   se->registerSubsystem(eval5);
0164 
0165 
0166   CaloCalibEmc_Pi0 *eval_pi1 = new CaloCalibEmc_Pi0("CEMC_CALIB_PI0", outputFile2);
0167   //  eval_pi1->set_mode(1);
0168   //  eval->Verbosity(verbosity);
0169   se->registerSubsystem(eval_pi1);
0170 
0171 
0172   CaloCalibEmc_Pi0 *eval_pi2 = new CaloCalibEmc_Pi0("CEMC_CALIB_PI02", outputFile3);
0173   //  eval_pi2->set_mode(1);
0174   //  eval->Verbosity(verbosity);
0175   eval_pi2->set_UseTowerInfo(1);
0176   se->registerSubsystem(eval_pi2);
0177   cout << "successful registration of pi0 2" << endl;
0178 
0179   
0180 
0181   /*
0182   Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", "testoutput_simfile_ver2_5.root");
0183 
0184   out->StripNode("WAVEFORMS_CEMC");
0185   se->registerOutputManager(out);
0186 
0187   */
0188 
0189   se->run(nEvents);
0190   se->End();
0191   se->PrintTimer();
0192   //  gSystem->Exit(0);
0193 }