Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-08-30 08:24:57

0001 /*
0002  * This macro shows a minimum working example of running the tracking
0003  * hit unpackers with some basic seeding algorithms to try to put together
0004  * tracks. There are some analysis modules run at the end which package
0005  * hits, clusters, and clusters on tracks into trees for analysis.
0006  */
0007 
0008 #include <fun4all/Fun4AllUtils.h>
0009 #include <GlobalVariables.C>
0010 #include <G4_ActsGeom.C>
0011 #include <G4_Global.C>
0012 #include <G4_Magnet.C>
0013 #include <G4_Mbd.C>
0014 #include <Trkr_Clustering.C>
0015 #include <Trkr_LaserClustering.C>
0016 #include <Trkr_RecoInit.C>
0017 #include <Trkr_TpcReadoutInit.C>
0018 
0019 #include <ffamodules/CDBInterface.h>
0020 #include <fun4all/Fun4AllDstInputManager.h>
0021 #include <fun4all/Fun4AllDstOutputManager.h>
0022 #include <fun4all/Fun4AllInputManager.h>
0023 #include <fun4all/Fun4AllOutputManager.h>
0024 #include <fun4all/Fun4AllRunNodeInputManager.h>
0025 #include <fun4all/Fun4AllServer.h>
0026 
0027 #include <phool/recoConsts.h>
0028 
0029 //#include <tpc/LaserEventIdentifier.h>
0030 
0031 #include <tpccalib/TpcCentralMembraneMatching.h>
0032 //#include <lasermatchingqa/laserMatchingQApp.h>
0033 
0034 #include <fstream>
0035 #include <cstdio>
0036 #include <format>
0037 R__LOAD_LIBRARY(libfun4all.so)
0038 R__LOAD_LIBRARY(libffamodules.so)
0039 R__LOAD_LIBRARY(libtpc.so)
0040 R__LOAD_LIBRARY(libtpccalib.so)
0041 //R__LOAD_LIBRARY(libLaserMatchingQA.so)
0042 void Fun4All_LaserMatching(
0043     const int nEvents = 10,
0044     const std::string& filelist = "",
0045     const std::string& distortionCorrection = "",
0046     const std::string& outdir = "/sphenig/tg/tg01/jets/bkimelman/")
0047 {
0048 
0049   auto *se = Fun4AllServer::instance();
0050   se->Verbosity(2);
0051 
0052   //std::string inputFile = tpcdir + tpcfilename;
0053   
0054   //std::pair<int, int>
0055   //runseg = Fun4AllUtils::GetRunSegment(tpcfilename);
0056   //int runnumber = runseg.first;
0057   //int segment = runseg.second;
0058   
0059   auto *rc = recoConsts::instance();
0060 
0061   Enable::CDB = true;
0062   rc->set_StringFlag("CDB_GLOBALTAG", "newcdbtag");
0063   //rc->set_IntFlag("RUNNUMBER",runnumber);
0064   //rc->set_uint64Flag("TIMESTAMP",runnumber);
0065 
0066   std::ifstream ifs(filelist);
0067   std::string filepath;
0068 
0069 
0070   int i=0;
0071   int runnumber = 0;
0072   int segment = 0;
0073   while(std::getline(ifs,filepath))
0074   {
0075     std::cout << "Adding DST with filepath: " << filepath << std::endl;
0076     if(i==0)
0077     {
0078       std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(filepath);
0079       runnumber = runseg.first;
0080       segment = runseg.second;
0081       rc->set_IntFlag("RUNNUMBER",runnumber);
0082       rc->set_uint64Flag("TIMESTAMP",runnumber);
0083     }
0084 
0085     //std::string inputname = "InputManager" + std::to_string(i);
0086     //auto hitsin = new Fun4AllDstInputManager(inputname);
0087     //hitsin->fileopen(filepath);
0088     //se->registerInputManager(hitsin);
0089     i++;
0090   }
0091 
0092 
0093   auto *hitsin = new Fun4AllDstInputManager("InputManager");
0094   hitsin->AddListFile(filelist);
0095   se->registerInputManager(hitsin);
0096   
0097   //auto hitsin = new Fun4AllDstInputManager("InputManager");
0098   //hitsin->fileopen(inputFile);
0099   //se->registerInputManager(hitsin);
0100   
0101 
0102   TRACKING::tpc_zero_supp = true;
0103   Enable::MVTX_APPLYMISALIGNMENT = true;
0104   ACTSGEOM::mvtx_applymisalignment = Enable::MVTX_APPLYMISALIGNMENT;
0105   
0106   std::string geofile = CDBInterface::instance()->getUrl("Tracking_Geometry");
0107   Fun4AllRunNodeInputManager *ingeo = new Fun4AllRunNodeInputManager("GeoIn");
0108   ingeo->AddFile(geofile);
0109   se->registerInputManager(ingeo);
0110 
0111   
0112   //  G4TPC::tpc_drift_velocity_reco = (8.0 / 1000) * 107.0 / 105.0;
0113   G4TPC::ENABLE_MODULE_EDGE_CORRECTIONS = true;
0114   //to turn on the default static corrections, enable the two lines below
0115 
0116   if(runnumber == 52077 || runnumber == 52078 || (runnumber >= 75103 && runnumber <= 75114) || (runnumber >= 75555 && runnumber <= 75574))
0117   {
0118 
0119     G4TPC::ENABLE_STATIC_CORRECTIONS = false;  
0120   }
0121   else
0122   {
0123     G4TPC::ENABLE_STATIC_CORRECTIONS = true;
0124     G4TPC::USE_PHI_AS_RAD_STATIC_CORRECTIONS=false;
0125   }
0126 
0127   if (!distortionCorrection.empty())
0128   {    
0129     G4TPC::ENABLE_AVERAGE_CORRECTIONS = true;
0130     
0131     G4TPC::average_correction_filename = distortionCorrection;
0132     G4TPC::USE_PHI_AS_RAD_AVERAGE_CORRECTIONS=false;
0133     G4TPC::average_correction_interpolate = false;
0134   }
0135   else
0136   {
0137     G4TPC::ENABLE_AVERAGE_CORRECTIONS = false;
0138   }
0139     
0140   
0141   //G4TPC::DISTORTIONS_USE_PHI_AS_RADIANS = false;
0142 
0143   //TRACKING::reco_tpc_maxtime_sample = 1023;
0144 
0145   TrackingInit();
0146 
0147 
0148   auto *centralMembraneMatcher = new TpcCentralMembraneMatching;
0149   centralMembraneMatcher->setSavehistograms( true );
0150   centralMembraneMatcher->Verbosity( 1 );
0151   centralMembraneMatcher->set_fieldOn(true);
0152   centralMembraneMatcher->set_doFancy(false);
0153   centralMembraneMatcher->set_doHadd(true);
0154   centralMembraneMatcher->set_averageMode(true);
0155   centralMembraneMatcher->set_event_sequence(segment);
0156   centralMembraneMatcher->setHistogramOutputfile(
0157     std::format("{}/PHTpcCentralMembraneMatcher-{:08d}-all.root",
0158                 outdir, runnumber));
0159 
0160   centralMembraneMatcher->setOutputfile(
0161     std::format("{}/CMDistortionCorrections-{:08d}-all.root",
0162                 outdir, runnumber));
0163 
0164   centralMembraneMatcher->setDebugOutputFile(
0165     std::format("{}/CMMatching-{:08d}-all.root",
0166                 outdir, runnumber));
0167   centralMembraneMatcher->set_grid_dimensions(500,500);
0168   se->registerSubsystem(centralMembraneMatcher);
0169 
0170 
0171   //auto lmQA = new laserMatchingQApp;
0172   //lmQA->setOutfile(Form("%s/LaserMatchingQA-%08d-all",outdir.c_str(),runnumber));
0173   //lmQA->setRunnumber(runnumber);
0174   //se->registerSubsystem(lmQA);
0175   
0176   se->run(nEvents);
0177   //se->run(-1);
0178   se->End();
0179   se->PrintTimer();
0180 
0181   delete se;
0182   std::cout << "Finished" << std::endl;
0183   gSystem->Exit(0);
0184 }