CanaFilter_module.cc
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////
2 /// \file CanaFilter.cxx
3 /// \brief Filter events based on the Cana analysis
4 /// \author messier@indiana.edu
5 /// \version $Id: CanaFilter.cxx,v 1.12 2012-09-25 16:06:22 gsdavies Exp $
6 /////////////////////////////////////////////////////////////////////////
11 
12 #include "Commissioning/CanaNt.h"
13 #include "DAQDataFormats/TriggerDefines.h"
14 
15 #include <string>
16 #include <vector>
17 #include <iostream>
18 
19 namespace comi {
20  class CanaFilter : public art::EDFilter
21  {
22  public:
23  explicit CanaFilter(fhicl::ParameterSet const& p);
24  virtual ~CanaFilter();
25 
26  virtual void reconfigure(fhicl::ParameterSet const& p);
27 
28  virtual bool filter(art::Event& e);
29 
30  private:
31  std::string fCanaLabel;///< Label of the Cana module instance
32  float fT1CutNuMI;///< [usec] Low edge of NuMI time window
33  float fT2CutNuMI;///< [usec] High edge of NuMI time window
34  float fT1CutBNB; ///< [usec] Low edge of BNB time window
35  float fT2CutBNB; ///< [usec] High edge of BNB time window
36  float fT1CutCAL; ///< [usec] Accept events inside calibration time window
37  float fT2CutCAL; ///< [usec] Accept events inside calibration time window
38  int fNhitXcut; ///< Require at least this many hits in the window
39  int fNhitYcut; ///< Require at least this many hits in the window
40  int fNplaneX; ///< Require size of event to be at least this long
41  int fNplaneY; ///< Require size of event to be at least this long
42  float fXlo; ///< Low edge of "fiducial volume" to select
43  float fXhi; ///< High edge of "fiducial volume" to select
44  float fYhi; ///< High edge of "fiducial volume" to select
45  float fZlo; ///< Low edge of "fiducial volume" to select
46  float fZhi; ///< High edge of "fiducial volume" to select
47  };
48 
49  //......................................................................
50 
52  {
53  this->reconfigure(p);
54  }
55 
56  //......................................................................
57 
59  {
60  fT1CutNuMI = p.get<float>("T1CutNuMI");
61  fT2CutNuMI = p.get<float>("T2CutNuMI");
62 
63  fT1CutBNB = p.get<float>("T1CutBNB");
64  fT2CutBNB = p.get<float>("T2CutBNB");
65 
66  fT1CutCAL = p.get<float>("T1CutCAL");
67  fT2CutCAL = p.get<float>("T2CutCAL");
68 
69  fNhitXcut = p.get<int>("NhitXcut");
70  fNhitYcut = p.get<int>("NhitYcut");
71 
72  fNplaneX = p.get<int>("NplaneX");
73  fNplaneY = p.get<int>("NplaneY");
74 
75  fXlo = p.get<float>("Xlo");
76  fXhi = p.get<float>("Xhi");
77 
78  fYhi = p.get<float>("Yhi");
79 
80  fZlo = p.get<float>("Zlo");
81  fZhi = p.get<float>("Zhi");
82 
83  fCanaLabel = p.get<std::string>("CanaLabel", "cana");
84  }
85 
86  //......................................................................
87 
89 
90  //......................................................................
91 
93  {
95  evt.getByLabel(fCanaLabel, nth);
96 
97  bool isgoodtrk = false;
98  bool isgoodevt = false;
99 
100  for (unsigned int i=0; i<nth->size(); ++i) {
101  const CanaNt& nt = (*nth)[i];
102  //
103  // Check if this is a good track. Good events will have at least
104  // one good track in them
105  //
106  isgoodtrk = true;
107 
108  //
109  // Apply correct timing cuts for this trigger source. The magic
110  // numbers are 0 for NuMI, 1 for BNB and 2 for calibration
111  // triggers
112  // Eventually try to use TRIGBITs from TriggerDefines.h
113  // but the numbers don't match??
114  //
115  if (nt.trgsrc==0) {
116  if (nt.tave<fT1CutNuMI) isgoodtrk = false;
117  if (nt.tave>fT2CutNuMI) isgoodtrk = false;
118  }
119  else if (nt.trgsrc==1) {
120  if (nt.tave<fT1CutBNB) isgoodtrk = false;
121  if (nt.tave>fT2CutBNB) isgoodtrk = false;
122  }
123  else if (nt.trgsrc==2) {
124  if (nt.tave<fT1CutCAL) isgoodtrk = false;
125  if (nt.tave>fT2CutCAL) isgoodtrk = false;
126  }
127  else {
128  std::cerr << __FILE__ << ":" << __LINE__
129  << " Unknown trigger source id=" << nt.trgsrc
130  << std::endl;
131  return false;
132  }
133 
134  //
135  // Ask for required number of hits in each view
136  //
137  if (nt.nhitx<fNhitXcut) isgoodtrk = false;
138  if (nt.nhity<fNhitYcut) isgoodtrk = false;
139 
140  //
141  // Ask for required number of planes crossed in each view
142  //
143  if ((abs(nt.plane2x-nt.plane1x))<fNplaneX) isgoodtrk = false;
144  if ((abs(nt.plane2y-nt.plane1y))<fNplaneY) isgoodtrk = false;
145 
146  //
147  // Require track start point (assumed down-going) to be inside the
148  // defined fiducial volume
149  //
150  if (nt.x1<fXlo) isgoodtrk = false;
151  if (nt.x1>fXhi) isgoodtrk = false;
152  if (nt.y1>fYhi) isgoodtrk = false;
153  if (nt.z1<fZlo) isgoodtrk = false;
154  if (nt.z1>fZhi) isgoodtrk = false;
155 
156  isgoodevt |= isgoodtrk;
157  }
158  return isgoodevt;
159  }
160 } // end namespace comi
161 ////////////////////////////////////////////////////////////////////////
163 ////////////////////////////////////////////////////////////////////////
Ntuple produced by the Cana module.
virtual void reconfigure(fhicl::ParameterSet const &p)
float tave
time where peak occurs (ave over hits) (usec)
Definition: CanaNt.h:34
int fNhitYcut
Require at least this many hits in the window.
float z1
Start position of track (cm)
Definition: CanaNt.h:48
float fZhi
High edge of "fiducial volume" to select.
float y1
Start position of track (cm)
Definition: CanaNt.h:47
float fXhi
High edge of "fiducial volume" to select.
const char * p
Definition: xmltok.h:285
int nhitx
Number of x view hits on track in peak time window.
Definition: CanaNt.h:22
OStream cerr
Definition: OStream.cxx:7
void abs(TH1 *hist)
int trgsrc
trigger source
Definition: CanaNt.h:20
DEFINE_ART_MODULE(TestTMapFile)
float fT1CutCAL
[usec] Accept events inside calibration time window
int fNhitXcut
Require at least this many hits in the window.
int fNplaneY
Require size of event to be at least this long.
Commissioning files to look at the quality of our data.
Definition: Cana_module.cc:39
float fT2CutCAL
[usec] Accept events inside calibration time window
T get(std::string const &key) const
Definition: ParameterSet.h:231
int evt
std::string fCanaLabel
Label of the Cana module instance.
Ntuple produced by the cana module.
Definition: CanaNt.h:14
int plane1y
1st plane in y view
Definition: CanaNt.h:26
float fXlo
Low edge of "fiducial volume" to select.
float fT2CutNuMI
[usec] High edge of NuMI time window
int fNplaneX
Require size of event to be at least this long.
float x1
Start position of track (cm)
Definition: CanaNt.h:46
float fT1CutNuMI
[usec] Low edge of NuMI time window
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
float fYhi
High edge of "fiducial volume" to select.
virtual bool filter(art::Event &e)
float fZlo
Low edge of "fiducial volume" to select.
int plane2x
last plane in x view
Definition: CanaNt.h:25
Float_t e
Definition: plot.C:35
TNtuple * nt
Definition: drawXsec.C:2
CanaFilter(fhicl::ParameterSet const &p)
int plane1x
1st plane in x view
Definition: CanaNt.h:24
float fT1CutBNB
[usec] Low edge of BNB time window
int plane2y
last plane in y view
Definition: CanaNt.h:27
int nhity
Number of y view hits on track in peak time window.
Definition: CanaNt.h:23
float fT2CutBNB
[usec] High edge of BNB time window
enum BeamMode string