RemoveOneDSlices_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: RemoveOneDSlices
3 // Module Type: producer
4 // File: RemoveOneDSlices_module.cc
5 //
6 // Generated at Wed June 5 by Matthew Tamsett based on SpaceSlice
7 //
8 ////////////////////////////////////////////////////////////////////////
9 
14 
19 
20 #include "DAQChannelMap/DAQChannelMap.h"
21 //---------------------------------------------------------------------
22 namespace novaddt {
23  class RemoveOneDSlices;
24 }
25 //---------------------------------------------------------------------
27  public:
28  explicit RemoveOneDSlices(fhicl::ParameterSet const & p);
29  virtual ~RemoveOneDSlices();
30  virtual bool filter(art::Event & event);
31  void endJob() override;
32  private:
33  // Declare member data here.
37  // functions
39  uint & x_hits,
40  uint & y_hits);
41  void printDDTSlice(HitList & hits);
42  // Counters
43  int _nEvents = 0;
44  int _nInputSlices = 0;
45  int _nOutputSlices = 0;
46 };
47 //---------------------------------------------------------------------
49 :
50  fInputLabel (p.get< std::string >("InputLabel" )),
51  fInputInstance (p.get< std::string >("InputInstance")),
52  fMinHitsPerView (p.get< uint >("MinHitsPerView"))
53 
54  // Initialize member data here.
55 {
56  std::cout << "=== novaddt::RemoveOneDSlices instantiate" << std::endl;
57  std::cout << "\t input hits label: " << fInputLabel << std::endl;
58  std::cout << "\t input hits instance: " << fInputInstance << std::endl;
59  std::cout << "\t min hits per view: " << fMinHitsPerView << std::endl;
60  // Call appropriate Produces<>() functions here.
61  produces<std::vector<HitList>>("TwoDSlices");
62 }
63 //---------------------------------------------------------------------
65 {
66  // Clean up dynamic memory and other resources here.
67 }
68 //---------------------------------------------------------------------
70 {
71  LOG_DEBUG("RemoveOneDSlices") << "=== novaddt::RemoveOneDSlices filter. Event: "
72  << event.id().event()
73  << std::endl;
74  _nEvents++;
76  event.getByLabel(fInputLabel, fInputInstance, hit_lists);
77  LOG_DEBUG("RemoveOneDSlices") << "\t got " << hit_lists->size() << " hit lists" << std::endl;
78 
79  //make a hit lists out of hits/hit lists that pass the spatial noise removal
80  std::unique_ptr< std::vector<HitList> >final_product(new std::vector<HitList>);
81 
82  for(unsigned int i=0; i<hit_lists->size(); ++i){
83  _nInputSlices++;
84  HitList product = hit_lists->at(i);
85  LOG_DEBUG("RemoveOneDSlices") << "\t hit list[" << i << "]: " << product.size() << " hits" << std::endl;
86  //printDDTSlice(product);
87  // count hits per view
88  uint x_hits = 0;
89  uint y_hits = 0;
90  countHitsPerViewOutlyingCells(product, x_hits, y_hits);
91 
92  //printDDTSlice(product);
93  if ((x_hits >= fMinHitsPerView) &&
94  (y_hits >= fMinHitsPerView)) final_product->push_back(product);
95 
96  } // end of loop on hits lists
97  //put the hits into the event for later use
98  LOG_DEBUG("RemoveOneDSlices") << "\t produced " << final_product->size() << " hit lists" << std::endl;
99  _nOutputSlices+=final_product->size();
100  event.put(std::move(final_product),"TwoDSlices");
101 
102  return true;
103 }
104 //---------------------------------------------------------------------
106  uint & x_hits,
107  uint & y_hits)
108 {
109  for (unsigned int i_hit = 0; i_hit < hits.size(); ++i_hit){
110  DAQHit hit = hits[i_hit];
111  // check that the current cells view
112  if (hit.View().val == daqchannelmap::X_VIEW){
113  x_hits++;
114  } else {
115  y_hits++;
116  }
117  } // end of loop on hits
118 
119  LOG_DEBUG("RemoveOneDSlices") << "\t\t - end of loop, current slice x hits: "
120  << x_hits << ", y hits: "
121  << y_hits << std::endl;
122 }
123 //---------------------------------------------------------------------
125 {
126  // print them
127  LOG_DEBUG("RemoveOneDSlices") << "\t\t - Hit list: " << hits.size()
128  << std::endl;
129  // sort them
130  sort(hits.begin(), hits.end(), novaddt::CompareDAQHit<novaddt::Cell>());
131  // loop over hits in each slice
132  for(unsigned int j = 0; j < hits.size(); ++j){
133  novaddt::DAQHit hit(hits[j]);
134  std::string view = "y";
135  if( hit.View().val == daqchannelmap::X_VIEW ){
136  view = "x";
137  }
138  LOG_DEBUG("RemoveOneDSlices") << "\t\t\thit[" << j
139  << "]: TDC: " << hit.TDC().val
140  << ", ADC: " << hit.ADC().val
141  << ", plane: " << hit.Plane().val
142  << ", " << view
143  << "-cell: " << hit.Cell().val
144  << std::endl;
145  } // end of loop on hits
146 }
147 //---------------------------------------------------------------------
149 {
150  std::cout << "=== novaddt::RemoveOneDSlices endJob" << std::endl;
151  std::cout << "\tNumber of events: " << _nEvents << std::endl;
152  std::cout << "\tNumber of slices: " << _nInputSlices << std::endl;
153  std::cout << "\tNumber of slices filtered: " << _nOutputSlices << std::endl;
154 }
155 //---------------------------------------------------------------------
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
value_type val
Definition: BaseProducts.h:34
novaddt::Plane const & Plane() const
Definition: DAQHit.h:70
novaddt::TDC const & TDC() const
Definition: DAQHit.h:74
std::vector< DAQHit > HitList
Definition: HitList.h:15
const char * p
Definition: xmltok.h:285
value_type val
Definition: BaseProducts.h:109
DEFINE_ART_MODULE(TestTMapFile)
void hits()
Definition: readHits.C:15
novaddt::ADC const & ADC() const
Definition: DAQHit.h:73
RemoveOneDSlices(fhicl::ParameterSet const &p)
novaddt::View const & View() const
Definition: DAQHit.h:72
Identifier for the X measuring view of the detector (top)
const double j
Definition: BetheBloch.cxx:29
value_type val
Definition: BaseProducts.h:84
OStream cout
Definition: OStream.cxx:6
virtual bool filter(art::Event &event)
T product(std::vector< T > dims)
Definition: structs.h:12
value_type val
Definition: BaseProducts.h:137
novaddt::Cell const & Cell() const
Definition: DAQHit.h:71
value_type val
Definition: BaseProducts.h:65
void countHitsPerViewOutlyingCells(HitList &hits, uint &x_hits, uint &y_hits)
enum BeamMode string
unsigned int uint