示例#1
0
//_____________________________________________
void KVLifeTimeTable::Initialize()
{

    TString dfile;
    dfile.Form("%s.DataFile",GetName());
    TString cl_path;
    if( !KVBase::SearchKVFile(gEnv->GetValue(dfile.Data(),""),cl_path,"data") ) {
        Error("Initialize","No file found for %s",GetName());
        return;
    }
    else {
        //Info("Initialize","%s will be read",gEnv->GetValue(dfile.Data(),""));
    }
    SetTitle(gEnv->GetValue(dfile.Data(),""));

    Int_t ntot=0;
    nucMap = new TMap(50,2);
    KVFileReader* fr = new KVFileReader();
    fr->OpenFileToRead(cl_path.Data());

    //Premier passage
    while (fr->IsOK()) {

        fr->ReadLine(" ");
        if (fr->GetNparRead()==0) break;
        else if (fr->GetReadPar(0).BeginsWith("//")) {

            kcomments+=fr->GetCurrentLine();
            kcomments+="\n";

        }
        else {
            Int_t zz = fr->GetIntReadPar(0);
            Int_t aa = fr->GetIntReadPar(1);
            GiveIndexToNucleus(zz,aa,ntot);
            ntot+=1;
        }
    }

    if ( !fr->PreparForReadingAgain() ) return;

    //Info("Initialize","Set up map for %d nuclei", ntot);
    CreateTable(ntot);

    KVLifeTime* lf = 0;
    ntot=0;
    while (fr->IsOK()) {

        fr->ReadLine(" ");
        if (fr->GetCurrentLine().IsNull()) {
            break;
        }
        else if (fr->GetNparRead()==0) {
            break;
        }
        else if (fr->GetReadPar(0).BeginsWith("//")) { }
        else {
            Double_t val = fr->GetDoubleReadPar(2);

            CreateElement(ntot);
            lf = (KVLifeTime* )GetCurrent();

            if (fr->GetNparRead()>3) {
                TString unit = fr->GetReadPar(3);
                if ( unit.EndsWith("eV") ) {
                    lf->SetResonnance(kTRUE);
                    val *= ToMeV(unit);
                }
                else {
                    lf->SetResonnance(kFALSE);
                    val *= ToSecond(unit);
                }
                if (fr->GetNparRead()>4) {
                    Int_t meas = fr->GetReadPar(4).Atoi();
                    lf->SetMeasured(meas);
                }
                else {
                    if (ntot==0) InfoOnMeasured();
                }
            }
            lf->SetValue(val);

            ntot+=1;
        }

    }

    //Info("Initialize","table initialised correctly for %d nuclei", ntot);
    fr->CloseFile();
    delete fr;

}
void KVElementDensityTable::Initialize()
{

   TString dfile;
   dfile.Form("%s.DataFile", GetName());
   TString cl_path;
   if (!KVBase::SearchKVFile(gEnv->GetValue(dfile.Data(), ""), cl_path, "data")) {
      Error("Initialize", "No file found for %s", GetName());
      return;
   }
   else {
//    Info("Initialize","%s will be read",gEnv->GetValue(dfile.Data(),""));
   }
   SetTitle(gEnv->GetValue(dfile.Data(), ""));

   Int_t ntot = 0;
   nucMap = new TMap(50, 2);
   KVFileReader* fr = new KVFileReader();
   fr->OpenFileToRead(cl_path.Data());

   //Premier passage
   //Lecture du nombre de noyaux a enregistrer
   while (fr->IsOK()) {

      fr->ReadLine(" \t");
      if (fr->GetCurrentLine().IsNull()) {
         break;
      }
      else if (fr->GetNparRead() == 0) {
         break;
      }
      else if (fr->GetReadPar(0).BeginsWith("//")) {

         kcomments += fr->GetCurrentLine();
         kcomments += "\n";

      }
      else {
         Int_t zz = fr->GetIntReadPar(4);
         Int_t aa = 2 * zz + 1;
         GiveIndexToNucleus(zz, aa, ntot);
         ntot += 1;
      }
   }

   if (!fr->PreparForReadingAgain()) return;

// Info("Initialize","Set up map for %d nuclei", ntot);
   CreateTable(ntot);

   KVElementDensity* lf = 0;
   ntot = 0;
   while (fr->IsOK()) {
      fr->ReadLine(" \t");
      if (fr->GetCurrentLine().IsNull()) {
         break;
      }
      else if (fr->GetNparRead() == 0) {
         break;
      }
      else if (fr->GetReadPar(0).BeginsWith("//")) { }
      else {
         CreateElement(ntot);
         lf = (KVElementDensity*)GetCurrent();

         KVString unit = fr->GetReadPar(1);
         Double_t units = KVUnits::g / KVUnits::cc;
         if (unit == "g/L") {
            lf->SetIsGas();
            units = KVUnits::g / KVUnits::litre;
         }
         Double_t val = fr->GetDoubleReadPar(0);
         lf->SetValue(val * units);
         lf->SetElementSymbol(fr->GetReadPar(3));
         lf->SetElementName(fr->GetReadPar(2));
         lf->SetZ(fr->GetIntReadPar(4));
         ntot += 1;
      }

   }

// Info("Initialize","table initialised correctly for %d/%d nuclei", ntot,GetNumberOfNuclei());
   fr->CloseFile();
   delete fr;

}