~vpec/maus/tof_calib_read

« back to all changes in this revision

Viewing changes to tests/cpp_unit/DetModel/SciFiPlaneTest.cc

reverse merge from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
 
2
 *
 
3
 * MAUS is free software: you can redistribute it and/or modify
 
4
 * it under the terms of the GNU General Public License as published by
 
5
 * the Free Software Foundation, either version 3 of the License, or
 
6
 * (at your option) any later version.
 
7
 *
 
8
 * MAUS is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with MAUS.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#include <G4VPhysicalVolume.hh>
 
19
#include <G4VSolid.hh>
 
20
#include <G4Material.hh>
 
21
#include <G4Element.hh>
 
22
#include <G4LogicalVolume.hh>
 
23
#include <G4ThreeVector.hh>
 
24
#include <G4PVPlacement.hh>
 
25
#include <globals.hh>
 
26
#include <G4SDManager.hh>
 
27
#include <G4UserLimits.hh>
 
28
#include <G4Tubs.hh>
 
29
#include <G4PVParameterised.hh>
 
30
 
 
31
#include <limits>
 
32
 
 
33
#include "src/legacy/Config/MiceModule.hh"
 
34
 
 
35
#include "src/common_cpp/DetModel/SciFi/SciFiPlane.hh"
 
36
 
 
37
#include "gtest/gtest.h"
 
38
#include "CLHEP/Random/Random.h"
 
39
 
 
40
namespace {
 
41
class SciFiPlaneTest : public ::testing::Test {
 
42
 protected:
 
43
  SciFiPlaneTest()  {
 
44
  G4double innerRadiusOfTheTube = 0.*cm;
 
45
  G4double outerRadiusOfTheTube = 30.*cm;
 
46
  G4double hightOfTheTube = 1.*m;
 
47
  G4double startAngleOfTheTube = 0.*deg;
 
48
  G4double spanningAngleOfTheTube = 360.*deg;
 
49
 
 
50
  G4Tubs* tracker_tube = new G4Tubs("tracker_tube",
 
51
                             innerRadiusOfTheTube,
 
52
                             outerRadiusOfTheTube,
 
53
                             hightOfTheTube,
 
54
                             startAngleOfTheTube,
 
55
                             spanningAngleOfTheTube);
 
56
 
 
57
  G4LogicalVolume* tracker_log
 
58
          = new G4LogicalVolume(tracker_tube, mat, "tracker_log");
 
59
 
 
60
 
 
61
 
 
62
  tracker = new G4PVPlacement(0, G4ThreeVector(),
 
63
                              "name", tracker_log,
 
64
                              0, false, 0, false);
 
65
  }
 
66
  virtual ~SciFiPlaneTest() {}
 
67
  virtual void SetUp()    {}
 
68
  virtual void TearDown() {}
 
69
 
 
70
  G4PVPlacement* tracker;
 
71
  G4Material* mat;
 
72
};
 
73
 
 
74
TEST_F(SciFiPlaneTest, Test_num_fibres_in_all_planes) {
 
75
  std::string filename;
 
76
  filename = "Stage6.dat";
 
77
  std::vector<const MiceModule*> modules;
 
78
  MiceModule*      _module;
 
79
  _module = new MiceModule(filename);
 
80
  modules = _module->findModulesByPropertyString("SensitiveDetector", "SciFi");
 
81
 
 
82
  for ( int trackerNo = 0; trackerNo < 2; trackerNo++ ) {
 
83
    for ( int stationNo = 1; stationNo < 6; stationNo++ ) {
 
84
      for ( int planeNo = 0; planeNo < 3; planeNo++ ) {
 
85
        // get the SciFi Modules
 
86
 
 
87
        const MiceModule* this_plane = NULL;
 
88
        for ( unsigned int j = 0; !this_plane && j < modules.size(); ++j ) {
 
89
        // find the module corresponding to this plane
 
90
          if ( modules[j]->propertyExists("Tracker", "int") &&
 
91
               modules[j]->propertyExists("Station", "int") &&
 
92
               modules[j]->propertyExists("Plane", "int") &&
 
93
               modules[j]->propertyInt("Tracker") == trackerNo &&
 
94
               modules[j]->propertyInt("Station") == stationNo &&
 
95
               modules[j]->propertyInt("Plane") == planeNo )
 
96
            // save the module
 
97
            this_plane = modules[j];
 
98
        }
 
99
        assert(this_plane != NULL);
 
100
 
 
101
        // arguments are the plane module, material and mother physical volume
 
102
        MiceModule* aplane = const_cast < MiceModule* > (this_plane);
 
103
        SciFiPlane(aplane, mat, tracker);
 
104
 
 
105
        // plane 0 (view v), plane 1 (view x), plane 2 (view w)
 
106
        if ( trackerNo == 0 && stationNo == 5 && planeNo == 1 )
 
107
          EXPECT_EQ(SciFiPlane::SciFi_numFibres, 215*7);
 
108
        if ( planeNo == 0 || planeNo == 2 )
 
109
          EXPECT_EQ(SciFiPlane::SciFi_numFibres, 214*7);
 
110
        if ( planeNo == 1 && !(trackerNo == 0 && stationNo == 5) )
 
111
          EXPECT_EQ(SciFiPlane::SciFi_numFibres, 212*7);
 
112
      }
 
113
    }
 
114
  }
 
115
}
 
116
 
 
117
} // namespace