All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
numu::MuonS2NStudy Class Reference
Inheritance diagram for numu::MuonS2NStudy:

Public Member Functions

 MuonS2NStudy (fhicl::ParameterSet const &p)
 
 MuonS2NStudy (MuonS2NStudy const &)=delete
 
 MuonS2NStudy (MuonS2NStudy &&)=delete
 
MuonS2NStudyoperator= (MuonS2NStudy const &)=delete
 
MuonS2NStudyoperator= (MuonS2NStudy &&)=delete
 
void analyze (art::Event const &e) override
 

Private Attributes

std::vector< std::array< TH1D *, 3 > > fSignal
 
std::array< TH1D *, 3 > fNoise
 
std::string fHitLabel
 
std::string fWireLabel
 

Detailed Description

Definition at line 62 of file MuonS2NStudy_module.cc.

Constructor & Destructor Documentation

numu::MuonS2NStudy::MuonS2NStudy ( fhicl::ParameterSet const &  p)
explicit

Definition at line 85 of file MuonS2NStudy_module.cc.

86  : EDAnalyzer{p}, // ,
87  fHitLabel(p.get<std::string>("HitLabel")),
88  fWireLabel(p.get<std::string>("WireLabel"))
89  // More initializers here.
90 {
91  art::ServiceHandle<art::TFileService> tfs;
92 
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"};
95  // initilize the signal and noise on each plane
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.);
100  }
101  fNoise[i] = tfs->make<TH1D>(("Noise " + planes[i]).c_str(), "Noise", 200, 0., 10.);
102  }
103 }
pdgs p
Definition: selectors.fcl:22
std::vector< std::array< TH1D *, 3 > > fSignal
BEGIN_PROLOG Z planes
std::array< TH1D *, 3 > fNoise
art::ServiceHandle< art::TFileService > tfs
numu::MuonS2NStudy::MuonS2NStudy ( MuonS2NStudy const &  )
delete
numu::MuonS2NStudy::MuonS2NStudy ( MuonS2NStudy &&  )
delete

Member Function Documentation

void numu::MuonS2NStudy::analyze ( art::Event const &  e)
override

Definition at line 105 of file MuonS2NStudy_module.cc.

106 {
107  art::ServiceHandle<cheat::BackTrackerService> backtracker;
108  const geo::GeometryCore *geo = lar::providerFrom<geo::Geometry>();
109  auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(ev);
110 
111  // Get the Signal Amplitude
112  const std::vector<simb::MCParticle> &mcparticle_list = *ev.getValidHandle<std::vector<simb::MCParticle>>("largeant");
113 
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);
118 
119  const simb::MCParticle *muon = NULL;
120 
121  // get the muon
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];
126  }
127  break;
128  }
129 
130  assert(muon != NULL);
131 
132  std::cout << "Muon Momentum Theta: " << muon->Momentum().Theta() << std::endl;
133  std::cout << "Muon Momentum Phi: " << muon->Momentum().Phi() << std::endl;
134 
135  // find the angular bin
136  int angle_bin = -1;
137  if (abs(muon->Momentum().Theta()) < 0.2) angle_bin = 0;
138  else if (muon->Momentum().Phi() < 0.) angle_bin = 1;
139  else angle_bin = 2;
140 
141  // make sure it's an energetic enough muon
142  // if (muon->E() < fMuonEnergyCut) return;
143 
144  // make sure the muon is mostly perpindicular to the wire-planes
145  // if (muon->Momentum()->CosTheta() < fMuonCosThetaCut) return;
146 
147  // get the true matched hits
148  std::vector<art::Ptr<recob::Hit>> muon_hits = backtracker->TrackIdToHits_Ps(clock_data, muon->TrackId(), hits);
149 
150  // Only consider the hit with the highest amplitude on each channel
151  // (in case of accidental delta rays or split hits)
152  std::map<raw::ChannelID_t, float> amplitude_map;
153 
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();
157  }
158  }
159 
160  // fill up all of the signals
161  for (auto const &pair: amplitude_map) {
162  fSignal[angle_bin][geo->View(pair.first)]->Fill(pair.second);
163  }
164 
165  // now get the background noise RMS
166 
167  // figure out which channels do not have any energy depositions
168  std::vector<raw::ChannelID_t> allChannels = geo->ChannelsInTPCs();
169 
170  std::set<raw::ChannelID_t> channelSet;
171  for (raw::ChannelID_t c: allChannels) channelSet.insert(c);
172 
173  // ignore wires that are shorter than the max length
174  for (raw::ChannelID_t c: allChannels) {
175  geo::WireID wireID = geo->ChannelToWire(c).at(0);
176  const geo::WireGeo &wireGeo = geo->Wire(wireID);
177  float length = wireGeo.Length();
178  // TODO: don't hardcode
179  if (geo->SignalType(wireID) == geo::kInduction && length < 577.3) {
180  channelSet.erase(c);
181  }
182  }
183 
184  art::Handle<std::vector<sim::SimChannel>> simChannels;
185  ev.getByLabel("largeant", simChannels);
186  for (const sim::SimChannel &c: *simChannels) {
187  if (c.TDCIDEMap().size()) {
188  channelSet.erase(c.Channel());
189  }
190  }
191 
192  // now get the wires
193  art::Handle<std::vector<recob::Wire>> wires;
194  ev.getByLabel(fWireLabel, wires);
195 
196  for (const recob::Wire &wire: *wires) {
197  if (!channelSet.count(wire.Channel())) continue;
198  // get the noise RMS
199  const recob::Wire::RegionsOfInterest_t &ROI = wire.SignalROI();
200  int ncount = 0;
201  double rms_sum = 0.;
203  for (float v: range) {
204  rms_sum += v * v;
205  ncount ++;
206  }
207  }
208  float noise = sqrt(rms_sum / ncount);
209  // std::cout << "Noise: " << noise;
210  fNoise[geo->View(wire.Channel())]->Fill(noise);
211  }
212 
213 }
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:145
double Length() const
Returns the wire length in centimeters.
Definition: WireGeo.h:236
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
const range_list_t & get_ranges() const
Returns the internal list of non-void ranges.
process_name hit
Definition: cheaterreco.fcl:51
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
T abs(T value)
Signal from induction planes.
Definition: geo_types.h:145
Description of geometry of one entire detector.
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
WireGeo const & Wire(geo::WireID const &wireid) const
Returns the specified wire.
process_name can override from command line with o or output muon
Definition: runPID.fcl:28
std::array< TH1D *, 3 > fNoise
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
Range class, with range and data.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
BEGIN_PROLOG could also be cout
std::vector< raw::ChannelID_t > ChannelsInTPCs() const
Returns an std::vector&lt;ChannelID_t&gt; in all TPCs in a TPCSet.
MuonS2NStudy& numu::MuonS2NStudy::operator= ( MuonS2NStudy const &  )
delete
MuonS2NStudy& numu::MuonS2NStudy::operator= ( MuonS2NStudy &&  )
delete

Member Data Documentation

std::string numu::MuonS2NStudy::fHitLabel
private

Definition at line 80 of file MuonS2NStudy_module.cc.

std::array<TH1D*, 3> numu::MuonS2NStudy::fNoise
private

Definition at line 79 of file MuonS2NStudy_module.cc.

std::vector<std::array<TH1D*,3> > numu::MuonS2NStudy::fSignal
private

Definition at line 78 of file MuonS2NStudy_module.cc.

std::string numu::MuonS2NStudy::fWireLabel
private

Definition at line 81 of file MuonS2NStudy_module.cc.


The documentation for this class was generated from the following file: