key4hep / k4geo

DD4hep based geometry models for lepton collider detectors (Formerly known as lcgeo)
GNU General Public License v3.0
8 stars 60 forks source link

Getting correct stave from dd4hep::VolumeManager for different ILD Hadronic Calorimeter #380

Open ggrenier opened 3 months ago

ggrenier commented 3 months ago

I'm running PFA within ILCsoft using ILD detector and the standard ILDConfig Marlin reconstruction. I'm using the ilcsoft build v02-02-03 available on DESY cvmfs. I run on centOS ( more exactly on x86_64_gcc82_centos7 configuration)

I have an issue to get the correct element between dd4hep, lcgeo/k4geo and DDMarlinPandora depending on the used ILD detector.

The DDMarlinPandora CaloHitCreator code has the following debug statement : see https://github.com/iLCSoft/DDMarlinPandora/blob/master/src/DDCaloHitCreator.cc#L696

        auto staveDetElement = m_volumeManager.lookupDetElement( pCaloHit->getCellID0() );
        dd4hep::Position local1(0.0, 0.0, 0.0);
        dd4hep::Position local2(normalVector[0],normalVector[1],normalVector[2]);
        dd4hep::Position global1(0.0, 0.0, 0.0);
        dd4hep::Position global2(0.0, 0.0, 0.0);
        staveDetElement.nominal().localToWorld( local1, global1 );
        staveDetElement.nominal().localToWorld( local2, global2 );
        dd4hep::Position normal( global2-global1 );

        streamlog_out(DEBUG6) << "   detelement: " << staveDetElement.name()
                  << "   parent: " << staveDetElement.parent().name()
                  << "   grandparent: " << staveDetElement.parent().parent().name()
                  << "   cellID: " << pCaloHit->getCellID0()
                              << "   PhiLoc:"  << atan2( global1.y(), global1.x() )*180/M_PI
                              << "   PhiNor:"  << atan2( normal.y(), normal.x() )*180/M_PI
                              << " normal vector "
                              << std::setw(15) << normal.x()
                              << std::setw(15) << normal.y()
                              << std::setw(15) << normal.z()
                              << std::endl;

I'm producing single klong simulation using ddsim.

When running Marlin the code above produces the following kind of output (hit position dependent) :

  1. When using ILD geometry ILD_l5_v02

    [ DEBUG6 "MyDDMarlinPandora"] detelement: stave5 parent: HcalBarrel grandparent: world cellID: 9704278 PhiLoc:0 PhiNor:-180 normal vector -1 -3.33067e-16 0

  2. When using ILD geometry ILD_l2_v02

    [ DEBUG6 "MyDDMarlinPandora"] detelement: HcalBarrel parent: world grandparent: cellID: 64095606 PhiLoc:0 PhiNor:0 normal vector 0 0 1

  3. For both geometry, for the YokeBarrel hits

    [ DEBUG6 "MyDDMarlinPandora"] detelement: stave4layer3module2 parent: module2 grandparent: YokeBarrel cellID: 103515 PhiLoc:3.50835e-15 PhiNor:3.50835e-15 normal vector 1 6.12323e-17 0

So, volumeManager.lookupDetElement( pCaloHit->getCellID0() ) returns stave detector element for detector/calorimeter/Yoke05_Barrel.cpp and for detector/calorimeter/SHcalSc04_Barrel_v04.cpp but returns the parent detector instead of the stave for detector/calorimeter/Hcal_Barrel_SD_v02.cpp

Looking at the 3 codes, I'm not enough familiar with dd4hep syntax to spot how to fix detector/calorimeter/Hcal_Barrel_SD_v02.cpp

andresailer commented 2 months ago

https://github.com/key4hep/k4geo/blob/9e9c87f54addd5149616c5ad1e6974dac2b2ca60/detector/calorimeter/Hcal_Barrel_SD_v02.cpp seems to be missing DetElements at the right levels of the hierarchy.

Something like https://github.com/key4hep/k4geo/blob/9e9c87f54addd5149616c5ad1e6974dac2b2ca60/detector/calorimeter/SHcalSc04_Barrel_v04.cpp#L699-L701

here https://github.com/key4hep/k4geo/blob/9e9c87f54addd5149616c5ad1e6974dac2b2ca60/detector/calorimeter/Hcal_Barrel_SD_v02.cpp#L502