|
| 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 | +#include <CCDB/BasicCCDBManager.h> |
| 13 | +#include "Common/CCDB/ctpRateFetcher.h" |
| 14 | +#include "Common/DataModel/EventSelection.h" |
| 15 | +#include "Common/DataModel/Multiplicity.h" |
| 16 | +#include "tables.h" |
| 17 | + |
| 18 | +#include "Framework/AnalysisTask.h" |
| 19 | +#include "Framework/runDataProcessing.h" |
| 20 | + |
| 21 | +using namespace o2; |
| 22 | +using namespace o2::framework; |
| 23 | +using namespace o2::framework::expressions; |
| 24 | + |
| 25 | +float fReal_fTPCSignalN(float mbb0R, float a1pt, float atgl, float side, float occ, float fOccTPCN, float fTrackOccMeanN) |
| 26 | +{ |
| 27 | + return ((0.019869f * mbb0R) + (0.0012031f * a1pt) + (-0.0031766f * atgl) + (-0.0058023f * atgl * mbb0R) + (0.00087494f * a1pt * mbb0R) + (0.0020074f * side) + (-0.0010434f * a1pt * a1pt) + (0.011812f)) * occ / 1.e3f + // |
| 28 | + ((0.009032f * mbb0R) + (0.0011737f * a1pt) + (-0.0010241f * atgl) + (-0.0075789f * atgl * mbb0R) + (0.00029324f * a1pt * mbb0R) + (0.00052475f * side) + (-0.00045413f * a1pt * a1pt) + (0.0024879f)) * fOccTPCN + // |
| 29 | + ((0.004255f * mbb0R) + (0.0011954f * a1pt) + (0.0054092f * atgl) + (-0.0033655f * atgl * mbb0R) + (0.00052243f * a1pt * mbb0R) + (-0.0002969f * side) + (-0.00074909f * a1pt * a1pt) + (-0.0075754f)) * fTrackOccMeanN + // |
| 30 | + ((-0.07925f * mbb0R) + (-0.03737f * a1pt) + (0.0017054f * atgl) + (0.093686f * atgl * mbb0R) + (0.023925f * a1pt * mbb0R) + (-0.0083407f * side) + (0.00336f * a1pt * a1pt) + (1.0461f)); |
| 31 | +}; |
| 32 | + |
| 33 | +float clamp(float value, float lo, float hi) |
| 34 | +{ |
| 35 | + return value < lo ? lo : (value > hi ? hi : value); |
| 36 | +} |
| 37 | + |
| 38 | +struct LeftJoin { |
| 39 | + Produces<aod::TracksTemporaryExtra> interm; |
| 40 | + Service<o2::ccdb::BasicCCDBManager> ccdb; |
| 41 | + ctpRateFetcher fetcher; |
| 42 | + |
| 43 | + Preslice<aod::Tracks> perColl = aod::track::collisionId; |
| 44 | + |
| 45 | + using BCs = soa::Join<aod::BCs, aod::Timestamps>; |
| 46 | + using Collisions = soa::Join<aod::Collisions, aod::Mults, aod::EvSels>; |
| 47 | + using Tracks = soa::Join<aod::Tracks, aod::TracksExtra>; |
| 48 | + |
| 49 | + int runNumber{0}; |
| 50 | + int colId{-100}; |
| 51 | + int bcId{-100}; |
| 52 | + int trkId{-100}; |
| 53 | + Collisions::iterator col; |
| 54 | + BCs::iterator bc; |
| 55 | + Tracks::iterator track; |
| 56 | + |
| 57 | + void process(BCs const& bcs, Collisions const& collisions, Tracks const& tracks, aod::TracksQAVersion const& tracksQA) |
| 58 | + { |
| 59 | + interm.reserve(tracksQA.size()); |
| 60 | + col = collisions.begin(); |
| 61 | + bc = bcs.begin(); |
| 62 | + runNumber = bc.runNumber(); |
| 63 | + track = tracks.begin(); |
| 64 | + for (auto& trackqa : tracksQA) { |
| 65 | + if (!trackqa.has_track()) { |
| 66 | + interm(0, 0, 0, 0, 0, o2::constants::math::Almost0, 0); |
| 67 | + continue; |
| 68 | + } |
| 69 | + if (trackqa.trackId() != trkId) { |
| 70 | + track.setCursor(trackqa.trackId()); |
| 71 | + } |
| 72 | + if (!track.has_collision()) { |
| 73 | + interm(0, 0, 0, 0, 0, o2::constants::math::Almost0, 0); |
| 74 | + continue; |
| 75 | + } |
| 76 | + if (track.collisionId() != colId) { |
| 77 | + colId = track.collisionId(); |
| 78 | + col.setCursor(colId); |
| 79 | + } |
| 80 | + if (!col.has_foundBC()) { |
| 81 | + interm(0, 0, 0, 0, 0, o2::constants::math::Almost0, 0); |
| 82 | + continue; |
| 83 | + } |
| 84 | + if (col.foundBCId() != bcId) { |
| 85 | + bc.setCursor(col.foundBCId()); |
| 86 | + if (bc.runNumber() != runNumber) { |
| 87 | + runNumber = bc.runNumber(); |
| 88 | + } |
| 89 | + } |
| 90 | + float rate = fetcher.fetch(ccdb.service, bc.timestamp(), runNumber, "ZNC hadronic") * 1.e-3; |
| 91 | + float occ = col.trackOccupancyInTimeRange(); |
| 92 | + float fOccTPCN = clamp(col.multTPC() / 1100.f, 0.f, 12.f); |
| 93 | + interm(rate, fOccTPCN, occ, fReal_fTPCSignalN(clamp(50.f / track.tpcSignal(), 0.05f, 1.05f), std::abs(track.signed1Pt()), std::abs(track.tgl()), track.tgl() > 0 ? 1.f : 0.f, occ, fOccTPCN, rate / 5.f), track.tpcSignal(), track.signed1Pt(), track.tgl()); |
| 94 | + } |
| 95 | + } |
| 96 | +}; |
| 97 | + |
| 98 | +struct ProduceExpressionCalib { |
| 99 | + Defines<aod::TracksQACorrectedE> tpcextra; |
| 100 | + |
| 101 | + void init(InitContext&) { |
| 102 | + tpcextra.projectors[0] = ifnode(aod::track::tpcSignal < o2::constants::math::Almost0, |
| 103 | + LiteralNode{0.f}, |
| 104 | + aod::track::tpcSignal / ( |
| 105 | + ((0.019869f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0012031f * nabs(aod::track::signed1Pt)) + (-0.0031766f * nabs(aod::track::tgl)) + (-0.0058023f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00087494f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0020074f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (-0.0010434f * aod::track::signed1Pt * aod::track::signed1Pt) + (0.011812f)) * aod::intermediate::occupancy / 1.e3f + // |
| 106 | + ((0.009032f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0011737f * nabs(aod::track::signed1Pt)) + (-0.0010241f * nabs(aod::track::tgl)) + (-0.0075789f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00029324f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00052475f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (-0.00045413f * aod::track::signed1Pt * aod::track::signed1Pt) + (0.0024879f)) * aod::intermediate::clampedTPCmult + // |
| 107 | + ((0.004255f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.0011954f * nabs(aod::track::signed1Pt)) + (0.0054092f * nabs(aod::track::tgl)) + (-0.0033655f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.00052243f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (-0.0002969f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (-0.00074909f * aod::track::signed1Pt * aod::track::signed1Pt) + (-0.0075754f)) * aod::intermediate::hRate / 5.f + // |
| 108 | + ((-0.07925f * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (-0.03737f * nabs(aod::track::signed1Pt)) + (0.0017054f * nabs(aod::track::tgl)) + (0.093686f * nabs(aod::track::tgl) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (0.023925f * nabs(aod::track::signed1Pt) * expressions::clamp(aod::intermediate::correction0 * 50.f / protect0(aod::track::tpcSignal), 0.05f, 1.05f)) + (-0.0083407f * ifnode(aod::track::tgl > 0.f, 1.f, 0.f)) + (0.00336f * aod::track::signed1Pt * aod::track::signed1Pt) + (1.0461f))// |
| 109 | + )); |
| 110 | + } |
| 111 | +}; |
| 112 | + |
| 113 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 114 | +{ |
| 115 | + return {adaptAnalysisTask<LeftJoin>(cfgc), adaptAnalysisTask<ProduceExpressionCalib>(cfgc)}; |
| 116 | +} |
0 commit comments