From 87a068648bb0a9eb19c1a2cdea280e9199e12323 Mon Sep 17 00:00:00 2001 From: niwgit Date: Wed, 19 Mar 2025 10:50:36 -0400 Subject: [PATCH 01/10] Implementation of recoil TOF geometry for RGH --- geometry_source/recoil_tof/GeoArgParse.groovy | 18 ++++ geometry_source/recoil_tof/config.dat | 23 +++++ geometry_source/recoil_tof/factory.groovy | 24 +++++ geometry_source/recoil_tof/geometry_java.pl | 85 +++++++++++++++++ geometry_source/recoil_tof/materials.pl | 21 +++++ geometry_source/recoil_tof/recoil_tof.gcard | 29 ++++++ geometry_source/recoil_tof/recoil_tof.pl | 91 +++++++++++++++++++ 7 files changed, 291 insertions(+) create mode 100644 geometry_source/recoil_tof/GeoArgParse.groovy create mode 100644 geometry_source/recoil_tof/config.dat create mode 100644 geometry_source/recoil_tof/factory.groovy create mode 100755 geometry_source/recoil_tof/geometry_java.pl create mode 100755 geometry_source/recoil_tof/materials.pl create mode 100644 geometry_source/recoil_tof/recoil_tof.gcard create mode 100755 geometry_source/recoil_tof/recoil_tof.pl diff --git a/geometry_source/recoil_tof/GeoArgParse.groovy b/geometry_source/recoil_tof/GeoArgParse.groovy new file mode 100644 index 00000000..0d48250d --- /dev/null +++ b/geometry_source/recoil_tof/GeoArgParse.groovy @@ -0,0 +1,18 @@ + +class GeoArgParse { + static String defaultVariation="default"; + static int defaultRunNumber=11; + static String getVariation(String[] args) { + for (int ii=0; ii + w<{$vname}; + $detector{"description"} = "CLAS12 recoil TOF, Sector $s"; + $detector{"pos"} = $positions->{$vname}; + $detector{"rotation"} = $rotations->{$vname}; + $detector{"type"} = $types->{$vname}; + $detector{"dimensions"} = $dimensions->{$vname}; + $detector{"color"} = "aa0000"; + $detector{"material"} = "G4_Galactic"; + $detector{"style"} = 0; + $detector{"visible"} = 0; + print_det(\%main::configuration, \%detector); + + for(my $row=1; $row<=$nRows; $row++) { + for(my $col=1; $col<=$nCols; $col++) { + make_bar($s, $row, $col); + } + } + } + +} + +sub make_bar +{ + my $iSector = $_[0]; + my $iRow = $_[1]; + my $iCol =$_[2]; + + my %detector = init_det(); + + my $vname = "bar_sector${iSector}_row${iRow}_column${iCol}"; + + $detector{"name"} = $vname; + $detector{"mother"} = $mothers->{$vname}; + $detector{"description"} = "Sector $iSector, Bar, row $iRow, column $iCol"; + $detector{"pos"} = $positions->{$vname}; + $detector{"rotation"} = $rotations->{$vname}; + $detector{"type"} = $types->{$vname}; + $detector{"dimensions"} = $dimensions->{$vname}; + $detector{"color"} = "aa0000"; + $detector{"material"} = "scintillator"; + $detector{"style"} = 0; + $detector{"visible"} = 1; + + print_det(\%main::configuration, \%detector); + +} + + +sub makeRECOILTOF +{ + + ($mothers, $positions, $rotations, $types, $dimensions, $ids) = @main::volumes; + + make_sector(); + + +} + +1; diff --git a/geometry_source/recoil_tof/materials.pl b/geometry_source/recoil_tof/materials.pl new file mode 100755 index 00000000..fce03b19 --- /dev/null +++ b/geometry_source/recoil_tof/materials.pl @@ -0,0 +1,21 @@ +use strict; +use warnings; + +our %configuration; + + +sub materials +{ + # uploading the mat definition + + # Scintillator + my %mat = init_mat(); + $mat{"name"} = "scintillator"; + $mat{"description"} = "recoil tof scintillator material"; + $mat{"density"} = "1.032"; + $mat{"ncomponents"} = "2"; + $mat{"components"} = "C 9 H 10"; + print_mat(\%configuration, \%mat); + +} + diff --git a/geometry_source/recoil_tof/recoil_tof.gcard b/geometry_source/recoil_tof/recoil_tof.gcard new file mode 100644 index 00000000..e132a383 --- /dev/null +++ b/geometry_source/recoil_tof/recoil_tof.gcard @@ -0,0 +1,29 @@ + + + diff --git a/geometry_source/recoil_tof/recoil_tof.pl b/geometry_source/recoil_tof/recoil_tof.pl new file mode 100755 index 00000000..d73609b0 --- /dev/null +++ b/geometry_source/recoil_tof/recoil_tof.pl @@ -0,0 +1,91 @@ +#!/usr/bin/perl -w + +use strict; +use lib ("$ENV{GEMC}/api/perl"); +use utils; +use parameters; +use geometry; +use hit; +use bank; +use math; +use materials; + +use Math::Trig; + +# Help Message +sub help() +{ + print "\n Usage: \n"; + print " recoil_tof.pl \n"; + print " Will create the CLAS12 recoil tof geometry, materials, bank and hit definitions\n"; + exit; +} + +# Make sure the argument list is correct +if( scalar @ARGV != 1) +{ + help(); + exit; +} + +# Loading configuration file and paramters +our %configuration = load_configuration($ARGV[0]); +#$configuration{"variation"} = "default" ; + +# Global pars - these should be read by the load_parameters from file or DB + + +# materials +require "./materials.pl"; + +# banks definitions +#require "./bank.pl"; + +# hits definitions +#require "./hit.pl"; + +#system("which run-groovy"); + +# sensitive geometry +require "./geometry_java.pl"; + + +# all the scripts must be run for every configuration +# Right now run both configurations, later on just ccdb +#my @allConfs = ("ccdb", "cosmicR1", "ddvcs", "java"); +#my @allConfs = ("default"); + +my @allConfs = ("default"); + +# bank definitions common to all variations +#define_bank(); + +#foreach my $conf ( @allConfs ){ +for(my $ii=0; $ii<=$#allConfs; $ii++){ +# $configuration{"variation"} = $conf ; + $configuration{"variation"} = $allConfs[$ii]; + print "$configuration{variation}\n"; + + system("/w/hallb-scshelf2102/clas12/users/nwickjlb/coatjava_edit/coatjava/coatjava/bin/run-groovy factory.groovy --variation $configuration{variation} --runnumber 11"); + #system("groovy -cp '../*:..' factory.groovy --variation $configuration{variation} --runnumber 11"); + + # %configuration = $configuration{"variation"}; + + # materials + materials(); + + # hits + #define_hit(); + + + # sensitive geometry + # Global pars - these should be read by the load_parameters from file or DB + our @volumes = get_volumes(%configuration); + + + print "variation default\n"; + print "configuration{$configuration{variation})\n"; + coatjava::makeRECOILTOF(); + +} + From ae0436e0fbac0582da1c25d2345a4f6bedc25d78 Mon Sep 17 00:00:00 2001 From: niwgit Date: Wed, 19 Mar 2025 10:58:01 -0400 Subject: [PATCH 02/10] Change file description to match with recoil TOF --- geometry_source/recoil_tof/config.dat | 2 +- geometry_source/recoil_tof/factory.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/geometry_source/recoil_tof/config.dat b/geometry_source/recoil_tof/config.dat index f7dcc421..561b9824 100644 --- a/geometry_source/recoil_tof/config.dat +++ b/geometry_source/recoil_tof/config.dat @@ -1,4 +1,4 @@ -# Configuration file for recoil +# Configuration file for recoil TOF # Detector name and variation detector_name: recoil_tof diff --git a/geometry_source/recoil_tof/factory.groovy b/geometry_source/recoil_tof/factory.groovy index fd27026d..fbb8701a 100644 --- a/geometry_source/recoil_tof/factory.groovy +++ b/geometry_source/recoil_tof/factory.groovy @@ -1,5 +1,5 @@ //============================================================ -// This script prints volumes for RECOIL detector +// This script prints volumes for RECOIL TOF detector //============================================================ import org.jlab.geom.base.*; import org.jlab.clasrec.utils.*; From 78eafcc5cc7799c6fbed2fcd7313f2090eb8b474 Mon Sep 17 00:00:00 2001 From: niwgit Date: Thu, 20 Mar 2025 11:39:44 -0400 Subject: [PATCH 03/10] Initial implementation of digitization for RGH recoil TOF --- geometry_source/recoil_tof/bank.pl | 36 +++ geometry_source/recoil_tof/geometry_java.pl | 5 +- geometry_source/recoil_tof/hit.pl | 23 ++ geometry_source/recoil_tof/recoil_tof.gcard | 4 +- source/SConstruct | 3 +- source/hitprocess/HitProcess_MapRegister.cc | 2 + .../recoil_tof/recoil_tof_hitprocess.cc | 293 ++++++++++++++++++ .../clas12/recoil_tof/recoil_tof_hitprocess.h | 68 ++++ source/output/hipoSchemas.cc | 7 +- source/output/hipoSchemas.h | 1 + source/output/hipo_output.h | 1 + 11 files changed, 437 insertions(+), 6 deletions(-) create mode 100755 geometry_source/recoil_tof/bank.pl create mode 100644 geometry_source/recoil_tof/hit.pl create mode 100644 source/hitprocess/clas12/recoil_tof/recoil_tof_hitprocess.cc create mode 100644 source/hitprocess/clas12/recoil_tof/recoil_tof_hitprocess.h diff --git a/geometry_source/recoil_tof/bank.pl b/geometry_source/recoil_tof/bank.pl new file mode 100755 index 00000000..0ff8e58b --- /dev/null +++ b/geometry_source/recoil_tof/bank.pl @@ -0,0 +1,36 @@ +use strict; +use warnings; + +our %configuration; + +# Variable Type is two chars. +# The first char: +# R for raw integrated variables +# D for dgt integrated variables +# S for raw step by step variables +# M for digitized multi-hit variables +# V for voltage(time) variables +# +# The second char: +# i for integers +# d for doubles + +sub define_bank +{ + my $bankname = shift; + my $bankId = shift; + + insert_bank_variable(\%configuration, $bankname, "bankid", $bankId, "Di", "$bankname bank ID"); + insert_bank_variable(\%configuration, $bankname, "sector", 1, "Di", "recoil tof sector"); + insert_bank_variable(\%configuration, $bankname, "row", 2, "Di", "recoil tof row"); + insert_bank_variable(\%configuration, $bankname, "column", 3, "Di", "recoil tof column"); + insert_bank_variable(\%configuration, $bankname, "TDC_order", 4, "Di", "order 0/1 for up/downstream"); + insert_bank_variable(\%configuration, $bankname, "TDC_TDC", 5, "Di", "TDC"); + insert_bank_variable(\%configuration, $bankname, "TDC_ToT" , 6, "Di", "ToT"); + insert_bank_variable(\%configuration, $bankname, "hitn", 99, "Di", "hit number"); +} + +sub define_banks { + define_bank("recoil_tof", 22700); +} + diff --git a/geometry_source/recoil_tof/geometry_java.pl b/geometry_source/recoil_tof/geometry_java.pl index 435abd1e..ec48fd85 100755 --- a/geometry_source/recoil_tof/geometry_java.pl +++ b/geometry_source/recoil_tof/geometry_java.pl @@ -66,7 +66,10 @@ sub make_bar $detector{"material"} = "scintillator"; $detector{"style"} = 0; $detector{"visible"} = 1; - + $detector{"sensitivity"} = "recoil_tof"; + $detector{"hit_type"} = "recoil_tof"; + # set the identifiers + $detector{"identifiers"} = "sector manual $iSector row manual $iRow column manual $iCol order manual 0"; print_det(\%main::configuration, \%detector); } diff --git a/geometry_source/recoil_tof/hit.pl b/geometry_source/recoil_tof/hit.pl new file mode 100644 index 00000000..18c9ad85 --- /dev/null +++ b/geometry_source/recoil_tof/hit.pl @@ -0,0 +1,23 @@ +use strict; +use warnings; + +our %configuration; + +sub define_hit +{ + # uploading the hit definition + my %hit = init_hit(); + $hit{"name"} = "recoil_tof"; + $hit{"description"} = "recoil tof hit definitions "; + $hit{"identifiers"} = "sector row column"; + $hit{"signalThreshold"} = "0.5*MeV"; + $hit{"timeWindow"} = "400*ns"; + $hit{"prodThreshold"} = "1*mm"; + $hit{"maxStep"} = "1*cm"; + $hit{"delay"} = "50*ns"; + $hit{"riseTime"} = "0.7*ns"; + $hit{"fallTime"} = "1.8*ns"; + $hit{"mvToMeV"} = 100; + $hit{"pedestal"} = -20; + print_hit(\%configuration, \%hit); +} diff --git a/geometry_source/recoil_tof/recoil_tof.gcard b/geometry_source/recoil_tof/recoil_tof.gcard index e132a383..64ccac45 100644 --- a/geometry_source/recoil_tof/recoil_tof.gcard +++ b/geometry_source/recoil_tof/recoil_tof.gcard @@ -6,8 +6,8 @@ -