|
| 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 | + |
| 12 | +#if !defined(__CLING__) || defined(__ROOTCLING__) |
| 13 | +#include <iomanip> |
| 14 | +#include <TMath.h> |
| 15 | +#include <CCDB/BasicCCDBManager.h> |
| 16 | +#include <DataFormatsCTP/Configuration.h> |
| 17 | +#include <DataFormatsParameters/GRPLHCIFData.h> |
| 18 | +#endif |
| 19 | +using namespace o2::ctp; |
| 20 | + |
| 21 | +void CreateBKForRun() |
| 22 | +{ |
| 23 | + std::vector<int> runs = {558124, 558126, 558215, 558217, 558221, 558244, 558247}; |
| 24 | + std::string mCCDBPathCTPScalers = "CTP/Calib/Scalers"; |
| 25 | + std::string mCCDBPathCTPConfig = "CTP/Config/Config"; |
| 26 | + // |
| 27 | + std::string filename = "BKcounters.txt"; |
| 28 | + std::ofstream outfile(filename); |
| 29 | + if (!outfile) { |
| 30 | + Error("", "Failed to open file %s", filename.c_str()); |
| 31 | + return; |
| 32 | + } |
| 33 | + auto& ccdbMgr = o2::ccdb::BasicCCDBManager::instance(); |
| 34 | + for (auto const& runNumber : runs) { |
| 35 | + auto soreor = ccdbMgr.getRunDuration(runNumber); |
| 36 | + uint64_t timeStamp = (soreor.second - soreor.first) / 2 + soreor.first; |
| 37 | + std::cout << runNumber << " Timestamp:" << timeStamp << std::endl; |
| 38 | + // |
| 39 | + std::string srun = std::to_string(runNumber); |
| 40 | + std::map<string, string> metadata; |
| 41 | + metadata["runNumber"] = srun; |
| 42 | + auto ctpscalers = ccdbMgr.getSpecific<CTPRunScalers>(mCCDBPathCTPScalers, timeStamp, metadata); |
| 43 | + if (ctpscalers == nullptr) { |
| 44 | + LOG(info) << "CTPRunScalers not in database, timestamp:" << timeStamp; |
| 45 | + } |
| 46 | + auto ctpcfg = ccdbMgr.getSpecific<CTPConfiguration>(mCCDBPathCTPConfig, timeStamp, metadata); |
| 47 | + if (ctpcfg == nullptr) { |
| 48 | + LOG(info) << "CTPRunConfig not in database, timestamp:" << timeStamp; |
| 49 | + } |
| 50 | + // |
| 51 | + ctpscalers->convertRawToO2(); |
| 52 | + std::vector<CTPClass>& ctpcls = ctpcfg->getCTPClasses(); |
| 53 | + std::vector<int> clslist = ctpcfg->getTriggerClassList(); |
| 54 | + auto times = ctpscalers->getTimeLimit(); |
| 55 | + for (size_t i = 0; i < clslist.size(); i++) { |
| 56 | + // std::cout << i << " " << ctpcls[i].name ; |
| 57 | + std::array<uint64_t, 7> cnts = ctpscalers->getIntegralForClass(i); |
| 58 | + if (clslist[i] != (int)cnts[0]) { |
| 59 | + LOG(fatal) << "cls list incompatible with counters"; |
| 60 | + } |
| 61 | + std::cout << std::setw(21) << ctpcls[cnts[0]].name; |
| 62 | + outfile << runNumber << ", " << ctpcls[i].name << ", " << std::get<1>(times) / 1000; |
| 63 | + for (int j = 1; j < 7; j++) { |
| 64 | + // std::cout << std::setw(21) << " " << cnts[j]; |
| 65 | + std::cout << ", " << cnts[j]; |
| 66 | + outfile << ", " << cnts[j]; |
| 67 | + } |
| 68 | + std::cout << std::endl; |
| 69 | + outfile << std::endl; |
| 70 | + } |
| 71 | + } |
| 72 | + // ctpscalers->printFromZero(std::cout); |
| 73 | + outfile.close(); |
| 74 | +} |
0 commit comments