Skip to content

Commit 6e88efa

Browse files
[PWGLF] Add converters in strangeness data model for missing info/tables (#11201)
1 parent e566a5c commit 6e88efa

File tree

3 files changed

+100
-3
lines changed

3 files changed

+100
-3
lines changed

PWGLF/TableProducer/Strangeness/Converters/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ o2physics_add_dpl_workflow(straevselsconverter4
5656

5757
o2physics_add_dpl_workflow(straevselsconverter5
5858
SOURCES straevselsconverter5.cxx
59-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ITStracking
59+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::ITStracking O2Physics::AnalysisCCDB
6060
COMPONENT_NAME Analysis)
6161

6262
o2physics_add_dpl_workflow(straevselsconverter2rawcents
@@ -113,3 +113,8 @@ o2physics_add_dpl_workflow(stramccollisionconverter2
113113
SOURCES stramccollisionconverter2.cxx
114114
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
115115
COMPONENT_NAME Analysis)
116+
117+
o2physics_add_dpl_workflow(zdcneutronsconverter
118+
SOURCES zdcneutronsconverter.cxx
119+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
120+
COMPONENT_NAME Analysis)

PWGLF/TableProducer/Strangeness/Converters/straevselsconverter5.cxx

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,75 @@
1111
#include "Framework/runDataProcessing.h"
1212
#include "Framework/AnalysisTask.h"
1313
#include "Framework/AnalysisDataModel.h"
14+
#include "CCDB/BasicCCDBManager.h"
15+
#include "DataFormatsParameters/AggregatedRunInfo.h"
1416
#include "ITStracking/Vertexer.h"
1517
#include "PWGLF/DataModel/LFStrangenessTables.h"
1618

1719
using namespace o2;
1820
using namespace o2::framework;
21+
using namespace o2::aod::evsel;
22+
23+
static const int32_t nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches;
1924

2025
// Converts Stra Event selections from 004 to 005
2126
struct straevselsconverter5 {
2227
Produces<aod::StraEvSels_005> straEvSels_005;
2328

24-
void process(aod::StraEvSels_004 const& straEvSels_004)
29+
Service<o2::ccdb::BasicCCDBManager> ccdb;
30+
31+
int lastRun = -1;
32+
int64_t lastTF = -1;
33+
uint32_t lastRCT = 0;
34+
uint64_t sorTimestamp = 0; // default SOR timestamp
35+
uint64_t eorTimestamp = 1; // default EOR timestamp
36+
int64_t bcSOR = -1; // global bc of the start of run
37+
int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 3
38+
std::map<uint64_t, uint32_t>* mapRCT = nullptr;
39+
40+
uint32_t getRctRaw(int run, uint64_t timestamp, uint64_t globalBC)
41+
{
42+
if (run != lastRun) {
43+
lastRun = run;
44+
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
45+
// first bc of the first orbit
46+
bcSOR = runInfo.orbitSOR * nBCsPerOrbit;
47+
// duration of TF in bcs
48+
nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit;
49+
// SOR and EOR timestamps
50+
sorTimestamp = runInfo.sor;
51+
eorTimestamp = runInfo.eor;
52+
// timestamp of the middle of the run used to access run-wise CCDB entries
53+
int64_t ts = runInfo.sor / 2 + runInfo.eor / 2;
54+
// QC info
55+
std::map<std::string, std::string> metadata;
56+
metadata["run"] = Form("%d", run);
57+
ccdb->setFatalWhenNull(0);
58+
mapRCT = ccdb->getSpecific<std::map<uint64_t, uint32_t>>("Users/j/jian/RCT", ts, metadata);
59+
ccdb->setFatalWhenNull(1);
60+
if (mapRCT == nullptr) {
61+
LOGP(info, "rct object missing... inserting dummy rct flags");
62+
mapRCT = new std::map<uint64_t, uint32_t>;
63+
mapRCT->insert(std::pair<uint64_t, uint32_t>(sorTimestamp, 0));
64+
}
65+
}
66+
67+
// store rct flags
68+
uint32_t rct = lastRCT;
69+
int64_t thisTF = (globalBC - bcSOR) / nBCsPerTF;
70+
if (mapRCT != nullptr && thisTF != lastTF) { // skip for unanchored runs; do it once per TF
71+
auto itrct = mapRCT->upper_bound(timestamp);
72+
if (itrct != mapRCT->begin())
73+
itrct--;
74+
rct = itrct->second;
75+
LOGP(debug, "sor={} eor={} ts={} rct={}", sorTimestamp, eorTimestamp, timestamp, rct);
76+
lastRCT = rct;
77+
lastTF = thisTF;
78+
}
79+
return rct;
80+
}
81+
82+
void process(soa::Join<aod::StraEvSels_004, aod::StraStamps> const& straEvSels_004)
2583
{
2684
for (auto& values : straEvSels_004) {
2785
straEvSels_005(values.sel8(),
@@ -55,7 +113,7 @@ struct straevselsconverter5 {
55113
values.energyCommonZNC(),
56114
values.flags(),
57115
0 /*dummy Alias value*/,
58-
0 /*dummy Rct value*/);
116+
getRctRaw(values.runNumber(), values.timestamp(), values.globalBC()) /* Rct value*/);
59117
}
60118
}
61119
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
#include "Framework/runDataProcessing.h"
12+
#include "Framework/AnalysisTask.h"
13+
#include "Framework/AnalysisDataModel.h"
14+
#include "PWGLF/DataModel/LFStrangenessTables.h"
15+
#include "PWGLF/DataModel/LFStrangenessMLTables.h"
16+
17+
using namespace o2;
18+
using namespace o2::framework;
19+
20+
//
21+
struct zdcneutronsconverter {
22+
Produces<aod::ZDCNeutrons> zdcNeutrons; // Primary neutrons within ZDC acceptance
23+
Produces<aod::ZDCNMCCollRefs> zdcNeutronsMCCollRefs; // references collisions from ZDCNeutrons
24+
25+
void process(aod::StraEvSels const&)
26+
{
27+
}
28+
};
29+
30+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
31+
{
32+
return WorkflowSpec{
33+
adaptAnalysisTask<zdcneutronsconverter>(cfgc)};
34+
}

0 commit comments

Comments
 (0)