Empty histograms

Asked by bernigaud

Dear MadAnalysis team,

I'm a beginner with MA5 and I apology if my question is trivial.

I have some troubles in the MA5v1.6-beta with the fillings of histograms : I get the file histo.saf but all the columns are empty (only 0 0 values, even in the nb of events). The strange part is that I am able to print the values of my observables ...

I certainly miss something (maybe in the finalize function which, in my case, is empty), but I can't figure what it is.

Thanks for your help,
Jordan.

PS: See the user.cpp file below

#include "SampleAnalyzer/User/Analyzer/Pol_t_from_squark_decay.h"

using namespace MA5;
using namespace std;

// -----------------------------------------------------------------------------
// Initialize
// function called one time at the beginning of the analysis
// -----------------------------------------------------------------------------
bool Pol_t_from_squark_decay::Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters)
{
  cout << "BEGIN Initialization" << endl;

  // Initializing the histogram
 Manager()->AddHisto("Histo_cos",15,-1,1);
 Manager()->AddHisto("Histo_MET",15,-1000,1000);

  cout << "END Initialization" << endl;
  return true;
}

// -----------------------------------------------------------------------------
// Finalize
// function called one time at the end of the analysis
// -----------------------------------------------------------------------------
void Pol_t_from_squark_decay::Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files)
{
  cout << "BEGIN Finalization" << endl;

  cout << "END Finalization" << endl;
}

// -----------------------------------------------------------------------------
// Execute
// function called each time one event is read
// -----------------------------------------------------------------------------
bool Pol_t_from_squark_decay::Execute(SampleFormat& sample, const EventFormat& event)
{

Manager()->InitializeForNewEvent(1);

 // Declaration of the particles

 const MCParticleFormat* top = 0;
 const MCParticleFormat* lepton = 0;

for (unsigned int i=0;i<event.mc()->particles().size();i++)
{
const MCParticleFormat* prt=&(event.mc()->particles()[i]);

// The lepton is a final state particle
if (PHYSICS->Id->IsFinalState(prt)) continue;

// Lepton selection based on the PDG-id
if ( std::abs(prt->pdgid())!=11 &&
std::abs(prt->pdgid())!=13 ) continue;

// Getting the mother of the lepton and
const MCParticleFormat* mother = prt->mother1();
if (mother==0) continue;
// Getting the grand-mother of the lepton and
// checking if it is a top quark
const MCParticleFormat* grandmother = mother->mother1();
if (grandmother==0) continue;
if (std::abs(grandmother->pdgid())!=6) continue;

// Saving the selected particles
lepton = prt;
top = grandmother;
// Particles are found: breaking the loop
break;
}

// Rejection of the event if the decay chain is not found
if (lepton==0)
{
WARNING << "(t > b W > b l nu) decay chain not found!"
<< std::endl;
return false;
}

 // missing transverse momentum:
MALorentzVector pTmiss = event.mc()->MET().momentum();
float MET = pTmiss.Pt();

// Boosting the lepton four-momentum to the top rest frame
MCParticleFormat lepton_new = *lepton;
lepton_new.ToRestFrame(top);

// Computing the observable; filling the histogram

// Here I print the values to be sure that they are indeed computed
cout << "MET = " << MET << endl;
cout << "angle top / lepton = " << cos(lepton_new.angle(top)) << endl;

Manager()->FillHisto("Histo_cos", cos(lepton_new.angle(top)));
Manager()->FillHisto("Histo_MET", 2.5);

  return true;
}

Question information

Language:
English Edit question
Status:
Solved
For:
MadAnalysis 5 Edit question
Assignee:
No assignee Edit question
Solved by:
Benjamin Fuks
Solved:
Last query:
Last reply:
Revision history for this message
Best Benjamin Fuks (fuks) said :
#1

Hi Jordan,

Have you defined a signal region? You need at least one of them. To use the new features of the expert mode.

Cheers,

Benjamin

> On 7 Mar 2017, at 10:44 , bernigaud <email address hidden> wrote:
>
> New question #531180 on MadAnalysis 5:
> https://answers.launchpad.net/madanalysis5/+question/531180
>
> Dear MadAnalysis team,
>
> I'm a beginner with MA5 and I apology if my question is trivial.
>
> I have some troubles in the MA5v1.6-beta with the fillings of histograms : I get the file histo.saf but all the columns are empty (only 0 0 values, even in the nb of events). The strange part is that I am able to print the values of my observables ...
>
> I certainly miss something (maybe in the finalize function which, in my case, is empty), but I can't figure what it is.
>
> Thanks for your help,
> Jordan.
>
> PS: See the user.cpp file below
>
>
> #include "SampleAnalyzer/User/Analyzer/Pol_t_from_squark_decay.h"
>
> using namespace MA5;
> using namespace std;
>
> // -----------------------------------------------------------------------------
> // Initialize
> // function called one time at the beginning of the analysis
> // -----------------------------------------------------------------------------
> bool Pol_t_from_squark_decay::Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters)
> {
> cout << "BEGIN Initialization" << endl;
>
>
>
>
> // Initializing the histogram
> Manager()->AddHisto("Histo_cos",15,-1,1);
> Manager()->AddHisto("Histo_MET",15,-1000,1000);
>
>
>
>
>
> cout << "END Initialization" << endl;
> return true;
> }
>
> // -----------------------------------------------------------------------------
> // Finalize
> // function called one time at the end of the analysis
> // -----------------------------------------------------------------------------
> void Pol_t_from_squark_decay::Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files)
> {
> cout << "BEGIN Finalization" << endl;
>
>
>
> cout << "END Finalization" << endl;
> }
>
> // -----------------------------------------------------------------------------
> // Execute
> // function called each time one event is read
> // -----------------------------------------------------------------------------
> bool Pol_t_from_squark_decay::Execute(SampleFormat& sample, const EventFormat& event)
> {
>
> Manager()->InitializeForNewEvent(1);
>
> // Declaration of the particles
>
> const MCParticleFormat* top = 0;
> const MCParticleFormat* lepton = 0;
>
>
>
> for (unsigned int i=0;i<event.mc()->particles().size();i++)
> {
> const MCParticleFormat* prt=&(event.mc()->particles()[i]);
>
>
> // The lepton is a final state particle
> if (PHYSICS->Id->IsFinalState(prt)) continue;
>
> // Lepton selection based on the PDG-id
> if ( std::abs(prt->pdgid())!=11 &&
> std::abs(prt->pdgid())!=13 ) continue;
>
> // Getting the mother of the lepton and
> const MCParticleFormat* mother = prt->mother1();
> if (mother==0) continue;
> // Getting the grand-mother of the lepton and
> // checking if it is a top quark
> const MCParticleFormat* grandmother = mother->mother1();
> if (grandmother==0) continue;
> if (std::abs(grandmother->pdgid())!=6) continue;
>
> // Saving the selected particles
> lepton = prt;
> top = grandmother;
> // Particles are found: breaking the loop
> break;
> }
>
>
>
> // Rejection of the event if the decay chain is not found
> if (lepton==0)
> {
> WARNING << "(t > b W > b l nu) decay chain not found!"
> << std::endl;
> return false;
> }
>
> // missing transverse momentum:
> MALorentzVector pTmiss = event.mc()->MET().momentum();
> float MET = pTmiss.Pt();
>
> // Boosting the lepton four-momentum to the top rest frame
> MCParticleFormat lepton_new = *lepton;
> lepton_new.ToRestFrame(top);
>
> // Computing the observable; filling the histogram
>
> // Here I print the values to be sure that they are indeed computed
> cout << "MET = " << MET << endl;
> cout << "angle top / lepton = " << cos(lepton_new.angle(top)) << endl;
>
> Manager()->FillHisto("Histo_cos", cos(lepton_new.angle(top)));
> Manager()->FillHisto("Histo_MET", 2.5);
>
>
>
>
> return true;
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this question notification because you are an answer
> contact for MadAnalysis 5.

Revision history for this message
bernigaud (jordan-bernigaud) said :
#2

Thanks Benjamin Fuks, that solved my question.