Skip to content

Commit

Permalink
[GENERATORS] Applying code checks/format
Browse files Browse the repository at this point in the history
  • Loading branch information
smuzaffar committed Oct 3, 2024
1 parent 6f0c989 commit f5f7ed5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 55 deletions.
6 changes: 1 addition & 5 deletions GeneratorInterface/BeamHaloGenerator/src/PYR.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@
CLHEP::HepRandomEngine* _BeamHalo_randomEngine;

extern "C" {
float bhgpyr_(int* idummy)
{
return (float)_BeamHalo_randomEngine->flat();
}
float bhgpyr_(int* idummy) { return (float)_BeamHalo_randomEngine->flat(); }
}

24 changes: 12 additions & 12 deletions GeneratorInterface/ExhumeInterface/src/Integral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

#include <cmath>

double dsimps_(double* F,double* A,double* B,int* N){

double dsimps_(double* F, double* A, double* B, int* N) {
double a = *A;
double b = *B;
int n = *N;
double deltaX = (b-a)/n;
double I=F[0] + F[n];

for(int i=1;i<=n/2;i++){
int j=2*i;
int k =2*i-1;
if(j<n) I += 2*F[j];
if(k<n) I += 4*F[k];

double deltaX = (b - a) / n;
double I = F[0] + F[n];

for (int i = 1; i <= n / 2; i++) {
int j = 2 * i;
int k = 2 * i - 1;
if (j < n)
I += 2 * F[j];
if (k < n)
I += 4 * F[k];
}
return(I*deltaX/3);
return (I * deltaX / 3);
}
8 changes: 3 additions & 5 deletions GeneratorInterface/GenExtensions/bin/BCVEGPY/main.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
extern "C"
{
void bcvegpy_();
extern "C" {
void bcvegpy_();
}

int main()
{
int main() {
bcvegpy_();
return 1;
}
17 changes: 6 additions & 11 deletions SimDataFormats/GeneratorProducts/src/hepmc_rootio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,22 @@
#include <iostream>

//HACK We need to change the internals of GenVertex when reading
// back via ROOT. We use the private access of GenEvent to
// back via ROOT. We use the private access of GenEvent to
// accomplish it.
namespace HepMC {
class GenEvent {
public:
static void clear_particles_in(HepMC::GenVertex* iVertex) {
iVertex->m_particles_in.clear();
}
static void clear_particles_in(HepMC::GenVertex* iVertex) { iVertex->m_particles_in.clear(); }
static void add_to_particles_in(HepMC::GenVertex* iVertex, HepMC::GenParticle* iPart) {
iVertex->m_particles_in.push_back(iPart);
}
};
}

} // namespace HepMC

namespace hepmc_rootio {
namespace hepmc_rootio {
void add_to_particles_in(HepMC::GenVertex* iVertex, HepMC::GenParticle* iPart) {
HepMC::GenEvent::add_to_particles_in(iVertex, iPart);
}

void clear_particles_in(HepMC::GenVertex* iVertex) {
HepMC::GenEvent::clear_particles_in(iVertex);
}
}
void clear_particles_in(HepMC::GenVertex* iVertex) { HepMC::GenEvent::clear_particles_in(iVertex); }
} // namespace hepmc_rootio
42 changes: 20 additions & 22 deletions SimDataFormats/GeneratorProducts/test/rootio_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,28 @@ int main() {
constexpr int eventNumber = 10;
{
TFile oFile("rootio_t.root", "RECREATE");
TTree events("Events","Events");
TTree events("Events", "Events");

HepMC::GenEvent event;

auto vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
auto vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));

constexpr double kMass = 1.;
constexpr double kMom = 1.;
const double kEnergy = sqrt( kMass*kMass+kMom*kMom);
const double kEnergy = sqrt(kMass * kMass + kMom * kMom);
constexpr int id = 11;

auto p1 = new HepMC::GenParticle(HepMC::FourVector{kMom,0.,0.,kEnergy}, id, 1);
auto p1 = new HepMC::GenParticle(HepMC::FourVector{kMom, 0., 0., kEnergy}, id, 1);

p1->suggest_barcode(1);
vtx->add_particle_out(p1);


auto p2 = new HepMC::GenParticle(HepMC::FourVector{-kMom,0.,0.,kEnergy}, -id, 1);
auto p2 = new HepMC::GenParticle(HepMC::FourVector{-kMom, 0., 0., kEnergy}, -id, 1);

p2->suggest_barcode(2);
vtx->add_particle_out(p2);

auto decayVtx = new HepMC::GenVertex(HepMC::FourVector(1.,0.,0.));
auto decayVtx = new HepMC::GenVertex(HepMC::FourVector(1., 0., 0.));
decayVtx->add_particle_in(p1);

event.add_vertex(vtx);
Expand All @@ -43,10 +42,10 @@ int main() {

HepMC::GenEvent* pEv = &event;

events.Branch("GenEvent",&pEv);
events.Branch("GenEvent", &pEv);

events.Fill();

oFile.Write();
oFile.Close();
}
Expand All @@ -55,35 +54,34 @@ int main() {
{
TFile iFile("rootio_t.root");

TTree* events = dynamic_cast<TTree*>( iFile.Get("Events") );
TTree* events = dynamic_cast<TTree*>(iFile.Get("Events"));

HepMC::GenEvent event;
HepMC::GenEvent* pEv = &event;
events->SetBranchAddress("GenEvent",&pEv);
events->SetBranchAddress("GenEvent", &pEv);

events->GetEntry(0);

assert(event.event_number() == eventNumber);
assert(event.particles_size() == 2);
assert(event.vertices_size() == 2);

int barcode = 1;
for(auto it = event.particles_begin(); it != event.particles_end(); ++it) {
if((*it)->production_vertex()) {
for (auto it = event.particles_begin(); it != event.particles_end(); ++it) {
if ((*it)->production_vertex()) {
auto vtx = (*it)->production_vertex();
assert( std::find(vtx->particles_out_const_begin(), vtx->particles_out_const_end(), *it) != vtx->particles_out_const_end());
assert(std::find(vtx->particles_out_const_begin(), vtx->particles_out_const_end(), *it) !=
vtx->particles_out_const_end());
}
if((*it)->end_vertex()) {
if ((*it)->end_vertex()) {
auto vtx = (*it)->end_vertex();
assert( std::find(vtx->particles_in_const_begin(), vtx->particles_in_const_end(), *it) != vtx->particles_in_const_end());
assert(std::find(vtx->particles_in_const_begin(), vtx->particles_in_const_end(), *it) !=
vtx->particles_in_const_end());
}

assert( (*it)->barcode() == barcode);
assert( *it == event.barcode_to_particle( (*it)->barcode() ) );
assert((*it)->barcode() == barcode);
assert(*it == event.barcode_to_particle((*it)->barcode()));
++barcode;
}


}

}

0 comments on commit f5f7ed5

Please sign in to comment.