-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'AliceO2Group:dev' into new-detector4
- Loading branch information
Showing
412 changed files
with
9,260 additions
and
8,864 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
DataFormats/Parameters/include/DataFormatsParameters/AggregatedRunInfo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// 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 GRPECSObject.h | ||
/// \brief Header of the AggregatedRunInfo struct | ||
/// \author [email protected] [email protected] | ||
|
||
#ifndef ALICEO2_DATA_AGGREGATEDRUNINFO_H_ | ||
#define ALICEO2_DATA_AGGREGATEDRUNINFO_H_ | ||
|
||
#include <cstdint> | ||
#include "CCDB/BasicCCDBManager.h" | ||
|
||
namespace o2::parameters | ||
{ | ||
|
||
/// Composite struct where one may collect important global properties of data "runs" | ||
/// aggregated from various sources (GRPECS, RunInformation CCDB entries, etc.). | ||
/// Also offers the authoritative algorithms to collect these information for easy reuse | ||
/// across various algorithms (anchoredMC, analysis, ...) | ||
struct AggregatedRunInfo { | ||
int runNumber; // run number | ||
int64_t sor; // best known timestamp for the start of run | ||
int64_t eor; // best known timestamp for end of run | ||
int64_t orbitsPerTF; // number of orbits per TF | ||
int64_t orbitReset; // timestamp of orbit reset before run | ||
int64_t orbitSOR; // orbit when run starts after orbit reset | ||
int64_t orbitEOR; // orbit when run ends after orbit reset | ||
|
||
// we may have pointers to actual data source objects GRPECS, ... | ||
|
||
// fills and returns AggregatedRunInfo for a given run number. | ||
static AggregatedRunInfo buildAggregatedRunInfo(o2::ccdb::CCDBManagerInstance& ccdb, int runnumber); | ||
}; | ||
|
||
} // namespace o2::parameters | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// 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 AggregatedRunInfo.cxx | ||
/// \author [email protected] | ||
|
||
#include "DataFormatsParameters/AggregatedRunInfo.h" | ||
#include "CCDB/BasicCCDBManager.h" | ||
#include "DataFormatsParameters/GRPECSObject.h" | ||
#include "CommonConstants/LHCConstants.h" | ||
#include "Framework/Logger.h" | ||
|
||
using namespace o2::parameters; | ||
|
||
o2::parameters::AggregatedRunInfo AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::CCDBManagerInstance& ccdb, int runnumber) | ||
{ | ||
// TODO: could think about caching results per runnumber to | ||
// avoid going to CCDB multiple times ---> but should be done inside the CCDBManagerInstance | ||
|
||
// we calculate the first orbit of a run based on sor (start-of-run) and eor | ||
// we obtain these by calling getRunDuration | ||
auto [sor, eor] = ccdb.getRunDuration(runnumber); | ||
|
||
// determine a good timestamp to query OrbitReset for this run | ||
// --> the middle of the run is very appropriate and safer than just sor | ||
auto run_mid_timestamp = sor + (eor - sor) / 2; | ||
|
||
// query the time of the orbit reset (when orbit is defined to be 0) | ||
auto ctpx = ccdb.getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", run_mid_timestamp); | ||
int64_t tsOrbitReset = (*ctpx)[0]; // us | ||
|
||
// get timeframe length from GRPECS | ||
std::map<std::string, std::string> metadata; | ||
metadata["runNumber"] = Form("%d", runnumber); | ||
auto grpecs = ccdb.getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", run_mid_timestamp, metadata); | ||
auto nOrbitsPerTF = grpecs->getNHBFPerTF(); | ||
|
||
// calculate SOR orbit | ||
int64_t orbitSOR = (sor * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; | ||
int64_t orbitEOR = (eor * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS; | ||
|
||
// adjust to the nearest TF edge to satisfy condition (orbitSOR % nOrbitsPerTF == 0) | ||
orbitSOR = (orbitSOR / nOrbitsPerTF + 1) * nOrbitsPerTF; // +1 to choose the safe boundary ... towards run middle | ||
orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF; | ||
|
||
// fetch SOR directly from CTP entry on CCDB | ||
bool oldFatalState = ccdb.getFatalWhenNull(); | ||
ccdb.setFatalWhenNull(false); | ||
auto ctp_first_run_orbit = ccdb.getForTimeStamp<std::vector<int64_t>>("CTP/Calib/FirstRunOrbit", run_mid_timestamp); | ||
ccdb.setFatalWhenNull(oldFatalState); | ||
if (ctp_first_run_orbit && ctp_first_run_orbit->size() >= 3) { | ||
// if we have CTP first run orbit available, we should use it | ||
|
||
// int64_t creation_time = (*ctp_first_run_orbit)[0]; | ||
int64_t ctp_run_number = (*ctp_first_run_orbit)[1]; | ||
int64_t ctp_orbitSOR = (*ctp_first_run_orbit)[2]; | ||
|
||
if (ctp_run_number != runnumber) { | ||
LOG(error) << "AggregatedRunInfo: run number inconsistency found (asked: " << runnumber << " vs CTP found: " << ctp_run_number << ")"; | ||
} | ||
|
||
// overwrite orbitSOR | ||
if (ctp_orbitSOR != orbitSOR) { | ||
LOG(warn) << "The calculated orbitSOR " << orbitSOR << " differs from CTP orbitSOR " << ctp_orbitSOR; | ||
// reasons for this is different unit of time storage in RunInformation (ms) and orbitReset (us), etc. | ||
|
||
// so we need to adjust the SOR timings to be consistent | ||
auto sor_new = (int64_t)((tsOrbitReset + ctp_orbitSOR * o2::constants::lhc::LHCOrbitMUS) / 1000.); | ||
if (sor_new != sor) { | ||
LOG(warn) << "Adjusting SOR from " << sor << " to " << sor_new; | ||
sor = sor_new; | ||
} | ||
} | ||
orbitSOR = ctp_orbitSOR; | ||
} | ||
|
||
return AggregatedRunInfo{runnumber, sor, eor, nOrbitsPerTF, tsOrbitReset, orbitSOR, orbitEOR}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright 2019-2020 CERN and copyright holders of ALICE O2. | ||
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. | ||
// All rights not expressly granted are reserved. | ||
// | ||
// This software is distributed under the terms of the GNU General Public | ||
// License v3 (GPL Version 3), copied verbatim in the file "COPYING". | ||
// | ||
// 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. | ||
|
||
#if !defined(__CLING__) || defined(__ROOTCLING__) | ||
#include <iomanip> | ||
#include <TMath.h> | ||
#include <CCDB/BasicCCDBManager.h> | ||
#include <DataFormatsCTP/Configuration.h> | ||
#include <DataFormatsParameters/GRPLHCIFData.h> | ||
#endif | ||
using namespace o2::ctp; | ||
|
||
void CreateBKForRun() | ||
{ | ||
std::vector<int> runs = {558124, 558126, 558215, 558217, 558221, 558244, 558247}; | ||
std::string mCCDBPathCTPScalers = "CTP/Calib/Scalers"; | ||
std::string mCCDBPathCTPConfig = "CTP/Config/Config"; | ||
// | ||
std::string filename = "BKcounters.txt"; | ||
std::ofstream outfile(filename); | ||
if (!outfile) { | ||
Error("", "Failed to open file %s", filename.c_str()); | ||
return; | ||
} | ||
auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); | ||
for (auto const& runNumber : runs) { | ||
auto soreor = ccdbMgr.getRunDuration(runNumber); | ||
uint64_t timeStamp = (soreor.second - soreor.first) / 2 + soreor.first; | ||
std::cout << runNumber << " Timestamp:" << timeStamp << std::endl; | ||
// | ||
std::string srun = std::to_string(runNumber); | ||
std::map<string, string> metadata; | ||
metadata["runNumber"] = srun; | ||
auto ctpscalers = ccdbMgr.getSpecific<CTPRunScalers>(mCCDBPathCTPScalers, timeStamp, metadata); | ||
if (ctpscalers == nullptr) { | ||
LOG(info) << "CTPRunScalers not in database, timestamp:" << timeStamp; | ||
} | ||
auto ctpcfg = ccdbMgr.getSpecific<CTPConfiguration>(mCCDBPathCTPConfig, timeStamp, metadata); | ||
if (ctpcfg == nullptr) { | ||
LOG(info) << "CTPRunConfig not in database, timestamp:" << timeStamp; | ||
} | ||
// | ||
ctpscalers->convertRawToO2(); | ||
std::vector<CTPClass>& ctpcls = ctpcfg->getCTPClasses(); | ||
std::vector<int> clslist = ctpcfg->getTriggerClassList(); | ||
auto times = ctpscalers->getTimeLimit(); | ||
for (size_t i = 0; i < clslist.size(); i++) { | ||
// std::cout << i << " " << ctpcls[i].name ; | ||
std::array<uint64_t, 7> cnts = ctpscalers->getIntegralForClass(i); | ||
if (clslist[i] != (int)cnts[0]) { | ||
LOG(fatal) << "cls list incompatible with counters"; | ||
} | ||
std::cout << std::setw(21) << ctpcls[cnts[0]].name; | ||
outfile << runNumber << ", " << ctpcls[i].name << ", " << std::get<1>(times) / 1000; | ||
for (int j = 1; j < 7; j++) { | ||
// std::cout << std::setw(21) << " " << cnts[j]; | ||
std::cout << ", " << cnts[j]; | ||
outfile << ", " << cnts[j]; | ||
} | ||
std::cout << std::endl; | ||
outfile << std::endl; | ||
} | ||
} | ||
// ctpscalers->printFromZero(std::cout); | ||
outfile.close(); | ||
} |
Oops, something went wrong.