/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/BOOST/EmcSim/EmcSim-00-00-46/src/BesEmcParameter.cc

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------//
00002 //      BOOST --- BESIII Object_Oriented Simulation Tool                     //
00003 //---------------------------------------------------------------------------//
00005 //Author: He Miao
00006 //Created: Nov,12 2004
00007 //Modified:
00008 //Comment:
00009 //---------------------------------------------------------------------------//
00010 //$ID: BesEmcParameter.hh
00011 
00012 #include "BesEmcParameter.hh"
00013 #include <fstream>
00014 #include <strstream>
00015 //#include "ReadBoostRoot.hh"
00016 #include "EmcGeneralClass/EmcStructure.h"
00017 using namespace std;
00018 
00019 //Initialize static data member
00020 BesEmcParameter* BesEmcParameter::fpInstance=0;
00021 
00022 BesEmcParameter::BesEmcParameter()
00023 {
00024 }
00025 
00026 
00027 BesEmcParameter::~BesEmcParameter()
00028 {
00029 }
00030 
00031 // static method
00032 //Access to an instance
00033 BesEmcParameter& BesEmcParameter::GetInstance()
00034 {
00035   if(!Exist()) {
00036     fpInstance=new BesEmcParameter;
00037     fpInstance->ReadData();
00038   }
00039   return *fpInstance;
00040 }
00041 
00042 bool BesEmcParameter::Exist()
00043 {
00044   return fpInstance!=0;
00045 }
00046 
00047 void BesEmcParameter::Kill()
00048 {
00049   if(Exist()) {
00050     delete fpInstance;
00051     fpInstance=0;
00052   }
00053 }
00054 
00055 void BesEmcParameter::ReadData()
00056 {
00057   G4String ParaPath = getenv("EMCSIMROOT");
00058   if(!ParaPath){
00059     G4Exception("BOOST environment not set!");
00060   }
00061   
00062   G4String ParaPath1 = ParaPath;
00063   
00064   ParaPath += "/dat/BesEmc.txt";
00065   ifstream fin;
00066   fin.open(ParaPath);
00067   assert(fin);
00068   
00069   const int maxCharOfOneLine=255;
00070   char temp[maxCharOfOneLine],*p;
00071   int lineNo=0,inputNo=0;
00072   
00073   while(fin.peek()!=EOF)
00074   {
00075     fin.getline(temp,maxCharOfOneLine);
00076     p=temp;
00077     lineNo++;
00078     while(*p!='\0')
00079     {
00080       if(*p=='#')
00081       {
00082         *p='\0';  //delete the comments.
00083         break;
00084       }
00085       p++;
00086     }
00087     p=temp; //reset the pointer to the beginning of the string.
00088     while(*p==' '||*p=='\t')p++;
00089     if(*p=='\0')continue;
00090     inputNo++;
00091     switch(inputNo)
00092     {
00093       case 1:
00094         istrstream(p)>>array_size>>m_tau>>m_highRange>>m_midRange>>m_lowRange>>m_sampleTime>>m_bitNb>>m_photonsPerMeV>>m_nonuniformity>>m_peakTime>>m_timeOffset;
00095         break;
00096       case 2:
00097         istrstream(p)>>WorldRmin1>>WorldRmax1>>WorldRmin2>>WorldRmax2>>WorldDz>>WorldZPosition>>CrystalLength>>CrystalLength1;
00098         break;
00099       case 3:
00100         istrstream(p)>>cryNumInOneLayer[0]>>cryNumInOneLayer[1]>>cryNumInOneLayer[2]>>cryNumInOneLayer[3]>>cryNumInOneLayer[4]>>cryNumInOneLayer[5];
00101         break;
00102       case 4:
00103         istrstream(p)>>pentaInOneSector[0]>>pentaInOneSector[1]>>pentaInOneSector[2]>>pentaInOneSector[3]>>pentaInOneSector[4];
00104         break;
00105       case 5:
00106         istrstream(p)>>fTyvekThickness>>fAlThickness>>fMylarThickness;
00107         break;
00108       case 6:
00109         istrstream(p)>>BSCRmin>>BSCDz>>BSCRmin1>>BSCRmax1>>BSCRmin2>>BSCRmax2>>BSCDz1;
00110         break;
00111       case 7:
00112         istrstream(p)>>BSCAngleRotat>>BSCNbPhi>>BSCNbTheta;
00113         break;
00114       case 8:
00115         istrstream(p)>>BSCYFront0>>BSCYFront>>BSCYFront1>>BSCPosition0>>BSCPosition1;
00116         break;
00117       case 9:
00118         istrstream(p)>>TaperRingDz>>TaperRingThickness1>>TaperRingThickness2>>TaperRingThickness3
00119           >>TaperRingTheta>>TaperRingInnerLength>>TaperRingOuterLength;
00120       case 10:
00121         istrstream(p)>>rearBoxLength>>rearBoxDz>>HangingPlateDz>>OCGirderAngle>>rearCasingThickness;
00122       case 11:
00123         istrstream(p)>>orgGlassLengthX>>orgGlassLengthY>>orgGlassLengthZ
00124           >>PDLengthX>>PDLengthY>>PDLengthZ>>AlPlateDz>>PABoxDz>>PABoxThickness;
00125       case 12:
00126         istrstream(p)>>cableDr>>waterPipeDr>>waterPipeThickness
00127           >>SPBarThickness>>SPBarThickness1>>SPBarwidth>>EndRingDz>>EndRingDr>>EndRingRmin;
00128       default:
00129         ;
00130     }
00131   }
00132   fin.close();
00133   
00134   ifstream fin1;
00135   ParaPath1 += "/dat/EmcLightOutput.dat";
00136   fin1.open(ParaPath1);
00137   assert(fin1);
00138   for(G4int i=0;i<6240;i++) {
00139     fin1>>lightOutput[i];
00140   }
00141   fin1.close();
00142 }
00143 
00144 G4double BesEmcParameter::GetLightOutput(G4int partId, G4int theta, G4int phi)
00145 {
00146   EmcStructure struc;
00147   struc.setEmcStruc();
00148   G4int index = struc.getGeomIndex(partId,theta,phi);
00149   if(index>=0&&index<6240) {
00150     return lightOutput[index];
00151   } else {
00152     return 1.;
00153   }
00154 }

Generated on Tue Nov 29 23:14:26 2016 for BOSS_7.0.2 by  doxygen 1.4.7