CMS 3D CMS Logo

HiGenCleaner.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HiGenCleaner
4 // Class: HiGenCleaner
5 //
13 //
14 // Original Author: Yetkin Yilmaz
15 // Created: Tue Jul 21 04:26:01 EDT 2009
16 //
17 //
18 
19 // system include files
21 #include <memory>
22 #include <vector>
23 
24 // user include files
27 
30 
33 
39 
42 
43 using namespace std;
44 using namespace edm;
45 
46 //
47 // class decleration
48 //
49 
50 //
51 // constants, enums and typedefs
52 //
53 
54 //
55 // static data member definitions
56 //
57 
58 //
59 // constructors and destructor
60 //
61 
62 template <class T2>
64  : jetSrc_(consumes<edm::View<T2> >(iConfig.getParameter<edm::InputTag>("src"))),
65  deltaR_(iConfig.getParameter<double>("deltaR")),
66  ptCut_(iConfig.getParameter<double>("ptCut")),
67  makeNew_(iConfig.getUntrackedParameter<bool>("createNewCollection", true)),
68  fillDummy_(iConfig.getUntrackedParameter<bool>("fillDummyEntries", true)) {
69  std::string alias = (iConfig.getParameter<InputTag>("src")).label();
70  produces<T2Collection>().setBranchAlias(alias);
71 }
72 
73 template <class T2>
75  // do anything here that needs to be done at desctruction time
76  // (e.g. close files, deallocate resources etc.)
77 }
78 
79 //
80 // member functions
81 //
82 
83 // ------------ method called to produce the data ------------
84 template <class T2>
86  using namespace edm;
87  using namespace reco;
88 
89  auto jets = std::make_unique<T2Collection>();
90 
91  edm::Handle<edm::View<T2> > genjets;
92  iEvent.getByToken(jetSrc_, genjets);
93 
94  int jetsize = genjets->size();
95 
96  vector<int> selection;
97  for (int ijet = 0; ijet < jetsize; ++ijet) {
98  selection.push_back(-1);
99  }
100 
101  vector<int> selectedIndices;
102  vector<int> removedIndices;
103 
104  for (int ijet = 0; ijet < jetsize; ++ijet) {
105  const T2* jet1 = &((*genjets)[ijet]);
106 
107  if (selection[ijet] == -1) {
108  selection[ijet] = 1;
109  for (int ijet2 = 0; ijet2 < jetsize; ++ijet2) {
110  if (ijet2 == ijet)
111  continue;
112 
113  const T2* jet2 = &((*genjets)[ijet2]);
114 
115  if (Geom::deltaR(jet1->momentum(), jet2->momentum()) < deltaR_) {
116  if (jet1->et() < jet2->et()) {
117  selection[ijet] = 0;
118  removedIndices.push_back(ijet);
119  break;
120  } else {
121  selection[ijet2] = 0;
122  removedIndices.push_back(ijet2);
123  }
124  }
125  }
126  }
127 
128  double etjet = ((*genjets)[ijet]).et();
129 
130  if (selection[ijet] == 1 && etjet > ptCut_) {
131  selectedIndices.push_back(ijet);
132  jets->push_back(*jet1);
133  }
134  }
135  iEvent.put(std::move(jets));
136 }
137 
138 template class HiGenCleaner<reco::GenParticle>;
139 template class HiGenCleaner<reco::GenJet>;
edm::StreamID
Definition: StreamID.h:30
GenJetCollection.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
EDProducer.h
VectorUtil.h
edm
HLT enums.
Definition: AlignableModifier.h:19
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
HiGenCleaner::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: HiGenCleaner.cc:85
GenParticle.h
MakerMacros.h
HiGenCleaner::~HiGenCleaner
~HiGenCleaner() override
Definition: HiGenCleaner.cc:74
GenParticleFwd.h
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
HiGenCleaner::HiGenCleaner
HiGenCleaner(const edm::ParameterSet &)
Definition: HiGenCleaner.cc:63
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
LorentzVector.h
iEvent
int iEvent
Definition: GenABIO.cc:224
EgHLTOffHistBins_cfi.et
et
Definition: EgHLTOffHistBins_cfi.py:8
edm::EventSetup
Definition: EventSetup.h:57
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:129
Point3D.h
View.h
ParameterSet.h
edm::Event
Definition: Event.h:73
HiGenCleaner.h
edm::InputTag
Definition: InputTag.h:15
HiGenCleaner
Definition: HiGenCleaner.h:41