Number of electrons per event

Hi,
I have a sample of electrons(with no cuts). I want to generate a histogram with the number of electrons along X and number of events along Y axis. I am using xAOD for my analysis.
Under histInitialize(), I gave h_el_no= new TH1F(“nel”.“nel”,10,0,10)

Under execute() I have,
EL::StatusCode ZMassAnalysis :: execute ()
{
// Here you do everything that needs to be done on every single
// events, e.g. read input variables, apply cuts, and fill
// histograms and trees. This is where most of your actual analysis
// code will go.

ANA_CHECK_SET_TYPE (EL::StatusCode);

// run QuickAna for the current event:
ANA_CHECK (quickAna->process ());
unsigned el_num = 0;
for (auto electron : *quickAna->electrons())
{
// QuickAna marks good objects by setting ana_select
// ana::SelectType is the type QuickAna uses for boolean decorations
if (electron->auxdataana::SelectType (“ana_select”))
{
h_el_pt->Fill(electron->pt()*0.001);// this is to plot the histogram for transverse momentum
}
}
return EL::StatusCode::SUCCESS;
}

I am not sure how to fill the histogram with the number of events from the above for loop.

Thanks

I can only guess that you want to add h_el_no->Fill(quickAna->electrons->size());. I am not sure if this is the number of electrons, or even if this object has a member size().

EL::StatusCode ZMassAnalysis :: execute ()
{
  // Here you do everything that needs to be done on every single
  // events, e.g. read input variables, apply cuts, and fill
  // histograms and trees.  This is where most of your actual analysis
  // code will go.

  ANA_CHECK_SET_TYPE (EL::StatusCode);

  // run QuickAna for the current event:
  ANA_CHECK (quickAna->process ());
  unsigned el_num = 0;

  h_el_no->Fill(quickAna->electrons()->size());

  for (auto electron : *quickAna->electrons())
  {
    // QuickAna marks good objects by setting ana_select
    // ana::SelectType is the type QuickAna uses for boolean decorations
    if (electron->auxdata ("ana_select"))
    {
      h_el_pt->Fill(electron->pt()*0.001);// this is to plot the histogram for transverse momentum
    }
  }
  return EL::StatusCode::SUCCESS;
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.