41 #include <Pythia8/Pythia.h> 45 #include "TLorentzVector.h" 47 #if PYTHIA_VERSION_INTEGER < 8304 71 std::map<int, TH1D*>
h_p;
72 std::map<int, TH1D*>
h_v;
108 pythia =
new Pythia8::Pythia();
126 for (
size_t i = 0;
i <
pids.size(); ++
i) {
130 if (!pdt.isParticle(pid)) {
131 edm::LogError(
"TestPythiaDecays") <<
"ERROR: BAD PARTICLE, pythia is not aware of pid " << pid;
132 throw cms::Exception(
"Unknown",
"FastSim") <<
"Bad Particle Type " << pid <<
"\n";
138 double m0 = pd->m0();
139 double w = pd->mWidth();
142 mmin = m0 - m0 / 1000.;
143 mmax = m0 + m0 / 1000.;
148 std::stringstream strstr;
149 strstr <<
"mass_" << pid;
150 h_mass[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, mmin, mmax);
151 h_mass_ref[pid] = predict.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, mmin, mmax);
157 h_mass_ref[pid]->SetBinContent(
b, TMath::BreitWigner(_val, m0,
w));
163 strstr <<
"p_" << pid;
164 h_p[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 20);
168 strstr <<
"v_" << pid;
169 h_v[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 1.);
172 double ctau0 = pd->tau0() / 10.;
174 strstr <<
"plt_" << pid;
175 h_plt[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0,
std::min(5. * ctau0, 500.));
176 h_plt_ref[pid] = predict.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0,
std::min(5. * ctau0, 500.));
178 for (
int b = 1;
b <=
h_plt_ref[pid]->GetNbinsX(); ++
b) {
179 double _val =
h_plt_ref[pid]->GetBinCenter(
b);
180 h_plt_ref[pid]->SetBinContent(
b, TMath::Exp(-_val / ctau0));
185 strstr <<
"br_" << pid;
186 h_br[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 0, 0, 0);
187 h_br[pid]->SetCanExtend(TH1::kAllAxes);
188 h_br_ref[pid] = predict.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 0, 0, 0);
189 h_br_ref[pid]->SetCanExtend(TH1::kAllAxes);
192 for (
int d = 0;
d < pd->sizeChannels(); ++
d) {
193 Pythia8::DecayChannel& channel = pd->channel(
d);
194 std::vector<int>
prod;
195 for (
int p = 0;
p < channel.multiplicity(); ++
p) {
196 int pId =
abs(channel.product(
p));
199 (pId > 10 && pId != 12 && pId != 14 && pId != 16 && pId != 18 && pId != 21 && (pId < 23 || pId > 40) &&
200 (pId < 81 || pId > 100) && pId != 2101 && pId != 3101 && pId != 3201 && pId != 1103 && pId != 2103 &&
201 pId != 2203 && pId != 3103 && pId != 3203 && pId != 3303);
203 prod.push_back(
abs(channel.product(
p)));
207 for (
size_t p = 0;
p <
prod.size(); ++
p) {
208 strstr <<
"_" <<
prod[
p];
213 h_br[pid]->SetEntries(0);
219 strstr <<
"originVertexRho_" << pid;
220 h_originVertexRho[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 200);
222 strstr <<
"originVertexZ_" << pid;
223 h_originVertexZ[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 400);
225 strstr <<
"decayVertexRho_" << pid;
226 h_decayVertexRho[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 200);
228 strstr <<
"decayVertexZ_" << pid;
229 h_decayVertexZ[pid] = observe.
make<TH1D>(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 400);
245 std::map<size_t, std::vector<size_t> > childMap;
246 std::map<size_t, int> parentMap;
247 for (
size_t j = 0;
j < simtracks->size();
j++) {
248 childMap[
j] = std::vector<size_t>();
253 for (
size_t j = 0;
j < simtracks->size();
j++) {
254 size_t childIndex =
j;
256 if (
child.noVertex())
261 size_t parentIndex =
vertex.parentIndex();
262 childMap[parentIndex].push_back(childIndex);
263 parentMap[childIndex] =
int(parentIndex);
266 for (
size_t j = 0;
j < simtracks->size();
j++) {
285 if (!childMap[
j].
empty()) {
287 const SimVertex& decayVertex = simvertices->at(
child.vertIndex());
293 for (
std::map<
size_t, std::vector<size_t> >::iterator it = childMap.begin(); it != childMap.end(); ++it) {
295 size_t parentIndex = it->first;
298 std::vector<size_t>& childIndices = it->second;
299 if (childIndices.empty())
306 const SimTrack& child0 = simtracks->at(childIndices[0]);
309 TLorentzVector lv_origin_vertex(origin_vertex.
position().X(),
313 TLorentzVector lv_decay_vertex(decay_vertex.
position().X(),
317 TLorentzVector lv_dist = lv_decay_vertex - lv_origin_vertex;
318 TLorentzVector lv_parent(
320 TVector3
boost = lv_parent.BoostVector();
321 lv_dist.Boost(-
boost);
323 double plt = lv_dist.T();
324 h_plt[pid]->Fill(plt);
327 std::vector<int>
prod;
328 for (
size_t d = 0;
d < childIndices.size(); ++
d) {
329 prod.push_back(
abs(simtracks->at(childIndices[
d]).type()));
332 std::stringstream strstr;
333 for (
size_t p = 0;
p <
prod.size(); ++
p) {
334 strstr <<
"_" <<
prod[
p];
static const std::string kSharedResource
std::map< int, TH1D * > h_plt
T getParameter(std::string const &) const
const math::XYZTLorentzVectorD & position() const
std::map< int, TH1D * > h_originVertexRho
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::map< int, TH1D * > h_plt_ref
std::map< int, TH1D * > h_br_ref
std::map< int, TH1D * > h_br
void analyze(const edm::Event &, const edm::EventSetup &) override
std::map< int, TH1D * > h_originVertexZ
const edm::EDGetTokenT< std::vector< SimVertex > > tokVertex_
T * make(const Args &...args) const
make new ROOT object
std::map< int, TH1D * > h_p
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
void addDefault(ParameterSetDescription const &psetDescription)
std::map< int, TH1D * > h_mass
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
HepPDT::ParticleData ParticleData
std::map< int, TH1D * > h_v
std::map< int, std::vector< std::string > > knownDecayModes
std::map< int, TH1D * > h_decayVertexZ
TestPythiaDecays(const edm::ParameterSet &)
std::map< int, TH1D * > h_decayVertexRho
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::map< int, TH1D * > h_mass_ref
Pythia8::ParticleDataEntry * ParticleDataEntryPtr
~TestPythiaDecays() override=default
const edm::EDGetTokenT< std::vector< SimTrack > > tokTrack_