/* * 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]; std::ifstream fipr; 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(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(atof(parameter)); } continue; }//if if ( strcmp(identificator, "lowerChannel") == 0 ) { sscanf(line, "%s", parameter); fLowerChannel = static_cast(atof(parameter)); } if ( strcmp(identificator, "upperChannel") == 0 ) { sscanf(line, "%s", parameter); fUpperChannel = static_cast(atof(parameter)); } if ( strcmp(identificator, "lowerPeakHight") == 0 ) { sscanf(line, "%s", parameter); fLowerPeakRelativeHight = static_cast(atof(parameter)); } if ( strcmp(identificator, "upperPeakHight") == 0 ) { sscanf(line, "%s", parameter); fUpperPeakRelativeHight = static_cast(atof(parameter)); } if ( strcmp(identificator, "peakPositionTolerance") == 0 ) { sscanf(line, "%s", parameter); fPeakPositionTolerance = static_cast(atof(parameter)); } if ( strcmp(identificator, "fitFunctionLineWidth") == 0 ) { sscanf(line, "%s", parameter); fFitFuncLineWidth = static_cast(atoi(parameter)); } if ( strcmp(identificator, "minFitSigma") == 0 ) { sscanf(line, "%s", parameter); fFitMinSigma = static_cast(atof(parameter)); } if ( strcmp(identificator, "fitHightThreshold") == 0 ) { sscanf(line, "%s", parameter); fFitPeakThreshold = static_cast(atof(parameter)); } if ( strcmp(identificator, "deadLayer") == 0 ) { sscanf(line, "%s", parameter); fDeadLayer = static_cast(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; }