Skip to content

Commit dd113d6

Browse files
First step towards the new centraltity task
So far a separated new task only tested by the dpt-dpt correlations task
1 parent f25c3ba commit dd113d6

File tree

4 files changed

+193
-4
lines changed

4 files changed

+193
-4
lines changed

Common/DataModel/Centrality_new.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
#ifndef O2_ANALYSIS_CENTRALITYNEW_H_
12+
#define O2_ANALYSIS_CENTRALITYNEW_H_
13+
14+
#include "Framework/AnalysisDataModel.h"
15+
16+
namespace o2::aod
17+
{
18+
namespace cent
19+
{
20+
DECLARE_SOA_COLUMN(CentEstV0M, centV0M, float); //! Centrality percentile estimated from V0C+V0A multiplicities
21+
DECLARE_SOA_COLUMN(CentEstSPDTracklets, centSPDTracklets, float); //! Centrality percentile estimated from SPD tracklets multiplicity
22+
DECLARE_SOA_COLUMN(CentEstCL0, centCL0, float); //! Centrality percentile estimated from CL0 multiplicity
23+
DECLARE_SOA_COLUMN(CentEstCL1, centCL1, float); //! Centrality percentile estimated from CL1 multiplicity
24+
} // namespace cent
25+
DECLARE_SOA_TABLE(CentV0Ms, "AOD", "CENTV0M", cent::CentEstV0M); //! V0M estimated centrality table
26+
DECLARE_SOA_TABLE(CentSPDs, "AOD", "CENTSPD", cent::CentEstSPDTracklets); //! SPD tracklets estimated centrality table
27+
DECLARE_SOA_TABLE(CentCL0s, "AOD", "CENTCL0", cent::CentEstCL0); //! CL0 estimated centrality table
28+
DECLARE_SOA_TABLE(CentCL1s, "AOD", "CENTCL1", cent::CentEstCL1); //! CL1 estimated centrality table
29+
using CentV0M = CentV0Ms::iterator;
30+
using CentSPD = CentSPDs::iterator;
31+
using CentCL0 = CentCL0s::iterator;
32+
using CentCL1 = CentCL1s::iterator;
33+
} // namespace o2::aod
34+
35+
#endif // O2_ANALYSIS_CENTRALITYNEW_H_

Common/TableProducer/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ o2physics_add_dpl_workflow(centrality-table
3636
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::CCDB
3737
COMPONENT_NAME Analysis)
3838

39+
o2physics_add_dpl_workflow(centralitynew-table
40+
SOURCES centralityTable_new.cxx
41+
PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::AnalysisCore O2::DetectorsBase O2::CCDB
42+
COMPONENT_NAME Analysis)
43+
3944
o2physics_add_dpl_workflow(timestamp
4045
SOURCES timestamp.cxx
4146
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2::DetectorsRaw O2Physics::AnalysisCore O2::CommonDataFormat O2::CCDB
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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 centrality.cxx
13+
/// \brief Task to produce the centrality tables associated to each of the required centrality estimators
14+
15+
#include "Framework/runDataProcessing.h"
16+
#include "Framework/AnalysisTask.h"
17+
#include "Framework/AnalysisDataModel.h"
18+
#include "Framework/RunningWorkflowInfo.h"
19+
#include "Common/DataModel/Multiplicity.h"
20+
#include "Common/DataModel/Centrality_new.h"
21+
#include <CCDB/BasicCCDBManager.h>
22+
#include <TH1F.h>
23+
#include <TF1.h>
24+
25+
using namespace o2;
26+
using namespace o2::framework;
27+
28+
struct CentralityTableTask {
29+
Produces<aod::CentV0Ms> centVOM;
30+
Produces<aod::CentSPDs> centSPD;
31+
Produces<aod::CentCL0s> centCL1;
32+
Produces<aod::CentCL1s> centCL2;
33+
Service<o2::ccdb::BasicCCDBManager> ccdb;
34+
35+
Configurable<int> estV0M{"estV0M", -1, {"Produces centrality percentiles using V0 multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}};
36+
Configurable<int> estSPD{"estSPD", -1, {"Produces centrality percentiles using SPD tracklets multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}};
37+
Configurable<int> estCL0{"estCL0", -1, {"Produces centrality percentiles using CL0 multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}};
38+
Configurable<int> estCL1{"estCL1", -1, {"Produces centrality percentiles using CL1 multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}};
39+
40+
int mRunNumber;
41+
bool mV0MCallibrationStored;
42+
TH1* mhVtxAmpCorrV0A;
43+
TH1* mhVtxAmpCorrV0C;
44+
TH1* mhMultSelCalibV0M;
45+
46+
void init(InitContext& context)
47+
{
48+
/* Checking the tables which are requested in the workflow and enabling them */
49+
auto& workflows = context.services().get<RunningWorkflowInfo const>();
50+
for (DeviceSpec device : workflows.devices) {
51+
for (auto input : device.inputs) {
52+
auto enable = [&input](const std::string detector, Configurable<int>& flag) {
53+
const std::string table = "Cent" + detector + "s";
54+
if (input.matcher.binding == table) {
55+
if (flag < 0) {
56+
flag.value = 1;
57+
LOGF(info, "Auto-enabling table: %s", table.c_str());
58+
} else if (flag > 0) {
59+
flag.value = 1;
60+
LOGF(info, "Table %s already enabled", table.c_str());
61+
} else {
62+
LOGF(info, "Table %s disabled", table.c_str());
63+
}
64+
}
65+
};
66+
enable("V0M", estV0M);
67+
enable("SPD", estSPD);
68+
enable("CL0", estCL0);
69+
enable("CL1", estCL1);
70+
}
71+
}
72+
ccdb->setURL("http://alice-ccdb.cern.ch");
73+
ccdb->setCaching(true);
74+
ccdb->setLocalObjectValidityChecking();
75+
mRunNumber = 0;
76+
mV0MCallibrationStored = false;
77+
mhVtxAmpCorrV0A = nullptr;
78+
mhVtxAmpCorrV0C = nullptr;
79+
mhMultSelCalibV0M = nullptr;
80+
}
81+
82+
void process(soa::Join<aod::Collisions, aod::Mults>::iterator const& collision, aod::BCsWithTimestamps const&, aod::Tracks const& tracks)
83+
{
84+
/* check the previous run number */
85+
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
86+
if (bc.runNumber() != mRunNumber) {
87+
LOGF(debug, "timestamp=%llu", bc.timestamp());
88+
TList* callst = ccdb->getForTimeStamp<TList>("Users/v/victor/Centrality", bc.timestamp());
89+
90+
if (callst != nullptr) {
91+
auto zvtxcalib = [callst](const char* tpname, const char* hname) {
92+
TProfile* tp = (TProfile*)callst->FindObject(tpname);
93+
TH1* h = new TH1F(TString::Format("%s", hname), TString::Format("%s;#it{z}_{vtx}", hname),
94+
tp->GetNbinsX(), tp->GetXaxis()->GetBinLowEdge(1), tp->GetXaxis()->GetBinUpEdge(tp->GetNbinsX()));
95+
TF1 one = TF1("one", "1", tp->GetXaxis()->GetBinLowEdge(1), tp->GetXaxis()->GetBinUpEdge(tp->GetNbinsX()));
96+
h->Reset();
97+
h->Add(&one, tp->GetMean(2));
98+
h->Divide(tp);
99+
return h;
100+
};
101+
auto multcalib = [callst](const char* ccdbhname, const char* hname) {
102+
TH1* h = (TH1*)callst->FindObject(ccdbhname)->Clone(hname);
103+
return h;
104+
};
105+
if (estV0M == 1) {
106+
mhVtxAmpCorrV0A = zvtxcalib("hVtx_fAmplitude_V0A", "zvtxCalibV0A");
107+
mhVtxAmpCorrV0C = zvtxcalib("hVtx_fAmplitude_V0C", "zvtxCalibV0C");
108+
mhMultSelCalibV0M = multcalib("hMultSelCalib_V0M", "MultSelCalibV0M");
109+
if ((mhVtxAmpCorrV0A != nullptr) and (mhVtxAmpCorrV0C != nullptr) and (mhMultSelCalibV0M != nullptr)) {
110+
mV0MCallibrationStored = true;
111+
}
112+
}
113+
if (estSPD == 1) {
114+
LOGF(fatal, "Calibraltion information estimated from SPD tracklets still not available");
115+
}
116+
if (estCL0 == 1) {
117+
LOGF(fatal, "Calibraltion information estimated from CL0 still not available");
118+
}
119+
if (estCL1 == 1) {
120+
LOGF(fatal, "Calibraltion information estimated from CL1 still not available");
121+
}
122+
if (mV0MCallibrationStored) {
123+
mRunNumber = bc.runNumber();
124+
}
125+
} else {
126+
/* we dont change the run number to keep trying */
127+
mV0MCallibrationStored = false;
128+
LOGF(error, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp());
129+
}
130+
}
131+
if (estV0M == 1) {
132+
float centV0M = 105.0f;
133+
if (mV0MCallibrationStored) {
134+
float v0m = collision.multV0A() * mhVtxAmpCorrV0A->GetBinContent(mhVtxAmpCorrV0A->FindFixBin(collision.posZ())) +
135+
collision.multV0C() * mhVtxAmpCorrV0C->GetBinContent(mhVtxAmpCorrV0C->FindFixBin(collision.posZ()));
136+
centV0M = mhMultSelCalibV0M->GetBinContent(mhMultSelCalibV0M->FindFixBin(v0m));
137+
}
138+
LOGF(info, "centV0M=%.0f", centV0M);
139+
// fill centrality columns
140+
centVOM(centV0M);
141+
}
142+
}
143+
};
144+
145+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
146+
{
147+
return WorkflowSpec{
148+
adaptAnalysisTask<CentralityTableTask>(cfgc, TaskName{"centrality-table"})};
149+
}

PWGCF/Tasks/dptdptcorrelations-simchl.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "Framework/AnalysisDataModel.h"
1414
#include "Framework/ASoAHelpers.h"
1515
#include "Common/DataModel/EventSelection.h"
16-
#include "Common/DataModel/Centrality.h"
16+
#include "Common/DataModel/Centrality_new.h"
1717
#include "Common/Core/TrackSelection.h"
1818
#include "Common/Core/MC.h"
1919
#include "PWGCF/Core/AnalysisConfigurableCuts.h"
@@ -90,8 +90,8 @@ DECLARE_SOA_TABLE(ScannedTrueTracks, "AOD", "SCANTRUETRACKS", //! The generated
9090
dptdptcorrelations::Eta,
9191
dptdptcorrelations::Phi);
9292

93-
using CollisionsEvSelCent = soa::Join<aod::Collisions, aod::EvSels, aod::Cents>;
94-
using CollisionEvSelCent = soa::Join<aod::Collisions, aod::EvSels, aod::Cents>::iterator;
93+
using CollisionsEvSelCent = soa::Join<aod::Collisions, aod::EvSels, aod::CentV0Ms>;
94+
using CollisionEvSelCent = soa::Join<aod::Collisions, aod::EvSels, aod::CentV0Ms>::iterator;
9595
using CollisionsEvSel = soa::Join<aod::Collisions, aod::EvSels>;
9696
using CollisionEvSel = soa::Join<aod::Collisions, aod::EvSels>::iterator;
9797
using TrackData = soa::Join<aod::Tracks, aod::TracksCov, aod::TracksExtra, aod::TracksExtended, aod::TrackSelection>::iterator;
@@ -882,7 +882,7 @@ struct DptDptCorrelationsFilterAnalysisTask {
882882
PROCESS_SWITCH(DptDptCorrelationsFilterAnalysisTask, processWithoutCentDetectorLevel, "Process MC detector level without centrality", false);
883883

884884
void processWithCentGeneratorLevel(aod::McCollision const& mccollision,
885-
soa::Join<aod::McCollisionLabels, aod::Collisions, aod::EvSels, aod::Cents> const& collisions,
885+
soa::Join<aod::McCollisionLabels, aod::Collisions, aod::EvSels, aod::CentV0Ms> const& collisions,
886886
aod::McParticles const& mcparticles)
887887
{
888888
using namespace filteranalysistask;

0 commit comments

Comments
 (0)