|
| 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 dqFlowAccWeights.C |
| 13 | +/// \brief A simple macro to read produced accptance weights for Q-vector and submit them to CCDB |
| 14 | +/// |
| 15 | +/// \author Chi ZHANG, CEA-Saclay, chi.zhang@cern.ch |
| 16 | + |
| 17 | +#include <gsl/span> |
| 18 | +#include <cmath> |
| 19 | +#include <string> |
| 20 | +#include <unordered_map> |
| 21 | +#include <vector> |
| 22 | +#include <iostream> |
| 23 | + |
| 24 | +#include <TSystem.h> |
| 25 | +#include <TFile.h> |
| 26 | +#include "Framework/Logger.h" |
| 27 | +#include "CCDB/BasicCCDBManager.h" |
| 28 | +#include "PWGCF/GenericFramework/Core/GFWWeights.h" |
| 29 | + |
| 30 | +using namespace o2; |
| 31 | +using namespace std; |
| 32 | + |
| 33 | +void dqFlowAccWeights(int64 tmin = 1546300800000, int64 tmax = 1577833200000, std::string Period = "LHC23zzh_pass2", std::string SubDir = "d-q-event-qvector", std::string FileName = "AnalysisResults.root") |
| 34 | +{ |
| 35 | + if (tmax < tmin) { |
| 36 | + LOG(fatal) << "Wrong validity syntax!"; |
| 37 | + } |
| 38 | + |
| 39 | + const std::string& ccdbHost = "http://alice-ccdb.cern.ch"; |
| 40 | + // long tmin = 1546300800000; // Jan 2019 |
| 41 | + // long tmax = 1577833200000; // Dec 2019 |
| 42 | + // long tmin = 1641038770000; // Jan 2022 |
| 43 | + // long tmax = 1663632000000; // 20 Sep 2022 |
| 44 | + const std::string& objectPath = Form("Users/c/chizh/Acceptance/%s", Period.c_str()); |
| 45 | + |
| 46 | + // Load weights |
| 47 | + TFile* file; |
| 48 | + try { |
| 49 | + file = TFile::Open(FileName.c_str()); |
| 50 | + } catch (std::exception const& e) { |
| 51 | + LOG(fatal) << "Cannot open input file!"; |
| 52 | + } |
| 53 | + |
| 54 | + GFWWeights* weights; |
| 55 | + try { |
| 56 | + file->GetObject(Form("%s/%s", SubDir.c_str(), "weights"), weights); |
| 57 | + } catch (std::exception const& e) { |
| 58 | + LOG(fatal) << "Cannot get GFWWeights from inpout file!"; |
| 59 | + } |
| 60 | + |
| 61 | + // Send to CCDB |
| 62 | + if (!ccdbHost.empty()) { |
| 63 | + LOGP(info, "Storing alignment object on {}/{}", ccdbHost, objectPath); |
| 64 | + o2::ccdb::CcdbApi api; |
| 65 | + map<string, string> metadata; // can be empty |
| 66 | + metadata.insert(std::pair{"comment", Form("Acceptance weights for %s", Period.c_str())}); |
| 67 | + api.init(ccdbHost.c_str()); |
| 68 | + try { |
| 69 | + api.storeAsTFileAny(weights, objectPath, metadata, tmin, tmax); |
| 70 | + } catch (std::exception const& e) { |
| 71 | + LOG(fatal) << "Failed at CCDB submission!"; |
| 72 | + } |
| 73 | + } |
| 74 | + file->Close(); |
| 75 | +} |
0 commit comments