Skip to content

Commit

Permalink
RingCounting ToolChain example (#263)
Browse files Browse the repository at this point in the history
* Expanded RingCounting functionality

- Add RC data flow from boost stores, not requiring a pre-computed CNNImage file anymore
- Add "load_from_file" config parameter. Config setting: 0/1
- Add Execute() method in Tool class
- Add get_next_event() method in Tool class
- Change functionality of other methods to support both "load_from_file" settings
- The Tool expects a CNNImage formatted input (std::vector<double>) called "CNNImageCharge" within the "RecoEvent" boost store when not using the input from file
- The predictions are stored in the "RecoEvent" boost store as "RingCountingSRPrediction" and "RingCountingMRPrediction"

Ringcounting/README.md:
- Specify where the predictions are stored (RecoEvent)
- Complete list of config parameters

* RingCounting Tool:
- README.md updated to reflect recent changes more accurately. Hopefully makes things a bit clearer.

* RingCounting Tool:
- README.md updated to reflect recent changes more accurately. Hopefully makes things a bit clearer.

RingCounting ToolChain:
- Added exemplary configuration with CNNImage and previous data loading

---------
  • Loading branch information
s4294967296 authored Jul 22, 2024
1 parent 29b2d49 commit c9d6b99
Show file tree
Hide file tree
Showing 23 changed files with 361 additions and 27 deletions.
33 changes: 26 additions & 7 deletions UserTools/RingCounting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,51 @@ For this a CNN-based machine learning approach is used.
This Tool uses PMT data in the CNNImage format (see UserTools/CNNImage). For further details on the tool and
the models used (including performance etc.) see the documentation found on the anniegpvm-machines at (**Todo**)
```
/pnfs/annie/persistent/users/dschmid/RingCountingStore/documentation/
```
/pnfs/annie/persistent/reconstruction/RingCounting/RingCountingStore/documentation/
```

---

All models can be found at
```
/pnfs/annie/persistent/users/dschmid/RingCountingStore/models/
/pnfs/annie/persistent/reconstruction/RingCounting/RingCountingStore/models/
```

## Data

- In the "load_from_file" mode, this tool adds single- and multi-ring (SR/MR) predictions to the RecoEvent BoostStore. When theh "load_from_file" config parameter is set to 0, the tool instead outputs the predictions to a csv file.
- The predictions are stored in the "RingCountingSRPrediction" and "RingCountingMRPrediction" variables

The predictions are given as probabilities in the interval [0,1] as doubles, and sum to 1 for both classes.

Implemented as:
```
reco_event_bs = self.m_data.Stores.at("RecoEvent")
reco_event_bs.Set("RingCountingSRPrediction", predicted_sr)
reco_event_bs.Set("RingCountingMRPrediction", predicted_mr)
```

---
## Configuration

The following configuration variables must be set for the tool to function properly (further details)
are found at the top of the RingCounting.py file.
The following configuration variables must be set for the tool to function properly.

---
Exemplary configuration:
```
PythonScript RingCounting
InitialiseFunction Initialise
ExecuteFunction Execute
FinaliseFunction Finalise
verbose 1
load_from_file 0 # If set to 1, load CNNImage formatted csv files
files_to_load configfiles/RingCounting/files_to_load.txt # txt file containing files to load in case load_from_file == 1
version 1_0_0 # Model version
model_path /annie/app/users/dschmid/RingCountingStore/models/ # Model path
pmt_mask november_22 # PMT mask (zeroed out)
save_to RC_output.csv # if load_from_file == 1, save predictions as csv
pmt_mask november_22 # Masked PMTs (name of hard-coded set of PMTs to ignore)
save_to RC_output.csv # Prediction output file, used if load_from_file == 1
```
15 changes: 15 additions & 0 deletions configfiles/RingCounting/CNNImageConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CNNImage config file

verbosity 1
DataMode Normal #options: Normal / Charge-Weighted / TimeEvolution
SaveMode Static #options: Static / Geometric / PMT-wise
DimensionX 16 #choose something suitable (32/64/...)
DimensionY 10 #choose something suitable (32/64/...)
OutputFile cnnimage_electron_la_sE_1_94
MCStaticMapping configfiles/CNNImage/mc_cnnimage_mapping.csv
DataStaticMapping configfiles/CNNImage/data_cnnimage_mapping.csv
DimensionLAPPD 5 #Size of the LAPPD pannal
IncludeTopBottom 1
DetectorConf ANNIEp2v7 #specify the detector version used in simulation
useLAPPDs 0
WriteToFile 0
132 changes: 132 additions & 0 deletions configfiles/RingCounting/Chankey_WCSimID_v7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
332 1
333 2
334 3
335 4
336 5
337 6
338 7
339 8
340 9
341 10
342 11
343 12
344 13
345 14
346 15
347 16
348 17
349 18
350 19
351 20
352 21
353 22
354 23
355 24
356 25
357 26
358 27
359 28
360 29
361 30
362 31
363 32
364 33
365 34
366 35
367 36
368 37
369 38
370 39
371 40
372 41
373 42
374 43
375 44
376 45
377 46
378 47
379 48
380 49
381 50
382 51
383 52
384 53
385 54
386 55
387 56
388 57
389 58
390 59
391 60
392 61
393 62
394 63
395 64
396 65
397 66
398 67
399 68
400 69
401 70
402 71
403 72
404 73
405 74
406 75
407 76
408 77
409 78
410 79
411 80
412 81
413 82
414 83
415 84
416 85
417 86
418 87
419 88
420 89
421 90
422 91
423 92
424 93
425 94
426 95
427 96
428 97
429 98
430 99
431 100
432 101
433 102
434 103
435 104
436 105
437 106
438 107
439 108
440 109
441 110
442 111
443 112
444 113
445 114
446 115
447 116
448 117
449 118
450 119
451 120
452 121
453 122
454 123
455 124
456 125
457 126
458 127
459 128
460 129
461 130
462 131
463 132
3 changes: 3 additions & 0 deletions configfiles/RingCounting/ClusterClassifiersConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ClusterClassifiers Config file
verbosity 0
IsData 0
12 changes: 12 additions & 0 deletions configfiles/RingCounting/ClusterFinderConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ClusterFinder Config File

verbosity 0
HitStore MCHits #Either MCHits or Hits (accessed in ANNIEEvent store)
OutputFile BCAMC_CLUSTERFINDER_ibd_SE_0_0-99 #Output root prefix name for the current run
ClusterFindingWindow 100 # in ns, size of the window used to "clusterize"
AcqTimeWindow 70000 # in ns, size of the acquisition window
ClusterIntegrationWindow 100 # in ns, all hits with +/- 1/2 of this window are considered in the cluster
MinHitsPerCluster 5 # group of hits are considered clusters above this amount of hits
end_of_window_time_cut 0.95 # from o to 1, length of the window you want to loop over with respect to acq. window (1 for full window, 0.95 for 95% from the start)
Plots2D 0 #Draw 2D charge-vs-time plots?
ChankeyToPMTIDMap ./configfiles/EventDisplay/Data-RecoEvent/Chankey_WCSimID.dat
11 changes: 11 additions & 0 deletions configfiles/RingCounting/DeadPMTIDs_p2v7.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
2
6
11
14
15
18
21
85
100
113
114
11 changes: 11 additions & 0 deletions configfiles/RingCounting/DigitBuilderConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# DigitBuilder config file

verbosity 0
ParametricModel 1
#Reading in MC files
IsMC 1
# There are three configurations: "PMT_only", "LAPPD_only", "All"
PhotoDetectorConfiguration PMT_only
#File must be in /pnfs/ space when loading on Fermilab cluster
LAPPDIDFile ./configfiles/VertexReco/PhaseIIRecoTruth/LAPPDIDs.txt
DigitChargeThr 0
11 changes: 11 additions & 0 deletions configfiles/RingCounting/EnergyExtractorConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
OutputFile cnnimage_energy_output_test
Verbosity 0
SaveNeutrino 1
SaveElectron 1
SaveGamma 0
SaveMuon 1
SavePion 1
SaveKaon 1
SaveNeutron 1
SaveVisible 1

26 changes: 26 additions & 0 deletions configfiles/RingCounting/EventSelectorConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# EventSelector config file

verbosity 0
MCPMTVolCut 0
MCFVCut 0
MCMRDCut 0
MCPiKCut 0
MCIsMuonCut 0
MCIsElectronCut 0
MCIsSingleRingCut 0
MCIsMultiRingCut 0
MCProjectedMRDHit 0
MCEnergyCut 0
Emin 0 #Minimum energy in MeV
Emax 500 #Maximum energy in MeV
MRDRecoCut 0
RecoPMTVolCut 0
RecoFVCut 0
NHitCut 0
NHitmin 4 #Minimum number of hit digits
PMTMRDCoincCut 0
PMTMRDOffset 0
PromptTrigOnly 0
TriggerWord -1
SaveStatusToStore 1
IsMC 1 #MC or Data?
12 changes: 12 additions & 0 deletions configfiles/RingCounting/FindMrdTracksConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# FindMrdTracks Config File
# all variables retrieved with m_variables.Get() must be defined here!

verbosity 0
IsData 0
OutputDirectory .
OutputFile STEC_MRDTracks_cluster40ns
DrawTruthTracks 0 # whether to add MC Truth track info for drawing in MrdPaddlePlot Tool
## note you need to run that tool to actually view the tracks!
WriteTracksToFile 0 # should the track information be written to a ROOT-file?
SelectTriggerType 0 #should the loaded data be filtered by trigger type?
TriggerType Beam #options: Cosmic, Beam, No Loopback
3 changes: 3 additions & 0 deletions configfiles/RingCounting/LoadANNIEEventConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
verbose 0
FileForListOfInputs ./configfiles/BeamClusterAnalysisMC/my_inputs.txt
EventOffset 0
12 changes: 12 additions & 0 deletions configfiles/RingCounting/LoadGenieEventConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
verbosity 0
FluxVersion 1 # use 0 to load genie files based on bnb_annie_0000.root etc files
# use 1 to load files based on beammc_annie_0000.root etc files
#FileDir NA # specify "NA" for newer files: full path is saved in WCSim
FileDir /pnfs/annie/persistent/simulations/genie3/G1810a0211a/standard/tank
#FileDir /pnfs/annie/persistent/users/moflaher/genie/BNB_World_10k_11-03-18_gsimpleflux
#FilePattern gntp.*.ghep.root
FilePattern LoadWCSimTool ## use this pattern to load corresponding genie info with the LoadWCSimTool
## N.B: FileDir must still be specified for now! (WCSim files do not record their directory)
ManualFileMatching 0
FileEvents 1000
EventOffset 0
8 changes: 8 additions & 0 deletions configfiles/RingCounting/LoadGeometryConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
verbosity 0
LAPPDChannelCount 60
FACCMRDGeoFile ./configfiles/LoadGeometry/FullMRDGeometry.csv
DetectorGeoFile ./configfiles/LoadGeometry/DetectorGeometrySpecs.csv
LAPPDGeoFile ./configfiles/LoadGeometry/LAPPDGeometry.csv
TankPMTGeoFile ./configfiles/LoadGeometry/FullTankPMTGeometry.csv
TankPMTGainFile ./configfiles/LoadGeometry/ChannelSPEGains2023.csv
AuxiliaryChannelFile ./configfiles/LoadGeometry/AuxChannels.csv
13 changes: 13 additions & 0 deletions configfiles/RingCounting/LoadWCSimConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
verbose 0

InputFile /pnfs/annie/persistent/simulations/wcsim/G1810a0211a/standard/tank/pmt/wcsim_0.19.19.root

WCSimVersion 3 ## should reflect the WCSim version of the files being loaded
HistoricTriggeroffset 0 ## time offset of digits relative to the trigger
UseDigitSmearedTime 1 ## whether to use smeared digit time (T), or true time of first photon (F)
LappdNumStrips 60 ## num channels to construct from each LAPPD
LappdStripLength 100 ## relative x position of each LAPPD strip, for dual-sided readout [mm]
LappdStripSeparation 10 ## stripline separation, for calculating relative y position of each LAPPD strip [mm]
PMTMask configfiles/BeamClusterAnalysisMC/DeadPMTIDs_p2v7.txt ## Which PMTs should be masked out? / are dead?
ChankeyToPMTIDMap ./configfiles/BeamClusterAnalysisMC/Chankey_WCSimID_v7.txt
SplitSubTriggers 0 # should subtriggers be loaded in separate Execute steps?
17 changes: 17 additions & 0 deletions configfiles/RingCounting/LoadWCSimLAPPDConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#LoadWCSimLAPPD Config File
# all variables retrieved with m_variables.Get() must be defined here!
verbose 0

#InputFile /pnfs/annie/persistent/users/moflaher/wcsim/multipmt/tankonly/wcsim_25_04_19_ANNIEp2v6_nodigit_BNB_Water_10k_22-05-17/wcsim_lappd_0.1.9.root
#InputFile /annie/app/users/mnieslon/WCSim_build/wcsim_ambe_port5_z0_lappd_0.root
#InputFile /pnfs/annie/persistent/users/mnieslon/wcsim/output/tankonly/wcsim_ANNIEp2v7_beam/lappd-files/LAPPD_wcsim_beam_gst_1046_38_0.5438.root
#InputFile /pnfs/annie/persistent/users/mnieslon/wcsim/output/tankonly/wcsim_ANNIEp2v7_beam/lappd-files/LAPPD_wcsim_beam_gst_1079_9_0.9009.root
#InputFile /annie/app/users/mnieslon/WCSim_build/wcsim_michel_1000_lappd_0.root
#/pnfs/annie/persistent/users/mnieslon/wcsim/output/tankonly/wcsim_ANNIEp2v7_throughgoing/wcsim_throughgoing_muon_R2614_lappd_0.0.root
#InputFile /pnfs/annie/scratch/users/dschmid/output/mcc_mu_10/WCSim_10_1_lappd_0.root

InputFile /pnfs/annie/persistent/simulations/wcsim/wcsim_ANNIEp2v7_beam/lappd-files/LAPPD_wcsim_beam_gst_1046_50_0.5450.root

WCSimVersion 3 ## should reflect the WCSim version of the files being loaded
InnerStructureRadius 1.3545 ## octagonal inner structure radius in m (from drawings 106.64")
DrawDebugGraphs 0 ## whether to draw TPolyMarker3D's of hits
4 changes: 4 additions & 0 deletions configfiles/RingCounting/MCParticlePropertiesConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# MCParticleProperties configuration file

verbosity 0
hasGENIE true
11 changes: 11 additions & 0 deletions configfiles/RingCounting/MCRecoEventLoaderConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# MCRecoEventLoader config file

verbosity 0
GetPionKaonInfo 1
GetNRings 1
ParticleID -13
DoParticleSelection 0
xshift 0.0
yshift 14.46469
zshift -168.1
IsMC 1
File renamed without changes.
Loading

0 comments on commit c9d6b99

Please sign in to comment.