IdenticalSlicerAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file IdenticalSlicerAna.cxx
3 // \brief Module to make sure physics slices of two slicers are identical
4 // \author rocco
5 // \date 5/17/2013
6 ////////////////////////////////////////////////////////////////////////
7 
8 // C/C++ includes
9 #include <cmath>
10 #include <iostream>
11 #include <map>
12 #include <vector>
13 
14 // ROOT includes
15 #include "TTree.h"
16 #include "TH1F.h"
17 #include "TH2F.h"
18 
19 // Framework includes
29 #include "fhiclcpp/ParameterSet.h"
31 
32 // NOvASoft includes
33 #include "RecoBase/CellHit.h"
34 #include "RecoBase/Cluster.h"
35 #include "Utilities/AssociationUtil.h"
36 
37 
38 
39 
40 
41 
42 // IdenticalSlicerAna header
43 namespace slicer {
45  public:
46  explicit IdenticalSlicerAna(fhicl::ParameterSet const& pset);
48 
49  void analyze(const art::Event& evt);
50  void reconfigure(const fhicl::ParameterSet& pset);
51 
52  private:
56 
57 
58  };
59 }
60 
61 
62 
63 namespace slicer
64 {
65  //.......................................................................
67  : EDAnalyzer(pset)
68  {
69  this->reconfigure(pset);
70  }
71 
72  //......................................................................
74  {
75  //======================================================================
76  // Clean up any memory allocated by your module
77  //======================================================================
78  }
79 
80  //......................................................................
82  {
83  fCellHitInput = pset.get< std::string> ("CellHitInput");
84  fOldSlicerLabel = pset.get<std::string> ("OldSlicerLabel");
85  fNewSlicerLabel = pset.get<std::string> ("NewSlicerLabel");
86  }
87 
88 
89 
90  //......................................................................
92  {
93 
94  // Get the hits from calhit
96  evt.getByLabel(fCellHitInput, hitcol);
97 
98  // make a vector
99  std::vector<art::Ptr<rb::CellHit > > hitlist;
100  for(unsigned int i = 0; i < hitcol->size(); ++i){
101  art::Ptr<rb::CellHit> hit(hitcol, i);
102  hitlist.push_back(hit);
103  }
104 
105  // get the old slices
106  art::Handle< std::vector< rb::Cluster > > oldSlicesHandle;
107  evt.getByLabel(fOldSlicerLabel, oldSlicesHandle);
108  std::vector< rb::Cluster > oldSlices = *oldSlicesHandle;
109 
110  art::Handle< std::vector< rb::Cluster > > newSlicesHandle;
111  evt.getByLabel(fNewSlicerLabel, newSlicesHandle);
112  std::vector< rb::Cluster > newSlices = *newSlicesHandle;
113 
114  // make sure both have
115  assert(newSlices.size() == oldSlices.size());
116 
117  for(size_t iSlc = 0; iSlc < oldSlices.size(); ++iSlc){
118  if(!newSlices[iSlc].IsNoise())
119  {
120  assert(newSlices[iSlc].NCell() == oldSlices[iSlc].NCell());
121 
122  for(size_t iHit = 0; iHit < oldSlices[iSlc].NCell(); ++iHit){
123  assert(*oldSlices[iSlc].Cell(iHit) == *newSlices[iSlc].Cell(iHit));
124  }
125 
126 
127  }
128  }
129 
130 
131 
132  // make sure that all cell hits in the new slices are unique
133  // first check output from calhit
134  for(size_t i = 0; i< hitlist.size(); ++i)
135  {
136  for(size_t j = 0; j< hitlist.size(); ++j)
137  {
138  if(i != j){
139  assert(!(*(hitlist[i]) == *(hitlist[j])) && " CalHits are not unique!");
140  }
141  }
142  }
143 
144 
145  for (auto it = newSlices.begin(); it != newSlices.end(); ++it)
146  {
147 
148  art::PtrVector< rb::CellHit > cells = it->AllCells();
149  for(size_t i = 0; i < cells.size(); ++i)
150  {
151  for(size_t j = 0; j < cells.size(); ++j)
152  {
153  if(i != j){
154  if(*(cells[i]) == *(cells[j]))
155  {
156  std::cout << i << " " << cells[i]->Cell() << " " << cells[i]->Plane() << " " <<
157  cells[i]->PE() << " " << cells[i]->TDC() << std::endl;
158 
159  std::cout << j << " " << cells[j]->Cell() << " " << cells[j]->Plane() << " " <<
160  cells[j]->PE() << " " << cells[j]->TDC() << std::endl;
161 
162  }
163  assert(!(*(cells[i]) == *(cells[j])) && " Cells are not unique");
164  }
165  }
166 
167  }
168 
169 
170  }
171 
172  std::cout << " slices are idential " << std::endl;
173 
174  return;
175  }
176 
177 
178 
179 
180 
181 } // end namespace slicer
182 ////////////////////////////////////////////////////////////////////////
183 
184 
185 
187 
188 namespace slicer
189 {
191 }
set< int >::iterator it
DEFINE_ART_MODULE(TestTMapFile)
T get(std::string const &key) const
Definition: ParameterSet.h:231
int evt
const double j
Definition: BetheBloch.cxx:29
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
size_type size() const
Definition: PtrVector.h:308
OStream cout
Definition: OStream.cxx:6
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: structs.h:12
assert(nhit_max >=nhit_nbins)
void analyze(const art::Event &evt)
Class to help Slicer4D manage the collection of hits.
void reconfigure(const fhicl::ParameterSet &pset)
IdenticalSlicerAna(fhicl::ParameterSet const &pset)
enum BeamMode string