10 #include "art/Framework/Core/EDAnalyzer.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
20 #include "art/Framework/Services/Registry/ServiceHandle.h"
32 #include "art_root_io/TFileService.h"
50 #include "nusimdata/SimulationBase/MCParticle.h"
51 #include "nusimdata/SimulationBase/MCTruth.h"
75 void analyze(art::Event
const&
e)
override;
87 fHitLabel(
p.get<std::string>(
"HitLabel")),
88 fWireLabel(
p.get<std::string>(
"WireLabel"))
91 art::ServiceHandle<art::TFileService>
tfs;
93 std::vector<std::string>
planes {
"U",
"V",
"Y"};
94 std::vector<std::string> angles {
"abs(#theta) < 0.2",
"#theta < -0.2",
"#theta > 0.2"};
96 for (
unsigned i = 0; i < 3; i++) {
97 for (
unsigned j = 0; j < 3; j++) {
98 fSignal.emplace_back();
99 fSignal[j][i] = tfs->make<TH1D>((
"Signal " + angles[j] +
" " +
planes[i]).c_str(),
"Signal", 200, 0., 400.);
101 fNoise[i] = tfs->make<TH1D>((
"Noise " +
planes[i]).c_str(),
"Noise", 200, 0., 10.);
107 art::ServiceHandle<cheat::BackTrackerService> backtracker;
109 auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(ev);
112 const std::vector<simb::MCParticle> &mcparticle_list = *ev.getValidHandle<std::vector<simb::MCParticle>>(
"largeant");
114 art::Handle<std::vector<recob::Hit>> hit_handle;
115 ev.getByLabel(fHitLabel, hit_handle);
116 std::vector<art::Ptr<recob::Hit>> hits;
117 art::fill_ptr_vector(hits, hit_handle);
119 const simb::MCParticle *
muon = NULL;
122 for (
unsigned i = 0; i < mcparticle_list.size(); i++) {
123 if (mcparticle_list[i].PdgCode() == 13 && mcparticle_list[i].Process() ==
"primary") {
124 assert(muon == NULL);
125 muon = &mcparticle_list[i];
130 assert(muon != NULL);
132 std::cout <<
"Muon Momentum Theta: " << muon->Momentum().Theta() << std::endl;
133 std::cout <<
"Muon Momentum Phi: " << muon->Momentum().Phi() << std::endl;
137 if (
abs(muon->Momentum().Theta()) < 0.2) angle_bin = 0;
138 else if (muon->Momentum().Phi() < 0.) angle_bin = 1;
148 std::vector<art::Ptr<recob::Hit>> muon_hits = backtracker->TrackIdToHits_Ps(clock_data, muon->TrackId(), hits);
152 std::map<raw::ChannelID_t, float> amplitude_map;
154 for (art::Ptr<recob::Hit>
hit: muon_hits) {
155 if (!amplitude_map.count(
hit->Channel()) || amplitude_map.at(
hit->Channel()) <
hit->PeakAmplitude()) {
156 amplitude_map[
hit->Channel()] =
hit->PeakAmplitude();
161 for (
auto const &pair: amplitude_map) {
162 fSignal[angle_bin][geo->
View(pair.first)]->Fill(pair.second);
168 std::vector<raw::ChannelID_t> allChannels = geo->
ChannelsInTPCs();
170 std::set<raw::ChannelID_t> channelSet;
177 float length = wireGeo.
Length();
184 art::Handle<std::vector<sim::SimChannel>> simChannels;
185 ev.getByLabel(
"largeant", simChannels);
187 if (c.TDCIDEMap().size()) {
188 channelSet.erase(c.Channel());
193 art::Handle<std::vector<recob::Wire>> wires;
194 ev.getByLabel(fWireLabel, wires);
197 if (!channelSet.count(wire.Channel()))
continue;
203 for (
float v: range) {
208 float noise = sqrt(rms_sum / ncount);
210 fNoise[geo->
View(wire.Channel())]->Fill(noise);
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Utilities related to art service access.
Energy deposited on a readout channel by simulated tracks.
Declaration of signal hit object.
double Length() const
Returns the wire length in centimeters.
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
void analyze(art::Event const &e) override
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
std::vector< std::array< TH1D *, 3 > > fSignal
Access the description of detector geometry.
Signal from induction planes.
Description of geometry of one entire detector.
Declaration of cluster object.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Provides recob::Track data product.
Provides a base class aware of world box coordinates.
WireGeo const & Wire(geo::WireID const &wireid) const
Returns the specified wire.
MuonS2NStudy & operator=(MuonS2NStudy const &)=delete
process_name can override from command line with o or output muon
std::array< TH1D *, 3 > fNoise
MuonS2NStudy(fhicl::ParameterSet const &p)
Class holding the regions of interest of signal from a channel.
Range class, with range and data.
Declaration of basic channel signal object.
art::ServiceHandle< art::TFileService > tfs
unsigned int ChannelID_t
Type representing the ID of a readout channel.
art framework interface to geometry description
BEGIN_PROLOG could also be cout
std::vector< raw::ChannelID_t > ChannelsInTPCs() const
Returns an std::vector<ChannelID_t> in all TPCs in a TPCSet.