CMS 3D CMS Logo

SubEventGenJetProducer.cc
Go to the documentation of this file.
1 
4 
9 
10 using namespace std;
11 using namespace reco;
12 using namespace edm;
13 using namespace cms;
14 
15 namespace {
16  bool checkHydro(const reco::GenParticle* p) {
17  const Candidate* m1 = p->mother();
18  while (m1) {
19  int pdg = abs(m1->pdgId());
20  int st = m1->status();
21  LogDebug("SubEventMothers") << "Pdg ID : " << pdg << endl;
22  if (st == 3 || pdg < 9 || pdg == 21) {
23  LogDebug("SubEventMothers") << "Sub-Collision Found! Pdg ID : " << pdg << endl;
24  return false;
25  }
26  const Candidate* m = m1->mother();
27  m1 = m;
28  if (!m1)
29  LogDebug("SubEventMothers") << "No Mother, particle is : " << pdg << " with status " << st << endl;
30  }
31  // return true;
32  return true; // Debugging - to be changed
33  }
34 } // namespace
35 
36 SubEventGenJetProducer::SubEventGenJetProducer(edm::ParameterSet const& conf) : VirtualJetProducer(conf) {
37  ignoreHydro_ = conf.getUntrackedParameter<bool>("ignoreHydro", true);
38 
39  // the subjet collections are set through the config file in the "jetCollInstanceName" field.
40 
41  input_cand_token_ = consumes<reco::CandidateView>(src_);
42 }
43 
45  std::vector<edm::Ptr<reco::Candidate>>::const_iterator inBegin = inputs_.begin(), inEnd = inputs_.end(), i = inBegin;
46  for (; i != inEnd; ++i) {
47  reco::CandidatePtr input = inputs_[i - inBegin];
48  if (edm::isNotFinite(input->pt()))
49  continue;
50  if (input->et() < inputEtMin_)
51  continue;
52  if (input->energy() < inputEMin_)
53  continue;
55  continue;
56 
57  edm::Ptr<reco::Candidate> p = inputs_[i - inBegin];
58  const GenParticle* pref = dynamic_cast<const GenParticle*>(p.get());
59  int subevent = pref->collisionId();
60  LogDebug("SubEventContainers") << "SubEvent is : " << subevent << endl;
61  LogDebug("SubEventContainers") << "SubSize is : " << subInputs_.size() << endl;
62 
63  if (subevent >= (int)subInputs_.size()) {
64  hydroTag_.resize(subevent + 1, -1);
65  subInputs_.resize(subevent + 1);
66  LogDebug("SubEventContainers") << "SubSize is : " << subInputs_.size() << endl;
67  LogDebug("SubEventContainers") << "HydroTagSize is : " << hydroTag_.size() << endl;
68  }
69 
70  LogDebug("SubEventContainers") << "HydroTag is : " << hydroTag_[subevent] << endl;
71  if (hydroTag_[subevent] != 0)
72  hydroTag_[subevent] = (int)checkHydro(pref);
73 
74  subInputs_[subevent].push_back(fastjet::PseudoJet(input->px(), input->py(), input->pz(), input->energy()));
75 
76  subInputs_[subevent].back().set_user_index(i - inBegin);
77  }
78 }
79 
81  LogDebug("VirtualJetProducer") << "Entered produce\n";
82 
83  fjJets_.clear();
84  subInputs_.clear();
85  nSubParticles_.clear();
86  hydroTag_.clear();
87  inputs_.clear();
88 
89  // get inputs and convert them to the fastjet format (fastjet::PeudoJet)
91  iEvent.getByToken(input_cand_token_, inputsHandle);
92  for (size_t i = 0; i < inputsHandle->size(); ++i) {
93  inputs_.push_back(inputsHandle->ptrAt(i));
94  }
95  LogDebug("VirtualJetProducer") << "Got inputs\n";
96 
97  inputTowers();
98  // Convert candidates to fastjet::PseudoJets.
99  // Also correct to Primary Vertex. Will modify fjInputs_
100  // and use inputs_
101 
103 
104  jets_ = std::make_unique<std::vector<GenJet>>();
105 
106  LogDebug("VirtualJetProducer") << "Inputted towers\n";
107 
108  size_t nsub = subInputs_.size();
109 
110  for (size_t isub = 0; isub < nsub; ++isub) {
111  if (ignoreHydro_ && hydroTag_[isub])
112  continue;
113  fjJets_.clear();
114  fjInputs_.clear();
115  fjInputs_ = subInputs_[isub];
116  runAlgorithm(iEvent, iSetup);
117  }
118 
119  //Finalize
120  LogDebug("SubEventJetProducer") << "Wrote jets\n";
121 
122  iEvent.put(std::move(jets_));
123  return;
124 }
125 
127  // run algorithm
128  fjJets_.clear();
129 
130  fjClusterSeq_ = std::make_shared<fastjet::ClusterSequence>(fjInputs_, *fjJetDefinition_);
131  fjJets_ = fastjet::sorted_by_pt(fjClusterSeq_->inclusive_jets(jetPtMin_));
132 
133  using namespace reco;
134 
135  for (unsigned int ijet = 0; ijet < fjJets_.size(); ++ijet) {
136  GenJet jet;
137  const fastjet::PseudoJet& fjJet = fjJets_[ijet];
138 
139  std::vector<fastjet::PseudoJet> fjConstituents = sorted_by_pt(fjClusterSeq_->constituents(fjJet));
140 
141  std::vector<CandidatePtr> constituents = getConstituents(fjConstituents);
142 
143  double px = fjJet.px();
144  double py = fjJet.py();
145  double pz = fjJet.pz();
146  double E = fjJet.E();
147  double jetArea = 0.0;
148  double pu = 0.;
149 
150  writeSpecific(jet, Particle::LorentzVector(px, py, pz, E), vertex_, constituents, iSetup);
151 
152  jet.setJetArea(jetArea);
153  jet.setPileup(pu);
154 
155  jets_->push_back(jet);
156  }
157 }
158 
cms::SubEventGenJetProducer
Definition: SubEventGenJetProducer.h:19
reco::writeSpecific
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, edm::EventSetup const &c)
Definition: JetSpecific.cc:34
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
reco::GenParticle::collisionId
int collisionId() const
Definition: GenParticle.h:36
cms::SubEventGenJetProducer::runAlgorithm
void runAlgorithm(edm::Event &, const edm::EventSetup &) override
Definition: SubEventGenJetProducer.cc:126
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
reco::GenParticle
Definition: GenParticle.h:21
cms::SubEventGenJetProducer::input_cand_token_
edm::EDGetTokenT< reco::CandidateView > input_cand_token_
Definition: SubEventGenJetProducer.h:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
cms::SubEventGenJetProducer::hydroTag_
std::vector< int > hydroTag_
Definition: SubEventGenJetProducer.h:29
reco::Candidate::status
virtual int status() const =0
status word
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
reco::Candidate::mother
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
edm::Handle
Definition: AssociativeIterator.h:50
GenParticle
Definition: GenParticle.py:1
VirtualJetProducer::vertex_
reco::Particle::Point vertex_
Definition: VirtualJetProducer.h:184
VirtualJetProducer::fjClusterSeq_
ClusterSequencePtr fjClusterSeq_
Definition: VirtualJetProducer.h:185
cms::SubEventGenJetProducer::jets_
std::unique_ptr< std::vector< reco::GenJet > > jets_
Definition: SubEventGenJetProducer.h:28
cms::SubEventGenJetProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: SubEventGenJetProducer.cc:80
GenParticle.h
VirtualJetProducer::inputEtMin_
double inputEtMin_
Definition: VirtualJetProducer.h:153
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
cms::SubEventGenJetProducer::inputTowers
void inputTowers() override
Definition: SubEventGenJetProducer.cc:44
nsub
const int nsub
Definition: CMTRawAnalyzer.h:421
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:78
VirtualJetProducer
Definition: VirtualJetProducer.h:35
VirtualJetProducer::inputs_
std::vector< edm::Ptr< reco::Candidate > > inputs_
Definition: VirtualJetProducer.h:183
edm::View::size
size_type size() const
VirtualJetProducer::src_
edm::InputTag src_
Definition: VirtualJetProducer.h:148
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
SubEventGenJetProducer.h
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
VirtualJetProducer::isAnomalousTower
virtual bool isAnomalousTower(reco::CandidatePtr input)
Definition: VirtualJetProducer.cc:499
VirtualJetProducer::jetPtMin_
double jetPtMin_
Definition: VirtualJetProducer.h:155
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
cms::SubEventGenJetProducer::ignoreHydro_
bool ignoreHydro_
Definition: SubEventGenJetProducer.h:31
cms::SubEventGenJetProducer::nSubParticles_
std::vector< int > nSubParticles_
Definition: SubEventGenJetProducer.h:30
edm::EventSetup
Definition: EventSetup.h:58
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
edm::Ptr< Candidate >
reco::Candidate
Definition: Candidate.h:27
reco::JetExtendedAssociation::LorentzVector
math::PtEtaPhiELorentzVectorF LorentzVector
Definition: JetExtendedAssociation.h:25
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
cms::SubEventGenJetProducer::subInputs_
std::vector< std::vector< fastjet::PseudoJet > > subInputs_
Definition: SubEventGenJetProducer.h:27
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
VirtualJetProducer::getConstituents
virtual std::vector< reco::CandidatePtr > getConstituents(const std::vector< fastjet::PseudoJet > &fjConstituents)
Definition: VirtualJetProducer.cc:522
isFinite.h
metsig::jet
Definition: SignAlgoResolutions.h:47
VirtualJetProducer::fjJets_
std::vector< fastjet::PseudoJet > fjJets_
Definition: VirtualJetProducer.h:192
VirtualJetProducer::fjJetDefinition_
JetDefPtr fjJetDefinition_
Definition: VirtualJetProducer.h:186
JetSpecific.h
pdg
Definition: pdg_functions.h:28
Exception.h
muons2muons_cfi.pu
pu
Definition: muons2muons_cfi.py:31
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
VirtualJetProducer::fjInputs_
std::vector< fastjet::PseudoJet > fjInputs_
Definition: VirtualJetProducer.h:191
edm::Event
Definition: Event.h:73
edm::View::ptrAt
Ptr< value_type > ptrAt(size_type i) const
VirtualJetProducer::inputEMin_
double inputEMin_
Definition: VirtualJetProducer.h:154
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21