HighEnergyAna_module.cc
Go to the documentation of this file.
10 
14 
15 #include <TH1.h>
16 #include <TH2.h>
17 
18 #include <tuple>
19 
20 namespace highe {
21  class HighEnergyAna;
22 }
23 
25 public:
26  explicit HighEnergyAna(fhicl::ParameterSet const & p);
27  virtual ~HighEnergyAna();
28 
29  void analyze(art::Event const & e) override;
30 
31  void beginJob() override;
32 
33 private:
34  typedef std::tuple<unsigned, double, double> Binning;
35 
36  void make_histo
37  (std::string const name, std::string const title, Binning const& bin);
38 
40  std::map<std::string, TH1*> h_;
41  std::map<std::string, TH2*> h2_;
43 };
44 
45 
47  EDAnalyzer(p),
48  slice_label_(p.get<std::string>("slice_label")),
49  slice_instance_(p.get<std::string>("slice_instance"))
50 {
51 }
52 
54 {
55 }
56 
58 {
59  Binning adc_bin(4096, -0.5, 4095.5);
60  Binning nbin(2001, -0.5, 2000.5);
61  Binning plane_bin(1001, -0.5, 1000.5);
62  Binning cell_bin(401, -0.5, 400.5);
63 
64  make_histo("counter", "Counter", Binning(10, 0.5, 10.5));
65 
66  make_histo("adc_all_hits", "ADC Distribution of All Hits", adc_bin);
67  make_histo("adc_all_hits_raw", "Raw ADC Distribution of All Hits", adc_bin);
68  make_histo("adc_mean", "Mean ADC per Slice", adc_bin);
69  make_histo("adc_max", "Maximum ADC per Slice", adc_bin);
70  make_histo("adc_min", "Minimum ADC per Slice", adc_bin);
71  make_histo("adc_sum", "Summed ADC per Slice", Binning(1e4, 0, 1e8));
72  make_histo("adc_sum_above_200", "Summed ADC (ADC > 200) per Slice",
73  Binning(1e4, 0, 1e8));
74 
75  make_histo("n_hits_per_slice", "Number of Hits per Slice", nbin);
76  make_histo("n_hits_per_triggered_slice",
77  "Number of Hits per Triggered Slice", nbin);
78  make_histo("n_hits_above_200", "Number of Hits above 200 ADC", nbin);
79  make_histo("n_hits_above_700", "Number of Hits above 700 ADC", nbin);
80  make_histo("n_hits_above_1000", "Number of Hits above 1000 ADC", nbin);
81  make_histo("n_hits_above_2000", "Number of Hits above 2000 ADC", nbin);
82 
83  make_histo("plane_all_hits", "Plane of All Hits", plane_bin);
84  make_histo("cell_all_hits", "Cell of All Hits", cell_bin);
85 
86 
87  h2_["trigger_rate_700"] = tfs_->make<TH2F>
88  ("trigger_rate_700", "Trigger Rate",
89  5, 0, 1000,
90  6, 0, 30);
91  h2_["trigger_rate_1000"] = tfs_->make<TH2F>
92  ("trigger_rate_1000", "Trigger Rate",
93  5, 0, 1000,
94  6, 0, 30);
95  h2_["trigger_rate_2000"] = tfs_->make<TH2F>
96  ("trigger_rate_2000", "Trigger Rate",
97  5, 0, 1000,
98  6, 0, 30);
99 }
100 
102 (std::string const name, std::string const title, Binning const& bin)
103 {
104  h_[name] = tfs_->make<TH1F>
105  (name.c_str(), title.c_str(),
106  std::get<0>(bin), std::get<1>(bin), std::get<2>(bin));
107 }
108 
109 
111 {
112  art::Handle<novaddt::HitList> sorted_hits;
113  e.getByLabel("tdcsort", "TDCSortedHits", sorted_hits);
114 
117 
119  e.getByLabel("highetrigger", decisions);
120 
121  h_["counter"]->Fill("event", 1);
122 
123  int y;
124 
125  if (!decisions.failedToGet())
126  {
127  if (decisions->size() == 1)
128  h_["counter"]->Fill("HE triggered", 1);
129 
130  if (decisions->size() > 1)
131  h_["counter"]->Fill("multiple HE triggered", 1);
132  }
133 
134  for (auto const& hit : *sorted_hits)
135  h_["adc_all_hits_raw"]->Fill(hit.ADC().val);
136 
137 
138  for (auto const& slice : *slices)
139  {
140  // h_["counter"]->Fill("slice", 1);
141 
142  double adc_sum = 0.0;
143  double adc_sum_above_200 = 0.0;
144  std::map<unsigned, unsigned> n_hits =
145  {{0, 0}, {200, 0}, {700, 0}, {1000, 0}, {2000, 0}};
146 
147  for (auto const& hit : slice)
148  {
149  // h_["counter"]->Fill("hit", 1);
150 
151  h_["plane_all_hits"]->Fill(hit.Plane().val);
152  h_["cell_all_hits"]->Fill(hit.Cell().val);
153 
154  auto adc = hit.ADC().val;
155  h_["adc_all_hits"]->Fill(adc);
156  adc_sum += adc;
157 
158  if (adc >= 200)
159  adc_sum_above_200 += adc;
160 
161  // we are looking for hits that have an energy above the thresholds
162  // in n_hits
163  for (auto & n : n_hits)
164  if (adc >= n.first)
165  ++n.second;
166  }
167 
168  double adc_mean;
169  unsigned adc_min, adc_max;
170  if (slice.size() > 0)
171  {
172  adc_mean = adc_sum / double(slice.size());
173  auto range =
174  std::minmax_element(slice.begin(), slice.end(),
176  adc_min = range.first->ADC().val;
177  adc_max = range.second->ADC().val;
178  } else {
179  adc_mean = 0.0;
180  adc_min = 0;
181  adc_max = 0;
182  }
183 
184  h_["adc_mean"]->Fill(adc_mean);
185  h_["adc_min"]->Fill(adc_min);
186  h_["adc_max"]->Fill(adc_max);
187  h_["adc_sum"]->Fill(adc_sum);
188  h_["adc_sum_above_200"]->Fill(adc_sum_above_200);
189 
190  h_["n_hits_per_slice"]->Fill(n_hits[0]);
191  h_["n_hits_above_200"]->Fill(n_hits[200]);
192  h_["n_hits_above_700"]->Fill(n_hits[700]);
193  h_["n_hits_above_1000"]->Fill(n_hits[1000]);
194  h_["n_hits_above_2000"]->Fill(n_hits[2000]);
195 
196  h2_["trigger_rate_700"]->Fill(adc_mean, n_hits[700]);
197  h2_["trigger_rate_1000"]->Fill(adc_mean, n_hits[1000]);
198  h2_["trigger_rate_2000"]->Fill(adc_mean, n_hits[2000]);
199 
200  // if this slice is triggered
201  if (n_hits[1000] >= 15 &&
202  adc_mean >= 600)
203  h_["n_hits_per_triggered_slice"]->Fill(n_hits[0]);
204  }
205 }
206 
std::tuple< unsigned, double, double > Binning
const XML_Char * name
Definition: expat.h:151
art::ServiceHandle< art::TFileService > tfs_
HighEnergyAna(fhicl::ParameterSet const &p)
void analyze(art::Event const &e) override
const char * p
Definition: xmltok.h:285
std::map< std::string, TH1 * > h_
DEFINE_ART_MODULE(TestTMapFile)
std::map< std::string, TH2 * > h2_
correl_yv Fill(-(dy[iP-1][iC-1]), hyv->GetBinContent(iP, iC))
void make_histo(std::string const name, std::string const title, Binning const &bin)
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
float bin[41]
Definition: plottest35.C:14
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
Float_t e
Definition: plot.C:35
bool failedToGet() const
Definition: Handle.h:196
enum BeamMode string