78 static const double dRcut = 1.0e-7;
79 static const double dTcut = 1.0;
83 double stringFirstTheta = 0.0;
84 double stringFirstPhi = 0.0;
86 double persSumE = 0.0;
87 double transSumE = 0.0;
89 unsigned int endBC = 0;
90 unsigned int endId = 0;
91 unsigned int endHit = 0;
92 HepGeom::Point3D<double> lastTransEnd(0.0, 0.0, 0.0);
93 HepGeom::Point3D<double> lastPersEnd(0.0, 0.0, 0.0);
97 if ( siHit->particleLink().barcode() != lastBarcode || (idx-endBC)==USHRT_MAX ) {
100 lastBarcode = siHit->particleLink().barcode();
103 using barcodeRep =
decltype(persCont->
m_barcode)::value_type;
104 persCont->
m_barcode.push_back(
static_cast<barcodeRep
>(lastBarcode));
107 persCont->
m_nBC.push_back(idx - endBC);
112 if ( ( (
int)siHit->identify() != lastId ) || (idx-endId)==USHRT_MAX) {
116 lastId = siHit->identify();
117 persCont->
m_id.push_back(lastId);
120 persCont->
m_nId.push_back(idx - endId);
125 HepGeom::Point3D<double> st = siHit->localStartPosition();
126 HepGeom::Point3D<double> en = siHit->localEndPosition();
128 const double dx = st.x() - lastTransEnd.x();
129 const double dy = st.y() - lastTransEnd.y();
130 const double dz = st.z() - lastTransEnd.z();
131 const double t = siHit->meanTime();
133 const double dRLast = sqrt(dx * dx + dy * dy + dz * dz);
134 const double dTLast = fabs(t - lastT);
136 CLHEP::Hep3Vector direction(0.0, 0.0, 0.0);
139 bool startNewString = (dRLast >= dRcut || dTLast >= dTcut || (idx - endHit) == USHRT_MAX);
141 if (!startNewString) {
145 direction = CLHEP::Hep3Vector( en.x() - lastPersEnd.x(), en.y() - lastPersEnd.y(), en.z() - lastPersEnd.z() );
147 theta = direction.theta();
153 if ( dTheta_2b < m_2bMaximum && dTheta_2b >= 0 && dPhi_2b < m_2bMaximum && dPhi_2b >= 0) {
154 persCont->
m_dTheta.push_back(dTheta_2b);
155 persCont->
m_dPhi.push_back(dPhi_2b);
161 startNewString =
true;
165 if (startNewString) {
169 direction = CLHEP::Hep3Vector( en.x() - st.x(), en.y() - st.y(), en.z() - st.z() );
171 theta = direction.theta();
181 lastPersEnd = std::move(st);
183 stringFirstTheta =
theta;
184 stringFirstPhi =
phi;
187 persCont->
m_nHits.push_back(idx - endHit);
192 lastTransEnd = std::move(en);
193 transSumE += siHit->energyLoss();
195 const int eneLoss_2b = (int)((transSumE - persSumE) /
m_persEneUnit + 0.5);
198 const int hitLength_2b = (int)(direction.mag() /
m_persLenUnit + 0.5);
201 double eneLoss = 0.0;
204 eneLoss = siHit->energyLoss();
225 CLHEP::Hep3Vector persDir(
length, 0.0, 0.0);
226 persDir.setTheta(
theta);
229 lastPersEnd = (CLHEP::Hep3Vector)lastPersEnd + persDir;
236 persCont->
m_nBC.push_back(idx - endBC);
237 persCont->
m_nId.push_back(idx - endId);
238 persCont->
m_nHits.push_back(idx - endHit);
239#ifdef ENABLE_SANITY_CHECKS
241 const unsigned int init(0);
242 const unsigned int transContSize = transCont->
size();
243 if (std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init)!=transContSize) {
244 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;
246 if (std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init)!=transContSize) {
247 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;
249 if (std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init)!=transContSize) {
250 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;
269#ifdef ENABLE_SANITY_CHECKS
271 const unsigned int transContSize = persCont->
m_hitEne_2b.size();
272 const unsigned int init(0);
273 if (std::accumulate(persCont->
m_nBC.begin(), persCont->
m_nBC.end(), init)!=transContSize) {
274 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;
276 if (std::accumulate(persCont->
m_nId.begin(), persCont->
m_nId.end(), init)!=transContSize) {
277 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;
279 if (std::accumulate(persCont->
m_nHits.begin(), persCont->
m_nHits.end(), init)!=transContSize) {
280 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;
284 unsigned int hitCount = 0;
285 unsigned int angleCount = 0;
286 unsigned int idxBC = 0;
287 unsigned int idxId = 0;
288 unsigned int idxEne4b = 0;
289 unsigned int idxLen4b = 0;
290 unsigned int endHit = 0;
291 unsigned int endBC = 0;
292 unsigned int endId = 0;
294 const EventContext& ctx = Gaudi::Hive::currentContext();
296 for (
unsigned int i = 0; i < persCont->
m_nHits.size(); i++) {
300 const unsigned int start = endHit;
301 endHit += persCont->
m_nHits[i];
308 for (
unsigned int j = start; j < endHit; j++) {
310 if (j >= endBC + persCont->
m_nBC[idxBC])
311 endBC += persCont->
m_nBC[idxBC++];
313 if (j >= endId + persCont->
m_nId[idxId])
314 endId += persCont->
m_nId[idxId++];
316 const double eneLoss_2b = persCont->
m_hitEne_2b[hitCount];
325 const double meanTime =
t0;
326 const double theta = theta0 + dTheta;
329 CLHEP::Hep3Vector
r(
length, 0.0, 0.0);
333 HepGeom::Point3D<double> endThis( endLast +
r );
339 transCont->
Emplace( endLast, endThis, eneLoss, meanTime, partLink, persCont->
m_id[idxId]);
341 endLast = std::move(endThis);
344 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.