81 static const double dRcut = 1.0e-7;
82 static const double dTcut = 1.0;
84 const EventContext& ctx = Gaudi::Hive::currentContext();
89 double stringFirstTheta = 0.0;
90 double stringFirstPhi = 0.0;
92 double persSumE = 0.0;
93 double transSumE = 0.0;
95 unsigned int endBC = 0;
96 unsigned int endId = 0;
97 unsigned int endHit = 0;
98 HepGeom::Point3D<double> lastTransEnd(0.0, 0.0, 0.0);
99 HepGeom::Point3D<double> lastPersEnd(0.0, 0.0, 0.0);
105 const int barcode = currentLink->
barcode();
112 if ( lastBarcode != barcode || lastIndex !=
index || (idx-endBC)==USHRT_MAX ) {
113 lastBarcode = barcode;
115 const unsigned short persIndex =
static_cast<unsigned short>(
index);
117 log << MSG::WARNING <<
"Attempting to persistify an eventIndex larger than max unsigned short!" <<
endmsg;
121 persCont->
m_barcode.push_back(
static_cast<unsigned long>(lastBarcode));
126 persCont->
m_nBC.push_back(idx - endBC);
131 if ( ( (
int)siHit->identify() != lastId ) || (idx-endId)==USHRT_MAX) {
136 lastId = siHit->identify();
137 persCont->
m_id.push_back(lastId);
140 persCont->
m_nId.push_back(idx - endId);
145 HepGeom::Point3D<double> st = siHit->localStartPosition();
146 HepGeom::Point3D<double> en = siHit->localEndPosition();
148 const double dx = st.x() - lastTransEnd.x();
149 const double dy = st.y() - lastTransEnd.y();
150 const double dz = st.z() - lastTransEnd.z();
151 const double t = siHit->meanTime();
153 const double dRLast = sqrt(dx * dx + dy * dy + dz * dz);
154 const double dTLast = fabs(t - lastT);
156 CLHEP::Hep3Vector direction(0.0, 0.0, 0.0);
159 bool startNewString = (dRLast >= dRcut || dTLast >= dTcut || (idx - endHit) == USHRT_MAX);
161 if (!startNewString) {
165 direction = CLHEP::Hep3Vector( en.x() - lastPersEnd.x(), en.y() - lastPersEnd.y(), en.z() - lastPersEnd.z() );
167 theta = direction.theta();
173 if ( dTheta_2b < m_2bMaximum && dTheta_2b >= 0 && dPhi_2b < m_2bMaximum && dPhi_2b >= 0) {
174 persCont->
m_dTheta.push_back(dTheta_2b);
175 persCont->
m_dPhi.push_back(dPhi_2b);
181 startNewString =
true;
185 if (startNewString) {
189 direction = CLHEP::Hep3Vector( en.x() - st.x(), en.y() - st.y(), en.z() - st.z() );
191 theta = direction.theta();
201 lastPersEnd = HepGeom::Point3D<double>(st.x(), st.y(), st.z());
203 stringFirstTheta =
theta;
204 stringFirstPhi =
phi;
207 persCont->
m_nHits.push_back(idx - endHit);
212 lastTransEnd = HepGeom::Point3D<double>(en.x(), en.y(), en.z());
213 transSumE += siHit->energyLoss();
215 const int eneLoss_2b = (int)((transSumE - persSumE) /
m_persEneUnit + 0.5);
218 const int hitLength_2b = (int)(direction.mag() /
m_persLenUnit + 0.5);
221 double eneLoss = 0.0;
224 eneLoss = siHit->energyLoss();
245 CLHEP::Hep3Vector persDir(
length, 0.0, 0.0);
246 persDir.setTheta(
theta);
249 lastPersEnd = (CLHEP::Hep3Vector)lastPersEnd + persDir;
256 persCont->
m_nBC.push_back(idx - endBC);
257 persCont->
m_nId.push_back(idx - endId);
258 persCont->
m_nHits.push_back(idx - endHit);
259#ifdef ENABLE_SANITY_CHECKS
261 const unsigned int init(0);
262 const unsigned int transContSize = transCont->
size();
263 if (std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init)!=transContSize) {
264 log << MSG::ERROR <<
"transToPers: sum of entries of persCont->m_nBC (" << std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init) <<
") does not match transient container size = " << transContSize <<
endmsg;
266 if (std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init)!=transContSize) {
267 log << MSG::ERROR <<
"transToPers: sum of entries of persCont->m_nId (" << std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init) <<
") does not match transient container size = " << transContSize <<
endmsg;
269 if (std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init)!=transContSize) {
270 log << MSG::ERROR <<
"transToPers: sum of entries of persCont->m_nHits (" << std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init) <<
") does not match transient container size = " << transContSize <<
endmsg;
289 const EventContext& ctx = Gaudi::Hive::currentContext();
290#ifdef ENABLE_SANITY_CHECKS
292 const unsigned int transContSize = persCont->
m_hitEne_2b.size();
293 const unsigned int init(0);
294 if (std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init)!=transContSize) {
295 log << MSG::ERROR <<
"persToTrans: sum of entries of persCont->m_nBC (" << std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init) <<
") does not match transient container size = " << transContSize <<
endmsg;
297 if (std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init)!=transContSize) {
298 log << MSG::ERROR <<
"persToTrans: sum of entries of persCont->m_nId (" << std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init) <<
") does not match transient container size = " << transContSize <<
endmsg;
300 if (std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init)!=transContSize) {
301 log << MSG::ERROR <<
"persToTrans: sum of entries of persCont->m_nHits (" << std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init) <<
") does not match transient container size = " << transContSize <<
endmsg;
305 unsigned int hitCount = 0;
306 unsigned int angleCount = 0;
307 unsigned int idxBC = 0;
308 unsigned int idxId = 0;
309 unsigned int idxEne4b = 0;
310 unsigned int idxLen4b = 0;
311 unsigned int endHit = 0;
312 unsigned int endBC = 0;
313 unsigned int endId = 0;
315 for (
unsigned int i = 0; i < persCont->
m_nHits.size(); i++) {
319 const unsigned int start = endHit;
320 endHit += persCont->
m_nHits[i];
327 for (
unsigned int j = start; j < endHit; j++) {
329 if (j >= endBC + persCont->
m_nBC[idxBC])
330 endBC += persCont->
m_nBC[idxBC++];
332 if (j >= endId + persCont->
m_nId[idxId])
333 endId += persCont->
m_nId[idxId++];
335 const double eneLoss_2b = persCont->
m_hitEne_2b[hitCount];
344 const double meanTime =
t0;
345 const double theta = theta0 + dTheta;
348 CLHEP::Hep3Vector
r(
length, 0.0, 0.0);
352 HepGeom::Point3D<double> endThis( endLast +
r );
362 transCont->
Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->
m_id[idxId]);
364 endLast = std::move(endThis);
367 if (j > start) ++angleCount;
a link optimized in size for a GenParticle in a McEventCollection
static std::vector< index_type > getEventPositionInCollection(index_type index, const IProxyDict *sg)
Return a vector of the positions in the McEventCollection of the GenEvent(s) with a given event numbe...
index_type eventIndex() const
Return the event number of the referenced GenEvent.
int barcode() const
Return the barcode of the target particle.
void setTruthSuppressionType(EBC_SUPPRESSED_TRUTH truthSupp)
Return whether the truth particle has been suppressed.