Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:16:52

0001 // GlobalVariables.C has to be included first, leave next line empty
0002 // so running clang-format will not reorganize order
0003 #include <GlobalVariables.C>
0004 
0005 #include <QA.C>
0006 
0007 #include <inttcalib/InttCalib.h>
0008 
0009 #include <ffamodules/HeadReco.h>
0010 #include <ffamodules/FlagHandler.h>
0011 #include <ffamodules/SyncReco.h>
0012 #include <ffamodules/CDBInterface.h>
0013 
0014 #include <ffarawmodules/InttCheck.h>
0015 #include <ffarawmodules/StreamingCheck.h>
0016 #include <ffarawmodules/TpcCheck.h>
0017 
0018 #include <fun4all/Fun4AllDstOutputManager.h>
0019 #include <fun4all/Fun4AllInputManager.h>
0020 #include <fun4all/Fun4AllDstInputManager.h>
0021 #include <fun4all/Fun4AllOutputManager.h>
0022 #include <fun4all/Fun4AllServer.h>
0023 #include <fun4all/Fun4AllUtils.h>
0024 
0025 #include <fun4allraw/Fun4AllStreamingInputManager.h>
0026 #include <fun4allraw/InputManagerType.h>
0027 #include <fun4allraw/SingleGl1PoolInput.h>
0028 #include <fun4allraw/SingleInttPoolInput.h>
0029 #include <fun4allraw/SingleMicromegasPoolInput.h>
0030 #include <fun4allraw/SingleMvtxPoolInput.h>
0031 #include <fun4allraw/SingleTpcPoolInput.h>
0032 #include <fun4allraw/SingleTpcTimeFrameInput.h>
0033 
0034 #include <phgarfield/PHGarfield.h>
0035 
0036 #include <TPolyLine.h>
0037 #include <TPolyLine3D.h>
0038 #include <TCanvas.h>
0039 #include <TGeoTube.h>
0040 #include <TBox.h>
0041 #include <phool/recoConsts.h>
0042 
0043 #include <format>
0044 R__LOAD_LIBRARY(libfun4all.so)
0045 R__LOAD_LIBRARY(libfun4allutils.so)
0046 R__LOAD_LIBRARY(libffamodules.so)
0047 R__LOAD_LIBRARY(libfun4allraw.so)
0048 R__LOAD_LIBRARY(libffarawmodules.so)
0049 R__LOAD_LIBRARY(libcdbobjects.so)
0050 R__LOAD_LIBRARY(libffamodules.so)
0051 R__LOAD_LIBRARY(libPHGarfield.so)
0052 
0053 #define Nebdc 24
0054 #define Nserver 2
0055 
0056 // Global namespace to assist drawing...
0057 TPolyLine3D *npoly3[48];
0058 TPolyLine3D *spoly3[48];
0059 TPolyLine   *npoly2[48];
0060 TPolyLine   *spoly2[48];
0061 TGeoTube    *tubby;
0062 TCanvas     *canny;
0063 TCanvas     *canny2;
0064 
0065 TBox        *boxer1;
0066 TBox        *boxer2;
0067 
0068 void TestFieldMap()
0069 {
0070   recoConsts* rc = recoConsts::instance();
0071 
0072   rc->set_StringFlag("CDB_GLOBALTAG","FieldMapTest");   // Weird offset field map
0073   //rc->set_StringFlag("CDB_GLOBALTAG","newcdbtag");      //sPHENIX default
0074   rc->set_uint64Flag("TIMESTAMP",1);
0075 
0076   auto *cdb = CDBInterface::instance();
0077   std::string url = cdb->getUrl("FIELDMAP_TRACKING");
0078   std::cout << "Field map URL:\n" << url << std::endl;
0079 
0080   Fun4AllServer *se = Fun4AllServer::instance();
0081 
0082   Enable::QA  = false;
0083   Enable::CDB = true;
0084   
0085   // Register a whole slew of input managers...
0086   // NOTE:  This depends upon the requested files being in frog.  Ribbit.
0087 
0088   Fun4AllInputManager* in[Nebdc]; 
0089   for (unsigned int ebdc=0; ebdc<24; ebdc++)
0090     {
0091       for (unsigned int server=0; server<2; server++)
0092     {
0093       auto nextinput = std::format("ebdc{:02d}_{:1d}", ebdc, server);
0094       //sprintf(nextfile,"DST_STREAMING_EVENT_ebdc%02d_%01d_run3line_laser_ana540_nocdbtag_v001-00064890-00000.root",ebdc,server);  // Line Laser
0095       std::string nextfile = std::format(
0096          "DST_STREAMING_EVENT_ebdc{:02}_{:1}_run3auau_ana514_nocdbtag_v001-00075570-00000.root", ebdc, server);
0097       std::cout << nextfile << " " << nextinput << std::endl;
0098       in[ebdc] = new Fun4AllDstInputManager(nextinput);
0099       in[ebdc]->fileopen(nextfile);
0100       se->registerInputManager(in[ebdc]);
0101     }
0102     }
0103 
0104   // Now register a flag handler because MAAABE it will make the CDB work correctly?
0105   //SubsysReco *fh = new FlagHandler();
0106   //se->registerSubsystem(fh);
0107   
0108   // Register my analysis module.
0109   PHGarfield *phg = new PHGarfield();
0110   se->registerSubsystem(phg);
0111 
0112   se->run(4);
0113 
0114   canny  = new TCanvas("canny","canny",3000,2500);
0115   canny2 = new TCanvas("canny2","canny2",3000,2500);
0116   tubby  = new TGeoTube("tubby",20,80,110);
0117 
0118   canny->cd();
0119   tubby->Draw();
0120 
0121   canny2->cd();
0122   //gPad->DrawFrame(-150., -10., 150., 10.);
0123   gPad->DrawFrame(-150., -100., 150., 100.);
0124   boxer1 = new TBox(-102,20,102,78);
0125   boxer1->Draw();
0126   boxer2 = new TBox(-102,-78,102,-20);
0127   boxer2->Draw("same");
0128   
0129   for (int i=0; i<48; i++)
0130     {
0131       canny->cd();
0132       npoly3[i] = phg->ReverseDrift(0,phg->GetRadius(i),102);
0133       npoly3[i]->SetLineColor(kRed);
0134       npoly3[i]->SetLineWidth(3);
0135       npoly3[i]->Draw("same");
0136 
0137       canny2->cd();
0138       int N = npoly3[i]->GetN();
0139       float *p =  npoly3[i]->GetP();
0140       float x[500];
0141       float y[500];
0142       float z[500];
0143       for (int j=0; j<N; j++)
0144       {
0145     x[j] = p[3*j+0];
0146     y[j] = p[3*j+1];
0147     z[j] = p[3*j+2];
0148     /*
0149     std::cout << j
0150             << "  " << x[j]
0151             << "  " << y[j]
0152             << "  " << z[j]
0153             << std::endl;
0154     */
0155       }
0156       npoly2[i] = new TPolyLine(N,z,y);
0157       npoly2[i]->SetLineColor(kRed);
0158       npoly2[i]->SetLineWidth(3);
0159       npoly2[i]->Draw("Lsame");
0160     }
0161 
0162   for (int i=0; i<48; i++)
0163     {
0164       canny->cd();
0165       spoly3[i] = phg->ReverseDrift(0,phg->GetRadius(i),-102);
0166       spoly3[i]->SetLineColor(kCyan);
0167       spoly3[i]->SetLineWidth(3);
0168       spoly3[i]->Draw("same");
0169 
0170       canny2->cd();
0171       int N = spoly3[i]->GetN();
0172       float *p =  spoly3[i]->GetP();
0173       float x[500];
0174       float y[500];
0175       float z[500];
0176       for (int j=0; j<N; j++)
0177       {
0178     x[j] = p[3*j+0];
0179     y[j] = p[3*j+1];
0180     z[j] = p[3*j+2];
0181     /*
0182     std::cout << j
0183             << "  " << x[j]
0184             << "  " << y[j]
0185             << "  " << z[j]
0186             << std::endl;
0187     */
0188       }
0189       spoly2[i] = new TPolyLine(N,z,y);
0190       spoly2[i]->SetLineColor(kCyan);
0191       spoly2[i]->SetLineWidth(3);
0192       spoly2[i]->Draw("Lsame");
0193     }
0194   //se->dumpHistos("Looker.root");
0195 }