HitAnaAlg_test.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE ( HitAnaAlg_test )
2 #include "boost/test/unit_test.hpp"
3 
5 
6 namespace hit{
7 
8  class HitAnaAlgTest{
9  public:
10  WireROIInfo const& GetWireDataStruct() const { return alg.wireData; }
11  std::vector<std::string> const& GetHitModuleLabels() const { return alg.HitModuleLabels; }
12  std::vector<HitAnaAlg::HitAssocPair> const& GetHitProcessingQueue() const
13  { return alg.HitProcessingQueue; }
14 
15  void LoadHitAssocPair(std::vector<recob::Hit> const& HitVector,
16  std::vector< std::vector<int> > const& AssocVector,
17  std::string const& HitModuleLabel)
18  { alg.LoadHitAssocPair(HitVector,AssocVector,HitModuleLabel); }
19 
20  void InitWireData(unsigned int e, unsigned int r)
21  { alg.InitWireData(e,r); }
22 
24 
26 
27  private:
29 
30  };
31 
32 }
33 
35 
36  HitAnaAlgFixture() : myHitAnaAlgTest(){}
38 };
39 
40 BOOST_FIXTURE_TEST_SUITE(HitAnaAlg_test, HitAnaAlgFixture)
41 
42 BOOST_AUTO_TEST_CASE(checkConstructor)
43 {
44 
45  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHitModules == 0 );
46  BOOST_TEST( myHitAnaAlgTest.GetHitModuleLabels().size() == 0U );
47  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue().size() == 0U );
48 
49 }
50 
51 BOOST_AUTO_TEST_CASE(LoadHitAssocPair_FirstTime)
52 {
53  size_t nHits = 10;
54  size_t nWires = 10;
55 
56  std::vector<recob::Hit> HitVector(nHits);
57 
58  std::vector< std::vector<int> > AssocVector(nWires);
59  for(size_t iter=0; iter<nWires; iter++)
60  AssocVector[iter].push_back(iter);
61 
62  std::string HitModuleLabel = "hit";
63 
64  myHitAnaAlgTest.LoadHitAssocPair(HitVector,AssocVector,HitModuleLabel);
65  BOOST_TEST( myHitAnaAlgTest.GetHitModuleLabels().size() == 1U );
66  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue().size() == 1U );
67 
68 }
69 
70 BOOST_AUTO_TEST_CASE(LoadHitAssocPair_MultipleHitModules)
71 {
72  size_t nHits1 = 10;
73  size_t nHits2 = 10;
74  size_t nWires = 10;
75 
76  std::vector<recob::Hit> HitVector1(nHits1);
77  std::vector<recob::Hit> HitVector2(nHits2);
78 
79  std::vector< std::vector<int> > AssocVector1(nWires);
80  std::vector< std::vector<int> > AssocVector2(nWires);
81  for(size_t iter=0; iter<nWires; iter++){
82  AssocVector1[iter].push_back(iter);
83  AssocVector2[iter].push_back(nWires-iter-1);
84  }
85  std::string HitModuleLabel1 = "hit1";
86  std::string HitModuleLabel2 = "hit2";
87 
88  myHitAnaAlgTest.LoadHitAssocPair(HitVector1,AssocVector1,HitModuleLabel1);
89  myHitAnaAlgTest.LoadHitAssocPair(HitVector2,AssocVector2,HitModuleLabel2);
90 
91  BOOST_TEST( myHitAnaAlgTest.GetHitModuleLabels().size() == 2U );
92  BOOST_TEST( myHitAnaAlgTest.GetHitModuleLabels()[0].compare(HitModuleLabel1) == 0 );
93  BOOST_TEST( myHitAnaAlgTest.GetHitModuleLabels()[1].compare(HitModuleLabel2) == 0 );
94 
95  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue().size() == 2U );
96  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue()[0].second.size() == nWires );
97  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue()[0].second[0].size() == 1U );
98  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue()[0].second[0][0] == 0 );
99  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue()[1].second.size() == nWires );
100  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue()[1].second[0].size() == 1U );
101  BOOST_TEST( myHitAnaAlgTest.GetHitProcessingQueue()[1].second[0][0] == (int)(nWires-1) );
102 
103 }
104 
105 BOOST_AUTO_TEST_CASE(LoadHitAssocPair_VectorSizesOff)
106 {
107  std::string str = "test";
108  myHitAnaAlgTest.AddHitModuleLabel(str);
109  BOOST_TEST( myHitAnaAlgTest.GetHitModuleLabels().size() == 1U );
110 
111  size_t nHits = 10;
112  size_t nWires = 10;
113 
114  std::vector<recob::Hit> HitVector(nHits);
115 
116  std::vector< std::vector<int> > AssocVector(nWires);
117  for(size_t iter=0; iter<nWires; iter++)
118  AssocVector[iter].push_back(iter);
119 
120  std::string HitModuleLabel = "hit";
121 
122  BOOST_CHECK_THROW(myHitAnaAlgTest.LoadHitAssocPair(HitVector,AssocVector,HitModuleLabel),hit::HitAnaAlgException);
123 
124 }
125 
126 BOOST_AUTO_TEST_CASE(InitWireData_OneModule)
127 {
128  size_t nHits = 10;
129  size_t nWires = 10;
130 
131  std::vector<recob::Hit> HitVector(nHits);
132 
133  std::vector< std::vector<int> > AssocVector(nWires);
134  for(size_t iter=0; iter<nWires; iter++)
135  AssocVector[iter].push_back(iter);
136 
137  std::string HitModuleLabel = "hit";
138 
139  myHitAnaAlgTest.LoadHitAssocPair(HitVector,AssocVector,HitModuleLabel);
140 
141  unsigned int event = 50;
142  unsigned int run =200;
143 
144  myHitAnaAlgTest.InitWireData(event,run);
145 
146  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().event == event );
147  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().run == run );
148  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHitModules == 1 );
149  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().HitModuleLabels.size() == 1U );
150  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().HitModuleLabels[0] == HitModuleLabel );
151 
152 }
153 
154 BOOST_AUTO_TEST_CASE(InitWireData_NoModules)
155 {
156  unsigned int event = 50;
157  unsigned int run =200;
158 
159  myHitAnaAlgTest.InitWireData(event,run);
160 
161  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().event == event );
162  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().run == run );
163  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHitModules == 0 );
164  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().HitModuleLabels.size() == 0U );
165 
166 }
167 
168 BOOST_AUTO_TEST_CASE(ClearWireDataHitInfo_NoModules)
169 {
170  unsigned int event = 50;
171  unsigned int run =200;
172 
173  myHitAnaAlgTest.InitWireData(event,run);
174  myHitAnaAlgTest.ClearWireDataHitInfo();
175 
176  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().event == event );
177  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().run == run );
178  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHitModules == 0 );
179  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHits.size() == 0U );
180  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().Hits_IntegratedCharge.size() == 0U );
181  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().Hits.size() == 0U );
182 
183 }
184 
185 BOOST_AUTO_TEST_CASE(ClearWireDataHitInfo_OneModule)
186 {
187  size_t nHits = 10;
188  size_t nWires = 10;
189 
190  std::vector<recob::Hit> HitVector(nHits);
191 
192  std::vector< std::vector<int> > AssocVector(nWires);
193  for(size_t iter=0; iter<nWires; iter++)
194  AssocVector[iter].push_back(iter);
195 
196  std::string HitModuleLabel = "hit";
197 
198  myHitAnaAlgTest.LoadHitAssocPair(HitVector,AssocVector,HitModuleLabel);
199 
200  unsigned int event = 50;
201  unsigned int run =200;
202 
203  myHitAnaAlgTest.InitWireData(event,run);
204  myHitAnaAlgTest.ClearWireDataHitInfo();
205 
206  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().event == event );
207  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().run == run );
208  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHitModules == 1 );
209  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHits.size() == 1U );
210  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().NHits[0] == 0 );
211  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().Hits_IntegratedCharge.size() == 1U );
212  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().Hits_IntegratedCharge[0] == 0 );
213  BOOST_TEST( myHitAnaAlgTest.GetWireDataStruct().Hits.size() == 1U );
214 
215 }
216 
217 BOOST_AUTO_TEST_SUITE_END()
std::vector< std::string > HitModuleLabels
Definition: HitAnaAlg.h:168
void LoadHitAssocPair(std::vector< recob::Hit > const &HitVector, std::vector< std::vector< int > > const &AssocVector, std::string const &HitModuleLabel)
void LoadHitAssocPair(std::vector< recob::Hit > const &, std::vector< std::vector< int >> const &, std::string const &)
Definition: HitAnaAlg.cxx:97
WireROIInfo wireData
Definition: HitAnaAlg.h:165
void AddHitModuleLabel(std::string str)
std::vector< HitAnaAlg::HitAssocPair > const & GetHitProcessingQueue() const
std::string string
Definition: nybbler.cc:12
void ClearWireDataHitInfo()
Definition: HitAnaAlg.cxx:133
struct vector vector
BOOST_AUTO_TEST_CASE(checkConstructor)
void InitWireData(unsigned int e, unsigned int r)
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
const double e
hit::HitAnaAlgTest myHitAnaAlgTest
Detector simulation of raw signals on wires.
std::vector< std::string > const & GetHitModuleLabels() const
std::vector< reco::ClusterHit2D * > HitVector
What follows are several highly useful typedefs which we want to expose to the outside world...
void InitWireData(unsigned int, unsigned int)
Definition: HitAnaAlg.cxx:123
WireROIInfo const & GetWireDataStruct() const
std::vector< HitAssocPair > HitProcessingQueue
Definition: HitAnaAlg.h:169
static QCString str
Event finding and building.