Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #ifndef CALO_CALIB_H
0002 #define CALO_CALIB_H
0003 
0004 #include <caloreco/CaloTowerCalib.h>
0005 #include <caloreco/CaloTowerStatus.h>
0006 #include <caloreco/RawClusterBuilderTemplate.h>
0007 #include <caloreco/RawClusterDeadHotMask.h>
0008 #include <caloreco/RawClusterPositionCorrection.h>
0009 
0010 #include <ffamodules/CDBInterface.h>
0011 #include <ffamodules/FlagHandler.h>
0012 
0013 #include <fun4all/Fun4AllInputManager.h>
0014 #include <fun4all/Fun4AllRunNodeInputManager.h>
0015 #include <fun4all/Fun4AllServer.h> // for Fun4AllServer
0016 
0017 #include <phool/recoConsts.h>
0018 
0019 #include <TSystem.h> // for gSystem
0020 
0021 R__LOAD_LIBRARY(libcalo_reco.so)
0022 R__LOAD_LIBRARY(libffamodules.so)
0023 R__LOAD_LIBRARY(libfun4allutils.so)
0024 
0025 void Process_Calo_Calib_Mahirochan()
0026 {
0027     Fun4AllServer *se = Fun4AllServer::instance();
0028     recoConsts *rc = recoConsts::instance();
0029 
0030     /////////////////
0031     // set MC or data
0032     bool isSim = true;
0033     int data_sim_runnumber_thres = 1000;
0034     if (rc->get_uint64Flag("TIMESTAMP") > data_sim_runnumber_thres)
0035     {
0036         isSim = false;
0037     }
0038     std::cout << "Calo Calib uses runnumber " << rc->get_uint64Flag("TIMESTAMP") << std::endl;
0039 
0040     //////////////////////
0041     // Input geometry node
0042     std::cout << "Adding Geometry file" << std::endl;
0043     Fun4AllInputManager *ingeo = new Fun4AllRunNodeInputManager("DST_GEO");
0044     std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0045     ingeo->AddFile(geoLocation);
0046     se->registerInputManager(ingeo);
0047 
0048     //////////////////////////////
0049     // set statuses on raw towers
0050     std::cout << "status setters" << std::endl;
0051     CaloTowerStatus *statusEMC = new CaloTowerStatus("CEMCSTATUS");
0052     statusEMC->set_detector_type(CaloTowerDefs::CEMC);
0053     statusEMC->set_time_cut(1);
0054     // MC Towers Status
0055     if (isSim)
0056     {
0057         // Uses threshold of 50% for towers be considered frequently bad.
0058         std::string calibName_hotMap = "CEMC_hotTowers_status";
0059         /* Systematic options (to be used as needed). */
0060         /* Uses threshold of 40% for towers be considered frequently bad. */
0061         // std::string calibName_hotMap = "CEMC_hotTowers_status_40";
0062 
0063         /* Uses threshold of 60% for towers be considered frequently bad. */
0064         // std::string calibName_hotMap = "CEMC_hotTowers_status_60";
0065 
0066         std::string calibdir = CDBInterface::instance()->getUrl(calibName_hotMap);
0067         statusEMC->set_directURL_hotMap(calibdir);
0068     }
0069     se->registerSubsystem(statusEMC);
0070 
0071     CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS");
0072     statusHCalIn->set_detector_type(CaloTowerDefs::HCALIN);
0073     statusHCalIn->set_time_cut(2);
0074     se->registerSubsystem(statusHCalIn);
0075 
0076     CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS");
0077     statusHCALOUT->set_detector_type(CaloTowerDefs::HCALOUT);
0078     statusHCALOUT->set_time_cut(2);
0079     se->registerSubsystem(statusHCALOUT);
0080 
0081     ////////////////////
0082     // Calibrate towers
0083     std::cout << "Calibrating EMCal" << std::endl;
0084     CaloTowerCalib *calibEMC = new CaloTowerCalib("CEMCCALIB");
0085     calibEMC->set_detector_type(CaloTowerDefs::CEMC);
0086     se->registerSubsystem(calibEMC);
0087 
0088     std::cout << "Calibrating OHcal" << std::endl;
0089     CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT");
0090     calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0091     se->registerSubsystem(calibOHCal);
0092 
0093     std::cout << "Calibrating IHcal" << std::endl;
0094     CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN");
0095     calibIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0096     se->registerSubsystem(calibIHCal);
0097 
0098     ////////////////
0099     // MC Calibration
0100     if (isSim && rc->get_uint64Flag("TIMESTAMP") < 28) // in run28 and beyond we moved the MC calibration into the waveformsim module for data embedding
0101     {
0102         std::string MC_Calib = CDBInterface::instance()->getUrl("CEMC_MC_RECALIB");
0103         if (MC_Calib.empty())
0104         {
0105             std::cout << "No MC calibration found :( )" << std::endl;
0106             gSystem->Exit(0);
0107         }
0108         CaloTowerCalib *calibEMC_MC = new CaloTowerCalib("CEMCCALIB_MC");
0109         calibEMC_MC->set_detector_type(CaloTowerDefs::CEMC);
0110         calibEMC_MC->set_inputNodePrefix("TOWERINFO_CALIB_");
0111         calibEMC_MC->set_outputNodePrefix("TOWERINFO_CALIB_");
0112         calibEMC_MC->set_directURL(MC_Calib);
0113         calibEMC_MC->set_doCalibOnly(true);
0114         se->registerSubsystem(calibEMC_MC);
0115     }
0116 
0117     //////////////////
0118     // Clusters
0119     std::cout << "Building clusters" << std::endl;
0120     RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
0121 
0122     ClusterBuilder->Detector("CEMC");
0123     ClusterBuilder->set_threshold_energy(0.070); // for when using basic calibration
0124     std::string emc_prof = getenv("CALIBRATIONROOT");
0125     emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
0126     ClusterBuilder->LoadProfile(emc_prof);
0127     ClusterBuilder->set_UseTowerInfo(1);  // to use towerinfo objects rather than old RawTower
0128     ClusterBuilder->set_UseAltZVertex(1); // Use MBD Vertex for vertex-based corrections
0129     ClusterBuilder->set_UseDetailedGeometry(false);
0130     se->registerSubsystem(ClusterBuilder);
0131 
0132     // currently NOT included!
0133     // std::cout << "Applying Position Dependent Correction" << std::endl;
0134     // RawClusterPositionCorrection *clusterCorrection = new RawClusterPositionCorrection("CEMC");
0135     // clusterCorrection->set_UseTowerInfo(1);  // to use towerinfo objects rather than old RawTower
0136     // se->registerSubsystem(clusterCorrection);
0137 }
0138 
0139 #endif