26 |
|
#include "Geometry/CaloGeometry/interface/CaloGeometry.h" |
27 |
|
#include "Geometry/Records/interface/CaloGeometryRecord.h" |
28 |
|
#include "SimDataFormats/HiGenData/interface/SubEventMap.h" |
29 |
– |
#include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h" |
29 |
|
#include "DataFormats/HepMCCandidate/interface/GenParticle.h" |
30 |
|
#include "FWCore/Framework/interface/ESHandle.h" |
31 |
|
#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" |
37 |
|
using namespace JetReco; |
38 |
|
|
39 |
|
namespace { |
41 |
– |
const bool debug = false; |
40 |
|
|
41 |
< |
bool selectForJet(const reco::GenParticle& par){ |
44 |
< |
if(par.status() != 1) return false; |
41 |
> |
bool checkHydro(GenParticleRef& p){ |
42 |
|
|
43 |
< |
// Below to be FIXED!!! What is a Jet??? |
44 |
< |
if(abs(par.pdgId()) == 11 || abs(par.pdgId()) == 12 || |
45 |
< |
abs(par.pdgId()) == 13 ||abs(par.pdgId()) == 14 || |
46 |
< |
abs(par.pdgId()) == 15 ||abs(par.pdgId()) == 16 |
47 |
< |
) return false; |
48 |
< |
|
49 |
< |
return true; |
43 |
> |
const Candidate* m1 = p->mother(); |
44 |
> |
while(m1){ |
45 |
> |
int pdg = abs(m1->pdgId()); |
46 |
> |
LogDebug("SubEventMothers")<<"Pdg ID : "<<pdg<<endl; |
47 |
> |
if(pdg < 9 || pdg == 21){ |
48 |
> |
LogDebug("SubEventMothers")<<"Parton Found! Pdg ID : "<<pdg<<endl; |
49 |
> |
return false; |
50 |
> |
} |
51 |
> |
const Candidate* m = m1->mother(); |
52 |
> |
m1 = m; |
53 |
> |
} |
54 |
> |
return true; |
55 |
|
} |
56 |
< |
|
56 |
> |
|
57 |
> |
const bool debug = false; |
58 |
|
|
59 |
|
bool makeCaloJet (const string& fTag) { |
60 |
|
return fTag == "CaloJet"; |
86 |
|
fJet->setNPasses (fProtojet.nPasses ()); |
87 |
|
} |
88 |
|
|
89 |
< |
void copyConstituents (const JetReco::InputCollection& fConstituents, const reco::GenParticleCollection& fInput, reco::Jet* fJet) { |
90 |
< |
// put constituents |
91 |
< |
for (unsigned iConstituent = 0; iConstituent < fConstituents.size (); ++iConstituent) { |
92 |
< |
fJet->addDaughter (fInput[fConstituents[iConstituent].index ()].sourceCandidatePtr(0)); |
93 |
< |
} |
94 |
< |
} |
95 |
< |
|
89 |
> |
void copyConstituents (const JetReco::InputCollection& fConstituents, const edm::View <Candidate>& fInput, reco::Jet* fJet) { |
90 |
> |
// put constituents |
91 |
> |
for (unsigned iConstituent = 0; iConstituent < fConstituents.size (); ++iConstituent) { |
92 |
> |
fJet->addDaughter (fInput.ptrAt (fConstituents[iConstituent].index ())); |
93 |
> |
} |
94 |
> |
} |
95 |
> |
|
96 |
|
} |
97 |
|
|
98 |
|
namespace cms |
100 |
|
// Constructor takes input parameters now: to be replaced with parameter set. |
101 |
|
BaseHiGenJetProducer::BaseHiGenJetProducer(const edm::ParameterSet& conf) |
102 |
|
: mSrc(conf.getParameter<edm::InputTag>( "src")), |
103 |
+ |
mapSrc(conf.getParameter<edm::InputTag>( "srcMap")), |
104 |
|
mJetType (conf.getParameter<string>( "jetType")), |
105 |
|
mVerbose (conf.getUntrackedParameter<bool>("verbose", false)), |
106 |
|
mEtInputCut (conf.getParameter<double>("inputEtMin")), |
107 |
|
mEInputCut (conf.getParameter<double>("inputEMin")), |
108 |
< |
skipLastSubEvent_ (conf.getUntrackedParameter<bool>("skipLastSubEvent", true)), |
109 |
< |
nHydro_(conf.getUntrackedParameter<double>("maxParticles", 2000)) |
108 |
> |
ignoreHydro_ (conf.getUntrackedParameter<bool>("ignoreHydro", true)), |
109 |
> |
nMax_(conf.getUntrackedParameter<double>("maxParticles", 2000)) |
110 |
|
{ |
111 |
|
std::string alias = conf.getUntrackedParameter<string>( "alias", conf.getParameter<std::string>("@module_label")); |
112 |
|
if (makeCaloJet (mJetType)) { |
131 |
|
{ |
132 |
|
using namespace reco; |
133 |
|
|
134 |
< |
edm::Handle<GenParticleCollection> inputHandle; |
134 |
> |
edm::Handle< edm::View<Candidate> > inputHandle; |
135 |
|
e.getByLabel(mSrc,inputHandle); |
136 |
|
|
137 |
|
edm::Handle<edm::SubEventMap> subs; |
138 |
< |
e.getByLabel(mSrc,subs); |
138 |
> |
e.getByLabel(mapSrc,subs); |
139 |
|
|
140 |
|
vector <ProtoJet> output; |
141 |
|
vector<JetReco::InputCollection> inputs; |
142 |
|
|
139 |
– |
int hydroEvent = -1; |
143 |
|
vector<int> nsubparticle; |
144 |
+ |
vector<int> hydroTag; |
145 |
|
|
146 |
|
for (unsigned i = 0; i < inputHandle->size(); ++i) { |
147 |
< |
|
148 |
< |
const GenParticle & p = (*inputHandle)[i]; |
149 |
< |
if(!selectForJet(p)) continue; |
146 |
< |
int subevent = (*subs)[GenParticleRef(inputHandle,i)]; |
147 |
> |
|
148 |
> |
GenParticleRef pref = inputHandle->refAt(i).castTo<GenParticleRef>(); |
149 |
> |
int subevent = (*subs)[pref]; |
150 |
|
LogDebug("SubEventJets")<<"inputs size "<<inputs.size()<<" subevent "<<subevent; |
151 |
< |
|
151 |
> |
|
152 |
|
if(subevent >= inputs.size()){ |
153 |
+ |
// hydroTag.push_back(-1); |
154 |
+ |
hydroTag.resize(subevent+1); |
155 |
+ |
hydroTag[subevent] = -1; |
156 |
|
inputs.resize(subevent+1); |
157 |
|
nsubparticle.resize(subevent+1); |
158 |
|
} |
159 |
< |
// cout<<"inputs size "<<inputs.size()<<" subevent "<<subevent<<endl; |
160 |
< |
if(nsubparticle[subevent]< nHydro_){ |
161 |
< |
(inputs[subevent]).push_back(JetReco::InputItem(&p,i)); |
159 |
> |
|
160 |
> |
if(hydroTag[subevent]<0) hydroTag[subevent] = (int)checkHydro(pref); |
161 |
> |
|
162 |
> |
if(nsubparticle[subevent]> nMax_ && hydroTag[subevent] != 1){ |
163 |
> |
LogDebug("JetsInHydro")<<"More particles than maximum particles cut, although not previously identified as sub-event, Sub-Event : "<<subevent; |
164 |
> |
|
165 |
> |
hydroTag[subevent] = 1; |
166 |
> |
} |
167 |
> |
|
168 |
> |
|
169 |
> |
if(hydroTag[subevent] != 1){ |
170 |
> |
(inputs[subevent]).push_back(JetReco::InputItem(&((*inputHandle)[i]),i)); |
171 |
|
nsubparticle[subevent]++; |
157 |
– |
}else{ |
158 |
– |
LogDebug("JetsInHydro")<<"More particles than hydro cut, Sub-Event : "<<subevent; |
159 |
– |
if(subevent != hydroEvent && hydroEvent != -1){ |
160 |
– |
edm::LogError("JetsInHydro")<<"More than one hydro event identified, Sub-Event : "<<subevent; |
161 |
– |
} |
162 |
– |
hydroEvent = subevent; |
172 |
|
} |
173 |
|
} |
174 |
< |
|
174 |
> |
|
175 |
|
int nsub = inputs.size(); |
176 |
+ |
|
177 |
|
for(int isub = 0; isub < nsub; ++isub){ |
178 |
|
cout<<"Processing Sub-Event : "<<isub<<endl; |
179 |
|
JetReco::InputCollection & input = inputs[isub]; |
180 |
< |
// if(skipLastSubEvent_ && isub == nsub-1){ |
181 |
< |
if(isub == hydroEvent){ |
172 |
< |
cout<<"Sub-Event number "<<isub<<" with more than "<<input.size()<<" particles, skipped as background event."<<endl; |
180 |
> |
if(hydroTag[isub] == 1){ |
181 |
> |
cout<<"Sub-Event number "<<isub<<" with more than "<<input.size()<<" particles, skipped as background event. Number of total sub-events: "<<nsub<<endl; |
182 |
|
}else{ |
183 |
|
|
184 |
|
if (mVerbose) { |