IAP GITLAB

Commit 9bb6052e authored by Colin Baus's avatar Colin Baus

remove compiler warnings and add an example histogram

git-svn-id: https://devel-ik.fzk.de/svn/mc/crmc/trunk@4675 c7a5e08c-de06-0410-9364-b41cf42a0b17
parent 297fe741
......@@ -23,10 +23,11 @@ ROOTCFLAGS = $(shell root-config --cflags)
ROOTLIBS = $(shell root-config --libs) -lEG
HEPCFLAGS = -I$(HEP_ROOT)/include
HEPLIBS = -L$(HEP_ROOT)/lib -lHepMC -lHepMCfio -lboost_iostreams
HEPLIBS = -L$(HEP_ROOT)/lib -lHepMC -lHepMCfio
BOOSTLIBS = -lboost_iostreams -lboost_system
CFLAGS = $(ROOTCFLAGS) $(HEPCFLAGS)
LIBS = $(ROOTLIBS) $(HEPLIBS)
LIBS = $(ROOTLIBS) $(HEPLIBS) $(BOOSTLIBS)
CXXFILES=analysis.cc
......
......@@ -25,6 +25,11 @@
#include "HepMC/Units.h"
#include "HepMC/GenEvent.h"
#include <TFile.h>
#include <TH1D.h>
#include "analysis.h"
......@@ -43,16 +48,22 @@ int main (int argc, char **argv)
theOutFile = new TFile(outFileName.c_str(),"RECREATE");
vector<string> filesModel1;
filesModel1.push_back("files/test.hepmc"); //add your files here
filesModel1.push_back("files/test.hepmc"); //add your files here with additional push_back()
DataManager data;
data.SetFiles(filesModel1); //for more models, loop over models and call SetFiles each time
theOutFile->mkdir("model1");
//------------------SET UP HISTOGRAMS
TH1D* examplehist = new TH1D("dNdeta",";#eta;dN/d#eta",21,-10,10);
//-------------------EVENT LOOP
int nEvts = 0;
while (data.GetNextEvent())
{
HepMC::HeavyIon* heavyIonInfo = NULL; //helpful to get cross section: heavyIonInfo->sigma_inel_NN ()
heavyIonInfo = data.evt->heavy_ion ();
++nEvts;
//HepMC::HeavyIon* heavyIonInfo = NULL; //helpful to get cross section: heavyIonInfo->sigma_inel_NN ()
//heavyIonInfo = data.evt->heavy_ion ();
//-------------------PARTICLE LOOP
HepMC::GenEvent::particle_const_iterator par = data.evt->particles_begin ();
......@@ -62,24 +73,26 @@ int main (int argc, char **argv)
if (p->status () != 1) continue; //get final state particles status==2 would be decayed particles, status == 4 is beam particles
HepMC::GenVertex* parent_vertex = p->production_vertex();
const int id = p->pdg_id ();
const double pt = p->momentum ().perp ();
const double e = p->momentum ().e ();
//HepMC::GenVertex* parent_vertex = p->production_vertex();
//const int id = p->pdg_id ();
const double eta = p->momentum ().eta ();
//const double pt = p->momentum ().perp ();
//const double e = p->momentum ().e ();
//for more advance paramters see HepMC documentation or load #include <TParticle.h> and fill object (see analysis.h)
//-------------------EVENT SELECTION
//-------------------FILL HISTOGRAMS WITH PER PARTICLE VARIABLES
examplehist->Fill(eta);
}//PARTICLE LOOP
//fill histograms.......
//-------------------FILL HISTOGRAMS WITH PER EVENT VARIABLES
}//EVENT LOOP
//---------------FINALISE HISTOGRAMS
examplehist->Scale(1./nEvts,"width");
std::cout << " ! Writing output file" << std::endl;
std::cout << " ! Writing output file " << outFileName << std::endl;
theOutFile->Write();
std::cout << " ! Closing output file" << std::endl;
std::cout << " ! Closing output file " << outFileName << std::endl;
theOutFile->Close();
delete theOutFile;
return 0;
......
......@@ -4,9 +4,6 @@
#include <string>
#include <map>
#include <vector>
#include <TFile.h>
#include <TGraphErrors.h>
#include <TGraphAsymmErrors.h>
#include <stdexcept>
#include <exception>
......@@ -17,7 +14,7 @@
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/zlib.hpp>
// #include <TParticle.h>
// #include <TParticle.h> //nice class for more information about particles
// #include <TParticlePDG.h>
// TParticle* CopyHepMC2ROOT(HepMC::GenParticle* a);
......@@ -67,7 +64,7 @@ public:
if(ascii_in) delete ascii_in;
std::cout << "DataManger::Closing after reading " << count << " events." << std::endl;
}
void SetFiles(const std::vector<std::string>& files)
{
filelist = files; //copy
......@@ -76,18 +73,18 @@ public:
ReadFile();
}
bool GetNextEvent()
{
delete evt;
evt = 0;
try
try
{
(*ascii_in) >> evt;
}
catch (std::exception& e)
{
evt = false;
evt = NULL;
std::cout << "Event could not be read: " << e.what() << std::endl;
}
if (!evt)
......@@ -103,7 +100,7 @@ public:
}
catch(std::exception& e)
{
evt = false;
evt = NULL;
std::cout << "Event could not be read again: " << e.what() << std::endl;
}
if (!evt) return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment