Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:09

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 #include <phool/recoConsts.h>
0008 #include <fun4all/Fun4AllNoSyncDstInputManager.h>
0009 #include <fun4all/Fun4AllDstInputManager.h>
0010 
0011 #include <caloreco/RawClusterBuilderTemplate.h>
0012 #include <fun4all/Fun4AllDstOutputManager.h>
0013 #include <fun4all/Fun4AllOutputManager.h>
0014 
0015 #include <caloreco/CaloTowerBuilder.h>
0016 #include <caloreco/CaloWaveformProcessing.h>
0017 
0018 #include <ffamodules/FlagHandler.h>
0019 #include <ffamodules/HeadReco.h>
0020 #include <ffamodules/SyncReco.h>
0021 #include <ffamodules/CDBInterface.h>
0022 
0023 #include <caloreco/TowerInfoDeadHotMask.h>
0024 #include <caloreco/DeadHotMapLoader.h>
0025 #include <caloreco/RawClusterDeadHotMask.h>
0026 
0027 
0028 #include <caloana/CaloAna.h>
0029 #include <fun4all/Fun4AllDstOutputManager.h>
0030 #include <fun4all/Fun4AllUtils.h>
0031 R__LOAD_LIBRARY(libfun4all.so)
0032 R__LOAD_LIBRARY(libfun4allraw.so)
0033 R__LOAD_LIBRARY(libcalo_reco.so)
0034 R__LOAD_LIBRARY(libcaloana.so)
0035 R__LOAD_LIBRARY(libffamodules.so)
0036 #endif
0037 
0038 void Fun4All_Calo(int nevents = 100,const std::string &fname = "input.txt")
0039 {
0040 
0041   bool enableMasking = 0;
0042 
0043   Fun4AllServer *se = Fun4AllServer::instance();
0044   int verbosity = 0;
0045 
0046   se->Verbosity(verbosity);
0047   recoConsts *rc = recoConsts::instance();
0048 
0049   ifstream file(fname);
0050   string first_file;
0051   getline(file, first_file);
0052 
0053  //===============
0054   // conditions DB flags
0055   //===============
0056   pair<int, int> runseg = Fun4AllUtils::GetRunSegment(first_file);
0057   int runnumber = runseg.first;
0058    cout << "run number = " << runnumber << endl;
0059 
0060   // global tag
0061   rc->set_StringFlag("CDB_GLOBALTAG","MDC2");
0062   // // 64 bit timestamp
0063   rc->set_uint64Flag("TIMESTAMP",runnumber);
0064 
0065 
0066   Fun4AllInputManager *in = new Fun4AllDstInputManager("DST_TOWERS");
0067   in->AddListFile(fname);
0068   se->registerInputManager(in);
0069 
0070   std::string filename = first_file.substr(first_file.find_last_of("/\\") + 1);
0071   std::string OutFile = "CALOHIST_" + filename;
0072 
0073 
0074   /////////////
0075   // masking
0076   if (enableMasking)
0077   {
0078     std::cout << "Loading EMCal deadmap" << std::endl;
0079     DeadHotMapLoader *towerMapCemc = new DeadHotMapLoader("CEMC");
0080     towerMapCemc->detector("CEMC");
0081     se->registerSubsystem(towerMapCemc);
0082 
0083     std::cout << "Loading ihcal deadmap" << std::endl;
0084     DeadHotMapLoader *towerMapHCalin = new DeadHotMapLoader("HCALIN");
0085     towerMapHCalin->detector("HCALIN");
0086     se->registerSubsystem(towerMapHCalin);
0087 
0088     std::cout << "Loading ohcal deadmap" << std::endl;
0089     DeadHotMapLoader *towerMapHCalout = new DeadHotMapLoader("HCALOUT");
0090     towerMapHCalout->detector("HCALOUT");
0091     se->registerSubsystem(towerMapHCalout);
0092 
0093     std::cout << "Loading cemc masker" << std::endl;
0094     TowerInfoDeadHotMask *towerMaskCemc = new TowerInfoDeadHotMask("CEMC");
0095     towerMaskCemc->detector("CEMC");
0096     se->registerSubsystem(towerMaskCemc);
0097 
0098     std::cout << "Loading hcal maskers" << std::endl;
0099     TowerInfoDeadHotMask *towerMaskHCalin = new TowerInfoDeadHotMask("HCALIN");
0100     towerMaskHCalin->detector("HCALIN");
0101     se->registerSubsystem(towerMaskHCalin);
0102 
0103     TowerInfoDeadHotMask *towerMaskHCalout = new TowerInfoDeadHotMask("HCALOUT");
0104     towerMaskHCalout->detector("HCALOUT");
0105     se->registerSubsystem(towerMaskHCalout);
0106 
0107     ///////////
0108     // Clusters
0109     std::cout << "Building clusters" << std::endl;
0110     RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
0111     ClusterBuilder->Detector("CEMC");
0112     ClusterBuilder->set_threshold_energy(0.030);  // for when using basic calibration
0113     std::string emc_prof = getenv("CALIBRATIONROOT");
0114     emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
0115     ClusterBuilder->LoadProfile(emc_prof);
0116     ClusterBuilder->set_UseTowerInfo(1);  // to use towerinfo objects rather than old RawTower
0117     se->registerSubsystem(ClusterBuilder);
0118 
0119 
0120     std::cout << "Masking clusters" << std::endl;
0121     RawClusterDeadHotMask *clusterMask = new RawClusterDeadHotMask("clusterMask");
0122     clusterMask->detector("CEMC");
0123     se->registerSubsystem(clusterMask);
0124 
0125   }
0126 
0127   CaloAna *ca = new CaloAna("calomodulename",OutFile);
0128   ca->set_timing_cut_width(200);  //integers for timing width, > 1 : wider cut around max peak time
0129   ca->apply_vertex_cut(false);  
0130   ca->set_vertex_cut(20.);
0131   se->registerSubsystem(ca);
0132 
0133   se->run(nevents); //update number of events as needed
0134   se->End();
0135 
0136 }