~durga/maus/online

« back to all changes in this revision

Viewing changes to src/legacy/Optics/AnalysisPlaneBank.cc

Builds but segv on executation of test_cpp

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include <fstream>
 
3
#include "AnalysisPlaneBank.hh"
 
4
 
 
5
using namespace std;
 
6
 
 
7
AnalysisPlaneBank::AnalysisPlaneBank() : CovarianceMatrix(6,6,0)
 
8
 
 
9
{
 
10
        planeType=0;
 
11
        planeNumber=0;
 
12
        weight=0;
 
13
        z=0;
 
14
        t=0;
 
15
        pz=0;
 
16
        E=0;
 
17
        beta_p=0;
 
18
        l_can=0;
 
19
        amplitudePzCovariance=0;
 
20
        for(int i=0; i<3; i++)
 
21
        {
 
22
                beta[i]=0;
 
23
                em2d[i]=0;
 
24
                sums[2*i]=0;
 
25
                sums[2*i+1]=0;
 
26
        }
 
27
 
 
28
        em4dXY=0;
 
29
        em6dTXY=0;
 
30
}
 
31
 
 
32
 
 
33
const AnalysisPlaneBank& AnalysisPlaneBank::operator= (const AnalysisPlaneBank& rhs)
 
34
{
 
35
        planeType=rhs.planeType;
 
36
        planeNumber=rhs.planeNumber;
 
37
        weight=rhs.weight;
 
38
        z=rhs.z;
 
39
        t=rhs.t;
 
40
        pz=rhs.pz;
 
41
        E=rhs.E;
 
42
        beta_p=rhs.beta_p;
 
43
        l_can=rhs.l_can;
 
44
        amplitudePzCovariance=rhs.amplitudePzCovariance;
 
45
        for(int i=0; i<3; i++)
 
46
        {
 
47
                beta[i]=rhs.beta[i];
 
48
                em2d[i]=rhs.em2d[i];
 
49
                sums[2*i]=rhs.sums[2*i];
 
50
                sums[2*i+1]=rhs.sums[2*i+1];
 
51
        }
 
52
        CovarianceMatrix = rhs.CovarianceMatrix;
 
53
        em4dXY=rhs.em4dXY;
 
54
        em6dTXY=rhs.em6dTXY;
 
55
 
 
56
        return rhs;
 
57
}
 
58
 
 
59
AnalysisPlaneBank::AnalysisPlaneBank(const AnalysisPlaneBank& rhs)
 
60
{
 
61
        planeType=rhs.planeType;
 
62
        planeNumber=rhs.planeNumber;
 
63
        weight=rhs.weight;
 
64
        z=rhs.z;
 
65
        t=rhs.t;
 
66
        pz=rhs.pz;
 
67
        E=rhs.E;
 
68
        beta_p=rhs.beta_p;
 
69
        l_can=rhs.l_can;
 
70
        amplitudePzCovariance=rhs.amplitudePzCovariance;
 
71
        for(int i=0; i<3; i++)
 
72
        {
 
73
                beta[i]=rhs.beta[i];
 
74
                em2d[i]=rhs.em2d[i];
 
75
                sums[2*i]=rhs.sums[2*i];
 
76
                sums[2*i+1]=rhs.sums[2*i+1];
 
77
        }
 
78
        CovarianceMatrix = rhs.CovarianceMatrix;
 
79
        em4dXY=rhs.em4dXY;
 
80
        em6dTXY=rhs.em6dTXY;
 
81
 
 
82
}
 
83
 
 
84
 
 
85
AnalysisPlaneBank::~AnalysisPlaneBank() {}
 
86
 
 
87
void AnalysisPlaneBank::Write(std::ostream &fout) const
 
88
{
 
89
        fout << planeType << " " << planeNumber << " " << weight << " " << z << " " << t << " "
 
90
             << pz << " " << E << " ";
 
91
        for(int i=0; i<3; i++)
 
92
                fout << beta[i] << " ";
 
93
        fout << beta_p << " " << " " << amplitudePzCovariance << " " << l_can << " ";
 
94
        for(int i=0; i<3; i++)
 
95
                fout << em2d[i] << " ";
 
96
        fout << em4dXY << " " << em6dTXY << std::endl;
 
97
        for(int i=0; i<6; i++)
 
98
                fout << sums[i] << " " ;
 
99
        fout << CovarianceMatrix;
 
100
}
 
101
 
 
102
void AnalysisPlaneBank::WriteHeader(std::ostream &fout) const
 
103
{
 
104
        fout << "planeType  planeNumber  weight  <z>  <t>  <pz>  <E>  beta[0]  beta[1]  beta[2]  beta_p  <SPE*Pz> <l_kin>  "
 
105
 
 
106
             << "em2d_0  em2d_1  em2d_2  em4dXY  em6dTXY" << std::endl;
 
107
        for(int i=0; i<6; i++)
 
108
                fout << " mean_" << i;
 
109
        fout << std::endl;
 
110
        for(int i=0; i<6; i++)
 
111
        {
 
112
                for(int j=0; j<6; j++)
 
113
                        fout << " Cov(" << i << "," << j << ")";
 
114
                fout << std::endl;
 
115
        }
 
116
}
 
117
 
 
118
void AnalysisPlaneBank::Read(std::istream& fin)
 
119
{
 
120
        fin >> planeType >> planeNumber >> weight >> z >> t >> pz >> E;
 
121
        for(int i=0; i<3; i++)
 
122
                fin >> beta[i];
 
123
        fin >> beta_p >> amplitudePzCovariance >> l_can;
 
124
        for(int i=0; i<3; i++)
 
125
                fin >> em2d[i];
 
126
        fin >> em4dXY >> em6dTXY;
 
127
        for(int i=0; i<6; i++)
 
128
                fin >> sums[i];
 
129
 
 
130
        for(int i=0; i<6; i++)
 
131
                for(int j=0; j<6; j++)
 
132
                        fin >> CovarianceMatrix[i][j];
 
133
 
 
134
}
 
135
 
 
136
std::ostream& operator << (std::ostream& out, const AnalysisPlaneBank& bank )
 
137
{
 
138
        bank.Write(out);
 
139
        return out;
 
140
}
 
141
 
 
142
std::istream& operator >> (std::istream& in,  AnalysisPlaneBank& bank )
 
143
{
 
144
        bank.Read(in);
 
145
        return in;
 
146
}