20 InputData::InputData() {}
39 iEvent.getByToken(stubToken, ttStubHandle);
41 std::set<DetId> lStubDetIds;
44 lStubDetIds.insert(p_ttstub->getDetId());
48 std::map<DetId, DetId> stubGeoDetIdMap;
49 for (
auto gd = tGeom.
dets().begin(); gd != tGeom.
dets().end(); gd++) {
50 DetId detid = (*gd)->geographicalId();
57 if (lStubDetIds.count(stackDetid) > 0) {
58 assert(stubGeoDetIdMap.count(stackDetid) == 0);
59 stubGeoDetIdMap[stackDetid] = detid;
62 assert(lStubDetIds.size() == stubGeoDetIdMap.size());
67 iEvent.getByToken(tpToken, tpHandle);
68 iEvent.getByToken(tpValueMapToken, tpValueMapHandle);
71 for (
unsigned int i = 0;
i < tpHandle->size();
i++) {
72 if (tpValueMap[tpHandle->refAt(
i)].use()) {
73 tpPtrToRefMap_[tpHandle->ptrAt(
i)] = tpHandle->refAt(
i);
80 for (
const auto& [edmPtr, edmRef] : tpPtrToRefMap_) {
81 TP tp = tpValueMap[edmRef];
82 if (
tp.physicsCollision()) {
85 genPt_PU_ +=
tp->pt();
87 if (settings.
debug() > 2) {
88 edm::LogInfo(
"InputData") <<
"InputData::genPt in the event " << genPt_;
91 if (
tp.useForAlgEff()) {
93 }
else if (
tp.useForVertexReco()) {
95 for (
unsigned int i = 0;
i < vertices_.size(); ++
i) {
96 if (
tp->vz() == vertices_[
i].vz()) {
97 vertices_[
i].insert(
tp);
105 vertices_.push_back(
vertex);
112 recoVertices_.push_back(
vertex);
115 if (settings.
debug() > 2)
116 edm::LogInfo(
"InputData") <<
"InputData::" << vertices_.size() <<
" pileup vertices in the event, " 117 << recoVertices_.size() <<
" reconstructable";
119 vertex_.computeParameters();
120 if (settings.
debug() > 2)
121 edm::LogInfo(
"InputData") <<
"InputData::Vertex " << vertex_.z0() <<
" containing " << vertex_.numTracks()
122 <<
" total pT " << vertex_.pT();
124 for (
unsigned int i = 0;
i < vertices_.size(); ++
i) {
125 vertices_[
i].computeParameters();
128 for (
unsigned int i = 0;
i < recoVertices_.size(); ++
i) {
129 recoVertices_[
i].computeParameters();
137 iEvent.getByToken(hepMCToken, HepMCEvt);
140 iEvent.getByToken(genParticlesToken, GenParticleHandle);
142 if (!HepMCEvt.isValid() && !GenParticleHandle.
isValid()) {
143 throw cms::Exception(
"Neither the edm::HepMCProduct nor the generator particles are available.");
145 if (HepMCEvt.isValid()) {
147 for (HepMC::GenEvent::vertex_const_iterator ivertex = MCEvt->vertices_begin(); ivertex != MCEvt->vertices_end();
149 bool hasParentVertex =
false;
152 for (HepMC::GenVertex::particle_iterator iparent = (*ivertex)->particles_begin(
HepMC::parents);
155 if ((*iparent)->production_vertex()) {
156 hasParentVertex =
true;
164 HepMC::FourVector
pos = (*ivertex)->position();
165 const double mm = 0.1;
170 if (GenParticleHandle.
isValid()) {
171 for (
const auto& genpart : *GenParticleHandle) {
172 if ((genpart.status() != 1) || (genpart.numberOfMothers() == 0))
174 genVertex_ =
Vertex(genpart.vz());
178 if ((hepMCVertex_.vz() == 0.0) && (genVertex_.vz() == 0.0)) {
179 throw cms::Exception(
"Neither the HepMC vertex nor the generator particle vertex were found.");
184 InputData::~InputData() {}
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
data_type const * const_iterator
unsigned int debug() const
uint32_t stack(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
static constexpr auto TOB
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
bool isLower(const DetId &id) const
unsigned int vx_minTracks() const
static constexpr auto TID