Plotting of Nch vs Average pT

Dear Experts
Published_nch_avg_pt

I am trying to Plot the Average pT vs Multiplicity using Pythia Monash
at 13 TeV but my plot is different from the one which is Published (Top Figure)
(Both are attached here). My Code is as follows: Please suggest if
something is wrong in the code.

TH1F pTvsNchg(“hMeanPtVsNchg”, “Mean p_{T} vs Number of charged
particles; N_{chg}; <p_{T}>”, 80, 0, 80);

// Event loop
for (int iEvent = 0; iEvent < nEvents; ++iEvent) {
    // Generate event
    if (!pythia.next()) continue;

    // Calculate quantities
    int nch = 0;
    double pTsum = 0.;

    for (int i = 0; i < pythia.event.size(); ++i) {
        Particle& particle = pythia.event[i];

        // Fill histograms for charged particles
        if (particle.isFinal() && particle.isCharged()) {
            ++nch;
            pTsum += particle.pT();
        }
    }

    // Fill histogram: <pT> vs Nchg
    if (nch > 0) {
        pTvsNchg.Fill(nch, pTsum / nch);
    }
}

Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi,

I believe you cannot do what you want using a simple TH1F. You need a TProfile for that.