diff --git a/sbndcode/CRT/CRTEventDisplay/CMakeLists.txt b/sbndcode/CRT/CRTEventDisplay/CMakeLists.txt index 0a8aa82af..c245b2729 100644 --- a/sbndcode/CRT/CRTEventDisplay/CMakeLists.txt +++ b/sbndcode/CRT/CRTEventDisplay/CMakeLists.txt @@ -13,4 +13,9 @@ simple_plugin( sbndcode_CRT_CRTEventDisplay ) +simple_plugin( + CRTChannelMappingEventDisplay module + sbndcode_CRT_CRTEventDisplay +) + install_fhicl() diff --git a/sbndcode/CRT/CRTEventDisplay/CRTChannelMappingEventDisplay_module.cc b/sbndcode/CRT/CRTEventDisplay/CRTChannelMappingEventDisplay_module.cc new file mode 100644 index 000000000..cfa00cd45 --- /dev/null +++ b/sbndcode/CRT/CRTEventDisplay/CRTChannelMappingEventDisplay_module.cc @@ -0,0 +1,89 @@ +//////////////////////////////////////////////////////////////////////// +// Class: CRTChannelMappingEventDisplay +// Plugin Type: analyzer (Unknown Unknown) +// File: CRTChannelMappingEventDisplay_module.cc +// +// Generated at Thu Oct 6 09:32:09 2022 by Henry Lay using cetskelgen +// from version . +//////////////////////////////////////////////////////////////////////// + +#include "art/Framework/Core/EDAnalyzer.h" +#include "art/Framework/Core/ModuleMacros.h" +#include "art/Framework/Principal/Event.h" +#include "art/Framework/Principal/Handle.h" +#include "art/Framework/Principal/Run.h" +#include "art/Framework/Principal/SubRun.h" +#include "canvas/Utilities/InputTag.h" +#include "fhiclcpp/ParameterSet.h" +#include "messagefacility/MessageLogger/MessageLogger.h" + +#include "lardata/DetectorInfoServices/DetectorClocksService.h" +#include "sbndcode/CRT/CRTEventDisplay/CRTEventDisplayAlg.h" + +#include "TSystem.h" + +namespace sbnd::crt { + class CRTChannelMappingEventDisplay; +} + +class sbnd::crt::CRTChannelMappingEventDisplay : public art::EDAnalyzer { +public: + + struct Config { + using Name = fhicl::Name; + using Comment = fhicl::Comment; + + fhicl::Table EventDisplayConfig { + Name("EventDisplayConfig"), + }; + + fhicl::Atom SaveDir { + Name("SaveDir"), + }; + }; + + using Parameters = art::EDAnalyzer::Table; + + explicit CRTChannelMappingEventDisplay(Parameters const &config); + + CRTChannelMappingEventDisplay(CRTChannelMappingEventDisplay const&) = delete; + CRTChannelMappingEventDisplay(CRTChannelMappingEventDisplay&&) = delete; + CRTChannelMappingEventDisplay& operator=(CRTChannelMappingEventDisplay const&) = delete; + CRTChannelMappingEventDisplay& operator=(CRTChannelMappingEventDisplay&&) = delete; + + void analyze(art::Event const& e) override; + +private: + + CRTEventDisplayAlg fCRTEventDisplayAlg; + art::ServiceHandle fCRTGeoService; + std::string fSaveDir; + std::vector fChosenTaggers; +}; + + +sbnd::crt::CRTChannelMappingEventDisplay::CRTChannelMappingEventDisplay(Parameters const& config) + : EDAnalyzer{config} + , fCRTEventDisplayAlg(config().EventDisplayConfig()) + , fSaveDir(config().SaveDir()) + , fChosenTaggers(config().EventDisplayConfig().ChosenTaggers()) + { + gSystem->Exec(Form("mkdir -p %s", fSaveDir.c_str())); + } + +void sbnd::crt::CRTChannelMappingEventDisplay::analyze(art::Event const& e) +{ + auto const clockData = art::ServiceHandle()->DataFor(e); + + for(auto const& [ name, module ] : fCRTGeoService->GetModules()) + { + if(std::find(fChosenTaggers.begin(), fChosenTaggers.end(), CRTCommonUtils::GetTaggerEnum(module.taggerName)) == fChosenTaggers.end()) + continue; + + fCRTEventDisplayAlg.SetHighlightedModules({module.adID}); + + fCRTEventDisplayAlg.Draw(clockData, e, Form("%s/%s", fSaveDir.c_str(), name.c_str())); + } +} + +DEFINE_ART_MODULE(sbnd::crt::CRTChannelMappingEventDisplay) diff --git a/sbndcode/CRT/CRTEventDisplay/build_tex.sh b/sbndcode/CRT/CRTEventDisplay/build_tex.sh new file mode 100644 index 000000000..235039478 --- /dev/null +++ b/sbndcode/CRT/CRTEventDisplay/build_tex.sh @@ -0,0 +1,83 @@ +version=$1 +gdml=$2 +author=$3 +email=$4 +basedir=$5 + +echo $version +echo $gdml +echo $author +echo $email +echo $basedir + +mkdir ${basedir}/tex_work + +echo "\documentclass{article} +\usepackage[a4paper, margin=3cm]{geometry} +\usepackage{graphicx} +\usepackage{pgffor} +\usepackage[hidelinks]{hyperref} + +\title{SBND CRT Channel Mapping Displays \\\\ \vspace{1em} \small \textit{Produced using} \texttt{sbndcode ${version}} \textit{\&} \texttt{${gdml}}} +\author{${author} \\\\ \small ${email}}" > ${basedir}/tex_work/crt_channel_mapping_evds.tex + +walls=(bottom south north west east toplow tophigh) +wallnames=(Bottom South North West East "Top Low" "Top High") + +for wall in "${walls[@]}" +do + list=$(ls ${basedir}/${wall}_wall/*_front.pdf) + echo -n "\newcommand*{\\"$wall"ids}{" >> ${basedir}/tex_work/crt_channel_mapping_evds.tex + + for item in ${list} + do + name=$(echo $item | cut -d '/' -f 10) + number=$(echo $name | cut -d '_' -f 2) + echo -n $number, >> ${basedir}/tex_work/crt_channel_mapping_evds.tex + done + + sed -i '$ s/.$//' ${basedir}/tex_work/crt_channel_mapping_evds.tex + echo "}" >> ${basedir}/tex_work/crt_channel_mapping_evds.tex +done + +echo "\begin{document} + +\maketitle + +\centering +\vspace{2em} + +\includegraphics[width=.6\textwidth]{/nashome/h/hlay/UOSLogo_Primary_Violet_RGB.png} +\vspace{2em} + +\includegraphics[width=.5\textwidth]{/nashome/h/hlay/sbnd_pride_transparent.png} +\flushleft +\newpage +\tableofcontents +\newpage +\section{Explanation} +This document contains a series of illustrations created using the \texttt{CRTEventDisplay} tool originally written by Tom Brooks \& heavily developed by myself. It shows the position of the various CRT modules according to the gdml file used in SBND simulation and reconstruction. The document is split into sections for the different tagger walls. For each module three illustrations are provided: front, top and side views. The axes show detector coordinates (X, Y and Z) and \`\`building coordinates\" (North, West and Up). The relevant module is shown in green. The TPCs are shown in grey in the centre for reference. The black outer is the full tagger wall. The thin grey are other modules in the wall. The red is the FEB position and the blue corresponds to the end of the FEB with channel 0 (the ethernet ports). +" >> ${basedir}/tex_work/crt_channel_mapping_evds.tex + +for i in "${!walls[@]}" +do + echo "\newpage +\section{${wallnames[i]} Wall} +\begingroup +\foreach \x in \\${walls[i]}ids +{ + \newpage + \subsection{volCRTModule\x\_\x} + \begin{center} + \includegraphics[width=.85\textwidth]{${basedir}/${walls[i]}_wall/volCRTModule\x_\x_front.pdf}\\\\ + \includegraphics[width=.85\textwidth]{${basedir}/${walls[i]}_wall/volCRTModule\x_\x_top.pdf}\\\\ + \includegraphics[width=.85\textwidth]{${basedir}/${walls[i]}_wall/volCRTModule\x_\x_side.pdf} + \end{center} +} +\endgroup" >> ${basedir}/tex_work/crt_channel_mapping_evds.tex +done + +echo "\end{document}" >> ${basedir}/tex_work/crt_channel_mapping_evds.tex + +pdflatex --shell-escape -output-directory ${basedir}/tex_work ${basedir}/tex_work/crt_channel_mapping_evds.tex +pdflatex --shell-escape -output-directory ${basedir}/tex_work ${basedir}/tex_work/crt_channel_mapping_evds.tex diff --git a/sbndcode/CRT/CRTEventDisplay/crteventdisplay_sbnd.fcl b/sbndcode/CRT/CRTEventDisplay/crteventdisplay_sbnd.fcl index 03f656d3b..a64ede384 100644 --- a/sbndcode/CRT/CRTEventDisplay/crteventdisplay_sbnd.fcl +++ b/sbndcode/CRT/CRTEventDisplay/crteventdisplay_sbnd.fcl @@ -4,14 +4,20 @@ BEGIN_PROLOG crteventdisplay_sbnd: { - EventDisplayConfig: @local::crteventdisplayalg_sbnd - module_type: "CRTEventDisplay" + EventDisplayConfig: @local::crteventdisplayalg_sbnd + module_type: "CRTEventDisplay" } crteventdisplay_sbnd_data: { - EventDisplayConfig: @local::crteventdisplayalg_sbnd_data - module_type: "CRTEventDisplay" + EventDisplayConfig: @local::crteventdisplayalg_sbnd_data + module_type: "CRTEventDisplay" +} + +crteventdisplay_sbnd_channel_mapping: +{ + EventDisplayConfig: @local::crteventdisplayalg_sbnd_channel_mapping + module_type: "CRTChannelMappingEventDisplay" } END_PROLOG diff --git a/sbndcode/CRT/CRTEventDisplay/crteventdisplayalg_sbnd.fcl b/sbndcode/CRT/CRTEventDisplay/crteventdisplayalg_sbnd.fcl index a2bc90e24..0f7a523c8 100644 --- a/sbndcode/CRT/CRTEventDisplay/crteventdisplayalg_sbnd.fcl +++ b/sbndcode/CRT/CRTEventDisplay/crteventdisplayalg_sbnd.fcl @@ -97,4 +97,28 @@ crteventdisplayalg_sbnd_data.UseTs0: true crteventdisplayalg_sbnd_data.MinTime: -1.5e6 crteventdisplayalg_sbnd_data.MaxTime: 1.5e6 +crteventdisplayalg_sbnd_channel_mapping: @local::crteventdisplayalg_sbnd + +crteventdisplayalg_sbnd_channel_mapping.MC: false +crteventdisplayalg_sbnd_channel_mapping.SaveRoot: false +crteventdisplayalg_sbnd_channel_mapping.SaveViews: true + +crteventdisplayalg_sbnd_channel_mapping.ChoseTaggers: true +crteventdisplayalg_sbnd_channel_mapping.HighlightModules: true + +crteventdisplayalg_sbnd_channel_mapping.DrawTaggers: true +crteventdisplayalg_sbnd_channel_mapping.DrawModules: true +crteventdisplayalg_sbnd_channel_mapping.DrawFEBs: true +crteventdisplayalg_sbnd_channel_mapping.DrawFEBEnds: true +crteventdisplayalg_sbnd_channel_mapping.DrawStrips: false +crteventdisplayalg_sbnd_channel_mapping.DrawTPC: true +crteventdisplayalg_sbnd_channel_mapping.DrawTrueTracks: false +crteventdisplayalg_sbnd_channel_mapping.DrawSimDeposits: false +crteventdisplayalg_sbnd_channel_mapping.DrawStripHits: false +crteventdisplayalg_sbnd_channel_mapping.DrawClusters: false +crteventdisplayalg_sbnd_channel_mapping.DrawSpacePoints: false +crteventdisplayalg_sbnd_channel_mapping.DrawTracks: false + +crteventdisplayalg_sbnd_channel_mapping.Print: false + END_PROLOG diff --git a/sbndcode/CRT/CRTEventDisplay/run_crteventdisplay_channel_mapping_all.fcl b/sbndcode/CRT/CRTEventDisplay/run_crteventdisplay_channel_mapping_all.fcl new file mode 100644 index 000000000..6da8eadc1 --- /dev/null +++ b/sbndcode/CRT/CRTEventDisplay/run_crteventdisplay_channel_mapping_all.fcl @@ -0,0 +1,53 @@ +#include "services_sbnd.fcl" +#include "particleinventoryservice.fcl" +#include "crteventdisplay_sbnd.fcl" +#include "crt_services_sbnd.fcl" + +process_name: CRTEventDisplay + +services: +{ + @table::sbnd_services + @table::crt_services_sbnd + ParticleInventoryService: @local::standard_particleinventoryservice + CRTChannelMapService: @local::crt_channel_map_no_inversion +} + +source: +{ + module_type: RootInput + maxEvents: -1 +} + +physics: +{ + analyzers: + { + crtevdbot: @local::crteventdisplay_sbnd_channel_mapping + crtevdsou: @local::crteventdisplay_sbnd_channel_mapping + crtevdnor: @local::crteventdisplay_sbnd_channel_mapping + crtevdwes: @local::crteventdisplay_sbnd_channel_mapping + crtevdeas: @local::crteventdisplay_sbnd_channel_mapping + crtevdtpl: @local::crteventdisplay_sbnd_channel_mapping + crtevdtph: @local::crteventdisplay_sbnd_channel_mapping + } + + ana: [ crtevdbot, crtevdsou, crtevdnor, crtevdwes, crtevdeas, crtevdtpl, crtevdtph ] + + end_paths: [ ana ] +} + +physics.analyzers.crtevdbot.SaveDir: "/YOUR/DIRECTORY/NAME/bottom_wall" +physics.analyzers.crtevdbot.EventDisplayConfig.ChosenTaggers: [ 0 ] +physics.analyzers.crtevdsou.SaveDir: "/YOUR/DIRECTORY/NAME/south_wall" +physics.analyzers.crtevdsou.EventDisplayConfig.ChosenTaggers: [ 1 ] +physics.analyzers.crtevdnor.SaveDir: "/YOUR/DIRECTORY/NAME/north_wall" +physics.analyzers.crtevdnor.EventDisplayConfig.ChosenTaggers: [ 2 ] +physics.analyzers.crtevdwes.SaveDir: "/YOUR/DIRECTORY/NAME/west_wall" +physics.analyzers.crtevdwes.EventDisplayConfig.ChosenTaggers: [ 3 ] +physics.analyzers.crtevdeas.SaveDir: "/YOUR/DIRECTORY/NAME/east_wall" +physics.analyzers.crtevdeas.EventDisplayConfig.ChosenTaggers: [ 4 ] +physics.analyzers.crtevdtpl.SaveDir: "/YOUR/DIRECTORY/NAME/toplow_wall" +physics.analyzers.crtevdtpl.EventDisplayConfig.ChosenTaggers: [ 5 ] +physics.analyzers.crtevdtph.SaveDir: "/YOUR/DIRECTORY/NAME/tophigh_wall" +physics.analyzers.crtevdtph.EventDisplayConfig.ChosenTaggers: [ 6 ] diff --git a/sbndcode/ChannelMaps/CRT/SBNDCRTChannelMap_v5_no_inversion.txt b/sbndcode/ChannelMaps/CRT/SBNDCRTChannelMap_v5_no_inversion.txt new file mode 100644 index 000000000..7e0478c14 --- /dev/null +++ b/sbndcode/ChannelMaps/CRT/SBNDCRTChannelMap_v5_no_inversion.txt @@ -0,0 +1,87 @@ +40 173 0 +41 172 0 +42 168 0 +43 170 0 +44 176 0 +45 59 0 +46 171 0 +47 61 0 +48 166 0 +49 169 0 +50 56 0 +51 60 0 +52 34 0 +53 33 0 +54 57 0 +55 24 0 +56 159 0 +57 153 0 +58 156 0 +59 152 0 +60 182 0 +61 158 0 +62 157 0 +63 136 0 +64 150 0 +65 151 0 +66 134 0 +67 135 0 +68 149 0 +69 58 0 +70 238 0 +71 155 0 +72 222 0 +73 220 0 +74 81 0 +75 85 0 +76 79 0 +77 206 0 +78 204 0 +79 200 0 +80 18 0 +81 132 0 +82 133 0 +83 162 0 +84 143 0 +85 131 0 +86 146 0 +87 147 0 +88 44 0 +89 160 0 +90 19 0 +91 202 0 +92 199 0 +93 197 0 +94 207 0 +95 203 0 +96 45 0 +97 198 0 +98 174 0 +99 148 0 +100 163 0 +101 164 0 +102 165 0 +103 80 0 +104 193 0 +105 42 0 +106 138 0 +107 130 0 +108 77 0 +109 78 0 +110 98 0 +111 97 0 +112 87 0 +113 95 0 +114 94 0 +115 93 0 +116 86 0 +117 83 0 +118 84 0 +119 104 0 +120 103 0 +121 102 0 +122 101 0 +123 100 0 +124 99 0 +125 90 0 +126 91 0 diff --git a/sbndcode/ChannelMaps/CRT/crt_channel_map_service_sbnd.fcl b/sbndcode/ChannelMaps/CRT/crt_channel_map_service_sbnd.fcl index a34f136cd..16e96b3bc 100644 --- a/sbndcode/ChannelMaps/CRT/crt_channel_map_service_sbnd.fcl +++ b/sbndcode/ChannelMaps/CRT/crt_channel_map_service_sbnd.fcl @@ -5,4 +5,9 @@ crt_channel_map_sbnd: FileName: "SBNDCRTChannelMap_Commissioning_v5.txt" } +crt_channel_map_no_inversion: +{ + FileName: "SBNDCRTChannelMap_v5_no_inversion.txt" +} + END_PROLOG