-
Notifications
You must be signed in to change notification settings - Fork 652
Expand file tree
/
Copy pathMaterialBudgetWeights.h
More file actions
96 lines (77 loc) · 3.23 KB
/
MaterialBudgetWeights.h
File metadata and controls
96 lines (77 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file materialBudgetWeights.cxx
///
/// \brief This code produces a table to retrieve material budget weights. The table is to be join with V0PhotonKF
///
/// \author Youssef El Mard (youssef.el.mard.bouziani@cern.ch)
///
#ifndef PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_
#define PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_
#include "PWGEM/PhotonMeson/DataModel/gammaTables.h"
#include "Framework/ASoAHelpers.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/AnalysisTask.h"
#include "Framework/Logger.h"
#include <CCDB/BasicCCDBManager.h>
#include <Framework/Configurable.h>
#include <Framework/InitContext.h>
#include <map>
#include <string>
using namespace o2;
using namespace o2::soa;
using namespace o2::framework;
using MyV0PhotonsMB = o2::soa::Join<o2::aod::V0PhotonsKF, o2::aod::V0KFEMEventIds>;
using MyV0PhotonMB = MyV0PhotonsMB::iterator;
struct MaterialBudgetWeights {
Produces<aod::V0PhotonOmegaMBWeights> omegaMBWeight;
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://ccdb-test.cern.ch:8080", "CCDB url"};
Configurable<std::string> mbWeightsPath{"mbWeightsPath", "Users/y/yelmard/MaterialBudget/OmegaMBWeights", "Path of the mb weights"};
Configurable<bool> runWithMBWeights{"runWithMBWeights", false, "Run task using material-budget weights for PCM photons"};
o2::ccdb::CcdbApi ccdbApi;
TH1F* hOmegaMBFromCCDB = nullptr;
void init(InitContext&)
{
if (!runWithMBWeights) {
LOG(info) << "MaterialBudgetWeights: runWithMBWeights=false -> no CCDB query, will write weight=1";
return;
}
ccdbApi.init(ccdbUrl.value);
std::map<std::string, std::string> metadata;
LOG(info) << "MaterialBudgetWeights: loading Omega MB histogram from CCDB at path: " << mbWeightsPath.value;
hOmegaMBFromCCDB = ccdbApi.retrieveFromTFileAny<TH1F>(mbWeightsPath, metadata, -1);
if (!hOmegaMBFromCCDB) {
LOG(fatal) << "MaterialBudgetWeights: runWithMBWeights=true but CCDB object is missing. Path=" << mbWeightsPath.value;
}
}
float computeMBWeight(float v0Rxy)
{
if (!hOmegaMBFromCCDB) {
LOG(fatal) << "MaterialBudgetWeights: internal error: histogram nullptr while runWithMBWeights=true";
}
int binMBWeight = hOmegaMBFromCCDB->FindBin(v0Rxy);
if (binMBWeight < 1 || binMBWeight > hOmegaMBFromCCDB->GetNbinsX()) {
LOG(debug) << "MaterialBudgetWeights: v0Rxy out of histogram range, returning 1";
return 1.f;
}
return hOmegaMBFromCCDB->GetBinContent(binMBWeight);
}
void process(MyV0PhotonMB const& v0)
{
if (!runWithMBWeights) {
omegaMBWeight(1.f);
return;
}
omegaMBWeight(computeMBWeight(v0.v0radius()));
}
};
#endif // PWGEM_PHOTONMESON_UTILS_MATERIALBUDGETWEIGHTS_H_