Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include <filesystem>
0002 #include <iostream>
0003 #include <string>
0004 
0005 #include <fun4all/Fun4AllDstInputManager.h>
0006 #include <fun4all/Fun4AllDstOutputManager.h>
0007 #include <fun4all/Fun4AllInputManager.h>
0008 #include <fun4all/Fun4AllOutputManager.h>
0009 #include <fun4all/Fun4AllServer.h>
0010 #include <fun4all/SubsysReco.h>
0011 
0012 #include <phool/recoConsts.h>
0013 
0014 #include <G4Setup_sPHENIX.C>
0015 #include <Trkr_Clustering.C>
0016 #include <Trkr_Reco.C>
0017 #include <Trkr_RecoInit.C>
0018 
0019 #include <intt/InttCombinedRawDataDecoder.h>
0020 #include <intt/InttMapping.h>
0021 
0022 #include <calotrigger/MinimumBiasClassifier.h>
0023 #include <calotrigger/TriggerRunInfoReco.h>
0024 #include <centrality/CentralityReco.h>
0025 #include <globalvertex/GlobalVertexReco.h>
0026 // #include <centrality/CentralityValid.h>
0027 
0028 #include <dndetaintt/dNdEtaINTT.h>
0029 
0030 #include <caloreco/CaloTowerBuilder.h>
0031 #include <caloreco/CaloTowerCalib.h>
0032 #include <mbd/MbdReco.h>
0033 #include <zdcinfo/ZdcReco.h>
0034 
0035 #include <GlobalVariables.C>
0036 
0037 #include <G4_ActsGeom.C>
0038 #include <G4_TrkrVariables.C>
0039 #include <intt/InttClusterizer.h>
0040 
0041 R__LOAD_LIBRARY(libfun4allraw.so)
0042 R__LOAD_LIBRARY(libffarawmodules.so)
0043 R__LOAD_LIBRARY(libfun4all.so)
0044 R__LOAD_LIBRARY(libffamodules.so)
0045 R__LOAD_LIBRARY(libdNdEtaINTT.so)
0046 R__LOAD_LIBRARY(libcentrality_io.so)
0047 R__LOAD_LIBRARY(libcentrality.so)
0048 R__LOAD_LIBRARY(libg4centrality.so)
0049 R__LOAD_LIBRARY(libcalotrigger.so)
0050 R__LOAD_LIBRARY(libmbd.so)
0051 R__LOAD_LIBRARY(libglobalvertex.so)
0052 // R__LOAD_LIBRARY(libcentralityvalid.so)
0053 R__LOAD_LIBRARY(libzdcinfo.so)
0054 
0055 void Intt_ZClustering()
0056 {
0057     int verbosity = std::max(Enable::VERBOSITY, Enable::INTT_VERBOSITY);
0058     Fun4AllServer *se = Fun4AllServer::instance();
0059 
0060     InttClusterizer *inttclusterizer = new InttClusterizer("InttClusterizer", G4MVTX::n_maps_layer, G4MVTX::n_maps_layer + G4INTT::n_intt_layer - 1);
0061     inttclusterizer->Verbosity(verbosity);
0062     // no Z clustering for Intt type 1 layers (we DO want Z clustering for type 0 layers)
0063     // turning off phi clustering for type 0 layers is not necessary, there is only one strip
0064     // per sensor in phi
0065     for (int i = G4MVTX::n_maps_layer; i < G4MVTX::n_maps_layer + G4INTT::n_intt_layer; i++)
0066     {
0067         if (G4INTT::laddertype[i - G4MVTX::n_maps_layer] == PHG4InttDefs::SEGMENTATION_PHI)
0068         {
0069             inttclusterizer->set_z_clustering(i, true);
0070         }
0071     }
0072     se->registerSubsystem(inttclusterizer);
0073 }
0074 
0075 int Fun4All_dNdeta2024AuAu_production(                          //
0076     const int runnumber = 54280,                                //
0077     const string productionTag = "ProdA_2024",                  //
0078     const string calodstlist = "./calolists/calo_54280_1.list", //
0079     const string inttdstlist = "./inttlists/intt_54280_0.list", //
0080     const int nEvents = 10,                                     //
0081     const string &outputFile = "./testNtuple.root",               //
0082     const int process = 0,                                      //
0083     const int skip = 0                                          //
0084 )
0085 {
0086     bool centralitycalib = true;
0087     bool minimumbiascalib = true;
0088     bool dointthitunpacking = false;
0089     bool doclustering = false;
0090     bool enable_inttzclustering = false;
0091 
0092     // local calibration files
0093     std::string hotchannel_file = "/sphenix/user/jaein213/macros/inttcalib/hotmap_cdb/hotmap_run_000" + std::to_string(runnumber) + ".root";
0094     std::string bcomap_file = "/sphenix/user/jaein213/macros/inttcalib/bcomap_cdb/bcomap_run_000" + std::to_string(runnumber) + ".root";
0095     std::string dac_file = "/sphenix/tg/tg01/commissioning/INTT/data/CDB_files/2024/dac_map/cdb_intt_dac_35_45_60_90_120_150_180_210_streaming.root";
0096 
0097     // guard
0098     if (!std::filesystem::exists(hotchannel_file))
0099     {
0100         std::cerr << "Error: Hot channel file does not exist: " << hotchannel_file << std::endl;
0101         return 1;
0102     }
0103 
0104     if (!std::filesystem::exists(bcomap_file))
0105     {
0106         std::cerr << "Error: BCO map file does not exist: " << bcomap_file << std::endl;
0107         return 1;
0108     }
0109 
0110     if (!std::filesystem::exists(dac_file))
0111     {
0112         std::cerr << "Error: DAC file does not exist: " << dac_file << std::endl;
0113         return 1;
0114     }
0115 
0116     Fun4AllServer *se = Fun4AllServer::instance();
0117     se->Verbosity(INT_MAX - 1);
0118 
0119     recoConsts *rc = recoConsts::instance();
0120 
0121     Enable::CDB = true;
0122     rc->set_StringFlag("CDB_GLOBALTAG", productionTag);
0123     rc->set_uint64Flag("TIMESTAMP", runnumber);
0124     rc->set_IntFlag("RUNNUMBER", runnumber); //! TODO: change the runnumber when the centrality calibration is available in CDB
0125 
0126     Fun4AllInputManager *caloinput = new Fun4AllDstInputManager("DST_calo");
0127     caloinput->Verbosity(2);
0128     caloinput->AddListFile(calodstlist);
0129     se->registerInputManager(caloinput);
0130 
0131     Fun4AllInputManager *inttinput = new Fun4AllDstInputManager("DST_track");
0132     inttinput->Verbosity(2);
0133     inttinput->AddListFile(inttdstlist);
0134     se->registerInputManager(inttinput);
0135 
0136     // Enable::MBD = true;
0137     // Enable::MBDRECO = false;
0138     // Enable::MBD_VERBOSITY = INT_MAX - 1;
0139     Enable::PIPE = true;
0140     Enable::MVTX = true;
0141     Enable::INTT = true;
0142     Enable::TPC = true;
0143     Enable::MICROMEGAS = true;
0144     Enable::ZDC = minimumbiascalib;
0145     Enable::ZDC_TOWER = minimumbiascalib;
0146 
0147     G4Init();
0148     G4Setup();
0149 
0150     if (dointthitunpacking)
0151     {
0152         // INTT unpacker - non-standard setup
0153         auto inttunpacker = new InttCombinedRawDataDecoder;
0154         inttunpacker->Verbosity(0);
0155         inttunpacker->runInttStandalone(true);
0156         inttunpacker->writeInttEventHeader(true);
0157         inttunpacker->set_triggeredMode(true);
0158         // inttunpacker->LoadHotChannelMapLocal(hotchannel_file);
0159         // inttunpacker->SetCalibBCO(bcomap_file, InttCombinedRawDataDecoder::FILE);
0160         // inttunpacker->SetCalibDAC(dac_file, InttCombinedRawDataDecoder::FILE);
0161         inttunpacker->LoadHotChannelMapRemote("INTT_HotChannelMap");
0162         inttunpacker->SetCalibBCO("INTT_BCOMAP", InttCombinedRawDataDecoder::CDB);
0163         inttunpacker->SetCalibDAC("INTT_DACMAP", InttCombinedRawDataDecoder::CDB);
0164         inttunpacker->set_bcoFilter(true);
0165         se->registerSubsystem(inttunpacker);
0166     }
0167 
0168     TrackingInit();
0169 
0170     if (doclustering)
0171     {
0172         if (enable_inttzclustering)
0173             Intt_ZClustering();
0174         else
0175             Intt_Clustering();
0176     }
0177 
0178     if (minimumbiascalib)
0179     {
0180         MbdReco *mbdreco = new MbdReco();
0181         mbdreco->Verbosity(0);
0182         se->registerSubsystem(mbdreco);
0183 
0184         GlobalVertexReco *gblvertex = new GlobalVertexReco();
0185         gblvertex->Verbosity(0);
0186         se->registerSubsystem(gblvertex);
0187 
0188         CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFTowerv4;
0189         CaloTowerBuilder *caZDC = new CaloTowerBuilder("ZDCBUILDER");
0190         caZDC->set_detector_type(CaloTowerDefs::ZDC);
0191         caZDC->set_builder_type(buildertype);
0192         caZDC->set_processing_type(CaloWaveformProcessing::FAST);
0193         caZDC->set_nsamples(16);
0194         caZDC->set_offlineflag();
0195         se->registerSubsystem(caZDC);
0196 
0197         std::cout << "Calibrating ZDC" << std::endl;
0198         CaloTowerCalib *calibZDC = new CaloTowerCalib("ZDC");
0199         calibZDC->set_detector_type(CaloTowerDefs::ZDC);
0200         se->registerSubsystem(calibZDC); // conditions DB flags
0201 
0202         // ZDC Reconstruction--Calib Info
0203         ZdcReco *zdcreco = new ZdcReco();
0204         zdcreco->set_zdc1_cut(0.0);
0205         zdcreco->set_zdc2_cut(0.0);
0206         se->registerSubsystem(zdcreco);
0207 
0208         MinimumBiasClassifier *mb = new MinimumBiasClassifier();
0209         mb->Verbosity(0);
0210         mb->setOverwriteScale("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/scales/cdb_centrality_scale_54280.root");            // Temoporary fix
0211         mb->setOverwriteVtx("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/vertexscales/cdb_centrality_vertex_scale_54280.root"); // Temoporary fix
0212         se->registerSubsystem(mb);
0213     }
0214 
0215     if (centralitycalib)
0216     {
0217         CentralityReco *cr = new CentralityReco();
0218         cr->Verbosity(INT_MAX - 1);
0219         cr->setOverwriteScale("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/scales/cdb_centrality_scale_54280.root");
0220         cr->setOverwriteVtx("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/vertexscales/cdb_centrality_vertex_scale_54280.root");
0221         cr->setOverwriteDivs("/sphenix/user/dlis/Projects/centrality/cdb/calibrations/divs/cdb_centrality_54280.root");
0222         se->registerSubsystem(cr);
0223     }
0224 
0225     TriggerRunInfoReco *triggerruninforeco = new TriggerRunInfoReco();
0226     se->registerSubsystem(triggerruninforeco);
0227 
0228     dNdEtaINTT *myAnalyzer = new dNdEtaINTT("dNdEtaAnalyzer", outputFile, true);
0229     myAnalyzer->GetINTTdata(true);
0230     myAnalyzer->GetRecoCluster(true);
0231     myAnalyzer->GetInttRawHit(false);
0232     myAnalyzer->GetTrkrHit(true);
0233     myAnalyzer->GetCentrality(true);
0234     myAnalyzer->GetPMTInfo(true);
0235     myAnalyzer->GetPHG4(false);
0236     myAnalyzer->GetHEPMC(false);
0237     myAnalyzer->GetTrigger(true);
0238     se->registerSubsystem(myAnalyzer);
0239 
0240     //--------------
0241     // Set up Input Managers
0242     //--------------
0243     // InputManagers();
0244 
0245     //-----------------
0246     // Event processing
0247     //-----------------
0248     se->skip(skip);
0249     se->run(nEvents);
0250 
0251     //-----
0252     // Exit
0253     //-----
0254     se->End();
0255     std::cout << "All done" << std::endl;
0256     delete se;
0257 
0258     gSystem->Exit(0);
0259     return 0;
0260 }