AculCalParsSi.cpp 5.31 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
/*
 * AculCalParsSi.cpp
 *
 *  Created on: Oct 26, 2016
 *      Author: vratik
 */

#include "AculCalParsSi.h"

AculCalParsSi::AculCalParsSi() {
	// TODO Auto-generated constructor stub
	Reset();
}

AculCalParsSi::AculCalParsSi(const char* parFile) {

	SetParFile(parFile);
	Init();
}

AculCalParsSi::~AculCalParsSi() {
	// TODO Auto-generated destructor stub
}

void AculCalParsSi::Init() {
	SetELosses();
	SetPars();
	SetCalEnergies();
}

void AculCalParsSi::Reset() {
	fParFileName = "";

	kRaNOPEAKS = 0;

	fEnergyInput.clear();
	fLowerChannel = 0.;
	fUpperChannel = 0.;
	fLowerPeakRelativeHight = 0.;
	fUpperPeakRelativeHight = 0.;
	fPeakPositionTolerance = 0.;
	fFitFuncLineWidth = 1;
	fFitMinSigma = 0.;
	fFitPeakThreshold = 0.;
	fDeadLayer = 0.;

	return;
}

void AculCalParsSi::SetPars() {
	if (fParFileName.Length()==0) {
		cerr << "\'AculCalibration::SetInputsParameters\" File with input parameters was not set." << endl;
		return;
	}

	const Int_t lineLength = 400;
	Char_t	line[lineLength];
	Char_t	parameter[100];
	Char_t	identificator[100];


62
	std::ifstream fipr;
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
	fipr.open(fParFileName.Data());
	if (!fipr.is_open()) {
		cerr << "\"AculCalibration::SetInputsParameters\" File with input parameters \""
				<< fParFileName << "\" was not opened." << endl;
		return;
	}

	cout << "\"AculCalibration::SetInputsParameters\" File with input parameters \""
			<< fParFileName << "\" will be processed." << endl;

	while (!fipr.eof()) {

		fipr.getline(line, lineLength);
		if (strlen(line) < 2) {
			continue;
		}

		sscanf(line, "%s %s", parameter, identificator);

		if ( strcmp(identificator, "noPeaks") == 0 ) {
			kRaNOPEAKS = static_cast<Int_t>(atoi(parameter));
			fEnergyInput.resize(kRaNOPEAKS);
			fEtab.resize(kRaNOPEAKS);
			for (Int_t i = 0; i < kRaNOPEAKS; i++) {
				fipr.getline(line, lineLength);
				sscanf(line, "%s", parameter);
				fEnergyInput[i] = static_cast<Double_t>(atof(parameter));
			}
			continue;
		}//if

		if ( strcmp(identificator, "lowerChannel") == 0 ) {
			sscanf(line, "%s", parameter);
			fLowerChannel = static_cast<Double_t>(atof(parameter));
		}

		if ( strcmp(identificator, "upperChannel") == 0 ) {
			sscanf(line, "%s", parameter);
			fUpperChannel = static_cast<Double_t>(atof(parameter));
		}

		if ( strcmp(identificator, "lowerPeakHight") == 0 ) {
			sscanf(line, "%s", parameter);
			fLowerPeakRelativeHight = static_cast<Double_t>(atof(parameter));
		}

		if ( strcmp(identificator, "upperPeakHight") == 0 ) {
			sscanf(line, "%s", parameter);
			fUpperPeakRelativeHight = static_cast<Double_t>(atof(parameter));
		}

		if ( strcmp(identificator, "peakPositionTolerance") == 0 ) {
			sscanf(line, "%s", parameter);
			fPeakPositionTolerance = static_cast<Double_t>(atof(parameter));
		}

		if ( strcmp(identificator, "fitFunctionLineWidth") == 0 ) {
			sscanf(line, "%s", parameter);
			fFitFuncLineWidth = static_cast<Width_t>(atoi(parameter));
		}

		if ( strcmp(identificator, "minFitSigma") == 0 ) {
			sscanf(line, "%s", parameter);
			fFitMinSigma = static_cast<Double_t>(atof(parameter));
		}

		if ( strcmp(identificator, "fitHightThreshold") == 0 ) {
			sscanf(line, "%s", parameter);
			fFitPeakThreshold = static_cast<Double_t>(atof(parameter));
		}

		if ( strcmp(identificator, "deadLayer") == 0 ) {
			sscanf(line, "%s", parameter);
			fDeadLayer = static_cast<Double_t>(atof(parameter));
		}

	}


	fipr.close();

	return;
}

void AculCalParsSi::PrintParameters(const char* option)
{
	//print alpha source parameters

	cout << "AculCalibration::PrintInputParameters:" << endl;
	cout << "\tNumber of peaks: " << kRaNOPEAKS << endl;
	for (Int_t i = 0; i < kRaNOPEAKS; i++) {
		cout << "\t\tfEnergyInput[" << i << "] = " << fEnergyInput[i] << " MeV" << endl;
	}
	cout << "\tEnergies used for calibration:" << endl;
	cout << "\t(deadLayer: " << fDeadLayer << " mcm)" << endl;
	for (Int_t i = 0; i < kRaNOPEAKS; i++) {
		cout << "\t\tfE[" << i << "] = " << fEtab[i] << " MeV" << endl;
	}

	cout << "\tlowerChannel: " << fLowerChannel << "; upperChannel: " << fUpperChannel << ";" << endl;
	cout << "\tlowerPeakHight: " << fLowerPeakRelativeHight << "; upperPeakHight: " << fUpperPeakRelativeHight << ";" << endl;
	cout << "\tfitHightThreshold: " << fFitPeakThreshold << "; minFitSigma: " << fFitMinSigma << ";" << endl;
	cout << "\tpeakPositionTolerance: " << fPeakPositionTolerance << ";" << endl;
	cout << "\tfitFunctionLineWidth: " << fFitFuncLineWidth << ";" << endl;

	return;

}

void AculCalParsSi::SetELosses() {

	Info("AculCalibration::SetELosses", "Combination of aplha particle with silicon material only.");
	fAlphaSi.SetEL(1, 2.321); // density in g/cm3
	fAlphaSi.AddEL(14., 28.086, 1);  //Z, mass
//	mSi.SetZP(1., 1.);		//protons
	fAlphaSi.SetZP(2., 4.);		//alphas, Z, A
	fAlphaSi.SetEtab(100000, 200.);	// ?, MeV calculate ranges
	fAlphaSi.SetDeltaEtab(300);
}

void AculCalParsSi::SetCalEnergies() {

	if (fDeadLayer<=0.) {
		Warning("AculCalibration::SetCalEnergies", "Dead layer was set equal or less than 0.");
		for(Int_t i = 0; i < kRaNOPEAKS; i++) {
			fEtab[i] = fEnergyInput[i];
		}
		Info("AculCalibration::SetCalEnergies", "Energies used for calibration are the same as input file.");
		return;
	}

	for(Int_t i = 0; i < kRaNOPEAKS; i++) {
		fEtab[i] = fAlphaSi.GetE(fEnergyInput[i], fDeadLayer);
	}
	Info("AculCalibration::SetCalEnergies", "Energies used for calibration considering %f mcm dead layer were set.", fDeadLayer);

	return;
}