Skip to content

Commit

Permalink
code checks and format
Browse files Browse the repository at this point in the history
  • Loading branch information
mandrenguyen committed Oct 7, 2020
1 parent fb1c496 commit b270197
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 75 deletions.
92 changes: 41 additions & 51 deletions RecoHI/HiJetAlgos/plugins/HiSignalGenJetProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,26 @@
using namespace std;
using namespace edm;


//
// class decleration
//

class HiSignalGenJetProducer : public edm::EDProducer {
public:
explicit HiSignalGenJetProducer(const edm::ParameterSet&);
~HiSignalGenJetProducer();

private:
virtual void produce(edm::Event&, const edm::EventSetup&) override;
// ----------member data ---------------------------
explicit HiSignalGenJetProducer(const edm::ParameterSet&);
~HiSignalGenJetProducer() override;

edm::EDGetTokenT<edm::View<reco::GenJet> > jetSrc_;
private:
void produce(edm::Event&, const edm::EventSetup&) override;
// ----------member data ---------------------------

edm::EDGetTokenT<edm::View<reco::GenJet> > jetSrc_;
};

//
// constants, enums and typedefs
//


//
// static data member definitions
//
Expand All @@ -72,67 +69,60 @@ class HiSignalGenJetProducer : public edm::EDProducer {
// constructors and destructor
//

HiSignalGenJetProducer::HiSignalGenJetProducer(const edm::ParameterSet& iConfig) :
jetSrc_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src")))
{
std::string alias = (iConfig.getParameter<InputTag>( "src")).label();
produces<reco::GenJetCollection>().setBranchAlias (alias);
HiSignalGenJetProducer::HiSignalGenJetProducer(const edm::ParameterSet& iConfig)
: jetSrc_(consumes<edm::View<reco::GenJet> >(iConfig.getParameter<edm::InputTag>("src"))) {
std::string alias = (iConfig.getParameter<InputTag>("src")).label();
produces<reco::GenJetCollection>().setBranchAlias(alias);
}

HiSignalGenJetProducer::~HiSignalGenJetProducer()
{
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
HiSignalGenJetProducer::~HiSignalGenJetProducer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}


//
// member functions
//

// ------------ method called to produce the data ------------

void
HiSignalGenJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;
using namespace reco;
void HiSignalGenJetProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
using namespace reco;

auto jets = std::make_unique<GenJetCollection>();
auto jets = std::make_unique<GenJetCollection>();

edm::Handle<edm::View<GenJet> > genjets;
iEvent.getByToken(jetSrc_,genjets);
edm::Handle<edm::View<GenJet> > genjets;
iEvent.getByToken(jetSrc_, genjets);

int jetsize = genjets->size();
int jetsize = genjets->size();

vector<int> selection;
for(int ijet = 0; ijet < jetsize; ++ijet){
selection.push_back(-1);
}
vector<int> selection;
selection.reserve(jetsize);
for (int ijet = 0; ijet < jetsize; ++ijet) {
selection.push_back(-1);
}

vector<int> selectedIndices;
vector<int> removedIndices;
vector<int> selectedIndices;
vector<int> removedIndices;

for(int ijet = 0; ijet < jetsize; ++ijet){
for (int ijet = 0; ijet < jetsize; ++ijet) {
const GenJet* jet1 = &((*genjets)[ijet]);

const GenJet* jet1 = &((*genjets)[ijet]);
const GenParticle* gencon = jet1->getGenConstituent(0);

const GenParticle* gencon = jet1->getGenConstituent(0);

if(gencon == 0) throw cms::Exception("GenConstituent","GenJet is missing its constituents");
else if(gencon->collisionId() == 0){
jets->push_back(*jet1);
selection[ijet] = 1;
}else{
selection[ijet] = 0;
removedIndices.push_back(ijet);
}
}

iEvent.put(std::move(jets));
if (gencon == nullptr)
throw cms::Exception("GenConstituent", "GenJet is missing its constituents");
else if (gencon->collisionId() == 0) {
jets->push_back(*jet1);
selection[ijet] = 1;
} else {
selection[ijet] = 0;
removedIndices.push_back(ijet);
}
}

iEvent.put(std::move(jets));
}

DEFINE_FWK_MODULE(HiSignalGenJetProducer);


37 changes: 14 additions & 23 deletions RecoHI/HiJetAlgos/plugins/HiSignalParticleProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,26 @@
using namespace std;
using namespace edm;


//
// class decleration
//

class HiSignalParticleProducer : public edm::EDProducer {
public:
explicit HiSignalParticleProducer(const edm::ParameterSet&);
~HiSignalParticleProducer();
~HiSignalParticleProducer() override;

private:
virtual void produce(edm::Event&, const edm::EventSetup&) override;
void produce(edm::Event&, const edm::EventSetup&) override;
// ----------member data ---------------------------

edm::EDGetTokenT<edm::View<reco::GenParticle> > genParticleSrc_;

};

//
// constants, enums and typedefs
//


//
// static data member definitions
//
Expand All @@ -71,61 +68,55 @@ class HiSignalParticleProducer : public edm::EDProducer {
// constructors and destructor
//

HiSignalParticleProducer::HiSignalParticleProducer(const edm::ParameterSet& iConfig) :
genParticleSrc_(consumes<edm::View<reco::GenParticle> >(iConfig.getParameter<edm::InputTag>("src")))
{
std::string alias = (iConfig.getParameter<InputTag>( "src")).label();
produces<reco::GenParticleCollection>().setBranchAlias (alias);
HiSignalParticleProducer::HiSignalParticleProducer(const edm::ParameterSet& iConfig)
: genParticleSrc_(consumes<edm::View<reco::GenParticle> >(iConfig.getParameter<edm::InputTag>("src"))) {
std::string alias = (iConfig.getParameter<InputTag>("src")).label();
produces<reco::GenParticleCollection>().setBranchAlias(alias);
}

HiSignalParticleProducer::~HiSignalParticleProducer()
{
HiSignalParticleProducer::~HiSignalParticleProducer() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}


//
// member functions
//

// ------------ method called to produce the data ------------

void
HiSignalParticleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
void HiSignalParticleProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
using namespace reco;

auto signalGenParticles = std::make_unique<GenParticleCollection>();

edm::Handle<edm::View<GenParticle> > genParticles;
iEvent.getByToken(genParticleSrc_,genParticles);
iEvent.getByToken(genParticleSrc_, genParticles);

int genParticleSize = genParticles->size();

vector<int> selection;
for(int igenParticle = 0; igenParticle < genParticleSize; ++igenParticle){
selection.reserve(genParticleSize);
for (int igenParticle = 0; igenParticle < genParticleSize; ++igenParticle) {
selection.push_back(-1);
}

vector<int> selectedIndices;
vector<int> removedIndices;

for(int igenParticle = 0; igenParticle < genParticleSize; ++igenParticle){

for (int igenParticle = 0; igenParticle < genParticleSize; ++igenParticle) {
const GenParticle* genParticle = &((*genParticles)[igenParticle]);
if(genParticle->collisionId() == 0){
if (genParticle->collisionId() == 0) {
signalGenParticles->push_back(*genParticle);
selection[igenParticle] = 1;
}else{
} else {
selection[igenParticle] = 0;
removedIndices.push_back(igenParticle);
}
}

iEvent.put(std::move(signalGenParticles));

}

DEFINE_FWK_MODULE(HiSignalParticleProducer);
2 changes: 1 addition & 1 deletion RecoJets/JetProducers/plugins/SubEventGenJetProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace cms {
void runAlgorithm(edm::Event&, const edm::EventSetup&) override;

protected:
std::vector<std::vector<fastjet::PseudoJet> > subInputs_;
std::vector<std::vector<fastjet::PseudoJet>> subInputs_;
std::unique_ptr<std::vector<reco::GenJet>> jets_;
std::vector<int> hydroTag_;
std::vector<int> nSubParticles_;
Expand Down

0 comments on commit b270197

Please sign in to comment.