1717#include <map>
1818#include <array>
1919
20- #include <ROOT/RDataFrame.hxx>
2120#include "TFile.h"
22- #include "TKey .h"
21+ #include "TGrid .h"
2322#include "TH1.h"
23+ #include "TKey.h"
24+ #include "TSystem.h"
25+ #include "TTree.h"
2426
2527#include "CCDB/BasicCCDBManager.h"
2628
27- const std ::string kBaseCCDBPath = "Users/r/rlietava /EventFiltering/OTS/" ;
29+ const std ::string kBaseCCDBPath = "Users/m/mpuccio /EventFiltering/OTS/" ;
2830
2931#pragma link C++ class std::vector < std::array < uint64_t, 2>> + ;
3032struct bcInfo {
3133 bcInfo () = default ;
32- ULong64_t bcAOD , bcEvSel , trigMask , selMask ;
34+ ULong64_t bcAOD , bcEvSel , trigMask [ 2 ] , selMask [ 2 ] ;
3335 void print () const ;
3436};
35- void uploadOTSobjects (std ::string inputList )
37+
38+ void uploadOTSobjects (std ::string inputList , std ::string passName , bool useAlien )
3639{
40+ std ::string baseCCDBpath = passName .empty () ? kBaseCCDBPath : kBaseCCDBPath + passName + "/" ;
41+ if (useAlien ) {
42+ TGrid ::Connect ("alien://" );
43+ }
3744 o2 ::ccdb ::CcdbApi api ;
3845 api .init ("http://alice-ccdb.cern.ch" );
3946
@@ -49,42 +56,53 @@ void uploadOTSobjects(std::string inputList)
4956 std ::pair < int64_t , int64_t > duration = o2 ::ccdb ::BasicCCDBManager ::getRunDuration (api , runNumber );
5057 duration .first -= 10000 ; // subtract 3 minutes from the run start
5158 duration .second += 180000 ; // add 3 minutes to the run duration
52- TFile scalersFile ((path + "/AnalysisResults_fullrun.root" ).data (), "READ" );
53- TH1 * scalers = (TH1 * )scalersFile .Get ("central-event-filter-task/scalers/mScalers" );
54- TH1 * filters = (TH1 * )scalersFile .Get ("central-event-filter-task/scalers/mFiltered" );
55- api .storeAsTFile (scalers , kBaseCCDBPath + "FilterCounters" , metadata , duration .first , duration .second );
56- api .storeAsTFile (filters , kBaseCCDBPath + "SelectionCounters" , metadata , duration .first , duration .second );
57- TH1 * hCounterTVX = (TH1 * )scalersFile .Get ("bc-selection-task/hCounterTVX" );
58- api .storeAsTFile (hCounterTVX , kBaseCCDBPath + "InspectedTVX" , metadata , duration .first , duration .second );
59+ std ::cout << ">>> Begin - end timestamps for the upload: " << duration .first << " - " << duration .second << std ::endl ;
60+ path = useAlien ? "alien://" + path : path ;
61+ std ::unique_ptr < TFile > scalersFile {TFile ::Open ((path + "/AnalysisResults_fullrun.root" ).data (), "READ" )};
62+ TH1 * scalers = (TH1 * )scalersFile -> Get ("central-event-filter-task/scalers/mScalers" );
63+ TH1 * filters = (TH1 * )scalersFile -> Get ("central-event-filter-task/scalers/mFiltered" );
64+ api .storeAsTFile (scalers , baseCCDBpath + "FilterCounters" , metadata , duration .first , duration .second );
65+ api .storeAsTFile (filters , baseCCDBpath + "SelectionCounters" , metadata , duration .first , duration .second );
66+ TH1 * hCounterTVX = (TH1 * )scalersFile -> Get ("bc-selection-task/hCounterTVX" );
67+ api .storeAsTFile (hCounterTVX , baseCCDBpath + "InspectedTVX" , metadata , duration .first , duration .second );
5968
6069 std ::vector < std ::array < uint64_t , 2 >> bcRanges , filterBitMask , selectionBitMask ;
61- TFile bcRangesFile ((path + "/bcRanges_fullrun.root" ).data (), "READ" );
70+ std :: unique_ptr < TFile > bcRangesFile { TFile :: Open ((path + "/bcRanges_fullrun.root" ).data (), "READ" )} ;
6271 int Nmax = 0 ;
63- for (auto key : * (bcRangesFile . GetListOfKeys ())) {
64- TTree * cefpTree = (TTree * )bcRangesFile . Get (Form ("%s/selectedBC" , key -> GetName ()));
72+ for (auto key : * (bcRangesFile -> GetListOfKeys ())) {
73+ TTree * cefpTree = (TTree * )bcRangesFile -> Get (Form ("%s/selectedBC" , key -> GetName ()));
6574 if (!cefpTree )
6675 continue ;
6776 bcInfo bci ;
6877 cefpTree -> SetBranchAddress ("bcAO2D" , & bci .bcAOD );
6978 cefpTree -> SetBranchAddress ("bcEvSel" , & bci .bcEvSel );
70- cefpTree -> SetBranchAddress ("selMask" , & bci .selMask );
71- cefpTree -> SetBranchAddress ("triMask" , & bci .trigMask );
79+ if (cefpTree -> GetBranch ("selMask" ) && cefpTree -> GetBranch ("triMask" )) {
80+ cefpTree -> SetBranchAddress ("selMask" , & bci .selMask [0 ]);
81+ cefpTree -> SetBranchAddress ("triMask" , & bci .trigMask [0 ]);
82+ } else {
83+ cefpTree -> SetBranchAddress ("selMask0" , & bci .selMask [0 ]);
84+ cefpTree -> SetBranchAddress ("triMask0" , & bci .trigMask [0 ]);
85+ cefpTree -> SetBranchAddress ("selMask1" , & bci .selMask [1 ]);
86+ cefpTree -> SetBranchAddress ("triMask1" , & bci .trigMask [1 ]);
87+ }
7288 for (int i = 0 ; i < cefpTree -> GetEntries (); i ++ ) {
7389 if ((i < Nmax ) || (Nmax == 0 )) {
7490 cefpTree -> GetEntry (i );
75- // Check consistency
76- if (~bci .trigMask & bci .selMask ) {
77- std ::cout << "ERROR selMask is not subset of trigMask:" ;
78- // bcAO2D.print();
79- }
8091 bcRanges .push_back ({bci .bcAOD , bci .bcEvSel });
81- filterBitMask .push_back ({bci .trigMask , 0ull });
82- selectionBitMask .push_back ({bci .selMask , 0ull });
92+ filterBitMask .push_back ({bci .trigMask [ 0 ], bci . trigMask [ 1 ] });
93+ selectionBitMask .push_back ({bci .selMask [ 0 ], bci . selMask [ 1 ] });
8394 }
8495 }
8596 }
86- api .storeAsTFileAny (& bcRanges , kBaseCCDBPath + "SelectedBCs" , metadata , duration .first , duration .second );
87- api .storeAsTFileAny (& filterBitMask , kBaseCCDBPath + "FilterBitMasks" , metadata , duration .first , duration .second );
88- api .storeAsTFileAny (& selectionBitMask , kBaseCCDBPath + "SelectionBitMasks" , metadata , duration .first , duration .second );
97+ api .storeAsTFileAny (& bcRanges , baseCCDBpath + "SelectedBCs" , metadata , duration .first , duration .second );
98+ api .storeAsTFileAny (& filterBitMask , baseCCDBpath + "FilterBitMasks" , metadata , duration .first , duration .second );
99+ api .storeAsTFileAny (& selectionBitMask , baseCCDBpath + "SelectionBitMasks" , metadata , duration .first , duration .second );
89100 }
90101}
102+
103+ void uploadOTSobjects (std ::string periodName )
104+ {
105+ int year = 2000 + std ::stoi (periodName .substr (3 , 2 ));
106+ gSystem -> Exec (Form ("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root | sed 's:/AnalysisResults_fullrun\\.root::' > list_%s.txt" , year , periodName .data (), periodName .data ()));
107+ uploadOTSobjects (Form ("list_%s.txt" , periodName .data ()), "" , true);
108+ }
0 commit comments