AnnularDetector.cpp 4.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
//////////////////////////////////////////////////////////
//									//
//	AnnularDetector					//
//									//
//
//Some description of this very useful class,
//its properties and a short example how to
//use it. This text may be partly used in
//PhD thesis.
//
//Description of the detector itself.
//
//														//
//////////////////////////////////////////////////////////

#include "AnnularDetector.h"

ClassImp(AnnularDetector);

TRandom3 AnnularDetector::ranTheta(1);
TRandom3 AnnularDetector::ranPhi(1);


AnnularDetector::AnnularDetector()
{
}

AnnularDetector::~AnnularDetector()
{
}

Int_t AnnularDetector::GetChMultiplicity(Bool_t sec)
{
	//Calculate the number of strips which detected signal in one event
	Int_t mult = 0;

	if (sec == 1) {
		for (Int_t i = 0; i < 32; i++) {
			if (fChSec[i] != 0) { mult++; }
		}
	}
	else {
		for (Int_t i = 0; i < 32; i++) {
			if (fChRing[i] != 0) { mult++; }
		}
	}

	return mult;
}

Int_t AnnularDetector::GetEMultiplicity(Bool_t sec)
{
	//Calculate the number of strips which detected signal over particular energy threshold in one event
	Int_t mult = 0;

	if (sec == 1) {
		for (Int_t i = 0; i < 32; i++) {
			if (fESec[i] > 0) { mult++; }
		}
	}
	else {
		for (Int_t i = 0; i < 32; i++) {
			if (fERing[i] > 0) { mult++; }
		}
	}

	return mult;
}

Int_t AnnularDetector::Reset()
{
	//Reset variables with energy and angle information

	for (Int_t i = 0; i < 32; i++) {
		fChRing[i] = 0;
		fChSec[i] = 0;
		fERing[i] = 0.;
		fESec[i] = 0.;
	}

	fMultChRing = 0;
	fMultChSec = 0;
	fMultERing = 0;
	fMultESec = 0;

	return 0;
}

Int_t AnnularDetector::FindSec()
{
	//Find first sector where E != 0

	Int_t i = 0;

	for (i = 0; i < fSecNumber; i++) {
		if (fESec[i] > 0.) { break; }
	}

	if (i == fSecNumber) {
		return (-1);
	}

	return i;
}

Int_t AnnularDetector::FindRing()
{
	//Find first ring where E != 0


	if (fDSD == kFALSE) { Warning("FindRing", "May not be used for this detector (SSD)"); }

	Int_t i = 0;

	for (i = 0; i < fRingsNumber; i++) {
		if (fERing[i] > 0.) { break; }
	}

	if (i == fRingsNumber) {
		return -1;
	}

	return i;
}

Double_t AnnularDetector::GetTheta(Int_t ring)
{
	//Get the angle theta in radians which was measured in the ring.

	if (ring >= fRingsNumber) {
		Warning("GetTheta", "Number of rings in this detector is equal to %d.", fRingsNumber);
		return 0.;	//zamyslet se
	}
	if (ring < 0) {
		Warning("GetTheta", "You cannot input negative ring number.");
		return 0.;	//zamyslet se
	}
	Double_t theta;
	theta = TMath::ATan(( fInnerR + ( ring+ranTheta.Uniform(1) )*(fOuterR - fInnerR)/fRingsNumber )/fZ);

	return theta;
}

Double_t AnnularDetector::GetPhi(Int_t sec)
{
	//Get the angle phi in radians which was measured in the sector sec.

	if (sec >= fSecNumber) {
		Warning("GetPhi", "Number of sectors in this detector is equal to %d.", fRingsNumber);
		return -1.;	//zamyslet se
	}
	if (sec < 0) {
		Warning("GetPhi", "You cannot input negative sector number.");
		return -1.;	//zamyslet se
	}
//	Double_t theta;
//	theta = TMath::ATan(( fInnerR + ( ring+ranTheta.Uniform(1) )*(fOuterR - fInnerR)/fRingsNumber )/fZ);

	return (2*TMath::Pi()/fSecNumber)*( sec + ranTheta.Uniform(1) );
}

Double_t AnnularDetector::GetX(Int_t ring, Int_t sec) {

	TVector2 flat;		//vector in detector plane

	Double_t r = fInnerR + ( ring+ranTheta.Uniform(1) )*(fOuterR - fInnerR)/fRingsNumber;
//	Double_t phi = 2 * TMath::Pi()
//					- (2*TMath::Pi()/fSecNumber)*( sec + ranTheta.Uniform(1) )
//					- TMath::Pi() / 2.;

	Double_t phi = //2 * TMath::Pi()
			- (2 * TMath::Pi() / fSecNumber) * (sec + ranTheta.Uniform(1))
			+ TMath::Pi() / 2.;

//	printf("sec: %d\tphi: %3.2f\n", sec, phi);

	flat.SetMagPhi(r, phi);

//	printf("sec: %d\tphi: %3.2f\tphiV: %3.2f\t\t", sec, phi*TMath::RadToDeg(), flat.Phi()*TMath::RadToDeg());

	return flat.X();
}

Double_t AnnularDetector::GetY(Int_t ring, Int_t sec) {

	TVector2 flat;		//vector in detector plane

	Double_t r = fInnerR + ( ring+ranTheta.Uniform(1) )*(fOuterR - fInnerR)/fRingsNumber;
	Double_t phi = //2 * TMath::Pi()
					- (2*TMath::Pi()/fSecNumber)*( sec + ranTheta.Uniform(1) )
					+ TMath::Pi() / 2.;

	flat.SetMagPhi(r, phi);

	return flat.Y();
}

void AnnularDetector::InitDetector(Bool_t dsd, Int_t nosecs, Int_t norings,
		Double_t innerr, Double_t outerr, Double_t thick,
		Double_t deadthick, Double_t z)
{
	//dsd = 1 for DSSD; dsd = 0 for SSSD
	//nosecs - number of sectors
	//norings - number of rings
	//innerr - inner radius in mm
	//outerr - outer radius in mm
	//thick - thickness of the detector in microns
	//deadthick - thickness of the dead layer in microns
	//z	- distance of the detector from the target

	SetDSD(dsd);
	SetSecNumber(nosecs);
	if (fDSD == 1) { SetRingsNumber(norings); }
	SetInnerR(innerr);
	SetOuterR(outerr);
	SetThickness(thick);
	SetDeadLayerThickness(deadthick);
	SetZ(z);

	return;
}