From 034cb021ce48da91235da5ebdfc411ff6015bc62 Mon Sep 17 00:00:00 2001 From: Brieuc Francois Date: Sat, 23 Mar 2024 21:21:05 +0100 Subject: [PATCH] MIT tutorial update (#147) --- .../FCCeeGeneralOverview.md | 59 ++++++++++--------- full-detector-simulations/README.md | 2 +- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/full-detector-simulations/FCCeeGeneralOverview/FCCeeGeneralOverview.md b/full-detector-simulations/FCCeeGeneralOverview/FCCeeGeneralOverview.md index bddbdcbb..647db877 100644 --- a/full-detector-simulations/FCCeeGeneralOverview/FCCeeGeneralOverview.md +++ b/full-detector-simulations/FCCeeGeneralOverview/FCCeeGeneralOverview.md @@ -3,7 +3,7 @@ Welcome to this general overview of the FCC-ee Full Simulation. -This tutorial aims at showing you how to run the state of the art full simulation of the various detector concepts currently under study for FCC-ee: CLD, ALLEGRO and IDEA. The [DD4hep](https://dd4hep.web.cern.ch/dd4hep/usermanuals/DD4hepManual/DD4hepManual.pdf) geometry descriptions of these detectors are hosted in the [k4geo](https://github.com/key4hep/k4geo/tree/main/FCCee) GitHub repository and made centrally available with the Key4hep stack under the `$K4GEO` environment variable. This tutorial should work on any `Alma9` machine with `cvmfs` access. +This tutorial aims at showing you how to run the state of the art full simulation of the various detector concepts currently under study for FCC-ee: CLD, ALLEGRO and IDEA. The [DD4hep](https://dd4hep.web.cern.ch/dd4hep/usermanuals/DD4hepManual/DD4hepManual.pdf) geometry descriptions of these detectors are hosted in the [k4geo](https://github.com/key4hep/k4geo/tree/main/FCCee) GitHub repository and made centrally available with the Key4hep stack under the `$K4GEO` environment variable. This tutorial should work on any machine with `cvmfs` access and running an operating system supported by Key4hep (AlmaLinux 9 and Ubuntu 22). @@ -24,7 +24,7 @@ cd fcc-tutorials/full-detector-simulations/FCCeeGeneralOverview/ ## Towards Full Sim physics analyses with CLD -The CLD detector has a complete geometry description and reconstruction chain. It is thus a very good candidate to start full sim physics analyses. To illustrate that, we will process some physics events through its Geant4 simulation and reconstruction, look at automatically generated diagnostic plots and produce ourselves a higher level quantity plot. +The CLD detector has a complete geometry description and reconstruction chain. It is thus a very good candidate to start full sim physics analyses. To illustrate that, we will process some physics events through its Geant4 simulation and reconstruction, look at automatically generated diagnostic plots and produce ourselves the Higgs recoil mass. ### Running CLD simulation @@ -32,13 +32,16 @@ Let's first run the CLD Geant4 simulation, through ddsim, for some $e^{+}e^{-} \ ```bash -# retrieve Z(mumu)H(X) MC generator events +# retrieve Z(mumu)H(X) MC generator events wget http://fccsw.web.cern.ch/fccsw/tutorials/MIT2024/wzp6_ee_mumuH_ecm240_GEN.stdhep.gz gunzip wzp6_ee_mumuH_ecm240_GEN.stdhep.gz # run the Geant4 simulation -ddsim -I wzp6_ee_mumuH_ecm240_GEN.stdhep -N 10 -O wzp6_ee_mumuH_ecm240_CLD_SIM.root --compactFile $K4GEO/FCCee/CLD/compact/CLD_o2_v05/CLD_o2_v05.xml +ddsim -I wzp6_ee_mumuH_ecm240_GEN.stdhep -N 10 -O wzp6_ee_mumuH_ecm240_CLD_SIM.root --compactFile $K4GEO/FCCee/CLD/compact/CLD_o2_v05/CLD_o2_v05.xml # NB: we run only on 10 events (-N 10) here for the sake of time +# for such small amount of event the detector geometry construction step dominates, it takes about 5 seconds per events and the geometry loading takes 1min30s ``` + + This will produce an output file in edm4hep dataformat with Geant4 SimHits that can then be fed to the reconstruction step. Note that ddsim can also digest other MC output format like `hepevt`, `hepmc`, `pairs` (GuineaPig output), ..., and of course also has particle gun**s** as we will see later. More information can be obtained with `ddsim -h`. @@ -50,7 +53,8 @@ Let's now apply the CLD reconstruction (from ILCSoft through the Gaudi wrappers cd ../../../ git clone https://github.com/key4hep/CLDConfig.git cd CLDConfig/CLDConfig -k4run CLDReconstruction.py --inputFiles ../../fcc-tutorials/full-detector-simulations/FCCeeGeneralOverview/wzp6_ee_mumuH_ecm240_CLD_SIM.root --outputBasename ../../fcc-tutorials/full-detector-simulations/FCCeeGeneralOverview/wzp6_ee_mumuH_ecm240_CLD_RECO --num-events -1 +sed -i "s/DEBUG/INFO/" CLDReconstruction.py +k4run CLDReconstruction.py --inputFiles ../../fcc-tutorials/full-detector-simulations/FCCeeGeneralOverview/wzp6_ee_mumuH_ecm240_CLD_SIM.root --outputBasename ../../fcc-tutorials/full-detector-simulations/FCCeeGeneralOverview/wzp6_ee_mumuH_ecm240_CLD_RECO --num-events -1 # Do not forget to modify the geoservice.detectors variable if you do not use the central detector cd ../../fcc-tutorials/full-detector-simulations/FCCeeGeneralOverview/ ``` @@ -66,7 +70,7 @@ A detailed documentation on the collection content still has to be written. NB: this step also produces a file named `wzp6_ee_mumuH_ecm240_CLD_RECO_aida.root` where you can find a lot of debugging distributions such as the pulls of the track fit. -### Plotting the Higgs recoil mass +### Plotting the Higgs recoil mass Let's now use the reconstructed sample to produce some physics quantities. As an example, we will plot the Higgs recoil mass using the Python bindings of [PODIO](https://github.com/key4hep/key4hep-tutorials/blob/main/edm4hep_analysis/edm4hep_api_intro.md#reading-edm4hep-files). The following very simple script already does a decent job: @@ -136,11 +140,11 @@ cd .. ``` In the xml compact file, the detector builder to use is specified by the `type` keyword in the `detector` beacon (e.g. ``) and it should match the detector type defined in the C++ builder with the instruction `DECLARE_DETELEMENT(MYCOOLDETECTOR)`. -Now lets first modify the sub-detector content of ALLEGRO. Since we will deal with the calorimeter, let's remove the drift chamber to run faster. For this, you just need to open the main detector "compact file" (`xml` file with detector parameters) with your favorite text editor and remove the import of the drift chamber (line 39), for instance: +Now lets first modify the sub-detector content of ALLEGRO. Since we will deal with the calorimeter, let's remove the drift chamber to run faster. For this, you just need to open the main detector "compact file" (`xml` file with detector parameters) with your favorite text editor and remove the import of the drift chamber (line 39), for instance: ``` # copy paste won't work here -vim $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/ALLEGRO_o1_v02.xml +vim $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/ALLEGRO_o1_v02.xml :39 dd :wq @@ -150,7 +154,7 @@ dd Let's now run a first particle gun simulation: -``` +```bash cd fcc-tutorials/full-detector-simulations/FCCeeGeneralOverview/ ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle e- --gun.thetaMin "55*degree" --gun.thetaMax "125*degree" --numberOfEvents 100 --outputFile electron_gun_10GeV_ALLEGRO_SIM.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/ALLEGRO_o1_v02.xml ``` @@ -163,13 +167,13 @@ k4run run_ALLEGRO_RECO.py --EventDataSvc.input="electron_gun_10GeV_ALLEGRO_SIM.r Now let's plot the energy resolution for raw clusters and MVA calibrated clusters: -``` +```bash python plot_calo_energy_resolution.py electron_gun_10GeV_ALLEGRO_RECO.root display electron_gun_10GeV_ALLEGRO_RECO_clusterEnergyResolution.png display electron_gun_10GeV_ALLEGRO_RECO_calibratedClusterEnergyResolution.png ``` -Look at both distributions to see how the MVA calibration improves the performance, both in terms of response and resolution. +Look at both distributions to see how the MVA calibration improves the performance, both in terms of response and resolution. NB: the MVA calibration was not trained exactly in the configuration used here. ### Changing Liquid Argon to Liquid Krypton @@ -177,7 +181,7 @@ In a sampling calorimeter, the ratio between the energy deposited in the dead ab ``` vim $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/ECalBarrel_thetamodulemerged.xml -# change "LAr" to "LKr" in line 114 and 121 +# change "LAr" to "LKr" in line 114 and 121 ``` And to accomodate this change, we have to update the sampling fraction in the steering file: @@ -186,44 +190,46 @@ And to accomodate this change, we have to update the sampling fraction in the st vim run_ALLEGRO_RECO.py # comment out line 105 and uncomment line 106 ``` -The derivation of new sampling fractions upon geometry change is done by ECAL experts and is out of scope for this tutorial. +The derivation of new sampling fractions upon geometry change is out of scope for this tutorial. Let's now re-run the simulation with the modified detector: -``` -ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle e- --numberOfEvents 100 --outputFile electron_gun_10GeV_ALLEGRO_LKr_SIM.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/ALLEGRO_o1_v02.xml +```bash +ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle e- --gun.thetaMin "55*degree" --gun.thetaMax "125*degree" --numberOfEvents 100 --outputFile electron_gun_10GeV_ALLEGRO_LKr_SIM.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v02/ALLEGRO_o1_v02.xml k4run run_ALLEGRO_RECO.py --EventDataSvc.input="electron_gun_10GeV_ALLEGRO_LKr_SIM.root" --out.filename="electron_gun_10GeV_ALLEGRO_LKr_RECO.root" python plot_calo_energy_resolution.py electron_gun_10GeV_ALLEGRO_LKr_RECO.root -display electron_gun_10GeV_ALLEGRO_LKr_RECO_calibratedClusterEnergyResolution.png +display electron_gun_10GeV_ALLEGRO_LKr_RECO_clusterEnergyResolution.png ``` -You can see that the energy resolution did not improve. This can be due to multiple reasons: the derivation of the sampling fractions was done with little statistics for the LKr option, the MVA calibration was not re-trained, we plot only 100 events, ... But at least now you know how to change some of the detector free parameters :-) +See how the energy resolution improved with LKr. NB: here the MVA calibration should be retrainned to achieve good performance. + ## Towards IDEA tracking with the detailed Drift Chamber -The IDEA tracking system Full Sim description is getting complete (we are just missing the Silicon Wrapper which will arrive soon) and we now have to design tracking algorithms. In this exercise we will produce a dataset containing Vertex and Drift Chamber digitized hits and which can therefore be used to develop tracking algorithms. +The IDEA tracking system Full Sim description is getting complete: the Vertex and Drift Chamber have a geometry description and a digitizer while the Silicon Wrapper is on its way. We can thus start to work on the tracking algorithms implementation. In this exercise, we will produce a dataset containing Vertex and Drift Chamber digitized hits and which can therefore be used as input to develop these tracking algorithms. -Let's run the IDEA simulation and digitization: +For this, let's run the IDEA simulation and digitization: -``` +```bash ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle e- --numberOfEvents 100 --outputFile electron_gun_10GeV_IDEA_SIM.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/IDEA/compact/IDEA_o1_v02/IDEA_o1_v02.xml - k4run run_IDEA_DIGI.py --EventDataSvc.input="electron_gun_10GeV_IDEA_SIM.root" --out.filename="electron_gun_10GeV_IDEA_DIGI.root" +k4run run_IDEA_DIGI.py --EventDataSvc.input="electron_gun_10GeV_IDEA_SIM.root" --out.filename="electron_gun_10GeV_IDEA_DIGI.root" ``` -The following collections will be useful for tracking: -``` +The following collections are the one to use for tracking: +```cpp CDCHDigis extension::DriftChamberDigi VTXDDigis edm4hep::TrackerHit3D VTXIBDigis edm4hep::TrackerHit3D VTXOBDigis edm4hep::TrackerHit3D ``` -Note that the drift chamber digitized hit has two positions (on the left or on the right of the wire) because the only accessible information from a drift chamber is the distance to the wire which is degenerated. This left/right ambiguity is alleviated in the tracking algorithm. +Note that the `extension::DriftChamberDigi` object has two positions attached: one if we assume that the hit is on the left of the wire and one assuming it was on the right. cause the only accessible information from a drift chamber is the distance to the wire which is degenerated. This left/right ambiguity comes from the fact that only the distance to the wire is known and is alleviated during the tracking step. You can now play with the digitized hits: -``` +```cpp root electron_gun_10GeV_IDEA_DIGI.root +# to be ran one by one (no full copy paste) events->Draw("leftHitSimHitDeltaDistToWire") // this is the difference of the distance to the wire between the left digi and the sim hit (only produced in debug mode) -events->Draw("CDCHDigis.rightPosition.x:CDCHDigis.rightPosition.y:CDCHDigis.rightPosition.z") // you can see that there was no magnetic field in this simulation and you can see the secondaries created inside the tracking volume +events->Draw("CDCHDigis.rightPosition.x:CDCHDigis.rightPosition.y:CDCHDigis.rightPosition.z") // you can see the electron trajectories events->Draw("CDCHHits.eDep/CDCHHits.pathLength", "CDCHHits.eDep/CDCHHits.pathLength < 4e-7") // this shows the de/dx from the simHits ``` @@ -260,4 +266,3 @@ This tool is useful but not perfect and will not meet all the needs (especially - [Key4hep tutorial](https://key4hep.github.io/key4hep-doc/setup-and-getting-started/README.html) - [FCC Full Sim webpage](https://fcc-ee-detector-full-sim.docs.cern.ch/) - Bi-weekly FCC Full Sim [working meeting](https://indico.cern.ch/category/16938/) - diff --git a/full-detector-simulations/README.md b/full-detector-simulations/README.md index 4f1fde1f..deef2d57 100644 --- a/full-detector-simulations/README.md +++ b/full-detector-simulations/README.md @@ -1,4 +1,4 @@ -# Full Detector Simulations +# Full Simulation If you have any problems or questions, you can