~scifianalysis/scifi/trackpointdisplay_devel

« back to all changes in this revision

Viewing changes to src/SciFiDisplayHelicalTracksPR.cc

  • Committer: Adam Dobbs
  • Date: 2015-01-06 23:02:17 UTC
  • Revision ID: phuccj@gmail.com-20150106230217-837xm4am3tra75kx
Added support for helical track display

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
// ROOT headers
 
19
#include "TAxis.h"
 
20
#include "TVirtualPad.h"
 
21
 
 
22
// Analysis headers
 
23
#include "SciFiDisplayHelicalTracksPR.hh"
 
24
 
 
25
namespace Analysis {
 
26
 
 
27
SciFiDisplayHelicalTracksPR::SciFiDisplayHelicalTracksPR() : mZMin(0.0),
 
28
                                                             mZMax(1200.0) {
 
29
  // Do nothing
 
30
}
 
31
 
 
32
SciFiDisplayHelicalTracksPR::~SciFiDisplayHelicalTracksPR() {
 
33
  // Do nothing
 
34
}
 
35
 
 
36
void SciFiDisplayHelicalTracksPR::Clear() {
 
37
  mTracksXY1.clear();
 
38
  mTracksZX1.clear();
 
39
  mTracksZY1.clear();
 
40
  mTracksZS1.clear();
 
41
  mTracksXY2.clear();
 
42
  mTracksZX2.clear();
 
43
  mTracksZY2.clear();
 
44
  mTracksZS2.clear();
 
45
}
 
46
 
 
47
void SciFiDisplayHelicalTracksPR::Fill() {
 
48
  Clear();
 
49
  // Loop over the data for each track in the spill and form the tracks
 
50
  for ( size_t i = 0; i < GetData()->mDataPR.size(); ++i ) {
 
51
    mTrackData = GetData()->mDataPR[i];
 
52
    double xc = mTrackData.CircleX0;
 
53
    double yc =  mTrackData.CircleY0;
 
54
    double rad = mTrackData.Radius;
 
55
    double dsdz = mTrackData.dsdz;
 
56
    double csz = mTrackData.SZIntercept;
 
57
    if (mTrackData.TrackerNumber == 0) {
 
58
      mTracksXY1.push_back(MakeCircle(xc, yc, rad));
 
59
      mTracksZX1.push_back(MakeTrackZX(-1, xc, rad, dsdz, csz, mZMin, mZMax));
 
60
      mTracksZY1.push_back(MakeTrackZY(yc, rad, dsdz, csz, mZMin, mZMax));
 
61
    } else if (mTrackData.TrackerNumber == 1) {
 
62
      mTracksXY2.push_back(MakeCircle(xc, yc, rad));
 
63
      mTracksZX2.push_back(MakeTrackZX(-1, xc, rad, dsdz, csz, mZMin, mZMax));
 
64
      mTracksZY2.push_back(MakeTrackZY(yc, rad, dsdz, csz, mZMin, mZMax));
 
65
    }
 
66
  }
 
67
}
 
68
 
 
69
SciFiDataHelicalPR* SciFiDisplayHelicalTracksPR::GetData() {
 
70
  return GetDataTemplate();
 
71
}
 
72
 
 
73
SciFiDataBase* SciFiDisplayHelicalTracksPR::MakeDataObject() {
 
74
  return MakeDataObjectTemplate();
 
75
}
 
76
 
 
77
TArc SciFiDisplayHelicalTracksPR::MakeCircle(double x0, double y0, double rad) {
 
78
  TArc arc = TArc(x0, y0, rad);
 
79
  arc.SetFillStyle(0); // 0 - Transparent
 
80
  arc.SetLineColor(kBlue);
 
81
  return arc;
 
82
};
 
83
 
 
84
TF1 SciFiDisplayHelicalTracksPR::MakeStraightTrack(double c, double m, double zmin, double zmax) {
 
85
  // Note: in the function expression, x is just the independent variable, which
 
86
  // in this case is the z coordinate in the tracker coordinate system
 
87
  TF1 trk = TF1("FuncStraight", "[0]+([1]*x)", zmin, zmax);
 
88
  trk.SetParameters(c, m);
 
89
  trk.SetLineColor(kRed);
 
90
  return trk;
 
91
};
 
92
 
 
93
TF1 SciFiDisplayHelicalTracksPR::MakeTrackZX(int handness, double circle_x0, double rad,
 
94
                                             double dsdz, double sz_c, double zmin, double zmax) {
 
95
  // Note: in the function expression, x is just the independent variable, which
 
96
  // in this case is the z coordinate in the tracker coordinate system
 
97
  TF1 func = TF1("FuncZX", "[0]-[4]*([1]*cos((1/[1])*([2]*x+[3])))", zmin, zmax);
 
98
  func.SetParameter(0, circle_x0);
 
99
  func.SetParameter(1, rad);
 
100
  func.SetParameter(2, dsdz);
 
101
  func.SetParameter(3, sz_c);
 
102
  func.SetParameter(4, handness);
 
103
  func.SetLineColor(kBlue);
 
104
  return func;
 
105
};
 
106
 
 
107
TF1 SciFiDisplayHelicalTracksPR::MakeTrackZY(double circle_y0, double rad, double dsdz,
 
108
                                             double sz_c, double zmin, double zmax) {
 
109
  // Note: in the function expression, x is just the independent variable, which
 
110
  // in this case is the z coordinate in the tracker coordinate system
 
111
  TF1 func = TF1("FuncZY", "[0]+([1]*sin((1/[1])*([2]*x+[3])))", zmin, zmax);
 
112
  func.SetParameter(0, circle_y0);
 
113
  func.SetParameter(1, rad);
 
114
  func.SetParameter(2, dsdz);
 
115
  func.SetParameter(3, sz_c);
 
116
  func.SetLineColor(kBlue);
 
117
  return func;
 
118
};
 
119
 
 
120
 
 
121
void SciFiDisplayHelicalTracksPR::Plot(TCanvas* aCanvas) {
 
122
  // If canvas if passed in use it, otherwise initialise the member canvas
 
123
  TCanvas* lCanvas(NULL);
 
124
  if ( aCanvas ) {
 
125
    lCanvas = aCanvas;
 
126
    if (mCanvas && (mCanvas != aCanvas)) delete mCanvas;
 
127
    mCanvas = aCanvas;
 
128
  } else {
 
129
    if (mCanvas) {
 
130
      mCanvas->Clear();
 
131
    } else {
 
132
      mCanvas = new TCanvas("cHelicalTracksXYZ", "Helical Tracks in XYZ", 200, 10, 700, 500);
 
133
      mCanvas->Divide(3, 2);
 
134
      mCanvas->Draw();
 
135
    }
 
136
    lCanvas = mCanvas;
 
137
  }
 
138
  lCanvas->cd();
 
139
 
 
140
  // Draw the graphs
 
141
  for (size_t i = 0; i < mTracksXY1.size(); ++i) {
 
142
    lCanvas->cd(1);
 
143
    mTracksXY1[i].Draw("same");
 
144
    lCanvas->Update();
 
145
  }
 
146
  for (size_t i = 0; i < mTracksZX1.size(); ++i) {
 
147
    lCanvas->cd(2);
 
148
    mTracksZX1[i].Draw("same");
 
149
    lCanvas->Update();
 
150
  }
 
151
  for (size_t i = 0; i < mTracksZY1.size(); ++i) {
 
152
    lCanvas->cd(3);
 
153
    mTracksZY1[i].Draw("same");
 
154
    lCanvas->Update();
 
155
  }
 
156
  for (size_t i = 0; i < mTracksXY2.size(); ++i) {
 
157
    lCanvas->cd(4);
 
158
    mTracksXY2[i].Draw("same");
 
159
    lCanvas->Update();
 
160
  }
 
161
  for (size_t i = 0; i < mTracksZX2.size(); ++i) {
 
162
    lCanvas->cd(5);
 
163
    mTracksZX2[i].Draw("same");
 
164
    lCanvas->Update();
 
165
  }
 
166
  for (size_t i = 0; i < mTracksZY2.size(); ++i) {
 
167
    lCanvas->cd(6);
 
168
    mTracksZY2[i].Draw("same");
 
169
    lCanvas->Update();
 
170
  }
 
171
 
 
172
  // Update the canvas
 
173
  lCanvas->Update();
 
174
}
 
175
 
 
176
void SciFiDisplayHelicalTracksPR::Save() {
 
177
  std::cerr << "SciFiDisplayHelicalTracksPR::Save: This is just a placeholder function.\n";
 
178
}
 
179
 
 
180
SciFiDataBase* SciFiDisplayHelicalTracksPR::SetData(SciFiDataBase* data) {
 
181
  return SetDataTemplate(data);
 
182
}
 
183
 
 
184
SciFiDataBase* SciFiDisplayHelicalTracksPR::SetUp() {
 
185
  SetUpData();
 
186
  return mSpillData;
 
187
}
 
188
 
 
189
} // ~namespace Analysis