compile does not recognize root histogram type TH1I

Asked by Sarah Ferguson

I am trying to create a model to use for analysis. I first build in normal mode and then in expert mode. It seems to compile fine before I edit the model .cpp and .h files.

    ~]$ cd madanalysis5/bin/
 bin]$ ./ma5
 bin]$ ./ma5 -R -E
bin]$ cd HAHM_LJmod/Build/
Build]$ source setup.sh
--------------------------------------------------------
    Your environment is properly configured for MA5
--------------------------------------------------------
Build]$ make
--------------------------------------------------
             Building MadAnalysis Job
--------------------------------------------------
--------------------------------------------------
                   Compilation
--------------------------------------------------
g++ -Wall -O3 -fPIC -I/afs/cern.ch/user/s/sferguso/madanalysis5/tools/ -I./ -pthread -std=c++11 -Wno-deprecated-declarations -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.14-x86_64-slc6-gcc49-opt/include -o Main/main.o -c Main/main.cpp
g++ -Wall -O3 -fPIC -I/afs/cern.ch/user/s/sferguso/madanalysis5/tools/ -I./ -pthread -std=c++11 -Wno-deprecated-declarations -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.14-x86_64-slc6-gcc49-opt/include -o SampleAnalyzer/User/Analyzer/HAHM_LJmod.o -c SampleAnalyzer/User/Analyzer/HAHM_LJmod.cpp
--------------------------------------------------
                     Linking
--------------------------------------------------
g++ Main/main.o SampleAnalyzer/User/Analyzer/HAHM_LJmod.o -L/afs/cern.ch/user/s/sferguso/madanalysis5/tools/SampleAnalyzer/Lib -L/afs/cern.ch/user/s/sferguso/madanalysis5/tools/SampleAnalyzer/ExternalSymLink/Lib -lprocess_for_ma5 -lprocess_for_ma5 -L/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.14-x86_64-slc6-gcc49-opt/lib -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lEG -lcommons_for_ma5 -o ./MadAnalysis5job

At this point I change the HAHM_LJmod.cpp and HAHM_LJmod.h files. I copy them from a colleague's area. He had no trouble with using them. Then I recompile:

 Build]$ source setup.sh
--------------------------------------------------------
    Your environment is properly configured for MA5
--------------------------------------------------------
Build]$ make
--------------------------------------------------
             Building MadAnalysis Job
--------------------------------------------------
--------------------------------------------------
                   Compilation
--------------------------------------------------
g++ -Wall -O3 -fPIC -I/afs/cern.ch/user/s/sferguso/madanalysis5/tools/ -I./ -pthread -std=c++11 -Wno-deprecated-declarations -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/include -o Main/main.o -c Main/main.cpp
In file included from ./SampleAnalyzer/User/Analyzer/analysisList.h:1:0,
                 from Main/main.cpp:12:
./SampleAnalyzer/User/Analyzer/HAHM_LJmod.h:26:3: error: â does not name a type
   TH1I* H0_;
   ^
make: *** [Main/main.o] Error 1

With this error the MadAnalysis5job does not run properly. Below are the .cpp and .h files before mentioned. Again, a colleague of mine uses these exact files and does not have a problem with it.

HAHM_LJmod.cpp:

#include "SampleAnalyzer/User/Analyzer/HAHM_LJmod.h"
using namespace MA5;
using namespace std;

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

 // Initializing PhysicsService for MC
  PHYSICS->mcConfig().Reset();

  // definition of the multiparticle "hadronic"
  PHYSICS->mcConfig().AddHadronicId(-5);
  PHYSICS->mcConfig().AddHadronicId(-4);
  PHYSICS->mcConfig().AddHadronicId(-3);
  PHYSICS->mcConfig().AddHadronicId(-2);
  PHYSICS->mcConfig().AddHadronicId(-1);
  PHYSICS->mcConfig().AddHadronicId(1);
  PHYSICS->mcConfig().AddHadronicId(2);
  PHYSICS->mcConfig().AddHadronicId(3);
  PHYSICS->mcConfig().AddHadronicId(4);
  PHYSICS->mcConfig().AddHadronicId(5);
  PHYSICS->mcConfig().AddHadronicId(21);

  // definition of the multiparticle "invisible"
  PHYSICS->mcConfig().AddInvisibleId(-16);
  PHYSICS->mcConfig().AddInvisibleId(-14);
  PHYSICS->mcConfig().AddInvisibleId(-12);
  PHYSICS->mcConfig().AddInvisibleId(12);
  PHYSICS->mcConfig().AddInvisibleId(14);
  PHYSICS->mcConfig().AddInvisibleId(16);
  PHYSICS->mcConfig().AddInvisibleId(1000022);

  // Initializing each selection item
  H0_= new TH1I("myhist", "Counts",3,0.5,3.5);

  //counters
   muonN2=0.0;
   pionN2=0.0;
   elecN2=0.0;
   zdN=0;
  muonN=0;
   pionN=0;
   elecN=0;

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

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

  //make histogram file
  TCanvas* myCanvas = new TCanvas("myCanvas","");
  H0_->Draw();
  H0_->GetXaxis()->SetTitle("1=e, 2=#mu, 3=#pi");
  myCanvas->SaveAs("temp.eps","eps");

//print pranching ratios
INFO <<"Number of electrons " << elecN << " Branching ratio " << (float) elecN/(2*(float)zdN) << endmsg;
INFO <<"Number of muons " << muonN << " Branching ratio " << (float) muonN/(2*(float)zdN) << endmsg;
INFO <<"Number of pions " << pionN << " Branching ratio " << (float) pionN/(2*(float)zdN) << endmsg;
INFO <<"Raw zd Number " << zdN <<endmsg;

vel=vel/zdN;
//float ct=4700*sqrt(1-pow(vel, 2))/(vel);
float ct=47/vel;
INFO << "v/c " << vel <<" => ct="<< ct <<endmsg;

cout << "END Finalization" << endl;

}

// -----------------------------------------------------------------------------
// Execute
// function called each time one event is read
// -----------------------------------------------------------------------------
bool HAHM_LJmod::Execute(SampleFormat& sample, const EventFormat& event)
{
 //My actual work
  unsigned int n=event.mc()->particles().size(); //get size of particle list
  for (unsigned int i=0; i<n ;i++) //loop over particles
  {
    const MCParticleFormat* prt = &event.mc()->particles()[i]; //pointer to that particle

  //this only for final state particle
  /*
  if(PHYSICS->Id->IsFinalState(prt)) //if final state
      {
  //if particle add to count and histogram
    if(std::abs(prt->pdgid())==ePDGID){muonN2+=1*event.mc()->weight();H0_->Fill(1);}
      if(std::abs(prt->pdgid())==muPDGID){elecN2+=1*event.mc()->weight();H0_->Fill(2);}
      if(std::abs(prt->pdgid())==piPDGID){pionN2+=1*event.mc()->weight();H0_->Fill(3);}
      // if(std::abs(prt->pdgid())==3000013){muonN+=1;H0_->Fill(1);}
      // if(std::abs(prt->pdgid())==3000011){elecN+=1;H0_->Fill(2);}
      // if(std::abs(prt->pdgid())==211){pionN+=1;H0_->Fill(3);}
      }
   */

   if(prt->pdgid()==3000001) //if zd
     {
    zdN+=1;
   vel+=prt->beta();
   //two daughters
    d1 = prt->daughters()[1];
    d2 = prt->daughters()[2];
    //update backup count
    if(std::abs(d1->pdgid())==muPDGID){muonN+=1;}
    if(std::abs(d1->pdgid())==ePDGID){elecN+=1;}
    if(std::abs(d1->pdgid())==piPDGID){pionN+=1;}
    if(std::abs(d2->pdgid())==muPDGID){muonN+=1;}
    if(std::abs(d2->pdgid())==ePDGID){elecN+=1;}
    if(std::abs(d2->pdgid())==piPDGID){pionN+=1;}
      }
  }

 return true;
}

HAHM_LJmod.h:

#ifndef analysis_HAHM_LJmod_h
#define analysis_HAHM_LJmod_h

#include "SampleAnalyzer/Process/Analyzer/AnalyzerBase.h"

namespace MA5
{
class HAHM_LJmod : public AnalyzerBase
{
  INIT_ANALYSIS(HAHM_LJmod,"HAHM_LJmod")

 public:
  virtual bool Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters);
  virtual void Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files);
  virtual bool Execute(SampleFormat& sample, const EventFormat& event);

 private:
 // Declaring histogram array
  PlotManager plots_;

  // Declaring cut array
  CounterManager cuts_;

  // Declaring shortcut to histograms
  //HistoFrequency<Int_t>* H0_;
  TH1I* H0_;

 float vel=0.0;

 //pdgID codes for particles
 int ePDGID=11;
 int muPDGID=13;
 int piPDGID=2110;

  //declare counters
  float muonN2;
  float pionN2;
  float elecN2;

 int zdN;
  int muonN;
  int pionN;
  int elecN;

  const MCParticleFormat* d1;
  const MCParticleFormat* d2;
};
}

#endif

Question information

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

Dear Sarah,

I have the impression your colleague has root installed and linked to ma5, which is not your case. As the analysis uses root classes, you get a crash at the level of the compilation. I hope it helps.

Regards,

Benjamin

> On 17 Apr 2017, at 20:37 , Sarah Ferguson <email address hidden> wrote:
>
> New question #621310 on MadAnalysis 5:
> https://answers.launchpad.net/madanalysis5/+question/621310
>
> I am trying to create a model to use for analysis. I first build in normal mode and then in expert mode. It seems to compile fine before I edit the model .cpp and .h files.
>
> ~]$ cd madanalysis5/bin/
> bin]$ ./ma5
> bin]$ ./ma5 -R -E
> bin]$ cd HAHM_LJmod/Build/
> Build]$ source setup.sh
> --------------------------------------------------------
> Your environment is properly configured for MA5
> --------------------------------------------------------
> Build]$ make
> --------------------------------------------------
> Building MadAnalysis Job
> --------------------------------------------------
> --------------------------------------------------
> Compilation
> --------------------------------------------------
> g++ -Wall -O3 -fPIC -I/afs/cern.ch/user/s/sferguso/madanalysis5/tools/ -I./ -pthread -std=c++11 -Wno-deprecated-declarations -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.14-x86_64-slc6-gcc49-opt/include -o Main/main.o -c Main/main.cpp
> g++ -Wall -O3 -fPIC -I/afs/cern.ch/user/s/sferguso/madanalysis5/tools/ -I./ -pthread -std=c++11 -Wno-deprecated-declarations -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.14-x86_64-slc6-gcc49-opt/include -o SampleAnalyzer/User/Analyzer/HAHM_LJmod.o -c SampleAnalyzer/User/Analyzer/HAHM_LJmod.cpp
> --------------------------------------------------
> Linking
> --------------------------------------------------
> g++ Main/main.o SampleAnalyzer/User/Analyzer/HAHM_LJmod.o -L/afs/cern.ch/user/s/sferguso/madanalysis5/tools/SampleAnalyzer/Lib -L/afs/cern.ch/user/s/sferguso/madanalysis5/tools/SampleAnalyzer/ExternalSymLink/Lib -lprocess_for_ma5 -lprocess_for_ma5 -L/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.04.14-x86_64-slc6-gcc49-opt/lib -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -lEG -lcommons_for_ma5 -o ./MadAnalysis5job
>
>
> At this point I change the HAHM_LJmod.cpp and HAHM_LJmod.h files. I copy them from a colleague's area. He had no trouble with using them. Then I recompile:
>
> Build]$ source setup.sh
> --------------------------------------------------------
> Your environment is properly configured for MA5
> --------------------------------------------------------
> Build]$ make
> --------------------------------------------------
> Building MadAnalysis Job
> --------------------------------------------------
> --------------------------------------------------
> Compilation
> --------------------------------------------------
> g++ -Wall -O3 -fPIC -I/afs/cern.ch/user/s/sferguso/madanalysis5/tools/ -I./ -pthread -std=c++11 -Wno-deprecated-declarations -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/5.34.25-x86_64-slc6-gcc48-opt/include -o Main/main.o -c Main/main.cpp
> In file included from ./SampleAnalyzer/User/Analyzer/analysisList.h:1:0,
> from Main/main.cpp:12:
> ./SampleAnalyzer/User/Analyzer/HAHM_LJmod.h:26:3: error: â does not name a type
> TH1I* H0_;
> ^
> make: *** [Main/main.o] Error 1
>
>
> With this error the MadAnalysis5job does not run properly. Below are the .cpp and .h files before mentioned. Again, a colleague of mine uses these exact files and does not have a problem with it.
>
>
> HAHM_LJmod.cpp:
>
> #include "SampleAnalyzer/User/Analyzer/HAHM_LJmod.h"
> using namespace MA5;
> using namespace std;
>
> // -----------------------------------------------------------------------------
> // Initialize
> // function called one time at the beginning of the analysis
> // -----------------------------------------------------------------------------
> bool HAHM_LJmod::Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters)
> {
> cout << "BEGIN Initialization" << endl;
> // initialize variables, histos
>
> // Initializing PhysicsService for MC
> PHYSICS->mcConfig().Reset();
>
> // definition of the multiparticle "hadronic"
> PHYSICS->mcConfig().AddHadronicId(-5);
> PHYSICS->mcConfig().AddHadronicId(-4);
> PHYSICS->mcConfig().AddHadronicId(-3);
> PHYSICS->mcConfig().AddHadronicId(-2);
> PHYSICS->mcConfig().AddHadronicId(-1);
> PHYSICS->mcConfig().AddHadronicId(1);
> PHYSICS->mcConfig().AddHadronicId(2);
> PHYSICS->mcConfig().AddHadronicId(3);
> PHYSICS->mcConfig().AddHadronicId(4);
> PHYSICS->mcConfig().AddHadronicId(5);
> PHYSICS->mcConfig().AddHadronicId(21);
>
> // definition of the multiparticle "invisible"
> PHYSICS->mcConfig().AddInvisibleId(-16);
> PHYSICS->mcConfig().AddInvisibleId(-14);
> PHYSICS->mcConfig().AddInvisibleId(-12);
> PHYSICS->mcConfig().AddInvisibleId(12);
> PHYSICS->mcConfig().AddInvisibleId(14);
> PHYSICS->mcConfig().AddInvisibleId(16);
> PHYSICS->mcConfig().AddInvisibleId(1000022);
>
> // Initializing each selection item
> H0_= new TH1I("myhist", "Counts",3,0.5,3.5);
>
> //counters
> muonN2=0.0;
> pionN2=0.0;
> elecN2=0.0;
> zdN=0;
> muonN=0;
> pionN=0;
> elecN=0;
>
> cout << "END Initialization" << endl;
> return true;
> }
>
> // -----------------------------------------------------------------------------
> // Finalize
> // function called one time at the end of the analysis
> // -----------------------------------------------------------------------------
> void HAHM_LJmod::Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files)
> {
> cout << "BEGIN Finalization" << endl;
>
> //make histogram file
> TCanvas* myCanvas = new TCanvas("myCanvas","");
> H0_->Draw();
> H0_->GetXaxis()->SetTitle("1=e, 2=#mu, 3=#pi");
> myCanvas->SaveAs("temp.eps","eps");
>
> //print pranching ratios
> INFO <<"Number of electrons " << elecN << " Branching ratio " << (float) elecN/(2*(float)zdN) << endmsg;
> INFO <<"Number of muons " << muonN << " Branching ratio " << (float) muonN/(2*(float)zdN) << endmsg;
> INFO <<"Number of pions " << pionN << " Branching ratio " << (float) pionN/(2*(float)zdN) << endmsg;
> INFO <<"Raw zd Number " << zdN <<endmsg;
>
> vel=vel/zdN;
> //float ct=4700*sqrt(1-pow(vel, 2))/(vel);
> float ct=47/vel;
> INFO << "v/c " << vel <<" => ct="<< ct <<endmsg;
>
> cout << "END Finalization" << endl;
>
> }
>
> // -----------------------------------------------------------------------------
> // Execute
> // function called each time one event is read
> // -----------------------------------------------------------------------------
> bool HAHM_LJmod::Execute(SampleFormat& sample, const EventFormat& event)
> {
> //My actual work
> unsigned int n=event.mc()->particles().size(); //get size of particle list
> for (unsigned int i=0; i<n ;i++) //loop over particles
> {
> const MCParticleFormat* prt = &event.mc()->particles()[i]; //pointer to that particle
>
> //this only for final state particle
> /*
> if(PHYSICS->Id->IsFinalState(prt)) //if final state
> {
> //if particle add to count and histogram
> if(std::abs(prt->pdgid())==ePDGID){muonN2+=1*event.mc()->weight();H0_->Fill(1);}
> if(std::abs(prt->pdgid())==muPDGID){elecN2+=1*event.mc()->weight();H0_->Fill(2);}
> if(std::abs(prt->pdgid())==piPDGID){pionN2+=1*event.mc()->weight();H0_->Fill(3);}
> // if(std::abs(prt->pdgid())==3000013){muonN+=1;H0_->Fill(1);}
> // if(std::abs(prt->pdgid())==3000011){elecN+=1;H0_->Fill(2);}
> // if(std::abs(prt->pdgid())==211){pionN+=1;H0_->Fill(3);}
> }
> */
>
>
> if(prt->pdgid()==3000001) //if zd
> {
> zdN+=1;
> vel+=prt->beta();
> //two daughters
> d1 = prt->daughters()[1];
> d2 = prt->daughters()[2];
> //update backup count
> if(std::abs(d1->pdgid())==muPDGID){muonN+=1;}
> if(std::abs(d1->pdgid())==ePDGID){elecN+=1;}
> if(std::abs(d1->pdgid())==piPDGID){pionN+=1;}
> if(std::abs(d2->pdgid())==muPDGID){muonN+=1;}
> if(std::abs(d2->pdgid())==ePDGID){elecN+=1;}
> if(std::abs(d2->pdgid())==piPDGID){pionN+=1;}
> }
> }
>
> return true;
> }
>
>
> HAHM_LJmod.h:
>
> #ifndef analysis_HAHM_LJmod_h
> #define analysis_HAHM_LJmod_h
>
> #include "SampleAnalyzer/Process/Analyzer/AnalyzerBase.h"
>
> namespace MA5
> {
> class HAHM_LJmod : public AnalyzerBase
> {
> INIT_ANALYSIS(HAHM_LJmod,"HAHM_LJmod")
>
> public:
> virtual bool Initialize(const MA5::Configuration& cfg, const std::map<std::string,std::string>& parameters);
> virtual void Finalize(const SampleFormat& summary, const std::vector<SampleFormat>& files);
> virtual bool Execute(SampleFormat& sample, const EventFormat& event);
>
> private:
> // Declaring histogram array
> PlotManager plots_;
>
> // Declaring cut array
> CounterManager cuts_;
>
> // Declaring shortcut to histograms
> //HistoFrequency<Int_t>* H0_;
> TH1I* H0_;
>
> float vel=0.0;
>
> //pdgID codes for particles
> int ePDGID=11;
> int muPDGID=13;
> int piPDGID=2110;
>
> //declare counters
> float muonN2;
> float pionN2;
> float elecN2;
>
> int zdN;
> int muonN;
> int pionN;
> int elecN;
>
> const MCParticleFormat* d1;
> const MCParticleFormat* d2;
> };
> }
>
> #endif
>
>
> --
> You received this question notification because you are an answer
> contact for MadAnalysis 5.

Can you help with this problem?

Provide an answer of your own, or ask Sarah Ferguson for more information if necessary.

To post a message you must log in.