Can't run macro but can run the code inside the macro in root prompt

I can run the code inside the macro but I can’t run the macro.
(Thank you for your help)
I am getting an error message:
error: unknown type name ‘Jet’
Jet jet = (Jet) branchJet->At(0); //only take leading jet

Here is my macro code:

#include "/home/bmondal/Delphes-3.4.1/external/ExRootAnalysis/ExRootTreeReader.h"
#include "/home/bmondal/root/include/TROOT.h"
void trim(){

	gSystem->Load("~/Delphes-3.4.1/libDelphes");
	
	TChain chain("Delphes");
	chain.Add("/media/bmondal/PROJECT/DELPHES/outputpp.root");

	ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
	Long64_t numberOfEntries = treeReader->GetEntries();
	TClonesArray *branchJet = treeReader->UseBranch("FatJet");


	//Follow exroottree reader example
	//Here is one code i have used for analysis
	for(Int_t entry = 0; entry<numberOfEntries; ++entry){
	        treeReader->ReadEntry(entry);
	        if(branchJet->GetEntries()>0) {
	        	Jet *jet = (Jet*) branchJet->At(0); //only take leading jet
	            cout<<entry<<",";
	            for(int i = 0; i<5; i++){
	                for(int j = 0; j<4; j++){
	                    cout<<jet->TrimmedP4[i][j]<<",";
	                }
	            }

	        }
	}
	cout<<endl;
} 


ROOT Version: 6.12
Platform: Ubuntu 18.04
Compiler: Not Provided


Hi!
I am not sure, but I think you are missing includes with declaration of Jet class (most luckily #include "classes/DelphesClasses.h")

Thank you so much. At least the error message of not finding jet is gone.
Now this error message is showing

You are probably missing the definition of ExRootTreeReader::ReadEntry(long long)
Maybe you need to load the corresponding shared library?

I dont find any file lke “libExRootAnalysis.so”. Then which shared library i should use?
Thank you for your help

I got it.
I separately downloaded it and make it.

Thank you

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