Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-04-05 08:08:19

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_hotmap.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   // qa_level = 0xffff corresponds to the very first spin QA selection
0036   unsigned int qa_level = 0xffff; // or equivalently 65535 in decimal notation
0037   SpinDBOutput spin_out("phnxrc");
0038   SpinDBContent spin_cont;
0039   spin_out.StoreDBContent(runnumber, runnumber, qa_level);
0040   if (!spin_out.GetDBContentStore(spin_cont, runnumber))
0041   {
0042     // spin QA row is not available
0043     return false;
0044   }
0045   
0046   // If badrunqa = 1, the run is discarded
0047   // It corresponds to either of these conditions:
0048   // spin pattern must match one of the known patterns given by Main Control Room
0049   // polarization values for either beam must be between 0 and 1
0050   // < 10 bunches exhibit a mismatch between intended and measured beam spin pattern
0051   int badrunqa = spin_cont.GetBadRunFlag();
0052 
0053   if (badrunqa == 1)
0054   {
0055     return false;
0056   }
0057 
0058   // In addition, the GL1P scalers must not be uniformly equal to 0
0059   const int nbunches = 120;
0060   for (int i = 0; i < nbunches; i++)
0061   {
0062     if (spin_cont.GetScalerMbdVertexCut(i) > 0)
0063     {
0064       return true;
0065     }
0066   }
0067   return false;
0068 }