Skip to content
Merged
Changes from all 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
86 changes: 82 additions & 4 deletions PWGCF/EbyEFluctuations/Tasks/MeanptFluctuations.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "Framework/runDataProcessing.h"
#include <CCDB/BasicCCDBManager.h>

#include "TDatabasePDG.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

#include <TDirectory.h>
#include <TF1.h>
#include <TFile.h>
Expand Down Expand Up @@ -149,6 +150,8 @@ struct MeanptFluctuationsAnalysis {
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
std::vector<std::vector<std::shared_ptr<TProfile2D>>> subSampleMcGen;
std::vector<std::vector<std::shared_ptr<TProfile2D>>> subSample;
std::vector<std::vector<std::shared_ptr<TProfile>>> subSampleMcGenV2;
std::vector<std::vector<std::shared_ptr<TProfile2D>>> subSampleV2;
TRandom3* fRndm = new TRandom3(0);

// filtering collisions and tracks***********
Expand All @@ -161,6 +164,7 @@ struct MeanptFluctuationsAnalysis {
using EventCandidatesMC = soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels, aod::CentFT0Cs, aod::CentFT0Ms, aod::CentFT0As, aod::CentFV0As, aod::Mults>;

Preslice<MyMCTracks> perCollision = aod::track::collisionId;
Preslice<aod::McParticles> perMcCollision = aod::mcparticle::mcCollisionId;

// Event selection cuts - Alex
TF1* fMultPVCutLow = nullptr;
Expand Down Expand Up @@ -246,6 +250,7 @@ struct MeanptFluctuationsAnalysis {
histos.add("MCGenerated/hPtParticleVsTrack", "", kTH2F, {ptAxis, ptAxis});
histos.add("MCGenerated/hEtaParticleVsTrack", "", kTH2F, {{100, -2.01, 2.01}, {100, -2.01, 2.01}});
histos.add("MCGenerated/hPhiParticleVsTrack", "", kTH2F, {{100, 0., o2::constants::math::TwoPI}, {100, 0., o2::constants::math::TwoPI}});
histos.add("MCGenerated/hNgenVsNrec", "Gen multiplicity vs. Rec multiplicity in MC", kTH2F, {multAxis, multAxis});

// Analysis Profiles for central val
histos.add("MCGenerated/AnalysisProfiles/Prof_mean_t1", "", {HistType::kTProfile2D, {centAxis, multAxis}});
Expand All @@ -255,16 +260,39 @@ struct MeanptFluctuationsAnalysis {
histos.add("MCGenerated/AnalysisProfiles/Hist2D_Nch_centrality", "", {HistType::kTH2D, {centAxis, multAxis}});
histos.add("MCGenerated/AnalysisProfiles/Hist2D_meanpt_centrality", "", {HistType::kTH2D, {centAxis, meanpTAxis}});

histos.add("MCGenerated/AnalysisProfilesV2/Prof_mean_t1", "", {HistType::kTProfile, {multAxis}});
histos.add("MCGenerated/AnalysisProfilesV2/Prof_var_t1", "", {HistType::kTProfile, {multAxis}});
histos.add("MCGenerated/AnalysisProfilesV2/Prof_skew_t1", "", {HistType::kTProfile, {multAxis}});
histos.add("MCGenerated/AnalysisProfilesV2/Prof_kurt_t1", "", {HistType::kTProfile, {multAxis}});
histos.add("AnalysisProfilesV2/Prof_mean_t1", "", {HistType::kTProfile2D, {multAxis, multAxis}});
histos.add("AnalysisProfilesV2/Prof_var_t1", "", {HistType::kTProfile2D, {multAxis, multAxis}});
histos.add("AnalysisProfilesV2/Prof_skew_t1", "", {HistType::kTProfile2D, {multAxis, multAxis}});
histos.add("AnalysisProfilesV2/Prof_kurt_t1", "", {HistType::kTProfile2D, {multAxis, multAxis}});

// Analysis Profiles for error
subSampleMcGen.resize(cfgNsubSample);
subSampleMcGenV2.resize(cfgNsubSample);
subSampleV2.resize(cfgNsubSample);
for (int i = 0; i < cfgNsubSample; i++) {
subSampleMcGen[i].resize(4);
subSampleMcGenV2[i].resize(4);
subSampleV2[i].resize(4);
}
for (int i = 0; i < cfgNsubSample; i++) {
subSampleMcGen[i][0] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("MCGenerated/AnalysisProfiles/subSample_%d/Prof_mean_t1", i), "", {HistType::kTProfile2D, {centAxis, multAxis}}));
subSampleMcGen[i][1] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("MCGenerated/AnalysisProfiles/subSample_%d/Prof_var_t1", i), "", {HistType::kTProfile2D, {centAxis, multAxis}}));
subSampleMcGen[i][2] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("MCGenerated/AnalysisProfiles/subSample_%d/Prof_skew_t1", i), "", {HistType::kTProfile2D, {centAxis, multAxis}}));
subSampleMcGen[i][3] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("MCGenerated/AnalysisProfiles/subSample_%d/Prof_kurt_t1", i), "", {HistType::kTProfile2D, {centAxis, multAxis}}));

subSampleMcGenV2[i][0] = std::get<std::shared_ptr<TProfile>>(histos.add(Form("MCGenerated/AnalysisProfilesV2/subSample_%d/Prof_mean_t1", i), "", {HistType::kTProfile, {multAxis}}));
subSampleMcGenV2[i][1] = std::get<std::shared_ptr<TProfile>>(histos.add(Form("MCGenerated/AnalysisProfilesV2/subSample_%d/Prof_var_t1", i), "", {HistType::kTProfile, {multAxis}}));
subSampleMcGenV2[i][2] = std::get<std::shared_ptr<TProfile>>(histos.add(Form("MCGenerated/AnalysisProfilesV2/subSample_%d/Prof_skew_t1", i), "", {HistType::kTProfile, {multAxis}}));
subSampleMcGenV2[i][3] = std::get<std::shared_ptr<TProfile>>(histos.add(Form("MCGenerated/AnalysisProfilesV2/subSample_%d/Prof_kurt_t1", i), "", {HistType::kTProfile, {multAxis}}));

subSampleV2[i][0] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("AnalysisProfilesV2/subSample_%d/Prof_mean_t1", i), "", {HistType::kTProfile2D, {multAxis, multAxis}}));
subSampleV2[i][1] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("AnalysisProfilesV2/subSample_%d/Prof_var_t1", i), "", {HistType::kTProfile2D, {multAxis, multAxis}}));
subSampleV2[i][2] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("AnalysisProfilesV2/subSample_%d/Prof_skew_t1", i), "", {HistType::kTProfile2D, {multAxis, multAxis}}));
subSampleV2[i][3] = std::get<std::shared_ptr<TProfile2D>>(histos.add(Form("AnalysisProfilesV2/subSample_%d/Prof_kurt_t1", i), "", {HistType::kTProfile2D, {multAxis, multAxis}}));
}
}

Expand Down Expand Up @@ -530,9 +558,11 @@ struct MeanptFluctuationsAnalysis {
if (!mcParticle.has_mcCollision())
continue;

int pdgCode = std::abs(mcParticle.pdgCode());
bool extraPDGType = (pdgCode != PDG_t::kK0Short && pdgCode != PDG_t::kLambda0);
if (extraPDGType && pdgCode != PDG_t::kElectron && pdgCode != PDG_t::kMuonMinus && pdgCode != PDG_t::kPiPlus && pdgCode != kKPlus && pdgCode != PDG_t::kProton)
// charged check
auto pdgEntry = TDatabasePDG::Instance()->GetParticle(mcParticle.pdgCode());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use TDatabasePDG directly. Use Service<o2::framework::O2DatabasePDG> instead.

if (!pdgEntry)
continue;
if (pdgEntry->Charge() == 0)
continue;

if (mcParticle.isPhysicalPrimary()) {
Expand Down Expand Up @@ -575,19 +605,29 @@ struct MeanptFluctuationsAnalysis {
histos.fill(HIST("MCGenerated/AnalysisProfiles/Hist2D_Nch_centrality"), cent, nChgen);
histos.fill(HIST("MCGenerated/AnalysisProfiles/Hist2D_meanpt_centrality"), cent, meanTerm1gen);

histos.get<TProfile>(HIST("MCGenerated/AnalysisProfilesV2/Prof_mean_t1"))->Fill(nChgen, meanTerm1gen);
histos.get<TProfile>(HIST("MCGenerated/AnalysisProfilesV2/Prof_var_t1"))->Fill(nChgen, varianceTerm1gen);
histos.get<TProfile>(HIST("MCGenerated/AnalysisProfilesV2/Prof_skew_t1"))->Fill(nChgen, skewnessTerm1gen);
histos.get<TProfile>(HIST("MCGenerated/AnalysisProfilesV2/Prof_kurt_t1"))->Fill(nChgen, kurtosisTerm1gen);

// selecting subsample and filling profiles
float lRandomMc = fRndm->Rndm();
int sampleIndexMc = static_cast<int>(cfgNsubSample * lRandomMc);
subSampleMcGen[sampleIndexMc][0]->Fill(cent, nChgen, meanTerm1gen);
subSampleMcGen[sampleIndexMc][1]->Fill(cent, nChgen, varianceTerm1gen);
subSampleMcGen[sampleIndexMc][2]->Fill(cent, nChgen, skewnessTerm1gen);
subSampleMcGen[sampleIndexMc][3]->Fill(cent, nChgen, kurtosisTerm1gen);

subSampleMcGenV2[sampleIndexMc][0]->Fill(nChgen, meanTerm1gen);
subSampleMcGenV2[sampleIndexMc][1]->Fill(nChgen, varianceTerm1gen);
subSampleMcGenV2[sampleIndexMc][2]->Fill(nChgen, skewnessTerm1gen);
subSampleMcGenV2[sampleIndexMc][3]->Fill(nChgen, kurtosisTerm1gen);
}
//-------------------------------------------------------------------------------------------
}
PROCESS_SWITCH(MeanptFluctuationsAnalysis, processMCGen, "Process Generated MC data", true);

void processMCRec(MyMCRecCollisions::iterator const& collision, MyMCTracks const& tracks, aod::McCollisions const&, aod::McParticles const&)
void processMCRec(MyMCRecCollisions::iterator const& collision, MyMCTracks const& tracks, aod::McCollisions const&, aod::McParticles const& mcParticles)
{
histos.fill(HIST("MCGenerated/hMC"), 5.5);

Expand Down Expand Up @@ -635,6 +675,32 @@ struct MeanptFluctuationsAnalysis {
histos.fill(HIST("Hist2D_globalTracks_PVTracks"), collision.multNTracksPV(), tracks.size());
histos.fill(HIST("Hist2D_cent_nch"), tracks.size(), centralityFT0C);

// Calculating generated no of particles for the collision event
double noGen = 0.0;
auto mcColl = collision.mcCollision();
// Slice particles belonging only to this MC collision
auto particlesThisEvent = mcParticles.sliceBy(perMcCollision, mcColl.globalIndex());

for (const auto& mcParticle : particlesThisEvent) {
if (!mcParticle.has_mcCollision())
continue;

// charged check
auto pdgEntry = TDatabasePDG::Instance()->GetParticle(mcParticle.pdgCode());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

if (!pdgEntry)
continue;
if (pdgEntry->Charge() == 0)
continue;

if (mcParticle.isPhysicalPrimary()) {
if ((mcParticle.pt() > cfgCutPtLower) && (mcParticle.pt() < cfgCutPreSelPt) && (std::abs(mcParticle.eta()) < cfgCutPreSelEta)) {
if (mcParticle.pt() > cfgCutPtLower && mcParticle.pt() < cfgCutPtUpper) {
noGen = noGen + 1.0;
}
}
}
} //! end particle loop

// variables
double pTsum = 0.0;
double nN = 0.0;
Expand Down Expand Up @@ -706,6 +772,8 @@ struct MeanptFluctuationsAnalysis {
}
} // end track loop

histos.fill(HIST("MCGenerated/hNgenVsNrec"), noGen, nCh);

// MeanPt
if (nN > 0.0f)
histos.fill(HIST("hMeanPt"), cent, pTsum / nN);
Expand All @@ -725,13 +793,23 @@ struct MeanptFluctuationsAnalysis {
histos.fill(HIST("AnalysisProfiles/Hist2D_Nch_centrality"), cent, nCh);
histos.fill(HIST("AnalysisProfiles/Hist2D_meanpt_centrality"), cent, meanTerm1);

histos.get<TProfile2D>(HIST("AnalysisProfilesV2/Prof_mean_t1"))->Fill(noGen, nCh, meanTerm1);
histos.get<TProfile2D>(HIST("AnalysisProfilesV2/Prof_var_t1"))->Fill(noGen, nCh, varianceTerm1);
histos.get<TProfile2D>(HIST("AnalysisProfilesV2/Prof_skew_t1"))->Fill(noGen, nCh, skewnessTerm1);
histos.get<TProfile2D>(HIST("AnalysisProfilesV2/Prof_kurt_t1"))->Fill(noGen, nCh, kurtosisTerm1);

// selecting subsample and filling profiles
float lRandom = fRndm->Rndm();
int sampleIndex = static_cast<int>(cfgNsubSample * lRandom);
subSample[sampleIndex][0]->Fill(cent, nCh, meanTerm1);
subSample[sampleIndex][1]->Fill(cent, nCh, varianceTerm1);
subSample[sampleIndex][2]->Fill(cent, nCh, skewnessTerm1);
subSample[sampleIndex][3]->Fill(cent, nCh, kurtosisTerm1);

subSampleV2[sampleIndex][0]->Fill(noGen, nCh, meanTerm1);
subSampleV2[sampleIndex][1]->Fill(noGen, nCh, varianceTerm1);
subSampleV2[sampleIndex][2]->Fill(noGen, nCh, skewnessTerm1);
subSampleV2[sampleIndex][3]->Fill(noGen, nCh, kurtosisTerm1);
}
//-------------------------------------------------------------------------------------------
}
Expand Down
Loading