Dear Experts I am trying to run this macro for making plots by reading hepmc file but it gives error:
yasir@yasir-X270:~/Downloads/Analysis/BS_Events/cell_deposit_test$ root bsfile.C -l
root [0]
Processing bsfile.C...
In file included from input_line_8:1:
/home/yasir/Downloads/Analysis/BS_Events/cell_deposit_test/bsfile.C:5:10: fatal error: 'HEPMC3/ReaderAscii.h' file not found
#include "HEPMC3/ReaderAscii.h"
While I have installed Hepmc3 and I can this file in the include directory
yasir@yasir-X270:~/Downloads/HepMC/HepMC3-3.2.6/include/HepMC3$ ls
AssociatedParticle.h GenPdfInfo.h ReaderHEPEVT.h
AttributeFeature.h GenRunInfo.h ReaderLHEF.h
Attribute.h GenVertex_fwd.h ReaderMT.h
bxzstr GenVertex.h ReaderPlugin.h
CompressedIO.h HEPEVT_Helpers.h ReaderRoot.h
Data HEPEVT_Wrapper.h ReaderRootTree.h
Errors.h HEPEVT_Wrapper_Runtime.h Relatives.h
Feature.h HEPEVT_Wrapper_Runtime_Static.h Selector.h
FilterAttribute.h HEPEVT_Wrapper_Template.h Setup.h
Filter.h HepMC3.h Units.h
FourVector.h LHEFAttributes.h Version.h
GenCrossSection_fwd.h LHEF.h WriterAscii.h
GenCrossSection.h Print.h WriterAsciiHepMC2.h
GenEvent.h PrintStreams.h WriterGZ.h
GenHeavyIon_fwd.h ReaderAscii.h Writer.h
.
.
In my bashrc I have:
export HEPMC_PREFIX=/home/yasir/Downloads/HepMC/HepMC3-3.2.6
export HEPMC_ROOT=/home/yasir/Downloads/HepMC/HepMC3-3.2.6
export HEP_ROOT=/home/yasir/Downloads/HepMC/HepMC3-3.2.6
export LD_LIBRARY_PATH=/home/yasir/Downloads/HepMC/HepMC3-3.2.6/lib
export LD_LIBRARY_PATH=/usr/local/lib/root:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/home/yasir/Downloads/root/lib:/home/yasir/Downloads/HepMC/HepMC3-3.2.6/lib:${LD_LIBRARY_PATH}
My code is as follows: Please suggest what could be the Problem
#include <iostream>
#include <fstream>
#include <vector>
#include "HEPMC3/ReaderAscii.h"
#include "HEPMC3/GenEvent.h"
#include "TH1F.h"
#include "TH3F.h"
#include "TCanvas.h"
void bremsstrahlungFromHEPMC3(const std::string& hepmcFile) {
// Open the HEPMC file for reading
HepMC3::ReaderAscii reader(hepmcFile);
TH1F* histX = new TH1F("histX", "X Distribution", 100, -1.0, 1.0);
TH1F* histY = new TH1F("histY", "Y Distribution", 100, -1.0, 1.0);
TH1F* histZ = new TH1F("histZ", "Z Distribution", 100, -1.0, 1.0);
TH3F* hist3D = new TH3F("hist3D", "3D Hit Distribution", 100, -1.0, 1.0, 100, -1.0, 1.0, 100, -1.0, 1.0);
histX->GetXaxis()->SetTitle("x (mm)");
histY->GetXaxis()->SetTitle("y (mm)");
histZ->GetXaxis()->SetTitle("z (mm)");
histX->GetYaxis()->SetTitle("Entries");
histY->GetYaxis()->SetTitle("Entries");
histZ->GetYaxis()->SetTitle("Entries");
hist3D->GetXaxis()->SetTitle("x (mm)");
hist3D->GetYaxis()->SetTitle("y (mm)");
hist3D->GetZaxis()->SetTitle("z (mm)");
// Loop over the events in the HEPMC file
while (!reader.failed()) {
HepMC3::GenEvent event;
reader.read_event(event);
// Loop over the particles in the event
for (const auto& particle : event.particles()) {
int pdgId = particle->pid();
// Check if the particle is a photon
if (pdgId == 22) {
double photonX = particle->momentum().x();
double photonY = particle->momentum().y();
double photonZ = particle->momentum().z();
histX->Fill(photonX);
histY->Fill(photonY);
histZ->Fill(photonZ);
hist3D->Fill(photonX, photonY, photonZ);
}
}
}
// Create a canvas and draw the histograms
TCanvas* c1 = new TCanvas("c1", "Bremsstrahlung Photon Distributions", 800, 600);
c1->Divide(2, 2);
c1->cd(1);
histX->Draw();
c1->cd(2);
histY->Draw();
c1->cd(3);
histZ->Draw();
c1->cd(4);
hist3D->Draw("BOX");
c1->Update();
}