Error while compiling

Hi everyone,
I have some errors while compiling my code, by the way the code works well with the computer of the guy who send it to me, but if I compile it I get this errors:


Error: Symbol #include is not defined in current scope  (tmpfile):1:
Error: Symbol exception is not defined in current scope  (tmpfile):1:
Syntax Error: #include <exception> (tmpfile):1:
Error: Symbol G__exception is not defined in current scope  (tmpfile):1:
Error: type G__exception not defined FILE:(tmpfile) LINE:1
(void)0
*** Interpreter error recovered ***

here is the code


#include "CMS2.cc"

#include <fstream>
#include <iostream>

using namespace std;
using namespace tas;

//int main(int argc, char** argv) {
void ElectronLooper(TString inputList) {

  enum Classification { UNKNOWN=-1, GOLDEN=0, BIGBREM=1, BADTRACK=2, SHOWERING=3, GAP=4 } ;

  TString reader;
  ifstream fileReader(inputList);

  TFile* outputFile = TFile::Open("output_histograms.root", "recreate");
  //TH1D* dielectron_mass = new TH1D("dielectron_mass", "", 200, 0., 200.);
  //TH1D* dielectron_mass_lowfbrem = new TH1D("dielectron_mass_lowfbrem", "", 200, 0., 200.);
  //TH1D* dielectron_mass_onecluster = new TH1D("dielectron_mass_onecluster", "", 200, 0., 200.);
  TH1D* dielectron_mass_golden = new TH1D("dielectron_mass_golden", "", 200, 0., 200.);
  
  while (!fileReader.eof()) {

    reader.ReadLine(fileReader);
    if (reader.Length() < 5) continue;
    cout << "Opening file " << reader.Data() << endl;

    TFile* fileHandle = TFile::Open(reader);
    TTree* treeHandle = static_cast<TTree*>(fileHandle->Get("Events"));
    Long64_t nentries = treeHandle->GetEntries();
    
    cms2.Init(treeHandle);
    for (Long64_t ientry = 0; ientry < nentries; ientry++) {
      CMS2::progress(ientry,nentries);
      cms2.GetEntry(ientry);
     

      // cout << "I found " << els_p4().size() << " electrons" << endl;      
      // for (int ielec = 0; ielec < els_p4().size(); ielec++) {
      // 	cout << "   Electron " << ielec << endl;
      // 	cout << "       Four-momentum:         " << els_p4().at(ielec).px() << " " << els_p4().at(ielec).py() << " " << els_p4().at(ielec).pz() << " " << els_p4().at(ielec).e() << endl;
      // 	cout << "       eta, phi, pt:          " << els_p4().at(ielec).eta() << " " << els_p4().at(ielec).phi() << " " << els_p4().at(ielec).pt() << endl;
      // 	cout << "       Number of pixel hits:  " << els_valid_pixelhits().at(ielec) << endl;
      // 	cout << "       R9:                    " << els_r9().at(ielec) << endl;
      // }

      if (els_p4().size() < 2) continue;
      
      //dielectron_mass->Fill((els_p4().at(0)+els_p4().at(1)).mass(), evt_scale1fb()); 
      
      //if (els_fbrem().at(0) < 0.5 && els_fbrem().at(1) < 0.5) {
      //dielectron_mass_lowfbrem->Fill((els_p4().at(0)+els_p4().at(1)).mass(), evt_scale1fb()); 
      //}

      //if (els_nSeed().at(0) == 0 && els_nSeed().at(1) == 0) {
      //	dielectron_mass_onecluster->Fill((els_p4().at(0)+els_p4().at(1)).mass(), evt_scale1fb()); 
      //}

      if (els_class().at(0) == GOLDEN && els_class().at(1) == GOLDEN) {
      dielectron_mass_golden->Fill((els_p4().at(0)+els_p4().at(1)).mass(), evt_scale1fb()); 
      }



    }
  }

  outputFile->cd();
//dielectron_mass->Write();
  //dielectron_mass_lowfbrem->Write();
  //dielectron_mass_onecluster->Write();
  dielectron_mass_golden->Write();
  outputFile->Close();
  
}

the CMS2.cc are in the same directory and the makfile too.
Could someone help me please.
thanks in advance.

You have to compile it, but you are using the CINT interpreter instead.

Add the “+” sign at the end of the file name

root -l .x ElectronLooper.C+("yourstring")

Hi,
Maybe my informations was not complete but the name of the code and the file txt (which has 5 root file) is:

I run it by doing:

.L ElectronLooper.cc+
 ElectronLooper("mc_small.txt")

And I got the errors I listed above.
After your reply I did.

.L ElectronLooper.cc+(mc_small.txt+)

And I got only this:

Warning in <TRint::ProcessLine>: argument(s) "(mc_small.txt+)" ignored with .L

After adding “+” in the name of the file as you said.
Cheers

Ok, then I misunderstood. You were doing it correctly. The + just after the .cc

Try:
root[0] .x ElectronLooper.C++(“yourstring”)

If it doesn’t help, you need to show “CMS2.cc” (and any files that it internally includes).

Don’t worry it’s me who was not clear

You can maybe hide the #include from CINT like this:

#ifndef __CINT__ #include <exception> #endif /* __CINT __ */

but not sure without having all makefile, .cc and so on.

ok here is all the file used in the code there is also the makefile which is

all:
	g++ `root-config --libs --cflags` ElectronLooper.cc -o ElectronLooper -lGenVector

And these extensions in the same directory

mc_small.txt (935 Bytes)
CMS2.h (1.24 MB)
CMS2.cc (94.3 KB)

I tried your source code with ROOT 5.34/36 and 6.06/02 (gcc 4.8.4 / x86_64) and I get no problem when compiling it directly: `root-config --cxx --cflags` -O2 -W -Wall ElectronLooper.cc -o ElectronLooper `root-config --libs` -lGenVector nor when using ACLiC: root [0] .L ElectronLooper.C++ Before you try it again, make sure that you first: rm -f AutoDict_* ElectronLooper_* ElectronLooper output_histograms.root
I cannot test how it runs because I don’t have xrootd libraries.

P.S. In order to create the “ElectronLooper.cc”, I simply copied “ElectronLooper.C” and added in the end: int main(int /*argc*/, char** /*argv*/) { ElectronLooper("mc_small.txt"); return 0; }

I managed to compile without using the Makefile, just (removing first Makefile and .so .d …) and running:

root -l 
.x ElectronLooper.C+("mc_small.txt")
Info in <TUnixSystem::ACLiC>: creating shared library /tmp/./ElectronLooper_C.so
Opening file root://xrootd.t2.ucsd.edu//store/group/snt/papers2012/Summer12_53X_MC/DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/V05-03-23/merged_ntuple_1.root
(...)

As I thought … you needed a cleanup: rm -f AutoDict_* ElectronLooper_* ElectronLooper output_histograms.root and do remember to use a safer “++” instead of “+”.

(I am not diboye!)

I removed all except:

And I compile with

[quote]
.x ElectronLooper.C+(“mc_small.txt”)
[/quote] As you asked me Ferhue, bud I keep having the same trouble.
I did also what Pepe said ie adding at the end of the code

int main(int /*argc*/, char** /*argv*/) {
  ElectronLooper("mc_small.txt");
  return 0;
}

And compile with

`root-config --cxx --cflags` -O2 -W -Wall ElectronLooper.cc -o ElectronLooper `root-config --libs` -lGenVector

or

g++ `root-config --libs --cflags` ElectronLooper.cc -o ElectronLooper -lGenVector

this time I have no error but I get nothing, no histo or cout.
So I don’t understand anymore. Maybe it is related to some warning before the errors occur like:


root [0] .L ElectronLooper.cc++
Info in <TUnixSystem::ACLiC>: creating shared library /afs/cern.ch/work/d/diboye/essai/CMSSW_5_3_22/src/ElectronLooper/./ElectronLooper_cc.so
root [1] ElectronLooper("mc_small.txt")
Opening file root://xrootd.t2.ucsd.edu//store/group/snt/papers2012/Summer12_53X_MC/DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball_Summer12_DR53X-PU_S10_START53_V7A-v1/V05-03-23/merged_ntuple_1.root
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float> > > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<TBits> is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<bool> is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<float> is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<int> is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float> > > > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<TString> > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<bool> > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<float> > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<int> > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float> > > > > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<vector<float> > > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<vector<int> > > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<vector<unsigned int> > is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<unsigned int> is available
Warning in <TClass::TClass>: no dictionary for class edm::Wrapper<ULong64_t> is available
Warning in <TClass::TClass>: no dictionary for class edm::EventAuxiliary is available
Warning in <TClass::TClass>: no dictionary for class ROOT::Math::PxPyPzE4D<float> is available
Warning in <TClass::TClass>: no dictionary for class ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<float> > is available
Warning in <TClass::TClass>: no dictionary for class edm::Hash<2> is available
Warning in <TClass::TClass>: no dictionary for class edm::EventID is available
Warning in <TClass::TClass>: no dictionary for class edm::Timestamp is available
Warning in <TClass::TClass>: no dictionary for class edm::LuminosityBlockAuxiliary is available
Warning in <TClass::TClass>: no dictionary for class edm::LuminosityBlockID is available
Warning in <TClass::TClass>: no dictionary for class edm::RunAuxiliary is available
Warning in <TClass::TClass>: no dictionary for class edm::RunID is available
Warning in <TClass::TClass>: no dictionary for class edm::StoredProductProvenance is available
Warning in <TClass::TClass>: no dictionary for class edm::Hash<1> is available
Warning in <TClass::TClass>: no dictionary for class edm::FileFormatVersion is available
Warning in <TClass::TClass>: no dictionary for class edm::FileID is available
Warning in <TClass::TClass>: no dictionary for class edm::IndexIntoFile is available
Warning in <TClass::TClass>: no dictionary for class edm::IndexIntoFile::RunOrLumiEntry is available
Warning in <TClass::TClass>: no dictionary for class edm::ProcessConfiguration is available
Warning in <TClass::TClass>: no dictionary for class edm::ProcessHistory is available
Warning in <TClass::TClass>: no dictionary for class edm::ParameterSetBlob is available
Warning in <TClass::TClass>: no dictionary for class edm::BranchKey is available
Warning in <TClass::TClass>: no dictionary for class edm::BranchID is available
Warning in <TClass::TClass>: no dictionary for class edm::ProductRegistry is available
Warning in <TClass::TClass>: no dictionary for class edm::BranchDescription is available
Warning in <TClass::TClass>: no dictionary for class edm::Parentage is available
Warning in <TClass::TClass>: no dictionary for class edm::BranchChildren is available
Warning in <TClass::TClass>: no dictionary for class pair<edm::Hash<1>,edm::ParameterSetBlob> is available
Warning in <TClass::TClass>: no dictionary for class pair<edm::BranchKey,edm::BranchDescription> is available
Warning in <TClass::TClass>: no dictionary for class pair<edm::BranchID,set<edm::BranchID> > is available
Warning in <TClass::TClass>: no dictionary for class edm::IndexIntoFile::Transients is available
Warning in <TClass::TClass>: no dictionary for class edm::ProductRegistry::Transients is available
Warning in <TClass::TClass>: no dictionary for class edm::Parentage::Transients is available
Error: Symbol #include is not defined in current scope  (tmpfile):1:
Error: Symbol exception is not defined in current scope  (tmpfile):1:
Syntax Error: #include <exception> (tmpfile):1:
Error: Symbol G__exception is not defined in current scope  (tmpfile):1:
Error: type G__exception not defined FILE:(tmpfile) LINE:1
(void)0
*** Interpreter error recovered ***
root [2] 

This is all I get!!
Cheers
Cheers