Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:14

0001 #include "SpinDBContentv1.h"
0002 
0003 #include <phool/PHObject.h>
0004 
0005 #include <format>
0006 #include <iostream>
0007 
0008 //////////////////////////////////////////////////////////
0009 
0010 void SpinDBContentv1::InitializeV1()
0011 {
0012   runnum = GetErrorValue();
0013   qa_level = GetErrorValue();
0014   fillnum = GetErrorValue();
0015   badrun = GetErrorValue();
0016   cross_shift = GetErrorValue();
0017 
0018   for (int icross = 0; icross < GetNCrossing(); icross++)
0019   {
0020     bpol[icross] = (float) GetErrorValue();
0021     bpolerr[icross] = (float) GetErrorValue();
0022     bpolsys[icross] = (float) GetErrorValue();
0023     ypol[icross] = (float) GetErrorValue();
0024     ypolerr[icross] = (float) GetErrorValue();
0025     ypolsys[icross] = (float) GetErrorValue();
0026     bpat[icross] = GetErrorValue();
0027     ypat[icross] = GetErrorValue();
0028     scaler_mbd_vtxcut[icross] = (long long) GetErrorValue();
0029     scaler_mbd_nocut[icross] = (long long) GetErrorValue();
0030     scaler_zdc_nocut[icross] = (long long) GetErrorValue();
0031     bad_bunch[icross] = GetErrorValue();
0032   }
0033 
0034   cross_angle = (float) GetErrorValue();
0035   cross_angle_std = (float) GetErrorValue();
0036   cross_angle_min = (float) GetErrorValue();
0037   cross_angle_max = (float) GetErrorValue();
0038 
0039   asym_bf = (float) GetErrorValue();
0040   asym_bb = (float) GetErrorValue();
0041   asym_yf = (float) GetErrorValue();
0042   asym_yb = (float) GetErrorValue();
0043   asymerr_bf = (float) GetErrorValue();
0044   asymerr_bb = (float) GetErrorValue();
0045   asymerr_yf = (float) GetErrorValue();
0046   asymerr_yb = (float) GetErrorValue();
0047   phase_bf = (float) GetErrorValue();
0048   phase_bb = (float) GetErrorValue();
0049   phase_yf = (float) GetErrorValue();
0050   phase_yb = (float) GetErrorValue();
0051   phaseerr_bf = (float) GetErrorValue();
0052   phaseerr_bb = (float) GetErrorValue();
0053   phaseerr_yf = (float) GetErrorValue();
0054   phaseerr_yb = (float) GetErrorValue();
0055 }
0056 
0057 /////////////////////////////////////////////////////////////////
0058 
0059 int SpinDBContentv1::CheckBunchNumber(int bunch) const
0060 {
0061   if (bunch < 0 || bunch >= GetNCrossing())
0062   {
0063     std::cout << std::format("Error : bunch number ({}) is out of range (0-119).", bunch) << std::endl;
0064     return (GetErrorValue());
0065   }
0066 
0067   return (1);
0068 }
0069 
0070 ///////////////////////////////////////////////////////////////
0071 
0072 void SpinDBContentv1::identify(std::ostream &os) const
0073 {
0074   os << std::format("Run number = {}", runnum) << std::endl;
0075   os << std::format("QA Level = {}", qa_level) << std::endl;
0076   os << std::format("Fill number = {}", fillnum) << std::endl;
0077   os << std::format("Bad run QA = {}", badrun) << std::endl;
0078   os << std::format("Crossing shift = {}", cross_shift) << std::endl;
0079 
0080   for (int i = 0; i < GetNCrossing(); i++)
0081   {
0082     os << std::format("{:3} : {:12} {:12} {:12} : {:3} {:3} : {}", i, scaler_mbd_vtxcut[i], scaler_mbd_nocut[i], scaler_zdc_nocut[i], bpat[i], ypat[i], bad_bunch[i]) << std::endl;
0083 
0084     os << std::format(" : {:6.3f} +- {:6.3f} +- {:6.3f} {:6.3f} +- {:6.3} +- {:6.3f}", bpol[i], bpolerr[i], bpolsys[i], ypol[i], ypolerr[i], ypolsys[i]) << std::endl;
0085   }
0086 
0087   return;
0088 }
0089 
0090 ///////////////////////////////////////////////////////////
0091 
0092 int SpinDBContentv1::SetPolarizationBlue(int bunch, float value, float error)
0093 {
0094   if (CheckBunchNumber(bunch) == GetErrorValue())
0095   {
0096     return (GetErrorValue());
0097   }
0098   bpol[bunch] = value;
0099   bpolerr[bunch] = error;
0100   return (1);
0101 }
0102 
0103 ///////////////////////////////////////////////////////////
0104 
0105 int SpinDBContentv1::SetPolarizationBlue(int bunch, float value, float error, float syserr)
0106 {
0107   if (CheckBunchNumber(bunch) == GetErrorValue())
0108   {
0109     return (GetErrorValue());
0110   }
0111   bpol[bunch] = value;
0112   bpolerr[bunch] = error;
0113   bpolsys[bunch] = syserr;
0114   return (1);
0115 }
0116 
0117 /////////////////////////////////////////////////////
0118 
0119 int SpinDBContentv1::SetPolarizationYellow(int bunch, float value, float error)
0120 {
0121   if (CheckBunchNumber(bunch) == GetErrorValue())
0122   {
0123     return (GetErrorValue());
0124   }
0125   ypol[bunch] = value;
0126   ypolerr[bunch] = error;
0127   return (1);
0128 }
0129 /////////////////////////////////////////////////////
0130 
0131 int SpinDBContentv1::SetPolarizationYellow(int bunch, float value, float error, float syserr)
0132 {
0133   if (CheckBunchNumber(bunch) == GetErrorValue())
0134   {
0135     return (GetErrorValue());
0136   }
0137   ypol[bunch] = value;
0138   ypolerr[bunch] = error;
0139   ypolsys[bunch] = syserr;
0140   return (1);
0141 }
0142 /////////////////////////////////////////////////////
0143 
0144 int SpinDBContentv1::SetSpinPatternBlue(int bunch, int value)
0145 {
0146   if (CheckBunchNumber(bunch) == GetErrorValue())
0147   {
0148     return (GetErrorValue());
0149   }
0150   bpat[bunch] = value;
0151   return (1);
0152 }
0153 
0154 /////////////////////////////////////////////////////
0155 
0156 int SpinDBContentv1::SetSpinPatternYellow(int bunch, int value)
0157 {
0158   if (CheckBunchNumber(bunch) == GetErrorValue())
0159   {
0160     return (GetErrorValue());
0161   }
0162   ypat[bunch] = value;
0163   return (1);
0164 }
0165 
0166 /////////////////////////////////////////////////////
0167 
0168 int SpinDBContentv1::SetScalerMbdVertexCut(int bunch, long long value)
0169 {
0170   if (CheckBunchNumber(bunch) == GetErrorValue())
0171   {
0172     return (GetErrorValue());
0173   }
0174   scaler_mbd_vtxcut[bunch] = value;
0175   return (1);
0176 }
0177 
0178 //////////////////////////////////////////////////////
0179 
0180 int SpinDBContentv1::SetScalerMbdNoCut(int bunch, long long value)
0181 {
0182   if (CheckBunchNumber(bunch) == GetErrorValue())
0183   {
0184     return (GetErrorValue());
0185   }
0186   scaler_mbd_nocut[bunch] = value;
0187   return (1);
0188 }
0189 
0190 //////////////////////////////////////////////////////
0191 
0192 int SpinDBContentv1::SetScalerZdcNoCut(int bunch, long long value)
0193 {
0194   if (CheckBunchNumber(bunch) == GetErrorValue())
0195   {
0196     return (GetErrorValue());
0197   }
0198   scaler_zdc_nocut[bunch] = value;
0199   return (1);
0200 }
0201 
0202 ////////////////////////////////////////////////////////
0203 
0204 int SpinDBContentv1::SetScaler(int channel, int bunch, long long value)
0205 {
0206   switch (channel)
0207   {
0208   case 0:
0209     return SetScalerMbdVertexCut(bunch, value);
0210   case 1:
0211     return SetScalerMbdNoCut(bunch, value);
0212   case 2:
0213     return SetScalerZdcNoCut(bunch, value);
0214   default:
0215     break;
0216   }
0217   return GetErrorValue();
0218 }
0219 
0220 ////////////////////////////////////////////////////////////////
0221 
0222 int SpinDBContentv1::SetBadBunchFlag(int bunch, int value)
0223 {
0224   if (CheckBunchNumber(bunch) == GetErrorValue())
0225   {
0226     return (GetErrorValue());
0227   }
0228   bad_bunch[bunch] = value;
0229   return (1);
0230 }
0231 
0232 //////////////////////////////////////////////////////
0233 
0234 void SpinDBContentv1::SetAsymBlueForward(float value, float error)
0235 {
0236   asym_bf = value;
0237   asymerr_bf = error;
0238   return;
0239 }
0240 
0241 //////////////////////////////////////////////////////
0242 
0243 void SpinDBContentv1::SetAsymBlueBackward(float value, float error)
0244 {
0245   asym_bb = value;
0246   asymerr_bb = error;
0247   return;
0248 }
0249 
0250 ////////////////////////////////////////////////////////////////
0251 
0252 void SpinDBContentv1::SetAsymYellowForward(float value, float error)
0253 {
0254   asym_yf = value;
0255   asymerr_yf = error;
0256   return;
0257 }
0258 
0259 /////////////////////////////////////////////////////////////////
0260 
0261 void SpinDBContentv1::SetAsymYellowBackward(float value, float error)
0262 {
0263   asym_yb = value;
0264   asymerr_yb = error;
0265   return;
0266 }
0267 
0268 //////////////////////////////////////////////////////
0269 
0270 void SpinDBContentv1::SetPhaseBlueForward(float value, float error)
0271 {
0272   phase_bf = value;
0273   phaseerr_bf = error;
0274   return;
0275 }
0276 
0277 //////////////////////////////////////////////////////
0278 
0279 void SpinDBContentv1::SetPhaseBlueBackward(float value, float error)
0280 {
0281   phase_bb = value;
0282   phaseerr_bb = error;
0283   return;
0284 }
0285 
0286 ////////////////////////////////////////////////////////////////
0287 
0288 void SpinDBContentv1::SetPhaseYellowForward(float value, float error)
0289 {
0290   phase_yf = value;
0291   phaseerr_yf = error;
0292   return;
0293 }
0294 
0295 /////////////////////////////////////////////////////////////////
0296 
0297 void SpinDBContentv1::SetPhaseYellowBackward(float value, float error)
0298 {
0299   phase_yb = value;
0300   phaseerr_yb = error;
0301   return;
0302 }
0303 
0304 ////////////////////////////////////////////////////////////////
0305 
0306 int SpinDBContentv1::GetPolarizationBlue(int bunch, float &value, float &error) const
0307 {
0308   if (CheckBunchNumber(bunch) == GetErrorValue())
0309   {
0310     return (GetErrorValue());
0311   }
0312   value = bpol[bunch];
0313   error = bpolerr[bunch];
0314   return (1);
0315 }
0316 
0317 ////////////////////////////////////////////////////////////////
0318 
0319 int SpinDBContentv1::GetPolarizationBlue(int bunch, float &value, float &error, float &syserr) const
0320 {
0321   if (CheckBunchNumber(bunch) == GetErrorValue())
0322   {
0323     return (GetErrorValue());
0324   }
0325   value = bpol[bunch];
0326   error = bpolerr[bunch];
0327   syserr = bpolsys[bunch];
0328   return (1);
0329 }
0330 
0331 /////////////////////////////////////////////////////////////////
0332 
0333 int SpinDBContentv1::GetPolarizationBlue(int bunch, double &value, double &error) const
0334 {
0335   if (CheckBunchNumber(bunch) == GetErrorValue())
0336   {
0337     return (GetErrorValue());
0338   }
0339   value = (double) bpol[bunch];
0340   error = (double) bpolerr[bunch];
0341   return (1);
0342 }
0343 
0344 /////////////////////////////////////////////////////////////////
0345 
0346 int SpinDBContentv1::GetPolarizationBlue(int bunch, double &value, double &error, double &syserr) const
0347 {
0348   if (CheckBunchNumber(bunch) == GetErrorValue())
0349   {
0350     return (GetErrorValue());
0351   }
0352   value = (double) bpol[bunch];
0353   error = (double) bpolerr[bunch];
0354   syserr = (double) bpolsys[bunch];
0355   return (1);
0356 }
0357 
0358 /////////////////////////////////////////////////////////////////
0359 
0360 int SpinDBContentv1::GetPolarizationYellow(int bunch, float &value, float &error) const
0361 {
0362   if (CheckBunchNumber(bunch) == GetErrorValue())
0363   {
0364     return (GetErrorValue());
0365   }
0366   value = ypol[bunch];
0367   error = ypolerr[bunch];
0368   return (1);
0369 }
0370 
0371 /////////////////////////////////////////////////////////////////
0372 
0373 int SpinDBContentv1::GetPolarizationYellow(int bunch, float &value, float &error, float &syserr) const
0374 {
0375   if (CheckBunchNumber(bunch) == GetErrorValue())
0376   {
0377     return (GetErrorValue());
0378   }
0379   value = ypol[bunch];
0380   error = ypolerr[bunch];
0381   syserr = ypolsys[bunch];
0382   return (1);
0383 }
0384 
0385 /////////////////////////////////////////////////////////////////
0386 
0387 int SpinDBContentv1::GetPolarizationYellow(int bunch, double &value, double &error) const
0388 {
0389   if (CheckBunchNumber(bunch) == GetErrorValue())
0390   {
0391     return (GetErrorValue());
0392   }
0393   value = (double) ypol[bunch];
0394   error = (double) ypolerr[bunch];
0395   return (1);
0396 }
0397 
0398 /////////////////////////////////////////////////////////////////
0399 
0400 int SpinDBContentv1::GetPolarizationYellow(int bunch, double &value, double &error, double &syserr) const
0401 {
0402   if (CheckBunchNumber(bunch) == GetErrorValue())
0403   {
0404     return (GetErrorValue());
0405   }
0406   value = (double) ypol[bunch];
0407   error = (double) ypolerr[bunch];
0408   syserr = (double) ypolsys[bunch];
0409   return (1);
0410 }
0411 
0412 /////////////////////////////////////////////////////////////////
0413 
0414 int SpinDBContentv1::GetSpinPatternBlue(int bunch) const
0415 {
0416   if (CheckBunchNumber(bunch) == GetErrorValue())
0417   {
0418     return (GetErrorValue());
0419   }
0420   return (bpat[bunch]);
0421 }
0422 
0423 ////////////////////////////////////////////////////////////////
0424 
0425 int SpinDBContentv1::GetSpinPatternYellow(int bunch) const
0426 {
0427   if (CheckBunchNumber(bunch) == GetErrorValue())
0428   {
0429     return (GetErrorValue());
0430   }
0431   return (ypat[bunch]);
0432 }
0433 
0434 ////////////////////////////////////////////////////////////////
0435 
0436 long long SpinDBContentv1::GetScalerMbdVertexCut(int bunch) const
0437 {
0438   if (CheckBunchNumber(bunch) == GetErrorValue())
0439   {
0440     return (GetErrorValue());
0441   }
0442   return (scaler_mbd_vtxcut[bunch]);
0443 }
0444 
0445 ////////////////////////////////////////////////////////////////
0446 
0447 long long SpinDBContentv1::GetScalerMbdNoCut(int bunch) const
0448 {
0449   if (CheckBunchNumber(bunch) == GetErrorValue())
0450   {
0451     return (GetErrorValue());
0452   }
0453   return (scaler_mbd_nocut[bunch]);
0454 }
0455 
0456 ////////////////////////////////////////////////////////////////
0457 
0458 long long SpinDBContentv1::GetScalerZdcNoCut(int bunch) const
0459 {
0460   if (CheckBunchNumber(bunch) == GetErrorValue())
0461   {
0462     return (GetErrorValue());
0463   }
0464   return (scaler_zdc_nocut[bunch]);
0465 }
0466 
0467 ////////////////////////////////////////////////////////////////
0468 
0469 long long SpinDBContentv1::GetScaler(int channel, int bunch) const
0470 {
0471   switch (channel)
0472   {
0473   case 0:
0474     return GetScalerMbdVertexCut(bunch);
0475   case 1:
0476     return GetScalerMbdNoCut(bunch);
0477   case 2:
0478     return GetScalerZdcNoCut(bunch);
0479   default:
0480     break;
0481   }
0482   return GetErrorValue();
0483 }
0484 
0485 ////////////////////////////////////////////////////////////////
0486 
0487 int SpinDBContentv1::GetBadBunchFlag(int bunch) const
0488 {
0489   if (CheckBunchNumber(bunch) == GetErrorValue())
0490   {
0491     return (GetErrorValue());
0492   }
0493   return (bad_bunch[bunch]);
0494 }
0495 
0496 ///////////////////////////////////////////////////////////////
0497 
0498 void SpinDBContentv1::GetAsymBlueForward(float &value, float &error) const
0499 {
0500   value = asym_bf;
0501   error = asymerr_bf;
0502   return;
0503 }
0504 
0505 ///////////////////////////////////////////////////////////////
0506 
0507 void SpinDBContentv1::GetAsymBlueBackward(float &value, float &error) const
0508 {
0509   value = asym_bb;
0510   error = asymerr_bb;
0511   return;
0512 }
0513 
0514 ///////////////////////////////////////////////////////////////
0515 
0516 void SpinDBContentv1::GetAsymYellowForward(float &value, float &error) const
0517 {
0518   value = asym_yf;
0519   error = asymerr_yf;
0520   return;
0521 }
0522 
0523 //////////////////////////////////////////////////////////////
0524 
0525 void SpinDBContentv1::GetAsymYellowBackward(float &value, float &error) const
0526 {
0527   value = asym_yb;
0528   error = asymerr_yb;
0529   return;
0530 }
0531 
0532 //////////////////////////////////////////////////////////////
0533 
0534 void SpinDBContentv1::GetPhaseBlueForward(float &value, float &error) const
0535 {
0536   value = phase_bf;
0537   error = phaseerr_bf;
0538   return;
0539 }
0540 
0541 ///////////////////////////////////////////////////////////////
0542 
0543 void SpinDBContentv1::GetPhaseBlueBackward(float &value, float &error) const
0544 {
0545   value = phase_bb;
0546   error = phaseerr_bb;
0547   return;
0548 }
0549 
0550 ///////////////////////////////////////////////////////////////
0551 
0552 void SpinDBContentv1::GetPhaseYellowForward(float &value, float &error) const
0553 {
0554   value = phase_yf;
0555   error = phaseerr_yf;
0556   return;
0557 }
0558 
0559 //////////////////////////////////////////////////////////////
0560 
0561 void SpinDBContentv1::GetPhaseYellowBackward(float &value, float &error) const
0562 {
0563   value = phase_yb;
0564   error = phaseerr_yb;
0565   return;
0566 }
0567 
0568 //////////////////////////////////////////////////////////////