|
8 | 8 | // In applying this license CERN does not waive the privileges and immunities |
9 | 9 | // granted to it by virtue of its status as an Intergovernmental Organization |
10 | 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 | + |
11 | 15 | #include "Framework/runDataProcessing.h" |
12 | 16 | #include "Framework/AnalysisTask.h" |
13 | 17 | #include "Framework/AnalysisDataModel.h" |
| 18 | +#include "Framework/RunningWorkflowInfo.h" |
14 | 19 | #include "Common/DataModel/Multiplicity.h" |
15 | 20 | #include "Common/DataModel/Centrality.h" |
16 | 21 | #include <CCDB/BasicCCDBManager.h> |
17 | | -#include "TH1F.h" |
| 22 | +#include <TH1F.h> |
18 | 23 |
|
19 | 24 | using namespace o2; |
20 | 25 | using namespace o2::framework; |
21 | 26 |
|
22 | 27 | struct CentralityTableTask { |
23 | | - Produces<aod::Cents> cent; |
| 28 | + Produces<aod::CentV0Ms> centVOM; |
| 29 | + Produces<aod::CentRun2SPDs> centRun2SPD; |
| 30 | + Produces<aod::CentRun2CL0s> centRun2CL1; |
| 31 | + Produces<aod::CentRun2CL1s> centRun2CL2; |
24 | 32 | Service<o2::ccdb::BasicCCDBManager> ccdb; |
25 | 33 |
|
26 | | - void init(InitContext&) |
| 34 | + Configurable<int> estV0M{"estV0M", -1, {"Produces centrality percentiles using V0 multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}}; |
| 35 | + Configurable<int> estRun2SPD{"estRun2SPD", -1, {"Produces Run2 centrality percentiles using SPD tracklets multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}}; |
| 36 | + Configurable<int> estRun2CL0{"estRun2CL0", -1, {"Produces Run2 centrality percentiles using CL0 multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}}; |
| 37 | + Configurable<int> estRun2CL1{"estRun2CL1", -1, {"Produces Run2 centrality percentiles using CL1 multiplicity. -1: auto, 0: don't, 1: yes. Default: auto (-1)"}}; |
| 38 | + |
| 39 | + int mRunNumber; |
| 40 | + bool mV0MCalibrationStored; |
| 41 | + TH1* mhVtxAmpCorrV0A; |
| 42 | + TH1* mhVtxAmpCorrV0C; |
| 43 | + TH1* mhMultSelCalibV0M; |
| 44 | + |
| 45 | + void init(InitContext& context) |
27 | 46 | { |
| 47 | + /* Checking the tables which are requested in the workflow and enabling them */ |
| 48 | + auto& workflows = context.services().get<RunningWorkflowInfo const>(); |
| 49 | + for (DeviceSpec device : workflows.devices) { |
| 50 | + for (auto input : device.inputs) { |
| 51 | + auto enable = [&input](const std::string detector, Configurable<int>& flag) { |
| 52 | + const std::string table = "Cent" + detector + "s"; |
| 53 | + if (input.matcher.binding == table) { |
| 54 | + if (flag < 0) { |
| 55 | + flag.value = 1; |
| 56 | + LOGF(info, "Auto-enabling table: %s", table.c_str()); |
| 57 | + } else if (flag > 0) { |
| 58 | + flag.value = 1; |
| 59 | + LOGF(info, "Table %s already enabled", table.c_str()); |
| 60 | + } else { |
| 61 | + LOGF(info, "Table %s disabled", table.c_str()); |
| 62 | + } |
| 63 | + } |
| 64 | + }; |
| 65 | + enable("V0M", estV0M); |
| 66 | + enable("Run2SPD", estRun2SPD); |
| 67 | + enable("Run2CL0", estRun2CL0); |
| 68 | + enable("Run2CL1", estRun2CL1); |
| 69 | + } |
| 70 | + } |
28 | 71 | ccdb->setURL("http://alice-ccdb.cern.ch"); |
29 | 72 | ccdb->setCaching(true); |
30 | 73 | ccdb->setLocalObjectValidityChecking(); |
| 74 | + mRunNumber = 0; |
| 75 | + mV0MCalibrationStored = false; |
| 76 | + mhVtxAmpCorrV0A = nullptr; |
| 77 | + mhVtxAmpCorrV0C = nullptr; |
| 78 | + mhMultSelCalibV0M = nullptr; |
31 | 79 | } |
32 | 80 |
|
33 | | - void process(soa::Join<aod::Collisions, aod::Mults>::iterator const& collision, aod::BCsWithTimestamps const&) |
| 81 | + void process(soa::Join<aod::Collisions, aod::Mults>::iterator const& collision, aod::BCsWithTimestamps const&, aod::Tracks const& tracks) |
34 | 82 | { |
| 83 | + /* check the previous run number */ |
35 | 84 | auto bc = collision.bc_as<aod::BCsWithTimestamps>(); |
36 | | - LOGF(debug, "timestamp=%llu", bc.timestamp()); |
37 | | - TH1F* hCumMultV0M = ccdb->getForTimeStamp<TH1F>("Centrality/CumMultV0M", bc.timestamp()); |
38 | | - if (!hCumMultV0M) { |
39 | | - LOGF(fatal, "V0M centrality calibration is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); |
40 | | - } |
41 | | - float centV0M = hCumMultV0M->GetBinContent(hCumMultV0M->FindFixBin(collision.multV0M())); |
| 85 | + if (bc.runNumber() != mRunNumber) { |
| 86 | + LOGF(debug, "timestamp=%llu", bc.timestamp()); |
| 87 | + TList* callst = ccdb->getForTimeStamp<TList>("Centrality/Estimators", bc.timestamp()); |
42 | 88 |
|
43 | | - LOGF(debug, "centV0M=%.0f", centV0M); |
44 | | - // fill centrality columns |
45 | | - cent(centV0M); |
| 89 | + if (callst != nullptr) { |
| 90 | + auto getccdb = [callst](const char* ccdbhname, const char* hname) { |
| 91 | + TH1* h = (TH1*)callst->FindObject(ccdbhname)->Clone(hname); |
| 92 | + return h; |
| 93 | + }; |
| 94 | + if (estV0M == 1) { |
| 95 | + mhVtxAmpCorrV0A = getccdb("hVtx_fAmplitude_V0A_Normalized", "zvtxCalibV0A"); |
| 96 | + mhVtxAmpCorrV0C = getccdb("hVtx_fAmplitude_V0C_Normalized", "zvtxCalibV0C"); |
| 97 | + mhMultSelCalibV0M = getccdb("hMultSelCalib_V0M", "MultSelCalibV0M"); |
| 98 | + if ((mhVtxAmpCorrV0A != nullptr) and (mhVtxAmpCorrV0C != nullptr) and (mhMultSelCalibV0M != nullptr)) { |
| 99 | + mV0MCalibrationStored = true; |
| 100 | + } else { |
| 101 | + LOGF(fatal, "Calibration information from V0M for run %d corrupted"); |
| 102 | + } |
| 103 | + } |
| 104 | + if (estRun2SPD == 1) { |
| 105 | + LOGF(fatal, "Run2 calibration information estimated from SPD tracklets still not available"); |
| 106 | + } |
| 107 | + if (estRun2CL0 == 1) { |
| 108 | + LOGF(fatal, "Run2 calibration information estimated from CL0 still not available"); |
| 109 | + } |
| 110 | + if (estRun2CL1 == 1) { |
| 111 | + LOGF(fatal, "Run2 calibration information estimated from CL1 still not available"); |
| 112 | + } |
| 113 | + if (mV0MCalibrationStored) { |
| 114 | + mRunNumber = bc.runNumber(); |
| 115 | + } |
| 116 | + } else { |
| 117 | + /* we dont change the run number to keep trying */ |
| 118 | + mV0MCalibrationStored = false; |
| 119 | + LOGF(fatal, "Centrality calibration is not available in CCDB for run=%d at timestamp=%llu", bc.runNumber(), bc.timestamp()); |
| 120 | + } |
| 121 | + } |
| 122 | + if (estV0M == 1) { |
| 123 | + float centV0M = 105.0f; |
| 124 | + if (mV0MCalibrationStored) { |
| 125 | + float v0m = collision.multV0A() * mhVtxAmpCorrV0A->GetBinContent(mhVtxAmpCorrV0A->FindFixBin(collision.posZ())) + |
| 126 | + collision.multV0C() * mhVtxAmpCorrV0C->GetBinContent(mhVtxAmpCorrV0C->FindFixBin(collision.posZ())); |
| 127 | + centV0M = mhMultSelCalibV0M->GetBinContent(mhMultSelCalibV0M->FindFixBin(v0m)); |
| 128 | + } |
| 129 | + LOGF(debug, "centV0M=%.0f", centV0M); |
| 130 | + // fill centrality columns |
| 131 | + centVOM(centV0M); |
| 132 | + } |
46 | 133 | } |
47 | 134 | }; |
48 | 135 |
|
|
0 commit comments