Bonjour a toutes et a tous,

Je suis assez novice en C++ et j'aurai besoin d'aide si cela est possible.
J'utilise un framework specifique a une collab de physique appliquee, et je suis en train de creer ma propre classe pour l'inclure dans mon analyse. Le probleme c'est qu'a la compilation, ma classe n'est pas interpretee, je me demande si je dois en faire une librairie et si oui, comment creer cette librairie.
Pour info, j'utilise un Makefile pour compiler le code et le logiciel utilise en sortie pour afficher le resultat (arbres, histogrammes, etc) est ROOT.
En vous remerciant,

Jerome

ps1 : voici mon message d'erreur :

g++ -O Muonjj.o ana.o -L/d0usr/products/prd/root/Linux-2-4/v4_04_02b_fbits_eh+GCC_3_4_3_+opt/lib -lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -pthread -lm -ldl -rdynamic -L /home/jammes/MAKE_HISTOS/libraries -lmet_util -ltmb_tree -o ana
Muonjj.o: In function `__static_initialization_and_destruction_0(int, int)':
Muonjj.o(.text+0x43e): undefined reference to `ROOT::GenerateInitInstance(Muonjj const*)'
Muonjj.o(.gnu.linkonce.d._ZTV6Muonjj+0xe4): undefined reference to `Muonjj::ShowMembers(TMemberInspector&, char*)'
Muonjj.o(.gnu.linkonce.d._ZTV6Muonjj+0xe8): undefined reference to `Muonjj::Streamer(TBuffer&)'
Muonjj.o: In function `Muonjj::IsA() const':
Muonjj.o(.gnu.linkonce.t._ZNK6Muonjj3IsAEv+0x13): undefined reference to `Muonjj::Class()'
collect2: ld returned 1 exit status
make: *** [ana] Erreur 1

ps2 : Muonjj est le nom de la classe perso, ana.cpp le nom du programme principal.

Code muonjj.h : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
#ifndef MUONJJ_H
#define MUONJJ_H
 
#include "tmb_tree/TMBLorentzVector.hpp"
#include "TLorentzVector.h"
#include "TVector3.h"
 
 
class Muonjj : public TLorentzVector
{
 
  protected :
 
 Double_t fE_Muonjj; //definit ici l'energie du vecteur de lorentz pour le muon
 TVector3 fP_Muonjj; //definit le 3-vecteur des impulsions pour le muon
 
  public :
 
  Muonjj(void);
  Muonjj(const Muonjj &muon_copie);
  ~Muonjj(void);
 
  //pour l'instant on ne donne aucune methode propre a la classe Muonjj
 
  ClassDef(Muonjj,5);
};
 
 
#endif
Code muonjj.cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
#include <iostream>
#include "Muonjj.h"
#include "TObject.h"
#include "TClonesArray.h"
#include "TLorentzVector.h"
 
ClassImp(Muonjj)
 
 
 
 
  //constructeur de classe herite du constructeur de la mere (TLorentzVector)
 
  Muonjj::Muonjj(void) : TLorentzVector(0.,0.,0.,0.)
{
  printf("Execution du constructeur de la classe Muonjj");
  return;
}
 
 
  //constructeur de copie a partir des variables de la classe Muonjj et des methodes heritees de TLorentzVector
 
Muonjj::Muonjj(const Muonjj & muon_copie) : TLorentzVector(muon_copie)
       , fP_Muonjj(muon_copie.Vect()), fE_Muonjj(muon_copie.T()) {}
 
 
  //{
  //  fP_Muonjj.X() = muon_copie.X();
  //  fP_Muonjj.Y() = muon_copie.Y();
  //  fP_Muonjj.Z() = muon_copie.Z();
  //  fE_Muonjj = muon_copie.T();
  //}
 
 
//destructeur de la classe Muonjj
Muonjj::~Muonjj(void)
{
  printf("Execution du destructeur de la classe Muonjj");
  return;
}
Code ana.cpp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
 
#include <iostream>
#include <sstream>
#include <fstream>
#include <vector>
 
//#include <map>
// ROOT includes :
#include <TROOT.h>
#include "TCanvas.h"
#include "TApplication.h"
#include "TPad.h"
#include "TGraphErrors.h"
#include "TH1.h"
#include "TFile.h"
#include "TTree.h"
#include "TFriendElement.h"
#include "TMath.h"
#include "TRandom.h"
#include "TLeaf.h"
 
 
#include "tmb_tree/TMBVector3.hpp"
#include "tmb_tree/TMBMuon.hpp"
#include "tmb_tree/TMBMCpart.hpp"
#include "tmb_tree/TMBLorentzVector.hpp"
#include "tmb_tree/TMBTau.hpp"
#include "tmb_tree/TMBJet.hpp"
#include "tmb_tree/TMBMCvtx.hpp"
 
 
#include "Muonjj.h"
 
//Muonjj* Muonc = new Muonjj;
//Muonjj* LooseMuonc = new Muonjj;
 
int main(int argc, char *argv[])
{
  bool debug=false;
  if (debug)
    {
      std::cout << "argc = " << argc << std::endl;
    }
  TApplication theApp("App", &argc, argv);
 
 
  const std::string rootfile1="example_file_W_jets.root";
  const std::string rootfile2="MUinclusive_0_Skim.root";
 
  TFile *tfileSI = TFile::Open(rootfile2.c_str());
  TTree* ch = (TTree*)tfileSI->Get("TMBTree");
  const Long64_t nentries=ch->GetEntries();
 
 
  TFile* hfile = new TFile("tmbtree_to_tree.root","RECREATE");
 
 
 
 double Muon_Pt=-1.;
 double Muon_Eta=-100.;
 // double Muon_calEta=-100.;
 double LooseMuon_Pt=-1.;
 double LooseMuon_Eta=-100.;
 // double LooseMuon_calEta=-100.;
 
 //Muonjj* Mu;
 //Mu = new Muonjj;
 
 
 
 TTree *outputTree = new TTree("mycopy","copy from TMBTree");
 
 
 
 if (nentries != 0) {
 
 
   TClonesArray* p20Muon = new TClonesArray("Muonjj",10);
   TClonesArray* p20LooseMuon = new TClonesArray("Muonjj",10);
 
   TBranch *b_muon=ch->GetBranch("Muon");
   TBranch *b_loosemuon=ch->GetBranch("LooseMuon");
 
 
   ch->SetBranchAddress("Muon", &p20Muon);
   ch->SetBranchAddress("LooseMuon", &p20LooseMuon);
 
 
      outputTree->Branch("Muonjj",&p20Muon);
 
 
      //outputTree->Branch("LooseMuon", &p20LooseMuon,"",2);
 
      //TLeaf *l_muon_calEta=b_muon->GetLeaf("Muon/Muon._calEta");
 
 
      outputTree->Branch("LooseMuonjj",&p20LooseMuon);
 
 
 
 
   for (Long64_t evtc=0;evtc<nentries;++evtc)
    {
 
       Long64_t localentry = ch->LoadTree(evtc);
       b_muon->GetEntry(localentry);
       b_loosemuon->GetEntry(localentry);
 
 
        Int_t nmuons=p20Muon->GetLast()+1;
 
        if (nmuons>=1)
         {
           for (int muonc=0;muonc<nmuons;++muonc)
             {
 
               Muonjj* Muonc=static_cast<Muonjj*>(p20Muon->At(muonc));
 
               Muon_Pt=(*Muonc).Pt();
               Muon_Eta=(*Muonc).Eta();
               //              Muon_calEta=(*Muonc).calEta();
 
     }
         }
 
 
 
        Int_t nloosemuons=p20LooseMuon->GetLast()+1;
 
        if (nloosemuons>=1)
         {
           for (int loosemuonc=0;loosemuonc<nloosemuons;++loosemuonc)
             {
 
               Muonjj* LooseMuonc=static_cast<Muonjj*>(p20LooseMuon->At(loosemuonc));
 
 
               LooseMuon_Pt=(*LooseMuonc).Pt();
               LooseMuon_Eta=(*LooseMuonc).Eta();
               //              LooseMuon_calEta=(*LooseMuonc).calEta();
 
 
 
             }
         }
 
 
 
       outputTree->Fill();
     }
    outputTree->GetCurrentFile()->Write();
 }
 
 
 
 
 
outputTree->Print();
 
 
 delete hfile;
 
 //delete Muonc;
 //delete LooseMuonc;
 
  theApp.Run("kTRUE");
 
 return 0;
 
}
Code Makefile : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
ARCH          = linux
 
CXX           =
ObjSuf        = o
SrcSuf        = cxx
ExeSuf        =
DllSuf        = so
OutPutOpt     = -o
 
VPATH=../src
 
ROOTCFLAGS   := $(shell root-config --cflags)
ROOTLIBS     := $(shell root-config --libs)
ROOTGLIBS    := $(shell root-config --glibs)
 
ifeq ($(ARCH),linux)
# Linux with egcs, gcc 2.9x, gcc 3.x (>= RedHat 5.2)
CXX           = g++
CXXFLAGS      = -O -Wall -fPIC
LD            = g++
LDFLAGS       = -O
SOFLAGS       = -shared
endif
 
 
 
ifeq ($(ARCH),linuxkcc)
# Linux with the KAI compiler
CXX           = KCC --one_instantiation_per_object
CXXFLAGS      = -fPIC +K0
LD            = KCC
LDFLAGS       = -O $(shell root-config --cflags)
SOFLAGS       =
endif
 
 
 
#CXXFLAGS     += $(ROOTCFLAGS) -I/d0dist/dist/releases/p14.05.01/include
#LIBS          = $(ROOTLIBS) $(SYSLIBS) -L../TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
#GLIBS         = $(ROOTGLIBS) $(SYSLIBS) -L./TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
 
#CXXFLAGS     += $(ROOTCFLAGS) -I/users_common/pgris/LIB/myinclude -I/opt/gcc-3.2.3/include/c++/3.2.3 -I/d0dist/dist/releases/p14.05.01/include
CXXFLAGS     += $(ROOTCFLAGS) -I/home/jammes/MAKE_HISTOS/libraries -I/home/jammes/MAKE_HISTOS/tmb_tree/tmb_tree -I/home/jammes/MAKE_HISTOS/met_util/met_util -I/home/jammes/MAKE_HISTOS/tmb_tree -I/home/jammes/MAKE_HISTOS/cafe
-I/home/jammes/MAKE_HISTOS/cafe/cafe
#LIBS          = $(ROOTLIBS) $(SYSLIBS) -L /users_common/pgris/LIB/TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
#GLIBS         = $(ROOTGLIBS) $(SYSLIBS) -L /users_common/pgris/LIB/TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
LIBS          = $(ROOTLIBS) $(SYSLIBS)  -L /home/jammes/MAKE_HISTOS/libraries -lmet_util -ltmb_tree
GLIBS         = $(ROOTGLIBS) $(SYSLIBS) -L /home/jammes/MAKE_HISTOS/libraries -lmet_util -ltmb_tree
 
 
 
MUONJJO         = Muonjj.$(ObjSuf)
MUONJJS         = Muonjj.$(SrcSuf)
MUONJJ          = Muonjj$(ExeSuf)
 
 
anaO            = ana.$(ObjSuf)
anaS            = ana.$(SrcSuf)
ana             = ana$(ExeSuf)
 
 
 
$(ana)     :    $(MUONJJO) $(anaO)
                $(LD) $(LDFLAGS) $^ $(GLIBS) $(OutPutOpt)$@
                @echo "$@ done"
clean:
                @rm -f *.$(OBJS) core
.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
 
.$(SrcSuf).$(ObjSuf):
        $(CXX) $(CXXFLAGS) -c $<