-
Notifications
You must be signed in to change notification settings - Fork 510
Expand file tree
/
Copy pathGRPObject.cxx
More file actions
127 lines (119 loc) · 4.34 KB
/
Copy pathGRPObject.cxx
File metadata and controls
127 lines (119 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file GRPObject.cxx
/// \brief Implementation of General Run Parameters object
/// \author ruben.shahoyan@cern.ch
#include <FairLogger.h>
#include <TFile.h>
#include "DataFormatsParameters/GRPObject.h"
#include <cmath>
#include "CommonConstants/PhysicsConstants.h"
using namespace o2::parameters;
using namespace o2::constants::physics;
using namespace o2::constants::lhc;
using o2::detectors::DetID;
//_______________________________________________
float GRPObject::getSqrtS() const
{
// get center of mass energy
double e0 = getBeamEnergyPerNucleon(BeamClockWise);
double e1 = getBeamEnergyPerNucleon(BeamAntiClockWise);
if (e0 <= MassProton || e1 <= MassProton) {
return 0.f;
}
double beta0 = 1. - MassProton * MassProton / (e0 * e0);
double beta1 = 1. - MassProton * MassProton / (e1 * e1);
beta0 = beta0 > 0 ? sqrt(beta0) : 0.;
beta1 = beta1 > 0 ? sqrt(beta1) : 0.;
double ss = 2. * (MassProton * MassProton + e0 * e1 * (1. + beta0 * beta1 * cos(mCrossingAngle)));
return ss > 0. ? sqrt(ss) : 0.;
}
//_______________________________________________
void GRPObject::print() const
{
// print itself
printf("Run: %8d\nFill: %6d\nPeriod: %s\n", getRun(), getFill(), getDataPeriod().data());
printf("LHC State: %s\n", getLHCState().data());
std::time_t t = mTimeStart; // system_clock::to_time_t(mTimeStart);
printf("Start: %s", std::ctime(&t));
t = mTimeEnd; // system_clock::to_time_t(mTimeEnd);
printf("End : %s", std::ctime(&t));
printf("1st orbit: %u\n", mFirstOrbit);
printf("Beam0: Z:A = %3d:%3d, Energy = %.3f\n", getBeamZ(BeamClockWise), getBeamA(BeamClockWise),
getBeamEnergyPerNucleon(BeamClockWise));
printf("Beam1: Z:A = %3d:%3d, Energy = %.3f\n", getBeamZ(BeamAntiClockWise), getBeamA(BeamAntiClockWise),
getBeamEnergyPerNucleon(BeamAntiClockWise));
printf("sqrt[s] = %.3f\n", getSqrtS());
printf("crossing angle (radian) = %e\n", getCrossingAngle());
printf("magnet currents (A) L3 = %.3f, Dipole = %.f\n", getL3Current(), getDipoleCurrent());
printf("Detectors: Cont.RO Triggers\n");
for (auto i = DetID::First; i <= DetID::Last; i++) {
if (!isDetReadOut(DetID(i))) {
continue;
}
printf("%9s: ", DetID(i).getName());
printf("%7s ", isDetContinuousReadOut(DetID(i)) ? " + " : " - ");
printf("%7s ", isDetTriggers(DetID(i)) ? " + " : " - ");
printf("\n");
}
}
//_______________________________________________
void GRPObject::setDetROMode(o2::detectors::DetID id, ROMode status)
{
/// set detector readout mode status
if (!(status & PRESENT)) {
remDetReadOut(id);
return;
}
addDetReadOut(id);
if ((status & CONTINUOUS) == CONTINUOUS) {
addDetContinuousReadOut(id);
} else {
remDetContinuousReadOut(id);
}
if ((status & TRIGGERING) == TRIGGERING) {
addDetTrigger(id);
} else {
remDetTrigger(id);
}
}
//_______________________________________________
GRPObject::ROMode GRPObject::getDetROMode(o2::detectors::DetID id) const
{
GRPObject::ROMode status = ABSENT;
if (isDetReadOut(id)) {
status = PRESENT;
} else {
if (isDetContinuousReadOut(id)) {
status = GRPObject::ROMode(status | CONTINUOUS);
}
if (isDetTriggers(id)) {
status = GRPObject::ROMode(status | TRIGGERING);
}
}
return status;
}
//_______________________________________________
GRPObject* GRPObject::loadFrom(const std::string& grpFileName, const std::string& grpName)
{
// load object from file
TFile flGRP(grpFileName.data());
if (flGRP.IsZombie()) {
LOG(ERROR) << "Failed to open " << grpFileName;
throw std::runtime_error("Failed to open GRP file");
}
auto grp = reinterpret_cast<o2::parameters::GRPObject*>(
flGRP.GetObjectChecked(grpName.data(), o2::parameters::GRPObject::Class()));
if (!grp) {
LOG(ERROR) << "Did not find GRP object named " << grpName;
throw std::runtime_error("Failed to load GRP object");
}
return grp;
}