Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion PWGLF/DataModel/mcCentrality.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in PWGLF/DataModel/mcCentrality.h

View workflow job for this annotation

GitHub Actions / O2 linter

[name/file-cpp]

Use lowerCamelCase or UpperCamelCase for names of C++ files. See the O2 naming conventions for details.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand All @@ -21,9 +21,10 @@
#define PWGLF_DATAMODEL_MCCENTRALITY_H_

// O2 includes
#include "Common/DataModel/Centrality.h"

#include "Framework/ASoA.h"
#include "Framework/AnalysisDataModel.h"
#include "Common/DataModel/Centrality.h"
#include "Framework/Logger.h"

namespace o2::aod
Expand Down
103 changes: 66 additions & 37 deletions PWGLF/TableProducer/Common/mcCentrality.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,35 @@
/// \brief Task to produce the table for the equalized multiplicity into centrality bins
///

// O2 includes
#include "CCDB/BasicCCDBManager.h"
#include "ReconstructionDataFormats/Track.h"
#include "CCDB/CcdbApi.h"
#include "Common/DataModel/TrackSelectionTables.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/runDataProcessing.h"
#include "Framework/HistogramRegistry.h"
#include "Framework/RunningWorkflowInfo.h"
#include "Framework/StaticFor.h"
#include "PWGLF/DataModel/McCentrality.h"

#include "TableHelper.h"
#include "Framework/O2DatabasePDGPlugin.h"
#include "Common/DataModel/Centrality.h"
#include "PWGLF/DataModel/mcCentrality.h"

#include "PWGLF/Utils/inelGt.h"

#include "Common/DataModel/Centrality.h"
#include "Common/DataModel/TrackSelectionTables.h"

#include <CCDB/BasicCCDBManager.h>
#include <CCDB/CcdbApi.h>
#include <Framework/AnalysisDataModel.h>
#include <Framework/AnalysisTask.h>
#include <Framework/HistogramRegistry.h>
#include <Framework/O2DatabasePDGPlugin.h>
#include <Framework/RunningWorkflowInfo.h>
#include <Framework/StaticFor.h>
#include <Framework/runDataProcessing.h>
#include <ReconstructionDataFormats/Track.h>

#include <string>

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using namespace o2::track;

/// Task to produce the response table
struct mcCentrality {
struct McCentrality {

// Tables to produce
Produces<aod::McCentFV0As> centFV0A;
Expand All @@ -52,27 +57,30 @@ struct mcCentrality {

// Input parameters
Service<o2::ccdb::BasicCCDBManager> ccdb;
Configurable<std::string> url{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Configurable<int64_t> ccdbTimestamp{"ccdb-timestamp", -1, "timestamp of the object used to query in CCDB the detector response. If 0 the object corresponding to the run number is used, if < 0 the latest object is used"};
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
Configurable<int64_t> ccdbTimestamp{"ccdbTimestamp", -1, "timestamp of the object used to query in CCDB the detector response. If 0 the object corresponding to the run number is used, if < 0 the latest object is used"};
Configurable<std::string> path{"path", "/tmp/InputCalibMC.root", "path to calib file or ccdb path if begins with ccdb://"};
Configurable<bool> selectPrimaries{"selectPrimaries", true, "Select only primary particles"};
Service<o2::framework::O2DatabasePDG> pdgDB;
ConfigurableAxis binsPercentile{"binsPercentile", {VARIABLE_WIDTH, 0, 0.001, 0.01, 1.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}, "Binning of the percentile axis"};
ConfigurableAxis binsMultiplicity{"binsMultiplicity", {1000, 0, 5000}, "Binning of the multiplicity axis"};
Configurable<bool> fillFt0A{"fillFt0A", false, "Fills the FT0A histogram"};
Configurable<bool> fillFt0C{"fillFt0C", false, "Fills the FT0C histogram"};

HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};

TH1F* h1dFT0M;
/*TH1F* h1dFT0A;
TH1F* h1dFT0A;
TH1F* h1dFT0C;
TH1F* h1dFDD;
TH1F* h1dNTP;*/
// TH1F* h1dFDD;
// TH1F* h1dNTP;

o2::pwglf::ParticleCounter<o2::framework::O2DatabasePDG> mCounter;

void init(o2::framework::InitContext& /*initContext*/)
{
// Set up the CCDB
ccdb->setURL(url.value);
ccdb->setURL(ccdbUrl.value);
ccdb->setCaching(true);
ccdb->setLocalObjectValidityChecking();
ccdb->setCreatedNotAfter(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count());
Expand All @@ -81,7 +89,15 @@ struct mcCentrality {
mCounter.mPdgDatabase = pdgDB.service;
mCounter.mSelectPrimaries = selectPrimaries.value;
histos.add("FT0M/percentile", "FT0M percentile.", HistType::kTH1D, {{binsPercentile, "FT0M percentile"}});
histos.add("FT0M/percentilevsMult", "FT0M percentile.", HistType::kTH2D, {{binsPercentile, "FT0M percentile"}, {1000, 0, 5000, "FT0M mult."}});
histos.add("FT0M/percentilevsMult", "FT0M percentile.", HistType::kTH2D, {{binsPercentile, "FT0M percentile"}, {binsMultiplicity, "FT0M mult."}});
if (fillFt0A) {
histos.add("FT0A/percentile", "FT0A percentile.", HistType::kTH1D, {{binsPercentile, "FT0A percentile"}});
histos.add("FT0A/percentilevsMult", "FT0A percentile.", HistType::kTH2D, {{binsPercentile, "FT0A percentile"}, {binsMultiplicity, "FT0A mult."}});
}
if (fillFt0C) {
histos.add("FT0C/percentile", "FT0C percentile.", HistType::kTH1D, {{binsPercentile, "FT0C percentile"}});
histos.add("FT0C/percentilevsMult", "FT0C percentile.", HistType::kTH2D, {{binsPercentile, "FT0C percentile"}, {binsMultiplicity, "FT0C mult."}});
}

TList* lOfInput;
if (path.value.rfind("ccdb://", 0) == 0) { // Getting post calib. from CCDB
Expand All @@ -105,35 +121,48 @@ struct mcCentrality {
LOG(fatal) << "The input file " << path.value << " does not contain the TList ccdb_object";
}
}
h1dFT0M = static_cast<TH1F*>(lOfInput->FindObject("h1dFT0M"));
if (!h1dFT0M) {
lOfInput->ls();
LOG(fatal) << "Could not open histogram h1dFT0M from TList";
return;
auto getHist = [lOfInput](const char* name) -> TH1F* {
auto hist = static_cast<TH1F*>(lOfInput->FindObject(name));
if (!hist) {
lOfInput->ls();
LOG(fatal) << "Could not open histogram " << name << " from TList";
}
return hist;
};
h1dFT0M = getHist("h1dFT0M");
if (fillFt0A) {
h1dFT0A = getHist("h1dFT0A");
}
if (fillFt0C) {
h1dFT0C = getHist("h1dFT0C");
}
}

// Full tables (independent on central calibrations)
void process(aod::McCollision const& /*mcCollision*/,
aod::McParticles const& mcParticles)
{
const float nFT0M = mCounter.countFT0A(mcParticles) + mCounter.countFT0C(mcParticles);
/*const float nFT0A = mCounter.countFT0A(mcParticles);
const float nFT0A = mCounter.countFT0A(mcParticles);
const float nFT0C = mCounter.countFT0C(mcParticles);
const float nFV0A = mCounter.countFV0A(mcParticles);*/
const float nFT0M = nFT0A + nFT0C;
// const float nFV0A = mCounter.countFV0A(mcParticles);

const float valueCentFT0M = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0M));
/*const float valueCentFT0A = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0A));
const float valueCentFT0C = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0C));
const float valueCentFV0A = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFV0A));*/
if (fillFt0A) {
const float valueCentFT0A = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0A));
centFT0A(valueCentFT0A);
}
if (fillFt0C) {
const float valueCentFT0C = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFT0C));
centFT0C(valueCentFT0C);
}
// const float valueCentFV0A = h1dFT0M->GetBinContent(h1dFT0M->FindBin(nFV0A));

centFT0M(valueCentFT0M);
/*centFT0A(valueCentFT0A);
centFT0C(valueCentFT0C);
centFV0A(valueCentFV0A);*/
// centFV0A(valueCentFV0A);
histos.fill(HIST("FT0M/percentile"), valueCentFT0M);
histos.fill(HIST("FT0M/percentilevsMult"), valueCentFT0M, nFT0M);
}
};

WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<mcCentrality>(cfgc)}; }
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask<McCentrality>(cfgc)}; }
Loading