Skip to content

Commit 8f7ad1f

Browse files
committed
Add the possibility to apply pT-dependent downsampling
1 parent d173470 commit 8f7ad1f

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

DPG/Tasks/AOTTrack/derivedDataCreatorD0Calibration.cxx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
#include <map>
2121
#include <string>
2222

23+
#include <TH1D.h>
24+
#include <TRandom3.h>
25+
2326
#include "CommonConstants/PhysicsConstants.h"
2427
#include "DCAFitter/DCAFitterN.h"
2528
#include "Framework/AnalysisTask.h"
26-
#include "Framework/HistogramRegistry.h"
2729
#include "Framework/runDataProcessing.h"
2830
#include "Framework/RunningWorkflowInfo.h"
2931
#include "ReconstructionDataFormats/DCA.h"
@@ -81,6 +83,11 @@ struct DerivedDataCreatorD0Calibration {
8183
std::string prefix = "candidateCuts";
8284
} cfgCandCuts;
8385

86+
struct : ConfigurableGroup {
87+
Configurable<bool> apply{"apply", false, "flag to apply downsampling"};
88+
Configurable<std::string> pathCcdbWeights{"pathCcdbWeights", "", "CCDB path containing pT-differential weights"};
89+
} cfgDownsampling;
90+
8491
using TracksWCovExtraPid = soa::Join<aod::Tracks, aod::TracksCov, aod::TracksExtra, aod::TrackSelection, aod::pidTPCFullPi, aod::pidTOFFullPi, aod::pidTPCFullKa, aod::pidTOFFullKa>;
8592
using CollisionsWEvSel = soa::Join<aod::Collisions, aod::CentFT0Cs, aod::EvSels>;
8693

@@ -99,8 +106,19 @@ struct DerivedDataCreatorD0Calibration {
99106
const float ptTolerance{0.1f};
100107
const float invMassTolerance{0.05f};
101108

109+
OutputObj<TH1D> histDownSampl{"histDownSampl"};
110+
102111
void init(InitContext const&)
103112
{
113+
// First we set the CCDB manager
114+
ccdb->setURL("http://alice-ccdb.cern.ch");
115+
ccdb->setCaching(true);
116+
ccdb->setLocalObjectValidityChecking();
117+
118+
if (cfgDownsampling.apply) {
119+
histDownSampl.setObject(reinterpret_cast<TH1D*>(ccdb->getSpecific<TH1D>(cfgDownsampling.pathCcdbWeights)));
120+
}
121+
104122
df.setPropagateToPCA(true);
105123
df.setMaxR(200.f);
106124
df.setMaxDZIni(4.f);
@@ -292,6 +310,23 @@ struct DerivedDataCreatorD0Calibration {
292310
if (ptBinD0 < 0) {
293311
continue;
294312
}
313+
314+
// random downsampling already here
315+
if (cfgDownsampling.apply) {
316+
int ptBinWeights{0};
317+
if (ptD0 < histDownSampl->GetBinLowEdge(1)) {
318+
ptBinWeights = 1;
319+
} else if (ptD0 > histDownSampl->GetXaxis()->GetBinUpEdge(histDownSampl->GetNbinsX())) {
320+
ptBinWeights = histDownSampl->GetNbinsX();
321+
} else {
322+
ptBinWeights = histDownSampl->GetXaxis()->FindBin(ptD0);
323+
}
324+
float weight = histDownSampl->GetBinContent(ptBinWeights);
325+
if (gRandom->Rndm() > weight) {
326+
continue;
327+
}
328+
}
329+
295330
// d0xd0
296331
if (dcaPos.getY() * dcaNeg.getY() > cfgCandCuts.topologicalCuts->get(ptBinD0, "max d0d0")) {
297332
continue;

0 commit comments

Comments
 (0)