From 29b2d492808282fabe9d951e99f25c500878256c Mon Sep 17 00:00:00 2001 From: marc1uk Date: Mon, 22 Jul 2024 15:33:03 +0100 Subject: [PATCH 1/3] Adding boost to root include path This eliminates the following error when attempting to run on the grid Error in cling::AutoLoadingVisitor::InsertIntoAutoLoadingState: Missing FileEntry for boost/serialization/version.hpp requested to autoload type boost::serialization::version isolated change from PR #265 --- Setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Setup.sh b/Setup.sh index 4efb35561..42bbeacac 100644 --- a/Setup.sh +++ b/Setup.sh @@ -12,7 +12,7 @@ export CLHEP_DIR=${ToolDAQapp}/ToolDAQ/2.4.0.2/CLHEP_install export LD_LIBRARY_PATH=`pwd`/lib:${ToolDAQapp}/lib:${ToolDAQapp}/ToolDAQ/zeromq-4.0.7/lib:${ToolDAQapp}/ToolDAQ/boost_1_66_0/install/lib:${ToolDAQapp}/ToolDAQ/root/lib:${ToolDAQapp}/ToolDAQ/WCSimLib/:${ToolDAQapp}/ToolDAQ/MrdTrackLib/src:${ToolDAQapp}/ToolDAQ/RATEventLib/lib/:${ToolDAQapp}/UserTools/PlotWaveforms:${ToolDAQapp}/ToolDAQ/log4cpp/lib:${ToolDAQapp}/ToolDAQ/Pythia6Support/v6_424/lib:${CLHEP_DIR}/lib:${ToolDAQapp}/ToolDAQ/LHAPDF-6.3.0/install/lib:${ToolDAQapp}/ToolDAQ/GENIE-v3-master/lib:${ToolDAQapp}/ToolDAQ/Reweight-3_00_04_ub3/lib:$LD_LIBRARY_PATH -export ROOT_INCLUDE_PATH=${ToolDAQapp}/ToolDAQ/WCSimLib/include/:${ToolDAQapp}/ToolDAQ/MrdTrackLib/include:${ToolDAQapp}/ToolDAQ/RATEventLib/include/:${ToolDAQapp}/UserTools/PlotWaveforms:$ROOT_INCLUDE_PATH +export ROOT_INCLUDE_PATH=${ToolDAQapp}/ToolDAQ/boost_1_66_0/install/include:${ToolDAQapp}/ToolDAQ/WCSimLib/include/:${ToolDAQapp}/ToolDAQ/MrdTrackLib/include:${ToolDAQapp}/ToolDAQ/RATEventLib/include/:${ToolDAQapp}/UserTools/PlotWaveforms:$ROOT_INCLUDE_PATH export PYTHIA6_DIR=${ToolDAQapp}/ToolDAQ/Pythia6Support/v6_424/ export LHAPATH=${ToolDAQapp}/ToolDAQ/LHAPDF-6.3.0/install/share/LHAPDF/ From c9d6b992982f397ffec94ce1a7f1713178c43a80 Mon Sep 17 00:00:00 2001 From: Daniel Tobias Schmid <82974642+s4294967296@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:54:14 +0200 Subject: [PATCH 2/3] RingCounting ToolChain example (#263) * 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) 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 --------- --- UserTools/RingCounting/README.md | 33 ++++- configfiles/RingCounting/CNNImageConfig | 15 ++ .../RingCounting/Chankey_WCSimID_v7.txt | 132 ++++++++++++++++++ .../RingCounting/ClusterClassifiersConfig | 3 + configfiles/RingCounting/ClusterFinderConfig | 12 ++ configfiles/RingCounting/DeadPMTIDs_p2v7.txt | 11 ++ configfiles/RingCounting/DigitBuilderConfig | 11 ++ .../RingCounting/EnergyExtractorConfig | 11 ++ configfiles/RingCounting/EventSelectorConfig | 26 ++++ configfiles/RingCounting/FindMrdTracksConfig | 12 ++ configfiles/RingCounting/LoadANNIEEventConfig | 3 + configfiles/RingCounting/LoadGenieEventConfig | 12 ++ configfiles/RingCounting/LoadGeometryConfig | 8 ++ configfiles/RingCounting/LoadWCSimConfig | 13 ++ configfiles/RingCounting/LoadWCSimLAPPDConfig | 17 +++ .../RingCounting/MCParticlePropertiesConfig | 4 + .../RingCounting/MCRecoEventLoaderConfig | 11 ++ ...files_to_load.txt => RC_files_to_load.txt} | 0 configfiles/RingCounting/README.md | 23 +-- configfiles/RingCounting/RingCountingConfig | 5 +- configfiles/RingCounting/TimeClusteringConfig | 13 ++ configfiles/RingCounting/ToolsConfig | 13 ++ configfiles/RingCounting/my_inputs.txt | 0 23 files changed, 361 insertions(+), 27 deletions(-) create mode 100644 configfiles/RingCounting/CNNImageConfig create mode 100644 configfiles/RingCounting/Chankey_WCSimID_v7.txt create mode 100644 configfiles/RingCounting/ClusterClassifiersConfig create mode 100644 configfiles/RingCounting/ClusterFinderConfig create mode 100644 configfiles/RingCounting/DeadPMTIDs_p2v7.txt create mode 100644 configfiles/RingCounting/DigitBuilderConfig create mode 100644 configfiles/RingCounting/EnergyExtractorConfig create mode 100644 configfiles/RingCounting/EventSelectorConfig create mode 100644 configfiles/RingCounting/FindMrdTracksConfig create mode 100644 configfiles/RingCounting/LoadANNIEEventConfig create mode 100644 configfiles/RingCounting/LoadGenieEventConfig create mode 100644 configfiles/RingCounting/LoadGeometryConfig create mode 100644 configfiles/RingCounting/LoadWCSimConfig create mode 100644 configfiles/RingCounting/LoadWCSimLAPPDConfig create mode 100644 configfiles/RingCounting/MCParticlePropertiesConfig create mode 100644 configfiles/RingCounting/MCRecoEventLoaderConfig rename configfiles/RingCounting/{files_to_load.txt => RC_files_to_load.txt} (100%) create mode 100644 configfiles/RingCounting/TimeClusteringConfig create mode 100644 configfiles/RingCounting/my_inputs.txt diff --git a/UserTools/RingCounting/README.md b/UserTools/RingCounting/README.md index 73b973348..8a2377936 100644 --- a/UserTools/RingCounting/README.md +++ b/UserTools/RingCounting/README.md @@ -6,13 +6,14 @@ 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 @@ -20,18 +21,36 @@ All models can be found at - 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 ``` diff --git a/configfiles/RingCounting/CNNImageConfig b/configfiles/RingCounting/CNNImageConfig new file mode 100644 index 000000000..e6e997fa5 --- /dev/null +++ b/configfiles/RingCounting/CNNImageConfig @@ -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 diff --git a/configfiles/RingCounting/Chankey_WCSimID_v7.txt b/configfiles/RingCounting/Chankey_WCSimID_v7.txt new file mode 100644 index 000000000..62473bdf0 --- /dev/null +++ b/configfiles/RingCounting/Chankey_WCSimID_v7.txt @@ -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 diff --git a/configfiles/RingCounting/ClusterClassifiersConfig b/configfiles/RingCounting/ClusterClassifiersConfig new file mode 100644 index 000000000..948ed3354 --- /dev/null +++ b/configfiles/RingCounting/ClusterClassifiersConfig @@ -0,0 +1,3 @@ +#ClusterClassifiers Config file +verbosity 0 +IsData 0 diff --git a/configfiles/RingCounting/ClusterFinderConfig b/configfiles/RingCounting/ClusterFinderConfig new file mode 100644 index 000000000..87fffd3d8 --- /dev/null +++ b/configfiles/RingCounting/ClusterFinderConfig @@ -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 diff --git a/configfiles/RingCounting/DeadPMTIDs_p2v7.txt b/configfiles/RingCounting/DeadPMTIDs_p2v7.txt new file mode 100644 index 000000000..4ce119098 --- /dev/null +++ b/configfiles/RingCounting/DeadPMTIDs_p2v7.txt @@ -0,0 +1,11 @@ +2 +6 +11 +14 +15 +18 +21 +85 +100 +113 +114 diff --git a/configfiles/RingCounting/DigitBuilderConfig b/configfiles/RingCounting/DigitBuilderConfig new file mode 100644 index 000000000..ca0839c95 --- /dev/null +++ b/configfiles/RingCounting/DigitBuilderConfig @@ -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 diff --git a/configfiles/RingCounting/EnergyExtractorConfig b/configfiles/RingCounting/EnergyExtractorConfig new file mode 100644 index 000000000..e9b6c7b10 --- /dev/null +++ b/configfiles/RingCounting/EnergyExtractorConfig @@ -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 + diff --git a/configfiles/RingCounting/EventSelectorConfig b/configfiles/RingCounting/EventSelectorConfig new file mode 100644 index 000000000..ae4988304 --- /dev/null +++ b/configfiles/RingCounting/EventSelectorConfig @@ -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? diff --git a/configfiles/RingCounting/FindMrdTracksConfig b/configfiles/RingCounting/FindMrdTracksConfig new file mode 100644 index 000000000..7a9d11f7d --- /dev/null +++ b/configfiles/RingCounting/FindMrdTracksConfig @@ -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 diff --git a/configfiles/RingCounting/LoadANNIEEventConfig b/configfiles/RingCounting/LoadANNIEEventConfig new file mode 100644 index 000000000..a630fec20 --- /dev/null +++ b/configfiles/RingCounting/LoadANNIEEventConfig @@ -0,0 +1,3 @@ +verbose 0 +FileForListOfInputs ./configfiles/BeamClusterAnalysisMC/my_inputs.txt +EventOffset 0 diff --git a/configfiles/RingCounting/LoadGenieEventConfig b/configfiles/RingCounting/LoadGenieEventConfig new file mode 100644 index 000000000..828a93981 --- /dev/null +++ b/configfiles/RingCounting/LoadGenieEventConfig @@ -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 diff --git a/configfiles/RingCounting/LoadGeometryConfig b/configfiles/RingCounting/LoadGeometryConfig new file mode 100644 index 000000000..c64227136 --- /dev/null +++ b/configfiles/RingCounting/LoadGeometryConfig @@ -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 diff --git a/configfiles/RingCounting/LoadWCSimConfig b/configfiles/RingCounting/LoadWCSimConfig new file mode 100644 index 000000000..d6405b928 --- /dev/null +++ b/configfiles/RingCounting/LoadWCSimConfig @@ -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? diff --git a/configfiles/RingCounting/LoadWCSimLAPPDConfig b/configfiles/RingCounting/LoadWCSimLAPPDConfig new file mode 100644 index 000000000..dd9bd15fb --- /dev/null +++ b/configfiles/RingCounting/LoadWCSimLAPPDConfig @@ -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 diff --git a/configfiles/RingCounting/MCParticlePropertiesConfig b/configfiles/RingCounting/MCParticlePropertiesConfig new file mode 100644 index 000000000..13c4c2911 --- /dev/null +++ b/configfiles/RingCounting/MCParticlePropertiesConfig @@ -0,0 +1,4 @@ +# MCParticleProperties configuration file + +verbosity 0 +hasGENIE true diff --git a/configfiles/RingCounting/MCRecoEventLoaderConfig b/configfiles/RingCounting/MCRecoEventLoaderConfig new file mode 100644 index 000000000..1919f6189 --- /dev/null +++ b/configfiles/RingCounting/MCRecoEventLoaderConfig @@ -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 diff --git a/configfiles/RingCounting/files_to_load.txt b/configfiles/RingCounting/RC_files_to_load.txt similarity index 100% rename from configfiles/RingCounting/files_to_load.txt rename to configfiles/RingCounting/RC_files_to_load.txt diff --git a/configfiles/RingCounting/README.md b/configfiles/RingCounting/README.md index 78d3e2015..406396e26 100644 --- a/configfiles/RingCounting/README.md +++ b/configfiles/RingCounting/README.md @@ -1,25 +1,12 @@ -# Configure files - *********************** -#Description +# RingCounting ********************** -Configure files are simple text files for passing variables to the Tools. - -Text files are read by the Store class (src/Store) and automatically assigned to an internal map for the relevant Tool to use. - - -************************ -#Usage -************************ - -Any line starting with a "#" will be ignored by the Store, as will blank lines. - -Variables should be stored one per line as follows: - +A ToolChain that classifies (MC) events as Single- or Multi-Ring. The RingCounting tool can also be used as +a stand-alone tool, when loading events from csv files, produced by the CNNImage tool. -Name Value #Comments +All other tools used in the tool chain are prerequisites for the CNNImage tool. +See UserTools/RingCounting and UserTools/CNNImage for more information. -Note: Only one value is permitted per name and they are stored in a string stream and template cast back to the type given. diff --git a/configfiles/RingCounting/RingCountingConfig b/configfiles/RingCounting/RingCountingConfig index 033f3eaf2..8570e7474 100644 --- a/configfiles/RingCounting/RingCountingConfig +++ b/configfiles/RingCounting/RingCountingConfig @@ -9,11 +9,12 @@ verbose 1 # analysis specific settings # # Define file containing (multiple) filepath(s) to be loaded -files_to_load configfiles/RingCounting/files_to_load.txt +load_from_file 0 +files_to_load configfiles/RingCounting/RC_files_to_load.txt # Model version -> check documentation version 1_0_0 # Folder containing models -model_path /annie/app/users/dschmid/RingCountingStore/models/ +model_path /exp/annie/app/users/dschmid/RingCountingStore/models/ # Masked PMTs (to 0) config -> check documentation pmt_mask november_22 # Output file diff --git a/configfiles/RingCounting/TimeClusteringConfig b/configfiles/RingCounting/TimeClusteringConfig new file mode 100644 index 000000000..6eb6634f4 --- /dev/null +++ b/configfiles/RingCounting/TimeClusteringConfig @@ -0,0 +1,13 @@ +#TimeClustering config file + +verbosity 0 +MinDigitsForTrack 4 +MaxMrdSubEventDuration 40 +MinSubeventTimeSep 40 +MakeMrdDigitTimePlot 0 +LaunchTApplication 0 +IsData 0 +#OutputROOTFile TimeClustering_MRDTest28_cluster40ns +OutputROOTFile STEC_TimeClusteringOut +MapChankey_WCSimID ./configfiles/SimpleTankEnergyCalibrator/MRD_Chankey_WCSimID.dat + diff --git a/configfiles/RingCounting/ToolsConfig b/configfiles/RingCounting/ToolsConfig index 2e1af9c88..29b257697 100644 --- a/configfiles/RingCounting/ToolsConfig +++ b/configfiles/RingCounting/ToolsConfig @@ -1 +1,14 @@ +myLoadGeometry LoadGeometry ./configfiles/LoadGeometry/LoadGeometryConfig +myLoadWCSim LoadWCSim ./configfiles/RingCounting/LoadWCSimConfig +#myLoadWCSimLAPPD LoadWCSimLAPPD ./configfiles/RingCounting/LoadWCSimLAPPDConfig +myLoadGenieEvent LoadGenieEvent ./configfiles/RingCounting/LoadGenieEventConfig +myMCParticleProperties MCParticleProperties ./configfiles/RingCounting/MCParticlePropertiesConfig +myMCRecoEventLoader MCRecoEventLoader ./configfiles/RingCounting/MCRecoEventLoaderConfig +myDigitBuilder DigitBuilder ./configfiles/RingCounting/DigitBuilderConfig +myTimeClustering TimeClustering ./configfiles/RingCounting/TimeClusteringConfig +myFindMrdTracks FindMrdTracks ./configfiles/RingCounting/FindMrdTracksConfig +myClusterFinder ClusterFinder ./configfiles/RingCounting/ClusterFinderConfig +myClusterClassifiers ClusterClassifiers ./configfiles/RingCounting/ClusterClassifiersConfig +myEventSelector EventSelector ./configfiles/RingCounting/EventSelectorConfig +myCNNImage CNNImage ./configfiles/RingCounting/CNNImageConfig myRingCounting PythonScript configfiles/RingCounting/RingCountingConfig diff --git a/configfiles/RingCounting/my_inputs.txt b/configfiles/RingCounting/my_inputs.txt new file mode 100644 index 000000000..e69de29bb From 334c605ca6c163d1d60c7fe0e5785eba972b076d Mon Sep 17 00:00:00 2001 From: Daniel Tobias Schmid <82974642+s4294967296@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:59:02 +0200 Subject: [PATCH 3/3] CNNImage (#260) * add RingCounting tool * RingCounting.py: added model loading and documentation * RingCounting.py: fix bug * RingCounting.py: rm unimplemented method call * RingCounting.py: fixed pmt masking, fixed file loading, added files_to_load path line commenting support * RingCounting.py: + docStrings + saving controlled by [[save_to]] * added RingCountingConfig, fixed loading error in RingCountingTool * RingCounting.py: + logging of successful file loading + pep8 formatting * Filled RingCountingTool README.md * Created RingCounting Tool (#1) Created RingCounting Tool --------- Co-authored-by: Daniel T. Schmid * Update files_to_load.txt noop to trigger CI test * Fixed mrdtotalentries being smaller than tanktotalentries throwing a fatal error in LoadRawData.cpp when build type is set to "MRD", since in this case only MRD data is expected to be loaded. * Updated CNNImage Tool: (including previous changes) - added useLAPPDs config file setting - added WriteToFile config file setting - removed PMT-wise config setting. It is still "supported" within the config file, but will just remap to "Static" - better pmt dimensionality selection - refactored a lot of the functionality to be split into smaller methods - PMT binning is now calculated once at the initialization of the tool, during execution a simple lookup is performed instead of recalculating the PMT binning for each hit - Histograms of PMT images are reset each executio step instead of being deleted and recreated - charge, absolute charge, time and time first images are added to the RecoEvent boost store as vector - The number of edge case floating point operations has been reduced * Updated CNNImage Tool: (including previous changes) - added useLAPPDs config file setting - added WriteToFile config file setting - removed PMT-wise config setting. It is still "supported" within the config file, but will just remap to "Static" - better pmt dimensionality selection - refactored a lot of the functionality to be split into smaller methods - PMT binning is now calculated once at the initialization of the tool, during execution a simple lookup is performed instead of recalculating the PMT binning for each hit - Histograms of PMT images are reset each executio step instead of being deleted and recreated - charge, absolute charge, time and time first images are added to the RecoEvent boost store as vector - The number of edge case floating point operations has been reduced - README.md updated --------- Co-authored-by: Daniel T. Schmid Co-authored-by: marc1uk --- UserTools/CNNImage/CNNImage.cpp | 1570 ++++++++++------- UserTools/CNNImage/CNNImage.h | 58 +- UserTools/CNNImage/README.md | 87 +- .../CNNImage/CNNImage_Data/CNNImageConfig | 18 +- .../CNNImage/CNNImage_MC/CNNImageConfig | 18 +- 5 files changed, 1085 insertions(+), 666 deletions(-) mode change 100644 => 100755 UserTools/CNNImage/CNNImage.cpp mode change 100644 => 100755 UserTools/CNNImage/CNNImage.h mode change 100644 => 100755 configfiles/CNNImage/CNNImage_Data/CNNImageConfig mode change 100644 => 100755 configfiles/CNNImage/CNNImage_MC/CNNImageConfig diff --git a/UserTools/CNNImage/CNNImage.cpp b/UserTools/CNNImage/CNNImage.cpp old mode 100644 new mode 100755 index a81baf629..92801f7a0 --- a/UserTools/CNNImage/CNNImage.cpp +++ b/UserTools/CNNImage/CNNImage.cpp @@ -5,9 +5,8 @@ CNNImage::CNNImage():Tool(){} bool CNNImage::Initialise(std::string configfile, DataModel &data){ - - if(configfile!="") m_variables.Initialise(configfile); // loading config file - //m_variables.Print(); + if(configfile!="") m_variables.Initialise(configfile); + m_variables.Print(); m_data= &data; //assigning transient data pointer //--------------------------------------------------------------- @@ -18,6 +17,8 @@ bool CNNImage::Initialise(std::string configfile, DataModel &data){ includeTopBottom = false; dimensionLAPPD = 1; isData = 0; + use_LAPPDs = false; + write_to_file = false; //User-specified values m_variables.Get("verbosity",verbosity); @@ -29,23 +30,37 @@ bool CNNImage::Initialise(std::string configfile, DataModel &data){ m_variables.Get("IncludeTopBottom",includeTopBottom); m_variables.Get("OutputFile",cnn_outpath); m_variables.Get("DimensionLAPPD",dimensionLAPPD); - m_variables.Get("IsData",isData); + m_variables.Get("IsData",isData); + m_variables.Get("useLAPPDs",use_LAPPDs); + m_variables.Get("WriteToFile",write_to_file); Log("CNNImage tool: Initialising...",v_message,verbosity); //Check for user options if (data_mode != "Normal" && data_mode != "Charge-Weighted" && data_mode != "TimeEvolution") data_mode = "Normal"; - if (save_mode != "Geometric" && save_mode != "PMT-wise") save_mode = "Geometric"; + if (save_mode != "Geometric" && save_mode != "PMT-wise" && save_mode != "Static") save_mode = "Static"; nlappdX = dimensionLAPPD; nlappdY = dimensionLAPPD; - npmtsX = 16; //in every row, we have 16 PMTs (8 sides, 2 PMTs per side per row) - if (!includeTopBottom) npmtsY = 6; //we have 6 rows of PMTs (excluding top and bottom PMTs) - else npmtsY = 10; //for top & bottom PMTs, include 2 extra rows of PMTs at top and at the bottom - + + //in every row, we have 16 PMTs (8 sides, 2 PMTs per side per row) + if (save_mode == "Geometric") { + npmtsX = dimensionX; + npmtsY = dimensionY; + } else { + npmtsX = 16; + } + + //we have 6 rows of PMTs (excluding top and bottom PMTs) + if (!includeTopBottom && save_mode != "Geometric") { + npmtsY = 6; + } else { //for top & bottom PMTs, include 2 extra rows of PMTs at top and at the bottom + npmtsY = 10; + } + //Output configuration - Log("CNNImage tool: Data mode: "+data_mode+" [Normal/Charge-Weighted]",v_message,verbosity); - Log("CNNImage tool: Save mode: "+save_mode+" [Geometric/PMT-wise]",v_message,verbosity); - Log("CNNImage tool: LAPPD dimension: "+dimensionLAPPD,v_message,verbosity); + Log("CNNImage tool: Data mode: " + data_mode + " [Normal/Charge-Weighted]", v_message, verbosity); + Log("CNNImage tool: Save mode: " + save_mode + " [Geometric/PMT-wise]", v_message, verbosity); + Log("CNNImage tool: LAPPD dimension: " + dimensionLAPPD, v_message, verbosity); //--------------------------------------------------------------- //----------------------Get geometry----------------------------- @@ -63,179 +78,32 @@ bool CNNImage::Initialise(std::string configfile, DataModel &data){ tank_center_y = detector_center.Y(); tank_center_z = detector_center.Z(); n_tank_pmts = geom->GetNumDetectorsInSet("Tank"); - std::map >* Detectors = geom->GetDetectors(); + std::map >* Detectors = geom->GetDetectors(); if (isData){ m_data->CStore.Get("pmt_tubeid_to_channelkey",pmtid_to_channelkey); } - //Read in PMT positions + // PMT related max_y = -100.; min_y = 100.; - for (std::map::iterator it = Detectors->at("Tank").begin(); - it != Detectors->at("Tank").end(); - ++it){ - Detector* apmt = it->second; - unsigned long detkey = it->first; - pmt_detkeys.push_back(detkey); - unsigned long chankey = apmt->GetChannels()->begin()->first; - pmt_chankeys.push_back(chankey); - Position position_PMT = apmt->GetDetectorPosition(); - x_pmt.insert(std::pair(detkey,position_PMT.X()-tank_center_x)); - y_pmt.insert(std::pair(detkey,position_PMT.Y()-tank_center_y)); - z_pmt.insert(std::pair(detkey,position_PMT.Z()-tank_center_z)); - if (y_pmt[detkey]>max_y && apmt->GetTankLocation()!="OD") max_y = y_pmt.at(detkey); - if (y_pmt[detkey]GetTankLocation()!="OD") min_y = y_pmt.at(detkey); - - //Some debug information - Log("CNNImage tool: Reading in detkey: "+std::to_string(detkey)+", chankey: "+std::to_string(chankey)+", position: ("+std::to_string(position_PMT.X())+","+std::to_string(position_PMT.Y())+","+std::to_string(position_PMT.Z())+")",v_debug,verbosity); - Log("CNNImage tool: Rho PMT: "+std::to_string(sqrt(x_pmt.at(detkey)*x_pmt.at(detkey)+z_pmt.at(detkey)*z_pmt.at(detkey)))+", y PMT: "+std::to_string(y_pmt.at(detkey)),v_debug,verbosity); - } - - Log("CNNImage tool: Max/min y-dimensions of PMT volume: Max y = "+std::to_string(max_y)+", min y = "+std::to_string(min_y),v_message,verbosity); - - //--------------------------------------------------------------- - //-------------------Order PMT positions------------------------- //--------------------------------------------------------------- - for (unsigned int i_pmt = 0; i_pmt < y_pmt.size(); i_pmt++){ - - double x,y; - unsigned long detkey = pmt_detkeys[i_pmt]; - Position pmt_pos(x_pmt[detkey],y_pmt[detkey],z_pmt[detkey]); - unsigned long chankey = pmt_chankeys[i_pmt]; - Detector *apmt = geom->ChannelToDetector(chankey); - if (apmt->GetTankLocation()=="OD") continue; //don't include OD PMTs - if ((y_pmt[detkey] >= max_y-0.001 || y_pmt[detkey] <= min_y+0.001) && !includeTopBottom) continue; //don't include top/bottom PMTs if specified - - if (y_pmt[detkey] >= max_y-0.001) { - ConvertPositionTo2D_Top(pmt_pos, x, y); - } - else if (y_pmt[detkey] <= min_y+0.001) { - ConvertPositionTo2D_Bottom(pmt_pos, x, y); - } - else { - ConvertPositionTo2D(pmt_pos, x, y); - } - x = (round(100*x)/100.); - y = (round(100*y)/100.); - if (fabs(x-0.52)<0.001) x = 0.53; - if (fabs(x-0.47)<0.001) x = 0.48; - if (y_pmt[detkey] <= min_y + 0.001){ - if (fabs(x-0.23)<0.001) x = 0.22; - if (fabs(x-0.77)<0.001) x = 0.78; - } - if (y_pmt[detkey] >= max_y - 0.001){ - if (fabs(x-0.19)<0.001) x = 0.21; - if (fabs(x-0.34)<0.001) x = 0.32; - if (fabs(x-0.48)<0.001) x = 0.50; - if (fabs(x-0.66)<0.001) x = 0.68; - } - if (y_pmt[detkey] >= max_y-0.001) vec_pmt2D_x_Top.push_back(x); - else if (y_pmt[detkey] <= min_y+0.001) vec_pmt2D_x_Bottom.push_back(x); - else vec_pmt2D_x.push_back(x); - vec_pmt2D_y.push_back(y); - Log("CNNImage tool: Detkey "+std::to_string(detkey)+", x (2D): "+std::to_string(x)+", y (2D): "+std::to_string(y),v_message,verbosity); - } - - //Sort the positions (in x & y separately) - Log("CNNImage tool: vec_pmt2D_* size: "+std::to_string(vec_pmt2D_x.size()),v_message,verbosity); - std::sort(vec_pmt2D_x.begin(),vec_pmt2D_x.end()); - std::sort(vec_pmt2D_y.begin(),vec_pmt2D_y.end()); - std::sort(vec_pmt2D_x_Top.begin(),vec_pmt2D_x_Top.end()); - std::sort(vec_pmt2D_x_Bottom.begin(),vec_pmt2D_x_Bottom.end()); - vec_pmt2D_x.erase(std::unique(vec_pmt2D_x.begin(),vec_pmt2D_x.end()),vec_pmt2D_x.end()); - vec_pmt2D_y.erase(std::unique(vec_pmt2D_y.begin(),vec_pmt2D_y.end()),vec_pmt2D_y.end()); - vec_pmt2D_x_Top.erase(std::unique(vec_pmt2D_x_Top.begin(),vec_pmt2D_x_Top.end()),vec_pmt2D_x_Top.end()); - vec_pmt2D_x_Bottom.erase(std::unique(vec_pmt2D_x_Bottom.begin(),vec_pmt2D_x_Bottom.end()),vec_pmt2D_x_Bottom.end()); - - //Output sorted positions - if (verbosity >= v_message){ - std::cout <<"Sorted 2D position vectors: Barrel x "<::iterator it = Detectors->at("LAPPD").begin(); - it != Detectors->at("LAPPD").end(); - ++it){ - Detector* anlappd = it->second; - unsigned long detkey = it->first; - lappd_detkeys.push_back(detkey); - unsigned long chankey = anlappd->GetChannels()->begin()->first; - Position position_LAPPD = anlappd->GetDetectorPosition(); - x_lappd.insert(std::pair(detkey,position_LAPPD.X()-tank_center_x)); - y_lappd.insert(std::pair(detkey,position_LAPPD.Y()-tank_center_y)); - z_lappd.insert(std::pair(detkey,position_LAPPD.Z()-tank_center_z)); - if (y_lappd[detkey]>max_y_lappd) max_y_lappd = y_lappd.at(detkey); - if (y_lappd[detkey]= max_y || y_lappd[detkey] <= min_y) continue; //don't include top/bottom/OD PMTs for now - ConvertPositionTo2D(lappd_pos, x, y); - vec_lappd2D_x.push_back(x); - vec_lappd2D_y.push_back(y); - Log("CNNImage tool: Detkey "+std::to_string(detkey)+", x (2D): "+std::to_string(x)+", y (2D): "+std::to_string(y),v_message,verbosity); - } - - //Sort LAPPD positions - Log("CNNImage tool: vec_lappd2D_* size: "+std::to_string(vec_lappd2D_x.size()),v_message,verbosity); - std::sort(vec_lappd2D_x.begin(),vec_lappd2D_x.end()); - std::sort(vec_lappd2D_y.begin(),vec_lappd2D_y.end()); - vec_lappd2D_x.erase(std::unique(vec_lappd2D_x.begin(),vec_lappd2D_x.end()),vec_lappd2D_x.end()); - vec_lappd2D_y.erase(std::unique(vec_lappd2D_y.begin(),vec_lappd2D_y.end()),vec_lappd2D_y.end()); - - //Output the sorted positions - if (verbosity >=2){ - std::cout <<"CMMImage tool: Sorted LAPPD 2D position vectors: x-values: "<Stores["ANNIEEvent"]->Get("MCHits", MCHits); if (!get_ok) {Log("CNNImage tool: Error retrieving MCHits object",v_error,verbosity); return false;} - get_ok = m_data->Stores["ANNIEEvent"]->Get("MCLAPPDHits", MCLAPPDHits); - if (!get_ok) {Log("CNNImage tool: Error retrieving MCLAPPDHits object",v_error,verbosity); return false;} + if (use_LAPPDs) { + get_ok = m_data->Stores["ANNIEEvent"]->Get("MCLAPPDHits", MCLAPPDHits); + if (!get_ok) {Log("CNNImage tool: Error retrieving MCLAPPDHits object",v_error,verbosity); return false;} + } get_ok = m_data->Stores["ANNIEEvent"]->Get("TDCData",TDCData); if (!get_ok) {Log("CNNImage tool: Error retrieving TDCData object (MC)",v_error,verbosity); return false;} get_ok = m_data->Stores.at("RecoEvent")->Get("NRings",nrings); @@ -318,12 +210,6 @@ bool CNNImage::Execute(){ } get_ok = m_data->Stores["ANNIEEvent"]->Get("EventNumber", evnum); if (!get_ok) {Log("CNNImage tool: Error retrieving EventNumber",v_error,verbosity); return false;} - /*get_ok = m_data->Stores["ANNIEEvent"]->Get("RunNumber",runnumber); - if (!get_ok) {Log("CNNImage tool: Error retrieving RunNumber",v_error,verbosity); return false;} - get_ok = m_data->Stores["ANNIEEvent"]->Get("SubRunNumber",subrunnumber); - if (!get_ok) {Log("CNNImage tool: Error retrieving SubRunNumber",v_error,verbosity); return false;} - get_ok = m_data->Stores["ANNIEEvent"]->Get("EventTime",EventTime); - if (!get_ok) {Log("CNNImage tool: Error retrieving EventTime",v_error,verbosity); return false;}*/ get_ok = m_data->CStore.Get("NumMrdTimeClusters",mrdeventcounter); if (!get_ok) {Log("CNNImage tool: Error retrieving NumMrdTimeClusters",v_error,verbosity); return false;} if (mrdeventcounter > 0 ){ @@ -336,16 +222,19 @@ bool CNNImage::Execute(){ if (!isData) Log("CNNImage tool: # Rings: "+std::to_string(nrings)+", # of MRD clusters: "+std::to_string(mrdeventcounter),v_message,verbosity); else Log("CNNImage tool: # of MRD clusters: "+std::to_string(mrdeventcounter),v_message,verbosity); + // ------------------------------ //Clear variables & containers charge.clear(); time.clear(); time_first.clear(); hitpmt_detkeys.clear(); - charge_lappd.clear(); - time_lappd.clear(); - time_first_lappd.clear(); - hits_lappd.clear(); - total_charge_lappd.clear(); + if (use_LAPPDs) { + charge_lappd.clear(); + time_lappd.clear(); + time_first_lappd.clear(); + hits_lappd.clear(); + total_charge_lappd.clear(); + } for (unsigned int i_pmt=0; i_pmt> temp_lappdXY; - std::vector> temp_int_lappdXY;; - for (int lappdX=0; lappdX temp_lappdY; - std::vector temp_int_lappdY; - temp_lappdY.assign(dimensionLAPPD,0.); - temp_int_lappdY.assign(dimensionLAPPD,0); - temp_lappdXY.push_back(temp_lappdY); - temp_int_lappdXY.push_back(temp_int_lappdY); + if (use_LAPPDs) { + for (unsigned int i_lappd=0; i_lappd> temp_lappdXY; + std::vector> temp_int_lappdXY;; + for (int lappdX=0; lappdX temp_lappdY; + std::vector temp_int_lappdY; + temp_lappdY.assign(dimensionLAPPD,0.); + temp_int_lappdY.assign(dimensionLAPPD,0); + temp_lappdXY.push_back(temp_lappdY); + temp_int_lappdXY.push_back(temp_int_lappdY); + } + charge_lappd.emplace(detkey,temp_lappdXY); + time_lappd.emplace(detkey,temp_lappdXY); + time_first_lappd.emplace(detkey,temp_lappdXY); + hits_lappd.emplace(detkey,temp_int_lappdXY); } - charge_lappd.emplace(detkey,temp_lappdXY); - time_lappd.emplace(detkey,temp_lappdXY); - time_first_lappd.emplace(detkey,temp_lappdXY); - hits_lappd.emplace(detkey,temp_int_lappdXY); } + num_mrd_paddles_cluster = 0; + num_mrd_layers_cluster = 0; + num_mrd_conslayers_cluster = 0; + num_mrd_adjacent_cluster = 0; + mrd_padperlayer_cluster = 0.; + std::fill_n(layer_occupied_cluster, 11, 0); + std::fill_n(mrd_paddlesize_cluster, 11, 0); + //--------------------------------------------------------------- //-------------------Iterate over MCHits ------------------------ //--------------------------------------------------------------- @@ -389,14 +288,20 @@ bool CNNImage::Execute(){ Log("CNNImage tool: Read in MCHits for chankey: "+std::to_string(chankey)+", detkey: "+std::to_string(detkey),v_debug,verbosity); if (thistube->GetDetectorElement()=="Tank"){ if (thistube->GetTankLocation()=="OD") continue; + hitpmt_detkeys.push_back(detkey); std::vector& Hits = apair.second; int hits_pmt = 0; for (MCHit &ahit : Hits){ if (ahit.GetTime()>-10. && ahit.GetTime()<40.){ charge[detkey] += ahit.GetCharge(); - if (data_mode == "Normal") time[detkey] += ahit.GetTime(); - else if (data_mode == "Charge-Weighted") time[detkey] += (ahit.GetTime()*ahit.GetCharge()); + + if (data_mode == "Normal") { + time[detkey] += ahit.GetTime(); + } else if (data_mode == "Charge-Weighted") { + time[detkey] += (ahit.GetTime()*ahit.GetCharge()); + } + if (hits_pmt == 0) time_first[detkey] = ahit.GetTime(); hits_pmt++; } @@ -406,12 +311,13 @@ bool CNNImage::Execute(){ total_hits_pmts++; } } + Log("CNNImage tool: Done with MCHits loop",v_message,verbosity); } else { vectsize = RecoDigits->size(); Log("CNNImage tool: RecoDigits size: "+std::to_string(vectsize),v_message,verbosity); total_hits_pmts = 0; - for (unsigned int i_digit = 0; i_digit < RecoDigits->size(); i_digit++){ + for (unsigned int i_digit = 0; i_digit < RecoDigits->size(); i_digit++) { RecoDigit thisdigit = RecoDigits->at(i_digit); int digitID = thisdigit.GetDetectorID(); unsigned long chankey = pmtid_to_channelkey[digitID]; @@ -428,76 +334,76 @@ bool CNNImage::Execute(){ //--------------------------------------------------------------- //-------------------Iterate over MCLAPPDHits ------------------- //--------------------------------------------------------------- - - total_hits_lappds=0; - total_charge_lappds=0; - min_time_lappds=9999; - max_time_lappds=-9999; - if (!isData){ - vectsize = MCLAPPDHits->size(); - Log("CNNImage tool: MCLAPPDHits size: "+std::to_string(vectsize),v_message,verbosity); - - for(std::pair>&& apair : *MCLAPPDHits){ - unsigned long chankey = apair.first; - Detector* det = geom->ChannelToDetector(chankey); - unsigned long detkey = det->GetDetectorID(); - std::vector& hits = apair.second; - Log("CNNImage tool: Chankey: "+std::to_string(chankey)+", detkey: "+std::to_string(detkey),v_debug,verbosity); - - for (MCLAPPDHit& ahit : hits){ - std::vector temp_pos = ahit.GetPosition(); - double x_lappd = temp_pos.at(0)-tank_center_x; //global x-position (in detector coordinates) - double y_lappd = temp_pos.at(1)-tank_center_y; //global y-position (in detector coordinates) - double z_lappd = temp_pos.at(2)-tank_center_z; //global z-position (in detector coordinates) - std::vector local_pos = ahit.GetLocalPosition(); - - double x_local_lappd = local_pos.at(1); //local parallel position within LAPPD - double y_local_lappd = local_pos.at(0); //local transverse position within LAPPD - - //Get corresponding bin - double lappd_charge = 1.0; - double t_lappd = ahit.GetTime(); - int binx_lappd = round((x_local_lappd+0.1)/0.2*dimensionLAPPD); //local positions can be positive and negative, 10cm > x_local_lappd > -10cm - int biny_lappd = round((y_local_lappd+0.1)/0.2*dimensionLAPPD); - - //Discard unphysical bins - if (binx_lappd < 0) binx_lappd=0; //FIXME: hits outside of -10cm...10cm should probably be just discarded - if (biny_lappd < 0) biny_lappd=0; //FIXME: hits outside of -10cm...10cm should probably be just discarded - if (binx_lappd > dimensionLAPPD-1) binx_lappd = dimensionLAPPD-1; //FIXME: hits outside of -10cm...10cm should probably be just discarded - if (biny_lappd > dimensionLAPPD-1) biny_lappd = dimensionLAPPD-1; //FIXME: hits outside of -10cm...10cm should probably be just discarded - - //Write charge & time hits into the histogram - if (t_lappd>-10. && t_lappd<40){ - charge_lappd[detkey].at(binx_lappd).at(biny_lappd) += lappd_charge; - time_lappd[detkey].at(binx_lappd).at(biny_lappd) += t_lappd; - hits_lappd[detkey].at(binx_lappd).at(biny_lappd)++; - total_charge_lappd[detkey] += lappd_charge; - total_charge_lappds += lappd_charge; - if (max_time_lappds < t_lappd) max_time_lappds = t_lappd; - if (min_time_lappds > t_lappd) min_time_lappds = t_lappd; - if (hits_lappd[detkey].at(binx_lappd).at(biny_lappd) == 1) time_first_lappd[detkey].at(binx_lappd).at(biny_lappd) = t_lappd; + if (use_LAPPDs) { + total_hits_lappds=0; + total_charge_lappds=0; + min_time_lappds=9999; + max_time_lappds=-9999; + if (!isData){ + vectsize = MCLAPPDHits->size(); + Log("CNNImage tool: MCLAPPDHits size: "+std::to_string(vectsize),v_message,verbosity); + + for(std::pair>&& apair : *MCLAPPDHits){ + unsigned long chankey = apair.first; + Detector* det = geom->ChannelToDetector(chankey); + unsigned long detkey = det->GetDetectorID(); + std::vector& hits = apair.second; + Log("CNNImage tool: Chankey: "+std::to_string(chankey)+", detkey: "+std::to_string(detkey),v_debug,verbosity); + + for (MCLAPPDHit& ahit : hits){ + std::vector temp_pos = ahit.GetPosition(); + double x_lappd = temp_pos.at(0)-tank_center_x; //global x-position (in detector coordinates) + double y_lappd = temp_pos.at(1)-tank_center_y; //global y-position (in detector coordinates) + double z_lappd = temp_pos.at(2)-tank_center_z; //global z-position (in detector coordinates) + std::vector local_pos = ahit.GetLocalPosition(); + + double x_local_lappd = local_pos.at(1); //local parallel position within LAPPD + double y_local_lappd = local_pos.at(0); //local transverse position within LAPPD + + //Get corresponding bin + double lappd_charge = 1.0; + double t_lappd = ahit.GetTime(); + int binx_lappd = round((x_local_lappd+0.1)/0.2*dimensionLAPPD); //local positions can be positive and negative, 10cm > x_local_lappd > -10cm + int biny_lappd = round((y_local_lappd+0.1)/0.2*dimensionLAPPD); + + //Discard unphysical bins + if (binx_lappd < 0) binx_lappd=0; //FIXME: hits outside of -10cm...10cm should probably be just discarded + if (biny_lappd < 0) biny_lappd=0; //FIXME: hits outside of -10cm...10cm should probably be just discarded + if (binx_lappd > dimensionLAPPD-1) binx_lappd = dimensionLAPPD-1; //FIXME: hits outside of -10cm...10cm should probably be just discarded + if (biny_lappd > dimensionLAPPD-1) biny_lappd = dimensionLAPPD-1; //FIXME: hits outside of -10cm...10cm should probably be just discarded + + //Write charge & time hits into the histogram + if (t_lappd>-10. && t_lappd<40){ + charge_lappd[detkey].at(binx_lappd).at(biny_lappd) += lappd_charge; + time_lappd[detkey].at(binx_lappd).at(biny_lappd) += t_lappd; + hits_lappd[detkey].at(binx_lappd).at(biny_lappd)++; + total_charge_lappd[detkey] += lappd_charge; + total_charge_lappds += lappd_charge; + if (max_time_lappds < t_lappd) max_time_lappds = t_lappd; + if (min_time_lappds > t_lappd) min_time_lappds = t_lappd; + if (hits_lappd[detkey].at(binx_lappd).at(biny_lappd) == 1) time_first_lappd[detkey].at(binx_lappd).at(biny_lappd) = t_lappd; + } + total_hits_lappds++; } - total_hits_lappds++; } } - } - for (unsigned int i_lappd=0; i_lappd0) time_lappd[detkey].at(i_lappdX).at(i_lappdY)/=hits_lappd[detkey].at(i_lappdX).at(i_lappdY); + for (unsigned int i_lappd=0; i_lappd0) time_lappd[detkey].at(i_lappdX).at(i_lappdY)/=hits_lappd[detkey].at(i_lappdX).at(i_lappdY); + } } } - } - if (!isData && min_time_lappds>0.) min_time_lappds=0.; + if (!isData && min_time_lappds>0.) min_time_lappds=0.; + } //--------------------------------------------------------------- //------------- Determine max+min values ------------------------ //--------------------------------------------------------------- - maximum_pmts = 0; max_time_pmts = 0; min_time_pmts = 999.; @@ -513,16 +419,19 @@ bool CNNImage::Execute(){ if (time_first[detkey]>max_firsttime_pmts) max_firsttime_pmts = time_first[detkey]; if (time_first[detkey] maximum_lappds) maximum_lappds = charge_lappd[detkey].at(iX).at(iY); - if (time_first_lappd[detkey].at(iX).at(iY) > max_firsttime_lappds) max_firsttime_lappds = time_first_lappd[detkey].at(iX).at(iY); - if (time_first_lappd[detkey].at(iX).at(iY) < min_firsttime_lappds) min_firsttime_lappds = time_first_lappd[detkey].at(iX).at(iY); + + if (use_LAPPDs) { + maximum_lappds = 0; + for (unsigned int i_lappd = 0; i_lappd < lappd_detkeys.size();i_lappd++){ + unsigned long detkey = lappd_detkeys[i_lappd]; + for (int iX=0; iX maximum_lappds) maximum_lappds = charge_lappd[detkey].at(iX).at(iY); + if (time_first_lappd[detkey].at(iX).at(iY) > max_firsttime_lappds) max_firsttime_lappds = time_first_lappd[detkey].at(iX).at(iY); + if (time_first_lappd[detkey].at(iX).at(iY) < min_firsttime_lappds) min_firsttime_lappds = time_first_lappd[detkey].at(iX).at(iY); + } } } } @@ -533,94 +442,26 @@ bool CNNImage::Execute(){ double global_min_time_first = (min_firsttime_pmts < min_firsttime_lappds)? min_firsttime_pmts : min_firsttime_lappds; double global_max_time_first = (max_firsttime_pmts > max_firsttime_lappds)? max_firsttime_pmts : max_firsttime_lappds; - Log("CNNImage tool: Min_time_pmts: "+std::to_string(min_time_pmts)+", min_time_lappds: "+std::to_string(min_time_lappds)+", global_min_time: "+std::to_string(global_min_time),v_message,verbosity); + Log("CNNImage tool: Min_time_pmts: " + std::to_string(min_time_pmts) + ", min_time_lappds: " \ + + std::to_string(min_time_lappds)+", global_min_time: " + std::to_string(global_min_time), + v_message, verbosity); if (fabs(global_max_time-global_min_time)<0.01) global_max_time = global_min_time+1; if (fabs(global_max_time_first-global_min_time_first)<0.01) global_max_time_first = global_min_time_first+1; if (global_max_charge<0.001) global_max_charge=1; - //--------------------------------------------------------------- - //-------------- Readout MRD ------------------------------------ //--------------------------------------------------------------- - int num_mrd_paddles_cluster=0; - int num_mrd_layers_cluster=0; - int num_mrd_conslayers_cluster=0; - int num_mrd_adjacent_cluster=0; - double mrd_padperlayer_cluster=0.; - bool layer_occupied_cluster[11] = {0}; - double mrd_paddlesize_cluster[11]; - - if(MrdTimeClusters.size()==0){ - //No entries in MrdTimeClusters object, don't read out anything - Log("CNNImage tool: No MRDClusters entries.",v_message,verbosity); - } else { - std::vector> mrd_hits; - for (int i_layer=0; i_layer<11; i_layer++){ - std::vector empty_hits; - mrd_hits.push_back(empty_hits); - } - std::vector temp_cons_layers; - for (int i_cluster=0; i_cluster < (int) MrdTimeClusters.size(); i_cluster++){ - if (i_cluster > 0) continue; //only evaluate first cluster, if there are multiple - std::vector single_cluster = MrdTimeClusters.at(i_cluster); - for (int i_pmt = 0; i_pmt < (int) single_cluster.size(); i_pmt++){ - int idigit = single_cluster.at(i_pmt); - unsigned long chankey = mrddigitchankeysthisevent.at(idigit); - Detector *thedetector = geom->ChannelToDetector(chankey); - if(thedetector->GetDetectorElement()!="MRD") { - continue; // this is a veto hit, not an MRD hit. - } - num_mrd_paddles_cluster++; - int detkey = thedetector->GetDetectorID(); - Paddle *apaddle = geom->GetDetectorPaddle(detkey); - int layer = apaddle->GetLayer(); - layer_occupied_cluster[layer-1]=true; - if (apaddle->GetOrientation()==1) { - mrd_hits.at(layer-2).push_back(0.5*(apaddle->GetXmin()+apaddle->GetXmax())); - mrd_paddlesize_cluster[layer-2]=apaddle->GetPaddleWidth(); - } - else if (apaddle->GetOrientation()==0) { - mrd_hits.at(layer-2).push_back(0.5*(apaddle->GetYmin()+apaddle->GetYmax())); - mrd_paddlesize_cluster[layer-2]=apaddle->GetPaddleWidth(); - } - } - if (num_mrd_paddles_cluster > 0) { - for (int i_layer=0;i_layer<11;i_layer++){ - if (layer_occupied_cluster[i_layer]==true) { - num_mrd_layers_cluster++; - if (num_mrd_conslayers_cluster==0) num_mrd_conslayers_cluster++; - else { - if (layer_occupied_cluster[i_layer-1]==true) num_mrd_conslayers_cluster++; - else { - temp_cons_layers.push_back(num_mrd_conslayers_cluster); - num_mrd_conslayers_cluster=0; - } - } - } - for (unsigned int i_hitpaddle=0; i_hitpaddle::iterator it = std::max_element(temp_cons_layers.begin(),temp_cons_layers.end()); - if (it != temp_cons_layers.end()) num_mrd_conslayers_cluster = *it; - else num_mrd_conslayers_cluster=0; - if (num_mrd_layers_cluster > 0.) mrd_padperlayer_cluster = double(num_mrd_paddles_cluster)/num_mrd_layers_cluster; - } - } - - //--------------------------------------------------------------- - //-------------- Create CNN images ------------------------------ - //--------------------------------------------------------------- + ReadoutMRD(); // Define histogram as an intermediate step to the CNN - std::stringstream ss_cnn, ss_title_cnn, ss_cnn_time, ss_title_cnn_time, ss_cnn_pmtwise, ss_title_cnn_pmtwise, ss_cnn_time_pmtwise, ss_title_cnn_time_pmtwise; - std::stringstream ss_cnn_abs, ss_title_cnn_abs, ss_cnn_time_first, ss_title_cnn_time_first, ss_cnn_time_abs, ss_title_cnn_time_abs, ss_cnn_time_first_abs, ss_title_cnn_time_first_abs, ss_cnn_abs_pmtwise, ss_title_cnn_abs_pmtwise, ss_cnn_time_first_pmtwise, ss_title_cnn_time_first_pmtwise, ss_cnn_time_abs_pmtwise, ss_title_cnn_time_abs_pmtwise, ss_cnn_time_first_abs_pmtwise, ss_title_cnn_time_first_abs_pmtwise; + std::stringstream ss_cnn, ss_title_cnn, ss_cnn_time, ss_title_cnn_time, ss_cnn_pmtwise, ss_title_cnn_pmtwise, + ss_cnn_time_pmtwise, ss_title_cnn_time_pmtwise; + std::stringstream ss_cnn_abs, ss_title_cnn_abs, ss_cnn_time_first, ss_title_cnn_time_first, ss_cnn_time_abs, + ss_title_cnn_time_abs, ss_cnn_time_first_abs, ss_title_cnn_time_first_abs, ss_cnn_abs_pmtwise, + ss_title_cnn_abs_pmtwise, ss_cnn_time_first_pmtwise, ss_title_cnn_time_first_pmtwise, ss_cnn_time_abs_pmtwise, + ss_title_cnn_time_abs_pmtwise, ss_cnn_time_first_abs_pmtwise, ss_title_cnn_time_first_abs_pmtwise; ss_cnn<<"hist_cnn"<Reset(); + hist_cnn_abs->Reset(); + hist_cnn_time->Reset(); + hist_cnn_time_abs->Reset(); + hist_cnn_time_first->Reset(); + hist_cnn_time_first_abs->Reset(); + hist_cnn_pmtwise->Reset(); + hist_cnn_abs_pmtwise->Reset(); + hist_cnn_time_pmtwise->Reset(); + hist_cnn_time_first_pmtwise->Reset(); + hist_cnn_time_abs_pmtwise->Reset(); + hist_cnn_time_first_abs_pmtwise->Reset(); + + hist_cnn->SetName(ss_cnn.str().c_str()); + hist_cnn_abs->SetName(ss_cnn_abs.str().c_str()); + hist_cnn_time->SetName(ss_cnn_time.str().c_str()); + hist_cnn_time_abs->SetName(ss_cnn_time_abs.str().c_str()); + hist_cnn_time_first->SetName(ss_title_cnn_time_first.str().c_str()); + hist_cnn_time_first_abs->SetName(ss_cnn_time_first_abs.str().c_str()); + hist_cnn_pmtwise->SetName(ss_cnn_pmtwise.str().c_str()); + hist_cnn_abs_pmtwise->SetName(ss_cnn_abs_pmtwise.str().c_str()); + hist_cnn_time_pmtwise->SetName(ss_cnn_time_pmtwise.str().c_str()); + hist_cnn_time_first_pmtwise->SetName(ss_cnn_time_first_pmtwise.str().c_str()); + hist_cnn_time_abs_pmtwise->SetName(ss_cnn_time_abs_pmtwise.str().c_str()); + hist_cnn_time_first_abs_pmtwise->SetName(ss_cnn_time_first_abs_pmtwise.str().c_str()); + + hist_cnn->SetTitle(ss_title_cnn.str().c_str()); + hist_cnn_abs->SetTitle(ss_title_cnn_abs.str().c_str()); + hist_cnn_time->SetTitle(ss_title_cnn_time.str().c_str()); + hist_cnn_time_abs->SetTitle(ss_title_cnn_time_abs.str().c_str()); + hist_cnn_time_first->SetTitle(ss_title_cnn_time_first.str().c_str()); + hist_cnn_time_first_abs->SetTitle(ss_title_cnn_time_first_abs.str().c_str()); + hist_cnn_pmtwise->SetTitle(ss_title_cnn_pmtwise.str().c_str()); + hist_cnn_abs_pmtwise->SetTitle(ss_title_cnn_abs_pmtwise.str().c_str()); + hist_cnn_time_pmtwise->SetTitle(ss_title_cnn_time_pmtwise.str().c_str()); + hist_cnn_time_first_pmtwise->SetTitle(ss_title_cnn_time_first_pmtwise.str().c_str()); + hist_cnn_time_abs_pmtwise->SetTitle(ss_title_cnn_time_abs_pmtwise.str().c_str()); + hist_cnn_time_first_abs_pmtwise->SetTitle(ss_title_cnn_time_first_abs_pmtwise.str().c_str()); + // Define LAPPD histograms (1 per LAPPD) - std::vector hists_lappd, hists_abs_lappd, hists_time_lappd, hists_time_first_lappd, hists_time_abs_lappd, hists_time_first_abs_lappd; - for (unsigned int i_lappd = 0; i_lappd < lappd_detkeys.size(); i_lappd++){ - std::stringstream ss_hist_lappd, ss_title_lappd, ss_hist_abs_lappd, ss_title_abs_lappd, ss_hist_time_lappd, ss_title_time_lappd, ss_hist_time_first_lappd, ss_title_time_first_lappd, ss_hist_time_abs_lappd, ss_title_time_abs_lappd, ss_hist_time_first_abs_lappd, ss_title_time_first_abs_lappd; - ss_hist_lappd<<"hist_lappd"< hists_lappd, hists_abs_lappd, hists_time_lappd, hists_time_first_lappd, hists_time_abs_lappd, + hists_time_first_abs_lappd; + if (use_LAPPDs) { + for (unsigned int i_lappd = 0; i_lappd < lappd_detkeys.size(); i_lappd++){ + std::stringstream ss_hist_lappd, ss_title_lappd, ss_hist_abs_lappd, ss_title_abs_lappd, ss_hist_time_lappd, + ss_title_time_lappd, ss_hist_time_first_lappd, ss_title_time_first_lappd, ss_hist_time_abs_lappd, + ss_title_time_abs_lappd, ss_hist_time_first_abs_lappd, ss_title_time_first_abs_lappd; + + ss_hist_lappd<<"hist_lappd"<GetXaxis()->FindBin(x); - int biny = hist_cnn->GetYaxis()->FindBin(y); - Log("CNNImage tool: Filling binx: "+std::to_string(binx)+", biny: "+std::to_string(biny)+" with charge: "+std::to_string(charge[detkey])+", time: "+std::to_string(time[detkey]),v_message,verbosity); - if (maximum_pmts < 0.001) maximum_pmts = 1.; if (fabs(max_time_pmts) < 0.001) max_time_pmts = 1.; - //Fill geometric histograms double charge_fill = charge[detkey]/global_max_charge; double time_fill = 0.; double time_first_fill = 0.; if (charge_fill > 1e-10) { - time_fill = (time[detkey]-global_min_time)/(global_max_time-global_min_time); - time_first_fill = (time_first[detkey]-global_min_time_first)/(global_max_time_first-global_min_time_first); + time_fill = (time[detkey] - global_min_time) / (global_max_time - global_min_time); + time_first_fill = (time_first[detkey] - global_min_time_first) / (global_max_time_first - global_min_time_first); } - hist_cnn->SetBinContent(binx,biny,hist_cnn->GetBinContent(binx,biny)+charge_fill); - hist_cnn_abs->SetBinContent(binx,biny,hist_cnn->GetBinContent(binx,biny)+charge[detkey]); - hist_cnn_time->SetBinContent(binx,biny,time_fill); - hist_cnn_time_abs->SetBinContent(binx,biny,time[detkey]); - hist_cnn_time_first->SetBinContent(binx,biny,time_first_fill); - hist_cnn_time_first_abs->SetBinContent(binx,biny,time_first[detkey]); - - //Fill the pmt-wise histograms - if ((y_pmt[detkey]>=max_y || y_pmt[detkey]<=min_y) && !includeTopBottom) continue; //don't include endcaps in the pmt-wise histogram for now - if (y_pmt[detkey]>=max_y) ConvertPositionTo2D_Top(pmt_pos,x,y); - if (y_pmt[detkey]<=min_y) ConvertPositionTo2D_Bottom(pmt_pos,x,y); - double xCorr, yCorr; - xCorr = (round(100*x)/100.); - yCorr = (round(100*y)/100.); - if (fabs(xCorr-0.52)<0.001) xCorr = 0.53; - if (fabs(xCorr-0.47)<0.001) xCorr = 0.48; - std::vector::iterator it_x, it_y; - if (y_pmt[detkey]>=max_y){ - if (fabs(xCorr-0.19)<0.001) xCorr = 0.21; - if (fabs(xCorr-0.34)<0.001) xCorr = 0.32; - if (fabs(xCorr-0.48)<0.001) xCorr = 0.50; - if (fabs(xCorr-0.66)<0.001) xCorr = 0.68; - it_x = std::find(vec_pmt2D_x_Top.begin(),vec_pmt2D_x_Top.end(),xCorr); - } - else if (y_pmt[detkey]<=min_y){ - if (fabs(xCorr-0.23)<0.001) xCorr = 0.22; - if (fabs(xCorr-0.77)<0.001) xCorr = 0.78; - it_x = std::find(vec_pmt2D_x_Bottom.begin(),vec_pmt2D_x_Bottom.end(),xCorr); + if (save_mode == "Geometric") { + //Get corresponding geometric-mode bins for 2D (x,y)-position + int binx_geometric = geometric_pmt_mapping[detkey].first; + int biny_geometric = geometric_pmt_mapping[detkey].second; + + Log("CNNImage tool: Filling binx_geometric: " + std::to_string(binx_geometric) + ", biny_geometric: " \ + + std::to_string(biny_geometric) + " with charge: " \ + + std::to_string(charge[detkey]) + ", time: " + std::to_string(time[detkey]), v_debug, verbosity + ); + + //Fill geometric histograms + hist_cnn->SetBinContent( + binx_geometric, biny_geometric, + hist_cnn->GetBinContent(binx_geometric, biny_geometric) + charge_fill + ); + hist_cnn_abs->SetBinContent( + binx_geometric, biny_geometric, hist_cnn->GetBinContent(binx_geometric, biny_geometric) + charge[detkey] + ); + hist_cnn_time->SetBinContent( + binx_geometric, biny_geometric, time_fill + ); + hist_cnn_time_abs->SetBinContent( + binx_geometric, biny_geometric, time[detkey] + ); + hist_cnn_time_first->SetBinContent( + binx_geometric, biny_geometric, time_first_fill + ); + hist_cnn_time_first_abs->SetBinContent( + binx_geometric, biny_geometric, time_first[detkey] + ); } - else { - it_x = std::find(vec_pmt2D_x.begin(),vec_pmt2D_x.end(),xCorr); + + if (save_mode == "PMT-wise" || save_mode == "Static") { + //Fill the static mapping and pmt-wise histograms + if ((y_pmt[detkey]>=max_y || y_pmt[detkey]<=min_y) && !includeTopBottom) continue; + + int index_x = static_pmt_mapping[detkey].first; + int index_y = static_pmt_mapping[detkey].second; + + // further safety. This error should never occur, however if the mapping contains unexpected values + // this will be caught here. + if (index_x <= -1 || index_y <= -1 || index_x >= npmtsX || index_y >= npmtsY) { + std::cout << index_x << " " << index_y << std::endl; + Log(R"LSTR(CNNImage tool: Unexpected value for index_x or index_y when filling PMT-wise histogram to produce the 2D + CNNImage. This error is a result of at least one of the indices being outside the size of the specified + matrix (Xmax, Ymax) = + )LSTR" + + std::to_string(npmtsX) + ", " + std::to_string(npmtsY) + + R"LSTR(), and could hint + toward bad values within the mapping files for the PMT-wise mode, or unexpected behaviour when loading + those.)LSTR", + v_error, verbosity); + return false; + } + + hist_cnn_pmtwise->SetBinContent(index_x+1, index_y+1, charge_fill); + hist_cnn_abs_pmtwise->SetBinContent(index_x+1, index_y+1, charge[detkey]); + hist_cnn_time_pmtwise->SetBinContent(index_x+1, index_y+1, time_fill); + hist_cnn_time_abs_pmtwise->SetBinContent(index_x+1, index_y+1, time[detkey]); + hist_cnn_time_first_pmtwise->SetBinContent(index_x+1, index_y+1, time_first_fill); + hist_cnn_time_first_abs_pmtwise->SetBinContent(index_x+1, index_y+1, time_first[detkey]); + + Log("CNNImage tool: BinContent at (" + std::to_string(index_x) + "," + std::to_string(index_y) + ") is " + + std::to_string(hist_cnn_pmtwise->GetBinContent(index_x+1, index_y+1)), v_debug, verbosity); } - it_y = std::find(vec_pmt2D_y.begin(),vec_pmt2D_y.end(),yCorr); - int index_x, index_y; - if (y_pmt[detkey]>=max_y) index_x = std::distance(vec_pmt2D_x_Top.begin(),it_x); - else if (y_pmt[detkey]<=min_y) index_x = std::distance(vec_pmt2D_x_Bottom.begin(),it_x); - else index_x = std::distance(vec_pmt2D_x.begin(),it_x); - index_y = std::distance(vec_pmt2D_y.begin(),it_y); - hist_cnn_pmtwise->SetBinContent(index_x+1,index_y+1,charge_fill); - hist_cnn_abs_pmtwise->SetBinContent(index_x+1,index_y+1,charge[detkey]); - hist_cnn_time_pmtwise->SetBinContent(index_x+1,index_y+1,time_fill); - hist_cnn_time_abs_pmtwise->SetBinContent(index_x+1,index_y+1,time[detkey]); - hist_cnn_time_first_pmtwise->SetBinContent(index_x+1,index_y+1,time_first_fill); - hist_cnn_time_first_abs_pmtwise->SetBinContent(index_x+1,index_y+1,time_first[detkey]); } //--------------------------------------------------------------- //---------------- Fill LAPPD images ---------------------------- //--------------------------------------------------------------- + if (use_LAPPDs) { + for (unsigned int i_lappd=0; i_lappd 1e-10) { + lappd_time_fill = (time_lappd[detkey].at(iX).at(iY)-global_min_time)/(global_max_time-global_min_time); + lappd_time_first_fill = (time_first_lappd[detkey].at(iX).at(iY)-global_min_time)/(global_max_time-global_min_time); + } - for (unsigned int i_lappd=0; i_lappd 1e-10) { - lappd_time_fill = (time_lappd[detkey].at(iX).at(iY)-global_min_time)/(global_max_time-global_min_time); - lappd_time_first_fill = (time_first_lappd[detkey].at(iX).at(iY)-global_min_time)/(global_max_time-global_min_time); + if (lappd_time_fill < 0) { + std::cout << "Min LAPPD time: " << min_time_lappds << ", Max LAPPD time: " \ + << max_time_lappds << ", time_lappd: " << time_lappd[detkey].at(iX).at(iY) << ", fill time: " \ + << lappd_time_fill << std::endl; + } + hists_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,lappd_charge_fill); + hists_abs_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,charge_lappd[detkey].at(iX).at(iY)); + hists_time_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,lappd_time_fill); + hists_time_first_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,lappd_time_first_fill); + hists_time_abs_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,time_lappd[detkey].at(iX).at(iY)); + hists_time_first_abs_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,time_first_lappd[detkey].at(iX).at(iY)); } - - if (lappd_time_fill < 0) std::cout <<"Min LAPPD time: "<SetBinContent(iX+1,iY+1,lappd_charge_fill); - hists_abs_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,charge_lappd[detkey].at(iX).at(iY)); - hists_time_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,lappd_time_fill); - hists_time_first_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,lappd_time_first_fill); - hists_time_abs_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,time_lappd[detkey].at(iX).at(iY)); - hists_time_first_abs_lappd.at(i_lappd)->SetBinContent(iX+1,iY+1,time_first_lappd[detkey].at(iX).at(iY)); } } } + // Define vector that will store the CNNImage used in the CNN tools + int cnn_image_size = 0; + if (save_mode == "Static") cnn_image_size = 160; + if (save_mode == "PMT-Wise") cnn_image_size = 160; + if (save_mode == "Geometric") cnn_image_size = hist_cnn->GetNbinsY() * hist_cnn->GetNbinsX(); + std::vector cnn_image_charge(cnn_image_size, 0); + std::vector cnn_image_charge_abs(cnn_image_size, 0); + std::vector cnn_image_time(cnn_image_size, 0); + std::vector cnn_image_time_first(cnn_image_size, 0); + //--------------------------------------------------------------- //---------------- Write information to csv---------------------- //--------------------------------------------------------------- @@ -806,116 +721,136 @@ bool CNNImage::Execute(){ Log("CNNImage tool: Passed Event Selection: "+std::to_string(passed_eventselection),v_message,verbosity); if (passed_eventselection) { - // Save Rings and MRD information - if (!isData) outfile_Rings << nrings << endl; - outfile_MRD << mrdeventcounter<< ","<< num_mrd_paddles_cluster <<","<< num_mrd_layers_cluster<<","<Write(); - hist_cnn_abs->Write(); - hist_cnn_time->Write(); - hist_cnn_time_first->Write(); - hist_cnn_time_abs->Write(); - hist_cnn_time_first_abs->Write(); - hist_cnn_pmtwise->Write(); - hist_cnn_abs_pmtwise->Write(); - hist_cnn_time_pmtwise->Write(); - hist_cnn_time_first_pmtwise->Write(); - hist_cnn_time_abs_pmtwise->Write(); - hist_cnn_time_first_abs_pmtwise->Write(); - for (unsigned int i_lappd=0; i_lappdWrite(); - hists_abs_lappd.at(i_lappd)->Write(); - hists_time_lappd.at(i_lappd)->Write(); - hists_time_first_lappd.at(i_lappd)->Write(); - hists_time_abs_lappd.at(i_lappd)->Write(); - hists_time_first_abs_lappd.at(i_lappd)->Write(); - } + if (write_to_file) { + // Save Rings and MRD information + if (!isData) outfile_Rings << nrings << endl; + outfile_MRD << mrdeventcounter << "," << num_mrd_paddles_cluster << "," << num_mrd_layers_cluster<< "," \ + << num_mrd_conslayers_cluster << "," << num_mrd_adjacent_cluster << "," << mrd_padperlayer_cluster << endl; + + // Save root histograms + std::vector temp_histograms_to_write_vec = { + hist_cnn, hist_cnn_abs, hist_cnn_time, hist_cnn_time_first, hist_cnn_time_abs, hist_cnn_time_first_abs, + hist_cnn_pmtwise, hist_cnn_abs_pmtwise, hist_cnn_time_pmtwise, hist_cnn_time_first_pmtwise, + hist_cnn_time_abs_pmtwise, hist_cnn_time_first_abs_pmtwise + }; + + for (auto hist : temp_histograms_to_write_vec) { + hist->Write(); + } - if (save_mode == "Geometric"){ - for (int i_binY=0; i_binY < hist_cnn->GetNbinsY();i_binY++){ - for (int i_binX=0; i_binX < hist_cnn->GetNbinsX();i_binX++){ - outfile << hist_cnn->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn->GetNbinsX()-1 || i_binY!=hist_cnn->GetNbinsY()-1) outfile<<","; - outfile_abs << hist_cnn_abs->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_abs->GetNbinsX()-1 || i_binY!=hist_cnn_abs->GetNbinsY()-1) outfile_abs<<","; - outfile_time << hist_cnn_time->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time->GetNbinsX()-1 || i_binY!=hist_cnn_time->GetNbinsY()-1) outfile_time<<","; - outfile_time_first << hist_cnn_time_first->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time_first->GetNbinsX()-1 || i_binY!=hist_cnn_time_first->GetNbinsY()-1) outfile_time_first<<","; - outfile_time_abs << hist_cnn_time_abs->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time_abs->GetNbinsX()-1 || i_binY!=hist_cnn_time_abs->GetNbinsY()-1) outfile_time_abs<<","; - outfile_time_first_abs << hist_cnn_time_first_abs->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time_first_abs->GetNbinsX()-1 || i_binY!=hist_cnn_time_first_abs->GetNbinsY()-1) outfile_time_first_abs<<","; + if (use_LAPPDs) { + for (unsigned int i_lappd=0; i_lappdWrite(); + hists_abs_lappd.at(i_lappd)->Write(); + hists_time_lappd.at(i_lappd)->Write(); + hists_time_first_lappd.at(i_lappd)->Write(); + hists_time_abs_lappd.at(i_lappd)->Write(); + hists_time_first_abs_lappd.at(i_lappd)->Write(); } } - } else if (save_mode == "PMT-wise"){ - for (int i_binY=0; i_binY < hist_cnn_pmtwise->GetNbinsY();i_binY++){ - for (int i_binX=0; i_binX < hist_cnn_pmtwise->GetNbinsX();i_binX++){ - outfile << hist_cnn_pmtwise->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_pmtwise->GetNbinsX()-1 || i_binY!=hist_cnn_pmtwise->GetNbinsY()-1) outfile<<","; - outfile_abs << hist_cnn_abs_pmtwise->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_abs_pmtwise->GetNbinsX()-1 || i_binY!=hist_cnn_abs_pmtwise->GetNbinsY()-1) outfile_abs<<","; - outfile_time << hist_cnn_time_pmtwise->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time_pmtwise->GetNbinsX()-1 || i_binY!=hist_cnn_time_pmtwise->GetNbinsY()-1) outfile_time<<","; - outfile_time_first << hist_cnn_time_first_pmtwise->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time_first_pmtwise->GetNbinsX()-1 || i_binY!=hist_cnn_time_first_pmtwise->GetNbinsY()-1) outfile_time_first<<","; - outfile_time_abs << hist_cnn_time_abs_pmtwise->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time_abs_pmtwise->GetNbinsX()-1 || i_binY!=hist_cnn_time_abs_pmtwise->GetNbinsY()-1) outfile_time_abs<<","; - outfile_time_first_abs << hist_cnn_time_first_abs_pmtwise->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hist_cnn_time_first_abs_pmtwise->GetNbinsX()-1 || i_binY!=hist_cnn_time_first_abs_pmtwise->GetNbinsY()-1) outfile_time_first_abs<<","; + + if (save_mode == "Geometric"){ + for (int i_binY=0; i_binY < hist_cnn->GetNbinsY();i_binY++){ + for (int i_binX=0; i_binX < hist_cnn->GetNbinsX();i_binX++){ + PopulateHistInFilePMT(outfile, hist_cnn, i_binX, i_binY); + PopulateHistInFilePMT(outfile_abs, hist_cnn_abs, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time, hist_cnn_time, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time_first, hist_cnn_time_first, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time_abs, hist_cnn_time_abs, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time_first_abs, hist_cnn_time_first_abs, i_binX, i_binY); + + cnn_image_charge[i_binY*hist_cnn->GetNbinsX() + i_binX] = hist_cnn->GetBinContent(i_binX+1,i_binY+1); + cnn_image_charge_abs[i_binY*hist_cnn_abs->GetNbinsX() + i_binX] = hist_cnn_abs->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time[i_binY*hist_cnn_time->GetNbinsX() + i_binX] = hist_cnn_time->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time_first[i_binY*hist_cnn_time_first->GetNbinsX() + i_binX] = hist_cnn_time_first->GetBinContent(i_binX+1,i_binY+1); + } } - } - for (unsigned int i_lappd=0;i_lappdGetNbinsY();i_binY++){ - for (int i_binX=0; i_binX < hists_lappd.at(i_lappd)->GetNbinsX();i_binX++){ - outfile_lappd << hists_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); - outfile_lappd_abs << hists_abs_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hists_lappd.at(i_lappd)->GetNbinsX()-1 || i_binY!=hists_lappd.at(i_lappd)->GetNbinsY()-1 || i_lappd != lappd_detkeys.size()-1) { - outfile_lappd<<","; - outfile_lappd_abs<<","; - } - outfile_lappd_time << hists_time_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); - outfile_lappd_time_first << hists_time_first_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); - outfile_lappd_time_abs << hists_time_abs_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); - outfile_lappd_time_first_abs << hists_time_first_abs_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); - if (i_binX != hists_time_lappd.at(i_lappd)->GetNbinsX()-1 || i_binY!=hists_time_lappd.at(i_lappd)->GetNbinsY()-1 || i_lappd != lappd_detkeys.size()-1) { - outfile_lappd_time<<","; - outfile_lappd_time_first<<","; - outfile_lappd_time_abs<<","; - outfile_lappd_time_first_abs<<","; + } else if (save_mode == "PMT-wise" || save_mode == "Static"){ + for (int i_binY=0; i_binY < hist_cnn_pmtwise->GetNbinsY();i_binY++){ + for (int i_binX=0; i_binX < hist_cnn_pmtwise->GetNbinsX();i_binX++){ + PopulateHistInFilePMT(outfile, hist_cnn_pmtwise, i_binX, i_binY); + PopulateHistInFilePMT(outfile_abs, hist_cnn_abs_pmtwise, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time, hist_cnn_time_pmtwise, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time_first, hist_cnn_time_first_pmtwise, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time_abs, hist_cnn_time_abs_pmtwise, i_binX, i_binY); + PopulateHistInFilePMT(outfile_time_first_abs, hist_cnn_time_first_abs_pmtwise, i_binX, i_binY); + + cnn_image_charge[i_binY*hist_cnn_pmtwise->GetNbinsX() + i_binX] = hist_cnn_pmtwise->GetBinContent(i_binX+1,i_binY+1); + cnn_image_charge_abs[i_binY*hist_cnn_abs_pmtwise->GetNbinsX() + i_binX] = hist_cnn_abs_pmtwise->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time[i_binY*hist_cnn_time_pmtwise->GetNbinsX() + i_binX] = hist_cnn_time_pmtwise->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time_first[i_binY*hist_cnn_time_first_pmtwise->GetNbinsX() + i_binX] = hist_cnn_time_first_pmtwise->GetBinContent(i_binX+1,i_binY+1); + } + } + if (use_LAPPDs) { + for (unsigned int i_lappd=0;i_lappdGetNbinsY();i_binY++){ + for (int i_binX=0; i_binX < hists_lappd.at(i_lappd)->GetNbinsX();i_binX++){ + outfile_lappd << hists_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); + outfile_lappd_abs << hists_abs_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); + if (i_binX != hists_lappd.at(i_lappd)->GetNbinsX()-1 || i_binY!=hists_lappd.at(i_lappd)->GetNbinsY()-1 || i_lappd != lappd_detkeys.size()-1) { + outfile_lappd<<","; + outfile_lappd_abs<<","; + } + outfile_lappd_time << hists_time_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); + outfile_lappd_time_first << hists_time_first_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); + outfile_lappd_time_abs << hists_time_abs_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); + outfile_lappd_time_first_abs << hists_time_first_abs_lappd.at(i_lappd)->GetBinContent(i_binX+1,i_binY+1); + if (i_binX != hists_time_lappd.at(i_lappd)->GetNbinsX()-1 || i_binY!=hists_time_lappd.at(i_lappd)->GetNbinsY()-1 || i_lappd != lappd_detkeys.size()-1) { + outfile_lappd_time<<","; + outfile_lappd_time_first<<","; + outfile_lappd_time_abs<<","; + outfile_lappd_time_first_abs<<","; + } + } } } + outfile_lappd << std::endl; + outfile_lappd_abs << std::endl; + outfile_lappd_time << std::endl; + outfile_lappd_time_first << std::endl; + outfile_lappd_time_abs << std::endl; + outfile_lappd_time_first_abs << std::endl; + } + } + + Log("MCRecoEventLoader Tool: Push projected Mrd Hit", v_message, verbosity); + + outfile << std::endl; + outfile_abs << std::endl; + outfile_time << std::endl; + outfile_time_first << std::endl; + outfile_time_abs << std::endl; + outfile_time_first_abs << std::endl; + } else { + if (save_mode == "Geometric") { + for (int i_binY=0; i_binY < hist_cnn->GetNbinsY();i_binY++) { + for (int i_binX=0; i_binX < hist_cnn->GetNbinsX();i_binX++) { + cnn_image_charge[i_binY*hist_cnn->GetNbinsX() + i_binX] = hist_cnn->GetBinContent(i_binX+1,i_binY+1); + cnn_image_charge_abs[i_binY*hist_cnn_abs->GetNbinsX() + i_binX] = hist_cnn_abs->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time[i_binY*hist_cnn_time->GetNbinsX() + i_binX] = hist_cnn_time->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time_first[i_binY*hist_cnn_time_first->GetNbinsX() + i_binX] = hist_cnn_time_first->GetBinContent(i_binX+1,i_binY+1); + } + } + } + else if (save_mode == "PMT-wise" || save_mode == "Static") { + for (int i_binY=0; i_binY < hist_cnn_pmtwise->GetNbinsY();i_binY++) { + for (int i_binX=0; i_binX < hist_cnn_pmtwise->GetNbinsX();i_binX++) { + cnn_image_charge[i_binY*hist_cnn_pmtwise->GetNbinsX() + i_binX] = hist_cnn_pmtwise->GetBinContent(i_binX+1,i_binY+1); + cnn_image_charge_abs[i_binY*hist_cnn_abs_pmtwise->GetNbinsX() + i_binX] = hist_cnn_abs_pmtwise->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time[i_binY*hist_cnn_time_pmtwise->GetNbinsX() + i_binX] = hist_cnn_time_pmtwise->GetBinContent(i_binX+1,i_binY+1); + cnn_image_time_first[i_binY*hist_cnn_time_first_pmtwise->GetNbinsX() + i_binX] = hist_cnn_time_first_pmtwise->GetBinContent(i_binX+1,i_binY+1); + } } } - outfile_lappd << std::endl; - outfile_lappd_abs << std::endl; - outfile_lappd_time << std::endl; - outfile_lappd_time_first << std::endl; - outfile_lappd_time_abs << std::endl; - outfile_lappd_time_first_abs << std::endl; } - outfile << std::endl; - outfile_abs << std::endl; - outfile_time << std::endl; - outfile_time_first << std::endl; - outfile_time_abs << std::endl; - outfile_time_first_abs << std::endl; + + m_data->Stores.at("RecoEvent")->Set("CNNImageCharge", cnn_image_charge); + m_data->Stores.at("RecoEvent")->Set("CNNImageChargeAbs", cnn_image_charge_abs); + m_data->Stores.at("RecoEvent")->Set("CNNImageTime", cnn_image_time); + m_data->Stores.at("RecoEvent")->Set("CNNImageTimeFirst", cnn_image_time_first); } - //Delete histograms after accessing them - delete hist_cnn; - delete hist_cnn_abs; - delete hist_cnn_time; - delete hist_cnn_time_first; - delete hist_cnn_time_abs; - delete hist_cnn_time_first_abs; - delete hist_cnn_pmtwise; - delete hist_cnn_abs_pmtwise; - delete hist_cnn_time_pmtwise; - delete hist_cnn_time_first_pmtwise; - delete hist_cnn_time_abs_pmtwise; - delete hist_cnn_time_first_abs_pmtwise; + //TODO: Delete histograms after accessing them -> resetting instead of recreating for (unsigned int i_lappd=0; i_lappdClose(); - outfile.close(); - outfile_abs.close(); - outfile_time.close(); - outfile_time_first.close(); - outfile_time_abs.close(); - outfile_time_first_abs.close(); - outfile_lappd.close(); - outfile_lappd_abs.close(); - outfile_lappd_time.close(); - outfile_lappd_time_first.close(); - outfile_lappd_time_abs.close(); - outfile_lappd_time_first_abs.close(); - outfile_Rings.close(); - outfile_MRD.close(); + if (write_to_file) { + + delete hist_cnn; + delete hist_cnn_abs; + delete hist_cnn_time; + delete hist_cnn_time_first; + delete hist_cnn_time_abs; + delete hist_cnn_time_first_abs; + delete hist_cnn_pmtwise; + delete hist_cnn_abs_pmtwise; + delete hist_cnn_time_pmtwise; + delete hist_cnn_time_first_pmtwise; + delete hist_cnn_time_abs_pmtwise; + delete hist_cnn_time_first_abs_pmtwise; + + file->Close(); + outfile.close(); + outfile_abs.close(); + outfile_time.close(); + outfile_time_first.close(); + outfile_time_abs.close(); + outfile_time_first_abs.close(); + outfile_lappd.close(); + outfile_lappd_abs.close(); + outfile_lappd_time.close(); + outfile_lappd_time_first.close(); + outfile_lappd_time_abs.close(); + outfile_lappd_time_first_abs.close(); + outfile_Rings.close(); + outfile_MRD.close(); + } return true; } @@ -986,57 +936,411 @@ void CNNImage::ConvertPositionTo2D(Position xyz_pos, double &x, double &y){ } void CNNImage::ConvertPositionTo2D_Top(Position xyz_pos, double &x, double &y){ - double rho = sqrt(xyz_pos.X()*xyz_pos.X()+xyz_pos.Z()*xyz_pos.Z()); - if (rho < 0.8) y = 0.9; - else y = 0.8; + + // set different y value depending on whether PMT is in the innermost constellation + if (rho < 0.8) { + y = 0.9; + } else { + y = 0.8; + } double phi = 0.; - if (xyz_pos.X()>0 && xyz_pos.Z()>0) phi = atan(xyz_pos.Z()/xyz_pos.X())+TMath::Pi()/2; - else if (xyz_pos.X()>0 && xyz_pos.Z()<0) phi = atan(xyz_pos.X()/-xyz_pos.Z()); - else if (xyz_pos.X()<0 && xyz_pos.Z()<0) phi = 3*TMath::Pi()/2+atan(xyz_pos.Z()/xyz_pos.X()); - else if (xyz_pos.X()<0 && xyz_pos.Z()>0) phi = TMath::Pi()+atan(-xyz_pos.X()/xyz_pos.Z()); - else if (fabs(xyz_pos.X())<0.0001){ - if (xyz_pos.Z()>0) phi = TMath::Pi(); - else if (xyz_pos.Z()<0) phi = 2*TMath::Pi(); - } - else if (fabs(xyz_pos.Z())<0.0001){ - if (xyz_pos.X()>0) phi = 0.5*TMath::Pi(); - else if (xyz_pos.X()<0) phi = 3*TMath::Pi()/2; - } - else phi = 0.; - if (phi>2*TMath::Pi()) phi-=(2*TMath::Pi()); - phi-=TMath::Pi(); - if (phi < - TMath::Pi()) phi = -TMath::Pi(); - if (phi<-TMath::Pi() || phi>TMath::Pi()) std::cout <<"Drawing Event: Phi out of bounds! "<<", x= "<ChannelToDetector(chankey); + if (apmt->GetTankLocation()=="OD") continue; //don't include OD PMTs + + // don't include top/bottom PMTs if specified + if ((y_pmt[detkey] >= max_y-0.001 || y_pmt[detkey] <= min_y+0.001) && !includeTopBottom) continue; + if (y_pmt[detkey] >= max_y-0.001) { + ConvertPositionTo2D_Top(pmt_pos, x, y); + } + else if (y_pmt[detkey] <= min_y+0.001) { + ConvertPositionTo2D_Bottom(pmt_pos, x, y); + } + else { + ConvertPositionTo2D(pmt_pos, x, y); + } + x = (round(100*x)/100.); + y = (round(100*y)/100.); + + if (y_pmt[detkey] >= max_y-0.001) { + vec_pmt2D_x_Top.push_back(x); + } else if (y_pmt[detkey] <= min_y+0.001) { + vec_pmt2D_x_Bottom.push_back(x); + } else { + vec_pmt2D_x.push_back(x); + } + + vec_pmt2D_y.push_back(y); + + Log("CNNImage tool: Detkey "+std::to_string(detkey)+", x (2D): "+std::to_string(x)+", y (2D): "+std::to_string(y),v_message,verbosity); + } + + //Sort the positions (in x & y separately) + Log("CNNImage tool: vec_pmt2D_* size: "+std::to_string(vec_pmt2D_x.size()),v_message,verbosity); + std::sort(vec_pmt2D_x.begin(),vec_pmt2D_x.end()); + std::sort(vec_pmt2D_y.begin(),vec_pmt2D_y.end()); + std::sort(vec_pmt2D_x_Top.begin(),vec_pmt2D_x_Top.end()); + std::sort(vec_pmt2D_x_Bottom.begin(),vec_pmt2D_x_Bottom.end()); + vec_pmt2D_x.erase(std::unique(vec_pmt2D_x.begin(),vec_pmt2D_x.end()),vec_pmt2D_x.end()); + vec_pmt2D_y.erase(std::unique(vec_pmt2D_y.begin(),vec_pmt2D_y.end()),vec_pmt2D_y.end()); + vec_pmt2D_x_Top.erase(std::unique(vec_pmt2D_x_Top.begin(),vec_pmt2D_x_Top.end()),vec_pmt2D_x_Top.end()); + vec_pmt2D_x_Bottom.erase(std::unique(vec_pmt2D_x_Bottom.begin(),vec_pmt2D_x_Bottom.end()),vec_pmt2D_x_Bottom.end()); + + //Output sorted positions + if (verbosity >= v_message){ + std::cout <<"Sorted 2D position vectors: Barrel x "< >* Detectors) { + if (!isData && use_LAPPDs){ + max_y_lappd = -100.; + min_y_lappd = 100.; + + for (std::map::iterator it = Detectors->at("LAPPD").begin(); + it != Detectors->at("LAPPD").end(); + ++it) { + Detector* anlappd = it->second; + unsigned long detkey = it->first; + lappd_detkeys.push_back(detkey); + unsigned long chankey = anlappd->GetChannels()->begin()->first; + Position position_LAPPD = anlappd->GetDetectorPosition(); + x_lappd.insert(std::pair(detkey,position_LAPPD.X()-tank_center_x)); + y_lappd.insert(std::pair(detkey,position_LAPPD.Y()-tank_center_y)); + z_lappd.insert(std::pair(detkey,position_LAPPD.Z()-tank_center_z)); + if (y_lappd[detkey]>max_y_lappd) max_y_lappd = y_lappd.at(detkey); + if (y_lappd[detkey] >* Detectors) { + for ( + std::map::iterator it = Detectors->at("Tank").begin(); + it != Detectors->at("Tank").end(); + ++it + ) { + Detector* apmt = it->second; + unsigned long detkey = it->first; + pmt_detkeys.push_back(detkey); + unsigned long chankey = apmt->GetChannels()->begin()->first; + pmt_chankeys.push_back(chankey); + Position position_PMT = apmt->GetDetectorPosition(); + + x_pmt.insert(std::pair(detkey, position_PMT.X() - tank_center_x)); + y_pmt.insert(std::pair(detkey, position_PMT.Y() - tank_center_y)); + z_pmt.insert(std::pair(detkey, position_PMT.Z() - tank_center_z)); + + if (y_pmt[detkey]>max_y && apmt->GetTankLocation()!="OD") max_y = y_pmt.at(detkey); + if (y_pmt[detkey]GetTankLocation()!="OD") min_y = y_pmt.at(detkey); + + //Some debug information + Log("CNNImage tool: Reading in detkey: " + std::to_string(detkey) + ", chankey: " + std::to_string(chankey) \ + + ", position: (" + std::to_string(position_PMT.X()) + "," + std::to_string(position_PMT.Y()) + "," \ + + std::to_string(position_PMT.Z()) + ")", v_debug, verbosity); + Log("CNNImage tool: Rho PMT: " \ + + std::to_string(sqrt(x_pmt.at(detkey)*x_pmt.at(detkey)+z_pmt.at(detkey)*z_pmt.at(detkey))) \ + + ", y PMT: " + std::to_string(y_pmt.at(detkey)), v_debug, verbosity); + } + + Log("CNNImage tool: Max/min y-dimensions of PMT volume: Max y = " + std::to_string(max_y) + ", min y = " \ + + std::to_string(min_y), v_message, verbosity); +} + + +void CNNImage::OrderLAPPDPositions() { + for (unsigned int i_lappd = 0; i_lappd < y_lappd.size(); i_lappd++){ + double x,y; + unsigned long detkey = lappd_detkeys[i_lappd]; + Position lappd_pos(x_lappd[detkey],y_lappd[detkey],z_lappd[detkey]); + if (y_lappd[detkey] >= max_y || y_lappd[detkey] <= min_y) continue; //don't include top/bottom/OD PMTs for now + ConvertPositionTo2D(lappd_pos, x, y); + vec_lappd2D_x.push_back(x); + vec_lappd2D_y.push_back(y); + Log("CNNImage tool: Detkey "+std::to_string(detkey)+", x (2D): "+std::to_string(x)+", y (2D): " \ + + std::to_string(y),v_message,verbosity); + } + + //Sort LAPPD positions + Log("CNNImage tool: vec_lappd2D_* size: "+std::to_string(vec_lappd2D_x.size()),v_message,verbosity); + std::sort(vec_lappd2D_x.begin(),vec_lappd2D_x.end()); + std::sort(vec_lappd2D_y.begin(),vec_lappd2D_y.end()); + vec_lappd2D_x.erase(std::unique(vec_lappd2D_x.begin(),vec_lappd2D_x.end()),vec_lappd2D_x.end()); + vec_lappd2D_y.erase(std::unique(vec_lappd2D_y.begin(),vec_lappd2D_y.end()),vec_lappd2D_y.end()); + + //Output the sorted positions + if (verbosity >= v_message){ + std::cout << "CMMImage tool: Sorted LAPPD 2D position vectors: x-values: " << std::endl; + for (unsigned int i_x = 0; i_x < vec_lappd2D_x.size(); i_x++) { + std::cout << i_x << ": " << vec_lappd2D_x.at(i_x) << std::endl; + } + std::cout << "CMMImage tool: Sorted LAPPD 2D position vectors: y-values: " << std::endl; + for (unsigned int i_y = 0; i_y < vec_lappd2D_y.size(); i_y++) { + std::cout << i_y << ": " << vec_lappd2D_y.at(i_y) << std::endl; + } + } +} + +void CNNImage::StaticPMTBinning(std::map > &m) { + // Each vertical PMT layer gets binned into its own layer, top and bottom PMTs get two. Inner PMTs on top and bottom + // make up the 0-th and 9-th layer/row + const std::vector vertical_bins = {-180.0, -160.0, -125.0, -75.0, -30.0, 10.0, 30, 75.0, 130.0}; + std::vector phi_bins; + for (int i = 0; i < 17; i++) { + phi_bins.push_back(i * 2 * TMath::Pi() / 16); //16 bins for 16 PMTs next to eachother + } + + for (unsigned int d = 0; d < pmt_detkeys.size(); d++) { + // go to cm for these calculations + auto xpos = 100 * x_pmt[pmt_detkeys[d]]; + auto ypos = 100 * y_pmt[pmt_detkeys[d]]; + auto zpos = 100 * z_pmt[pmt_detkeys[d]]; + + auto vbin_it = std::lower_bound(vertical_bins.begin(), vertical_bins.end(), ypos); + auto calculated_ybin = std::distance(vertical_bins.begin(), vbin_it) - 1; + + auto rho = TMath::Sqrt(xpos*xpos + zpos*zpos); + double phi = 0.0; + + //get phi within the z/x plane + if (zpos >= 0) { + phi = TMath::ACos(xpos / rho); + } else { + phi = 2 * TMath::Pi() - TMath::ACos(xpos / rho); + } + + /* + * The downstream direction should be in the center of all bins, which is at an angle of pi. Thus we transform + * phi -> phi + pi/2 + * and map all values back into the [0, 2pi] interval. + */ + phi = phi + TMath::Pi() / 2; + if (phi > 2*TMath::Pi()) { + phi = phi - 2*TMath::Pi(); + } + + auto hbin_it = std::lower_bound(phi_bins.begin(), phi_bins.end(), phi); + int calculated_xbin = std::distance(phi_bins.begin(), hbin_it) - 1; + + // radius of inner 4 bottom PMT centers is approx. 35 cm + if (calculated_ybin == 1) { + if (TMath::Sqrt(xpos * xpos + zpos * zpos) < 35) { + calculated_ybin = 0; + } + } + + // radius of inner 4 top PMT centers is approx. 50 cm + if (calculated_ybin == 8) { + if (TMath::Sqrt(xpos * xpos + zpos * zpos) < 50) { + calculated_ybin = 9; + } + } + + //std::cout << xpos << " " << ypos << " " << zpos << " " << phi << "\n"; + std::cout << pmt_detkeys[d] << " " << calculated_xbin << " " << calculated_ybin<< "\n"; + m[pmt_detkeys[d]] = std::make_pair(calculated_xbin, calculated_ybin); + } + +} + +void CNNImage::GeometricPMTBinning(std::map > &m, TH2F *geometric_hist) { + /* + Geometric binning uses dynamic scale of histogram, defined at execution time via the config file. A simple way of + getting correct x/y binning is to simply define the histogram with the physical dimensions of the tank (vertical + and angular coordinates, y and phi), then having root compute the binning. Since this only has to be computed once + at the initialization of the tool, this is ok. + */ + for (unsigned int d = 0; d < pmt_detkeys.size(); d++) { + auto detkey = pmt_detkeys[d]; + double x,y; + Position pmt_pos(x_pmt[detkey], y_pmt[detkey], z_pmt[detkey]); + ConvertPositionTo2D(pmt_pos, x, y); + + //Get corresponding geometric-mode bins for 2D (x,y)-position + int binx_geometric = geometric_hist->GetXaxis()->FindBin(x); + int biny_geometric = geometric_hist->GetYaxis()->FindBin(y); + + m[detkey] = std::make_pair(binx_geometric, biny_geometric); + } +} + +void CNNImage::ReadoutMRD() { + if(MrdTimeClusters.size()==0){ + //No entries in MrdTimeClusters object, don't read out anything + Log("CNNImage tool: No MRDClusters entries.",v_message,verbosity); + } else { + std::vector> mrd_hits; + for (int i_layer=0; i_layer<11; i_layer++){ + std::vector empty_hits; + mrd_hits.push_back(empty_hits); + } + std::vector temp_cons_layers; + for (int i_cluster=0; i_cluster < (int) MrdTimeClusters.size(); i_cluster++){ + if (i_cluster > 0) continue; //only evaluate first cluster, if there are multiple + std::vector single_cluster = MrdTimeClusters.at(i_cluster); + for (int i_pmt = 0; i_pmt < (int) single_cluster.size(); i_pmt++){ + int idigit = single_cluster.at(i_pmt); + unsigned long chankey = mrddigitchankeysthisevent.at(idigit); + Detector *thedetector = geom->ChannelToDetector(chankey); + if(thedetector->GetDetectorElement()!="MRD") { + continue; // this is a veto hit, not an MRD hit. } - else phi = 0.; - if (phi>2*TMath::Pi()) phi-=(2*TMath::Pi()); - phi-=TMath::Pi(); - if (phi < - TMath::Pi()) phi = -TMath::Pi(); - if (phi<-TMath::Pi() || phi>TMath::Pi()) std::cout <<"Drawing Event: Phi out of bounds! "<<", x= "< #include +#include +#include + +#include #include "TH2F.h" #include "TMath.h" @@ -12,9 +16,11 @@ /** - * \class CNNImage - * - * The tool CNNImage is supposed to create custom csv input files for CNN classification processes. The framework relies on the EventDisplay tool and basically feeds that geometric information of the hit pattern into a matrix format +* \class CNNImage +* +* The tool CNNImage is supposed to create custom csv input files for CNN classification processes. +* The framework relies on the EventDisplay tool and basically feeds that geometric information of the hit pattern +* into a matrix format * * $Author: M.Nieslony $ * $Date: 2019/08/09 10:44:00 $ @@ -22,8 +28,6 @@ */ class CNNImage: public Tool { - - public: CNNImage(); ///< constructor for CNNImage class @@ -35,6 +39,18 @@ class CNNImage: public Tool { void ConvertPositionTo2D_Top(Position xyz_pos, double &x, double &y); /// >* Detectors); + void OrderPMTPositions(); + + void GetLAPPDPositions(std::map >* Detectors); + void OrderLAPPDPositions(); + + void StaticPMTBinning(std::map >&m); + void GeometricPMTBinning(std::map > &m, TH2F *geometric_hist); + + void ReadoutMRD(); + + void PopulateHistInFilePMT(ofstream &outfile, TH2F* hist, int binX, int binY); private: @@ -43,13 +59,20 @@ class CNNImage: public Tool { std::string detector_config; std::string data_mode; //Charge, Time std::string save_mode; //How is the PMT information supposed to be written out? Geometric/PMT-wise + bool use_LAPPDs; + bool write_to_file; int dimensionX; //dimension of the CNN image in x-direction int dimensionY; //dimension of the CNN image in y-direction int dimensionLAPPD; //dimension of LAPPD CNN images (both directions, square) bool includeTopBottom; - bool isData; + + std::map > static_pmt_mapping; + std::map > geometric_pmt_mapping; + + bool isData; int verbosity; + // ANNIEEvent variables int runnumber; int subrunnumber; @@ -71,6 +94,20 @@ class CNNImage: public Tool { // RecoEvent variables int nrings; + // Hists + TH2F *hist_cnn; + TH2F *hist_cnn_abs; + TH2F *hist_cnn_time; + TH2F *hist_cnn_time_first; + TH2F *hist_cnn_time_abs; + TH2F *hist_cnn_time_first_abs; + TH2F *hist_cnn_pmtwise; + TH2F *hist_cnn_abs_pmtwise; + TH2F *hist_cnn_time_pmtwise; + TH2F *hist_cnn_time_first_pmtwise; + TH2F *hist_cnn_time_abs_pmtwise; + TH2F *hist_cnn_time_first_abs_pmtwise; + // Geometry variables double tank_radius; double tank_height; @@ -98,6 +135,15 @@ class CNNImage: public Tool { double min_time_pmts, max_time_pmts, min_time_lappds, max_time_lappds; double min_time_first_pmts, max_time_first_pmts, min_time_first_lappds, max_time_first_lappds; + // MRD information + int num_mrd_paddles_cluster=0; + int num_mrd_layers_cluster=0; + int num_mrd_conslayers_cluster=0; + int num_mrd_adjacent_cluster=0; + double mrd_padperlayer_cluster=0.; + bool layer_occupied_cluster[11] = {0}; + double mrd_paddlesize_cluster[11]; + // Detectorkey layout organization std::map channelkey_to_pmtid; std::map pmt_tubeid_to_channelkey; diff --git a/UserTools/CNNImage/README.md b/UserTools/CNNImage/README.md index 463d1a70d..1eb1ada4d 100644 --- a/UserTools/CNNImage/README.md +++ b/UserTools/CNNImage/README.md @@ -1,26 +1,89 @@ # CNNImage -CNNImage creates ANNIE event display information in a csv-file format that can directly be loaded into Machine Learning classifier frameworks like CNNs for image classification purposes. Currently only PMT information from the side PMTs is loaded, no information from the top/bottom PMTs and LAPPDs is used. +CNNImage creates ANNIE event display information in matrix format that +can directly be loaded and used by Machine Learning classifier frameworks like CNNs for image/event +classification purposes. Currently only PMT information is loaded, no information from the LAPPDs is used. + +The event display created by this tool is given in a rectangular format (static mapping mode: 16x10, +geometric mapping mode: user-defined shape), and produces normalized and absolute charge and time +(time of first hit, and average hit time) maps that are stored in boost stores or may be written +to csv files. ## Data -CNNImage creates multiple `.csv`-files and one `.root`-file. Each csv-file contains the event display information in single rows per event for a specific event type (PMTs/LAPPDs, charge/time), whereas the root-file provides the same information in a 2D histogram format. +CNNImage creates multiple `.csv`-files and one `.root`-file, when `WriteToFile` +is set to 1 in the config file. Each csv-file contains the event display information in single rows +per event for a specific event type (PMTs/LAPPDs, charge/time), whereas the root-file provides the +same information in a 2D histogram format, where each event gets its own histogram. + +The PMT data can be written Static mode, with a pre-defined mapping (16x10 Matrix) or Geometric mode +(every pixel is defined by its geometric location, if a PMT happens to be within the pixel its value +is added to the pixel value, PMTs can overlap. Top and bottom caps are given by circles and not +squished into rows). The configuration variables `DimensionX` and `DimensionY` hence only apply when +using the `Geometric` save mode and not for the `Static` save mode. + +LAPPDs are not yet supported in the static mapping. Further, static mapping does not support +dynamically resizing the output matrix size. + +The `DataMode` configuration specifies whether the average hit time per PMT is calculated as a simple +mean (`Normal`) or weighted by the charge (`Charge`). -The PMT data can be written PMT-wise (every pixel is reserved for just 1 PMT, no spaces in between) or geometrically (every pixel is defined by its geometric location, if a PMT happens to be within the pixel its value is added to the pixel value). The configuration variables `DimensionX` and `DimensionY` hence only apply when using the `Geometric` save mode and not for the `PMT-wise` save mode. The dimensions for the `PMT-wise` save mode are simply given by the number of PMTs in x- and y-direction. When choosing `PMT-wise`, the LAPPD information is also saved per LAPPD in a 20x20cm grid. +## Boost store +The following data are provided within the RecoEvent boost store +``` +m_data->Stores.at("RecoEvent")->Set("CNNImageCharge", cnn_image_charge); +m_data->Stores.at("RecoEvent")->Set("CNNImageChargeAbs", cnn_image_charge_abs); +m_data->Stores.at("RecoEvent")->Set("CNNImageTime", cnn_image_time); +m_data->Stores.at("RecoEvent")->Set("CNNImageTimeFirst", cnn_image_time_first); +``` +where the images are implemented as +``` +std::vector cnn_image_charge(cnn_image_size, 0); +``` -The `DataMode` configuration specifies whether the average hit time per PMT is calculated as a simple mean (`Normal`) or weighted by the charge (`Charge-Weighted`). +## Binning in Static mapping mode +The Static PMT binning is defined in the `CNNImage::StaticPMTBinning` method. The vertical (y) and +horizontal (x/phi) binning is implemented (in detector coordinates) as +``` +const std::vector vertical_bins = {-180.0, -160.0, -125.0, -75.0, -30.0, 10.0, 30, 75.0, 130.0}; +std::vector phi_bins; + for (int i = 0; i < 17; i++) { + phi_bins.push_back(i * 2 * TMath::Pi() / 16); //16 bins for 16 PMTs next to eachother +} +``` +The bottom and top PMTs are split into two rows, where the inner circle of the tank top PMTs correspond +to the first row, the inner circle of the tank bottom PMTs correspond to the last row in the produced +output. +## Prerequisites +The tool needs the following tools to be loaded at some point beforehand: +``` +MCParticleProperties +MCRecoEventLoader +ClusterFinder +DigitBuilder +TimeClustering +EventSelector +EnergyExtractor +``` ## Configuration -CNNImage uses the following configuration variables: +CNNImage uses the following recommended configuration variables: ``` -verbosity 1 -DataMode Normal #options: Normal / Charge-Weighted -SaveMode Geometric #options: Geometric / PMT-wise -DimensionX 16 #choose something suitable (32/64/...) -DimensionY 20 #choose something suitable (32/64/...) -OutputFile beam_test0 #csv file name -DetectorConf ANNIEp2v6 #specify the detector version used in simulation +verbosity 0 +DataMode Normal #options: Charge/Time/Normal +SaveMode Static #options: Static / Geometric +DimensionX 16 #choose something suitable (32/64/...) Relevant only for geometric mode +DimensionY 10 #choose something suitable (32/64/...) +OutputFile your_base_name #base name of output files, if WriteToFile == 1 + +DimensionLAPPD 5 #Size of the LAPPD pannal +IncludeTopBottom 1 #Whether top and bottom should be included + #IncludeTopBottom is only relevant for geometric mode +DetectorConf ANNIEp2v7 +useLAPPDs 0 +WriteToFile 0 + ``` diff --git a/configfiles/CNNImage/CNNImage_Data/CNNImageConfig b/configfiles/CNNImage/CNNImage_Data/CNNImageConfig old mode 100644 new mode 100755 index b1a41ff86..8ce3325dd --- a/configfiles/CNNImage/CNNImage_Data/CNNImageConfig +++ b/configfiles/CNNImage/CNNImage_Data/CNNImageConfig @@ -1,12 +1,14 @@ # CNNImage config file -verbosity 1 -DataMode Normal #options: Charge/Time -SaveMode PMT-wise #options: Geometric / PMT-wise +verbosity 0 +DataMode Normal #options: Normal / Charge-Weighted / TimeEvolution +SaveMode Static #options: Static / Geometric DimensionX 16 #choose something suitable (32/64/...) -DimensionY 20 #choose something suitable (32/64/...) -OutputFile R1613p1_CNNImage -DimensionLAPPD 5 # Size of the LAPPD pannal +DimensionY 10 #choose something suitable (32/64/...) +OutputFile CNNImage_data_testData +useLAPPDs 0 +DimensionLAPPD 5 #Size of the LAPPD pannal IncludeTopBottom 1 -DetectorConf ANNIEp2v6 #specify the detector version used in simulation -IsData 1 #IsData: 0/1 +DetectorConf ANNIEp2v7 #specify the detector version used in simulation +IsData 1 +WriteToFile 0 diff --git a/configfiles/CNNImage/CNNImage_MC/CNNImageConfig b/configfiles/CNNImage/CNNImage_MC/CNNImageConfig old mode 100644 new mode 100755 index c26b60e88..be9855b4a --- a/configfiles/CNNImage/CNNImage_MC/CNNImageConfig +++ b/configfiles/CNNImage/CNNImage_MC/CNNImageConfig @@ -1,11 +1,15 @@ # CNNImage config file -verbosity 0 -DataMode Normal #options: Charge/Time -SaveMode PMT-wise #options: Geometric / PMT-wise +verbosity 1 +IsData 0 +DataMode Normal #options: Normal / Charge-Weighted / TimeEvolution +SaveMode Static #options: Static / Geometric DimensionX 16 #choose something suitable (32/64/...) -DimensionY 20 #choose something suitable (32/64/...) -OutputFile test_beam_lappd5x5_0 -DimensionLAPPD 5 # Size of the LAPPD pannal +DimensionY 32 #choose something suitable (32/64/...) +OutputFile ./test_output_cnnimageNM_geometric +DimensionLAPPD 5 #Size of the LAPPD pannal IncludeTopBottom 1 -DetectorConf ANNIEp2v6 #specify the detector version used in simulation +DetectorConf ANNIEp2v7 #specify the detector version used in simulation +useLAPPDs 0 +WriteToFile 1 +