Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:12:49

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/RawClusterLikelihoodProfile.h>
0008 #include <caloreco/RawClusterDeadHotMask.h>
0009 #include <caloreco/RawClusterPositionCorrection.h>
0010 
0011 #include <ffamodules/CDBInterface.h>
0012 #include <ffamodules/FlagHandler.h>
0013 #include <phool/recoConsts.h>
0014 
0015 #include <fun4all/Fun4AllInputManager.h>
0016 #include <fun4all/Fun4AllRunNodeInputManager.h>
0017 
0018 
0019 R__LOAD_LIBRARY(libcalo_reco.so)
0020 R__LOAD_LIBRARY(libffamodules.so)
0021 R__LOAD_LIBRARY(libfun4allutils.so)
0022 
0023 void Modified_Calo_Calib_ForClusterProb_PPRun24()
0024 {
0025   Fun4AllServer *se = Fun4AllServer::instance();
0026   recoConsts *rc = recoConsts::instance();
0027   
0028   /////////////////
0029   // set MC or data 
0030   bool isSim = true;
0031   int data_sim_runnumber_thres = 1000;
0032   if (rc->get_uint64Flag("TIMESTAMP") > data_sim_runnumber_thres) 
0033   {
0034     isSim = false;
0035   }
0036   std::cout << "Calo Calib uses runnumber " << rc->get_uint64Flag("TIMESTAMP") << std::endl;
0037 
0038   //////////////////////////////
0039   // set statuses on raw towers
0040   std::cout << "status setters" << std::endl;
0041   CaloTowerStatus *statusEMC = new CaloTowerStatus("CEMCSTATUS");
0042   statusEMC->set_detector_type(CaloTowerDefs::CEMC);
0043   statusEMC->set_time_cut(1);
0044   se->registerSubsystem(statusEMC);
0045 
0046   CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS");
0047   statusHCalIn->set_detector_type(CaloTowerDefs::HCALIN);
0048   statusHCalIn->set_time_cut(2);
0049   se->registerSubsystem(statusHCalIn);
0050 
0051   CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS");
0052   statusHCALOUT->set_detector_type(CaloTowerDefs::HCALOUT);
0053   statusHCALOUT->set_time_cut(2);
0054   se->registerSubsystem(statusHCALOUT);
0055 
0056   ////////////////////
0057   // Calibrate towers
0058   std::cout << "Calibrating EMCal" << std::endl;
0059   CaloTowerCalib *calibEMC = new CaloTowerCalib("CEMCCALIB");
0060   calibEMC->set_detector_type(CaloTowerDefs::CEMC);
0061   se->registerSubsystem(calibEMC);
0062 
0063   std::cout << "Calibrating OHcal" << std::endl;
0064   CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT");
0065   calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0066   se->registerSubsystem(calibOHCal);
0067 
0068   std::cout << "Calibrating IHcal" << std::endl;
0069   CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN");
0070   calibIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0071   se->registerSubsystem(calibIHCal);
0072 
0073   ////////////////
0074   // MC Calibration
0075   if (isSim) 
0076   {
0077     std::string MC_Calib = CDBInterface::instance()->getUrl("CEMC_MC_RECALIB");
0078     if (MC_Calib.empty())
0079     {
0080       std::cout << "No MC calibration found :( )" << std::endl;
0081       gSystem->Exit(0);
0082     }
0083     CaloTowerCalib *calibEMC_MC = new CaloTowerCalib("CEMCCALIB_MC");
0084     calibEMC_MC->set_detector_type(CaloTowerDefs::CEMC);
0085     calibEMC_MC->set_inputNodePrefix("TOWERINFO_CALIB_");
0086     calibEMC_MC->set_outputNodePrefix("TOWERINFO_CALIB_");
0087     calibEMC_MC->set_directURL(MC_Calib);
0088     calibEMC_MC->set_doZScrosscalib(false);
0089     se->registerSubsystem(calibEMC_MC);
0090   }
0091 
0092   //////////////////
0093   // Clusters
0094   std::cout << "Building clusters" << std::endl;
0095   
0096   //Default cluster
0097   RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
0098   ClusterBuilder->Detector("CEMC");
0099   ClusterBuilder->set_threshold_energy(0.070); 
0100   std::string emc_prof = getenv("CALIBRATIONROOT");
0101   emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
0102   std::cout << emc_prof.c_str() << std::endl;
0103   ClusterBuilder->LoadProfile(emc_prof);
0104   ClusterBuilder->set_UseTowerInfo(1);
0105   ClusterBuilder->setSubclusterSplitting(true); // Cluster splitting on
0106   ClusterBuilder->Verbosity(1);
0107 
0108   //Mother cluster
0109   RawClusterBuilderTemplate *ClusterBuilderMother = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplateMother");
0110   ClusterBuilderMother->Detector("CEMC");
0111   ClusterBuilderMother->set_threshold_energy(0.070); 
0112   ClusterBuilderMother->LoadProfile(emc_prof);
0113   ClusterBuilderMother->set_UseTowerInfo(1); 
0114   ClusterBuilderMother->setSubclusterSplitting(false); // Cluster splitting off
0115   ClusterBuilderMother->set_outputNodeName("CEMC_CLUSTERINFO_MOTHER");
0116   ClusterBuilderMother->Verbosity(1);
0117 
0118   //Default cluster profile
0119   std::string probprofile = CDBInterface::instance()->getUrl("EMCPROBPROFILE");
0120   std::cout << "probprofile : " << probprofile.c_str() << std::endl;
0121   RawClusterLikelihoodProfile *ClusterProfile = new RawClusterLikelihoodProfile("RawClusterLikelihoodProfile");
0122   ClusterProfile->set_profile_filepath(probprofile);
0123   ClusterProfile->set_min_cluster_e(1.0);
0124   ClusterProfile->set_inputNodeName("CEMC_CLUSTERINFO");
0125   ClusterProfile->set_outputNodeName("CEMC_CLUSTERINFO");
0126 
0127   //Mother cluster profile
0128   RawClusterLikelihoodProfile *ClusterProfileMother= new RawClusterLikelihoodProfile("RawClusterLikelihoodProfileMother");
0129   ClusterProfileMother->set_profile_filepath(probprofile);
0130   ClusterProfileMother->set_min_cluster_e(1.0);
0131   ClusterProfileMother->set_inputNodeName("CEMC_CLUSTERINFO_MOTHER");
0132   ClusterProfileMother->set_outputNodeName("CEMC_CLUSTERINFO_MOTHER");
0133 
0134   se->registerSubsystem(ClusterBuilder);
0135   se->registerSubsystem(ClusterBuilderMother);
0136   se->registerSubsystem(ClusterProfile);
0137   se->registerSubsystem(ClusterProfileMother);
0138 
0139   // currently NOT included! 
0140   //std::cout << "Applying Position Dependent Correction" << std::endl;
0141   //RawClusterPositionCorrection *clusterCorrection = new RawClusterPositionCorrection("CEMC");
0142   //clusterCorrection->set_UseTowerInfo(1);  // to use towerinfo objects rather than old RawTower
0143  // se->registerSubsystem(clusterCorrection);
0144 }
0145 
0146 #endif