spradlin / WCSim

The WCSim GEANT4 application
0 stars 0 forks source link

Investigating main_into_hybrid #15

Open spradlin opened 2 years ago

spradlin commented 2 years ago

Description

The tdealtry/main_into_hybrid is a necessary and massive revision to the WCSim project to allow the simulation of a HyperK far detector with heterogenous PMT types in the innder detectore. Given the scope of the revision, it needs careful validation. This issue documents my attempts to contribute to the validation effort.

In ongoing validation efforts reported in 19 May 2022 HK Software meeting, two concerns are noted:

  1. Fewer outer detectore (OD) hits than expected are recorded in simulated events with high energy muons,
    • Expect average 150 hits in OD for 5GeV muons based on simulations with main WCSim/develop, see average of 3 hits.
  2. OD hits are recorded when there should be none in simulated events with low energy electrons at the center of the main barrel,
    • 5MeV electrons and their emitted photons should not pierce the optical shielding between the innter detector and OD, yet see OD hits in approximately 1% of events.

I will try to recreate these observations and investigate their causes.

spradlin commented 2 years ago

Test macros

I was provided the following macro to use as a starting point for testing. It should run on both WCSim/develop and tdealtry/main_into_hybrid branches and produce comparable or near-identical output: wcsim_hkod_explicit_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500_seed98.mac.txt

It imports additional configuration macros to define the primaries and to set the dark noise rates to 0: darktank0.mac.txt darkod0.mac.txt gun5000MeVmumOD.mac.txt

The main macro also imports a daq.mac, which was not provided. I will use the version provided as standard with tdealtry/main_into_hybrid, macros/daq.mac. It differes from the WCSim/develop version only in the DAQ/DigitizerOpt/TimingPrecision option: https://github.com/WCSim/WCSim/blob/0403225ffb3b22ef25113bd0ae66ab21db952699/macros/daq.mac#L11 https://github.com/tdealtry/WCSim/blob/f7d1424cf39f287a2ecd754f0aeba84d880188bd/macros/daq.mac#L11

The detector geometry invoked by this test macro is HyperKWithOD, which has an homogenous inner detector. This geometry should be the same in the two versions of WCSim. Running this test macro in the two versions should produce statistically compatible results.

spradlin commented 2 years ago

Output files

WCSim/develop

Running the test macro with the current WCSim/develop produces three output files:

  1. wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500.root, the main output file containing the results of the simulation,
  2. cosmicflux.root, a dump of the internal representation of the cosmic muon flux (not used in the test simulation), and
  3. geofile.txt, a plain text file with, presumably, some geometry information.

tdealtry/main_into_hybrid

Running the test macro with the current head of tdealtry/main_into_hybrid, i get the following error message,

WCSim requires 2 mac-files:
    Usage: WCSim {input.mac} {tuning.mac}
TODO: restore the no-arguments mode of running, where you can type your .mac arguments directly into the G4 command prompt

Unless otherwise noted, i will use the tuningNominal.mac file included in the base directory of tdealtry/main_into_hybrid as the second argument.

After amending the command line to include the tuning file, WCSim produces five output files. These include files 1 and 2 as above and the following:

  1. wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500_flat.root,
  2. geofile_SuperK.txt, and
  3. geofile_HyperKWithOD.txt.

The contents of files 4 and 5 differ from each other and from the geofile.txt of WCSim/develop. I have never looked into the process that produce these files, so i do not know if this is expected.

spradlin commented 2 years ago

Initial inspection of Root files

Popping open the wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500.root files produced by each of the versions for a cursory inspection.

WCSim/develop

The standard output file contains three TTree objects:

root [2] fin->ls()
TFile**     wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500.root WCSim ROOT file
 TFile*     wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500.root WCSim ROOT file
  KEY: TTree    wcsimT;1    WCSim Tree
  KEY: TTree    wcsimGeoT;1 WCSim Geometry Tree
  KEY: TTree    wcsimRootOptionsT;1 WCSim Options Tree

The tree wcsimGeoT contains one entry and one branch: one WCSimRootGeom object in total:

root [3] auto gt = dynamic_cast<TTree *>(fin->Get("wcsimGeoT"));
root [4] gt->Print()
******************************************************************************
*Tree    :wcsimGeoT : WCSim Geometry Tree                                    *
*Entries :        1 : Total =         2128608 bytes  File  Size =     248937 *
*        :          : Tree compression factor =   8.56                       *
******************************************************************************
*Br    0 :wcsimrootgeom : WCSimRootGeom                                      *
*Entries :        1 : Total  Size=    2128172 bytes  File Size  =     248500 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   8.56     *
*............................................................................*

Similarly, the tree wcsimRootOptionsT contains one WCSimRootOptions object:

root [5] auto ot = dynamic_cast<TTree *>(fin->Get("wcsimRootOptionsT"));
root [6] ot->Print()
******************************************************************************
*Tree    :wcsimRootOptionsT: WCSim Options Tree                                     *
*Entries :        1 : Total =            1441 bytes  File  Size =        767 *
*        :          : Tree compression factor =   1.40                       *
******************************************************************************
*Br    0 :wcsimrootoptions : WCSimRootOptions                                *
*Entries :        1 : Total  Size=        988 bytes  File Size  =        325 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   1.40     *
*............................................................................*

The wcsimT tree contains the main event records, 500 entries of several branches:

root [7] auto wt = dynamic_cast<TTree *>(fin->Get("wcsimT"));
root [8] wt->Print()
******************************************************************************
*Tree    :wcsimT    : WCSim Tree                                             *
*Entries :      500 : Total =       309180631 bytes  File  Size =  101776991 *
*        :          : Tree compression factor =   3.04                       *
******************************************************************************
*Branch  :wcsimrootevent                                                     *
*Entries :      500 : BranchElement (see below)                              *
*............................................................................*
*Br    0 :fUniqueID : UInt_t                                                 *
*Entries :      500 : Total  Size=       2583 bytes  File Size  =        116 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=  17.91     *
*............................................................................*
*Br    1 :fBits     : UInt_t                                                 *
*Entries :      500 : Total  Size=       4571 bytes  File Size  =        956 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   4.27     *
*............................................................................*
*Br    2 :fEventList : TObjArray*                                            *
*Entries :      500 : Total  Size=  265811583 bytes  File Size  =   84402572 *
*Baskets :      500 : Basket Size=      64000 bytes  Compression=   3.15     *
*............................................................................*
*Branch  :wcsimrootevent_OD                                                  *
*Entries :      500 : BranchElement (see below)                              *
*............................................................................*
*Br    3 :fUniqueID : UInt_t                                                 *
*Entries :      500 : Total  Size=       2583 bytes  File Size  =        116 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=  17.91     *
*............................................................................*
*Br    4 :fBits     : UInt_t                                                 *
*Entries :      500 : Total  Size=       4571 bytes  File Size  =        956 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   4.27     *
*............................................................................*
*Br    5 :fEventList : TObjArray*                                            *
*Entries :      500 : Total  Size=   43351883 bytes  File Size  =   17361491 *
*Baskets :      500 : Basket Size=      64000 bytes  Compression=   2.50     *
*............................................................................*

tdealtry/main_into_hybrid

The new version output file contains the same three trees:

root [2] fin->ls()
TFile**     wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500.root WCSim ROOT file
 TFile*     wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500.root WCSim ROOT file
  KEY: TTree    wcsimGeoT;1 WCSim Geometry Tree
  KEY: TTree    wcsimRootOptionsT;1 WCSim Options Tree
  KEY: TTree    wcsimT;1    WCSim Tree

The tree wcsimGeoT contains one WCSimRootGeom object, as in the standard version:

root [3] auto gt = dynamic_cast<TTree *>(fin->Get("wcsimGeoT"));
root [4] gt->Print()
******************************************************************************
*Tree    :wcsimGeoT : WCSim Geometry Tree                                    *
*Entries :        1 : Total =         2499701 bytes  File  Size =     343805 *
*        :          : Tree compression factor =   7.28                       *
******************************************************************************
*Br    0 :wcsimrootgeom : WCSimRootGeom                                      *
*Entries :        1 : Total  Size=    2499265 bytes  File Size  =     343372 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   7.28     *
*............................................................................*

Similarly, the tree wcsimRootOptionsT contains one WCSimRootOptions object:

root [5] auto ot = dynamic_cast<TTree *>(fin->Get("wcsimRootOptionsT"));
root [6] ot->Print()
******************************************************************************
*Tree    :wcsimRootOptionsT: WCSim Options Tree                                     *
*Entries :        1 : Total =            1473 bytes  File  Size =        776 *
*        :          : Tree compression factor =   1.44                       *
******************************************************************************
*Br    0 :wcsimrootoptions : WCSimRootOptions                                *
*Entries :        1 : Total  Size=       1020 bytes  File Size  =        338 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   1.44     *
*............................................................................*

The wcsimT tree has some interesting differences in structure:

root [7] auto wt = dynamic_cast<TTree *>(fin->Get("wcsimT"));
root [8] wt->Print()
******************************************************************************
*Tree    :wcsimT    : WCSim Tree                                             *
*Entries :   197742 : Total =        33775100 bytes  File  Size =   13490939 *
*        :          : Tree compression factor =   2.50                       *
******************************************************************************
*Branch  :wcsimrootevent                                                     *
*Entries :        0 : BranchElement (see below)                              *
*............................................................................*
*Br    0 :fUniqueID : UInt_t                                                 *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :fBits     : UInt_t                                                 *
*Entries :        0 : Total  Size=        489 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :fEventList : TObjArray*                                            *
*Entries :        0 : Total  Size=        509 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Branch  :wcsimrootevent2                                                    *
*Entries :        0 : BranchElement (see below)                              *
*............................................................................*
*Br    3 :fUniqueID : UInt_t                                                 *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :fBits     : UInt_t                                                 *
*Entries :        0 : Total  Size=        489 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :fEventList : TObjArray*                                            *
*Entries :        0 : Total  Size=        509 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Branch  :wcsimrootevent_OD                                                  *
*Entries :      500 : BranchElement (see below)                              *
*............................................................................*
*Br    6 :fUniqueID : UInt_t                                                 *
*Entries :      500 : Total  Size=       2583 bytes  File Size  =        116 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=  17.91     *
*............................................................................*
*Br    7 :fBits     : UInt_t                                                 *
*Entries :      500 : Total  Size=       4571 bytes  File Size  =        956 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   4.27     *
*............................................................................*
*Br    8 :fEventList : TObjArray*                                            *
*Entries :      500 : Total  Size=   33760837 bytes  File Size  =   13483651 *
*Baskets :      500 : Basket Size=      64000 bytes  Compression=   2.50     *
*............................................................................*

Some observations:

Additional 'flat' root file

The additional Root file written by the tdealtry/main_into_hybrid version, wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500_flat.root, contains seven TTree objects:

root [2] fin->ls()
TFile**     wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500_flat.root    WCSim FLAT ROOT file
 TFile*     wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500_flat.root    WCSim FLAT ROOT file
  KEY: TTree    MasterTree;1    Main WCSim Tree
  KEY: TTree    Geometry;1  Geometry Tree
  KEY: TTree    Tracks;1    Tracks Tree
  KEY: TTree    CherenkovHits;1 Cherenkov Hits Tree
  KEY: TTree    CherenkovDigiHits;1 Cherenkov DigiHits Tree
  KEY: TTree    Trigger;1   Trigger Tree
  KEY: TTree    EventInfo;1 EventInfo Tree

MasterTree appears to be empty:

root [3] auto mt = dynamic_cast<TTree *>(fin->Get("MasterTree"));
root [4] mt->Print()
******************************************************************************
*Tree    :MasterTree: Main WCSim Tree                                        *
*Entries :        0 : Total =             676 bytes  File  Size =        375 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************

Geometry does look like a representation that has been flattened into arrays of builtin datatypes:

root [5] auto gt = dynamic_cast<TTree *>(fin->Get("Geometry"));
root [6] gt->Print()
******************************************************************************
*Tree    :Geometry  : Geometry Tree                                          *
*Entries :        1 : Total =         3113789 bytes  File  Size =     205559 *
*        :          : Tree compression factor =  15.24                       *
******************************************************************************
*Br    0 :GeometryType : GeometryType[20]/C                                  *
*Entries :        1 : Total  Size=        625 bytes  File Size  =        104 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :CylinderRadius : CylinderRadius/D                                  *
*Entries :        1 : Total  Size=        622 bytes  File Size  =         93 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :CylinderLength : CylinderLength/D                                  *
*Entries :        1 : Total  Size=        622 bytes  File Size  =         93 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    3 :PMTtype_ID : PMTtype_ID[50]/C                                      *
*Entries :        1 : Total  Size=        607 bytes  File Size  =         94 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :PMTradius_ID : PMTradius_ID/D                                      *
*Entries :        1 : Total  Size=        612 bytes  File Size  =         91 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :PMTtype_OD : PMTtype_OD[50]/C                                      *
*Entries :        1 : Total  Size=        607 bytes  File Size  =         94 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    6 :PMTradius_OD : PMTradius_OD/D                                      *
*Entries :        1 : Total  Size=        612 bytes  File Size  =         91 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    7 :numPMT_ID : numPMT_ID/I                                            *
*Entries :        1 : Total  Size=        585 bytes  File Size  =         84 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    8 :numPMT_OD : numPMT_OD/I                                            *
*Entries :        1 : Total  Size=        585 bytes  File Size  =         84 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    9 :Orientation : Orientation/I                                        *
*Entries :        1 : Total  Size=        595 bytes  File Size  =         86 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   10 :Offset_x  : Offset_x/D                                             *
*Entries :        1 : Total  Size=        592 bytes  File Size  =         87 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   11 :Offset_y  : Offset_y/D                                             *
*Entries :        1 : Total  Size=        592 bytes  File Size  =         87 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   12 :Offset_z  : Offset_z/D                                             *
*Entries :        1 : Total  Size=        592 bytes  File Size  =         87 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   13 :num_mPMT  : num_mPMT/I                                             *
*Entries :        1 : Total  Size=        580 bytes  File Size  =         83 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   14 :Tube      : Tube[numPMT_ID]/I                                      *
*Entries :        1 : Total  Size=     155548 bytes  File Size  =      76509 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   2.03     *
*............................................................................*
*Br   15 :mPMT      : mPMT[numPMT_ID]/I                                      *
*Entries :        1 : Total  Size=     155548 bytes  File Size  =      76509 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=   2.03     *
*............................................................................*
*Br   16 :mPMT_pmt  : mPMT_pmt[numPMT_ID]/I                                  *
*Entries :        1 : Total  Size=     155568 bytes  File Size  =        871 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression= 177.92     *
*............................................................................*
*Br   17 :x         : x[numPMT_ID]/D                                         *
*Entries :        1 : Total  Size=     310428 bytes  File Size  =      14531 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=  21.32     *
*............................................................................*
*Br   18 :y         : y[numPMT_ID]/D                                         *
*Entries :        1 : Total  Size=     310428 bytes  File Size  =      15095 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=  20.53     *
*............................................................................*
*Br   19 :z         : z[numPMT_ID]/D                                         *
*Entries :        1 : Total  Size=     310428 bytes  File Size  =       2761 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression= 112.22     *
*............................................................................*
*Br   20 :cylLocation : cylLocation[numPMT_ID]/I                             *
*Entries :        1 : Total  Size=     155583 bytes  File Size  =        799 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression= 193.96     *
*............................................................................*
*Br   21 :direction_x : direction_x[numPMT_ID]/D                             *
*Entries :        1 : Total  Size=     310478 bytes  File Size  =       3935 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=  78.74     *
*............................................................................*
*Br   22 :direction_y : direction_y[numPMT_ID]/D                             *
*Entries :        1 : Total  Size=     310478 bytes  File Size  =       3809 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=  81.35     *
*............................................................................*
*Br   23 :direction_z : direction_z[numPMT_ID]/D                             *
*Entries :        1 : Total  Size=     310478 bytes  File Size  =       1822 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression= 170.06     *
*............................................................................*
*Br   24 :phi       : phi[numPMT_ID]/D                                       *
*Entries :        1 : Total  Size=     310438 bytes  File Size  =       3746 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression=  82.71     *
*............................................................................*
*Br   25 :theta     : theta[numPMT_ID]/D                                     *
*Entries :        1 : Total  Size=     310448 bytes  File Size  =       1780 *
*Baskets :        1 : Basket Size=      32000 bytes  Compression= 174.07     *
*............................................................................*

Tracks also appears to be empty:

root [9] auto tr = dynamic_cast<TTree *>(fin->Get("Tracks"));
root [10] tr->Print()
******************************************************************************
*Tree    :Tracks    : Tracks Tree                                            *
*Entries :        0 : Total =           13113 bytes  File  Size =       1325 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :Run       : Run/I                                                  *
*Entries :        0 : Total  Size=        477 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :Event     : Event/I                                                *
*Entries :        0 : Total  Size=        485 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :SubEvent  : SubEvent/I                                             *
*Entries :        0 : Total  Size=        497 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    3 :Ntracks   : Ntracks/I                                              *
*Entries :        0 : Total  Size=        493 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :Pid       : Pid[Ntracks]/I                                         *
*Entries :        0 : Total  Size=        569 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :Flag      : Flag[Ntracks]/I                                        *
*Entries :        0 : Total  Size=        573 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    6 :Mass      : Mass[Ntracks]/D                                        *
*Entries :        0 : Total  Size=        588 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    7 :P         : P[Ntracks]/D                                           *
*Entries :        0 : Total  Size=        576 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    8 :Energy    : Energy[Ntracks]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    9 :ParentID  : ParentID[Ntracks]/I                                    *
*Entries :        0 : Total  Size=        589 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   10 :TrackID   : TrackID[Ntracks]/I                                     *
*Entries :        0 : Total  Size=        585 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   11 :Time      : Time[Ntracks]/D                                        *
*Entries :        0 : Total  Size=        588 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   12 :Dirx      : Dirx[Ntracks]/D                                        *
*Entries :        0 : Total  Size=        588 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   13 :Diry      : Diry[Ntracks]/D                                        *
*Entries :        0 : Total  Size=        588 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   14 :Dirz      : Dirz[Ntracks]/D                                        *
*Entries :        0 : Total  Size=        588 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   15 :Px        : Px[Ntracks]/D                                          *
*Entries :        0 : Total  Size=        580 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   16 :Py        : Py[Ntracks]/D                                          *
*Entries :        0 : Total  Size=        580 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   17 :Pz        : Pz[Ntracks]/D                                          *
*Entries :        0 : Total  Size=        580 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   18 :Start_x   : Start_x[Ntracks]/D                                     *
*Entries :        0 : Total  Size=        600 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   19 :Start_y   : Start_y[Ntracks]/D                                     *
*Entries :        0 : Total  Size=        600 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   20 :Start_z   : Start_z[Ntracks]/D                                     *
*Entries :        0 : Total  Size=        600 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   21 :Stop_x    : Stop_x[Ntracks]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   22 :Stop_y    : Stop_y[Ntracks]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   23 :Stop_z    : Stop_z[Ntracks]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   24 :Length    : Length[Ntracks]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*

as does CherenkovHits:

root [12] auto ch = dynamic_cast<TTree *>(fin->Get("CherenkovHits"));
root [13] ch->Print()
******************************************************************************
*Tree    :CherenkovHits: Cherenkov Hits Tree                                    *
*Entries :        0 : Total =           11605 bytes  File  Size =       1275 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :Run       : Run/I                                                  *
*Entries :        0 : Total  Size=        477 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :Event     : Event/I                                                *
*Entries :        0 : Total  Size=        485 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :SubEvent  : SubEvent/I                                             *
*Entries :        0 : Total  Size=        497 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    3 :NHits     : NHits/I                                                *
*Entries :        0 : Total  Size=        485 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :NHits_noDN : NHits_noDN/I                                          *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :NPMTs     : NPMTs/I                                                *
*Entries :        0 : Total  Size=        485 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    6 :NPMTs_noDN : NPMTs_noDN/I                                          *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    7 :Time      : Time[NHits]/D                                          *
*Entries :        0 : Total  Size=        580 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    8 :PMT_QTot  : PMT_QTot[NHits]/I                                      *
*Entries :        0 : Total  Size=        581 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    9 :PMT_QTot_noDN : PMT_Qtot_noDN[NHits]/I                             *
*Entries :        0 : Total  Size=        601 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   10 :ParentID  : ParentID[NHits]/I                                      *
*Entries :        0 : Total  Size=        581 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   11 :Vector_index : Vector_index[NHits]/I                               *
*Entries :        0 : Total  Size=        597 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   12 :Tube      : Tube[NHits]/I                                          *
*Entries :        0 : Total  Size=        565 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   13 :mPMT      : mPMT[NHits]/I                                          *
*Entries :        0 : Total  Size=        565 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   14 :mPMT_pmt  : mPMT_pmt[NHits]/I                                      *
*Entries :        0 : Total  Size=        581 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   15 :TrackID   : TrackID[NHits]/I                                       *
*Entries :        0 : Total  Size=        577 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   16 :PMT_x     : PMT_x[NHits]/D                                         *
*Entries :        0 : Total  Size=        584 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   17 :PMT_y     : PMT_y[NHits]/D                                         *
*Entries :        0 : Total  Size=        584 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   18 :PMT_z     : PMT_z[NHits]/D                                         *
*Entries :        0 : Total  Size=        584 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   19 :PMT_dirx  : PMT_dirx[NHits]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   20 :PMT_diry  : PMT_diry[NHits]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   21 :PMT_dirz  : PMT_dirz[NHits]/D                                      *
*Entries :        0 : Total  Size=        596 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*

and CherenkovDigiHits:

root [14] auto cd = dynamic_cast<TTree *>(fin->Get("CherenkovDigiHits"));
root [15] cd->Print()
******************************************************************************
*Tree    :CherenkovDigiHits: Cherenkov DigiHits Tree                                *
*Entries :        0 : Total =            9643 bytes  File  Size =       1126 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :Run       : Run/I                                                  *
*Entries :        0 : Total  Size=        477 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :Event     : Event/I                                                *
*Entries :        0 : Total  Size=        485 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :SubEvent  : SubEvent/I                                             *
*Entries :        0 : Total  Size=        497 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    3 :NDigiHits : NDigiHits/I                                            *
*Entries :        0 : Total  Size=        501 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :NDigiPMTs : NDigiPMTs/I                                            *
*Entries :        0 : Total  Size=        501 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :QTotDigi  : QTotDigi/D                                             *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    6 :Q         : Q[NDigiHits]/D                                         *
*Entries :        0 : Total  Size=        584 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    7 :T         : T[NDigiHits]/D                                         *
*Entries :        0 : Total  Size=        584 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    8 :Vector_index : Vector_index[NDigiHits]/I                           *
*Entries :        0 : Total  Size=        613 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    9 :Tube      : Tube[NDigiHits]/I                                      *
*Entries :        0 : Total  Size=        581 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   10 :mPMT      : mPMT[NDigiHits]/I                                      *
*Entries :        0 : Total  Size=        581 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   11 :mPMT_pmt  : mPMT_pmt[NDigiHits]/I                                  *
*Entries :        0 : Total  Size=        597 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   12 :PMT_x     : PMT_x[NDigiHits]/D                                     *
*Entries :        0 : Total  Size=        600 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   13 :PMT_y     : PMT_y[NDigiHits]/D                                     *
*Entries :        0 : Total  Size=        600 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   14 :PMT_z     : PMT_z[NDigiHits]/D                                     *
*Entries :        0 : Total  Size=        600 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   15 :PMT_dirx  : PMT_dirx[NDigiHits]/D                                  *
*Entries :        0 : Total  Size=        612 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   16 :PMT_diry  : PMT_diry[NDigiHits]/D                                  *
*Entries :        0 : Total  Size=        612 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br   17 :PMT_dirz  : PMT_dirz[NDigiHits]/D                                  *
*Entries :        0 : Total  Size=        612 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*

and Trigger:

root [17] auto tr = dynamic_cast<TTree *>(fin->Get("Trigger"));
root [18] tr->Print()
******************************************************************************
*Tree    :Trigger   : Trigger Tree                                           *
*Entries :        0 : Total =            3882 bytes  File  Size =        687 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :Run       : Run/I                                                  *
*Entries :        0 : Total  Size=        477 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :Event     : Event/I                                                *
*Entries :        0 : Total  Size=        485 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :SubEvent  : SubEvent/I                                             *
*Entries :        0 : Total  Size=        497 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    3 :Type      : Type/I                                                 *
*Entries :        0 : Total  Size=        481 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :TriggeredDigits : TriggerDigits/I                                  *
*Entries :        0 : Total  Size=        519 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :Length    : TriggerLength/D                                        *
*Entries :        0 : Total  Size=        518 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    6 :StartTime : StartTime/D                                            *
*Entries :        0 : Total  Size=        509 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*

and EventInfo:

root [19] auto ev = dynamic_cast<TTree *>(fin->Get("EventInfo"));
root [20] ev->Print()
******************************************************************************
*Tree    :EventInfo : EventInfo Tree                                         *
*Entries :        0 : Total =            4438 bytes  File  Size =        742 *
*        :          : Tree compression factor =   1.00                       *
******************************************************************************
*Br    0 :Run       : Run/I                                                  *
*Entries :        0 : Total  Size=        477 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    1 :Event     : Event/I                                                *
*Entries :        0 : Total  Size=        485 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    2 :SubEvent  : SubEvent/I                                             *
*Entries :        0 : Total  Size=        497 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    3 :InteractionMode : InteractionMode/I                                *
*Entries :        0 : Total  Size=        525 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :VertexVolume : VertexVolume[100]/C                                 *
*Entries :        0 : Total  Size=        523 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :Vertex_x  : Vertex_x/D                                             *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    6 :Vertex_y  : Vertex_y/D                                             *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*
*Br    7 :Vertex_z  : Vertex_z/D                                             *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      32000 bytes  Compression=   1.00     *
*............................................................................*

I would guess that this file is filled only if a new option is set. Will ignore it, for now.

spradlin commented 2 years ago

Dumping wcsimGeoT

The testgeo.C Root script dumps much of the contents of the geometry tree wcsimGeoT. By default, it caps the number of PMTs dumped at 20. I removed the cap and ran the script over each of the wcsim_hkod_SensitiveDetector_Only_NoTrigger_gun5000MeVmumOD_dark0_n500.root output files.

The stdout of the script is long---116170 lines---so i will not attach it here. The important thing is that the two versions of WCSim produce geometry trees with nearly identical contents. The diff of the testgeo.C outputs indicates just one difference:

$ diff geodump.develop.txt geodump.main_into_hybrid.txt 
6c6[`testgeo.C`](https://github.com/WCSim/WCSim/blob/develop/sample-root-scripts/testgeo.C)
< Cyl length 6697.854980
---
> Cyl length 6694.200195

All of the other information dumped by the script, including the locations and orientations of the 38720 PMTs, is identical between the two versions.

Update---OD

I previously failed to notice that testgeo.C does not dump what information is contained about the OD PMTs. The comparisons that i made above were only for the inner detector PMTs. I made a copy of the script and updated it to dump just the OD PMT information.

Although the inner detector dumps are almost identical, there are significant differences in the OD dumps. The number of OD PMTs is different:

Interestingly, the OD PMT radius is also different:

And the coordinates of all of the PMTs is different. May need to check whether the same type of PMTs were used and rectify.

spradlin commented 2 years ago

Initial fixes to wcsimT

There are two clear problems with the wcsimT output TTree from tdealtry/main_into_hybrid:

The entries of the TTree wcsimT are filled in WCSimEventAction::EndOfEventAction. Specifically, it happens in lines 950-999. The wcsimT TTree has 3 main branches (2 in WCSim/develop) each called wcsimrootevent plus some optional suffix. Each of these branches appears to correspond to a subdetector:

It looks like all three of the branches may always exist, but they are filled selectively depending on whether the given subdetector is defined. It looks like this has resulted in an implementation in which the branches are filled independently and only when the corresponding subdetector is defined, probably to avoid storing large quantities of non-data for undefined subdetectors. In order for this to work, TTree::Fill() should never be called, as that will store the current contents of all branches, including the ones for undefined subdetectors. Instead, the individual TBranch::Fill() methods should be called.

However, TBranch::Fill() does not increment the counter for the number of entries attached to the TTree (to be verified). In order to handle this, WCSim keeps a running count of the number of events and calls TTree::SetEntries() to set the number of entries to the correct number. We should expect the number of entries in each branch to either be the number of entries in the TTree that contains it or 0.

With this understanding of the design intent, i think i can see where the code does not correspond to the design. First, the TBranch::Fill() method for the inner detector branches are not being called because the WCSimEventAction::FillRootEventHybrid() method does not call them. The corresponding WCSimEventAction::FillRootEvent(), which is used to fill wcsimrootevent_OD, ends with a call to TBranch::Fill().

The reason that this might seem to work if an OD is not defined is the TTree::Fill() call in lines 989-L993

The reason that the number of entries appears to be wrong is that that the counter that is used to set the TTree number of events is incremented in many independent places: the calls to runAction->incrementEventsGenerated():

This does not appear to be the intended behavior. The only call to the accessor WCSimRunAction::GetNumberOfEventsGenerated() in the entire code base is line 998 of WCSimEventAction::EndOfEventAction() which sets the size of the wcsimT TTree. Its only purpose is to keep an accurate count of the number of events recorded in the output.

Initial changes

I tried to address this in https://github.com/spradlin/WCSim/commit/d1ff1860cd486b5a0a77311cba7d5ba48925dac8.

wcsimT counters after initial changes

They make more sense:

root [3] auto wt = dynamic_cast<TTree *>(fin->Get("wcsimT"));
root [4] wt->Print()
******************************************************************************
*Tree    :wcsimT    : WCSim Tree                                             *
*Entries :      500 : Total =      1154121269 bytes  File  Size =  680771699 *
*        :          : Tree compression factor =   1.70                       *
******************************************************************************
*Branch  :wcsimrootevent                                                     *
*Entries :      500 : BranchElement (see below)                              *
*............................................................................*
*Br    0 :fUniqueID : UInt_t                                                 *
*Entries :      500 : Total  Size=       2583 bytes  File Size  =        116 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=  17.91     *
*............................................................................*
*Br    1 :fBits     : UInt_t                                                 *
*Entries :      500 : Total  Size=       4571 bytes  File Size  =        956 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   4.27     *
*............................................................................*
*Br    2 :fEventList : TObjArray*                                            *
*Entries :      500 : Total  Size= 1120340518 bytes  File Size  =  667274362 *
*Baskets :      500 : Basket Size=      64000 bytes  Compression=   1.68     *
*............................................................................*
*Branch  :wcsimrootevent2                                                    *
*Entries :        0 : BranchElement (see below)                              *
*............................................................................*
*Br    3 :fUniqueID : UInt_t                                                 *
*Entries :        0 : Total  Size=        505 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Br    4 :fBits     : UInt_t                                                 *
*Entries :        0 : Total  Size=        489 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Br    5 :fEventList : TObjArray*                                            *
*Entries :        0 : Total  Size=        509 bytes  One basket in memory    *
*Baskets :        0 : Basket Size=      64000 bytes  Compression=   1.00     *
*............................................................................*
*Branch  :wcsimrootevent_OD                                                  *
*Entries :      500 : BranchElement (see below)                              *
*............................................................................*
*Br    6 :fUniqueID : UInt_t                                                 *
*Entries :      500 : Total  Size=       2583 bytes  File Size  =        116 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=  17.91     *
*............................................................................*
*Br    7 :fBits     : UInt_t                                                 *
*Entries :      500 : Total  Size=       4571 bytes  File Size  =        956 *
*Baskets :        1 : Basket Size=      64000 bytes  Compression=   4.27     *
*............................................................................*
*Br    8 :fEventList : TObjArray*                                            *
*Entries :      500 : Total  Size=   33760837 bytes  File Size  =   13483651 *
*Baskets :      500 : Basket Size=      64000 bytes  Compression=   2.50     *
*............................................................................*
spradlin commented 2 years ago

Contents of wcsimT

The Root macro read_OD.C reads the contents of the wcsimT TTree and produces some histograms and a TTree of per-event counters. Attached are plots of the contents of the TTree counters.

Inner detector counters

rawHitsID digiHitsID numPMTsHitID numPMTsDigiHitID

In general, main_into_hybrid (_new) produces a much larger number of inner detector hits than WCSim/develop (_old).

Outer detector counters

rawHitsOD digiHitsOD numPMTsHitOD numPMTsDigiHitOD

In general, main_into_hybrid (_new) produces far fewer outer detector hits than WCSim/develop (_old).

spradlin commented 2 years ago

Single-event stdout

The stdout of both versions of WCSim feature floods of warnings for each event that indicate geometry overlaps. Keeping the log file of a 500 event run is not useful to me at this time, so i did not retain it. However, i am interested in whether the output from the configuration and initialzation phase of WCSim is consistent. So i ran 1-event runs throught both versions, configured as before.

File size

The stdout from main_into_hybrid is far more compact than that from WCSim/develop:

$ wc develop_n1.log main_into_hybrid_n1.log 
  603401 2846456 24560101 develop_n1.log
  190325  979936 8960069 main_into_hybrid_n1.log

Geant4 version

The two versions of WCSim are compiled against different versions of Geant4:

Some differences in the stdout will be attributal to this underlying difference.

Missing from main_into_hybrid

Investigations into statements in the WCSim/develop that are missing from the stdout of main_into_hybrid.

Setting OD WLS plate cladding reflectivity 0.900000

This message is printed from WCSimTuningMessenger::SetNewValue(). The corresponding print statement exists in main_into_hybrid, but it isn't invoked. Why? I am not sure. I do not see a relevant explicit call to WCSimTuningMessenger::SetNewValue() in the WCSim code base. Could this be something in the underlying Geant4 messaging?

This difference probably does not affect the output. The default value is 0.9 in both cases: WCSim/develop, main_into_hybrid.

Edit: This is understood when this comparison is resumed in a subsequent comment.

Resetting---match Geant4 versions

In discussing observations up to this point with @tdealtry, it was pointed out that the WCSim/develop can be compiled successfully against Geant4.10.3.3. I will do so, run the tests with the updated recompilation, and proceed from there.

spradlin commented 2 years ago

Contents of wcsimT updated

Adding the results of running WCSim/develop compiled against Geant4.10.3.3 to the plots in my previous comment.

The Root macro read_OD.C reads the contents of the wcsimT TTree and produces some histograms and a TTree of per-event counters. Attached are plots of the contents of the TTree counters. The source of the distribution is indicated by the suffix in the corresponding stat box:

The effect of the change in Geant4 version on the WCSim/develop counters (_int vs. _old) is not very large.

Inner detector counters

rawHitsID digiHitsID numPMTsHitID numPMTsDigiHitID

Outer detector counters

rawHitsOD digiHitsOD numPMTsHitOD numPMTsDigiHitOD

spradlin commented 2 years ago

Single-event stdout with matched Geant4

Restarting the observations of a previous comment, but this time with WCSim/develop and main_into_hybrid compiled against the same Geant4 version (geant4-10-03-patch-03).

File size

When compiled against Geant4.10.3.3, WCSim/develop has less stdout than even main_into_hybrid:

$ wc develop_n1.log develop_10_3_n1.log main_into_hybrid_n1.log
  603401 2846456 24560101 develop_n1.log
  137237  706973 6461269 develop_10_3_n1.log
  190325  979936 8960069 main_into_hybrid_n1.log

Missing from main_into_hybrid

Investigations into statements in the WCSim/develop that are missing from the stdout of main_into_hybrid.

Setting OD WLS plate cladding reflectivity 0.900000

My previous speculation that this difference might be due to a difference in Geant4 version was wrong. Interesting. Ahh, this seems to be due to the default tuning parameters that are automatically applied in the WCSim.cc main(). It automatically reads macros/tuning_parameters.mac, which includes an explicit command to set /WCSim/tuning/WCODWLSCladdingReflectivity.

In main_into_hybrid, this automatic processing of a hard-coded file is replaced with the requirement of an additional command line argument for a tuning macro.

Are there any other differences in the tuning parameters? See 'Comparison of tuning parameters' below.

Setting OD tyvek reflectivity 0.900000

Due to the same reason as 'Setting OD WLS plate cladding reflectivity 0.900000' message. This is set in the macros/tuning_parameters.mac that is automatically processed by WCSim/develop. However, it is set to its default value in both versions, and so is not expected to produce a difference: WCSim/develop, main_into_hybrid

Comparison of tuning parameters

When running WCSim/develop, WCsim is automatically importing and processing macros/tuning_parameters.mac.

When running main_into_hybrid, i am including the tuningNominal.mac file included in the main repository directory.

The differences:

$ diff tuningNominal.mac macros/tuning_parameters.mac 
5c5
< /WCSim/tuning/bsrff 2.5
---
> /WCSim/tuning/bsrff 2.50
12a13,16
> 
> 
> /WCSim/tuning/WCODWLSCladdingReflectivity 0.90
> /WCSim/tuning/WCODTyvekReflectivity 0.90

The difference of precision in bsrff should be trivial. The variable WCODWLSCladdingReflectivity is set to its default value in both versions: WCSim/develop, main_into_hybrid. The variable WCODTyvekReflectivity is also set to its default value in both versions: WCSim/develop, main_into_hybrid

These differences in the tuning files should almost certainly not produce an appreciable difference.

spradlin commented 2 years ago

Extra in main_into_hybrid

Edit: Split off from previous comment due to growing length.

'ABWFF : 1.3', 'RAYFF: 0.75', and 'MIEFF: 0'

These three lines come from WCSimDetectorConstruction::ConstructMaterials(). They are not associated with any significant change between the versions and appear to be merely additional print statements after these parameter values are retrieved from the WCSimTuningParameters object. For reference, below are links to the context that produces these lines and their analagous context in WCSim/develop:

B.Q: Read/control/execute ..../macros/jobOptions.mac

This is a new line of stdout, but it reports on something that happens in both version. It comes from WCSim.cc main(). In WCSim/develop, the analagous code block is silent.

So macros/jobOptions.mac is always read (hard-coded filename). The WCSim/develop version and main_into_hybrid version differ slightly. From a WCSim/develop clone:

$ git diff tdealtry/main_into_hybrid -- macros/jobOptions.mac 
diff --git a/macros/jobOptions.mac b/macros/jobOptions.mac
index fc78aa6..2b15d7d 100644
--- a/macros/jobOptions.mac
+++ b/macros/jobOptions.mac
@@ -13,7 +13,5 @@
 #/WCSim/physics/list QGSP_BIC_HP #preferred for energies below 5 GeV
 #/WCSim/physics/list LBE # preferred for low-background experiments.  
 /WCSim/physics/list FTFP_BERT # recommended for high energy physics and hadron 
-#/WCSim/physics/list FTFP_BERT_HP
-/WCSim/physics/nCapture Default

The /WCSim/physics/nCapture command is new to main_into_hybrid. It sets the value of WCSimPhysicsListFactory::nCaptModelChoice. This value is used in WCSimPhysicsListFactory::ConstructProcess() to configure an additional physics process. If the value is "Default" (as it is), then the behavior of the main_into_hybrid version of WCSimPhysicsListFactory::ConstructProcess() should be the same as the WCSim/develop version.

Setting neutron capture model to Default

Output from the new method WCSimPhysicsListFactory::SetnCaptModel(). See above for more discussion of the new neutron capture physics configuration. The 'Defualt' option appears to reproduce the WCSim/develop physics configuration.

WCSimWCPMT::WCSimWCPMT recording collection name WCRawPMTSignalCollection

This message comes from the WCSimWCPMT class constructor. In WCSim/develop, a similar message is conditionally printed if the implementation file is compiled with a verbosity flag, but the main_into_hybrid version prints it unconditionally.

Two additional messages appear in the main_into_hybrid stdout from this bit of code:

WCSimWCPMT::WCSimWCPMT recording collection name WCRawPMTSignalCollection2

and

WCSimWCPMT::WCSimWCPMT recording collection name WCRawPMTSignalCollection_OD

The WCSimWCPMT class derives from G4VDigitizerModule. It is interesting that there is an instance constructed for the second tank array of PMTs (see the WCRawPMTSignalCollection2 message) when this test scenario should not have a secondary tank array. Is this expected? Interestingly, yes. All WCSimWCPMT objects appear to be created in the WCSimEventAction class constructor. In both WCSim/develop and main_into_hybrid, the WCSimEventAction unconditionally constructs all WCSimWCPMT and WCSimWCAddDarkNoise objects that might be needed for any configuration.

added tankPMT2 to the DarkRateMessenger

This comes from WCSimDarkRateMessenger::AddDarkRateInstance(), which is invoked from the WCSimWCAddDarkNoise constructor (see above item concerning construction of WCSimWCAddDarkNoise objects in the WCSimEventAction constructor). The relevant code in the WCSimWCAddDarkNoise constructor and WCSimDarkRateMessenger::AddDarkRateInstance() is unchanged with respect to WCSim/develop. The key differences are in the WCSimEventAction constructor, where a new WCSimWCAddDarkNoise object is created for "tankPMT2".

This message is followed by additional reporting from WCSimDarkRateMessenger::SetNewValue() setting the defaults for this new object:

Setting DarkMode value 0 (this is a default set; it may be overwritten by user commands)
Setting DarkLow value 0 (this is a default set; it may be overwritten by user commands)
Setting DarkHigh value 100000 (this is a default set; it may be overwritten by user commands)
Setting DarkWindow value 5000 (this is a default set; it may be overwritten by user commands)
spradlin commented 2 years ago

Present in both but differing

Computed tolerance = {x} mm

In context within the stdout, this appears immediately following the message indicating the start of detector construction. For WCSim/develop:

**** Building Cylindrical Detector ****
Computed tolerance = 4.08e-07 mm

For main_into_hybrid:

**** Building Cylindrical Detector ****
16840.8, 180, 0, 0.1
Computed tolerance = 3.624e-07 mm
spradlin commented 2 years ago

Differences in stdout geometry

Two cylindrical detectors

The single-event stdout from both versions indicate that two cylindrical detectors are constructed. This is indicated by the presence to two instances of the message

**** Building Cylindrical Detector ****

which comes from the WCSimDetectorConstruction::ConstructCylinder() method (corresponding code in WCSim/develop.) Each of these appears to have differences in their construction.

First, try to determine where each of the calls to WCSimDetectorConstruction::ConstructCylinder() occurs and what each is constructing. From the stdout context, the first is constructed after the creation of the WCSimWCAddDarkNoise digitizers and before the configuration of the physics list. Tracing the calls that produce this message:

There is an invocation of /WCSim/Construct in the test macro. I suspect the other Construct command is invoked somehow in the construction of the WCSimDetectorConstruction object in main() and its construction of its WCSimDetectorMessenger . If this is the case, then the latter probably happens first while the SuperK default geometry is active. If this is the case, then the first set of geometry differences in the stdout should not affect the output, though they may indicate interesting differences in the geometry code.

This series of suppositions seems to be confirmed by comments that i received from @tdealtry. Tom also indicated that there are expected differences in the SuperK geometry in the two versions that were implemented in an ancestor of main_into_hybrid to fix a SuperK geometry overlap. The main_into_hybrid version of the SuperK geometry is expected to be better.

First cylindrical detector (SuperK)

Extra lists of numbers

Throughout the geometry section of the main_into_hybrid stdout, there are lines of comma-separated numbers that do not appear in the WCSim/develop stdout. These appear to be stuck in to debug aspects of the geometry, but their lack of annotation is really annoying and unhelpful.

Computed tolerance

As indicated in the previous comment, the value of the 'computed tolerance' is the first clear difference in the stdout of the first geometry block. It is reported in WCSimDetectorConstruction::ConstructCylinder() (corresponding WCSim/develop code) and is a value from a single Geant4 tolerance object:

G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()

This does not appear to be a parameter that is set in the WCSim code. According to this discussion, this represents something like the smallest distance between the surfaces of two geometry elements that is treated as a separation. Not sure why it is different. I would have guessed that it would be a function of the size of the world volume and the machine precision of the floats used to define the geometry. I would expect both of those quantities to be the same in the two versions of WCSim.

"Checking overlaps for volume WCBarrel ... OK!" in main_into_hybrid

This is the first overlap check reported in the main_into_hybrid stdout. I do not see anything about an overlap check for WCBarrel in the WCSim/develop.

The WCBarrel is the second volume created and placed in both versions: WCSim/develop, main_into_hybrid. It is a solid cylinder of water placed at the center of the first created volume, a solid cylinder of air (the world volume), with some hard-coded margins. WCSim/develop does not check for overlaps wtih the world volume when WCBarrel is placed. main_into_hybrid does if WCSim is compiled with some flag set to true. That is all there is to this difference.

It might be a good idea to check eventually the consistency of the arithmetic of the world volume dimensions for OD-having cylindrical detectors. Maybe postpone for the examination of the stdout of the HyperKOD construction.

"Checking overlaps for volume WCPMT ... OK!" in WCSim/develop

The next stdout difference in the first construction block is the presence of "Checking overlaps for volume WCPMT ... OK!" messages in the WCSim/develop stdout and their absence in the main_into_hybrid stdout. I see 42 instances of this message throughout the WCSim/develop SuperK construction stdout. There are none in the main_into_hybrid stdout. In the WCSim/develop stdout, these occur after the message "Checking overlaps for volume WCExtraTowerBlackSheet ... OK!", so let us find the placement of WCExtraTowerBlackSheet in both versions and go from there. After the WCExtraTowerBlackSheet placement there are some visualizer settings for it followed by a conditional construction and placement of a WCTopVeto volume. Then we get to the construction of WCPMT: location in WCSim/develop, location in main_into_hybrid. (This function could definitely benefit from some subdivision.)

The construction of the logical volume for a PMT is encapsulated in a separate function. The first placement of the WCPMT logical volume is, conditionally, in the WCTopVeto logical volume where it is placed without overlap checking in the WCSim/develop version and with compilation configured overlap checking in main_into_hybrid. Its next placement is within the WCBarrelCell logical volume, where WCSim/develop places it always with overlap checking and main_into_hybrid places it with compile-configured overlap checking which is off by default. This should account for 12 of the first 18 instances of the message (a cell should have 4 * 3 PMTs. The remaining 6 may come from the subsequent placements in the 'truncated' WCExtraTowerCell.

Like the placement of WCPMT within WCBarrelCell, its placement within WCExtraTowerCell always has overlap checking for WCSim/develop and has overlap checking conditioned on a compiled option in main_into_hybrid. Try to run some numbers to determine if there are 6 PMTs in this extra tower. The WCExtraTowerCell is a rectangular array of PMTs that is WCPMTperCellVertical PMTs high and (WCBarrelNumPMTHorizontal % WCPMTperCellHorizontal) wide. In WCSim/develop, this would be

3 high and (150 % 4) = 2 wide.

For main_into_hybrid it would be the same. So, yea, 6 additional messages for the WCExtraTowerCell.

New output from WCSimDetectorConstruction::ConstructPMT in main_into_hybrid

The main_into_hybrid stdout records some new printout from WCSimDetectorConstruction::ConstructPMT() that is missing from the WCSim/develop version of the method:

========================================================
Expose height for PMT SuperK-glassFaceWCPMT : 180 mm
Radius at expose height : 254 mm
Radius of curvature : 269.211 mm
Reflector radius : 254 mm
Reflector thickness : 0 mm
========================================================
Number of PMTs per Vessel, in ConstructPMT = 1

That is not precisely true. The main_into_hybrid version has two overloaded WCSimDetectorConstruction::ConstructPMT() methods:

  1. G4LogicalVolume* WCSimDetectorConstruction::ConstructPMT(G4String, G4String, G4String, G4int)
  2. G4LogicalVolume* WCSimDetectorConstruction::ConstructPMT(G4String, G4String, G4String, bool)

(their signatures differ in the type of the last argument). WCSim/develop has only one WCSimDetectorConstruction::ConstructPMT(), and its signature corresponds to the second of the main_into_hybrid methods (with the bool argument). In fact, the WCSim/develop version differs from the second main_into_hybrid version only by irrelevant white space.

Interesting. In main_into_hybrid, where is each instance called?

spradlin commented 2 years ago

Note to self: Check "tank" in WCSimDetectorConstruction::ConstructEggShapedHyperK() line 125

spradlin commented 2 years ago

Comparing versions of ConstructPMT

In a comment above, i noted that there are two versions of WCSimDetectorConstruction::ConstructPMT() in main_into_hybrid:

  1. G4LogicalVolume* WCSimDetectorConstruction::ConstructPMT(G4String, G4String, G4String, G4int)
  2. G4LogicalVolume* WCSimDetectorConstruction::ConstructPMT(G4String, G4String, G4String, bool)

The second is functionally identical to the single version in WCSim/develop. The first is more commonly used in the main_into_hybrid code.

Junk attribute code

Near the start of each method, there is a bit of code that creates a G4VisAttributes object:

  1. G4int version
  2. bool version

This code, as it currently exists, cannot accomplish anything useful. The pointers to the newly created G4VisAttributes objects are confined to the block scope of their conditional. They are lost at the end of the block, and the newly created objects become inaccessible. They are not passed to any object nor used as arguments to any function. This is just a memory leak.

Reflector/collector differences

May need to explore this in more detail. The bool version uses a separate classe, WCSimLC to construct reflectors/light collectors. The G4int version has a conditional construction of a reflector embedded within it.

Containing volume differences

The return value of both versions is the containing volume of the PMT unit. It can take different shapes depending on which version is used and what parameters are passed.

  1. G4int version
    • G4Polycone (solid of rotation of a polygon) for individual PMTs
    • G4Sphere (spherical shell segment) for multi PMTs,
    • (no support for constructing WLS plates)
  2. bool version

The material options for the containing volume are also different:

  1. G4int version
  2. bool version

Difference in placement of glass face (logicGlassFaceWCPMT)

The placement of the PMT glass face logical volume within the PMT has some differences, namely in the z-position within the containing volume (logicWCPMT). The code:

G4int z-pos

Backtrace the computation

bool z-pos

Backtrace the computation

spradlin commented 2 years ago

OD PMT definition

Scanning a little bit ahead in the single-event stdout, i see that the combined PMT QE curve is different. One of the component PMTs is different. This and the earlier observation about the OD PMT radius stored in the wcsimGeoT indicates that i need to check the OD PMT data in the two versions. \

The .mac file that i am running does explicitly set the PMT type

/WCSim/HyperKOD/PMTODRadius 3inch

So, the two runs should use the same named PMT definition. This macro command is interpreted by the WCSimDetectorMessenger (main_into_hybrid version). It is processed by WCSimDetectorConstruction::SetWCPMTODSize() (main_into_hybrid version), which in turn uses WCSimDetectorConstruction::CreatePMTObject() to select the PMT from the set of named PMT types (main_into_hybrid version). In each case, the configuration should be using the PMT3inch object type, so let us compare those.

Duplication of cases

The main_into_hybrid version of WCSimDetectorConstruction::CreatePMTObject() duplicates some cases. Probably a symptom of the complicated merge. Should be cleaned up, but the duplicates should just be junk code with no effect.

Differences in PMT3inch

The data for the PMT3inch objects in the two versions are different.

OK, so they are using different physical quantities for the tube definition. Let me replace the main_into_hybrid definition with the one in WCsim/develop and see what that does to the OD wcsimGeoT dump.

spradlin commented 2 years ago

wcsimGeoT after PMT3inch rectification

Changing the main_into_hybrid definition of PMT3inch to match that in WCSim/develop did change the dump of the OD PMTs from wcsimGeoT, but it did not bring that dump into agreement with that from WCSim/develop. The total number of PMTs in the OD remains unchanged, 11248 for main_into_hybrid compared to 11932 by WCSim/develop. It may be useful to look into this aspect a bit.

Multiple conventions for tubeID

In trying to compare the dump of wcsimGeoT and the main_into_hybrid output fie geofile_HyperKWithOD.txt, i ran across an inconsistency in the tubeID conventions used by each. Looking into that a bit more....

Relationship of wcsimGeoT and WCSimPmtInfo container tube IDs

The contents of wcsimGeoT are filled by WCSimRunAction::FillGeoTree() (WCSim/develop version). Most of the information related to individual PMTs is retrieved from the containers of WCSimPmtInfo objects

Much of the information is transferred directly to components wcsimGeoT. However, the tubeNo for OD PMTs (and only OD PMTs) are transformed by adding to them the number of PMTs in the inner detector primary array:

Creation of WCSimPmtInfo objects

The WCSimPmtInfo objects in the WCSimDetectorConstruction are constructed in WCSimDetectorConstruction::DumpGeometryTableToFile(), the method that writes out the geofile_<detector config>.txt files. It is the last thing called by WCSimDetectorConstruction::Construct(), the top-level detector construction method.

Primary inner detector

The WCSimPmtInfo objects for the primary inner detector (the elements of container WCSimDetectorConstruction::fpmts) are created in a loop over ordinals in the interval [1, WCSimDetectorConstruction:totalNumPMTs]. These ordinals are assigned to the loop variable tubeID, which is used as a key into the map WCSimDetectorConstruction::tubeIDMap. The corresponding WCSimPmtInfo::tube is assigned the value of this key/ordinal. There are additional maps to further identify PMTs within a multiPMT in the two inner detector arrays (but not the outer detector array). Will forego looking into that for the moment.

Secondary inner detector

The WCSimPmtInfo objects for the secondary inner detector (the elements of container WCSimDetectorConstruction::fpmts2) are created in a loop over ordinals in the interval [1, WCSimDetectorConstruction:totalNumPMTs2]. These ordinals are assigned to the loop variable tubeID, which is used as a key into the map WCSimDetectorConstruction::tubeIDMap2. The corresponding WCSimPmtInfo::tube is assigned the value of this key/ordinal.

Note that this means that the tube number or tube ID does not uniquely identify a PMT. The subdetector that contains it or some equivalent piece of information is also needed.

Outer detector

The WCSimPmtInfo objects for the outer detector (the elements of container WCSimDetectorConstruction::fODpmts) are created in a loop over ordinals in the interval [1, WCSimDetectorConstruction:totalNumODPMTs]. These ordinals are assigned to the loop variable tubeID, which is used as a key into the map WCSimDetectorConstruction::ODtubeIDMap. The corresponding WCSimPmtInfo::tube is assigned the value of this key/ordinal.

WCSimPmtInfo::cylocation

The definition of the values assigned to the WCSimPmtInfo::cylocation data members is contained entirely witihin WCSimDetectorConstruction::DumpGeometryTableToFile(), and it accompanies the code that creates the WCSimPmtInfo objects. The meaning of the value depends on the subdetector:

Comparisons of geofiles

From examining WCSimDetectorConstruction::DumpGeometryTableToFile() (main_into_hybrid version) and its use, i now know that geofile.txt produced by the WCSim/develop version should contain data from the construction of the HyperKWithOD geometry, just as the main_into_hybrid file geofile_HyperKWithOD.txt does. So, i can look at both and make some gross comparisons.

Ranges of tube IDs

From the cylocation values of the PMTs, we can determine the ranges of WCSimPmtInfo::tube numbers that correspond to each component.

WCSim/develop range tot main_into_hybrid range tot
0 Inner top [24193, 30592] 6400 [24193, 30592] 6400
1 Inner barrel [1, 24192], [30593, 32320] 25920 [1, 24192], [30593, 32320] 25920
2 Inner bot [32321, 38720] 6400 [32321, 38720] 6400
3 Outer bot evens [7022, 10852] 1916 evens [6554, 10240] 1844
4 Outer barrel [1, 7020], [10853, 11932] 8100 [1, 6552], [10241, 11248] 7560
5 Outer top odds [7021, 10851] 1916 odds [6553, 10239] 1844

Comparisons of wcsimGeoT

Physical dimensions

I modified the testgeo.C script to detemine the maximum and minimum of the cylindrical coordinates of the PMT placements for each cylocation. The dimensions are in cm:

WCSim/develop rho (min, max) z (min, max) main_into_hybrid rho (min, max) z (min, max)
0 Inner top (49.9824, 3188.32) (3298.92, 3298.92) (49.9824, 3188.32) (3298.92, 3298.92)
1 Inner barrel (3249.11, 3258.38) (-3217.91, 3217.91) (3249.11, 3258.38) (-3217.91, 3217.91)
2 Inner bot (49.9824, 3188.32) (-3298.92, -3298.92) (49.9824, 3188.32) (-3298.92, -3298.92)
3 Outer bot (92.2753, 3219.07) (-3348.93, -3348.93) (94.0846, 3211.3) (-3348.93, -3348.93)
4 Outer barrel (3300.93, 3309.01) (-3194.83, 3194.83) (3236.86, 3245.95) (-3155.71, 3155.71)
5 Outer top (92.2753, 3219.07) (3348.93, 3348.93) (94.0846, 3211.3) (3348.93, 3348.93)

Huh, it looks like the outer detector barrel PMTs are inside the inner detector barrel, rho_OD < rho_ID for main_into_hybrid. If this record is accurate, that's a problem. Let us try to track down how the OD radius is configured.

spradlin commented 2 years ago

OD construction

The parameter configuration methods for the HyperKWithODGeometry are identical in the two versions: WCSim/develop version; main_into_hybrid version. So, any differences in their construction must come from the implementation.

Conditional on WCSimDetectorConstruction::isODConstructed

The outer detector geometry construction appears to happen in conditional blocks of WCSimDetectorConstruction::ConstructCylinder() (WCSim/develop version) and WCSimDetectorConstruction::ConstructCaps() (WCSim/develop version). The execution of these conditional blocks is dependent on the bool WCSimDetectorConstruction::isODConstructed.

Edit: I previously stated that this block of code was junk. That was mistaken. I overlooked the role of the variable outerAnnulusRadius.

Clues from stdout

One of the conditional blocks includes some stdout of values related to the OD dimensions. Let us take a look at these for clues to which parameters are going wrong. From the single-event stdout for WCSim/develop compiled against Geant4.10.3.3:

AreaRingOD : 922.759 (m2)
AreaCellOD : 25.6322 (m2)
AreaPMTOD : 0.00477822 (m2)
--> NbPMTODCovered : 540.73
--> NbPMTODByCellFull : 15.0203
--> NbPMTODByCell : 15
--> SuggestedODCoverage : 0.0028
--> RealODCoverage : 0.00279622

From the single-event stdout for main_into_hybrid:

AreaRingOD : 887.297 (m2)
AreaCellOD : 24.6471 (m2)
AreaPMTOD : 0.00477822 (m2)
--> NbPMTODCovered : 519.949
--> NbPMTODByCellFull : 14.443
--> NbPMTODByCell : 14
--> SuggestedODCoverage : 0.0028
--> RealODCoverage : 0.00271411

Most of these quantities are computd specifically for this block of output, but the factors that go into them are either the parameters used in construction or directly related to those parameters. So, let's try backtracing the calculation of these things.

AreaCellOD

AreaCellOD = barrelODCellWidth * barrelODCellHeight;

WCSim/develop, main_into_hybrid.

barrelODCellWidth   = 2.*WCODRadius*tan(dPhi/2.);
barrelODCellHeight  = barrelCellHeight * (barrelODCellWidth/barrelCellWidth);

WCSim/develop, main_into_hybrid.

WCODRadius = outerAnnulusRadius - sphereRadius;

WCSim/develop, main_into_hybrid

sphereRadius = (WCPMTODExposeHeight * WCPMTODExposeHeight + WCPMTODRadius * WCPMTODRadius)/(2  *WCPMTODExposeHeight);

WCSim/develop, main_into_hybrid

Difference for outerAnnulusRadius: WCSim/develop:

outerAnnulusRadius =
        WCIDRadius + WCBlackSheetThickness + WCODDeadSpace + // ID Structure
        WCODTyvekSheetThickness + // Tyvek attached to structure
        sphereRadius;  // PMT height

main_into_hybrid

outerAnnulusRadius = WCIDRadius + WCBlackSheetThickness + 1.*mm;

Note that the WCSim/develop code does exist in main_into_hybrid, but it immedieatly overridden by the quoted line. Similarly, the main_into_hybrid line does exist in WCSim/develop, but it is executed first and is then conditionally overridden by quoted code.

So, let's swap the order of execution in main_into_hybrid and see how that affects the rest.

spradlin commented 2 years ago

After rectification of outerAnnulusRadius

After the update indicated in my previous comment, i ran another single-event run.

stdout clip

The clip from the main_into_hybrid single-event stdout that i was looking at in my previous comment is now identical to that from WCSim/develop:

AreaRingOD : 922.759 (m2)
AreaCellOD : 25.6322 (m2)
AreaPMTOD : 0.00477822 (m2)
--> NbPMTODCovered : 540.73
--> NbPMTODByCellFull : 15.0203
--> NbPMTODByCell : 15
--> SuggestedODCoverage : 0.0028
--> RealODCoverage : 0.00279622

Comparison of wcsimGeoT

After the change, the physical dimension comparison in a previous comment from information in the wcsimGeoT agrees better...

WCSim/develop rho (min, max) z (min, max) main_into_hybrid rho (min, max) z (min, max)
0 Inner top (49.9824, 3188.32) (3298.92, 3298.92) (49.9824, 3188.32) (3298.92, 3298.92)
1 Inner barrel (3249.11, 3258.38) (-3217.91, 3217.91) (3249.11, 3258.38) (-3217.91, 3217.91)
2 Inner bot (49.9824, 3188.32) (-3298.92, -3298.92) (49.9824, 3188.32) (-3298.92, -3298.92)
3 Outer bot (92.2753, 3219.07) (-3348.93, -3348.93) (92.2753, 3219.07) (-3348.93, -3348.93)
4 Outer barrel (3300.93, 3309.01) (-3194.83, 3194.83) (3300.93, 3309.01) (-3194.83, 3194.83)
5 Outer top (92.2753, 3219.07) (3348.93, 3348.93) (92.2753, 3219.07) (3348.93, 3348.93)

Comparison of OD part of geofile

The inner detector parts of the geofiles are hard to directly compare because the main_into_hybrdi version has some additional fields for multiPMTs. However, the OD parts should have an identicatl format and should be easily comparable with diff.

After the rectification of outerAnnulusRadius, the OD parts of the main_into_hybrid geofile_HyperKWithOD.txt is identical to the corresponding part of WCSim/develop geofile.txt. Identical. Exactly the same number of PMTs and exactly the same placement.

Great. It is time to run 500 events and look at hit distributions.

spradlin commented 2 years ago

Contents of wcsimT updated

Updating the plots in my previous comment after rectifying both the PMT3inch data and the outerAnnulusRadius.

The Root macro read_OD.C reads the contents of the wcsimT TTree and produces some histograms and a TTree of per-event counters. Attached are plots of the contents of the TTree counters. The source of the distribution is indicated by the suffix in the corresponding stat box:

The effect of the change in Geant4 version on the WCSim/develop counters (_int vs. _old) is not very large.

The main_into_hybrid results are now close to being statistically consistent for the inner detector. For the outer detector, they are not statistically compatible, but they are no longer clearly pathological.

Inner detector counters

rawHitsID

digiHitsID

numPMTsHitID

numPMTsDigiHitID

Outer detector counters

rawHitsOD

digiHitsOD

numPMTsHitOD

numPMTsDigiHitOD

spradlin commented 2 years ago

No differences in ConstructPMTAndWLSPlate

Because there are still statistical discrepancies in the OD, continue to look into the OD construction and processing. In discussing the plots in the previous comment with Paul Soler, we hypothesized that the discrepancies might be due to the wavelength shifting (WLS) plates. I previously checked that the dimensions and steering variables are the same in the two versions.. This includes the WLS plate dimensions.

The WLS plates are constructed by WCSimDetectorConstruction::ConstructPMTAndWLSPlate(): WCSim/develop version, main_into_hybrid. The code of the two versions differ only in minor ways that do not affect the function.

spradlin commented 2 years ago

OD tube identifiers

Histogram the PMT tube IDs recorded for the outer detector hits to see if something stands out: odTubeID

Nothing seems to stande out. The increased number of hits appears to be spread across all of the PMTs.

spradlin commented 2 years ago

Additional G4LogicalSkinSurfaces in main_into_hybrid

The only remaining obvious differences in WCSimDetectorConstruction::ConstructCylinder() are the construction of the G4LogicalSkinSurfaces BSBarrelCellSkinSurface and BSTowerCellSkinSurface in main_into_hybrid that are not present in WCSim/develop.

I removed these constructions from a local version of main_into_hybrid and ran 500 events. The removal of these G4LogicalSkinSurfaces does not reconcile the remaining differences with WCSim/develop. The plots below show the results compared to WCSim/develop. As in the previous sets of plots, the source of the distribution is indicated by the suffix in the corresponding stat box:

spradlin commented 2 years ago

Ruling things out

I am currently trying to rule out certain sets of differences by copying WCSim/develop versions of algorithms and methods into a copy of main_into_hybrid, replacing the use of the main_into_hybrid version.

PMT3inch definition

For a while now, i have been using the WCSim/version of the definition of PMT3inch. The remaining discrepancies are not due to that.

src/WCSimConstructCylinder.cc

My recent examinations indicate that the remaining differences in src/WCSimConstructCylinder.cc have no significant effect on the output for the test condition. However, to completely rule out the code in src/WCSimConstructCylinder.cc as culprits, i copied the WCSim/develop version of the file into main_into_hybrid_hacking and hacked the geometry construction to use the WCSim/develop versions when constructing HyperKWithOD. Below is one of the usual OD comparison plots for hit occupancies. Remaining differences in src/WCSimConstructCylinder.cc are not the culprit. rawHitsOD

I was also concerned about the potential effects of unitialized or wrongly initialized data members of WCSimDetectorConstruction that were added in the main_into_hybrid version. Because the WCSim/develop version of src/WCSimConstructCylinder.cc does not use any of these data members, those data members that are exclusively used in are also ruled out.

spradlin commented 2 years ago

Ruling out: StackingAction application of QE

Although the test case uses the SensitiveDetector_Only method for applying the quantum efficiency check, previous examinations indicate that there are special cases in WCSimStackingAction::ClassifyNewTrack() that ignore the method flag. These special cases for photons produced either as primary particles and photons produced by G4 optical physics. (Cherenkov photons are produced by G4 EM physics and should not trigger these special cases). These special cases are preserved in main_into_hybrid, but the fOptical special case for primary photons differs.

None of this should affect the test case that i am running, but it is easy enough to just replace main_into_hybrid version of WCSimStackingAction::ClassifyNewTrack() with that from WCSim/develop. Below is one of the usual OD comparison plots for hit occupancies. Differences in WCSimStackingAction::ClassifyNewTrack() are ruled out as the culprit. rawHitsOD

spradlin commented 2 years ago

Hmm, things still to check include

spradlin commented 2 years ago

Attempt to simultaneously rule out remaining geometry, SD QE, and materials

In hope that i could be a little more efficient in the search for the remaining discrepancies, i simultaneously changed

to rectify differences with their counterparts in the WCSim/develop branch. For WCSimDetectorConstruction::Construct() and WCSimDetectorConstruction::ConstructMaterials(), i replaced their code with the corresponding WCSim/develop code with minor fixes to address compilation and runtime errors (ref WCSim/develop WCSimDetectorConstruction::Construct(), `WCSimDetectorConstruction::ConstructMaterials()). For WCSimWCSD::ProcessHits(), made spot modifications rather than wholesale replacement.

These changes were all on top of the previous hacks described in previous comments

Below is one of the usual OD comparison plots for hit occupancies of the result. One or more of these three changes largely resolves the difference in the OD hit occupancy. rawHitsOD

Main cuprit in materials

I undid the changes described above in the order in which they were described. After undoing the changes to WCSimDetectorConstruction::Construct() and WCSimWCSD::ProcessHits(), the hit occupancies still appear to agree. Below is one of the usual OD comparison plots for hit occupancies of the result. This configuration is recorded in my main_into_hybrid_hacking branch. The primary remaining differences are in the material construction. rawHitsOD

spradlin commented 2 years ago

Glass refractive index

The main_into_hybrid version of WCSimDetectorConstruction::ConstructMaterials() has many differences with respect to the WCSim/develop version. Many of these differences introduce new materials that are used in the multiPMT construction and support structure construction that were added in the nuPrism branch. One of the changes to a material that is common to both branch is the change to the photon-energy-dependent refractive index of the glass used in the construction of the PMT face:

The WCSim/develop version is a simple uniform refractive index of 1.600. The main_into_hybrid version appears to be intended to be more accurate. It includes a citation to a source. This is probably a clear improvement in the main_into_hybrid version.

However, it also appears to be the main source of the residual differences. I created a new personal branch main_into_hybrid_simpleglassref, which forks off of my main_into_hybrid rather than the hacking branch that i was using previously. In this branch, i reverted the PMT glass refractive index to the simplified constant used in WCSim/develop and ran the test case. Below is one of the usual OD comparison plots for hit occupancies of the result. rawHitsOD

spradlin commented 1 year ago

OK, let's make sure that my conclusions are reproducible. Rerun the various code configurations from clean installations.

Todo:

  1. Document results of attempts to reproduce,
  2. Run a known configuration with a different random seed to check utility of K-S test.
spradlin commented 1 year ago

Comparison statistics

I wanted to be more quantitative in my comparison of the hit distributions. So, i began computing Kolmogorov test statistic for the unbinned distributions. I am using the Root TMath::KolmogorovTest() implementation of the test. To prepare the values for the test, i

  1. Transfer the individual sample values from their TTree to std::vectors, and
  2. Sort the std::vectorss

Then i pass the std::vectors for the two distributions that i want to compare in to the Root TMath::KolmogorovTest() calculator. The return value of the calculator is a p-value representing the probability that the two samples were drawn from the same underlying probability density.

Same conditions with different random seeds

In order to test the machinery and check that the p-values from the KS test make sense, i ran my develop branch with two different random seeds. This should produce statistically independent samples drawn from the same underlying probability density, and the KS test p-values should reflect consistency. The results of doing this is shown in the following plots. I have included the p-values as the quantity labeled $p_{\text{KS}}(\text{dev})$. Note that the top stat box (black, _dev) shows the comparison for the first distribution with itself, and it should always have a value of 1.

The p-values are in the range 15%-96%, and all are consistent with the distributions sharing an underlying probability density.

rawHitsID digiHitsID numPMTsHitID numPMTsDigiHitID rawHitsOD digiHitsOD numPMTsHitOD numPMTsDigiHitOD

spradlin commented 1 year ago

Reproduction/Recapitulation

In addition to the miscalculation of OD radius, i found the following differences between the develop version and the main_into_hybrid version that seemed to be significant:

  1. The PMT3inch definition, including its quantum efficiency curve and physical dimensions, and
  2. The refractive index of PMT glass in the material definition.

In previous tests, rectifying these two differences appeared bring develop and main_into_hybrid largely into agreement. I have had trouble reproducing this, and it seems i was a little sloppy in tracking the various code iterations. Here, i carefully reproduce 4 versions of main_into_hybrid, each of which is based on the version with the corrected OD radius calculation,

For each of these 4 main_into_hybrid versions, i compute the Kolmogorov p-value with respect to a control sample produced by the develop branch.

Inner detector plots

rawHitsID digiHitsID numPMTsHitID numPMTsDigiHitID

The Kolmogorov p-values show that there are statistically significant differences in the inner detector, even though the graphs of the distributions look good. Interesting.

Outer detector plots

rawHitsOD digiHitsOD numPMTsHitOD numPMTsDigiHitOD

Reevaluation of conclusions

So the OD plots tell an interesting story.

As i feared, i was too sloppy in my previous work in noting when i did and did not have the PMT3inch definition rectified. All of these distributions are qualitatively consistent with previous ones up to the ambiguity of the PMT3inch definition where it is not explicitly noted.

It is very surprising that fixing the PMT3inch definition increases the divergence. Something is happening that i have not found and that is very interesting.

spradlin commented 1 year ago

Individual PMT properties

Upon presenting some of the observations in the previous comment to colleagues, a few have asked which of the PMT properties is responsible for the differences in the mih_RI and mih_RI_PMT3. As noted in an earlier comment, the differences of the PMT3inch definitions include

WCSim/develop tdealtry/main_into_hybrid
Source ETEL 9302B TBD
Radius 39 mm 40 mm
Expose height 29 mm 20 mm
Glass thickness 4.0 mm 1.0 mm
Default dark rate 400 Hz 4.2 kHz
Quantum efficiency Different curves
Max Q.E. 0.30 0.211

So, i made some runs to check the effects of each of the parameters individually. In the plot below, the curves

rawHitsOD

No single property is responsible for the full effect. The quantum efficiency appears to have the greatest effect, while the radius, interestingly, has the least effect.