|
| 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 | +// |
| 13 | +// Task to add a table of track parameters propagated to the primary vertex |
| 14 | +// |
| 15 | + |
| 16 | +#include "Framework/AnalysisDataModel.h" |
| 17 | +#include "Framework/AnalysisTask.h" |
| 18 | +#include "Framework/runDataProcessing.h" |
| 19 | +#include "Framework/RunningWorkflowInfo.h" |
| 20 | +#include "Common/Core/TrackSelection.h" |
| 21 | +#include "Common/DataModel/TrackSelectionTables.h" |
| 22 | +#include "Common/DataModel/TrackPropagation.h" |
| 23 | +#include "Common/Core/trackUtilities.h" |
| 24 | +#include "ReconstructionDataFormats/DCA.h" |
| 25 | +#include "DetectorsBase/Propagator.h" |
| 26 | +#include "DetectorsBase/GeometryManager.h" |
| 27 | +#include "DetectorsCommonDataFormats/NameConf.h" |
| 28 | +#include "CCDB/CcdbApi.h" |
| 29 | +#include "DataFormatsParameters/GRPObject.h" |
| 30 | +#include "CCDB/BasicCCDBManager.h" |
| 31 | +#include "Framework/HistogramRegistry.h" |
| 32 | +#include "Framework/runDataProcessing.h" |
| 33 | +#include "DataFormatsCalibration/MeanVertexObject.h" |
| 34 | + |
| 35 | +using namespace o2; |
| 36 | +using namespace o2::framework; |
| 37 | +using namespace o2::framework::expressions; |
| 38 | + |
| 39 | +namespace o2 |
| 40 | +{ |
| 41 | +namespace analysis |
| 42 | +{ |
| 43 | +namespace trackpropagation |
| 44 | +{ |
| 45 | +constexpr long run3lut_timestamp = (1665695116725 + 1634159124442) / 2; |
| 46 | +constexpr long run3grp_timestamp = (1619781650000 + 1619781529000) / 2; |
| 47 | + |
| 48 | +} // namespace trackpropagation |
| 49 | +} // namespace analysis |
| 50 | +} // namespace o2 |
| 51 | + |
| 52 | +struct TrackPropagation { |
| 53 | + |
| 54 | + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject, true, true}; |
| 55 | + |
| 56 | + Produces<aod::tracksPropagated> tracksPropagated; |
| 57 | + Produces<aod::tracksParPropagated> tracksParPropagated; |
| 58 | + Produces<aod::TracksExtended> tracksExtended; |
| 59 | + |
| 60 | + Service<o2::ccdb::BasicCCDBManager> ccdb; |
| 61 | + |
| 62 | + bool fillTracksPropagated = false; |
| 63 | + bool fillTracksParPropagated = false; |
| 64 | + bool fillTracksExtended = false; |
| 65 | + |
| 66 | + o2::base::Propagator::MatCorrType matCorr; |
| 67 | + |
| 68 | + const o2::dataformats::MeanVertexObject* mVtx; |
| 69 | + |
| 70 | + Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; |
| 71 | + Configurable<std::string> lutPath{"lutPath", "GLO/Param/MatLUT", "Path of the Lut parametrization"}; |
| 72 | + Configurable<std::string> geoPath{"geoPath", "GLO/Config/Geometry", "Path of the geometry file"}; |
| 73 | + Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; |
| 74 | + Configurable<std::string> mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; |
| 75 | + |
| 76 | + Configurable<bool> fillQAHists{"fillQAHists", false, "option to fill the QA histograms"}; |
| 77 | + Configurable<bool> isForceFillTracksPropagated{"isForceFillTracksPropagated", false, "option to fill the tracksPropagated table without workflow requirement"}; |
| 78 | + Configurable<bool> isForceFillTracksParPropagated{"isForceFillTracksParPropagated", false, "option to fill the tracksParPropagated table without workflow requirement"}; |
| 79 | + Configurable<bool> isForceFillTracksExtended{"isForceFillTracksExtended", false, "option to fill the tracksExtended tables without workflow requirement"}; |
| 80 | + |
| 81 | + void init(o2::framework::InitContext& initContext) |
| 82 | + { |
| 83 | + |
| 84 | + // Checking if the tables are requested in the workflow and enabling them |
| 85 | + auto& workflows = initContext.services().get<RunningWorkflowInfo const>(); |
| 86 | + for (DeviceSpec device : workflows.devices) { |
| 87 | + for (auto input : device.inputs) { |
| 88 | + const std::string tableTracksPropagated = "tracksPropagated"; |
| 89 | + if (input.matcher.binding == tableTracksPropagated) { |
| 90 | + fillTracksPropagated = true; |
| 91 | + } |
| 92 | + const std::string tableTracksParPropagated = "tracksParPropagated"; |
| 93 | + if (input.matcher.binding == tableTracksParPropagated) { |
| 94 | + fillTracksParPropagated = true; |
| 95 | + } |
| 96 | + const std::string tableTracksExtended = "TracksExtended"; |
| 97 | + if (input.matcher.binding == tableTracksExtended) { |
| 98 | + fillTracksExtended = true; |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + if (isForceFillTracksPropagated) { |
| 104 | + fillTracksPropagated = true; |
| 105 | + } |
| 106 | + if (isForceFillTracksParPropagated) { |
| 107 | + fillTracksParPropagated = true; |
| 108 | + } |
| 109 | + if (isForceFillTracksExtended) { |
| 110 | + fillTracksExtended = true; |
| 111 | + } |
| 112 | + |
| 113 | + if (fillQAHists) { |
| 114 | + registry.add("hpt", "track #it{p}_{T} (GeV/#it{c});not propagated; propagated to PV", {HistType::kTH2F, {{200, 0., 20.}, {200, 0., 20.}}}); |
| 115 | + registry.add("hphi", "track #phi; not propagated; propagated to PV", {HistType::kTH2F, {{140, -1., 8.}, {140, -1., 8.}}}); |
| 116 | + registry.add("heta", "track #eta; not propagated; propagated to PV", {HistType::kTH2F, {{200, -2., 2.}, {200, -2., 2.}}}); |
| 117 | + } |
| 118 | + |
| 119 | + ccdb->setURL(ccdburl); |
| 120 | + ccdb->setCaching(true); |
| 121 | + ccdb->setLocalObjectValidityChecking(); |
| 122 | + |
| 123 | + //auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->getForTimeStamp<o2::base::MatLayerCylSet>(lutPath, analysis::trackpropagation::run3lut_timestamp)); |
| 124 | + auto lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get<o2::base::MatLayerCylSet>(lutPath)); |
| 125 | + |
| 126 | + matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT; |
| 127 | + if (!o2::base::GeometryManager::isGeometryLoaded()) { |
| 128 | + ccdb->get<TGeoManager>(geoPath); |
| 129 | + o2::parameters::GRPObject* grpo = ccdb->getForTimeStamp<o2::parameters::GRPObject>(grpPath, analysis::trackpropagation::run3grp_timestamp); |
| 130 | + o2::base::Propagator::initFieldFromGRP(grpo); |
| 131 | + o2::base::Propagator::Instance()->setMatLUT(lut); |
| 132 | + } |
| 133 | + |
| 134 | + mVtx = ccdb->get<o2::dataformats::MeanVertexObject>(mVtxPath); |
| 135 | + } |
| 136 | + |
| 137 | + void process(aod::Tracks const& tracks, aod::Collisions const&) |
| 138 | + { |
| 139 | + |
| 140 | + gpu::gpustd::array<float, 2> dcaInfo; |
| 141 | + for (auto& track : tracks) { |
| 142 | + |
| 143 | + auto trackPar = getTrackPar(track); |
| 144 | + if (track.has_collision()) { |
| 145 | + auto const& collision = track.collision(); |
| 146 | + |
| 147 | + o2::base::Propagator::Instance()->propagateToDCABxByBz({collision.posX(), collision.posY(), collision.posZ()}, trackPar, 2.f, matCorr, &dcaInfo); |
| 148 | + if (fillTracksPropagated) { |
| 149 | + tracksPropagated(track.collisionId(), track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta()); |
| 150 | + } |
| 151 | + if (fillTracksParPropagated) { |
| 152 | + tracksParPropagated(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt()); |
| 153 | + } |
| 154 | + if (fillTracksExtended) { |
| 155 | + tracksExtended(dcaInfo[0], dcaInfo[1]); |
| 156 | + } |
| 157 | + |
| 158 | + if (fillQAHists) { |
| 159 | + registry.fill(HIST("hpt"), track.pt(), trackPar.getPt()); |
| 160 | + registry.fill(HIST("hphi"), track.phi(), trackPar.getPhi()); |
| 161 | + registry.fill(HIST("heta"), track.eta(), trackPar.getEta()); |
| 162 | + } |
| 163 | + } else { |
| 164 | + |
| 165 | + o2::base::Propagator::Instance()->propagateToDCABxByBz({mVtx->getX(), mVtx->getY(), mVtx->getZ()}, trackPar, 2.f, matCorr, &dcaInfo); //put mean collision information here |
| 166 | + |
| 167 | + if (fillTracksPropagated) { |
| 168 | + tracksPropagated(-1, track.trackType(), trackPar.getSign(), trackPar.getPt(), trackPar.getPhi(), trackPar.getEta()); |
| 169 | + } |
| 170 | + if (fillTracksParPropagated) { |
| 171 | + tracksParPropagated(trackPar.getX(), trackPar.getAlpha(), trackPar.getY(), trackPar.getZ(), trackPar.getSnp(), trackPar.getTgl(), trackPar.getQ2Pt()); |
| 172 | + } |
| 173 | + if (fillTracksExtended) { |
| 174 | + tracksExtended(dcaInfo[0], dcaInfo[1]); |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | +}; |
| 180 | + |
| 181 | +//**************************************************************************************** |
| 182 | +/** |
| 183 | + * Workflow definition. |
| 184 | + */ |
| 185 | +//**************************************************************************************** |
| 186 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 187 | +{ |
| 188 | + WorkflowSpec workflow{adaptAnalysisTask<TrackPropagation>(cfgc)}; |
| 189 | + return workflow; |
| 190 | +} |
0 commit comments