Skip to content

Commit

Permalink
Clang-Format
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsbuild committed May 15, 2019
1 parent f49614b commit 08cd101
Show file tree
Hide file tree
Showing 161 changed files with 8,462 additions and 10,065 deletions.
49 changes: 20 additions & 29 deletions IOMC/Input/interface/HepMCFileReader.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef Input_HepMCFileReader_h
#define Input_HepMCFileReader_h


/** \class HepMCFileReader
*
* This class is used by the implementation of DaqEventFactory present
Expand All @@ -12,7 +11,7 @@
* it exposes.
*
* \author G. Bruno - CERN, EP Division
*/
*/

#include <vector>
#include <map>
Expand All @@ -23,60 +22,52 @@ namespace HepMC {
class IO_BaseClass;
class GenEvent;
class GenParticle;
}

} // namespace HepMC

class HepMCFileReader {

protected:
protected:
HepMCFileReader();
public:
virtual ~HepMCFileReader();
virtual void initialize(const std::string &filename);

public:
virtual ~HepMCFileReader();
virtual void initialize(const std::string &filename);
inline bool isInitialized() const;

virtual bool setEvent(int event);
virtual bool readCurrentEvent();
virtual bool printHepMcEvent() const;
virtual bool printHepMcEvent() const;
HepMC::GenEvent *fillCurrentEventData();
// virtual bool fillEventData(HepMC::GenEvent *event);
// this method prints the event information as
// this method prints the event information as
// obtained by the input file in HepEvt style
void printEvent() const;
// get all the 'integer' properties of a particle
// get all the 'integer' properties of a particle
// like mother, daughter, pid and status
// 'j' is the number of the particle in the HepMc
virtual void getStatsFromTuple(int &mo1, int &mo2, int &da1, int &da2,
int &status, int &pid, int j) const;
virtual void getStatsFromTuple(int &mo1, int &mo2, int &da1, int &da2, int &status, int &pid, int j) const;
virtual void ReadStats();

static HepMCFileReader *instance();

private:
HepMC::IO_BaseClass const* input() const {return get_underlying_safe(input_);}
HepMC::IO_BaseClass*& input() {return get_underlying_safe(input_);}
private:
HepMC::IO_BaseClass const *input() const { return get_underlying_safe(input_); }
HepMC::IO_BaseClass *&input() { return get_underlying_safe(input_); }

// current HepMC evt
edm::propagate_const<HepMC::GenEvent*> evt_;
edm::propagate_const<HepMC::IO_BaseClass*> input_;
edm::propagate_const<HepMC::GenEvent *> evt_;
edm::propagate_const<HepMC::IO_BaseClass *> input_;

static HepMCFileReader *instance_;

int rdstate() const;
//maps to convert HepMC::GenParticle to particles # and vice versa
// -> needed for HepEvt like output
std::vector<HepMC::GenParticle*> index_to_particle;
std::map<HepMC::GenParticle*,int> particle_to_index;
std::vector<HepMC::GenParticle *> index_to_particle;
std::map<HepMC::GenParticle *, int> particle_to_index;
// find index to HepMC::GenParticle* p in map m
int find_in_map(const std::map<HepMC::GenParticle*,int>& m,
HepMC::GenParticle *p) const;
int find_in_map(const std::map<HepMC::GenParticle *, int> &m, HepMC::GenParticle *p) const;
};


bool HepMCFileReader::isInitialized() const
{
return input_ != nullptr;
}
bool HepMCFileReader::isInitialized() const { return input_ != nullptr; }

#endif
8 changes: 4 additions & 4 deletions IOMC/Input/interface/MCFileSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class HepMCFileReader;

namespace HepMC{
namespace HepMC {
class GenEvent;
}

Expand All @@ -30,13 +30,13 @@ namespace edm {

private:
bool setRunAndEventInfo(EventID&, TimeValue_t& time, EventAuxiliary::ExperimentType& eType) override;
void produce(Event &e) override;
void produce(Event& e) override;
void clear();

edm::propagate_const<HepMCFileReader*> reader_;
edm::propagate_const<HepMC::GenEvent*> evt_;
bool useExtendedAscii_;
};
}
} // namespace edm

#endif
38 changes: 13 additions & 25 deletions IOMC/Input/plugins/HepMCEventWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,42 @@

#include "HepMC/IO_GenEvent.h"


class HepMCEventWriter : public edm::EDAnalyzer {
public:
explicit HepMCEventWriter(const edm::ParameterSet &params);
~HepMCEventWriter() override;

protected:
void beginRun(const edm::Run &run, const edm::EventSetup &es) override;
void endRun(const edm::Run &run, const edm::EventSetup &es) override;
void analyze(const edm::Event &event, const edm::EventSetup &es) override;

private:
edm::propagate_const<HepMC::IO_GenEvent*> _output;
edm::propagate_const<HepMC::IO_GenEvent *> _output;
edm::InputTag hepMCProduct_;
};

HepMCEventWriter::HepMCEventWriter(const edm::ParameterSet &params) :
hepMCProduct_(params.getParameter<edm::InputTag>("hepMCProduct"))
{
}

HepMCEventWriter::~HepMCEventWriter()
{
}

void HepMCEventWriter::beginRun(const edm::Run &run, const edm::EventSetup &es)
{
HepMCEventWriter::HepMCEventWriter(const edm::ParameterSet &params)
: hepMCProduct_(params.getParameter<edm::InputTag>("hepMCProduct")) {}

_output = new HepMC::IO_GenEvent("GenEvent_ASCII.dat",std::ios::out);
HepMCEventWriter::~HepMCEventWriter() {}

void HepMCEventWriter::beginRun(const edm::Run &run, const edm::EventSetup &es) {
_output = new HepMC::IO_GenEvent("GenEvent_ASCII.dat", std::ios::out);
}


void HepMCEventWriter::endRun(const edm::Run &run, const edm::EventSetup &es)
{
if (_output) delete _output.get();
void HepMCEventWriter::endRun(const edm::Run &run, const edm::EventSetup &es) {
if (_output)
delete _output.get();
}

void HepMCEventWriter::analyze(const edm::Event &event, const edm::EventSetup &es)
{

void HepMCEventWriter::analyze(const edm::Event &event, const edm::EventSetup &es) {
edm::Handle<edm::HepMCProduct> product;
event.getByLabel(hepMCProduct_, product);

const HepMC::GenEvent* evt = product->GetEvent();
const HepMC::GenEvent *evt = product->GetEvent();

_output->write_event(evt);

}

DEFINE_FWK_MODULE(HepMCEventWriter);
Loading

0 comments on commit 08cd101

Please sign in to comment.