Commit in projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors on MAIN | |||
DDSegmentationCalorimeterHitProcessor.cc | +51 | -21 | 3248 -> 3249 |
Correct the position in the output hit. Also get correct values for id0 and id1.
--- projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.cc 2014-08-11 19:43:43 UTC (rev 3248) +++ projects/lcdd/branches/v05-00-00-dev/src/lcdd/detectors/DDSegmentationCalorimeterHitProcessor.cc 2014-08-11 21:44:05 UTC (rev 3249) @@ -44,34 +44,37 @@
return false; }
+ // Get touchable from the PreStepPoint. + G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle(); + + // Get the Segmentation object.
DD4hep::DDSegmentation::Segmentation* segmentation = _calorimeter->getDDSegmentation();
- // Compute the global midpoint of the step. - G4ThreeVector globalMidPoint = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
+ // Compute the global midpoint of the step using the pre and post step points. + G4ThreeVector globalMidVec = (0.5 * (step->GetPreStepPoint()->GetPosition() + step->GetPostStepPoint()->GetPosition()));
- // Create the global position for input to Segmentation. - DD4hep::DDSegmentation::Vector3D globalPosition = DD4hep::DDSegmentation::Vector3D(globalMidPoint.x(), globalMidPoint.y(), globalMidPoint.z());
+ // Create the global position for input to the Segmentation. + DD4hep::DDSegmentation::Vector3D globalPosition = DD4hep::DDSegmentation::Vector3D(globalMidVec.x(), globalMidVec.y(), globalMidVec.z());
- // Get touchable from PreStepPoint. - G4TouchableHandle touchable = step->GetPreStepPoint()->GetTouchableHandle();
+ // Compute the local step position for input to the Segmentation. + G4ThreeVector localVec = touchable->GetHistory()->GetTopTransform().TransformPoint(globalMidVec); + DD4hep::DDSegmentation::Vector3D localPosition = DD4hep::DDSegmentation::Vector3D(localVec.x(), localVec.y(), localVec.z());
- // Compute local position. - G4ThreeVector localPosition = touchable->GetHistory()->GetTopTransform().TransformPoint(globalMidPoint); - - // Create the VolumeID.
+ // Create the VolumeID which does not have Segmentation bin values.
DD4hep::DDSegmentation::VolumeID volumeId = IdFactory::createVolumeId(step, _calorimeter->getIdSpec());
- // Get the encoded 64-bit cell ID from the Segmentation. - long cellId = segmentation->cellID(localPosition, globalPosition, volumeId);
+ // Create the encoded 64-bit cell ID from the Segmentation. + DD4hep::DDSegmentation::CellID cellId = segmentation->cellID(localPosition, globalPosition, volumeId);
G4cout << "fieldDescription = " << segmentation->decoder()->fieldDescription() << G4endl;
- segmentation->decoder()->setValue(cellId);
+ //segmentation->decoder()->setValue(cellId);
- int ix = segmentation->decoder()->index("x"); - int iy = segmentation->decoder()->index("y");
+ //int ix = segmentation->decoder()->index("x"); + //int iy = segmentation->decoder()->index("y");
- G4cout << "x = " << segmentation->decoder()[ix] << G4endl; - G4cout << "y = " << segmentation->decoder()[iy] << G4endl;
+ // FIXME: Commented code causes Seg Fault. + //G4cout << "x = " << segmentation->decoder()[ix] << G4endl; + //G4cout << "y = " << segmentation->decoder()[iy] << G4endl;
// Check for an existing hit with this identifier. CalorimeterHit* hit = _calorimeter->getCalorimeterHitMap(getCollectionIndex())->get(cellId);
@@ -79,21 +82,48 @@
// Was there a hit found with this identifier? if (hit == NULL) {
- int id0 = cellId & 0xFFFF0000; - int id1 = (cellId & 0x0000FFFF) << 32;
+ G4cout << "creating a new hit " << G4endl; + G4cout << "cellID: " << std::hex << cellId << G4endl; + + int id0 = segmentation->decoder()->lowWord(); + int id1 = segmentation->decoder()->highWord(); +
Id64bit id = Id64bit(id0, id1);
+ G4cout << "id0: " << std::hex << id0 << G4endl; + G4cout << "id1: " << std::hex << id1 << G4endl; +
// Get the global cell position from the Segmentation.
- DD4hep::DDSegmentation::Vector3D globalCellPosition = segmentation->position(cellId);
+ DD4hep::DDSegmentation::Vector3D localCellPosition = segmentation->position(cellId);
+ G4cout << "local cell position: " + << std::dec + << localCellPosition.x() << ", " + << localCellPosition.y() << ", " + << localCellPosition.z() << G4endl; + + // Create a G4ThreeVector for the hit's local cell position. + G4ThreeVector localCellVec = G4ThreeVector(localCellPosition.x(), localCellPosition.y(), localCellPosition.z()); + + // Compute the global cell position from the local. + G4ThreeVector globalCellVec = touchable->GetHistory()->GetTopTransform().Inverse().TransformPoint(localCellVec); + + G4cout << "global cell position: " + << std::dec + << globalCellVec.x() << ", " + << globalCellVec.y() << ", " + << globalCellVec.z() << G4endl; +
// No hit was found, so a new one is created.
- hit = new CalorimeterHit(id, edep, G4ThreeVector(globalCellPosition.x(), globalCellPosition.y(), globalCellPosition.z()));
+ hit = new CalorimeterHit(id, edep, globalCellVec);
// Add the new hit to the calorimeter. _calorimeter->addHit(hit, _collectionIndex); } else {
+ //G4cout << "adding " << std::dec << edep << " to existing hit" << G4endl; +
// Add energy deposition to an existing hit. hit->addEdep(edep); }
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1