22 namespace HGCal_helpers {
34 ROOT::Math::SMatrixIdentity
id;
36 const float uncert = 0.001;
110 momentum.px(), momentum.py(), momentum.pz(), position.x(), position.y(), position.z(),
charge,
output);
198 mySimEvent_ = std::make_unique<FSimEvent>(particleFilter_);
202 tree.Branch(
"gen_n", &
gen_n_,
"gen_n/I");
203 tree.Branch(
"gen_PUNumInt", &
gen_PUNumInt_,
"gen_PUNumInt/I");
211 tree.Branch(
"vtx_x", &
vtx_x_);
212 tree.Branch(
"vtx_y", &
vtx_y_);
213 tree.Branch(
"vtx_z", &
vtx_z_);
217 tree.Branch(
"gen_pt", &
gen_pt_);
254 const std::vector<PileupSummaryInfo> &PupInfo = *PupInfo_h;
268 mySimEvent_->fill(*simTracksHandle, *simVerticesHandle);
270 HepMC::GenVertex *
primaryVertex = *(hevH)->GetEvent()->vertices_begin();
271 const float mm2cm = 0.1;
272 vtx_x_ = primaryVertex->position().x() * mm2cm;
273 vtx_y_ = primaryVertex->position().y() * mm2cm;
274 vtx_z_ = primaryVertex->position().z() * mm2cm;
278 std::vector<FSimTrack *> allselectedgentracks;
279 const float eeInnerRadius = 25.;
280 const float eeOuterRadius = 160.;
282 for (
unsigned int i = 0;
i <
npart; ++
i) {
283 std::vector<float> xp, yp, zp;
287 int reachedEE = ReachHGCal::notReach;
295 if (myTrack.noEndVertex())
299 toHGCalPropagator.
propagate(myTrack.momentum(), myTrack.vertex().position(), myTrack.charge(), propcoords);
302 if (reachesHGCal && vtx.Rho() < eeOuterRadius && vtx.Rho() > eeInnerRadius) {
303 reachedEE = ReachHGCal::onEESurface;
306 for (
int i = 0;
i < myTrack.nDaughters(); ++
i)
307 dpt += myTrack.daughter(
i).momentum().pt();
308 if (
abs(myTrack.type()) == 11)
309 fbrem = dpt / myTrack.momentum().pt();
310 }
else if (reachesHGCal && vtx.Rho() > eeOuterRadius)
311 reachedEE = ReachHGCal::outsideEESurface;
314 for (
unsigned il = 1; il <=
nlayers; ++il) {
315 const float charge = myTrack.charge();
318 indiv_particleProp.
propagate(myTrack.momentum(), myTrack.vertex().position(),
charge, propCoords);
320 xp.push_back(propCoords.
x);
321 yp.push_back(propCoords.
y);
322 zp.push_back(propCoords.
z);
325 vtx = myTrack.endVertex().position();
327 auto orig_vtx = myTrack.vertex().position();
344 toHGCalPropagator.
propagate(myTrack.momentum(), orig_vtx, myTrack.charge(), hitsHGCal);
364 gen_n_ = genParticlesHandle->size();
366 for (
const auto &particle : *genParticlesHandle) {
369 gen_pt_.push_back(particle.pt());
374 std::vector<int> daughters(particle.daughterRefVector().size(), 0);
375 for (
unsigned j = 0;
j < particle.daughterRefVector().size(); ++
j) {
376 daughters[
j] =
static_cast<int>(particle.daughterRefVector().at(
j).key());
383 for (
size_t i = 0;
i < allselectedgentracks.size();
i++) {
384 const auto tracki = allselectedgentracks.at(
i);
386 for (
size_t j =
i + 1;
j < allselectedgentracks.size();
j++) {
387 const auto trackj = allselectedgentracks.at(
j);
389 if (!tracki->noMother()) {
390 if (&tracki->mother() == trackj)
393 if (!trackj->noMother()) {
394 if (&trackj->mother() == tracki)
400 for (
const auto &PVI : PupInfo) {
401 if (PVI.getBunchCrossing() == 0) {
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
const MagneticField * aField_
std::vector< int > genpart_mother_
const MagneticField * field_
std::vector< std::vector< int > > gen_daughters_
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
uint16_t *__restrict__ id
edm::ESHandle< MagneticField > magfield
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Geom::Phi< T > phi() const
Plane::PlanePointer targetPlaneBackward_
std::vector< std::vector< float > > genpart_posy_
CurvilinearTrajectoryError err_
GlobalPoint globalPosition() const
edm::EDGetToken gen_PU_token_
std::vector< float > genpart_phi_
edm::ESHandle< HGCalTriggerGeometryBase > geometry
edm::EDGetToken gen_token_
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final
std::vector< float > gen_energy_
std::vector< float > genpart_exy_
std::unique_ptr< FSimEvent > mySimEvent_
edm::EDGetToken simVertices_token_
std::vector< float > gen_eta_
std::vector< std::vector< float > > genpart_posz_
std::vector< int > gen_status_
std::vector< float > genpart_dvy_
std::vector< int > genpart_reachedEE_
std::vector< int > gen_pdgid_
std::vector< float > genpart_exx_
std::vector< float > gen_phi_
static PlanePointer build(Args &&...args)
edm::ESHandle< HepPDT::ParticleDataTable > pdt
std::vector< int > genpart_pid_
std::vector< int > gen_charge_
std::vector< bool > genpart_fromBeamPipe_
Abs< T >::type abs(const T &t)
edm::EDGetToken hepmcev_token_
std::vector< float > genpart_fbrem_
std::vector< float > genpart_eta_
std::vector< float > genpart_pt_
std::vector< float > genpart_ovz_
const RKPropagatorInS & RKProp() const
HGCalTriggerTools triggerTools_
Plane::PlanePointer targetPlaneForward_
TrajectoryStateOnSurface TSOS
std::vector< std::vector< float > > genpart_posx_
SimpleTrackPropagator(const MagneticField *f)
std::vector< float > genpart_ovy_
T const * product() const
T getParameter(std::string const &) const
std::vector< float > gen_pt_
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
std::vector< float > genpart_exphi_
bool propagate(const double px, const double py, const double pz, const double x, const double y, const double z, const float charge, Coordinates &coords) const
void setPropagationTargetZ(const float &z)
std::vector< float > genpart_energy_
math::XYZTLorentzVectorD toVector()
static int position[264][3]
std::vector< float > genpart_ovx_
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::vector< float > genpart_exeta_
void fill(const edm::Event &, const HGCalTriggerNtupleEventSetup &) final
HGCalTriggerNtupleGen(const edm::ParameterSet &)
edm::EDGetToken simTracks_token_
std::vector< float > genpart_dvz_
std::vector< int > genpart_gen_
std::vector< float > genpart_dvx_
defaultRKPropagator::Product prod_