21 InputData::InputData() {}
40 iEvent.getByToken(stubToken, ttStubHandle);
42 std::set<DetId> lStubDetIds;
45 lStubDetIds.insert(p_ttstub->getDetId());
49 std::map<DetId, DetId> stubGeoDetIdMap;
50 for (
auto gd = tGeom.
dets().begin(); gd != tGeom.
dets().end(); gd++) {
51 DetId detid = (*gd)->geographicalId();
58 if (lStubDetIds.count(stackDetid) > 0) {
59 assert(stubGeoDetIdMap.count(stackDetid) == 0);
60 stubGeoDetIdMap[stackDetid] = detid;
63 assert(lStubDetIds.size() == stubGeoDetIdMap.size());
68 iEvent.getByToken(tpToken, tpHandle);
69 iEvent.getByToken(tpValueMapToken, tpValueMapHandle);
72 for (
unsigned int i = 0;
i < tpHandle->size();
i++) {
73 if (tpValueMap[tpHandle->refAt(
i)].use()) {
74 tpPtrToRefMap_[tpHandle->ptrAt(
i)] = tpHandle->refAt(
i);
81 for (
const auto& [edmPtr, edmRef] : tpPtrToRefMap_) {
82 TP tp = tpValueMap[edmRef];
83 if (
tp.physicsCollision()) {
86 genPt_PU_ +=
tp->pt();
88 if (settings.
debug() > 0) {
89 edm::LogInfo(
"InputData") <<
"InputData::genPt in the event " << genPt_;
92 if (
tp.useForAlgEff()) {
94 }
else if (
tp.useForVertexReco()) {
96 for (
unsigned int i = 0;
i < vertices_.size(); ++
i) {
97 if (
tp->vz() == vertices_[
i].vz()) {
98 vertices_[
i].insert(
tp);
106 vertices_.push_back(
vertex);
113 recoVertices_.push_back(
vertex);
116 if (settings.
debug() > 0)
117 edm::LogInfo(
"InputData") <<
"InputData::" << vertices_.size() <<
" pileup vertices in the event, "
118 << recoVertices_.size() <<
" reconstructable";
120 vertex_.computeParameters();
121 if (settings.
debug() > 2)
122 edm::LogInfo(
"InputData") <<
"InputData::Vertex " << vertex_.z0() <<
" containing " << vertex_.numTracks()
123 <<
" total pT " << vertex_.pT();
125 for (
unsigned int i = 0;
i < vertices_.size(); ++
i) {
126 vertices_[
i].computeParameters();
129 for (
unsigned int i = 0;
i < recoVertices_.size(); ++
i) {
130 recoVertices_[
i].computeParameters();
138 iEvent.getByToken(hepMCToken, HepMCEvt);
141 iEvent.getByToken(genParticlesToken, GenParticleHandle);
143 if (!HepMCEvt.isValid() && !GenParticleHandle.
isValid()) {
144 throw cms::Exception(
"Neither the edm::HepMCProduct nor the generator particles are available.");
146 if (HepMCEvt.isValid()) {
148 for (HepMC::GenEvent::vertex_const_iterator ivertex = MCEvt->vertices_begin(); ivertex != MCEvt->vertices_end();
150 bool hasParentVertex =
false;
153 for (HepMC::GenVertex::particle_iterator iparent = (*ivertex)->particles_begin(
HepMC::parents);
156 if ((*iparent)->production_vertex()) {
157 hasParentVertex =
true;
165 HepMC::FourVector
pos = (*ivertex)->position();
166 const double mm = 0.1;
171 if (GenParticleHandle.
isValid()) {
172 for (
const auto& genpart : *GenParticleHandle) {
173 if ((genpart.status() != 1) || (genpart.numberOfMothers() == 0))
175 genVertex_ =
Vertex(genpart.vz());
179 if ((hepMCVertex_.vz() == 0.0) && (genVertex_.vz() == 0.0)) {
180 throw cms::Exception(
"Neither the HepMC vertex nor the generator particle vertex were found.");
185 InputData::~InputData() {}