GRSISort "v4.1.1.0"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TSharc2.cxx
Go to the documentation of this file.
1#include "TSharc2.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//==========================================================================//
12//==========================================================================//
13//==========================================================================//
14//==========================================================================//
15//==========================================================================//
16
17//all units in mm unless otherwise noted
18
19//default offset of things. Assume 0 unless otherwise noted.
20double TSharc2::fXoffset = +0.00; //
21double TSharc2::fYoffset = +0.00; //
22double TSharc2::fZoffset = +0.00; //
23
24//UBOX details
25double TSharc2::fXdim = +72.0; // total X dimension of all boxes
26double TSharc2::fYdim = +72.0; // total Y dimension of all boxes
27double TSharc2::fZdim = +48.0; // total Z dimension of all boxes
28double TSharc2::fXposUB = +42.5;
29double TSharc2::fYminUB = -36.0;
30double TSharc2::fZminUB = -5.00;
31
32//Downstream cS2 details
33double TSharc2::fZposDS2 = 58.5; // short spacer
34//double TSharc2::fZposDS2 = 41.5; //long spacer
35double TSharc2::fXminDS2 = 11.0; //inner radius of cS2 active area
36double TSharc2::fStripPitchDS2 = 0.5; //0.5 mm strip width;
37double TSharc2::fSectorWidthDS2 = 2 * TMath::Pi() / 16.0; //16 sectors. this is in radians
38
39//Upstream cS2 details
40double TSharc2::fZposUS2 = 72.0; // distance from target to UcS2
41double TSharc2::fXminUS2 = 11.0; //inner radius of cS2 active area
42double TSharc2::fStripPitchUS2 = 0.5; //0.5 mm strip width;
43double TSharc2::fSectorWidthUS2 = 2 * TMath::Pi() / 16.0; //16 sectors. this is in radians
44
45// const int TSharc2::frontstripslist[16] = {16,16,16,16, 24,24,24,24, 24,24,24,24, 16,16,16,16};
46// const int TSharc2::backstripslist[16] = {24,24,24,24, 48,48,48,48, 48,48,48,48, 24,24,24,24};
47
48// const double TSharc2::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};
49// const double TSharc2::backpitchlist[16] = {TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,TMath::Pi()/48,
50// 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};
51// QQQ back pitches are angles
52//
53double TSharc2::fStripFPitch = TSharc2::fYdim / 24.0; // TSharc2::frontstripslist[5]; // 72.0/24 = 3.0 mm
54double TSharc2::fStripBPitch = TSharc2::fZdim / 48.0; // TSharc2::backstripslist[5] ; // 48.0/48 = 1.0 mm
55
56// The dimensions are described for a single detector of each type UQ,UB,DB,DQ, and all other detectors can be
57// calculated by rotating this
58
60{
61 Clear();
62}
63
65{
66 Class()->IgnoreTObjectStreamer(kTRUE);
67 Clear("ALL");
68 rhs.Copy(*this);
69}
70
71void TSharc2::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel* chan)
72{
73 if(frag == nullptr || chan == nullptr) {
74 return;
75 }
76 switch(chan->GetMnemonic()->ArraySubPosition()) {
79 fFrontFragments.push_back(*frag);
80 } else {
81 fBackFragments.push_back(*frag);
82 }
83 break;
84 default:
85 break;
86 };
87}
88
90{
91 std::vector<TFragment>::iterator front;
92 std::vector<TFragment>::iterator back;
93
94 for(front = fFrontFragments.begin(); front != fFrontFragments.end();) {
95 bool front_used = false;
96 bool back_used = false;
97 for(back = fBackFragments.begin(); back != fBackFragments.end(); back++) {
98 if(front->GetDetector() == back->GetDetector()) {
99 front_used = true;
100 back_used = true;
101 break;
102 }
103 }
104 if(front_used && back_used) {
105 auto* hit = new TSharc2Hit;
106 hit->SetFront(*front);
107 hit->SetBack(*back);
108 AddHit(hit);
109 front = fFrontFragments.erase(front);
110 back = fBackFragments.erase(back);
111 } else {
112 front++;
113 }
114 }
115}
116
117void TSharc2::RemoveHits(std::vector<TSharc2Hit>* hits, std::set<int>* to_remove)
118{
119 for(auto iter = to_remove->rbegin(); iter != to_remove->rend(); ++iter) {
120 if(*iter == -1) {
121 continue;
122 }
123 hits->erase(hits->begin() + *iter);
124 }
125}
126
127void TSharc2::Clear(Option_t* option)
128{
129 TDetector::Clear(option);
130
131 fFrontFragments.clear(); //!
132 fBackFragments.clear(); //!
133
134 if(strcmp(option, "ALL") == 0) {
135 fXoffset = 0.00;
136 fYoffset = 0.00;
137 fZoffset = 0.00;
138 }
139}
140
141void TSharc2::Print(Option_t*) const
142{
143 Print(std::cout);
144}
145
146void TSharc2::Print(std::ostream& out) const
147{
148 std::ostringstream str;
149 str << "not yet written..." << std::endl;
150 out << str.str();
151}
152
153void TSharc2::Copy(TObject& rhs) const
154{
155 TDetector::Copy(rhs);
156}
157
158TVector3 TSharc2::GetPosition(int detector, int frontstrip, int backstrip, double X, double Y, double Z)
159{
160 int FrontDet = detector;
161 int FrontStr = frontstrip;
162 // int BackDet = detector;
163 int BackStr = backstrip;
164 double nrots = 0.; // allows us to rotate into correct position
165
166 TVector3 position;
167 TVector3 position_offset;
168 position_offset.SetXYZ(X, Y, Z);
169
170 //no forward box in SHARC2!!
171 //We will keep detectors 5-8 for the forward box to keep this consistent with the SHARC-1 class
172
173 if(FrontDet >= 9 && FrontDet <= 12) { // backward box
174 nrots = FrontDet - 9 + 0.5; // edited to make box 9 on the beam left (+x direction). assuming rotation consistent with TIGRESS (clockwise when looking along beam travel direction)! plus 0.5 because the BOX detectors are shifted by 45 deg from parallel to lab vertical/horizontal
175 double x = fXposUB;
176 double y = fYminUB + (FrontStr + 0.5) * fStripFPitch; // [(-36.0) - (+36.0)]
177 double z = fZminUB - (BackStr + 0.5) * fStripBPitch; // [(-5.0) - (-53.0)]
178 position.SetXYZ(x, y, z);
179 position.RotateZ(TMath::Pi() * nrots / 2.); //we rotate here because the rotation will be different for the cS2 detectors
180 }
181
182 //only 1 up/downstream detector for SHARC-2 instead of the 4 QQQs from SHARC-1. We will set them at detector number 1 and 16
183 //so that we have a few spare detectors in case we want to add e.g. a thick pad behind the downstream S2 later.
184 else if(FrontDet == 1) { // forward (downstream) compact S2
185 nrots = (BackStr - 7) + 0.5; //sector 7 is the sector just clockwise from (+x,y=0). We remove that number to get the nrots needed. We add 0.5 to rotate to the middle of the sector too
186 double x = fXminDS2 + fStripPitchDS2 * (FrontStr + 0.5); //Counting from the inside radius to the outside radius. Add 0.5 to center in the middle of the ring.
187 double y = 0; //we start this with the hit oriented at beam left (+x,y=0). Will rotate afterwards
188 double z = fZposDS2;
189 position.SetXYZ(x, y, z);
190 position.RotateZ(fSectorWidthDS2 * nrots + (fSectorWidthDS2 * gRandom->Uniform(-1, 1))); //the addition does randomization over the sector width
191 } else if(FrontDet == 16) { // backward (upstream) compact S2
192 nrots = (BackStr - 15) + 0.5; //sector 15 is the sector just clockwise from (+x,y=0). We remove that number to get the nrots needed. We add 0.5 to rotate to the middle of the sector too
193 double x = fXminUS2 + fStripPitchUS2 * (FrontStr + 0.5); //Counting from the inside radius to the outside radius. Add 0.5 to center in the middle of the ring.
194 double y = 0; //we start this with the hit oriented at beam left (+x,y=0). Will rotate afterwards
195 double z = -1 * fZposUS2; //minus because we are upstream of the reaction target
196 position.SetXYZ(x, y, z);
197 position.RotateZ(-1 * fSectorWidthUS2 * nrots + (fSectorWidthUS2 * gRandom->Uniform(-1, 1))); //we multiply this one by -1 because the upstream cS2 needs to be rotated the opposite direction. Both cS2 detectors are rotated CW relative to beam, but they are mounted opposite
198 }
199
200 return (position + position_offset);
201}
202
203//modified from the SHARC-1 class
205{
206 static std::array<double, 16> fDetectorThickness = {50., 0., 0., 0., 0., 0., 0., 0., 999., 999., 1023., 999., 0., 0., 0., 1004.}; //microns
207 if(dist < 0.0) {
208 dist = fDetectorThickness[hit.GetDetector() - 1]; //minus 1 because the array indexes at 0 but SHARC indexes at 1.
209 }
210
211 double phi_90 = fmod(std::fabs(hit.GetPosition().Phi()), TMath::Pi() / 2);
212 double phi_45 = phi_90;
213 if(phi_90 > (TMath::Pi() / 4.)) {
214 phi_45 = TMath::Pi() / 2 - phi_90;
215 }
216
217 if(hit.GetDetector() >= 5 && hit.GetDetector() <= 12) {
218 return dist / (TMath::Sin(hit.GetPosition().Theta()) * TMath::Cos(phi_45));
219 }
220 return std::fabs(dist / (TMath::Cos(hit.GetPosition().Theta())));
221}
222
224{
225 //these are estimated dead layer thicknesses based on the SHARC-1 information. SHARC-1 1000um BB11's have 0.1 um dead layer thickness.
226 //The SHARC-1 QQQ detectors have 0.7 um dead layer thickness, so we will estimate those for the compact S2 detectors
227 //but WE DON'T KNOW the compact S2 dead layer thicknesses!!! these are GUESSES only!
228 static std::array<double, 16> fDeadLayerThickness = {0.7, 0., 0., 0., 0., 0., 0., 0., 0.1, 0.1, 0.1, 0.1, 0., 0., 0., 0.7};
229 return GetDetectorThickness(hit, fDeadLayerThickness[hit.GetDetector() - 1]); //minus 1 because the array indexes at 0 but SHARC indexes at 1.
230}
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.cxx:67
virtual void AddHit(TDetectorHit *hit)
Definition TDetector.h:60
virtual EMnemonic ArraySubPosition() const
Definition TMnemonic.h:63
virtual EMnemonic CollectedCharge() const
Definition TMnemonic.h:65
void SetFront(const TFragment &frag)
!
TVector3 GetPosition(Double_t dist) const override
!
void RemoveHits(std::vector< TSharc2Hit > *, std::set< int > *)
!
Definition TSharc2.cxx:117
std::vector< TFragment > fBackFragments
Definition TSharc2.h:70
static double fXdim
Definition TSharc2.h:83
static double fXposUB
total Z dimension of all boxes
Definition TSharc2.h:86
void Print(Option_t *="") const override
!
Definition TSharc2.cxx:141
static double fStripFPitch
Definition TSharc2.h:106
static double fSectorWidthDS2
Definition TSharc2.h:94
static double fStripBPitch
Definition TSharc2.h:107
TSharc2()
Definition TSharc2.cxx:59
static double fZdim
total Y dimension of all boxes
Definition TSharc2.h:85
void BuildHits() override
!
Definition TSharc2.cxx:89
static double fYoffset
!
Definition TSharc2.h:78
static TVector3 GetPosition(int detector, int frontstrip, int backstrip, double X=0.00, double Y=0.00, double Z=0.00)
!
Definition TSharc2.cxx:158
void Copy(TObject &) const override
!
Definition TSharc2.cxx:153
static double fXoffset
!
Definition TSharc2.h:77
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
Definition TSharc2.cxx:71
static double fXminUS2
Definition TSharc2.h:98
static double fZminUB
Definition TSharc2.h:88
static double fZposDS2
Definition TSharc2.h:91
static double GetDetectorThickness(TSharc2Hit &hit, double dist=-1.0)
Definition TSharc2.cxx:204
static double fZposUS2
Definition TSharc2.h:97
static double fStripPitchUS2
Definition TSharc2.h:99
static double fZoffset
!
Definition TSharc2.h:79
static double fStripPitchDS2
Definition TSharc2.h:93
void Clear(Option_t *="") override
!
Definition TSharc2.cxx:127
static double fYminUB
Definition TSharc2.h:87
static double fYdim
total X dimension of all boxes
Definition TSharc2.h:84
static double GetDeadLayerThickness(TSharc2Hit &hit)
Definition TSharc2.cxx:223
static double fSectorWidthUS2
Definition TSharc2.h:100
static double fXminDS2
Definition TSharc2.h:92
std::vector< TFragment > fFrontFragments
Definition TSharc2.h:69