Project
Loading...
Searching...
No Matches
GRPLHCIFData.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
18#include <ctime>
19#include <sstream>
20#include <cmath>
21#include <iomanip>
22#include <Framework/Logger.h>
23
24using namespace o2::parameters;
25using namespace o2::constants::physics;
26using namespace o2::constants::lhc;
27
28const std::unordered_map<unsigned int, unsigned int> GRPLHCIFData::mZtoA =
29 {
30 {1, 1},
31 {8, 16},
32 {10, 20},
33 {82, 208}};
34
35//_______________________________________________
37{
38 // set both A and Z of the beam in direction 'beam'
39 if (beam == beamDirection::BeamC) {
40 auto atomicNum = mZtoA.find(getAtomicNumberB1());
41 if (atomicNum != mZtoA.end()) {
42 mBeamAZ[static_cast<int>(beam)] = (atomicNum->second << 16) + getAtomicNumberB1();
43 }
44 } else {
45 auto atomicNum = mZtoA.find(getAtomicNumberB2());
46 if (atomicNum != mZtoA.end()) {
47 mBeamAZ[static_cast<int>(beam)] = (atomicNum->second << 16) + getAtomicNumberB2();
48 }
49 }
50}
51
52//_______________________________________________
54{
55
56 // setting A and Z for both beams
59}
60
61//_______________________________________________
63{
64 // get center of mass energy
67 if (e0 <= MassProton || e1 <= MassProton) {
68 return 0.f;
69 }
70 double beta0 = 1. - MassProton * MassProton / (e0 * e0);
71 double beta1 = 1. - MassProton * MassProton / (e1 * e1);
72 beta0 = beta0 > 0 ? sqrt(beta0) : 0.;
73 beta1 = beta1 > 0 ? sqrt(beta1) : 0.;
74 double ss = 2. * (MassProton * MassProton + e0 * e1 * (1. + beta0 * beta1 * cos(getCrossingAngle())));
75 return ss > 0. ? sqrt(ss) : 0.;
76}
77
78//_________________________________________________________________
79
80void GRPLHCIFData::translateBucketsToBCNumbers(std::vector<int32_t>& bcNb, std::vector<int32_t>& buckets, int beam)
81{
82 // to translate the vector of bucket numbers to BC numbers
83 for (auto i : buckets) {
84 if (i) {
86 }
87 }
88}
89
90//_______________________________________________
91GRPLHCIFData* GRPLHCIFData::loadFrom(const std::string& grpFileName)
92{
93 // load object from file
94 auto fname = o2::base::NameConf::getGRPLHCIFFileName(grpFileName);
95 TFile flGRP(fname.c_str());
96 if (flGRP.IsZombie()) {
97 LOG(error) << "Failed to open " << fname;
98 throw std::runtime_error("Failed to open GRPLHCIF file");
99 }
100 auto grp = reinterpret_cast<o2::parameters::GRPLHCIFData*>(flGRP.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
101 if (!grp) {
102 throw std::runtime_error(fmt::format("Failed to load GRPLHCIF object from {}", fname));
103 }
104 return grp;
105}
106
107//_______________________________________________
109{
110 // print itself
111 auto timeStr = [](long t) -> std::string {
112 if (t) {
113 std::time_t temp = t / 1000;
114 std::tm* tt = std::gmtime(&temp);
115 std::stringstream ss;
116 ss << std::put_time(tt, "%d/%m/%y %H:%M:%S") << " UTC";
117 return ss.str();
118 }
119 return {" N / A "};
120 };
121
122 printf("%s: Fill : %d\n", timeStr(mFillNumber.first).c_str(), mFillNumber.second);
123 printf("%s: Injection scheme : %s\n", timeStr(mInjectionScheme.first).c_str(), mInjectionScheme.second.c_str());
124 printf("%s: Beam energy per Z : %d\n", timeStr(mBeamEnergyPerZ.first).c_str(), mBeamEnergyPerZ.second);
125 printf("%s: A beam1 (clock) : %d\n", timeStr(mAtomicNumberB1.first).c_str(), mAtomicNumberB1.second);
126 printf("%s: A beam2 (a-clock) : %d\n", timeStr(mAtomicNumberB2.first).c_str(), mAtomicNumberB2.second);
127 printf("%s: Bunch filling\n", timeStr(mBunchFilling.first).c_str());
128 if (mBunchFilling.first > 0) {
129 mBunchFilling.second.print();
130 }
131}
int32_t i
container for the LHC InterFace data
Definition of the Names Generator class.
Header to collect physics constants.
static std::string getGRPLHCIFFileName(const std::string_view prefix=STANDARDSIMPREFIX)
Definition NameConf.cxx:70
static constexpr std::string_view CCDBOBJECT
Definition NameConf.h:66
float getBeamEnergyPerNucleonInGeV(beamDirection beam) const
void translateBucketsToBCNumbers(std::vector< int32_t > &bcNb, std::vector< int32_t > &buckets, int beam)
helper function for BunchFilling
o2::units::AngleRad_t getCrossingAngle() const
int32_t getAtomicNumberB2() const
static GRPLHCIFData * loadFrom(const std::string &grpLHCIFFileName="")
static const std::unordered_map< unsigned int, unsigned int > mZtoA
int32_t getAtomicNumberB1() const
float getSqrtS() const
calculate center of mass energy per nucleon collision
GLboolean * data
Definition glcorearb.h:298
constexpr int LHCMaxBunches
constexpr int BunchOffsetsP2[2]
constexpr double MassProton
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"