Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Assembly volume and g4-copynumbers #1360

Closed
1 task done
lopezzot opened this issue Nov 29, 2024 · 3 comments · Fixed by #1362
Closed
1 task done

Issue with Assembly volume and g4-copynumbers #1360

lopezzot opened this issue Nov 29, 2024 · 3 comments · Fixed by #1362
Assignees
Labels

Comments

@lopezzot
Copy link

lopezzot commented Nov 29, 2024

Check duplicate issues.

  • Checked for duplicates

Goal

The issue is the reproducibility of g4-copynumbers for volumes placed inside an Assembly volume.

I am placing volumes inside an Assembly volume and assigning g4-copynumbers (j) to them (together with volIDs).

Assembly AssemblyEndcap("DREndcapTubes");
 for (std::size_t j = 0; j < static_cast<std::size_t>(NbOfZRot); j++) {
    // Placement of right endcap (positive z-coordinate)
    RotationZ rotz1(M_PI / 2.); 
    RotationZ rotz2(j * phi_unit); 
    RotationX rotx(M_PI);
    RotationY roty(M_PI);
    Transform3D slice_trnsform(rotz1 * rotz2 * rotx * roty,
                               Position(0, 0, (innerR)*tan(thetaB) + length / 2.));
    PlacedVolume phiERPlaced = AssemblyEndcap.placeVolume(phiERLog, j, slice_trnsform);
    // ID this volume with one number, the rotation
    phiERPlaced.addPhysVolID("stave", j);

    // Placement of left endcap (negative z-coordinate)
    RotationY rotyleft(0.);
    Transform3D slice_trnsformleft(rotz1 * rotz2 * rotx * rotyleft,
                                   Position(0, 0, -1. * ((innerR)*tan(thetaB) + length / 2.)));
    PlacedVolume phiELPlaced = AssemblyEndcap.placeVolume(phiERLog, j+NbOfZRot, slice_trnsformleft);
    phiELPlaced.addPhysVolID("stave", j+NbOfZRot);
  }  // end of slice/stave placement

when I try to access the g4-copynumber in the SDAction code with

auto StaveID = aStep->GetPreStepPoint()->GetTouchable()->GetCopyNumber(4);

this cpno is not the same I set in the geometry code. I believe g4-copynumbers for these volumes are changed by DD4hep in the conversion from TGeo to G4 geometry.

This seems similar to #1271 fixed in #1277.

Thank you.

Operating System and Version

Any

compiler

Any

ROOT Version

Any

DD4hep Version

Any

Reproducer

std::cout<<aStep->GetPreStepPoint()->GetTouchable()->GetCopyNumber()<<std::endl;

this would be different w.r.t. the g4-cpno set in the geometry construction code for volumes placed inside an Assembly.

Additional context

This was spotted while reviewing this k4geo PR key4hep/k4geo#411

@lopezzot lopezzot added the bug label Nov 29, 2024
@andresailer andresailer self-assigned this Dec 4, 2024
@andresailer
Copy link
Member

Hi @lopezzot
Since your reproducer is a bit in the short side...

What copy number do you see, and which copy number do you assign?

@andresailer
Copy link
Member

I am running ctest -V -R t_ClientTests_sim_Assemblies with

index c3b734e5..33c96393 100644
--- a/DDG4/plugins/Geant4SDActions.cpp
+++ b/DDG4/plugins/Geant4SDActions.cpp
@@ -657,6 +657,8 @@ namespace dd4hep {
         //       << " edep: " << h.deposit() << std::endl ;
         void *prePV = h.volume(h.pre), *postPV = h.volume(h.post);
 
+        std::cout << "Copy Number " <<  step->GetPreStepPoint()->GetTouchable()->GetCopyNumber()<<std::endl;
+
         Geant4HitCollection* coll = sensitive->collection(0);
         /// If we are handling a new track, then store the content of the previous one.
         if ( mustSaveTrack(h.track) )  {

And that copy number comes from here

numberOfDaughters + i,

@lopezzot
Copy link
Author

lopezzot commented Dec 5, 2024

I confirm #1362 fixes this issue. Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants