77 static const double dRcut = 1.0e-7;
78 static const double dTcut = 1.0;
82 double stringFirstTheta = 0.0;
83 double stringFirstPhi = 0.0;
85 double persSumE = 0.0;
86 double transSumE = 0.0;
88 unsigned int endBC = 0;
89 unsigned int endId = 0;
90 unsigned int endHit = 0;
91 HepGeom::Point3D<double> lastTransEnd(0.0, 0.0, 0.0);
92 HepGeom::Point3D<double> lastPersEnd(0.0, 0.0, 0.0);
96 if ( siHit->particleLink().barcode() != lastBarcode || (idx-endBC)==USHRT_MAX ) {
99 lastBarcode = siHit->particleLink().barcode();
103 persCont->
m_barcode.push_back(
static_cast<barcodeRep
>(lastBarcode));
106 persCont->
m_nBC.push_back(idx - endBC);
111 if ( ( (
int)siHit->identify() != lastId ) || (idx-endId)==USHRT_MAX) {
115 lastId = siHit->identify();
116 persCont->
m_id.push_back(lastId);
119 persCont->
m_nId.push_back(idx - endId);
124 HepGeom::Point3D<double> st = siHit->localStartPosition();
125 HepGeom::Point3D<double> en = siHit->localEndPosition();
127 const double dx = st.x() - lastTransEnd.x();
128 const double dy = st.y() - lastTransEnd.y();
129 const double dz = st.z() - lastTransEnd.z();
130 const double t = siHit->meanTime();
132 const double dRLast = sqrt(dx * dx + dy * dy + dz * dz);
133 const double dTLast = fabs(t - lastT);
135 CLHEP::Hep3Vector direction(0.0, 0.0, 0.0);
138 bool startNewString = (dRLast >= dRcut || dTLast >= dTcut || (idx - endHit) == USHRT_MAX);
140 if (!startNewString) {
144 direction = CLHEP::Hep3Vector( en.x() - lastPersEnd.x(), en.y() - lastPersEnd.y(), en.z() - lastPersEnd.z() );
146 theta = direction.theta();
152 if ( dTheta_2b < m_2bMaximum && dTheta_2b >= 0 && dPhi_2b < m_2bMaximum && dPhi_2b >= 0) {
153 persCont->
m_dTheta.push_back(dTheta_2b);
154 persCont->
m_dPhi.push_back(dPhi_2b);
160 startNewString =
true;
164 if (startNewString) {
168 direction = CLHEP::Hep3Vector( en.x() - st.x(), en.y() - st.y(), en.z() - st.z() );
170 theta = direction.theta();
180 lastPersEnd = std::move(st);
182 stringFirstTheta =
theta;
183 stringFirstPhi =
phi;
186 persCont->
m_nHits.push_back(idx - endHit);
191 lastTransEnd = std::move(en);
192 transSumE += siHit->energyLoss();
194 const int eneLoss_2b = (int)((transSumE - persSumE) /
m_persEneUnit + 0.5);
197 const int hitLength_2b = (int)(direction.mag() /
m_persLenUnit + 0.5);
200 double eneLoss = 0.0;
203 eneLoss = siHit->energyLoss();
224 CLHEP::Hep3Vector persDir(
length, 0.0, 0.0);
225 persDir.setTheta(
theta);
228 lastPersEnd = (CLHEP::Hep3Vector)lastPersEnd + persDir;
235 persCont->
m_nBC.push_back(idx - endBC);
236 persCont->
m_nId.push_back(idx - endId);
237 persCont->
m_nHits.push_back(idx - endHit);
238#ifdef ENABLE_SANITY_CHECKS
240 const unsigned int init(0);
241 const unsigned int transContSize = transCont->
size();
242 if (std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init)!=transContSize) {
243 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;
245 if (std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init)!=transContSize) {
246 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;
248 if (std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init)!=transContSize) {
249 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;
268#ifdef ENABLE_SANITY_CHECKS
270 const unsigned int transContSize = persCont->
m_hitEne_2b.size();
271 const unsigned int init(0);
272 if (std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init)!=transContSize) {
273 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;
275 if (std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init)!=transContSize) {
276 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;
278 if (std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init)!=transContSize) {
279 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;
283 unsigned int hitCount = 0;
284 unsigned int angleCount = 0;
285 unsigned int idxBC = 0;
286 unsigned int idxId = 0;
287 unsigned int idxEne4b = 0;
288 unsigned int idxLen4b = 0;
289 unsigned int endHit = 0;
290 unsigned int endBC = 0;
291 unsigned int endId = 0;
295 for (
unsigned int i = 0; i < persCont->
m_nHits.size(); i++) {
299 const unsigned int start = endHit;
300 endHit += persCont->
m_nHits[i];
307 for (
unsigned int j = start; j < endHit; j++) {
309 if (j >= endBC + persCont->
m_nBC[idxBC])
310 endBC += persCont->
m_nBC[idxBC++];
312 if (j >= endId + persCont->
m_nId[idxId])
313 endId += persCont->
m_nId[idxId++];
315 const double eneLoss_2b = persCont->
m_hitEne_2b[hitCount];
324 const double meanTime =
t0;
325 const double theta = theta0 + dTheta;
328 CLHEP::Hep3Vector
r(
length, 0.0, 0.0);
332 HepGeom::Point3D<double> endThis( endLast +
r );
338 transCont->
Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->
m_id[idxId]);
340 endLast = std::move(endThis);
343 if (j > start) ++angleCount;
a link optimized in size for a GenParticle in a McEventCollection
static int getEventNumberAtPosition(index_type position, const IProxyDict *sg)
Return the event number of the GenEvent at the specified position in the McEventCollection.
void setTruthSuppressionType(EBC_SUPPRESSED_TRUTH truthSupp)
Return whether the truth particle has been suppressed.