Project

General

Profile

Bug #1832 » test_tof_sp.cc

Rajaram, Durga, 16 March 2016 20:38

 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk/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 <iostream>
19

    
20
#include "src/common_cpp/DataStructure/TOFEvent.hh"
21

    
22
int main(int argc, char* argv[]) {
23
    float z[3] = {4000., 12000., 22000.};
24
    std::vector<MAUS::TOFSpacePoint> tof_sp_vec(0);
25
        
26
    std::cout << "Setting tof space points" << std::endl;
27
    MAUS::TOFSpacePoint tof_sp = MAUS::TOFSpacePoint();
28
    for (int s=0; s<3; ++s) {
29
        tof_sp.SetStation(s);
30
        tof_sp.SetGlobalPosX(z[s]*0.01);
31
        tof_sp.SetGlobalPosY(z[s]*0.02);
32
        tof_sp.SetGlobalPosZ(z[s]);
33
        tof_sp.SetTime(z[s]*0.001);
34
        tof_sp_vec.push_back(tof_sp);
35
        std::cout << "     "  << &tof_sp << " " << tof_sp.GetTime() << " " << tof_sp.GetGlobalPosX() << " " <<  tof_sp.GetGlobalPosY() << " " <<  tof_sp.GetGlobalPosZ() << std::endl;
36
    }
37

    
38
    MAUS::TOFEventSpacePoint tof_space_point = MAUS::TOFEventSpacePoint();
39
    MAUS::TOF0SpacePointArray tof0_sp_array = tof_space_point.GetTOF0SpacePointArray();
40
    tof0_sp_array.push_back(tof_sp_vec[0]);
41
    tof_space_point.SetTOF0SpacePointArray(tof0_sp_array);
42

    
43
    MAUS::TOF1SpacePointArray tof1_sp_array = tof_space_point.GetTOF1SpacePointArray();
44
    tof1_sp_array.push_back(tof_sp_vec[1]);
45
    tof_space_point.SetTOF1SpacePointArray(tof1_sp_array);
46

    
47
    MAUS::TOF2SpacePointArray tof2_sp_array = tof_space_point.GetTOF2SpacePointArray();
48
    tof2_sp_array.push_back(tof_sp_vec[2]);
49
    tof_space_point.SetTOF2SpacePointArray(tof2_sp_array);
50

    
51
        
52
    std::cout << "Getting tof space points - first" << std::endl;
53
    
54
    MAUS::TOFSpacePoint tof0 = tof_space_point.GetTOF0SpacePointArray()[0];
55
    std::cout << "     " << &tof0 << " " << tof0.GetTime() << " " << tof0.GetGlobalPosX() << " " << tof0.GetGlobalPosY() << " " << tof0.GetGlobalPosZ() << std::endl;
56
        
57
    MAUS::TOFSpacePoint tof1 = tof_space_point.GetTOF1SpacePointArray()[0];
58
    std::cout << "     " << &tof1 << " " << tof1.GetTime() << " " << tof1.GetGlobalPosX() << " " << tof1.GetGlobalPosY() << " " << tof1.GetGlobalPosZ() << std::endl;
59
   
60
    MAUS::TOFSpacePoint tof2 = tof_space_point.GetTOF2SpacePointArray()[0];
61
    std::cout << "     " << &tof2 << " " << tof2.GetTime() << " " << tof2.GetGlobalPosX() << " " << tof2.GetGlobalPosY() << " " << tof2.GetGlobalPosZ() << std::endl;
62
   
63
    std::cout << "Getting tof space points - second" << std::endl;
64
    std::cout << "     " << &tof0 << " " << tof0.GetTime() << " " << tof0.GetGlobalPosX() << " " << tof0.GetGlobalPosY() << " " << tof0.GetGlobalPosZ() << std::endl;
65
   
66
    std::cout << "Getting tof space points - third" << std::endl;
67
    // NOTE:
68
    // Expect this to return the same thing thrice since tof_sp is == the last set in the first loop above (lines 47-55)
69
    for (int s=0; s<3; ++s) {
70
        std::cout << "     " << &tof_sp << " " <<  tof_sp.GetTime() << " " << tof_sp.GetGlobalPosX() << " " << tof_sp.GetGlobalPosY() << " " << tof_sp.GetGlobalPosZ() << std::endl;
71
    }
72

    
73
    std::cout << "Getting tof space points - fourth" << std::endl;
74
    // Now, get the correct spacepoint object for each station and hope to see the correct values
75
    std::cout << "     " << &tof0 << " " <<  tof0.GetTime() << " " << tof0.GetGlobalPosX() << " " << tof0.GetGlobalPosY() << " " << tof0.GetGlobalPosZ() << std::endl;
76
    std::cout << "     " << &tof1 << " " <<  tof1.GetTime() << " " << tof1.GetGlobalPosX() << " " << tof1.GetGlobalPosY() << " " << tof1.GetGlobalPosZ() << std::endl;
77
    std::cout << "     " << &tof2 << " " <<  tof2.GetTime() << " " << tof2.GetGlobalPosX() << " " << tof2.GetGlobalPosY() << " " << tof2.GetGlobalPosZ() << std::endl;
78

    
79
} // end main
(3-3/5)