GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TSharc.cxx
Go to the documentation of this file.
1#include "TSharc.h"
2#include "TMnemonic.h"
3
4#include <cstdio>
5#include <iostream>
6#include <cmath>
7
8#include "TClass.h"
9#include "TMath.h"
10
11// various sharc dimensions in mm
12
13// const int TSharc::frontstripslist[16] = {16,16,16,16, 24,24,24,24, 24,24,24,24, 16,16,16,16};
14// const int TSharc::backstripslist[16] = {24,24,24,24, 48,48,48,48, 48,48,48,48, 24,24,24,24};
15
16// const double TSharc::frontpitchlist[16] = {2.0,2.0,2.0,2.0, 3.0,3.0,3.0,3.0, 3.0,3.0,3.0,3.0,
17// 2.0,2.0,2.0,2.0};
18// const double TSharc::backpitchlist[16] = {TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,
19// 1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0, TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48}; // QQQ back
20// pitches are angles
21// const double TSharc::stripFpitch = TSharc::Ydim / TSharc::frontstripslist[5]; // 72.0/24 = 3.0 mm
22// const double TSharc::ringpitch = TSharc::Rdim / TSharc::frontstripslist[1]; // 32.0/16 = 2.0 mm
23// const double TSharc::stripBpitch = TSharc::Zdim / TSharc::backstripslist[5] ; // 48.0/48 = 1.0 mm
24// const double TSharc::segmentpitch = TSharc::Pdim / TSharc::backstripslist[1] ; // 81.6/24 = 3.4 degrees
25// (angular pitch)
26
27//==========================================================================//
28//==========================================================================//
29//==========================================================================//
30//==========================================================================//
31//==========================================================================//
32
33double TSharc::fXoffset = +0.00; //
34double TSharc::fYoffset = +0.00; //
35double TSharc::fZoffset = +0.00; //
36
37double TSharc::fXdim = +72.0; // total X dimension of all boxes
38double TSharc::fYdim = +72.0; // total Y dimension of all boxes
39double TSharc::fZdim = +48.0; // total Z dimension of all boxes
40double TSharc::fRdim = +32.0; // Rmax-Rmin for all QQQs
41double TSharc::fPdim = +81.6; // QQQ quadrant angular range (degrees)
42double TSharc::fXposUB = +42.5;
43double TSharc::fYminUB = -36.0;
44double TSharc::fZminUB = -5.00;
45double TSharc::fXposDB = +40.5;
46double TSharc::fYminDB = -36.0;
47double TSharc::fZminDB = +9.00;
48double TSharc::fZposUQ = -66.5;
49double TSharc::fRmaxUQ = +41.00;
50double TSharc::fRminUQ = +9.00;
51double TSharc::fPminUQ = +2.00; // degrees
52double TSharc::fZposDQ = +74.5;
53double TSharc::fRmaxDQ = +41.00;
54double TSharc::fRminDQ = +9.00;
55double TSharc::fPminDQ = +6.40; // degrees
56
57// const int TSharc::frontstripslist[16] = {16,16,16,16, 24,24,24,24, 24,24,24,24, 16,16,16,16};
58// const int TSharc::backstripslist[16] = {24,24,24,24, 48,48,48,48, 48,48,48,48, 24,24,24,24};
59
60// const double TSharc::frontpitchlist[16] = {2.0,2.0,2.0,2.0, 3.0,3.0,3.0,3.0, 3.0,3.0,3.0,3.0, 2.0,2.0,2.0,2.0};
61// const double TSharc::backpitchlist[16] = {TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,
62// 1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0, TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48};
63// QQQ back pitches are angles
64//
65double TSharc::fStripFPitch = TSharc::fYdim / 24.0; // TSharc::frontstripslist[5]; // 72.0/24 = 3.0 mm
66double TSharc::fRingPitch = TSharc::fRdim / 16.0; // TSharc::frontstripslist[1]; // 32.0/16 = 2.0 mm
67double TSharc::fStripBPitch = TSharc::fZdim / 48.0; // TSharc::backstripslist[5] ; // 48.0/48 = 1.0 mm
69 TSharc::fPdim / 24.0; // TSharc::backstripslist[1] ; // 81.6/24 = 3.4 degrees (angular pitch)
70
71// The dimensions are described for a single detector of each type UQ,UB,DB,DQ, and all other detectors can be
72// calculated by rotating this
73
75{
76 Clear();
77}
78
80{
81 Class()->IgnoreTObjectStreamer(kTRUE);
82 Clear("ALL");
83 rhs.Copy(*this);
84}
85
86void TSharc::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel* chan)
87{
88 if(frag == nullptr || chan == nullptr) {
89 return;
90 }
91 switch(chan->GetMnemonic()->ArraySubPosition()) {
94 fFrontFragments.push_back(*frag);
95 } else {
96 fBackFragments.push_back(*frag);
97 }
98 break;
100 fPadFragments.push_back(*frag);
101 break;
102 default:
103 break;
104 };
105}
106
108{
109 std::vector<TFragment>::iterator front;
110 std::vector<TFragment>::iterator back;
111 std::vector<TFragment>::iterator pad;
112
113 for(front = fFrontFragments.begin(); front != fFrontFragments.end();) {
114 bool front_used = false;
115 bool back_used = false;
116 for(back = fBackFragments.begin(); back != fBackFragments.end(); back++) {
117 if(front->GetDetector() == back->GetDetector()) {
118 front_used = true;
119 back_used = true;
120 break;
121 }
122 }
123 if(front_used && back_used) {
124 auto* hit = new TSharcHit;
125 hit->SetFront(*front);
126 hit->SetBack(*back);
127 AddHit(hit);
128 front = fFrontFragments.erase(front);
129 back = fBackFragments.erase(back);
130 } else {
131 front++;
132 }
133 }
134
135 for(auto& fSharcHit : Hits()) {
136 for(pad = fPadFragments.begin(); pad != fPadFragments.end(); pad++) {
137 if(fSharcHit->GetDetector() == pad->GetDetector()) {
138 static_cast<TSharcHit*>(fSharcHit)->SetPad(*pad);
139 pad = fPadFragments.erase(pad);
140 break;
141 }
142 }
143 }
144}
145
146void TSharc::RemoveHits(std::vector<TSharcHit>* hits, std::set<int>* to_remove)
147{
148 for(auto iter = to_remove->rbegin(); iter != to_remove->rend(); ++iter) {
149 if(*iter == -1) {
150 continue;
151 }
152 hits->erase(hits->begin() + *iter);
153 }
154}
155
156void TSharc::Clear(Option_t* option)
157{
158 TDetector::Clear(option);
159
160 fFrontFragments.clear(); //!
161 fBackFragments.clear(); //!
162 fPadFragments.clear(); //!
163
164 if(strcmp(option, "ALL") == 0) {
165 fXoffset = 0.00;
166 fYoffset = 0.00;
167 fZoffset = 0.00;
168 }
169}
170
171void TSharc::Print(Option_t*) const
172{
173 Print(std::cout);
174}
175
176void TSharc::Print(std::ostream& out) const
177{
178 std::ostringstream str;
179 str << "not yet written..." << std::endl;
180 out << str.str();
181}
182
183void TSharc::Copy(TObject& rhs) const
184{
185 // if(!rhs.InheritsFrom("TSharc"))
186 // return;
187 TDetector::Copy(rhs);
188}
189
190TVector3 TSharc::GetPosition(int detector, int frontstrip, int backstrip, double X, double Y, double Z)
191{
192 int FrontDet = detector;
193 int FrontStr = frontstrip;
194 // int BackDet = detector;
195 int BackStr = backstrip;
196 int nrots = 0; // allows us to rotate into correct position
197
198 TVector3 position;
199 TVector3 position_offset;
200 position_offset.SetXYZ(X, Y, Z);
201
202 if(FrontDet >= 5 && FrontDet <= 8) { // forward box
203 nrots = FrontDet - 4; // edited to make box 5 on the ceiling. assuming rotaing ccw around the +z axis!!
204 double x = fXposDB; // ?? x stays the same. first detector is aways defined in the y-z plane.
205 double y = -(fYminDB + (FrontStr + 0.5) * fStripFPitch); // [(-36.0) - (+36.0)] // ?? add minus sign,
206 // reversve the order of the strips on the ds section.
207 double z = fZminDB + (BackStr + 0.5) * fStripBPitch; // [(+9.0) - (+57.0)]
208 position.SetXYZ(x, y, z);
209 } else if(FrontDet >= 9 && FrontDet <= 12) { // backward box
210 nrots = FrontDet - 8; // edited to make box 5 on the ceiling. assuming rotaing ccw around the +z axis!!
211 double x = fXposUB;
212 double y = fYminUB + (FrontStr + 0.5) * fStripFPitch; // [(-36.0) - (+36.0)]
213 double z = fZminUB - (BackStr + 0.5) * fStripBPitch; // [(-5.0) - (-53.0)]
214 position.SetXYZ(x, y, z);
215 } else if(FrontDet >= 13) { // backward (upstream) QQQ
216 nrots = FrontDet - 13;
217 double z = fZposUQ;
218 double rho = fRmaxUQ - (FrontStr + 0.5) * fRingPitch; // [(+9.0) - (+41.0)]
219 double phi = (fPminUQ + (BackStr + 0.5) * fSegmentPitch) * TMath::Pi() / 180.0; // [(+2.0) - (+83.6)]
220 position.SetXYZ(rho * TMath::Sin(phi), rho * TMath::Cos(phi), z);
221 } else if(FrontDet <= 4) { // forward (downstream) QQQ
222 nrots = FrontDet - 1;
223 double z = fZposDQ;
224 double rho = fRmaxDQ - (FrontStr + 0.5) * fRingPitch; // [(+9.0) - (+41.0)]
225 double phi = (fPminDQ + (BackStr + 0.5) * fSegmentPitch) * TMath::Pi() / 180.0; // [(+6.4) - (+88.0)]
226 position.SetXYZ(rho * TMath::Sin(phi), rho * TMath::Cos(phi), z);
227 }
228
229 position.RotateZ(TMath::Pi() * nrots / 2);
230 return (position + position_offset);
231}
232
234{
235 static std::array<double, 16> fDetectorThickness = {998., 998., 998., 1001., 141., 142., 133., 143.,
236 999., 1001., 1001., 1002., 390., 390., 383., 385.};
237 if(dist < 0.0) {
238 dist = fDetectorThickness[hit.GetDetector()];
239 }
240
241 double phi_90 = fmod(std::fabs(hit.GetPosition().Phi()), TMath::Pi() / 2);
242 double phi_45 = phi_90;
243 if(phi_90 > (TMath::Pi() / 4.)) {
244 phi_45 = TMath::Pi() / 2 - phi_90;
245 }
246
247 if(hit.GetDetector() >= 5 && hit.GetDetector() <= 12) {
248 return dist / (TMath::Sin(hit.GetPosition().Theta()) * TMath::Cos(phi_45));
249 }
250 return std::fabs(dist / (TMath::Cos(hit.GetPosition().Theta())));
251}
252
254{
255 static std::array<double, 16> fDeadLayerThickness = {0.7, 0.7, 0.7, 0.7, 0.1, 0.1, 0.1, 0.1,
256 0.1, 0.1, 0.1, 0.1, 0.7, 0.7, 0.7, 0.7};
257 return GetDetectorThickness(hit, fDeadLayerThickness[hit.GetDetector()]);
258}
259
261{
262 static std::array<double, 16> fPadThickness = {0.0, 0.0, 0.0, 0.0, 1534, 1535, 1535, 1539,
263 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
264 return GetDetectorThickness(hit, fPadThickness[hit.GetDetector()]);
265}
266
268{
269 static std::array<double, 16> fPadDeadLayerThickness = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0,
270 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
271 return GetDetectorThickness(hit, fPadDeadLayerThickness[hit.GetDetector()]);
272}
const TMnemonic * GetMnemonic() const
virtual Int_t GetDetector() const
!
void Copy(TObject &) const override
!
Definition TDetector.cxx:24
void Clear(Option_t *="") override
!
Definition TDetector.h:68
std::vector< TDetectorHit * > & Hits()
Definition TDetector.h:78
virtual void AddHit(TDetectorHit *hit)
Definition TDetector.h:63
virtual EMnemonic ArraySubPosition() const
Definition TMnemonic.h:62
virtual EMnemonic CollectedCharge() const
Definition TMnemonic.h:64
TVector3 GetPosition(Double_t dist) const override
!
Definition TSharcHit.cxx:53
void SetFront(const TFragment &frag)
!
Definition TSharcHit.cxx:79
void RemoveHits(std::vector< TSharcHit > *, std::set< int > *)
!
Definition TSharc.cxx:146
static double GetDeadLayerThickness(TSharcHit &hit)
Definition TSharc.cxx:253
void Clear(Option_t *="") override
!
Definition TSharc.cxx:156
static double fPdim
Rmax-Rmin for all QQQs.
Definition TSharc.h:89
static double fRingPitch
Definition TSharc.h:112
static double fStripBPitch
Definition TSharc.h:111
static double fPminDQ
Definition TSharc.h:105
TSharc()
Definition TSharc.cxx:74
static double fYdim
total X dimension of all boxes
Definition TSharc.h:86
static double fZminDB
Definition TSharc.h:96
static double fRminDQ
Definition TSharc.h:104
std::vector< TFragment > fPadFragments
Definition TSharc.h:71
static double fYminUB
Definition TSharc.h:92
static double fZminUB
Definition TSharc.h:93
static double fPminUQ
Definition TSharc.h:101
static double GetDetectorThickness(TSharcHit &hit, double dist=-1.0)
Definition TSharc.cxx:233
static double fZposDQ
degrees
Definition TSharc.h:102
static double fXposDB
Definition TSharc.h:94
static double fRdim
total Z dimension of all boxes
Definition TSharc.h:88
static TVector3 GetPosition(int detector, int frontstrip, int backstrip, double X=0.00, double Y=0.00, double Z=0.00)
!
Definition TSharc.cxx:190
static double fZdim
total Y dimension of all boxes
Definition TSharc.h:87
static double fZoffset
!
Definition TSharc.h:82
void Copy(TObject &) const override
!
Definition TSharc.cxx:183
static double GetPadThickness(TSharcHit &hit)
Definition TSharc.cxx:260
static double fZposUQ
Definition TSharc.h:98
static double fRmaxUQ
Definition TSharc.h:99
static double fRmaxDQ
Definition TSharc.h:103
static double fYminDB
Definition TSharc.h:95
static double fXdim
Definition TSharc.h:85
std::vector< TFragment > fFrontFragments
Definition TSharc.h:69
static double GetPadDeadLayerThickness(TSharcHit &hit)
Definition TSharc.cxx:267
static double fRminUQ
Definition TSharc.h:100
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
Definition TSharc.cxx:86
void BuildHits() override
!
Definition TSharc.cxx:107
std::vector< TFragment > fBackFragments
Definition TSharc.h:70
static double fSegmentPitch
Definition TSharc.h:113
static double fYoffset
!
Definition TSharc.h:81
static double fXoffset
!
Definition TSharc.h:80
void Print(Option_t *="") const override
!
Definition TSharc.cxx:171
static double fXposUB
QQQ quadrant angular range (degrees)
Definition TSharc.h:91
static double fStripFPitch
degrees
Definition TSharc.h:110