Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:20:34

0001 #if !defined (__CINT__) || defined (__CLING__) || defined(__MAKE_CINT__)
0002 #include <fun4all/Fun4AllServer.h>
0003 #include <fun4all/Fun4AllDstOutputManager.h>
0004 #include <fun4all/Fun4AllInputManager.h>
0005 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0006 
0007 #include <phool/recoConsts.h>
0008 
0009 #include <mvtxprototype2/MvtxPrototype2Geom.h>
0010 #include <mvtxprototype2/MvtxPrototype2UnpackPRDF.h>
0011 #include <mvtxprototype2/MvtxPrototype2Clusterizer.h>
0012 #include <mvtxprototype2/MvtxPrototype2Align.h>
0013 #include <anamvtxprototype2/AnaMvtxTestBeam2019.h>
0014 
0015 #include <TSystem.h>
0016 
0017 R__LOAD_LIBRARY(libfun4all.so)
0018 R__LOAD_LIBRARY(libfun4allraw.so)
0019 R__LOAD_LIBRARY(libmvtxprototype2.so)
0020 R__LOAD_LIBRARY(libanamvtxtestbeam2019.so)
0021 #endif
0022 
0023 #include <string>
0024 #include <iostream>
0025 using namespace std;
0026 
0027 void Fun4All_TestBeam(
0028         int nEvents = 10,
0029         const string &input_file = "calib-00000648-0000.prdf")
0030 {
0031   gSystem->Load("libfun4all");
0032   gSystem->Load("libfun4allraw");
0033   gSystem->Load("libmvtxprototype2.so");
0034   gSystem->Load("libanamvtxtestbeam2019.so");
0035 
0036   Fun4AllServer *se = Fun4AllServer::instance();
0037   se->Verbosity(Fun4AllServer::VERBOSITY_SOME);
0038 
0039     char ifile[input_file.length()+1]; // + 1 for the \0 which marks the end of string
0040     strcpy(ifile, input_file.c_str());
0041     strtok(ifile,"-");
0042     int runnumber = atoi(strtok(0,"-"));
0043     int segnumber = atoi(strtok(strtok(0,"-"),"."));
0044     cout << "runnumber: " << runnumber << " segment " << segnumber << endl;
0045 
0046   recoConsts *rc = recoConsts::instance();
0047   rc->set_IntFlag("RUNNUMBER",runnumber);
0048 
0049     /*
0050     MvtxRunInfoUnpackPRDF *unpack_run = new MvtxRunInfoUnpackPRDF();
0051     unpack_run->Verbosity(0);
0052     se->registerSubsystem(unpack_run);
0053     */
0054 
0055     //Unpack
0056     MvtxPrototype2UnpackPRDF *unpack = new MvtxPrototype2UnpackPRDF();
0057     unpack->Verbosity(1);
0058     se->registerSubsystem(unpack);
0059 
0060     /*
0061     MvtxApplyHotDead *hotdead = new MvtxApplyHotDead("MvtxApplyHotDead",Form("hotmap/hotmap_testbeam_%08d.txt",runnumber));
0062     hotdead->Verbosity(0);
0063     hotdead->PrintHotDeadMap();
0064     se->registerSubsystem(hotdead);
0065     */
0066 
0067     MvtxPrototype2Clusterizer *clus = new MvtxPrototype2Clusterizer();
0068     clus->Verbosity(0);
0069     se->registerSubsystem(clus);
0070 
0071   bool do_align = false;
0072   if ( do_align )
0073   {
0074     MvtxPrototype2Align *align = new MvtxPrototype2Align("MvtxAlign");
0075     //align->SetAlignmentParFileDir("beamcenter/");
0076     align->SetAlignmentParFileDir("./");
0077     align->SetAlignmentParFileName("beamcenter_mean_0848_0849_0851.txt");
0078     //align->PrintAlignmentPars();
0079     align->Verbosity(0);
0080     se->registerSubsystem(align);
0081   }
0082 
0083   bool do_eval  = true;
0084   bool do_standalone_tracking = do_eval && false;//true;
0085   bool do_ghost_rej = do_standalone_tracking && true;
0086   if ( do_eval )
0087   {
0088 
0089     AnaMvtxTestBeam2019 *eval = new AnaMvtxTestBeam2019();
0090       eval->set_out_filename(Form("MvtxBT2019Eval-%08d-%04d.root",
0091                            runnumber,segnumber+200));
0092     eval->Verbosity(0);
0093     eval->set_ref_align_stave(0);
0094     eval->set_do_tracking(do_standalone_tracking);
0095     eval->getStandaloneTracking()->SetGhostRejection(do_ghost_rej);
0096     eval->getStandaloneTracking()->SetWindowX(3E-2); //300 um
0097     eval->getStandaloneTracking()->SetWindowZ(3E-2); //300 um
0098     eval->getStandaloneTracking()->Verbosity(0);
0099 
0100       se->registerSubsystem(eval);
0101 
0102   }
0103 
0104 /*
0105   if ( do_tracking )
0106   {
0107     //  // Find all clusters associated with each seed track
0108     TpcPrototypeGenFitTrkFinder *finder = new TpcPrototypeGenFitTrkFinder();
0109     finder->Verbosity(verbosity);
0110     finder->set_do_evt_display(eventDisp);
0111     finder->set_do_eval(false);
0112     finder->set_eval_filename(input_file + "_TpcPrototypeGenFitTrkFinder.root");
0113     se->registerSubsystem(finder);
0114     ////
0115     ////  //
0116     //  //------------------------------------------------
0117     //  // Fitting of tracks using Kalman Filter
0118     //  //------------------------------------------------
0119     //
0120     TpcPrototypeGenFitTrkFitter *kalman = new TpcPrototypeGenFitTrkFitter();
0121     kalman->Verbosity(verbosity);
0122     kalman->set_do_evt_display(eventDisp);
0123     kalman->set_eval_filename(input_file + "_TpcPrototypeGenFitTrkFitter.root");
0124     kalman->set_do_eval(true);
0125     se->registerSubsystem(kalman);
0126   }
0127 */
0128 
0129   bool do_dst = false;
0130   if ( do_dst )
0131   {
0132       Fun4AllDstOutputManager *out_Manager = new Fun4AllDstOutputManager("DSTOUT",  input_file + "_DST.root" );
0133       se->registerOutputManager(out_Manager);
0134   }
0135 
0136   Fun4AllInputManager *in = new Fun4AllPrdfInputManager("PRDFin");
0137   in->fileopen(input_file);
0138   se->registerInputManager(in);
0139 
0140   se->run(nEvents);
0141 
0142   se->End();
0143 }