GRSISort "v4.0.0.5"
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 std::vector<TFragment>::iterator pad;
94
95 for(front = fFrontFragments.begin(); front != fFrontFragments.end();) {
96 bool front_used = false;
97 bool back_used = false;
98 for(back = fBackFragments.begin(); back != fBackFragments.end(); back++) {
99 if(front->GetDetector() == back->GetDetector()) {
100 front_used = true;
101 back_used = true;
102 break;
103 }
104 }
105 if(front_used && back_used) {
106 auto* hit = new TSharc2Hit;
107 hit->SetFront(*front);
108 hit->SetBack(*back);
109 AddHit(hit);
110 front = fFrontFragments.erase(front);
111 back = fBackFragments.erase(back);
112 } else {
113 front++;
114 }
115 }
116}
117
118void TSharc2::RemoveHits(std::vector<TSharc2Hit>* hits, std::set<int>* to_remove)
119{
120 for(auto iter = to_remove->rbegin(); iter != to_remove->rend(); ++iter) {
121 if(*iter == -1) {
122 continue;
123 }
124 hits->erase(hits->begin() + *iter);
125 }
126}
127
128void TSharc2::Clear(Option_t* option)
129{
130 TDetector::Clear(option);
131
132 fFrontFragments.clear(); //!
133 fBackFragments.clear(); //!
134
135 if(strcmp(option, "ALL") == 0) {
136 fXoffset = 0.00;
137 fYoffset = 0.00;
138 fZoffset = 0.00;
139 }
140}
141
142void TSharc2::Print(Option_t*) const
143{
144 Print(std::cout);
145}
146
147void TSharc2::Print(std::ostream& out) const
148{
149 std::ostringstream str;
150 str << "not yet written..." << std::endl;
151 out << str.str();
152}
153
154void TSharc2::Copy(TObject& rhs) const
155{
156 TDetector::Copy(rhs);
157}
158
159TVector3 TSharc2::GetPosition(int detector, int frontstrip, int backstrip, double X, double Y, double Z)
160{
161 int FrontDet = detector;
162 int FrontStr = frontstrip;
163 // int BackDet = detector;
164 int BackStr = backstrip;
165 double nrots = 0.; // allows us to rotate into correct position
166
167 TVector3 position;
168 TVector3 position_offset;
169 position_offset.SetXYZ(X, Y, Z);
170
171 //no forward box in SHARC2!!
172 //We will keep detectors 5-8 for the forward box to keep this consistent with the SHARC-1 class
173
174 if(FrontDet >= 9 && FrontDet <= 12) { // backward box
175 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
176 double x = fXposUB;
177 double y = fYminUB + (FrontStr + 0.5) * fStripFPitch; // [(-36.0) - (+36.0)]
178 double z = fZminUB - (BackStr + 0.5) * fStripBPitch; // [(-5.0) - (-53.0)]
179 position.SetXYZ(x, y, z);
180 position.RotateZ(TMath::Pi() * nrots / 2.); //we rotate here because the rotation will be different for the cS2 detectors
181 }
182
183 //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
184 //so that we have a few spare detectors in case we want to add e.g. a thick pad behind the downstream S2 later.
185 else if(FrontDet == 1) { // forward (downstream) compact S2
186 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
187 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.
188 double y = 0; //we start this with the hit oriented at beam left (+x,y=0). Will rotate afterwards
189 double z = fZposDS2;
190 position.SetXYZ(x, y, z);
191 position.RotateZ(fSectorWidthDS2 * nrots + (fSectorWidthDS2 * gRandom->Uniform(-1, 1))); //the addition does randomization over the sector width
192 } else if(FrontDet == 16) { // backward (upstream) compact S2
193 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
194 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.
195 double y = 0; //we start this with the hit oriented at beam left (+x,y=0). Will rotate afterwards
196 double z = -1 * fZposUS2; //minus because we are upstream of the reaction target
197 position.SetXYZ(x, y, z);
198 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
199 }
200
201 return (position + position_offset);
202}
203
204//modified from the SHARC-1 class
206{
207 static std::array<double, 16> fDetectorThickness = {50., 0., 0., 0., 0., 0., 0., 0., 999., 999., 1023., 999., 0., 0., 0., 1004.}; //microns
208 if(dist < 0.0) {
209 dist = fDetectorThickness[hit.GetDetector() - 1]; //minus 1 because the array indexes at 0 but SHARC indexes at 1.
210 }
211
212 double phi_90 = fmod(std::fabs(hit.GetPosition().Phi()), TMath::Pi() / 2);
213 double phi_45 = phi_90;
214 if(phi_90 > (TMath::Pi() / 4.)) {
215 phi_45 = TMath::Pi() / 2 - phi_90;
216 }
217
218 if(hit.GetDetector() >= 5 && hit.GetDetector() <= 12) {
219 return dist / (TMath::Sin(hit.GetPosition().Theta()) * TMath::Cos(phi_45));
220 }
221 return std::fabs(dist / (TMath::Cos(hit.GetPosition().Theta())));
222}
223
225{
226 //these are estimated dead layer thicknesses based on the SHARC-1 information. SHARC-1 1000um BB11's have 0.1 um dead layer thickness.
227 //The SHARC-1 QQQ detectors have 0.7 um dead layer thickness, so we will estimate those for the compact S2 detectors
228 //but WE DON'T KNOW the compact S2 dead layer thicknesses!!! these are GUESSES only!
229 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};
230 return GetDetectorThickness(hit, fDeadLayerThickness[hit.GetDetector() - 1]); //minus 1 because the array indexes at 0 but SHARC indexes at 1.
231}
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
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
void SetFront(const TFragment &frag)
!
TVector3 GetPosition(Double_t dist) const override
!
void RemoveHits(std::vector< TSharc2Hit > *, std::set< int > *)
!
Definition TSharc2.cxx:118
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:142
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:159
void Copy(TObject &) const override
!
Definition TSharc2.cxx:154
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:205
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:128
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:224
static double fSectorWidthUS2
Definition TSharc2.h:100
static double fXminDS2
Definition TSharc2.h:92
std::vector< TFragment > fFrontFragments
Definition TSharc2.h:69