Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions DD4hepTutorials/LICENSE

This file was deleted.

26 changes: 5 additions & 21 deletions DD4hepTutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,18 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
# DD4hepTutorials for DRD6
# DD4hepTutorials for DRDCalo

Welcome to the DD4hep Tutorials for DRD6 repository!
Welcome to the DD4hep Tutorials of DRDCalo repository!

This repository contains hands-on exercises to help you learn DD4hep, a powerful detector description framework. The exercises are organized into separate folders:

- **simplecalo1**: Learn the fundamentals of DD4hep by building your first simplified calorimeter.
- **simplecalo2**: Build on simplecalo1 and explore how to set up a custom Geant4 Sensitive Detector.

The tutorials should be run after sourcing the Key4hep environment.
To do this, you will need access to an Alma9 machine with CVMFS.

The first step is to **build the repository**:

```bash
# Login to an Alma9 machine with CVMFS mounted, e.g. lxplus
source /cvmfs/sw.hsf.org/key4hep/setup.sh
git clone git@github.com:DRD6/DD4hepTutorials.git
cd DD4hepTutorials
mkdir build install
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=../install -Wno-dev
make install -j 8
cd ..
# The following command configures the environment to ensure the system can locate the DD4hep detector builders:
k4_local_repo
```

For instructions on **simplecalo1** and **simplecalo2** follow [this presentation](https://indico.ijclab.in2p3.fr/event/11400/sessions/5873/attachments/25413/37372/DRD6DD4hepTutorial_April2025.pdf).

## Previous editions of this tutorial
- April 2025, DRDCalo Collaboration Meeting [presentation](https://indico.ijclab.in2p3.fr/event/11400/sessions/5873/attachments/25413/37372/DRD6DD4hepTutorial_April2025.pdf)

Happy coding! :rocket:
27 changes: 26 additions & 1 deletion DD4hepTutorials/sdaction/src/simplecaloSDAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ namespace sim {
if (std::abs(localPosition.x()) > 30. || std::abs(localPosition.y()) > 30.) {
return true;
}
// end of Hands-on 5
*/

// Create the hits and accumulate contributions from multiple steps
Expand All @@ -135,11 +136,35 @@ namespace sim {
hit->cellID = VolID; // this should be assigned only once
// we divide the coordinated by 10 to save them as cm
Position HitCellPos(CellPos.x() / 10, CellPos.y() / 10, CellPos.z() / 10);
hit->position = CellPos; // this should be assigned only once
hit->position = HitCellPos; // this should be assigned only once
hit->energyDeposit = aStep->GetTotalEnergyDeposit();

// Hands-on 6: add calo hit contributions
//
// Crete the first contribution associated to this hit
/*Geant4Calorimeter::Hit::Contribution contrib;
contrib.trackID = aStep->GetTrack()->GetTrackID();
contrib.deposit = aStep->GetTotalEnergyDeposit();
contrib.time = aStep->GetPreStepPoint()->GetGlobalTime();
contrib.x = HitCellPos.x(); contrib.y = HitCellPos.y(); contrib.z = HitCellPos.z();
hit->truth.emplace_back(contrib);*/
// end on Hands-on 6

coll->add(VolID, hit); // add the hit to the hit collection
} else { // if the hit exists already, increment its fields
hit->energyDeposit += aStep->GetTotalEnergyDeposit();

// Hands-on 6: add calo hit contributions
//
// Add a new contribution associated to this hit
/*Geant4Calorimeter::Hit::Contribution contrib;
contrib.trackID = aStep->GetTrack()->GetTrackID();
contrib.deposit = aStep->GetTotalEnergyDeposit();
contrib.time = aStep->GetPreStepPoint()->GetGlobalTime();
Position HitCellPos(CellPos.x() / 10, CellPos.y() / 10, CellPos.z() / 10);
contrib.x = HitCellPos.x(); contrib.y = HitCellPos.y(); contrib.z = HitCellPos.z();
hit->truth.emplace_back(contrib);*/
// end on Hands-on 6
}

return true;
Expand Down
18 changes: 0 additions & 18 deletions DD4hepTutorials/simplecalo1/compact/elements.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
<!--
-- Copyright (c) 2020-2024 Key4hep-Project.
--
-- This file is part of Key4hep.
-- See https://key4hep.github.io/key4hep-doc/ for further info.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-->
<materials>
<element Z="89" formula="Ac" name="Ac" >
<atom type="A" unit="g/mol" value="227.028" />
Expand Down
18 changes: 0 additions & 18 deletions DD4hepTutorials/simplecalo1/compact/simplecalo1.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
<!--
-- Copyright (c) 2020-2024 Key4hep-Project.
--
-- This file is part of Key4hep.
-- See https://key4hep.github.io/key4hep-doc/ for further info.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-->
<lccdd>
<!-- #==========================================================================
# AIDA Detector description implementation
Expand Down
18 changes: 0 additions & 18 deletions DD4hepTutorials/simplecalo2/compact/elements.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
<!--
-- Copyright (c) 2020-2024 Key4hep-Project.
--
-- This file is part of Key4hep.
-- See https://key4hep.github.io/key4hep-doc/ for further info.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-->
<materials>
<element Z="89" formula="Ac" name="Ac" >
<atom type="A" unit="g/mol" value="227.028" />
Expand Down
18 changes: 0 additions & 18 deletions DD4hepTutorials/simplecalo2/compact/simplecalo2.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
<!--
-- Copyright (c) 2020-2024 Key4hep-Project.
--
-- This file is part of Key4hep.
-- See https://key4hep.github.io/key4hep-doc/ for further info.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-->
<lccdd>
<!-- #==========================================================================
# AIDA Detector description implementation
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SoftwareTutorials


This repository hosts a variety of software tutorials related to DRDCalo (formerly DRD6) Collaboriation.activities.
This repository hosts a variety of software tutorials related to DRDCalo (formerly DRD6) Collaboriation activities.
It includes the tutorials on DD4hep and Gaudi, presented in the 2nd and 4th Collaboration Meeting respectively.

Ideally, this repository is expanded with relevant tutorials in the future.
Expand All @@ -12,7 +12,7 @@ The tutorials can be completed by following the presentation slides linked in th
## Compilation

These tutorials are made within the key4hep environment.
To compile and run them, access to an Alma9 machine with `/cvmfs/` mounted to source the key4hep stack is required.
To compile and run them, access to an Alma9 machine with `/cvmfs/` mounted (e.g. lxplus) to source the key4hep stack is required.

To clone and build the repository, run the following commands:

Expand Down
Loading