// Written by Peter Stromberger // based on work of Mirco Deckenhoff // modified by Bastian Rössler #include "Analysis.hh" #include "Parameters.hh" #include #include Parameters* Parameters::singleton = 0; Parameters::Parameters() { //// Read parameter values and set corresponding variables //// G4cout << ">>> Constructor of Parameter class called <<<" << G4endl; //char parameterFileName[40] = "parameterFiles/parameters.dat"; #if defined __APPLE__ char parameterFileName[200] = "/Users/basti/Programming/LHCb/SciFiSim-Xcode/SimulationData/parameterFiles/parameters.dat"; #pragma message("Compiling for MacOSX") #else char parameterFileName[40] = "parameterFiles/parameters.dat"; #pragma message("Compiling for Linux") #endif std::ifstream parameterFile; parameterFile.open(parameterFileName); if(parameterFile.good()) { parameterFile >> randomSeed; // random seed for random engine parameterFile >> randomNumber; // random number for detector strip positioning randomNumber = randomNumber/32767.0; // max random number in bourne shell random number generator parameterFile >> fibreLength; // length of fibre in meter parameterFile >> semiAxisZ; // semi axis of fibre in z in millimeter parameterFile >> semiAxisY; // semi axis of fibre in y in millimeter parameterFile >> triggerX; // x-size of Trigger in mm parameterFile >> triggerY; // y-size of Trigger in mm parameterFile >> triggerZ; // z-size of Trigger in mm parameterFile >> triggerXPos; // x-position of Trigger in millimeter parameterFile >> triggerZPos; // z-position of Trigger in millimeter parameterFile >> probabilityOfPhotonLossAtSurface; // probability that a photon is killed when reaching fibre surface if(probabilityOfPhotonLossAtSurface<0 || probabilityOfPhotonLossAtSurface>1) probabilityOfPhotonLossAtSurface = 1; parameterFile >> placeMirror; // place a mirror at fibre end parameterFile >> mirrorReflectivity; // reflectivity of mirror at fibre end parameterFile >> detectorMaterial; // place a mirror at fibre end parameterFile.ignore(256,'\n'); parameterFile.peek(); parameterFile.getline(emissionSpectrumFileName,256); G4cout << "Emission FIle: " << emissionSpectrumFileName << G4endl; std::ifstream emissionFile; emissionFile.open(emissionSpectrumFileName); if(emissionFile.good()) { std::vector energyVector; std::vector intensityVector; G4double readValue1; G4double readValue2; numberOfEnergies = 0; while(emissionFile >> readValue1) { if(emissionFile >> readValue2) { energyVector.push_back(readValue1); intensityVector.push_back(readValue2); numberOfEnergies ++; } } Energy = new G4double[numberOfEnergies]; Intensity = new G4double[numberOfEnergies]; for(int i=0; i> numberOfInterpolatedPoints; // number of points to be interpolated within each emission spectrum interval parameterFile.ignore(256,'\n'); parameterFile.peek(); parameterFile.getline(wlsAbsSpectrumFileName,256); std::ifstream wlsAbsFile; wlsAbsFile.open(wlsAbsSpectrumFileName); if(wlsAbsFile.good()) { std::vector wlsAbsEnergyVector; std::vector wlsAbsLengthVector; G4double readValue1; G4double readValue2; numberOfWlsAbsEnergies = 0; while(wlsAbsFile >> readValue1) { if(wlsAbsFile >> readValue2) { wlsAbsEnergyVector.push_back(readValue1); wlsAbsLengthVector.push_back(readValue2); numberOfWlsAbsEnergies ++; } } WlsAbsEnergy = new G4double[numberOfWlsAbsEnergies]; WlsAbsLength = new G4double[numberOfWlsAbsEnergies]; for(int i=0; i wlsEmissionEnergyVector; std::vector wlsEmissionIntensityVector; G4double readValue1; G4double readValue2; numberOfWlsEmissionEnergies = 0; while(wlsEmissionFile >> readValue1) { if(wlsEmissionFile >> readValue2) { wlsEmissionEnergyVector.push_back(readValue1); wlsEmissionIntensityVector.push_back(readValue2); numberOfWlsEmissionEnergies ++; } } WlsEmissionEnergy = new G4double[numberOfWlsEmissionEnergies]; WlsEmissionIntensity = new G4double[numberOfWlsEmissionEnergies]; for(int i=0; i> scintillationYield; //scintillation yield in photons per keV parameterFile >> resolutionScale; // width of gaussian to generate photon number parameterFile >> decayTimeFast; // fast decay time of excited states in ns parameterFile >> decayTimeSlow; // slow decay time of excited states in ns parameterFile >> yieldRatio; // ratio of fast component and total scintillation yield parameterFile >> birksConstant; // Birk's constant in mm/MeV parameterFile >> wlsDecayTime; // decay time of wls excited states in ns parameterFile.ignore(256,'\n'); parameterFile.peek(); parameterFile.getline(refractiveIndexVacuum,256); parameterFile.getline(refractiveIndexCore,256); parameterFile.getline(refractiveIndexClad1,256); parameterFile.getline(refractiveIndexClad2,256); parameterFile.getline(absorptionCore,512); parameterFile.getline(absorptionClad1,512); parameterFile.getline(absorptionClad2,512); parameterFile.getline(absorptionFromIrradiationCore,512); parameterFile.getline(absorptionFromIrradiationClad1,512); parameterFile.getline(absorptionFromIrradiationClad2,512); parameterFile.getline(sectionsFileName,80); std::ifstream sectionsFile; sectionsFile.open(sectionsFileName); if(sectionsFile.good()) sectionsFile >> numberOfSections; else G4cout << "Could not read sections file: " << sectionsFileName <<" !" << G4endl; sectionsFile.close(); parameterFile.getline(rayleighCore,512); parameterFile.getline(rayleighClad1,512); parameterFile.getline(rayleighClad2,512); } else { G4cout << "Could not read parameter file: " << parameterFileName <<" !" << G4endl; } parameterFile.close(); //// Open file to store parameters //// sprintf(parameterOutputFileName,"%s.parameters",Analysis::GetInstance()->FileName()); std::ofstream parameterOutputFile; parameterOutputFile.open(parameterOutputFileName); parameterOutputFile << "Length of fibre: "; parameterOutputFile << fibreLength << " m \n"; parameterOutputFile << "Semi axis of fibre in z: "; parameterOutputFile << semiAxisZ << " mm \n"; parameterOutputFile << "Semi axis of fibre in y: "; parameterOutputFile << semiAxisY << " mm \n"; parameterOutputFile << "Probability to lose photons at fibre surface: "; parameterOutputFile << probabilityOfPhotonLossAtSurface << "\n"; parameterOutputFile << "Mirror placement at fibre end: "; parameterOutputFile << placeMirror << "\n"; parameterOutputFile << "Reflectivity of mirror at fibre end: "; parameterOutputFile << mirrorReflectivity << "\n"; parameterOutputFile << "Detector material vacuum/polystyrene (0/1): "; parameterOutputFile << detectorMaterial << "\n"; parameterOutputFile << "Used emission spectrum: \""; parameterOutputFile << emissionSpectrumFileName << "\"\n"; parameterOutputFile << "Number of energies: "; parameterOutputFile << numberOfEnergies << "\n"; parameterOutputFile << "Energy / eV \t Intensity\n"; for(int i=0; i