From eb91b894963dda9f0ddcfef7a3760cbd326f1bef Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Sat, 4 Sep 2021 18:19:43 +0200 Subject: [PATCH 01/24] First version lcsim file 2021 MC FEE --- .../EcalFEECalibration2021MC.lcsim | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim new file mode 100644 index 0000000000..4e65079ad1 --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + EcalHits + EcalHitsIter1 + ecalGains.txt + + + EcalClustersIter1 + EcalHitsIter1 + + + EcalClustersIter1 + true + yes + 0 + 100 + 0.5 + 6.0 + 0.5 + 6.0 + + + EcalCalHits EcalClusters + ${outputFile}.slcio + + + + + ${outputFile}.root + + + From a881eccab27dcdcd58de5e956c8ef6827f26e259 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Sat, 4 Sep 2021 18:42:52 +0200 Subject: [PATCH 02/24] Explicitly setting the hit threshold in the steering file --- .../main/java/org/hps/recon/ecal/IterateGainFactorDriver.java | 1 + .../org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim | 1 + 2 files changed, 2 insertions(+) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java index 8084cbd0c6..678815cc46 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java @@ -105,6 +105,7 @@ private void readGainFile() { } catch (IOException e) { e.printStackTrace(); } + System.out.println("ECAL Gain Factors were read"); } @Override diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim index 4e65079ad1..1ee13ad10c 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim @@ -19,6 +19,7 @@ EcalClustersIter1 EcalHitsIter1 + 0.0075 EcalClustersIter1 From 7f1fcea6b533d945837e751ca89f47822120cb03 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Tue, 26 Oct 2021 17:55:49 +0200 Subject: [PATCH 03/24] Adding two steering files, one to recon data (FEE only), oe to process the FEE --- .../calibration/EcalFEECalibration2021.lcsim | 50 +++++++++++++ .../recon/PhysicsRun2021_NoSVT_NoRF.lcsim | 70 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim create mode 100644 steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim new file mode 100644 index 0000000000..7048626e72 --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + EcalHitsIter1 + EcalHitsIter2 + ecalGains.txt + + + EcalClustersIter1 + EcalHitsIter1 + + + EcalClustersIter1 + yes + 30 + 65 + 0.5 + 6.0 + 0.5 + 6.0 + + + EcalCalHits EcalClusters + ${outputFile}.slcio + + + + + ${outputFile}.root + + + diff --git a/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim b/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim new file mode 100644 index 0000000000..540f57af94 --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + CONFIG + + + + + + + + + + WARNING + EcalClusters + + + EcalClusters + EcalClustersCorr + + + + + + CONFIG + + + + true + 8 + CONFIG + + + + ${outputFile}.slcio + + + + + + From 1aa7e166f72a510f0b2c77371c5559bf248e470f Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Wed, 27 Oct 2021 19:14:49 +0200 Subject: [PATCH 04/24] Fixing two steering files --- .../hps/steering/calibration/EcalFEECalibration2021MC.lcsim | 6 +++--- .../org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim index 1ee13ad10c..974e6c61fe 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim @@ -1,7 +1,7 @@ - + @@ -9,8 +9,8 @@ - - + EcalHits EcalHitsIter1 diff --git a/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim b/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim index 540f57af94..769956f7cd 100644 --- a/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/recon/PhysicsRun2021_NoSVT_NoRF.lcsim @@ -30,13 +30,13 @@ - CONFIG + CONFIG - + From a016ce6f3a765b7cf57b9502c8f54902aff150ce Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Fri, 29 Oct 2021 09:15:20 +0200 Subject: [PATCH 05/24] Fixing EcalFEECAlibration2021 --- .../org/hps/steering/calibration/EcalFEECalibration2021.lcsim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim index 7048626e72..31a9ca4da9 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim @@ -19,13 +19,13 @@ 10115 --> - EcalHitsIter1 + EcalHits EcalHitsIter2 ecalGains.txt + EcalHitsIter2 EcalClustersIter1 - EcalHitsIter1 EcalClustersIter1 From 118b257e6e5bc92b67dcc8af7fa056452b8bb7a5 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Fri, 29 Oct 2021 10:35:39 +0200 Subject: [PATCH 06/24] fixing steering file --- .../org/hps/steering/calibration/EcalFEECalibration2021.lcsim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim index 31a9ca4da9..dca1dc8818 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim @@ -19,11 +19,12 @@ 10115 --> - EcalHits + EcalCalHits EcalHitsIter2 ecalGains.txt + CONFIG EcalHitsIter2 EcalClustersIter1 From aff2696477bc2fd4eb609c5b9b95ff2ffb390106 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Mon, 17 Jan 2022 21:09:20 +0100 Subject: [PATCH 07/24] 2021 MC ECAlFEECalibration fixing threshold to 30 MeV --- .../org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim index 974e6c61fe..eca62a0b79 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim @@ -19,7 +19,7 @@ EcalClustersIter1 EcalHitsIter1 - 0.0075 + 0.030 EcalClustersIter1 From ae403ff70a5243fdc485dadfff5a2b66c8775bbb Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Tue, 15 Feb 2022 09:40:05 +0100 Subject: [PATCH 08/24] Adding 30 MeV thr for 2021 to both data and MC; adding list of broken channels in 2021 in the IterateGainFactorDriver --- .../recon/ecal/IterateGainFactorDriver.java | 30 ++++++++++++++++--- .../calibration/EcalFEECalibration2021.lcsim | 2 ++ .../EcalFEECalibration2021MC.lcsim | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java index 678815cc46..c5faec6879 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java @@ -52,16 +52,35 @@ public void setOutputCollectionName(final String outputCollectionName) { } private final String ecalReadoutName = "EcalHits"; - + private int calibYear=0; + private ArrayList badChannels = null; /** * Basic no argument constructor. + A.C.: I add a year-specific set of crystals that are broken, with the corresponding energy to be set to zero for both data and MC. + For the moment, this is hard-coded */ public IterateGainFactorDriver() { + badChannels=new ArrayList(); + if (this.calibYear==2021) { + badChannels.add((long) 6); + badChannels.add((long) 15); + badChannels.add((long) 26); + badChannels.add((long) 153); + badChannels.add((long) 192); + badChannels.add((long) 198); + badChannels.add((long) 275); + badChannels.add((long) 334); + badChannels.add((long) 419); + } } public void setGainFile(String filename) { this.gainFileName = filename; } + + public void setCalibYear(int year) { + this.calibYear=year; + } /** * Read in a text file that has multiplicative factors on the original gain @@ -128,9 +147,12 @@ public List iterateHits(final List hits) { for (final CalorimeterHit hit : hits) { double time = hit.getTime(); long cellID = hit.getCellID(); - double energy = hit.getCorrectedEnergy() * gainFileGains.get(findChannelId(cellID)); - CalorimeterHit newHit = CalorimeterHitUtilities.create(energy, time, cellID); - newHits.add(newHit); + /*Only if the channels is not flagged as "bad", re-compute the energy and create a new CalorimterHit*/ + if (this.badChannels.contains(cellID)==false) { + double energy = hit.getCorrectedEnergy() * gainFileGains.get(findChannelId(cellID)); + CalorimeterHit newHit = CalorimeterHitUtilities.create(energy, time, cellID); + newHits.add(newHit); + } } return newHits; } diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim index dca1dc8818..487fca056b 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021.lcsim @@ -22,11 +22,13 @@ EcalCalHits EcalHitsIter2 ecalGains.txt + 2021 CONFIG EcalHitsIter2 EcalClustersIter1 + 0.030 EcalClustersIter1 diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim index eca62a0b79..fc550f3b27 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021MC.lcsim @@ -15,6 +15,7 @@ EcalHits EcalHitsIter1 ecalGains.txt + 2021 EcalClustersIter1 From 4d0c41ca82e0266e51476530d15fb51b07d386b5 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Tue, 15 Feb 2022 10:17:25 +0100 Subject: [PATCH 09/24] Fixing the IterateGainFactorDriver for the bad channels --- .../recon/ecal/IterateGainFactorDriver.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java index c5faec6879..33e130e571 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java @@ -61,7 +61,22 @@ public void setOutputCollectionName(final String outputCollectionName) { */ public IterateGainFactorDriver() { badChannels=new ArrayList(); + } + + public void setGainFile(String filename) { + this.gainFileName = filename; + } + + public void setCalibYear(int year) { + this.calibYear=year; + System.out.println("IterateGainFactorDriver: setting calib year to "+this.calibYear); + + } + + + public void setBadChannels() { if (this.calibYear==2021) { + System.out.println("Adding the 2021 bad channels"); badChannels.add((long) 6); badChannels.add((long) 15); badChannels.add((long) 26); @@ -72,14 +87,7 @@ public IterateGainFactorDriver() { badChannels.add((long) 334); badChannels.add((long) 419); } - } - - public void setGainFile(String filename) { - this.gainFileName = filename; - } - - public void setCalibYear(int year) { - this.calibYear=year; + System.out.println("IterateGainFactorDriver: bad channels are "+badChannels); } /** @@ -132,6 +140,7 @@ public void detectorChanged(Detector detector) { // ECAL combined conditions object. ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions(); readGainFile(); + setBadChannels(); } /** From a3d0fb5a50abae89ab24945505e4a718e4124ce7 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Tue, 15 Feb 2022 10:22:24 +0100 Subject: [PATCH 10/24] Fixing the IterateGainFactorDriver for the bad channels n.2 --- .../recon/ecal/IterateGainFactorDriver.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java index 33e130e571..f8ca6a048d 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java @@ -53,14 +53,14 @@ public void setOutputCollectionName(final String outputCollectionName) { private final String ecalReadoutName = "EcalHits"; private int calibYear=0; - private ArrayList badChannels = null; - /** + private ArrayList badChannels = null; + /* * Basic no argument constructor. A.C.: I add a year-specific set of crystals that are broken, with the corresponding energy to be set to zero for both data and MC. For the moment, this is hard-coded */ public IterateGainFactorDriver() { - badChannels=new ArrayList(); + badChannels=new ArrayList(); } public void setGainFile(String filename) { @@ -77,15 +77,15 @@ public void setCalibYear(int year) { public void setBadChannels() { if (this.calibYear==2021) { System.out.println("Adding the 2021 bad channels"); - badChannels.add((long) 6); - badChannels.add((long) 15); - badChannels.add((long) 26); - badChannels.add((long) 153); - badChannels.add((long) 192); - badChannels.add((long) 198); - badChannels.add((long) 275); - badChannels.add((long) 334); - badChannels.add((long) 419); + badChannels.add(6); + badChannels.add(15); + badChannels.add(26); + badChannels.add(153); + badChannels.add(192); + badChannels.add(198); + badChannels.add(275); + badChannels.add(334); + badChannels.add(419); } System.out.println("IterateGainFactorDriver: bad channels are "+badChannels); } @@ -156,8 +156,8 @@ public List iterateHits(final List hits) { for (final CalorimeterHit hit : hits) { double time = hit.getTime(); long cellID = hit.getCellID(); - /*Only if the channels is not flagged as "bad", re-compute the energy and create a new CalorimterHit*/ - if (this.badChannels.contains(cellID)==false) { + /*Only if the channels is not flagged as "bad", re-compute the energy and create a new CalorimterHit*/ + if (this.badChannels.contains(findChannelId(cellID))==false) { double energy = hit.getCorrectedEnergy() * gainFileGains.get(findChannelId(cellID)); CalorimeterHit newHit = CalorimeterHitUtilities.create(energy, time, cellID); newHits.add(newHit); From 963d69f74cd0103575599bf93d296269e154029e Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Mon, 28 Feb 2022 08:49:18 +0100 Subject: [PATCH 11/24] Ecal 2021 slopes file --- .../recon/ecal/IterateGainFactorDriver.java | 4 +- .../EcalFEECalibration2021_slope.lcsim | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java index f8ca6a048d..582ab84da0 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/IterateGainFactorDriver.java @@ -156,7 +156,9 @@ public List iterateHits(final List hits) { for (final CalorimeterHit hit : hits) { double time = hit.getTime(); long cellID = hit.getCellID(); - /*Only if the channels is not flagged as "bad", re-compute the energy and create a new CalorimterHit*/ + /*If the channels is not flagged as "bad", re-compute the energy and create a new CalorimterHit + * Otherwise ignore the hit + * */ if (this.badChannels.contains(findChannelId(cellID))==false) { double energy = hit.getCorrectedEnergy() * gainFileGains.get(findChannelId(cellID)); CalorimeterHit newHit = CalorimeterHitUtilities.create(energy, time, cellID); diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim new file mode 100644 index 0000000000..ed326b501e --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + EcalCalHits + EcalHitsIter1 + ecalSlopes.txt + 14316 + + + EcalHitsIter1 + EcalHitsIter2 + ecalGains.txt + 2021 + + + CONFIG + EcalHitsIter2 + EcalClustersIter1 + 0.030 + + + EcalClustersIter1 + yes + 30 + 65 + 0.5 + 6.0 + 0.5 + 6.0 + + + EcalCalHits EcalClusters + ${outputFile}.slcio + + + + + ${outputFile}.root + + + From 5b9a9441627bac0b7bc78168be313aed20784c70 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Mon, 28 Feb 2022 13:42:17 +0100 Subject: [PATCH 12/24] fix --- .../hps/steering/calibration/EcalFEECalibration2021_slope.lcsim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim index ed326b501e..2730e4e9b5 100644 --- a/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalFEECalibration2021_slope.lcsim @@ -2,7 +2,7 @@ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - + From f69c22a3d19ec7f1c5d8a592c56ae5c3b69d3605 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Thu, 10 Mar 2022 17:30:34 +0100 Subject: [PATCH 13/24] Adding 2021 SF driver, MC --- .../org/hps/analysis/ecal/SF2021Driver.java | 424 ++++++++++++++++++ .../hps/steering/calibration/EcalSF2021.lcsim | 32 ++ 2 files changed, 456 insertions(+) create mode 100644 analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java create mode 100644 steering-files/src/main/resources/org/hps/steering/calibration/EcalSF2021.lcsim diff --git a/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java b/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java new file mode 100644 index 0000000000..ecd796e50a --- /dev/null +++ b/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java @@ -0,0 +1,424 @@ +package org.hps.analysis.ecal; + +import hep.aida.IAnalysisFactory; +import hep.aida.IPlotter; + +import java.io.IOException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.hps.conditions.database.DatabaseConditionsManager; +import org.hps.conditions.ecal.EcalChannel; +import org.hps.conditions.ecal.EcalConditions; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.Cluster; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.subdetector.HPSEcal3; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +import org.lcsim.event.MCParticle; +import org.lcsim.event.SimTrackerHit; + +import org.lcsim.event.base.BaseCluster; + +import hep.physics.vec.BasicHep3Vector; +import hep.physics.vec.Hep3Vector; + +import org.hps.detector.ecal.EcalCrystal; +import org.hps.detector.ecal.HPSEcalDetectorElement; + +import org.hps.recon.ecal.cluster.ClusterCorrectionUtilities; + +/** + * This driver is used to check the Sampling Fraction correction for the 2019 + * run, using MC + */ +public class SF2021Driver extends Driver { + + // private AIDAFrame plotterFrame; + private AIDA aida = AIDA.defaultInstance(); + IPlotter plotter; + IAnalysisFactory fac = aida.analysisFactory(); + private String inputCollection = "EcalClusters"; + + public void setInputCollection(final String inputCollection) { + this.inputCollection = inputCollection; + } + + private DatabaseConditionsManager conditionsManager = null; + private EcalConditions ecalConditions = null; + private String histoNameFormat = "%3d"; + + private String outputPlots = null; + + // Set min energy in histo + private double minHistoE; + + // Set max energy in histo + private double maxHistoE; + + private double E0 = 4.5560; + + double BEAMGAPTOP = 20.0; + double BEAMGAPBOT = -20.0; + double BEAMGAPTOPC; + double BEAMGAPBOTC; + + static int MC_GENERATED_PARTICLE = 1; + + + int PID; + + HPSEcal3 ecal; + + public void setBeamEnergy(double beamE) { + System.out.println("SF2019Driver, setBeamEnergy: " + beamE + " GeV "); + this.E0 = beamE; + minHistoE = E0 * 0.1; + maxHistoE = E0 * 1.2; + } + + + public void setPid(int pid) { + PID = pid; + } + + + @Override + protected void detectorChanged(Detector detector) { + + conditionsManager = DatabaseConditionsManager.getInstance(); + ecalConditions = conditionsManager.getEcalConditions(); + + aida.histogram2D("hitPositionEcalImpinging_all", 100, -350., 350., 100, -100., 100.); + aida.histogram2D("hitPositionEcalImpinging", 100, -350., 350., 100, -100., 100.); + + aida.histogram2D("hitPositionEcal_ScoringPlane", 100, -350., 350., 100, -100., 100.); + aida.histogram2D("hitPositionEcal_Cluster", 100, -350., 350., 100, -100., 100.); + + /*aida.tree().cd("/"); + for (EcalChannel cc : ecalConditions.getChannelCollection()) { + aida.histogram1D(getHistoName(cc), 200, minHistoE, maxHistoE); + }*/ + aida.histogram1D("clusterEnergy", 700, 0.5 * E0, 1.2 * E0); + aida.histogram1D("clusterEnergy_cutE0", 700, 0.5 * E0, 1.2 * E0); + aida.histogram1D("clusterEnergy_cutE0_fidcut", 700, 0.5 * E0, 1.2 * E0); + + aida.histogram2D("hitPositionYvsE_yScoringPlane", 100, -100., 100., 700, 0.5 * E0, 1.2 * E0); + aida.histogram2D("hitPositionYvsE_yCluster", 100, -100., 100., 700, 0.5 * E0, 1.2 * E0); + + + + aida.histogram2D("edgeScoringPlane_vs_edgeCluster", 100, 0, 100, 100, 0, 100); + + aida.histogram2D("hitPositionDistancevsE_ScoringPlane", 200, -100., 100., 700, 0.5 * E0, 1.2 * E0); + aida.histogram2D("hitPositionDistancevsE_Cluster", 200, -100., 100., 700, 0.5 * E0, 1.2 * E0); + + + aida.histogram2D("dx_vs_xCluster", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dx_vs_yCluster", 200, -100., 100., 400, -50, 50); + aida.histogram2D("dy_vs_xCluster", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dy_vs_yCluster", 200, -100., 100., 400, -50, 50); + + aida.histogram2D("dx_vs_xScoringPlane", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dx_vs_yScoringPlane", 200, -100., 100., 400, -50, 50); + aida.histogram2D("dy_vs_xScoringPlane", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dy_vs_yScoringPlane", 200, -100., 100., 400, -50, 50); + + aida.histogram2D("dx_vs_xCluster_corr", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dx_vs_yCluster_corr", 200, -100., 100., 400, -50, 50); + aida.histogram2D("dy_vs_xCluster_corr", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dy_vs_yCluster_corr", 200, -100., 100., 400, -50, 50); + + aida.histogram2D("dx_vs_xScoringPlane_corr", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dx_vs_yScoringPlane_corr", 200, -100., 100., 400, -50, 50); + aida.histogram2D("dy_vs_xScoringPlane_corr", 350, -350., 350., 400, -50, 50); + aida.histogram2D("dy_vs_yScoringPlane_corr", 200, -100., 100., 400, -50, 50); + + aida.histogram2D("xScoringPlane_vs_xCluster", 200, -350., 350., 200, -350., 350.); + aida.histogram2D("yScoringPlane_vs_yCluster", 200, -100., 100., 200, -100., 100.); + + aida.histogram2D("xScoringPlane_vs_xCluster_corr", 200, -350., 350., 200, -350., 350.); + aida.histogram2D("yScoringPlane_vs_yCluster_corr", 200, -100., 100., 200, -100., 100.); + + + ecal = (HPSEcal3) detector.getSubdetector("Ecal"); + + // distance to beam gap edge + + + // Get these values from the Ecal geometry - I AM USING SAME code as in + // ClusterEnergyCorrection.java + + + BEAMGAPTOP = 20.0; + try { + BEAMGAPTOP = ecal.getNode().getChild("layout").getAttribute("beamgapTop").getDoubleValue(); + } catch (Exception e) { + try { + BEAMGAPTOP = ecal.getNode().getChild("layout").getAttribute("beamgap").getDoubleValue(); + } catch (Exception ee) { + ee.printStackTrace(); + } + } + BEAMGAPBOT = -20.0; + try { + BEAMGAPBOT = -ecal.getNode().getChild("layout").getAttribute("beamgapBottom").getDoubleValue(); + } catch (Exception e) { + try { + BEAMGAPBOT = -ecal.getNode().getChild("layout").getAttribute("beamgap").getDoubleValue(); + } catch (Exception ee) { + ee.printStackTrace(); + } + } + BEAMGAPTOPC = BEAMGAPTOP + 13.0;// mm + BEAMGAPBOTC = BEAMGAPBOT - 13.0;// mm + + System.out.println("SF2019Driver: BEAMGAPTOP= " + BEAMGAPTOP + " BEAMGAPBOT= " + BEAMGAPBOT); + System.out.println("SF2019Driver: BEAMGAPTOBC= " + BEAMGAPTOPC + " BEAMGAPBOTC= " + BEAMGAPBOTC); + + } + + + /** + * Return the y position relative to the beam gap edge, according to the 2015 + * analysis note convention. + * + + * @param xpos: cluster position X coordinate mm + * @param ypos: cluster position Y coordinate mm + * @return the distance wrt the beam gap, in mm + */ + private double getYpositionFromBeamGapEdge(double xpos, double ypos) { + + double r; + + HPSEcalDetectorElement detElement = (HPSEcalDetectorElement) ecal.getDetectorElement(); + // x-coordinates of crystals on either side of row 1 cut out + EcalCrystal crystalM = detElement.getCrystal(-11, 1); + Hep3Vector posM = crystalM.getPositionFront(); + EcalCrystal crystalP = detElement.getCrystal(-1, 1); + Hep3Vector posP = crystalP.getPositionFront(); + + double matchingPoint = 35; + + + if ((xpos < posM.x()) || (xpos > posP.x())) { + if (ypos > 0) { + r = Math.abs(ypos - BEAMGAPTOP); + } else { + r = Math.abs(ypos - BEAMGAPBOT); + } + } + // crystals above row 1 cut out + else { + if (ypos > 0) { + if (ypos > (matchingPoint + BEAMGAPTOP)) { + r = Math.abs(ypos - BEAMGAPTOP); + } else { + r = Math.abs(ypos - BEAMGAPTOPC); + } + } else { + if (ypos > (-matchingPoint + BEAMGAPBOT)) { + r = Math.abs(ypos - BEAMGAPBOTC); + } else { + r = Math.abs(ypos - BEAMGAPBOT); + } + } + } + + return r; + } + + private String getHistoName(EcalChannel cc) { + return String.format(histoNameFormat, cc.getChannelId()); + } + + public void process(EventHeader event) { + aida.tree().cd("/"); + + int decCalo = 0; + int decTracker = 0; + double scoringE = 0; + + double xpos, ypos; + double xClus, yClus; + + double dX, dY; + + + double edgeDistance_clus; + double edgeDistance_pos; + + int iX, iY; + boolean flagMCgenerator = false; + Hep3Vector scoringP = new BasicHep3Vector(0, 0, 0); + Hep3Vector scoringX = new BasicHep3Vector(0, 0, 0); + + + /*Determine the generated particle*/ + List mcParticles = event.get(MCParticle.class, "MCParticle"); + if (mcParticles.size() < 1) + return; + MCParticle fee = mcParticles.get(0); // just to init + + for (MCParticle particle : mcParticles) { + if (particle.getGeneratorStatus() == SF2021Driver.MC_GENERATED_PARTICLE) { + fee = particle; + flagMCgenerator = true; + break; + } + } + if (!flagMCgenerator) { + return; + } + + + MCParticle.SimulatorStatus simstat = fee.getSimulatorStatus(); + + if (simstat.isDecayedInCalorimeter()) { + decCalo = 1; + } + if (simstat.isDecayedInTracker()) { + decTracker = 1; + } + // System.out.println("FEE: "+fee.getPZ()+" "+decCalo+" "+decTracker); + + if ((decCalo != 1) || (decTracker != 0)) + return; + + + List simTrackerHitList = event.get(SimTrackerHit.class, "TrackerHitsECal"); + for (SimTrackerHit hit : simTrackerHitList) { + Hep3Vector simTrackerHitPos = hit.getPositionVec(); + Hep3Vector simTrackerHitMomentum = new BasicHep3Vector(hit.getMomentum()); + double simTrackerHitTime = hit.getTime(); + if (hit.getMCParticle() == fee) { + if (simTrackerHitMomentum.magnitude() > scoringE) { + scoringX = simTrackerHitPos; + scoringP = simTrackerHitMomentum; + scoringE = simTrackerHitMomentum.magnitude(); + } + } + } + + xpos = scoringX.x(); + ypos = scoringX.y(); + aida.histogram2D("hitPositionEcalImpinging_all").fill(xpos, ypos); + + if (scoringE > 0.85 * E0) { + xpos = scoringX.x(); + ypos = scoringX.y(); + aida.histogram2D("hitPositionEcalImpinging").fill(xpos, ypos); + } + + + List rawClusters = event.get(Cluster.class, inputCollection); + + for (Cluster clus : rawClusters) { + List hits = clus.getCalorimeterHits(); + CalorimeterHit seed = hits.get(0); + double seedE = seed.getCorrectedEnergy(); + double clusE = clus.getEnergy(); + double time = seed.getTime(); + aida.histogram1D("clusterEnergy").fill(clusE); + if (scoringE > 0.85 * E0) { + aida.histogram1D("clusterEnergy_cutE0").fill(clusE); + iX = seed.getIdentifierFieldValue("ix"); + iY = seed.getIdentifierFieldValue("iy"); + + if ((iY == -3) || (iY == -4) || (iY == 3) || (iY == 4)) { + aida.histogram1D("clusterEnergy_cutE0_fidcut").fill(clusE); + } + + xpos = scoringX.x(); + ypos = scoringX.y(); + + xClus = clus.getPosition()[0]; + yClus = clus.getPosition()[1]; + + + dX = xClus - xpos; + dY = yClus - ypos; + + + aida.histogram2D("hitPositionEcal_ScoringPlane").fill(xpos, ypos); + aida.histogram2D("hitPositionEcal_Cluster").fill(xClus, yClus); + + edgeDistance_pos = getYpositionFromBeamGapEdge(xpos, ypos); + edgeDistance_clus = getYpositionFromBeamGapEdge(xClus, yClus); + + aida.histogram2D("yScoringPlane_vs_yCluster").fill(ypos, yClus); + aida.histogram2D("xScoringPlane_vs_xCluster").fill(xpos, xClus); + aida.histogram2D("edgeScoringPlane_vs_edgeCluster").fill(edgeDistance_pos, edgeDistance_clus); + + aida.histogram2D("hitPositionYvsE_yScoringPlane").fill(ypos, clusE); + aida.histogram2D("hitPositionYvsE_yCluster").fill(yClus, clusE); + + aida.histogram2D("hitPositionDistancevsE_ScoringPlane").fill(edgeDistance_pos, clusE); + aida.histogram2D("hitPositionDistancevsE_Cluster").fill(edgeDistance_clus, clusE); + + + aida.histogram2D("dx_vs_xCluster").fill(xClus, dX); + aida.histogram2D("dx_vs_yCluster").fill(yClus, dX); + aida.histogram2D("dy_vs_xCluster").fill(xClus, dY); + aida.histogram2D("dy_vs_yCluster").fill(yClus, dY); + + aida.histogram2D("dx_vs_xScoringPlane").fill(xpos, dX); + aida.histogram2D("dx_vs_yScoringPlane").fill(ypos, dX); + aida.histogram2D("dy_vs_xScoringPlane").fill(xpos, dY); + aida.histogram2D("dy_vs_yScoringPlane").fill(ypos, dY); + + BaseCluster baseClus = new BaseCluster(clus); + baseClus.setParticleId(PID); + baseClus.setNeedsPropertyCalculation(false); + + ClusterCorrectionUtilities.applyCorrections(4.55, ecal, baseClus, true); + xClus = baseClus.getPosition()[0]; + yClus = baseClus.getPosition()[1]; + dX = xClus - xpos; + dY = yClus - ypos; + + aida.histogram2D("dx_vs_xCluster_corr").fill(xClus, dX); + aida.histogram2D("dx_vs_yCluster_corr").fill(yClus, dX); + aida.histogram2D("dy_vs_xCluster_corr").fill(xClus, dY); + aida.histogram2D("dy_vs_yCluster_corr").fill(yClus, dY); + + aida.histogram2D("dx_vs_xScoringPlane_corr").fill(xpos, dX); + aida.histogram2D("dx_vs_yScoringPlane_corr").fill(ypos, dX); + aida.histogram2D("dy_vs_xScoringPlane_corr").fill(xpos, dY); + aida.histogram2D("dy_vs_yScoringPlane_corr").fill(ypos, dY); + + aida.histogram2D("yScoringPlane_vs_yCluster_corr").fill(ypos, yClus); + aida.histogram2D("xScoringPlane_vs_xCluster_corr").fill(xpos, xClus); + + } + } + } + + public void setOutputPlots(String output) { + this.outputPlots = output; + } + + public EcalChannel findChannel(int channel_id) { + return ecalConditions.getChannelCollection().findChannel(channel_id); + } + + public EcalChannel findChannel(CalorimeterHit hit) { + return ecalConditions.getChannelCollection().findGeometric(hit.getCellID()); + } + + public void endOfData() { + System.out.println("OutputFile"); + if (outputPlots != null) { + try { + aida.saveAs("outputSF2019MC.root"); + } catch (IOException ex) { + Logger.getLogger(SF2021Driver.class.getName()).log(Level.SEVERE, null, ex); + } + } + } +} diff --git a/steering-files/src/main/resources/org/hps/steering/calibration/EcalSF2021.lcsim b/steering-files/src/main/resources/org/hps/steering/calibration/EcalSF2021.lcsim new file mode 100644 index 0000000000..6e2a8764f1 --- /dev/null +++ b/steering-files/src/main/resources/org/hps/steering/calibration/EcalSF2021.lcsim @@ -0,0 +1,32 @@ + + + + + + + + + + + ${EcalClustersCollectionName} + yes + ${beamE} + ${pid} + + + EcalCalHits EcalClusters + ${outputFile}.slcio + + + + + ${outputFile}.root + + + 1000 + + + + From 5ecc5118ded04d9f87b22ae4c6d560ee7c1a7a30 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Thu, 10 Mar 2022 17:32:36 +0100 Subject: [PATCH 14/24] missing save --- .../java/org/hps/analysis/ecal/SF2021Driver.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java b/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java index ecd796e50a..02bd91ea04 100644 --- a/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java +++ b/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java @@ -33,7 +33,7 @@ import org.hps.recon.ecal.cluster.ClusterCorrectionUtilities; /** - * This driver is used to check the Sampling Fraction correction for the 2019 + * This driver is used to check the Sampling Fraction correction for the 2021 * run, using MC */ public class SF2021Driver extends Driver { @@ -60,7 +60,7 @@ public void setInputCollection(final String inputCollection) { // Set max energy in histo private double maxHistoE; - private double E0 = 4.5560; + private double E0 = 3.74; double BEAMGAPTOP = 20.0; double BEAMGAPBOT = -20.0; @@ -75,7 +75,7 @@ public void setInputCollection(final String inputCollection) { HPSEcal3 ecal; public void setBeamEnergy(double beamE) { - System.out.println("SF2019Driver, setBeamEnergy: " + beamE + " GeV "); + System.out.println("SF2021Driver, setBeamEnergy: " + beamE + " GeV "); this.E0 = beamE; minHistoE = E0 * 0.1; maxHistoE = E0 * 1.2; @@ -177,8 +177,8 @@ protected void detectorChanged(Detector detector) { BEAMGAPTOPC = BEAMGAPTOP + 13.0;// mm BEAMGAPBOTC = BEAMGAPBOT - 13.0;// mm - System.out.println("SF2019Driver: BEAMGAPTOP= " + BEAMGAPTOP + " BEAMGAPBOT= " + BEAMGAPBOT); - System.out.println("SF2019Driver: BEAMGAPTOBC= " + BEAMGAPTOPC + " BEAMGAPBOTC= " + BEAMGAPBOTC); + System.out.println("SF2021Driver: BEAMGAPTOP= " + BEAMGAPTOP + " BEAMGAPBOT= " + BEAMGAPBOT); + System.out.println("SF2021Driver: BEAMGAPTOBC= " + BEAMGAPTOPC + " BEAMGAPBOTC= " + BEAMGAPBOTC); } @@ -415,7 +415,7 @@ public void endOfData() { System.out.println("OutputFile"); if (outputPlots != null) { try { - aida.saveAs("outputSF2019MC.root"); + aida.saveAs("outputSF2021MC.root"); } catch (IOException ex) { Logger.getLogger(SF2021Driver.class.getName()).log(Level.SEVERE, null, ex); } From 5e129b88f9a123c6c5923e4cd763d18ab548b3b1 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Tue, 22 Mar 2022 09:43:56 +0100 Subject: [PATCH 15/24] Adding 2021 SF parameters for MC only --- .../2021SF_MC_parameters_electrons.dat | 65 +++++++++++++++++++ .../cluster/2021SF_MC_parameters_photons.dat | 1 + .../2021SF_MC_parameters_positrons.dat | 65 +++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_electrons.dat create mode 120000 ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_photons.dat create mode 100644 ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_positrons.dat diff --git a/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_electrons.dat b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_electrons.dat new file mode 100644 index 0000000000..35718314a0 --- /dev/null +++ b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_electrons.dat @@ -0,0 +1,65 @@ +64 +2.5 0.0376134 -0.133219 0.803587 +3.5 0.0376265 -0.151049 0.846674 +4.5 0.0263716 -0.13441 0.862891 +5.5 0.0130311 -0.112819 0.871087 +6.5 -0.000527673 -0.0901444 0.874664 +7.5 -0.00774761 -0.0760884 0.877762 +8.5 -0.0112882 -0.0693794 0.881842 +9.5 -0.00736167 -0.0776796 0.890454 +10.5 -0.00270407 -0.0890544 0.899266 +11.5 0.0158049 -0.123518 0.916354 +12.5 0.0148503 -0.122679 0.918333 +13.5 0.0186582 -0.135269 0.928987 +14.5 0.0235311 -0.151155 0.942661 +15.5 0.0159201 -0.143696 0.944743 +16.5 0.0135794 -0.14861 0.951566 +17.5 0.0145193 -0.155795 0.957597 +18.5 0.0112396 -0.155605 0.96039 +19.5 0.0097296 -0.156281 0.962623 +20.5 0.0134858 -0.16281 0.965569 +21.5 0.0138372 -0.162824 0.965413 +22.5 0.0241148 -0.17786 0.969579 +23.5 0.0237103 -0.175858 0.966624 +24.5 0.0284701 -0.182561 0.96659 +25.5 0.0358676 -0.190728 0.966981 +26.5 0.0445166 -0.195615 0.964698 +27.5 0.0355128 -0.181805 0.962001 +28.5 0.0391405 -0.192089 0.969877 +29.5 0.0343443 -0.189656 0.971914 +30.5 0.0260147 -0.17912 0.969961 +31.5 0.0234389 -0.178432 0.971392 +32.5 0.0213642 -0.178747 0.973159 +33.5 0.0179543 -0.174174 0.971943 +34.5 0.013787 -0.166154 0.968668 +35.5 0.0184419 -0.171583 0.969993 +36.5 0.0235541 -0.176597 0.970176 +37.5 0.0310838 -0.186058 0.971662 +38.5 0.0329181 -0.189919 0.970691 +39.5 0.0383681 -0.196302 0.970039 +40.5 0.0425744 -0.193149 0.964003 +41.5 0.0450861 -0.198503 0.96928 +42.5 0.0396422 -0.190381 0.968891 +43.5 0.0289745 -0.176945 0.965763 +44.5 0.0251115 -0.173589 0.966341 +45.5 0.0217988 -0.173886 0.968787 +46.5 0.0183621 -0.171133 0.96911 +47.5 0.0134967 -0.164149 0.966694 +48.5 0.0122216 -0.160445 0.964253 +49.5 0.00799245 -0.149466 0.958269 +50.5 0.0132337 -0.153487 0.957193 +51.5 0.0182965 -0.158016 0.955678 +52.5 0.0249918 -0.164708 0.952589 +53.5 0.0250911 -0.158872 0.943985 +54.5 0.0123957 -0.121826 0.920095 +55.5 0.00679913 -0.104388 0.911402 +56.5 0.00392602 -0.0969372 0.90656 +57.5 -0.00508209 -0.079817 0.896113 +58.5 -0.0147636 -0.0625214 0.884154 +59.5 -0.0164141 -0.0594603 0.877056 +60.5 -0.0108784 -0.0705658 0.874143 +61.5 -0.00169523 -0.0868869 0.870754 +62.5 0.0069961 -0.100986 0.863026 +63.5 0.0158254 -0.11322 0.849358 +64.5 0.0362143 -0.141523 0.834817 +65.5 0.0524733 -0.168377 0.814544 \ No newline at end of file diff --git a/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_photons.dat b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_photons.dat new file mode 120000 index 0000000000..4fb51580ba --- /dev/null +++ b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_photons.dat @@ -0,0 +1 @@ +2019SF_MC_parameters_photons.dat \ No newline at end of file diff --git a/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_positrons.dat b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_positrons.dat new file mode 100644 index 0000000000..21fd080663 --- /dev/null +++ b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_MC_parameters_positrons.dat @@ -0,0 +1,65 @@ +64 +2.5 0.03079 -0.127739 0.801691 +3.5 0.0175497 -0.111316 0.828815 +4.5 0.0160078 -0.113881 0.853819 +5.5 -0.00225441 -0.085593 0.859772 +6.5 -0.0117407 -0.0704797 0.866094 +7.5 -0.0229067 -0.0508211 0.867752 +8.5 -0.0160828 -0.063248 0.880256 +9.5 -0.017056 -0.0637525 0.885828 +10.5 -0.00608903 -0.0865503 0.899264 +11.5 -0.000216666 -0.0993029 0.907703 +12.5 0.00736236 -0.108698 0.912401 +13.5 0.014203 -0.128415 0.92673 +14.5 0.0112484 -0.131945 0.935602 +15.5 0.0100432 -0.136584 0.942852 +16.5 0.00448691 -0.134974 0.946945 +17.5 0.00234785 -0.139862 0.952922 +18.5 0.00159036 -0.142771 0.956596 +19.5 9.20166e-05 -0.143272 0.958385 +20.5 -0.0024241 -0.141338 0.958509 +21.5 0.00278206 -0.149157 0.961423 +22.5 0.0202686 -0.176165 0.970157 +23.5 0.0241649 -0.181673 0.970253 +24.5 0.028888 -0.187093 0.9691 +25.5 0.0377158 -0.19461 0.968696 +26.5 0.0315903 -0.181175 0.961187 +27.5 0.0377374 -0.190364 0.966456 +28.5 0.0382856 -0.192851 0.970657 +29.5 0.0329601 -0.187619 0.971281 +30.5 0.0204465 -0.172792 0.967981 +31.5 0.0149667 -0.166375 0.967514 +32.5 0.0115778 -0.166198 0.96933 +33.5 0.00866508 -0.160711 0.967458 +34.5 0.00596656 -0.157012 0.966158 +35.5 0.00591205 -0.15332 0.963677 +36.5 0.0142582 -0.165762 0.967573 +37.5 0.0184651 -0.168439 0.965996 +38.5 0.02753 -0.183386 0.968983 +39.5 0.0302747 -0.184456 0.966035 +40.5 0.0386378 -0.189717 0.96401 +41.5 0.053109 -0.210778 0.973953 +42.5 0.0422341 -0.195974 0.97126 +43.5 0.0247786 -0.172384 0.964958 +44.5 0.0198858 -0.169018 0.965941 +45.5 0.00669259 -0.151439 0.960926 +46.5 0.00461721 -0.149855 0.961381 +47.5 -0.000556661 -0.142807 0.959164 +48.5 0.000673244 -0.144479 0.959355 +49.5 -0.00161562 -0.137271 0.95461 +50.5 0.00320433 -0.139461 0.95224 +51.5 0.00643227 -0.139424 0.948779 +52.5 0.0106438 -0.142833 0.944892 +53.5 0.0130232 -0.139479 0.937016 +54.5 0.0062333 -0.113121 0.91768 +55.5 -0.0054013 -0.0846413 0.904011 +56.5 -0.00912061 -0.0779347 0.900476 +57.5 -0.0110691 -0.0727788 0.894226 +58.5 -0.0220605 -0.0535301 0.881928 +59.5 -0.0249785 -0.0475771 0.873186 +60.5 -0.0210844 -0.0549938 0.868733 +61.5 -0.0115277 -0.0708626 0.864527 +62.5 -0.00323225 -0.0851777 0.85725 +63.5 0.0136036 -0.11186 0.849755 +64.5 0.0233509 -0.123462 0.828537 +65.5 0.0056287 -0.0817425 0.776174 \ No newline at end of file From d708b76f9c6b54f30fe6dc55c8a38bf26dc325f3 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Tue, 22 Mar 2022 09:51:10 +0100 Subject: [PATCH 16/24] 2021 MC corrections in ClusterCorrectionUtilities --- .../cluster/ClusterCorrectionUtilities.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java index d2206077e0..447d2fdad1 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java @@ -119,11 +119,12 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, Cluster cl BaseCluster baseCluster = (BaseCluster) cluster; boolean addNoise = false; - // Apply PID based energy correction. - if (beamEnergy > 4.0) { + // Apply PID based energy correction. 2019 and 2021 are a special case + if (beamEnergy > 3.0) { // here we need to play a little bit. - // ClusterEnergyCorrection2019 requires the CORRECT position and the RAW energy - // ClusterPositionCorrection2019 requires the CORRECT energy and the RAW + // ClusterEnergyCorrection2019/2021 requires the CORRECT position and the RAW + // energy + // ClusterPositionCorrection2019/2021 requires the CORRECT energy and the RAW // position. // Idea: iterate from the non-corrected values @@ -146,15 +147,22 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, Cluster cl // and the raw energy baseCluster.setPosition(clusterPosition); baseCluster.setEnergy(clusterEnergy_NC); - ClusterEnergyCorrection2019.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); + if (beamEnergy > 4.0) { + ClusterEnergyCorrection2019.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); + } else { + ClusterEnergyCorrection2021.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); + } double clusterEnergy_C = baseCluster.getEnergy(); // To correct the position, need the correct energy - from previous iteration - // and the raw position baseCluster.setEnergy(clusterEnergy); baseCluster.setPosition(clusterPosition_NC); - ClusterPositionCorrection2019.setCorrectedPosition(baseCluster); - + if (beamEnergy > 4.0) { + ClusterPositionCorrection2019.setCorrectedPosition(baseCluster); + } else { + ClusterPositionCorrection2021.setCorrectedPosition(baseCluster); + } // now set back the energy after correction (the position is already set) baseCluster.setEnergy(clusterEnergy_C); @@ -204,7 +212,17 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, Cluster cl // is different from below, since 2019 corrections are based on the CORRECTED // ENERGY ClusterPositionCorrection2019.setCorrectedPosition(baseCluster); - } else { + } else if (beamEnergy > 3.0) { + // Apply energy correction - this depends on the non-corrected energy (from + // baseCluster) and ypos, from tracking. + ClusterEnergyCorrection2021.setCorrectedEnergy(ecal, baseCluster, ypos, isMC); + // Now the energy is correct, can use the 2019 correction. Note that the order + // is different from below, since 2019 corrections are based on the CORRECTED + // ENERGY + ClusterPositionCorrection2021.setCorrectedPosition(baseCluster); + } + + else { // Apply PID based position correction, which should happen before final energy // correction. ClusterPositionCorrection.setCorrectedPosition(baseCluster); From a0e5fe856d352bf623e72a397e5ba56d7f73414b Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Sat, 2 Apr 2022 15:42:07 +0200 Subject: [PATCH 17/24] 2021 corrections --- .../cluster/ClusterEnergyCorrection2021.java | 382 ++++++++++++++++++ .../ClusterPositionCorrection2021.java | 258 ++++++++++++ 2 files changed, 640 insertions(+) create mode 100644 ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java create mode 100644 ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java new file mode 100644 index 0000000000..9c026ccf37 --- /dev/null +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java @@ -0,0 +1,382 @@ +package org.hps.recon.ecal.cluster; + +import java.io.IOException; +import java.util.Random; + +import org.apache.commons.math3.analysis.interpolation.SplineInterpolator; +import org.apache.commons.math3.analysis.polynomials.PolynomialSplineFunction; +import org.lcsim.event.Cluster; +import org.lcsim.event.base.BaseCluster; +import org.lcsim.geometry.subdetector.HPSEcal3; + +import java.util.logging.Logger; + +/** + * This class handles the cluster energy correction for the 2021 run, to include + * edge corrections and sampling fractions derived from data. + */ +public final class ClusterEnergyCorrection2021 { + + private static final Logger LOG = Logger.getLogger(ClusterEnergyCorrection2021.class.getName()); + + public static String name = "ClusterEnergyCorrection2021"; + + private static final byte DATA = 0; + private static final byte MC = 1; + + static boolean[] hasLoaded = new boolean[] { false, false }; + + // These are the three splices used to interpolate the A,B,C parameters for + // photons - determined from MC + static PolynomialSplineFunction psf_parA_p; + static PolynomialSplineFunction psf_parB_p; + static PolynomialSplineFunction psf_parC_p; + + // These are the three splices used to interpolate the A,B,C parameters for + // electrons + static PolynomialSplineFunction psf_parA_em; + static PolynomialSplineFunction psf_parB_em; + static PolynomialSplineFunction psf_parC_em; + + // These are the three splices used to interpolate the A,B,C parameters for + // positrons + static PolynomialSplineFunction psf_parA_ep; + static PolynomialSplineFunction psf_parB_ep; + static PolynomialSplineFunction psf_parC_ep; + + // p0 and p1 parameters for data + static PolynomialSplineFunction psf_parP0; + static PolynomialSplineFunction psf_parP1; + + private static void loadDataCorrectionParameters() { + String fname; + fname = "2021SF_parameters_data.dat"; + LOG.config("Loading resource data: " + fname); + java.io.InputStream fis = ClusterEnergyCorrection2021.class.getResourceAsStream(fname); + java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(fis)); + try { + String[] arrOfStr; + String line = br.readLine(); + arrOfStr = line.split(" "); + if (arrOfStr.length != 1) { + throw new RuntimeException("Error reading resource file 2021SF_parameters_data.dat first line"); + } + Integer N = new Integer(arrOfStr[0]); + double[] xvals = new double[N]; + double[] yvalsP0 = new double[N]; + double[] yvalsP1 = new double[N]; + + int iline = 0; + while ((line = br.readLine()) != null) { + arrOfStr = line.split(" "); + if (arrOfStr.length != 3) { + throw new RuntimeException("Error reading resource file 2021SF_parameters_data.dat"); + } + xvals[iline] = new Double(arrOfStr[0]); + yvalsP0[iline] = new Double(arrOfStr[1]); + yvalsP1[iline] = new Double(arrOfStr[2]); + iline += 1; + } + if (iline != N) { + throw new RuntimeException("Error in # of lines in resource file. Excepted " + N + ", got " + iline); + } + + psf_parP0 = new SplineInterpolator().interpolate(xvals, yvalsP0); + psf_parP1 = new SplineInterpolator().interpolate(xvals, yvalsP1); + + } catch (IOException x) { + throw new RuntimeException(String.format("Error reading resource file: %s %s%n", fname, x)); + } + + } + + private static void loadDataFromResourceFile(int pdg) { + + String pname; + switch (pdg) { + case 11: + pname = "electrons"; + break; + case -11: + pname = "positrons"; + break; + case 22: + pname = "photons"; + break; + default: + throw new RuntimeException("Unsupported PID=" + pdg); + } + + String fname; + + fname = "2021SF_MC_parameters_" + pname + ".dat"; + + LOG.config("Loading resource data: " + fname); + + java.io.InputStream fis = ClusterEnergyCorrection2021.class.getResourceAsStream(fname); + java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(fis)); + + try { + String[] arrOfStr; + String line = br.readLine(); + arrOfStr = line.split(" "); + if (arrOfStr.length != 1) { + throw new RuntimeException("Error reading resource file first line PID: " + pdg); + } + Integer N = new Integer(arrOfStr[0]); + double[] xvals = new double[N]; + double[] yvalsA = new double[N]; + double[] yvalsB = new double[N]; + double[] yvalsC = new double[N]; + + int iline = 0; + while ((line = br.readLine()) != null) { + arrOfStr = line.split(" "); + if (arrOfStr.length != 4) { + throw new RuntimeException("Error reading resource file first line PID: " + pdg); + } + xvals[iline] = new Double(arrOfStr[0]); + yvalsA[iline] = new Double(arrOfStr[1]); + yvalsB[iline] = new Double(arrOfStr[2]); + yvalsC[iline] = new Double(arrOfStr[3]); + iline += 1; + } + if (iline != N) { + throw new RuntimeException( + "Error in # of lines in resource file. Excepted " + N + ", got " + iline + ", PID=" + pdg); + } + + switch (pdg) { + case 22: + psf_parA_p = new SplineInterpolator().interpolate(xvals, yvalsA); + psf_parB_p = new SplineInterpolator().interpolate(xvals, yvalsB); + psf_parC_p = new SplineInterpolator().interpolate(xvals, yvalsC); + break; + case 11: + psf_parA_em = new SplineInterpolator().interpolate(xvals, yvalsA); + psf_parB_em = new SplineInterpolator().interpolate(xvals, yvalsB); + psf_parC_em = new SplineInterpolator().interpolate(xvals, yvalsC); + break; + case -11: + psf_parA_ep = new SplineInterpolator().interpolate(xvals, yvalsA); + psf_parB_ep = new SplineInterpolator().interpolate(xvals, yvalsB); + psf_parC_ep = new SplineInterpolator().interpolate(xvals, yvalsC); + break; + } + + } catch (IOException x) { + throw new RuntimeException(String.format("Error reading resource file: %s %s%n", fname, x)); + } + } + + private static void loadDataFromResourceFiles(int type) { + if (!hasLoaded[type]) { + loadDataFromResourceFile(11); + loadDataFromResourceFile(-11); + loadDataFromResourceFile(22); + + if (type == DATA) { + loadDataCorrectionParameters(); + } + } + hasLoaded[type] = true; + } + + /** + * Calculates energy correction based on cluster raw energy and particle type as + * per HPS Note 2014-001 + * + * @param ecal + * @param pdg Particle id as per PDG + * @param rawEnergy Raw Energy of the cluster (sum of hits with shared hit + * distribution) + * @param xpos + * @param ypos + * @param isMC + * @return Corrected Energy + */ + public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEnergy, double xpos, double ypos, + boolean isMC) { + + final int type = isMC ? MC : DATA; + + loadDataFromResourceFiles(type); + + // distance to beam gap edge + double r = ClusterCorrectionUtilities.computeYDistanceFromEdge(ecal, xpos, ypos); + + // avoid extrapolation all the way to the edge: + if (r > 65.5) { + r = 65.5; + } else if (r < 2.5) { + r = 2.5; + } + + if (isMC) { + switch (pdg) { + case 11: + // electron + return computeCorrectedEnergy(r, rawEnergy, psf_parA_em, psf_parB_em, psf_parC_em, isMC); + case -11: + // positron + return computeCorrectedEnergy(r, rawEnergy, psf_parA_ep, psf_parB_ep, psf_parC_ep, isMC); + case 22: + // photon + return computeCorrectedEnergy(r, rawEnergy, psf_parA_p, psf_parB_p, psf_parC_p, isMC); + default: + // unknown + return rawEnergy; + } + } else { + switch (pdg) { + case 11: + // electron + return computeCorrectedEnergy(r, rawEnergy, psf_parA_em, psf_parB_em, psf_parC_em, isMC); + case -11: + // positron + return computeCorrectedEnergy(r, rawEnergy, psf_parA_ep, psf_parB_ep, psf_parC_ep, isMC); + case 22: + // photon + return computeCorrectedEnergy(r, rawEnergy, psf_parA_p, psf_parB_p, psf_parC_p, isMC); + default: + // unknown + return rawEnergy; + } + } + } + + /** + * Calculates the energy correction to a cluster given the variables from the + * fit as per HPS Note 2014-001 Note that this is correct as there is a typo in the + * formula print in the note. + * + * @param rawEnergy Raw energy of the cluster + * @param A,B,C from fitting in note + * @return Corrected Energy + */ + private static double computeCorrectedEnergy(double y, double rawEnergy, PolynomialSplineFunction splineA, + PolynomialSplineFunction splineB, PolynomialSplineFunction splineC, boolean isMC) { + + /*A.C. fix*/ + + double A = splineA.value(y); + double B = splineB.value(y); + double C = splineC.value(y); + + double SF, corrEnergy; + corrEnergy = rawEnergy; + if (isMC == true) { + SF = A / rawEnergy + B / Math.sqrt(rawEnergy) + C; + corrEnergy = rawEnergy / SF; + } else { + + double p0, p1, y0, y1; + y0 = y; + y1 = y; + if (y0 < psf_parP0.getKnots()[0]) + y0 = psf_parP0.getKnots()[0]; + if (y0 > psf_parP0.getKnots()[psf_parP0.getN()]) + y0 = psf_parP0.getKnots()[psf_parP0.getN()]; + + if (y1 < psf_parP0.getKnots()[0]) + y1 = psf_parP0.getKnots()[0]; + if (y1 > psf_parP0.getKnots()[psf_parP0.getN()]) + y1 = psf_parP0.getKnots()[psf_parP0.getN()]; + + p0 = psf_parP0.value(y0); + p1 = psf_parP1.value(y1); + SF = A / rawEnergy + B / Math.sqrt(rawEnergy) + C; + SF = SF * (p0 + p1 * rawEnergy); + corrEnergy = rawEnergy / SF; + } + + return corrEnergy; + } + + /** + * Calculate the corrected energy for the cluster. + * + * @param cluster The input cluster. + * @return The corrected energy. + */ + public static final double calculateCorrectedEnergy(HPSEcal3 ecal, Cluster cluster, boolean isMC) { + double rawE = cluster.getEnergy(); + return computeCorrectedEnergy(ecal, cluster.getParticleId(), rawE, cluster.getPosition()[0], + cluster.getPosition()[1], isMC); + } + + /** + * Calculate the corrected energy for the cluster using track position at ecal. + * + * @param cluster The input cluster. + * @return The corrected energy. + */ + public static final double calculateCorrectedEnergy(HPSEcal3 ecal, Cluster cluster, double ypos, boolean isMC) { + double rawE = cluster.getEnergy(); + return computeCorrectedEnergy(ecal, cluster.getParticleId(), rawE, cluster.getPosition()[0], ypos, isMC); + } + + /** + * Calculate the corrected energy and set on the cluster. + * + * @param cluster The input cluster. + */ + public static final void setCorrectedEnergy(HPSEcal3 ecal, BaseCluster cluster, boolean isMC,boolean addNoise) { + double correctedEnergy = calculateCorrectedEnergy(ecal, cluster, isMC); + if (isMC&&addNoise) { + correctedEnergy += ClusterCorrectionUtilities.calcNoise(correctedEnergy); + } + cluster.setEnergy(correctedEnergy); + } + + /** + * Calculate the corrected energy and set on the cluster. + * + * @param cluster The input cluster. + */ + public static final void setCorrectedEnergy(HPSEcal3 ecal, BaseCluster cluster, double ypos, boolean isMC) { + double correctedEnergy = calculateCorrectedEnergy(ecal, cluster, ypos, isMC); + if (isMC) { + correctedEnergy += ClusterCorrectionUtilities.calcNoise(correctedEnergy); + } + cluster.setEnergy(correctedEnergy); + } + + public static void main(String[] args) { + + int type = DATA; + + loadDataFromResourceFiles(type); + + Random r = new Random(); + + for (int ii = 0; ii < 10000; ii++) { + double y = r.nextDouble() * 63 + 2.5; // 1..66; + double A = psf_parA_em.value(y); + double B = psf_parB_em.value(y); + double C = psf_parC_em.value(y); + System.out.println(y + " " + A + " " + B + " " + C); + } + + for (int ii = 0; ii < 10000; ii++) { + double y = r.nextDouble() * 63 + 2.5; // 1..66; + double A = psf_parA_ep.value(y); + double B = psf_parB_ep.value(y); + double C = psf_parC_ep.value(y); + System.out.println(y + " " + A + " " + B + " " + C); + } + + for (int ii = 0; ii < 10000; ii++) { + double y = r.nextDouble() * 63 + 2.5; // 2.5..65.5; + double A = psf_parA_p.value(y); + double B = psf_parB_p.value(y); + double C = psf_parC_p.value(y); + System.out.println(y + " " + A + " " + B + " " + C); + } + + } +} diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java new file mode 100644 index 0000000000..72c960134e --- /dev/null +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java @@ -0,0 +1,258 @@ +package org.hps.recon.ecal.cluster; + +import org.lcsim.event.base.BaseCluster; + +/** + * This uses the uncorrected cluster energy to correct the position of the cluster. + * This should be used before the energy is corrected on the Cluster and after + * cluster-track matching. + * This is to be used with 2021 data + * + * To determine these corrections, we simulated e+ e- and gamma at fixed + * energies over the ECAL acceptance, sampled the true hit position with MC + * scoring plane, and compared with the measured cluster position. We then + * considered: + * + * dX vs X (dX = measured - true) ---> true=measured-dX dY vs Y (dY = measured - + * true) ---> true=measured-dY + * + * We then performed a fit to these with dX = q + m*X dY = q1 + t*Y if x < 0 ; = + * q2 + t*Y if Y > 0 + * + * See also A.C. Talk at Nov. 2020 collaboration meeting + * + * We then checked the dependency of the q,m, q1,q2, t parameters as a function + * of the energy + * + * Electrons and Positrons: parameter(E) = p0 + p1*pow(E,p2) for all parameters + * Photons: par(E) = p0 + p1*pow(E,p2) | par = q,m par(E) = (a + b*E + c*E*E)/(d + * + e*E + f*E*E) | par = q1,t,q2 + */ +final class ClusterPosResult { + private final double X; + private final double Y; + + public ClusterPosResult(double X, double Y) { + this.X = X; + this.Y = Y; + } + + public double getX() { + return X; + } + + public double getY() { + return Y; + } + +} + +public final class ClusterPositionCorrection2021 { + // Parameterizations tested in MC using v3-fieldmap + // Nov 2015 + + // Variables for positron position corrections. + static final double POSITRON_POS_Q_P0 = 0.966731; + static final double POSITRON_POS_Q_P1 = 6.80944; + static final double POSITRON_POS_Q_P2 = -0.517001; + + static final double POSITRON_POS_M_P0 = -0.0321032; + static final double POSITRON_POS_M_P1 = 0.0137824; + static final double POSITRON_POS_M_P2 = -0.657067; + + static final double POSITRON_POS_Q1_P0 = -3.38561; + static final double POSITRON_POS_Q1_P1 = 0.516986; + static final double POSITRON_POS_Q1_P2 = -1.58624; + + static final double POSITRON_POS_Q2_P0 = 2.43338; + static final double POSITRON_POS_Q2_P1 = -0.523349; + static final double POSITRON_POS_Q2_P2 = -1.5865; + + static final double POSITRON_POS_T_P0 = -0.03764; + static final double POSITRON_POS_T_P1 = 0.0086778; + static final double POSITRON_POS_T_P2 = -1.76526; + + // Variables for electron position corrections. + static final double ELECTRON_POS_Q_P0 = 5.94692; + static final double ELECTRON_POS_Q_P1 = -9.50585; + static final double ELECTRON_POS_Q_P2 = -0.520818; + + static final double ELECTRON_POS_M_P0 = -0.0333753; + static final double ELECTRON_POS_M_P1 = 0.0141766; + static final double ELECTRON_POS_M_P2 = -0.590604; + + static final double ELECTRON_POS_Q1_P0 = -3.33536; + static final double ELECTRON_POS_Q1_P1 = 0.367933; + static final double ELECTRON_POS_Q1_P2 = -2.50553; + + static final double ELECTRON_POS_Q2_P0 = 2.38039; + static final double ELECTRON_POS_Q2_P1 = -0.335049; + static final double ELECTRON_POS_Q2_P2 = -2.6066; + + static final double ELECTRON_POS_T_P0 = -0.0372583; + static final double ELECTRON_POS_T_P1 = 0.00688212; + static final double ELECTRON_POS_T_P2 = -2.45476; + + // Variables for photon position corrections. + static final double PHOTON_POS_Q_P0 = 6.05676; + static final double PHOTON_POS_Q_P1 = -3.35614; + static final double PHOTON_POS_Q_P2 = -0.129487; + + static final double PHOTON_POS_M_P0 = -0.0604739; + static final double PHOTON_POS_M_P1 = 0.0345978; + static final double PHOTON_POS_M_P2 = -0.134836; + + static final double PHOTON_POS_Q1_A = -5.35288e-04; + static final double PHOTON_POS_Q1_B = -2.59465e-03; + static final double PHOTON_POS_Q1_C = -1.25344e-02; + static final double PHOTON_POS_Q1_D = 5.38706e-04; + static final double PHOTON_POS_Q1_E = -1.03844e-04; + static final double PHOTON_POS_Q1_F = 3.42212e-03; + + static final double PHOTON_POS_T_A = -2.94034e-05; + static final double PHOTON_POS_T_B = 5.01519e-05; + static final double PHOTON_POS_T_C = -1.61436e-04; + static final double PHOTON_POS_T_D = 9.81269e-04; + static final double PHOTON_POS_T_E = -1.72302e-03; + static final double PHOTON_POS_T_F = 3.44850e-03; + + static final double PHOTON_POS_Q2_A = 7.20260e-01; + static final double PHOTON_POS_Q2_B = -7.33752e-01; + static final double PHOTON_POS_Q2_C = 3.70987e+00; + static final double PHOTON_POS_Q2_D = 4.20218e-01; + static final double PHOTON_POS_Q2_E = -5.84695e-01; + static final double PHOTON_POS_Q2_F = 1.35651e+00; + + /** + * + * @param cluster The cluster to be corrected, where the energy is the + * already-corrected energy. THIS IS DIFFERENT FROM 2015! + * @return The corrected cluster position + */ + + public static double[] calculateCorrectedPosition(BaseCluster cluster) { + double clusterPosition[] = cluster.getPosition(); + + ClusterPosResult correctedPosition = computeCorrectedPosition(cluster.getParticleId(), clusterPosition[0], + clusterPosition[1], cluster.getEnergy()); + + double[] position = new double[3]; + position[0] = correctedPosition.getX(); + position[1] = correctedPosition.getY(); + position[2] = clusterPosition[2]; + + return position; + } + + public static void setCorrectedPosition(BaseCluster cluster) { + cluster.setPosition(calculateCorrectedPosition(cluster)); + } + + /** + * Calculates position correction based on cluster corrected energy, x + * calculated position, and particle type as per HPS + * Note 2014-001 + * + * @param pdg Particle id as per PDG + * @param xCl Calculated x centroid position of the cluster, uncorrected, at + * face + * @param Energy Corrected energy of the cluster + * @return the corrected x position + */ + private static ClusterPosResult computeCorrectedPosition(int pdg, double xPos, double yPos, double Energy) { + // double xCl = xPos / 10.0;//convert to cm + ClusterPosResult res; + double xCorr; + switch (pdg) { + case 11: // Particle is electron + res = positionCorrectionElectron(xPos, yPos, Energy); + break; + case -11:// Particle is positron + res = positionCorrectionPositron(xPos, yPos, Energy); + break; + case 22: // Particle is photon + res = positionCorrectionPhoton(xPos, yPos, Energy); + break; + default: // Unknown + res = new ClusterPosResult(xPos, yPos); + } + return res; + } + + private static ClusterPosResult positionCorrectionElectron(double xPos, double yPos, double Energy) { + double xCorr, yCorr; + double deltaX, deltaY; + + double q = ELECTRON_POS_Q_P0 + ELECTRON_POS_Q_P1 * Math.pow(Energy, ELECTRON_POS_Q_P2); + double m = ELECTRON_POS_M_P0 + ELECTRON_POS_M_P1 * Math.pow(Energy, ELECTRON_POS_M_P2); + double q1 = ELECTRON_POS_Q1_P0 + ELECTRON_POS_Q1_P1 * Math.pow(Energy, ELECTRON_POS_Q2_P2); + double q2 = ELECTRON_POS_Q2_P0 + ELECTRON_POS_Q2_P1 * Math.pow(Energy, ELECTRON_POS_Q2_P2); + double t = ELECTRON_POS_T_P0 + ELECTRON_POS_T_P1 * Math.pow(Energy, ELECTRON_POS_T_P2); + + deltaX = q + m * xPos; + + if (yPos < 0) { + deltaY = q1 + t * yPos; + } else { + deltaY = q2 + t * yPos; + } + + xCorr = xPos - deltaX; + yCorr = yPos - deltaY; + + return new ClusterPosResult(xCorr, yCorr); + } + + private static ClusterPosResult positionCorrectionPositron(double xPos, double yPos, double Energy) { + double xCorr, yCorr; + double deltaX, deltaY; + + double q = POSITRON_POS_Q_P0 + POSITRON_POS_Q_P1 * Math.pow(Energy, POSITRON_POS_Q_P2); + double m = POSITRON_POS_M_P0 + POSITRON_POS_M_P1 * Math.pow(Energy, POSITRON_POS_M_P2); + double q1 = POSITRON_POS_Q1_P0 + POSITRON_POS_Q1_P1 * Math.pow(Energy, POSITRON_POS_Q2_P2); + double q2 = POSITRON_POS_Q2_P0 + POSITRON_POS_Q2_P1 * Math.pow(Energy, POSITRON_POS_Q2_P2); + double t = POSITRON_POS_T_P0 + POSITRON_POS_T_P1 * Math.pow(Energy, POSITRON_POS_T_P2); + + deltaX = q + m * xPos; + + if (yPos < 0) { + deltaY = q1 + t * yPos; + } else { + deltaY = q2 + t * yPos; + } + + xCorr = xPos - deltaX; + yCorr = yPos - deltaY; + + return new ClusterPosResult(xCorr, yCorr); + } + + private static ClusterPosResult positionCorrectionPhoton(double xPos, double yPos, double Energy) { + double xCorr, yCorr; + double deltaX, deltaY; + + double q = PHOTON_POS_Q_P0 + PHOTON_POS_Q_P1 * Math.pow(Energy, PHOTON_POS_Q_P2); + double m = PHOTON_POS_M_P0 + PHOTON_POS_M_P1 * Math.pow(Energy, PHOTON_POS_M_P2); + double q1 = PHOTON_POS_Q1_A + PHOTON_POS_Q1_B * Energy + PHOTON_POS_Q1_C * Energy * Energy + / (PHOTON_POS_Q1_D + PHOTON_POS_Q1_E * Energy + PHOTON_POS_Q1_F * Energy * Energy); + double q2 = PHOTON_POS_Q2_A + PHOTON_POS_Q2_B * Energy + PHOTON_POS_Q2_C * Energy * Energy + / (PHOTON_POS_Q2_D + PHOTON_POS_Q2_E * Energy + PHOTON_POS_Q2_F * Energy * Energy); + double t = PHOTON_POS_T_A + PHOTON_POS_T_B * Energy + PHOTON_POS_T_C * Energy * Energy + / (PHOTON_POS_T_D + PHOTON_POS_T_E * Energy + PHOTON_POS_T_F * Energy * Energy); + + deltaX = q + m * xPos; + + if (yPos < 0) { + deltaY = q1 + t * yPos; + } else { + deltaY = q2 + t * yPos; + } + + xCorr = xPos - deltaX; + yCorr = yPos - deltaY; + + return new ClusterPosResult(xCorr, yCorr); + } + +} From 23ee99620fff554dc18e468fbc1f5d4be0824b05 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Thu, 14 Apr 2022 17:49:38 +0200 Subject: [PATCH 18/24] Fix ClusterCorrectionUtilities2021 --- .../org/hps/analysis/ecal/SF2021Driver.java | 2 +- .../cluster/ClusterCorrectionUtilities.java | 140 +++++++++++++++--- .../ClusterPositionCorrection2019.java | 24 +-- .../ClusterPositionCorrection2021.java | 24 +-- 4 files changed, 148 insertions(+), 42 deletions(-) diff --git a/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java b/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java index 02bd91ea04..6af2421019 100644 --- a/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java +++ b/analysis/src/main/java/org/hps/analysis/ecal/SF2021Driver.java @@ -376,7 +376,7 @@ public void process(EventHeader event) { baseClus.setParticleId(PID); baseClus.setNeedsPropertyCalculation(false); - ClusterCorrectionUtilities.applyCorrections(4.55, ecal, baseClus, true); + ClusterCorrectionUtilities.applyCorrections(3.74, ecal, baseClus, true); xClus = baseClus.getPosition()[0]; yClus = baseClus.getPosition()[1]; dX = xClus - xpos; diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java index 447d2fdad1..3f493b0f6d 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterCorrectionUtilities.java @@ -20,14 +20,18 @@ public final class ClusterCorrectionUtilities { static final double NOISE_B = 1.3725E-4; static final double NOISE_C = 3.01E-4; - static final int N_ITERATIONS_2019 = 5; - static final Random random = new Random(); + static final int N_ITERATIONS_2019 = 5; static final double deltaClusterEnergy_thr2019 = 0.5 / 100; // relative deltaE/E static final double deltaClusterX_thr2019 = 0.5; // abs dX in mm static final double deltaClusterY_thr2019 = 0.5; // abs dY in mm + static final int N_ITERATIONS_2021 = 5; + static final double deltaClusterEnergy_thr2021 = 0.5 / 100; // relative deltaE/E + static final double deltaClusterX_thr2021 = 0.5; // abs dX in mm + static final double deltaClusterY_thr2021 = 0.5; // abs dY in mm + // Calculate the noise factor to smear the Ecal energy by public static double calcNoise(double energy) { return random.nextGaussian() * Math.sqrt(NOISE_A + NOISE_B * energy + NOISE_C * Math.pow(energy, 2)); @@ -98,7 +102,53 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, List 3.0) { + for (int it = 0; it < N_ITERATIONS_2021; it++) { + if (it == 0) + addNoise = true; + else + addNoise = false; + + // get the cluster energy and cluster position from last iteration + double clusterPosition[] = baseCluster.getPosition(); + double clusterEnergy = baseCluster.getEnergy(); + + // To correct the energy, need the correct position - from previous iteration - + // and the raw energy + baseCluster.setPosition(clusterPosition); + baseCluster.setEnergy(clusterEnergy_NC); + ClusterEnergyCorrection2021.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); + double clusterEnergy_C = baseCluster.getEnergy(); + + // To correct the position, need the correct energy - from previous iteration - + // and the raw position + baseCluster.setEnergy(clusterEnergy); + baseCluster.setPosition(clusterPosition_NC); + ClusterPositionCorrection2021.setCorrectedPosition(baseCluster); + + // now set back the energy after correction (the position is already set) + baseCluster.setEnergy(clusterEnergy_C); + + // absolute POS, relative in energy + double deltaClusterEnergy = clusterEnergy - clusterEnergy_C; + double deltaClusterX = clusterPosition[0] - baseCluster.getPosition()[0]; + double deltaClusterY = clusterPosition[1] - baseCluster.getPosition()[1]; + + // A.C. : add a condition on the relative variation of the energy before-after + // iteration + // add a condition on the absolute variation of the position before-after + // iteration + // if all are satisfied, break the loop + if ((Math.abs(deltaClusterEnergy / clusterEnergy) < deltaClusterEnergy_thr2021) + && (Math.abs(deltaClusterX) < deltaClusterX_thr2021) + && (Math.abs(deltaClusterY) < deltaClusterY_thr2021)) { + break; + } + + } + } + + else { ClusterPositionCorrection.setCorrectedPosition(baseCluster); ClusterEnergyCorrection.setCorrectedEnergy(ecal, baseCluster, isMC); } @@ -120,7 +170,7 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, Cluster cl BaseCluster baseCluster = (BaseCluster) cluster; boolean addNoise = false; // Apply PID based energy correction. 2019 and 2021 are a special case - if (beamEnergy > 3.0) { + if (beamEnergy > 4.0) { // here we need to play a little bit. // ClusterEnergyCorrection2019/2021 requires the CORRECT position and the RAW // energy @@ -147,22 +197,18 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, Cluster cl // and the raw energy baseCluster.setPosition(clusterPosition); baseCluster.setEnergy(clusterEnergy_NC); - if (beamEnergy > 4.0) { - ClusterEnergyCorrection2019.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); - } else { - ClusterEnergyCorrection2021.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); - } + + ClusterEnergyCorrection2019.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); + double clusterEnergy_C = baseCluster.getEnergy(); // To correct the position, need the correct energy - from previous iteration - // and the raw position baseCluster.setEnergy(clusterEnergy); baseCluster.setPosition(clusterPosition_NC); - if (beamEnergy > 4.0) { - ClusterPositionCorrection2019.setCorrectedPosition(baseCluster); - } else { - ClusterPositionCorrection2021.setCorrectedPosition(baseCluster); - } + + ClusterPositionCorrection2019.setCorrectedPosition(baseCluster); + // now set back the energy after correction (the position is already set) baseCluster.setEnergy(clusterEnergy_C); @@ -183,8 +229,68 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, Cluster cl } } + } else if (beamEnergy > 3.0) { + // here we need to play a little bit. + // ClusterEnergyCorrection2019/2021 requires the CORRECT position and the RAW + // energy + // ClusterPositionCorrection2019/2021 requires the CORRECT energy and the RAW + // position. + // Idea: iterate from the non-corrected values - } else { + baseCluster.setNeedsPropertyCalculation(false); // should have been set already before calling this - + // just in case. + double clusterPosition_NC[] = baseCluster.getPosition(); + double clusterEnergy_NC = baseCluster.getEnergy(); + + for (int it = 0; it < N_ITERATIONS_2021; it++) { + if (it == 0) + addNoise = true; + else + addNoise = false; + + // get the cluster energy and cluster position from last iteration + double clusterPosition[] = baseCluster.getPosition(); + double clusterEnergy = baseCluster.getEnergy(); + + // To correct the energy, need the correct position - from previous iteration - + // and the raw energy + baseCluster.setPosition(clusterPosition); + baseCluster.setEnergy(clusterEnergy_NC); + + ClusterEnergyCorrection2021.setCorrectedEnergy(ecal, baseCluster, isMC, addNoise); + + double clusterEnergy_C = baseCluster.getEnergy(); + + // To correct the position, need the correct energy - from previous iteration - + // and the raw position + baseCluster.setEnergy(clusterEnergy); + baseCluster.setPosition(clusterPosition_NC); + + ClusterPositionCorrection2021.setCorrectedPosition(baseCluster); + + // now set back the energy after correction (the position is already set) + baseCluster.setEnergy(clusterEnergy_C); + + // absolute POS, relative in energy + double deltaClusterEnergy = clusterEnergy - clusterEnergy_C; + double deltaClusterX = clusterPosition[0] - baseCluster.getPosition()[0]; + double deltaClusterY = clusterPosition[1] - baseCluster.getPosition()[1]; + // A.C. : add a condition on the relative variation of the energy before-after + // iteration + // add a condition on the absolute variation of the position before-after + // iteration + // if all are satisfied, break the loop + if ((Math.abs(deltaClusterEnergy / clusterEnergy) < deltaClusterEnergy_thr2021) + && (Math.abs(deltaClusterX) < deltaClusterX_thr2021) + && (Math.abs(deltaClusterY) < deltaClusterY_thr2021)) { + break; + } + + } + + } + + else { // Apply PID based position correction, which should happen before final energy // correction. ClusterPositionCorrection.setCorrectedPosition(baseCluster); @@ -216,8 +322,8 @@ public static void applyCorrections(double beamEnergy, HPSEcal3 ecal, Cluster cl // Apply energy correction - this depends on the non-corrected energy (from // baseCluster) and ypos, from tracking. ClusterEnergyCorrection2021.setCorrectedEnergy(ecal, baseCluster, ypos, isMC); - // Now the energy is correct, can use the 2019 correction. Note that the order - // is different from below, since 2019 corrections are based on the CORRECTED + // Now the energy is correct, can use the 2021 correction. Note that the order + // is different from below, since 2021 corrections are based on the CORRECTED // ENERGY ClusterPositionCorrection2021.setCorrectedPosition(baseCluster); } diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2019.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2019.java index 3b8969ddbd..700091d87a 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2019.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2019.java @@ -28,11 +28,11 @@ * Photons: par(E) = p0 + p1*pow(E,p2) | par = q,m par(E) = (a + b*E + c*E*E)/(d * + e*E + f*E*E) | par = q1,t,q2 */ -final class ClusterPosResult { +final class ClusterPosResult19 { private final double X; private final double Y; - public ClusterPosResult(double X, double Y) { + public ClusterPosResult19(double X, double Y) { this.X = X; this.Y = Y; } @@ -133,7 +133,7 @@ public final class ClusterPositionCorrection2019 { public static double[] calculateCorrectedPosition(BaseCluster cluster) { double clusterPosition[] = cluster.getPosition(); - ClusterPosResult correctedPosition = computeCorrectedPosition(cluster.getParticleId(), clusterPosition[0], + ClusterPosResult19 correctedPosition = computeCorrectedPosition(cluster.getParticleId(), clusterPosition[0], clusterPosition[1], cluster.getEnergy()); double[] position = new double[3]; @@ -160,9 +160,9 @@ public static void setCorrectedPosition(BaseCluster cluster) { * @param Energy Corrected energy of the cluster * @return the corrected x position */ - private static ClusterPosResult computeCorrectedPosition(int pdg, double xPos, double yPos, double Energy) { + private static ClusterPosResult19 computeCorrectedPosition(int pdg, double xPos, double yPos, double Energy) { // double xCl = xPos / 10.0;//convert to cm - ClusterPosResult res; + ClusterPosResult19 res; double xCorr; switch (pdg) { case 11: // Particle is electron @@ -175,12 +175,12 @@ private static ClusterPosResult computeCorrectedPosition(int pdg, double xPos, d res = positionCorrectionPhoton(xPos, yPos, Energy); break; default: // Unknown - res = new ClusterPosResult(xPos, yPos); + res = new ClusterPosResult19(xPos, yPos); } return res; } - private static ClusterPosResult positionCorrectionElectron(double xPos, double yPos, double Energy) { + private static ClusterPosResult19 positionCorrectionElectron(double xPos, double yPos, double Energy) { double xCorr, yCorr; double deltaX, deltaY; @@ -201,10 +201,10 @@ private static ClusterPosResult positionCorrectionElectron(double xPos, double y xCorr = xPos - deltaX; yCorr = yPos - deltaY; - return new ClusterPosResult(xCorr, yCorr); + return new ClusterPosResult19(xCorr, yCorr); } - private static ClusterPosResult positionCorrectionPositron(double xPos, double yPos, double Energy) { + private static ClusterPosResult19 positionCorrectionPositron(double xPos, double yPos, double Energy) { double xCorr, yCorr; double deltaX, deltaY; @@ -225,10 +225,10 @@ private static ClusterPosResult positionCorrectionPositron(double xPos, double y xCorr = xPos - deltaX; yCorr = yPos - deltaY; - return new ClusterPosResult(xCorr, yCorr); + return new ClusterPosResult19(xCorr, yCorr); } - private static ClusterPosResult positionCorrectionPhoton(double xPos, double yPos, double Energy) { + private static ClusterPosResult19 positionCorrectionPhoton(double xPos, double yPos, double Energy) { double xCorr, yCorr; double deltaX, deltaY; @@ -252,7 +252,7 @@ private static ClusterPosResult positionCorrectionPhoton(double xPos, double yPo xCorr = xPos - deltaX; yCorr = yPos - deltaY; - return new ClusterPosResult(xCorr, yCorr); + return new ClusterPosResult19(xCorr, yCorr); } } diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java index 72c960134e..c6a5477549 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterPositionCorrection2021.java @@ -28,11 +28,11 @@ * Photons: par(E) = p0 + p1*pow(E,p2) | par = q,m par(E) = (a + b*E + c*E*E)/(d * + e*E + f*E*E) | par = q1,t,q2 */ -final class ClusterPosResult { +final class ClusterPosResult21 { private final double X; private final double Y; - public ClusterPosResult(double X, double Y) { + public ClusterPosResult21(double X, double Y) { this.X = X; this.Y = Y; } @@ -133,7 +133,7 @@ public final class ClusterPositionCorrection2021 { public static double[] calculateCorrectedPosition(BaseCluster cluster) { double clusterPosition[] = cluster.getPosition(); - ClusterPosResult correctedPosition = computeCorrectedPosition(cluster.getParticleId(), clusterPosition[0], + ClusterPosResult21 correctedPosition = computeCorrectedPosition(cluster.getParticleId(), clusterPosition[0], clusterPosition[1], cluster.getEnergy()); double[] position = new double[3]; @@ -160,9 +160,9 @@ public static void setCorrectedPosition(BaseCluster cluster) { * @param Energy Corrected energy of the cluster * @return the corrected x position */ - private static ClusterPosResult computeCorrectedPosition(int pdg, double xPos, double yPos, double Energy) { + private static ClusterPosResult21 computeCorrectedPosition(int pdg, double xPos, double yPos, double Energy) { // double xCl = xPos / 10.0;//convert to cm - ClusterPosResult res; + ClusterPosResult21 res; double xCorr; switch (pdg) { case 11: // Particle is electron @@ -175,12 +175,12 @@ private static ClusterPosResult computeCorrectedPosition(int pdg, double xPos, d res = positionCorrectionPhoton(xPos, yPos, Energy); break; default: // Unknown - res = new ClusterPosResult(xPos, yPos); + res = new ClusterPosResult21(xPos, yPos); } return res; } - private static ClusterPosResult positionCorrectionElectron(double xPos, double yPos, double Energy) { + private static ClusterPosResult21 positionCorrectionElectron(double xPos, double yPos, double Energy) { double xCorr, yCorr; double deltaX, deltaY; @@ -201,10 +201,10 @@ private static ClusterPosResult positionCorrectionElectron(double xPos, double y xCorr = xPos - deltaX; yCorr = yPos - deltaY; - return new ClusterPosResult(xCorr, yCorr); + return new ClusterPosResult21(xCorr, yCorr); } - private static ClusterPosResult positionCorrectionPositron(double xPos, double yPos, double Energy) { + private static ClusterPosResult21 positionCorrectionPositron(double xPos, double yPos, double Energy) { double xCorr, yCorr; double deltaX, deltaY; @@ -225,10 +225,10 @@ private static ClusterPosResult positionCorrectionPositron(double xPos, double y xCorr = xPos - deltaX; yCorr = yPos - deltaY; - return new ClusterPosResult(xCorr, yCorr); + return new ClusterPosResult21(xCorr, yCorr); } - private static ClusterPosResult positionCorrectionPhoton(double xPos, double yPos, double Energy) { + private static ClusterPosResult21 positionCorrectionPhoton(double xPos, double yPos, double Energy) { double xCorr, yCorr; double deltaX, deltaY; @@ -252,7 +252,7 @@ private static ClusterPosResult positionCorrectionPhoton(double xPos, double yPo xCorr = xPos - deltaX; yCorr = yPos - deltaY; - return new ClusterPosResult(xCorr, yCorr); + return new ClusterPosResult21(xCorr, yCorr); } } From 8f60f759483f8ce294658e530d9fa177cb5857ed Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Thu, 14 Apr 2022 18:26:04 +0200 Subject: [PATCH 19/24] Adding 2021SF_parameters_data.dat, for the moment this is a copy of 2019SF_parameters_data.dat --- .../ecal/cluster/2021SF_parameters_data.dat | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat diff --git a/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat new file mode 100644 index 0000000000..474a277bb7 --- /dev/null +++ b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat @@ -0,0 +1,101 @@ +100 +2.5 0.760321 0.070724 +3.13 0.783612 0.0621251 +3.76 0.815193 0.0518603 +4.39 0.852242 0.0407169 +5.02 0.892622 0.0291955 +5.65 0.933526 0.0178851 +6.28 0.968577 0.00837647 +6.91 0.992219 0.00205842 +7.54 0.990641 0.00245948 +8.17 0.984738 0.00398489 +8.8 0.977339 0.00588544 +9.43 0.978456 0.0055739 +10.06 0.983247 0.00431913 +10.69 0.983251 0.00430338 +11.32 0.984312 0.00401947 +11.95 0.987212 0.0032712 +12.58 0.989522 0.00267413 +13.21 0.997244 0.00070006 +13.84 1.01816 -0.00458871 +14.47 1.03181 -0.00800772 +15.1 1.04317 -0.0108329 +15.73 1.04782 -0.0119667 +16.36 1.04987 -0.012449 +16.99 1.05025 -0.0125238 +17.62 1.05034 -0.0125264 +18.25 1.05193 -0.0128936 +18.88 1.05495 -0.0136268 +19.51 1.05555 -0.01377 +20.14 1.05568 -0.0137924 +20.77 1.05583 -0.0138227 +21.4 1.05718 -0.0141566 +22.03 1.06062 -0.015018 +22.66 1.06916 -0.0171449 +23.29 1.07149 -0.0177309 +23.92 1.06948 -0.0172418 +24.55 1.07365 -0.0183011 +25.18 1.07457 -0.0185736 +25.81 1.07018 -0.0175133 +26.44 1.08044 -0.0200896 +27.07 1.09166 -0.022888 +27.7 1.09459 -0.0235699 +28.33 1.09399 -0.023337 +28.96 1.09298 -0.0230392 +29.59 1.09558 -0.023672 +30.22 1.09839 -0.0243594 +30.85 1.09988 -0.0247212 +31.48 1.09753 -0.0241331 +32.11 1.09558 -0.0236334 +32.74 1.09616 -0.0237612 +33.37 1.09887 -0.0244193 +34 1.10393 -0.0256659 +34.63 1.10349 -0.0255676 +35.26 1.10254 -0.0253508 +35.89 1.10167 -0.0251391 +36.52 1.09724 -0.0240367 +37.15 1.09448 -0.0233665 +37.78 1.09881 -0.024475 +38.41 1.10006 -0.0248307 +39.04 1.09981 -0.0247926 +39.67 1.10564 -0.0262889 +40.3 1.11474 -0.0286419 +40.93 1.12328 -0.0307591 +41.56 1.11873 -0.02954 +42.19 1.11342 -0.0281692 +42.82 1.11035 -0.0273746 +43.45 1.10812 -0.0267994 +44.08 1.10691 -0.026495 +44.71 1.10934 -0.0270944 +45.34 1.1098 -0.027186 +45.97 1.10901 -0.0269621 +46.6 1.11115 -0.0274771 +47.23 1.11136 -0.0275457 +47.86 1.10697 -0.0264857 +48.49 1.10917 -0.0270531 +49.12 1.11248 -0.0278888 +49.75 1.11234 -0.0278775 +50.38 1.10868 -0.0270087 +51.01 1.10403 -0.0259078 +51.64 1.11439 -0.0285602 +52.27 1.11805 -0.0295632 +52.9 1.11211 -0.0281634 +53.53 1.11347 -0.0286416 +54.16 1.11819 -0.0300413 +54.79 1.11833 -0.030184 +55.42 1.11647 -0.029695 +56.05 1.11925 -0.0304233 +56.68 1.12383 -0.0316603 +57.31 1.12307 -0.0315539 +57.94 1.1168 -0.0300625 +58.57 1.10902 -0.0281965 +59.2 1.10399 -0.0270344 +59.83 1.10491 -0.0274142 +60.46 1.11104 -0.0291759 +61.09 1.12106 -0.0320298 +61.72 1.13697 -0.0365703 +62.35 1.13078 -0.0353004 +62.98 1.10683 -0.0291682 +63.61 1.11338 -0.0314179 +64.24 1.14513 -0.0410519 +64.87 1.21805 -0.0631803 From 65b0f2f1d4f337718ffecb1febddd7a25bbbc6d9 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Thu, 14 Apr 2022 18:42:39 +0200 Subject: [PATCH 20/24] Temporary fix to ClusterEnergyCorrection2021.jaava to use always MC corrections --- .../ecal/cluster/ClusterEnergyCorrection2021.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java index 9c026ccf37..b246be4391 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java @@ -200,8 +200,17 @@ private static void loadDataFromResourceFiles(int type) { public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEnergy, double xpos, double ypos, boolean isMC) { - final int type = isMC ? MC : DATA; - + + + /*TODO + * FIX + * A.c. very important, for the moment I am fixing this to always use MC corrections, for later analysis. + * + * final int type = isMC ? MC : DATA; + */ + final int type = MC; + + loadDataFromResourceFiles(type); // distance to beam gap edge From f9ce849ea4c81f023f3590be9b00fe4583728bf9 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Fri, 15 Apr 2022 11:37:03 +0200 Subject: [PATCH 21/24] fix energy correction 2021 to be mc only also for data --- .../cluster/ClusterEnergyCorrection2021.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java index b246be4391..99fea663ed 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java @@ -223,7 +223,15 @@ public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEn r = 2.5; } - if (isMC) { + /*TODO + * FIX + * A.c. very important, for the moment I am fixing this to always use MC corrections, for later analysis. + * + * final int type = isMC ? MC : DATA; + */ + int tmpMC=1; + //if(isMC){ + if (tmpMC==1) { switch (pdg) { case 11: // electron @@ -278,7 +286,12 @@ private static double computeCorrectedEnergy(double y, double rawEnergy, Polynom double SF, corrEnergy; corrEnergy = rawEnergy; - if (isMC == true) { + + /*A.C. fix TODO*/ + + int tmpMC=1; +// if (isMC == true) { + if (tmpMC==1){ SF = A / rawEnergy + B / Math.sqrt(rawEnergy) + C; corrEnergy = rawEnergy / SF; } else { From 9be69c5627051a33e5d43e468e02aac907140ff1 Mon Sep 17 00:00:00 2001 From: Andrea Celentano Date: Fri, 22 Apr 2022 12:20:41 +0200 Subject: [PATCH 22/24] 2021SF for data --- .../cluster/ClusterEnergyCorrection2021.java | 33 +-- .../ecal/cluster/2021SF_parameters_data.dat | 200 +++++++++--------- 2 files changed, 110 insertions(+), 123 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java index 99fea663ed..cd41b8fc32 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java @@ -202,13 +202,10 @@ public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEn - /*TODO - * FIX - * A.c. very important, for the moment I am fixing this to always use MC corrections, for later analysis. - * - * final int type = isMC ? MC : DATA; - */ - final int type = MC; + + final int type = isMC ? MC : DATA; + + loadDataFromResourceFiles(type); @@ -223,15 +220,8 @@ public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEn r = 2.5; } - /*TODO - * FIX - * A.c. very important, for the moment I am fixing this to always use MC corrections, for later analysis. - * - * final int type = isMC ? MC : DATA; - */ - int tmpMC=1; - //if(isMC){ - if (tmpMC==1) { + + if(isMC){ switch (pdg) { case 11: // electron @@ -278,8 +268,7 @@ public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEn private static double computeCorrectedEnergy(double y, double rawEnergy, PolynomialSplineFunction splineA, PolynomialSplineFunction splineB, PolynomialSplineFunction splineC, boolean isMC) { - /*A.C. fix*/ - + double A = splineA.value(y); double B = splineB.value(y); double C = splineC.value(y); @@ -287,11 +276,9 @@ private static double computeCorrectedEnergy(double y, double rawEnergy, Polynom double SF, corrEnergy; corrEnergy = rawEnergy; - /*A.C. fix TODO*/ - - int tmpMC=1; -// if (isMC == true) { - if (tmpMC==1){ + + if (isMC == true) { + SF = A / rawEnergy + B / Math.sqrt(rawEnergy) + C; corrEnergy = rawEnergy / SF; } else { diff --git a/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat index 474a277bb7..66c72ed16b 100644 --- a/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat +++ b/ecal-recon/src/main/resources/org/hps/recon/ecal/cluster/2021SF_parameters_data.dat @@ -1,101 +1,101 @@ 100 -2.5 0.760321 0.070724 -3.13 0.783612 0.0621251 -3.76 0.815193 0.0518603 -4.39 0.852242 0.0407169 -5.02 0.892622 0.0291955 -5.65 0.933526 0.0178851 -6.28 0.968577 0.00837647 -6.91 0.992219 0.00205842 -7.54 0.990641 0.00245948 -8.17 0.984738 0.00398489 -8.8 0.977339 0.00588544 -9.43 0.978456 0.0055739 -10.06 0.983247 0.00431913 -10.69 0.983251 0.00430338 -11.32 0.984312 0.00401947 -11.95 0.987212 0.0032712 -12.58 0.989522 0.00267413 -13.21 0.997244 0.00070006 -13.84 1.01816 -0.00458871 -14.47 1.03181 -0.00800772 -15.1 1.04317 -0.0108329 -15.73 1.04782 -0.0119667 -16.36 1.04987 -0.012449 -16.99 1.05025 -0.0125238 -17.62 1.05034 -0.0125264 -18.25 1.05193 -0.0128936 -18.88 1.05495 -0.0136268 -19.51 1.05555 -0.01377 -20.14 1.05568 -0.0137924 -20.77 1.05583 -0.0138227 -21.4 1.05718 -0.0141566 -22.03 1.06062 -0.015018 -22.66 1.06916 -0.0171449 -23.29 1.07149 -0.0177309 -23.92 1.06948 -0.0172418 -24.55 1.07365 -0.0183011 -25.18 1.07457 -0.0185736 -25.81 1.07018 -0.0175133 -26.44 1.08044 -0.0200896 -27.07 1.09166 -0.022888 -27.7 1.09459 -0.0235699 -28.33 1.09399 -0.023337 -28.96 1.09298 -0.0230392 -29.59 1.09558 -0.023672 -30.22 1.09839 -0.0243594 -30.85 1.09988 -0.0247212 -31.48 1.09753 -0.0241331 -32.11 1.09558 -0.0236334 -32.74 1.09616 -0.0237612 -33.37 1.09887 -0.0244193 -34 1.10393 -0.0256659 -34.63 1.10349 -0.0255676 -35.26 1.10254 -0.0253508 -35.89 1.10167 -0.0251391 -36.52 1.09724 -0.0240367 -37.15 1.09448 -0.0233665 -37.78 1.09881 -0.024475 -38.41 1.10006 -0.0248307 -39.04 1.09981 -0.0247926 -39.67 1.10564 -0.0262889 -40.3 1.11474 -0.0286419 -40.93 1.12328 -0.0307591 -41.56 1.11873 -0.02954 -42.19 1.11342 -0.0281692 -42.82 1.11035 -0.0273746 -43.45 1.10812 -0.0267994 -44.08 1.10691 -0.026495 -44.71 1.10934 -0.0270944 -45.34 1.1098 -0.027186 -45.97 1.10901 -0.0269621 -46.6 1.11115 -0.0274771 -47.23 1.11136 -0.0275457 -47.86 1.10697 -0.0264857 -48.49 1.10917 -0.0270531 -49.12 1.11248 -0.0278888 -49.75 1.11234 -0.0278775 -50.38 1.10868 -0.0270087 -51.01 1.10403 -0.0259078 -51.64 1.11439 -0.0285602 -52.27 1.11805 -0.0295632 -52.9 1.11211 -0.0281634 -53.53 1.11347 -0.0286416 -54.16 1.11819 -0.0300413 -54.79 1.11833 -0.030184 -55.42 1.11647 -0.029695 -56.05 1.11925 -0.0304233 -56.68 1.12383 -0.0316603 -57.31 1.12307 -0.0315539 -57.94 1.1168 -0.0300625 -58.57 1.10902 -0.0281965 -59.2 1.10399 -0.0270344 -59.83 1.10491 -0.0274142 -60.46 1.11104 -0.0291759 -61.09 1.12106 -0.0320298 -61.72 1.13697 -0.0365703 -62.35 1.13078 -0.0353004 -62.98 1.10683 -0.0291682 -63.61 1.11338 -0.0314179 -64.24 1.14513 -0.0410519 -64.87 1.21805 -0.0631803 +2.5 0.994939 0.00183601 +3.13 0.984952 0.0052958 +3.76 0.983308 0.00573963 +4.39 0.988172 0.00399503 +5.02 0.997387 0.000869833 +5.65 0.992518 0.00246158 +6.28 1.00955 -0.0031109 +6.91 1.05236 -0.0169254 +7.54 1.05718 -0.0183675 +8.17 1.05666 -0.0181 +8.8 1.0547 -0.0173954 +9.43 1.05561 -0.0176148 +10.06 1.05895 -0.0186158 +10.69 1.06379 -0.0200848 +11.32 1.0729 -0.0228899 +11.95 1.08755 -0.0274402 +12.58 1.09083 -0.0284174 +13.21 1.09545 -0.0297613 +13.84 1.10763 -0.0333973 +14.47 1.10225 -0.031579 +15.1 1.09615 -0.0295976 +15.73 1.11073 -0.034001 +16.36 1.11927 -0.0365263 +16.99 1.12273 -0.0375106 +17.62 1.12515 -0.0381909 +18.25 1.12509 -0.038117 +18.88 1.12047 -0.0366609 +19.51 1.12624 -0.0383821 +20.14 1.13259 -0.0402957 +20.77 1.12845 -0.0390289 +21.4 1.13038 -0.0396202 +22.03 1.13715 -0.041698 +22.66 1.13799 -0.0419952 +23.29 1.13829 -0.0421512 +23.92 1.13984 -0.0426998 +24.55 1.1426 -0.0436142 +25.18 1.14249 -0.0436341 +25.81 1.13868 -0.0425495 +26.44 1.13812 -0.0424498 +27.07 1.13425 -0.0412219 +27.7 1.13416 -0.0410919 +28.33 1.13176 -0.0402544 +28.96 1.12858 -0.0392128 +29.59 1.1285 -0.0391407 +30.22 1.12842 -0.0390748 +30.85 1.12787 -0.0388736 +31.48 1.12979 -0.0394293 +32.11 1.13296 -0.0403602 +32.74 1.13573 -0.0411785 +33.37 1.13646 -0.0413939 +34 1.13578 -0.0411903 +34.63 1.13836 -0.0419759 +35.26 1.13728 -0.0416541 +35.89 1.13137 -0.0398819 +36.52 1.13231 -0.0402017 +37.15 1.13417 -0.0408079 +37.78 1.1356 -0.0413055 +38.41 1.13517 -0.0412566 +39.04 1.13421 -0.0410318 +39.67 1.13745 -0.0421215 +40.3 1.14178 -0.0435629 +40.93 1.14423 -0.0442821 +41.56 1.1428 -0.0437122 +42.19 1.14025 -0.0428435 +42.82 1.13766 -0.0420065 +43.45 1.13765 -0.0419746 +44.08 1.13782 -0.0419882 +44.71 1.13562 -0.0412778 +45.34 1.13716 -0.0417053 +45.97 1.14156 -0.0430119 +46.6 1.1416 -0.0430046 +47.23 1.14098 -0.0428156 +47.86 1.1397 -0.0424431 +48.49 1.13711 -0.0416834 +49.12 1.13386 -0.0407298 +49.75 1.13347 -0.0406528 +50.38 1.13798 -0.0420834 +51.01 1.14577 -0.0445236 +51.64 1.13987 -0.0428249 +52.27 1.13775 -0.0423296 +52.9 1.13894 -0.042852 +53.53 1.14471 -0.0448302 +54.16 1.15492 -0.0482804 +54.79 1.1662 -0.0519685 +55.42 1.16754 -0.0523861 +56.05 1.16956 -0.0530492 +56.68 1.17298 -0.0542226 +57.31 1.17197 -0.0540578 +57.94 1.16695 -0.0526718 +58.57 1.18136 -0.0574612 +59.2 1.1933 -0.0615182 +59.83 1.19428 -0.0621412 +60.46 1.18598 -0.0598452 +61.09 1.17841 -0.0578189 +61.72 1.18792 -0.0614259 +62.35 1.1957 -0.0646395 +62.98 1.2037 -0.0681544 +63.61 1.21293 -0.0723976 +64.24 1.21399 -0.0742179 +64.87 1.19553 -0.0694522 From 50b2005e658fe73e2fca822d9d4b3bfbd6b3087e Mon Sep 17 00:00:00 2001 From: Graf Date: Thu, 28 Apr 2022 08:30:52 -0700 Subject: [PATCH 23/24] Update ClusterEnergyCorrection2021.java Fix formatting. --- .../cluster/ClusterEnergyCorrection2021.java | 56 +++++++++---------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java index cd41b8fc32..a7c8846945 100644 --- a/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java +++ b/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterEnergyCorrection2021.java @@ -24,7 +24,7 @@ public final class ClusterEnergyCorrection2021 { private static final byte DATA = 0; private static final byte MC = 1; - static boolean[] hasLoaded = new boolean[] { false, false }; + static boolean[] hasLoaded = new boolean[]{false, false}; // These are the three splices used to interpolate the A,B,C parameters for // photons - determined from MC @@ -183,15 +183,15 @@ private static void loadDataFromResourceFiles(int type) { } /** - * Calculates energy correction based on cluster raw energy and particle type as - * per HPS Note 2014-001 * * @param ecal - * @param pdg Particle id as per PDG + * @param pdg Particle id as per PDG * @param rawEnergy Raw Energy of the cluster (sum of hits with shared hit - * distribution) + * distribution) * @param xpos * @param ypos * @param isMC @@ -200,14 +200,8 @@ private static void loadDataFromResourceFiles(int type) { public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEnergy, double xpos, double ypos, boolean isMC) { - + final int type = isMC ? MC : DATA; - - final int type = isMC ? MC : DATA; - - - - loadDataFromResourceFiles(type); // distance to beam gap edge @@ -220,8 +214,7 @@ public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEn r = 2.5; } - - if(isMC){ + if (isMC) { switch (pdg) { case 11: // electron @@ -255,30 +248,28 @@ public static double computeCorrectedEnergy(HPSEcal3 ecal, int pdg, double rawEn } /** - * Calculates the energy correction to a cluster given the variables from the - * fit as per HPS Note 2014-001 Note that this is correct as there is a typo in the - * formula print in the note. + * >HPS Note 2014-001 Note that this is correct as there is a typo in + * the formula print in the note. * * @param rawEnergy Raw energy of the cluster - * @param A,B,C from fitting in note + * @param A,B,C from fitting in note * @return Corrected Energy */ private static double computeCorrectedEnergy(double y, double rawEnergy, PolynomialSplineFunction splineA, PolynomialSplineFunction splineB, PolynomialSplineFunction splineC, boolean isMC) { - double A = splineA.value(y); double B = splineB.value(y); double C = splineC.value(y); double SF, corrEnergy; corrEnergy = rawEnergy; - - + if (isMC == true) { - + SF = A / rawEnergy + B / Math.sqrt(rawEnergy) + C; corrEnergy = rawEnergy / SF; } else { @@ -286,15 +277,19 @@ private static double computeCorrectedEnergy(double y, double rawEnergy, Polynom double p0, p1, y0, y1; y0 = y; y1 = y; - if (y0 < psf_parP0.getKnots()[0]) + if (y0 < psf_parP0.getKnots()[0]) { y0 = psf_parP0.getKnots()[0]; - if (y0 > psf_parP0.getKnots()[psf_parP0.getN()]) + } + if (y0 > psf_parP0.getKnots()[psf_parP0.getN()]) { y0 = psf_parP0.getKnots()[psf_parP0.getN()]; + } - if (y1 < psf_parP0.getKnots()[0]) + if (y1 < psf_parP0.getKnots()[0]) { y1 = psf_parP0.getKnots()[0]; - if (y1 > psf_parP0.getKnots()[psf_parP0.getN()]) + } + if (y1 > psf_parP0.getKnots()[psf_parP0.getN()]) { y1 = psf_parP0.getKnots()[psf_parP0.getN()]; + } p0 = psf_parP0.value(y0); p1 = psf_parP1.value(y1); @@ -319,7 +314,8 @@ public static final double calculateCorrectedEnergy(HPSEcal3 ecal, Cluster clust } /** - * Calculate the corrected energy for the cluster using track position at ecal. + * Calculate the corrected energy for the cluster using track position at + * ecal. * * @param cluster The input cluster. * @return The corrected energy. @@ -334,9 +330,9 @@ public static final double calculateCorrectedEnergy(HPSEcal3 ecal, Cluster clust * * @param cluster The input cluster. */ - public static final void setCorrectedEnergy(HPSEcal3 ecal, BaseCluster cluster, boolean isMC,boolean addNoise) { + public static final void setCorrectedEnergy(HPSEcal3 ecal, BaseCluster cluster, boolean isMC, boolean addNoise) { double correctedEnergy = calculateCorrectedEnergy(ecal, cluster, isMC); - if (isMC&&addNoise) { + if (isMC && addNoise) { correctedEnergy += ClusterCorrectionUtilities.calcNoise(correctedEnergy); } cluster.setEnergy(correctedEnergy); From 91ca6087a69bdff32f857c903389d7cec5baea3d Mon Sep 17 00:00:00 2001 From: Graf Date: Thu, 28 Apr 2022 08:37:29 -0700 Subject: [PATCH 24/24] Added new detector HPS_Run2021Pass2FEE_1pt92 Added new detector for the single pass running at 1.92GeV --- .../SamplingFractions/Ecal.properties | 1 + .../SamplingFractions/Hodoscope.properties | 1 + .../HPS_Run2021Pass2FEE_1pt92/compact.xml | 791 ++++++++++++++++++ .../detector.properties | 1 + 4 files changed, 794 insertions(+) create mode 100644 detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Ecal.properties create mode 100644 detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Hodoscope.properties create mode 100644 detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/compact.xml create mode 100644 detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/detector.properties diff --git a/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Ecal.properties b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Ecal.properties new file mode 100644 index 0000000000..6d1c9ac61f --- /dev/null +++ b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Ecal.properties @@ -0,0 +1 @@ +samplingFraction: 1.0 diff --git a/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Hodoscope.properties b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Hodoscope.properties new file mode 100644 index 0000000000..6d1c9ac61f --- /dev/null +++ b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/SamplingFractions/Hodoscope.properties @@ -0,0 +1 @@ +samplingFraction: 1.0 diff --git a/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/compact.xml b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/compact.xml new file mode 100644 index 0000000000..0eedef6226 --- /dev/null +++ b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/compact.xml @@ -0,0 +1,791 @@ + + + + + HPS detector for 2021 run with fieldmap for 1.92GeV running, + Tracker at nominal opening angle, no SVT survey, + this detector uses the corrected fieldmap scaled to -1.022T for 3.7 GeV. + Includes L0 and Hodoscope. + ECAL with survey alignment for HPSEcal3 (global y/z translations). + This detector has the full hierarchical alignment structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Scoring plane after ECal flange for calibration studies + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The crystal ECal + + + + + + + + + + + + + + + system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12 + + + system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12 + + + + system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12 + + + + system:6,barrel:3,layer:4,ix:4,iy:-3,hole:-3 + + + system:6,barrel:3,layer:4,module:12,sensor:1,side:32:-2,strip:12 + + + + + system:6,layer:2,ix:-8,iy:-6 + + + + + + + + + + + + + + + diff --git a/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/detector.properties b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/detector.properties new file mode 100644 index 0000000000..6f014151be --- /dev/null +++ b/detector-data/detectors/HPS_Run2021Pass2FEE_1pt92/detector.properties @@ -0,0 +1 @@ +name: HPS_Run2021Pass2FEE_1pt92