Hello!
I have a problem with my macros with FWLite.
I need to load the libFWCoreFWLite to define the object “vector bj”, but when I do this, I get this error :
Error: Symbol chain is not defined in current scope test_plot.C:19:
Error: Failed to evaluate chain.GetEntries()
*** Interpreter error recovered ***
If I remove the part of macros wich loads the libFWCoreFWLite,
then “chain.GetEntries()” works, but a problem with identification of “vector bj” appears of course.
So, please, may be somebody can help me, why it happens?
That is the contents of my macros:
void test_plot() {
if (gSystem->Load("libFWCoreFWLite") == 0) { // if not loaded yet, load it
AutoLibraryLoader::enable();
}
TChain chain("Events");
chain.Add("SingleTopMuEvents_1.root");
chain.Add("SingleTopMuEvents_2.root");
TH1F* h = new TH1F("h","",50,0,250);
TBranch * topBjets = chain.GetBranch( "TopJets_selectedTopBJets__StEventReco.obj" );
// Loop over events and fill histogram
Int_t nev = chain.GetEntries();
cout << "nev = " << nev << endl;
vector bj;
for( int ev = 0; ev < nev; ++ev ) {
topBjets -> SetAddress( & bj );
topBjets -> GetEntry( ev );
double pt=bj[0].pt();
h->Fill(pt);
}
gStyle->SetOptStat(0000);
gStyle->SetCanvasBorderMode(-1);
gStyle->SetCanvasBorderSize(1);
gStyle->SetCanvasColor(10);
h->SetLineColor(2);
h->SetLineWidth(3);
TCanvas* myCanvas = new TCanvas(“myCanvas”,“Jets”,100,10,800,800);
myCanvas->SetFillColor(10);
myCanvas->cd();
h->Draw();
TLegend *legend = new TLegend(0.75,0.75,0.95,0.95,"",“NDC”);
legend->AddEntry(h,“bj[0].pt”,“l”);
legend->Draw(“Same”);
myCanvas->Update();
// output:
TString gif(“bj[0]_new.pt.gif”);
myCanvas->Print(gif);
}
P.S. Files SingleTopMuEvents_*.root has several trees, one of them calls “Events”
Thank you in advance.