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 {82, 208}};
32
33//_______________________________________________
35{
36 // set both A and Z of the beam in direction 'beam'
37 if (beam == beamDirection::BeamC) {
38 auto atomicNum = mZtoA.find(getAtomicNumberB1());
39 if (atomicNum != mZtoA.end()) {
40 mBeamAZ[static_cast<int>(beam)] = (atomicNum->second << 16) + getAtomicNumberB1();
41 }
42 } else {
43 auto atomicNum = mZtoA.find(getAtomicNumberB2());
44 if (atomicNum != mZtoA.end()) {
45 mBeamAZ[static_cast<int>(beam)] = (atomicNum->second << 16) + getAtomicNumberB2();
46 }
47 }
48}
49
50//_______________________________________________
52{
53
54 // setting A and Z for both beams
57}
58
59//_______________________________________________
61{
62 // get center of mass energy
65 if (e0 <= MassProton || e1 <= MassProton) {
66 return 0.f;
67 }
68 double beta0 = 1. - MassProton * MassProton / (e0 * e0);
69 double beta1 = 1. - MassProton * MassProton / (e1 * e1);
70 beta0 = beta0 > 0 ? sqrt(beta0) : 0.;
71 beta1 = beta1 > 0 ? sqrt(beta1) : 0.;
72 double ss = 2. * (MassProton * MassProton + e0 * e1 * (1. + beta0 * beta1 * cos(getCrossingAngle())));
73 return ss > 0. ? sqrt(ss) : 0.;
74}
75
76//_________________________________________________________________
77
78void GRPLHCIFData::translateBucketsToBCNumbers(std::vector<int32_t>& bcNb, std::vector<int32_t>& buckets, int beam)
79{
80 // to translate the vector of bucket numbers to BC numbers
81 for (auto i : buckets) {
82 if (i) {
84 }
85 }
86}
87
88//_______________________________________________
89GRPLHCIFData* GRPLHCIFData::loadFrom(const std::string& grpFileName)
90{
91 // load object from file
92 auto fname = o2::base::NameConf::getGRPLHCIFFileName(grpFileName);
93 TFile flGRP(fname.c_str());
94 if (flGRP.IsZombie()) {
95 LOG(error) << "Failed to open " << fname;
96 throw std::runtime_error("Failed to open GRPLHCIF file");
97 }
98 auto grp = reinterpret_cast<o2::parameters::GRPLHCIFData*>(flGRP.GetObjectChecked(o2::base::NameConf::CCDBOBJECT.data(), Class()));
99 if (!grp) {
100 throw std::runtime_error(fmt::format("Failed to load GRPLHCIF object from {}", fname));
101 }
102 return grp;
103}
104
105//_______________________________________________
107{
108 // print itself
109 auto timeStr = [](long t) -> std::string {
110 if (t) {
111 std::time_t temp = t / 1000;
112 std::tm* tt = std::gmtime(&temp);
113 std::stringstream ss;
114 ss << std::put_time(tt, "%d/%m/%y %H:%M:%S") << " UTC";
115 return ss.str();
116 }
117 return {" N / A "};
118 };
119
120 printf("%s: Fill : %d\n", timeStr(mFillNumber.first).c_str(), mFillNumber.second);
121 printf("%s: Injection scheme : %s\n", timeStr(mInjectionScheme.first).c_str(), mInjectionScheme.second.c_str());
122 printf("%s: Beam energy per Z : %d\n", timeStr(mBeamEnergyPerZ.first).c_str(), mBeamEnergyPerZ.second);
123 printf("%s: A beam1 (clock) : %d\n", timeStr(mAtomicNumberB1.first).c_str(), mAtomicNumberB1.second);
124 printf("%s: A beam2 (a-clock) : %d\n", timeStr(mAtomicNumberB2.first).c_str(), mAtomicNumberB2.second);
125 printf("%s: Bunch filling\n", timeStr(mBunchFilling.first).c_str());
126 if (mBunchFilling.first > 0) {
127 mBunchFilling.second.print();
128 }
129}
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"