Merging.
54 {
55
57
58
61 NewContainer->setStore(auxNewContainer);
62
63 static const SG::Decorator<float> mDecor_sumPt2("sumPt2");
64 static const SG::Decorator<float> mDecor_mass("mass");
65 static const SG::Decorator<float> mDecor_energy("ee");
66 static const SG::Decorator<int> mDecor_nrobbed("nrobbed");
67 static const SG::Decorator<int> mDecor_intrk("NumInputTrk");
68
69 static const SG::Accessor<float> mAcc_sumPt2("sumPt2");
70 static const SG::Accessor<int> mAcc_momdir ("MomentaDirection");
71 static const SG::Accessor<float> mAcc_mass("mass");
72 static const SG::Accessor<float> mAcc_energy("ee");
73 static const SG::Accessor<int> mAcc_intrk("NumInputTrk");
74 static const SG::Accessor<float> mAcc_radpat("radiiPattern");
75 static const SG::Accessor<std::vector<float> > mAcc_trkwt("trkWeight");
76 static const SG::Accessor<int> mAcc_numtav("NumTrkAtVtx");
77 static const SG::Accessor<std::vector<float> > mAcc_trkdoe("trkDistOverError");
78
79 bool moreDeco = mAcc_momdir.isAvailable(*MyVxCont.
front());
80
81 if (!moreDeco)
83
91
92
93 std::vector<bool> remerged(MyVxCont.
size(),
false);
94
97 unsigned int Ni = 0;
101
102 if (remerged[Ni])
103 continue;
104
105 std::vector<const xAOD::TrackParticle*> combinedTracks;
106 std::vector<ElementLink<xAOD::TrackParticleContainer>> tpLinks1 =
108 if (!tpLinks1.empty()) {
109 for (const auto& tp_EL : tpLinks1) {
111 combinedTracks.push_back(trk);
112 }
113
114 unsigned int Nj = Ni + 1;
115 bool newmerge = false;
117 ++j, Nj++) {
119 if (remerged[Nj])
120 continue;
121
122 if (newmerge) {
123 combinedTracks.clear();
125 if (tpLinks1.empty())
126 break;
127 for (const auto& tp_EL : tpLinks1) {
129 combinedTracks.push_back(trk);
130 }
131 newmerge = false;
132 }
133
134
135
137 continue;
138
140
141
142 const std::vector<ElementLink<xAOD::TrackParticleContainer>>
144 if (tpLinks2.empty())
145 continue;
146
147 for (const auto& tp_EL : tpLinks2) {
149 combinedTracks.push_back(trk);
150 }
151
153 << tpLinks2.size());
154
155
156
158
159
162
164
165 remerged[Nj] = true;
166 remerged[Ni] = true;
167 newmerge = true;
168
169
170 float pt1 = sqrt(mAcc_sumPt2(*vx));
171 float pt2 = sqrt(mAcc_sumPt2(*mergeCand));
174 float wght1 =
175 0.6 * pt1 / (pt1 + pt2) + 0.4 * ntrk1 / (ntrk1 + ntrk2);
176 float wght2 =
177 0.6 * pt2 / (pt1 + pt2) + 0.4 * ntrk2 / (ntrk1 + ntrk2);
178
181 float mas1 = mAcc_mass(*vx);
182 float mas2 = mAcc_mass(*mergeCand);
183 float e1 = mAcc_energy(*vx);
184 float e2 = mAcc_energy(*mergeCand);
185 int inNtrk1 = mAcc_intrk(*vx);
186 int inNtrk2 = mAcc_intrk(*mergeCand);
187
188 int ntrks = 0;
189 float md1 = 0., md2 = 0., hf1 = 0., hf2 = 0.;
190 std::vector<float> trkW1, trkW2, doe1, doe2;
191 if (moreDeco) {
192 doe1 = mAcc_trkdoe(*vx);
193 doe2 = mAcc_trkdoe(*mergeCand);
194 doe2.insert(doe2.end(), doe1.begin(), doe1.end());
195 md1 = mAcc_momdir(*vx);
196 md2 = mAcc_momdir(*mergeCand);
197 hf1 = mAcc_radpat(*vx);
198 hf2 = mAcc_radpat(*mergeCand);
199 trkW1 = mAcc_trkwt(*vx);
200 trkW2 = mAcc_trkwt(*mergeCand);
201 trkW2.insert(trkW2.end(), trkW1.begin(), trkW1.end());
202 ntrks = mAcc_numtav(*vx) + mAcc_numtav(*mergeCand);
203 }
204
205
206 delete vx;
207 vx = mergedVtx;
208
209 if (wght1 >= wght2)
211 else
213
214 if (moreDeco) {
215 mAcc_trkdoe(*vx) = doe2;
216 mAcc_momdir(*vx) = wght1 * md1 + wght2 * md2;
217 mAcc_radpat(*vx) = wght1 * hf1 + wght2 * hf2;
218 mAcc_trkwt(*vx) = trkW2;
219 mAcc_numtav(*vx) = ntrks;
220 }
221
222 mDecor_sumPt2(*vx) = pt1 * pt1 + pt2 * pt2;
223 mDecor_mass(*vx) = wght1 * mas1 + wght2 * mas2;
224 mDecor_energy(*vx) = wght1 *
e1 + wght2 *
e2;
225 mDecor_nrobbed(*vx) = 0;
226 mDecor_intrk(*vx) = (
int)(wght1 * inNtrk1 + wght1 * inNtrk2);
227
228 }
229 }
230
231
232 if (vx != nullptr){
235 }
236 }
237
238 return std::make_pair(NewContainer, auxNewContainer);
239
240 }
DataModel_detail::const_iterator< DataVector > const_iterator
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const T * front() const
Access the first element in the collection as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
VxType::VertexType vertexType() const
The type of the vertex.
const Amg::Vector3D & position() const
Returns the 3-pos.
double e2(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 2nd sampling
double e1(const xAOD::CaloCluster &cluster)
return the uncorrected cluster energy in 1st sampling
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.