Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-04 08:08:21

0001 #include <uspin/SpinDBInput.h>
0002 #include <uspin/SpinDBOutput.h>
0003 #include <uspin/SpinDBContent.h>
0004 
0005 R__LOAD_LIBRARY(libuspin.so)
0006 
0007 bool hasGoodSpinQA(int runnumber);
0008 
0009 void macro_select_run_spinqa(const std::string& runListName = "RunList_golden.txt")
0010 {
0011   std::ifstream runListFile;
0012   runListFile.open(runListName);
0013 
0014   std::ofstream runListFileOutput;
0015   runListFileOutput.open("RunList_spinqa.txt");
0016 
0017   std::string line;
0018   int runnumber;
0019   while (std::getline(runListFile, line))
0020   {
0021     runnumber = std::stoi(line);
0022     if (hasGoodSpinQA(runnumber))
0023     {
0024      runListFileOutput << runnumber << std::endl;
0025     }
0026   }
0027   runListFileOutput.close();
0028   runListFile.close();
0029 
0030   gSystem->Exit(0);
0031 }
0032 
0033 bool hasGoodSpinQA(int runnumber)
0034 {
0035   SpinDBOutput spin_out("phnxrc");
0036   SpinDBContent *spin_cont = new SpinDBContentv1();
0037   spin_out.StoreDBContent(runnumber, runnumber);
0038   if (!spin_out.GetDBContentStore(spin_cont, runnumber))
0039   {
0040     // spin QA row is not available
0041     return false;
0042   }
0043   
0044   // If badrunqa = 1, the run is discarded
0045   // It corresponds to either of these conditions:
0046   // spin pattern must match one of the known patterns given by Main Control Room
0047   // polarization values for either beam must be between 0 and 1
0048   // < 10 bunches exhibit a mismatch between intended and measured beam spin pattern
0049   int badrunqa = spin_cont->GetBadRunFlag();
0050 
0051   if (badrunqa == 1)
0052   {
0053     return false;
0054   }
0055 
0056   // In addition, the GL1P scalers must not be uniformly equal to 0
0057   const int nbunches = 120;
0058   for (int i = 0; i < nbunches; i++)
0059   {
0060     if (spin_cont->GetScalerMbdVertexCut(i) > 0)
0061     {
0062       return true;
0063     }
0064   }
0065   return false;
0066 }