|
| 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 | +/// \file TestCTPScalers.C |
| 13 | +/// \brief create CTP scalers, test it and add to database |
| 14 | +/// \author Roman Lietava |
| 15 | +#if !defined(__CLING__) || defined(__ROOTCLING__) |
| 16 | + |
| 17 | +#include <fairlogger/Logger.h> |
| 18 | +#include "CCDB/CcdbApi.h" |
| 19 | +#include "CCDB/BasicCCDBManager.h" |
| 20 | +#include "DataFormatsCTP/Scalers.h" |
| 21 | +#include "DataFormatsCTP/Configuration.h" |
| 22 | +#include "TFile.h" |
| 23 | +#include "TString.h" |
| 24 | +#include <string> |
| 25 | +#include <map> |
| 26 | +#include <iostream> |
| 27 | +#endif |
| 28 | +using namespace o2::ctp; |
| 29 | +void GetAndSave(std::string ccdbHost = "http://ccdb-test.cern.ch:8080") |
| 30 | +{ |
| 31 | + std::string CCDBPathCTPScalers = "CTP/Calib/Scalers"; |
| 32 | + // std::vector<string> runs = {"518541","518543","518546","518547"}; |
| 33 | + // std::vector<long> timestamps = {1655116302316,1655118513690,1655121997478,1655123792911}; |
| 34 | + std::vector<string> runs = {"519903", "519904", "519905", "519906"}; |
| 35 | + std::vector<long> timestamps = {1656658674161, 1656660737184, 1656667772462, 1656669421115}; |
| 36 | + // std::vector<string> runs = {"518543"}; |
| 37 | + // std::vector<long> timestamps = {1655118513690}; |
| 38 | + int i = 0; |
| 39 | + CTPRunManager mng; |
| 40 | + // mng.setCCDBHost(ccdbHost); |
| 41 | + auto& mgr = o2::ccdb::BasicCCDBManager::instance(); |
| 42 | + mgr.setURL(ccdbHost); |
| 43 | + for (auto const& run : runs) { |
| 44 | + CTPConfiguration ctpcfg; |
| 45 | + CTPRunScalers scl; |
| 46 | + map<string, string> metadata; // can be empty |
| 47 | + metadata["runNumber"] = run; |
| 48 | + CTPRunScalers* ctpscalers = mgr.getSpecific<CTPRunScalers>(CCDBPathCTPScalers, timestamps[i], metadata); |
| 49 | + if (ctpscalers == nullptr) { |
| 50 | + std::cout << run << " CTPRunScalers not in database, timestamp:" << timestamps[i] << std::endl; |
| 51 | + } else { |
| 52 | + // ctpscalers->printStream(std::cout); |
| 53 | + std::string name = run + ".root"; |
| 54 | + TFile* myFile = TFile::Open(name.c_str(), "RECREATE"); |
| 55 | + myFile->WriteObject(ctpscalers, "CTPRunScalers"); |
| 56 | + // myFile->Write(); |
| 57 | + std::cout << run << " ok" << std::endl; |
| 58 | + } |
| 59 | + i++; |
| 60 | + } |
| 61 | +} |
0 commit comments