~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_cpp/DataStructure/SciFiEvent.cc

  • Committer: Durga Rajaram
  • Date: 2014-07-16 15:13:05 UTC
  • mfrom: (659.1.92 cand)
  • Revision ID: durga@fnal.gov-20140716151305-q27rv1y9p03v9lks
Tags: MAUS-v0.9, MAUS-v0.9.0
MAUS-v0.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
  _scifitracks.resize(0);
29
29
}
30
30
 
31
 
SciFiEvent::SciFiEvent(const SciFiEvent& _scifievent) {
32
 
    _scifidigits.resize(_scifievent._scifidigits.size());
33
 
    for (unsigned int i = 0; i < _scifievent._scifidigits.size(); ++i) {
34
 
      _scifidigits[i] = new SciFiDigit(*_scifievent._scifidigits[i]);
35
 
    }
36
 
 
37
 
    _scificlusters.resize(_scifievent._scificlusters.size());
38
 
    for (unsigned int i = 0; i < _scifievent._scificlusters.size(); ++i) {
39
 
      _scificlusters[i] = new SciFiCluster(*_scifievent._scificlusters[i]);
40
 
    }
41
 
 
42
 
    _scifispacepoints.resize(_scifievent._scifispacepoints.size());
43
 
    for (unsigned int i = 0; i < _scifievent._scifispacepoints.size(); ++i) {
44
 
      _scifispacepoints[i] = new SciFiSpacePoint(*_scifievent._scifispacepoints[i]);
45
 
    }
46
 
 
47
 
    _scifiseeds.resize(_scifievent._scifiseeds.size());
48
 
    for (unsigned int i = 0; i < _scifievent._scifiseeds.size(); ++i) {
49
 
      _scifiseeds[i] = new SciFiSpacePoint(*_scifievent._scifiseeds[i]);
50
 
    }
51
 
 
52
 
    _scifistraightprtracks.resize(_scifievent._scifistraightprtracks.size());
53
 
    for (unsigned int i = 0; i < _scifievent._scifistraightprtracks.size(); ++i) {
54
 
      _scifistraightprtracks[i] =
55
 
          new SciFiStraightPRTrack(*_scifievent._scifistraightprtracks[i]);
56
 
    }
57
 
 
58
 
    _scifihelicalprtracks.resize(_scifievent._scifihelicalprtracks.size());
59
 
    for (unsigned int i = 0; i < _scifievent._scifihelicalprtracks.size(); ++i) {
60
 
      _scifihelicalprtracks[i] =
61
 
          new SciFiHelicalPRTrack(*_scifievent._scifihelicalprtracks[i]);
62
 
    }
63
 
 
64
 
    _scifitracks.resize(_scifievent._scifitracks.size());
65
 
    for (unsigned int i = 0; i < _scifievent._scifitracks.size(); ++i) {
66
 
      _scifitracks[i] = _scifievent._scifitracks[i];
67
 
    }
 
31
SciFiEvent::SciFiEvent(const SciFiEvent& old_event) {
 
32
  *this = old_event;
68
33
}
69
34
 
70
 
SciFiEvent& SciFiEvent::operator=(const SciFiEvent& _scifievent) {
71
 
  std::cerr << "IN = operator " << std::endl;
72
 
    if (this == &_scifievent) {
73
 
        return *this;
74
 
    }
75
 
 
76
 
    _scifidigits.resize(_scifievent._scifidigits.size());
77
 
    for (unsigned int i = 0; i < _scifievent._scifidigits.size(); ++i) {
78
 
      _scifidigits[i] = new SciFiDigit(*_scifievent._scifidigits[i]);
79
 
    }
80
 
 
81
 
        _scifispacepoints.resize(_scifievent._scifispacepoints.size());
82
 
    for (unsigned int i = 0; i < _scifievent._scifispacepoints.size(); ++i) {
83
 
      _scifispacepoints[i] = new SciFiSpacePoint(*_scifievent._scifispacepoints[i]);
84
 
    }
85
 
 
86
 
    _scifiseeds.resize(_scifievent._scifiseeds.size());
87
 
    for (unsigned int i = 0; i < _scifievent._scifiseeds.size(); ++i) {
88
 
      _scifiseeds[i] = new SciFiSpacePoint(*_scifievent._scifiseeds[i]);
89
 
    }
90
 
 
91
 
    _scifistraightprtracks.resize(_scifievent._scifistraightprtracks.size());
92
 
    for (unsigned int i = 0; i < _scifievent._scifistraightprtracks.size(); ++i) {
93
 
      _scifistraightprtracks[i] =
94
 
          new SciFiStraightPRTrack(*_scifievent._scifistraightprtracks[i]);
95
 
    }
96
 
 
97
 
    _scifihelicalprtracks.resize(_scifievent._scifihelicalprtracks.size());
98
 
    for (unsigned int i = 0; i < _scifievent._scifihelicalprtracks.size(); ++i) {
99
 
      _scifihelicalprtracks[i] =
100
 
          new SciFiHelicalPRTrack(*_scifievent._scifihelicalprtracks[i]);
101
 
    }
102
 
 
103
 
    _scifitracks.resize(_scifievent._scifitracks.size());
104
 
    for (unsigned int i = 0; i < _scifievent._scifitracks.size(); ++i) {
105
 
      _scifitracks[i] = _scifievent._scifitracks[i];
106
 
    }
107
 
 
108
 
    return *this;
 
35
SciFiEvent& SciFiEvent::operator=(const SciFiEvent& rhs) {
 
36
  if (this == &rhs) {
 
37
      return *this;
 
38
  }
 
39
 
 
40
  // Deep copy the digits
 
41
  _scifidigits.resize(rhs._scifidigits.size());
 
42
  for (unsigned int i = 0; i < rhs._scifidigits.size(); ++i) {
 
43
    _scifidigits[i] = new SciFiDigit(*rhs._scifidigits[i]);
 
44
  }
 
45
 
 
46
  // Deep copy the clusters
 
47
  _scificlusters.resize(rhs._scificlusters.size());
 
48
  for (unsigned int i = 0; i < rhs._scificlusters.size(); ++i) {
 
49
    _scificlusters[i] = new SciFiCluster(*rhs._scificlusters[i]);
 
50
    // Now set cross-pointers so they point to correct place in the new copy of the datastructure
 
51
    SciFiDigitPArray new_digits(rhs._scificlusters[i]->get_digits()->GetLast() + 1);
 
52
    for (unsigned int j = 0; j < new_digits.size(); ++j) {
 
53
      new_digits[j] = NULL;
 
54
      for (unsigned int k = 0; k < rhs._scifidigits.size(); ++k) {
 
55
        if (rhs._scificlusters[i]->get_digits()->At(j) == rhs._scifidigits[k]) {
 
56
          new_digits[j] = _scifidigits[k];
 
57
          break;
 
58
        }
 
59
      }
 
60
    }
 
61
    _scificlusters[i]->set_digits_pointers(new_digits);
 
62
  }
 
63
 
 
64
  // Deep copy the spacepoints
 
65
  _scifispacepoints.resize(rhs._scifispacepoints.size());
 
66
  for (unsigned int i = 0; i < rhs._scifispacepoints.size(); ++i) {
 
67
    _scifispacepoints[i] = new SciFiSpacePoint(*rhs._scifispacepoints[i]);
 
68
    // Now set cross-pointers so they point to correct place in the new copy of the datastructure
 
69
    SciFiClusterPArray new_clusters(rhs._scifispacepoints[i]->get_channels()->GetLast() + 1);
 
70
    for (unsigned int j = 0; j < new_clusters.size(); ++j) {
 
71
      new_clusters[j] = NULL;
 
72
      for (unsigned int k = 0; k < rhs._scificlusters.size(); ++k) {
 
73
        if (rhs._scifispacepoints[i]->get_channels()->At(j) == rhs._scificlusters[k]) {
 
74
          new_clusters[j] = _scificlusters[k];
 
75
          break;
 
76
        }
 
77
      }
 
78
    }
 
79
    _scifispacepoints[i]->set_channels_pointers(new_clusters);
 
80
  }
 
81
 
 
82
  // Deep copy the seeds
 
83
  _scifiseeds.resize(rhs._scifiseeds.size());
 
84
  for (unsigned int i = 0; i < rhs._scifiseeds.size(); ++i) {
 
85
    _scifiseeds[i] = new SciFiSpacePoint(*rhs._scifiseeds[i]);
 
86
    // Now set cross-pointers so they point to correct place in the new copy of the datastructure
 
87
    SciFiClusterPArray new_clusters(rhs._scifiseeds[i]->get_channels()->GetLast() + 1);
 
88
    for (unsigned int j = 0; j < new_clusters.size(); ++j) {
 
89
        new_clusters[j] = NULL;
 
90
        for (unsigned int k = 0; k < rhs._scificlusters.size(); ++k) {
 
91
            if (rhs._scifiseeds[i]->get_channels()->At(j) == rhs._scificlusters[k]) {
 
92
                new_clusters[j] = _scificlusters[k];
 
93
                break;
 
94
            }
 
95
        }
 
96
    }
 
97
    _scifiseeds[i]->set_channels_pointers(new_clusters);
 
98
  }
 
99
 
 
100
  // Deep copy the straight pattern recognition tracks
 
101
  _scifistraightprtracks.resize(rhs._scifistraightprtracks.size());
 
102
  for (unsigned int i = 0; i < rhs._scifistraightprtracks.size(); ++i) {
 
103
    _scifistraightprtracks[i] = new SciFiStraightPRTrack(*rhs._scifistraightprtracks[i]);
 
104
    // Now set cross-pointers so they point to correct place in the new copy of the datastructure
 
105
    SciFiSpacePointPArray new_sps(rhs._scifistraightprtracks[i]->get_spacepoints()->GetLast()+1);
 
106
    for (unsigned int j = 0; j < new_sps.size(); ++j) {
 
107
      new_sps[j] = NULL;
 
108
      for (unsigned int k = 0; k < rhs._scifispacepoints.size(); ++k) {
 
109
        if (rhs._scifistraightprtracks[i]->get_spacepoints_pointers()[j] ==
 
110
          rhs._scifispacepoints[k]) {
 
111
          new_sps[j] = _scifispacepoints[k];
 
112
          break;
 
113
        }
 
114
      }
 
115
    }
 
116
    _scifistraightprtracks[i]->set_spacepoints_pointers(new_sps);
 
117
  }
 
118
 
 
119
  // Deep copy the helical pattern recognition tracks
 
120
  _scifihelicalprtracks.resize(rhs._scifihelicalprtracks.size());
 
121
  for (unsigned int i = 0; i < rhs._scifihelicalprtracks.size(); ++i) {
 
122
    _scifihelicalprtracks[i] = new SciFiHelicalPRTrack(*rhs._scifihelicalprtracks[i]);
 
123
    // Now set cross-pointers so they point to correct place in the new copy of the datastructure
 
124
    SciFiSpacePointPArray new_sps(rhs._scifihelicalprtracks[i]->get_spacepoints()->GetLast() + 1);
 
125
    for (unsigned int j = 0; j < new_sps.size(); ++j) {
 
126
      new_sps[j] = NULL;
 
127
      for (unsigned int k = 0; k < rhs._scifispacepoints.size(); ++k) {
 
128
        if (rhs._scifihelicalprtracks[i]->get_spacepoints()->At(j) == rhs._scifispacepoints[k]) {
 
129
          new_sps[j] = _scifispacepoints[k];
 
130
          break;
 
131
        }
 
132
      }
 
133
    }
 
134
    _scifihelicalprtracks[i]->set_spacepoints_pointers(new_sps);
 
135
  }
 
136
 
 
137
  // Deep copy the kalman tracks
 
138
  _scifitracks.resize(rhs._scifitracks.size());
 
139
  for (unsigned int iTrk = 0; iTrk < rhs._scifitracks.size(); ++iTrk) {
 
140
    _scifitracks[iTrk] =  new SciFiTrack(*rhs._scifitracks[iTrk]);
 
141
    // Deep copy the scifi trackpoints
 
142
    SciFiTrackPointPArray rhs_tpoints = rhs._scifitracks[iTrk]->scifitrackpoints();
 
143
    SciFiTrackPointPArray new_tpoints(rhs_tpoints.size());
 
144
    // Loop over the rhs track trackpoints
 
145
    for (unsigned int iRtp = 0; iRtp < rhs_tpoints.size(); ++iRtp) {
 
146
      new_tpoints[iRtp] = new SciFiTrackPoint(*(rhs_tpoints[iRtp]));
 
147
      // Now set the cross-pointer to the cluster within the trackpoint so that it points to
 
148
      // correct place in the new copy of the datastructure, by searching for the cluster index in
 
149
      // rhs event, which matches the pointer address of the cluster in the rhs trackpoint. Use
 
150
      // this to set new trackpoint cluster to pointer to the correct cluster in the new event.
 
151
      SciFiCluster* new_cluster = NULL;
 
152
      for (unsigned int iRcl = 0; iRcl < rhs.clusters().size(); ++iRcl) {
 
153
        if (rhs_tpoints[iRtp]->get_cluster_pointer() == rhs._scificlusters[iRcl]) {
 
154
          new_cluster = _scificlusters[iRcl];
 
155
          break;
 
156
        }
 
157
      }
 
158
      new_tpoints[iRtp]->set_cluster_pointer(new_cluster);
 
159
    }
 
160
    _scifitracks[iTrk]->set_scifitrackpoints(new_tpoints);
 
161
  }
 
162
  return *this;
109
163
}
110
164
 
111
165
SciFiEvent::~SciFiEvent() {