From 33cf2a5dde2c56b6e0d26ee2defdf2bd5ff0d144 Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Thu, 4 Jul 2024 20:08:13 +0200 Subject: [PATCH 1/8] include HCal Endcap in run_thetamodulemerged.py - will work when the following PRs are merged https://github.com/HEP-FCC/k4RecCalorimeter/pull/91 https://github.com/key4hep/k4geo/pull/350 --- FCCSW_ecal/run_thetamodulemerged.py | 59 +++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index 52e0c2b..df6afd4 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -282,11 +282,12 @@ saveHCalTool.CaloHits.Path = hcalBarrelHitsName # - HCAL endcap - # saveHCalEndcapTool = SimG4SaveCalHits( - # "saveHCalEndcapHits", - # readoutName = hcalEndcapReadoutName - # ) - # saveHCalEndcapTool.CaloHits.Path = "HCalEndcapHits" + saveHCalEndcapTool = SimG4SaveCalHits( + "saveHCalEndcapHits", + readoutName = hcalEndcapReadoutName, + OutputLevel=INFO + ) + saveHCalEndcapTool.CaloHits.Path = "HCalEndcapHits" # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") @@ -299,7 +300,7 @@ if runHCal: outputTools += [ saveHCalTool, - # saveHCalEndcapTool + saveHCalEndcapTool ] if saveG4Hist: @@ -491,14 +492,34 @@ createHcalBarrelPositionedCells2.positionedHits.Path = hcalBarrelPositionedCellsName2 # Create cells in HCal endcap - # createHcalEndcapCells = CreateCaloCells("CreateHcalEndcapCaloCells", - # doCellCalibration=True, - # calibTool=calibHcalEndcap, - # addCellNoise=False, - # filterCellNoise=False, - # OutputLevel=INFO) - # createHcalEndcapCells.hits.Path="HCalEndcapHits" - # createHcalEndcapCells.cells.Path="HCalEndcapCells" + # 1 - merge hits into cells with the default readout + hcalEndcapCellsName = "HCalEndcapCells" + createHcalEndcapCells = CreateCaloCells("CreateHCalEndcapCells", + doCellCalibration=True, + calibTool=calibHcalEndcap, + addCellNoise=False, + filterCellNoise=False, + addPosition=True, + hits="HCalEndcapHits", + cells=hcalEndcapCellsName, + OutputLevel=INFO) + + # 2 - attach positions to the cells (cell positions needed for RedoSegmentation!) + #cellPositionHcalEndcapTool = CellPositionsHCalBarrelPhiThetaSegTool( + cellPositionHcalEndcapTool = CellPositionsHCalBarrelPhiThetaSegTool( + "CellPositionsHCalEndcap", + readoutName=hcalEndcapReadoutName, + detectorName="HCalThreePartsEndcap", + OutputLevel=DEBUG + ) + hcalEndcapPositionedCellsName = "HCalEndcapPositionedCells" + createHcalEndcapPositionedCells = CreateCaloCellPositionsFCCee( + "CreateHcalEndcapPositionedCells", + OutputLevel=INFO + ) + createHcalEndcapPositionedCells.positionsTool = cellPositionHcalEndcapTool + createHcalEndcapPositionedCells.hits.Path = hcalEndcapCellsName + createHcalEndcapPositionedCells.positionedHits.Path = hcalEndcapPositionedCellsName else: hcalBarrelCellsName = "emptyCaloCells" @@ -742,10 +763,12 @@ if not saveCells: out.outputCommands.append("drop ECal*Cells*") + out.outputCommands.append("drop HCal*Cells*") if not saveClusterCells: out.outputCommands.append("drop *ClusterCells*") if not saveHits: out.outputCommands.append("drop ECal*Hits*") + out.outputCommands.append("drop HCal*Hits*") # out.filename = "root/output_fullCalo_SimAndDigi_withTopoCluster_MagneticField_"+str(magneticField)+"_pMin_"+str(momentum*1000)+"_MeV"+"_ThetaMinMax_"+str(thetaMin)+"_"+str(thetaMax)+"_pdgId_"+str(pdgCode)+"_pythia"+str(use_pythia)+"_Noise"+str(addNoise)+".root" out.filename = "./root/output_evts_" + str(Nevts) + "_pdg_" + str(pdgCode) + "_" + str(momentum) + "_GeV" + "_ThetaMinMax_" + str(thetaMin) + "_" + str( @@ -761,7 +784,10 @@ createEcalBarrelCells.AuditExecute = True createEcalBarrelPositionedCells.AuditExecute = True if runHCal: - createHcalBarrelCells.AuditExecute = True + createHcalBarrelCells.AuditExecute = + createHcalBarrelPositionedCells.AuditExecute = True + createHcalEndcapCells.AuditExecute = True + createHcalEndcapPositionedCells.AuditExecute = True if doTopoClustering: createTopoClusters.AuditExecute = True out.AuditExecute = True @@ -793,7 +819,8 @@ rewriteHCalBarrel, createHcalBarrelCells2, createHcalBarrelPositionedCells2, - # createHcalEndcapCells + createHcalEndcapCells, + createHcalEndcapPositionedCells ] if doSWClustering or doTopoClustering: From 698aa8497f7989e69942bc093cb559b39a4682a8 Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:09:50 +0200 Subject: [PATCH 2/8] Include Giovanni's comments in run_thetamodulemerged.py --- FCCSW_ecal/run_thetamodulemerged.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index df6afd4..021edf3 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -510,7 +510,7 @@ "CellPositionsHCalEndcap", readoutName=hcalEndcapReadoutName, detectorName="HCalThreePartsEndcap", - OutputLevel=DEBUG + OutputLevel=INFO ) hcalEndcapPositionedCellsName = "HCalEndcapPositionedCells" createHcalEndcapPositionedCells = CreateCaloCellPositionsFCCee( @@ -784,7 +784,7 @@ createEcalBarrelCells.AuditExecute = True createEcalBarrelPositionedCells.AuditExecute = True if runHCal: - createHcalBarrelCells.AuditExecute = + createHcalBarrelCells.AuditExecute = True createHcalBarrelPositionedCells.AuditExecute = True createHcalEndcapCells.AuditExecute = True createHcalEndcapPositionedCells.AuditExecute = True From 58804fe112472f9fb242fef1d704569768486975 Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:04:46 +0200 Subject: [PATCH 3/8] Update cells creation in HCal endcap --- FCCSW_ecal/run_thetamodulemerged.py | 48 +++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index 021edf3..ddd3855 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -500,16 +500,17 @@ addCellNoise=False, filterCellNoise=False, addPosition=True, - hits="HCalEndcapHits", + hits="HCalEndcapPositionedHits", cells=hcalEndcapCellsName, OutputLevel=INFO) # 2 - attach positions to the cells (cell positions needed for RedoSegmentation!) - #cellPositionHcalEndcapTool = CellPositionsHCalBarrelPhiThetaSegTool( - cellPositionHcalEndcapTool = CellPositionsHCalBarrelPhiThetaSegTool( + #cellPositionHcalEndcapTool = CellPositionsHCalPhiThetaSegTool( + cellPositionHcalEndcapTool = CellPositionsHCalPhiThetaSegTool( "CellPositionsHCalEndcap", readoutName=hcalEndcapReadoutName, detectorName="HCalThreePartsEndcap", + numLayersHCalThreeParts=[6,9,22], OutputLevel=INFO ) hcalEndcapPositionedCellsName = "HCalEndcapPositionedCells" @@ -521,6 +522,47 @@ createHcalEndcapPositionedCells.hits.Path = hcalEndcapCellsName createHcalEndcapPositionedCells.positionedHits.Path = hcalEndcapPositionedCellsName + # 3 - compute new cellID of cells based on new readout - removing row information + hcalEndcapCellsName2 = "HCalEndcapCells2" + + # first we create new hits with the readout without the row information + # and then merge them into new cells + rewriteHCalEndcap = RedoSegmentation("ReSegmentationEndcapHcal", + # old bitfield (readout) + oldReadoutName=hcalEndcapReadoutName, + # specify which fields are going to be altered (deleted/rewritten) + oldSegmentationIds=["row", "theta", "phi"], + # new bitfield (readout), with new segmentation (merged modules and theta cells) + newReadoutName=hcalEndcapReadoutName2, + OutputLevel=INFO, + debugPrint=200, + inhits=hcalEndcapPositionedCellsName, + outhits="HCalEndcapCellsWithoutRow") + + createHcalEndcapCells2 = CreateCaloCells("CreateHCalEndcapCells2", + doCellCalibration=False, + addCellNoise=False, + filterCellNoise=False, + OutputLevel=INFO, + hits=rewriteHCalEndcap.outhits.Path, + cells=hcalEndcapCellsName2) + # 4 - attach positions to the new cells + cellPositionHcalEndcapTool2 = CellPositionsHCalPhiThetaSegTool( + "CellPositionsHCalEndcap2", + readoutName=hcalEndcapReadoutName2, + detectorName="HCalThreePartsEndcap", + numLayersHCalThreeParts=[6,9,22], + OutputLevel=INFO + ) + hcalEndcapPositionedCellsName2 = "HCalEndcapPositionedCells2" + createHcalEndcapPositionedCells2 = CreateCaloCellPositionsFCCee( + "CreateHcalEndcapPositionedCells2", + OutputLevel=INFO + ) + createHcalEndcapPositionedCells2.positionsTool = cellPositionHcalEndcapTool2 + createHcalEndcapPositionedCells2.hits.Path = hcalEndcapCellsName2 + createHcalEndcapPositionedCells2.positionedHits.Path = hcalEndcapPositionedCellsName2 + else: hcalBarrelCellsName = "emptyCaloCells" hcalBarrelPositionedCellsName = "emptyCaloCells" From 90524a4de829d86c8dcc07827d61490ca1b15811 Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:06:52 +0200 Subject: [PATCH 4/8] harmonize hits name --- FCCSW_ecal/run_thetamodulemerged.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index ddd3855..766715d 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -287,7 +287,7 @@ readoutName = hcalEndcapReadoutName, OutputLevel=INFO ) - saveHCalEndcapTool.CaloHits.Path = "HCalEndcapHits" + saveHCalEndcapTool.CaloHits.Path = "HCalEndcapPositionedHits" # next, create the G4 algorithm, giving the list of names of tools ("XX/YY") particle_converter = SimG4PrimariesFromEdmTool("EdmConverter") From 899c4112ec07fd05289213432f2c6eadb1e2d161 Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:12:19 +0200 Subject: [PATCH 5/8] add hcalEndcapReadoutName2 --- FCCSW_ecal/run_thetamodulemerged.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index 766715d..f97cc75 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -248,10 +248,12 @@ hcalBarrelReadoutName = "HCalBarrelReadout" # barrel, layer-row-theta-phi based (can be used to fill various cell collections with different readouts) hcalBarrelReadoutName2 = "BarHCal_Readout_phitheta" # barrel, layer-theta-phi based, groups tiles from different rows together (baseline) hcalEndcapReadoutName = "HCalEndcapReadout" # endcap + hcalEndcapReadoutName2 = "HCalEndcapReadout_phitheta" # endcap else: hcalBarrelReadoutName = "" hcalBarrelReadoutName2 = "" hcalEndcapReadoutName = "" + hcalEndcapReadoutName2 = "" # Configure saving of calorimeter positioned hits # - ECAL barrel From 973ea6da6881b4cd9a7943e05ff2849b22a2078c Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:20:27 +0200 Subject: [PATCH 6/8] switch to saveHCalBarrelTool --- FCCSW_ecal/run_thetamodulemerged.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index f97cc75..39e8634 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -276,12 +276,12 @@ if runHCal: # - HCAL barrel hcalBarrelHitsName = "HCalBarrelPositionedHits" - saveHCalTool = SimG4SaveCalHits( + saveHCalBarrelTool = SimG4SaveCalHits( "saveHCalBarrelHits", readoutName=hcalBarrelReadoutName, OutputLevel=INFO ) - saveHCalTool.CaloHits.Path = hcalBarrelHitsName + saveHCalBarrelTool.CaloHits.Path = hcalBarrelHitsName # - HCAL endcap saveHCalEndcapTool = SimG4SaveCalHits( @@ -301,7 +301,7 @@ ] if runHCal: outputTools += [ - saveHCalTool, + saveHCalBarrelTool, saveHCalEndcapTool ] From 63d0aa56aada8619475fc0c1ed93323ce5bcd51c Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:07:34 +0200 Subject: [PATCH 7/8] move to CellPositionsHCalPhiThetaSegTool --- FCCSW_ecal/run_thetamodulemerged.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index 39e8634..40431ca 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -433,8 +433,8 @@ OutputLevel=INFO) # 2 - attach positions to the cells (cell positions needed for RedoSegmentation!) - from Configurables import CellPositionsHCalBarrelPhiThetaSegTool - cellPositionHcalBarrelTool = CellPositionsHCalBarrelPhiThetaSegTool( + from Configurables import CellPositionsHCalPhiThetaSegTool + cellPositionHcalBarrelTool = CellPositionsHCalPhiThetaSegTool( "CellPositionsHCalBarrel", readoutName=hcalBarrelReadoutName, OutputLevel=INFO @@ -478,9 +478,8 @@ cells=hcalBarrelCellsName2) # 4 - attach positions to the new cells - from Configurables import CellPositionsHCalBarrelPhiThetaSegTool hcalBarrelPositionedCellsName2 = "HCalBarrelPositionedCells2" - cellPositionHcalBarrelTool2 = CellPositionsHCalBarrelPhiThetaSegTool( + cellPositionHcalBarrelTool2 = CellPositionsHCalPhiThetaSegTool( "CellPositionsHCalBarrel2", readoutName=hcalBarrelReadoutName2, OutputLevel=INFO @@ -507,7 +506,7 @@ OutputLevel=INFO) # 2 - attach positions to the cells (cell positions needed for RedoSegmentation!) - #cellPositionHcalEndcapTool = CellPositionsHCalPhiThetaSegTool( + # numLayersHCalThreeParts needs to be specified for the Endcap cellPositionHcalEndcapTool = CellPositionsHCalPhiThetaSegTool( "CellPositionsHCalEndcap", readoutName=hcalEndcapReadoutName, From 7723f4473ace78fc1a9d23e033088471aa875d6b Mon Sep 17 00:00:00 2001 From: mmlynari <104267016+mmlynari@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:14:30 +0200 Subject: [PATCH 8/8] small fix for the barrel --- FCCSW_ecal/run_thetamodulemerged.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FCCSW_ecal/run_thetamodulemerged.py b/FCCSW_ecal/run_thetamodulemerged.py index 40431ca..4b634b6 100644 --- a/FCCSW_ecal/run_thetamodulemerged.py +++ b/FCCSW_ecal/run_thetamodulemerged.py @@ -437,6 +437,7 @@ cellPositionHcalBarrelTool = CellPositionsHCalPhiThetaSegTool( "CellPositionsHCalBarrel", readoutName=hcalBarrelReadoutName, + detectorName=="HCalBarrel", OutputLevel=INFO ) hcalBarrelPositionedCellsName = "HCalBarrelPositionedCells" @@ -482,6 +483,7 @@ cellPositionHcalBarrelTool2 = CellPositionsHCalPhiThetaSegTool( "CellPositionsHCalBarrel2", readoutName=hcalBarrelReadoutName2, + detectorName=="HCalBarrel", OutputLevel=INFO ) createHcalBarrelPositionedCells2 = CreateCaloCellPositionsFCCee(