AirShower_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: AirShower
3 // Module Type: analyzer
4 // File: AirShower_module.cc
5 //
6 // Generated at Thu Jan 9 13:51:59 2014 by Martin Frank using artmod
7 // from cetpkgsupport v1_04_02.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include <iostream>
11 
12 #include "RecoBase/CellHit.h"
13 #include "RecoBase/Cluster.h"
14 #include "RecoBase/HoughResult.h"
15 
24 #include "fhiclcpp/ParameterSet.h"
25 
26 #include <TH1.h>
27 
28 #include <boost/format.hpp>
29 
30 namespace air {
31  class AirShower;
32 }
33 
35 public:
36  explicit AirShower(fhicl::ParameterSet const & p);
37  virtual ~AirShower();
38 
39  void beginJob();
40  void analyze(art::Event const & e) override;
41 
42 private:
44 
45  std::map<std::string, TH1*> h_;
46 };
47 
48 
49 
51  EDAnalyzer(p),
52  hit_label_(p.get<std::string>("hit_label")),
53  slice_label_(p.get<std::string>("slice_label"))
54 {
55 }
56 
57 
58 
60 {
61 }
62 
63 
64 
66 {
68 
69  h_["adc"] = tfs->make<TH1I>("adc", "ADC Distribution", 4096, -0.5, 4095.5);
70  h_["nhits"] =
71  tfs->make<TH1I>("nhits", "Number of Hits per Event", 101, -0.5, 100.5);
72 
73  h_["nhits_high"] =
74  tfs->make<TH1I>("nhits_high",
75  "Number of Hits per Event Above 100 ADC",
76  101, -0.5, 100.5);
77 
78  h_["nhits_per_slice"] =
79  tfs->make<TH1I>("nhits_per_slice",
80  "Number of Hits per Non-Noise Slice",
81  1001, -0.5, 1000.5);
82 }
83 
84 
85 
87 {
89  e.getByLabel(hit_label_, hits);
90 
92  e.getByLabel(slice_label_, slices);
93 
95  e.getByLabel("hought", hough_results);
96 
97  // Let's play around with the raw Hough information a bit:
98  for (auto const& hough_result : *hough_results)
99  {
100  std::cout << "MF: Hough Result" << std::endl;
101  for (auto const & peak : hough_result.fPeak)
102  std::cout << "MF: \tRho = " << peak.fRho
103  << "\nMF: \tTheta = " << peak.fTheta
104  << std::endl;
105  }
106 
107 
108  unsigned n_hits(0), n_hits_high(0);
109  for (auto const& hit : *hits)
110  {
111  if (hit.ADC(0) > 0)
112  n_hits++;
113 
114  if (hit.ADC(0) > 100)
115  n_hits_high++;
116 
117  h_["adc"]->Fill(hit.ADC(0));
118 
119  if (n_hits > 0)
120  h_["nhits"]->Fill(n_hits);
121 
122  if (n_hits_high > 0)
123  h_["nhits_high"]->Fill(n_hits_high);
124  }
125 
126  boost::format header("%15s %15s %15s %15s");
127  boost::format form("%15.0f %15.0f %15.2f %15.2f");
128  std::cout << header % "Slice Number" % "N Hits" % "Total ADC" % "Z Extent"
129  << std::endl;
130 
131  unsigned n_slice = 0;
132  for (auto const& slice : *slices)
133  {
134  if (!slice.IsNoise())
135  {
136  h_["nhits_per_slice"]->Fill(slice.NCell());
137  std::cout << form %
138  ++n_slice % slice.NCell() % slice.TotalADC() % slice.ExtentZ()
139  << std::endl;
140  }
141  }
142 
143  std::cout << std::endl;
144 }
145 
146 
147 
const char * p
Definition: xmltok.h:285
std::string hit_label_
DEFINE_ART_MODULE(TestTMapFile)
std::string slice_label_
void analyze(art::Event const &e) override
void hits()
Definition: readHits.C:15
std::map< std::string, TH1 * > h_
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
OStream cout
Definition: OStream.cxx:6
T * make(ARGS...args) const
Data resulting from a Hough transform on the cell hit positions.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
virtual ~AirShower()
Float_t e
Definition: plot.C:35
AirShower(fhicl::ParameterSet const &p)
enum BeamMode string