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+
13+ // / \brief uplaods the lutEntry_t to ccdb for a given set of lookup tables
14+
15+ #include " ALICE3/Core/FlatTrackSmearer.h"
16+ #include " ALICE3/Core/FlatLutEntry.h"
17+
18+ void uploadToCCDB ()
19+ {
20+ // Upload path
21+ const char * ccdbPath = " Users/j/jekarlss/ccdbUploadTest3/luts" ;
22+
23+ // Lookup tables to upload
24+ const char * lutEl = " lutCovm.el.20kG.rmin20.geometry_v2.dat" ;
25+ const char * lutMu = " lutCovm.mu.20kG.rmin20.geometry_v2.dat" ;
26+ const char * lutPi = " lutCovm.pi.20kG.rmin20.geometry_v2.dat" ;
27+ const char * lutKa = " lutCovm.ka.20kG.rmin20.geometry_v2.dat" ;
28+ const char * lutPr = " lutCovm.pr.20kG.rmin20.geometry_v2.dat" ;
29+ const char * lutDe = " " ;
30+ const char * lutTr = " " ;
31+ const char * lutHe3 = " " ;
32+ const char * lutAl = " " ;
33+
34+ // __________________________________________________
35+ std::vector<const char *> subDirectories = {" lutEl" , " lutMu" , " lutPi" , " lutKa" , " lutPr" , " lutDe" , " lutTr" , " lutHe3" , " lutAl" };
36+ std::vector<const char *> files = {lutEl, lutMu, lutPi, lutKa, lutPr, lutDe, lutTr, lutHe3, lutAl};
37+ std::vector<int > pdgs = {11 , 13 , 211 , 321 , 2212 , 1000010020 , 1000010030 , 1000020030 , 1000020040 };
38+
39+ static constexpr int nLUTs = 9 ; // Number of LUT available
40+
41+ o2::ccdb::CcdbApi ccdb;
42+ ccdb.init (" https://alice-ccdb.cern.ch" );
43+
44+ // Go ahead with ccdb uplaod
45+ map<string, string> metadata; // can be empty
46+ for (int lut{0 }; lut < nLUTs; ++lut) {
47+ if (pdgs[lut] != 211 ) {
48+ continue ;
49+ }
50+
51+ std::ifstream file (files[lut], std::ios::binary);
52+ if (!file.is_open ()) {
53+ std::cerr << " Failed to open file " << files[lut] << " \n " ;
54+ continue ;
55+ }
56+ o2::delphes::FlatLutData lutData = o2::delphes::FlatLutData::loadFromFile (file, files[lut]);
57+
58+ LOG (info) << " Attempting ccdb upload..." ;
59+ try {
60+ string fullPath = Form (" %s/%s" , ccdbPath, subDirectories[lut]);
61+ ccdb.storeAsBinaryFile (reinterpret_cast <const char *>(lutData.data ()), lutData.bytes (), files[lut], " o2::delphes::FlatLutData" , fullPath, metadata, /* tsSOR*/ 1747442464000 , /* tsEOR*/ 1747442764000 );
62+
63+ // ccdb.storeAsTFileAny(&lutData, fullPath, metadata, /*tsSOR*/ 1747442464000 , /*tsEOR*/ 1747442764000);
64+ } catch (const std::exception& e) {
65+ LOG (fatal) << " Failed at CCDB submission!" ;
66+ }
67+ LOG (info) << " Table for pdg " << pdgs[lut] << " uploaded!" ;
68+ }
69+ }
0 commit comments