TGeoMaterial* KVIonRangeTableMaterial::GetTGeoMaterial() const
{
   // Create and return pointer to a TGeoMaterial or TGeoMixture (for compound materials)
   // with the properties of this material.
   // gGeoManager must exist.

   TGeoMaterial* gmat = 0x0;
   if (!gGeoManager) return gmat;
   if (IsCompound()) {
      gmat = new TGeoMixture(GetTitle(), GetComposition()->GetEntries(), GetDensity());
      TIter next(GetComposition());
      KVNameValueList* nvl;
      while ((nvl = (KVNameValueList*)next())) {
         KVNucleus n(nvl->GetIntValue("Z"), nvl->GetIntValue("A"));
         TGeoElement* gel = gGeoManager->GetElementTable()->FindElement(n.GetSymbol("EL"));
         float poids = nvl->GetDoubleValue("NormWeight");
         ((TGeoMixture*)gmat)->AddElement(gel, poids);
      }
   }
   else {
      gmat = new TGeoMaterial(GetTitle(), GetMass(), GetZ(), GetDensity());
   }
   // set state of material
   if (IsGas()) gmat->SetState(TGeoMaterial::kMatStateGas);
   else gmat->SetState(TGeoMaterial::kMatStateSolid);
   return gmat;
}
示例#2
0
void KVRangeYanezMaterial::Initialize()
{
   KVIonRangeTableMaterial::Initialize();
   if(IsCompound()){
      fNelem=0;
      iabso=-1;
      TIter next(fComposition);
      KVNameValueList* nvl;
      while( (nvl = (KVNameValueList*)next()) ){
         fAbsorb[fNelem].z = nvl->GetIntValue("Z");
         fAbsorb[fNelem].a = nvl->GetIntValue("A");
         fAbsorb[fNelem].w = nvl->GetDoubleValue("Ar*Weight");
         fNelem++;
      }
   }
   else if(IsMixture()){
      fNelem=0;
      iabso=-1;
      TIter next(fComposition);
      KVNameValueList* nvl;
      while( (nvl = (KVNameValueList*)next()) ){
         fAbsorb[fNelem].z = nvl->GetIntValue("Z");
         fAbsorb[fNelem].a = nvl->GetIntValue("A");
         fAbsorb[fNelem].w = nvl->GetDoubleValue("Ar*Weight");
         fNelem++;
      }
   }
}
示例#3
0
Int_t KVAvailableRunsFile::Count(Int_t run)
{
   //Count the number of times a given run number appears in the file
   //If available runs file does not exist, Update() is called to create it.

//    //does runlist exist ?
//    if (!OpenAvailableRunsFile()) {
//       Error("Count", "Error opening available runs file");
//       return 0;
//    }
//    //loop over lines in runlist file
//    //look for line beginning with 'run|'
//    TString line;
//    Int_t occurs = 0;
//    line.ReadLine(fRunlist);
//    while (fRunlist.good()) {
//       if (line.BeginsWith(Form("%d|", run))) {
//          occurs++;
//       }
//       line.ReadLine(fRunlist);
//    }
//    CloseAvailableRunsFile();
//    return occurs;
   ReadFile();
   KVNameValueList* nvlrun = (KVNameValueList*)fAvailableRuns->FindObject(Form("%d",run));
   if(nvlrun) return nvlrun->GetIntValue("Occurs");
   return 0;
}
void KVIonRangeTableMaterial::PrintComposition(ostream& output) const
{
   // Print to stream the composition of this material, in a format compatible with the VEDALOSS parameter file.
   if (IsCompound()) output << "COMPOUND";
   else if (IsMixture()) output << "MIXTURE";
   else output << "ELEMENT";
   output << endl;
   if (IsCompound() || IsMixture()) {
      output << fComposition->GetEntries() << endl;
      TIter next(fComposition);
      KVNameValueList* nvl;
      while ((nvl = (KVNameValueList*)next())) {
         KVNucleus n(nvl->GetIntValue("Z"), nvl->GetIntValue("A"));
         output << n.GetZ() << " " << n.GetA() << " " << nvl->GetIntValue("Natoms");
         if (IsMixture()) output << " " << nvl->GetDoubleValue("Proportion");
         output << endl;
      }
   }
}
示例#5
0
KVNumberList KVAvailableRunsFile::CheckMultiRunfiles()
{
   //Returns a list with all runs which occur more than once in the available runs file.

//    //does runlist exist ?
//    if (!OpenAvailableRunsFile()) {
//       Error("CheckMultiRunfiles", "Cannot open available runs file");
//       return 0;
//    }
// 
//    TString fLine;
//    TList *run_list = new TList;
//    fLine.ReadLine(fRunlist);
// 
//    KVNumberList multiruns;
// 
//    Int_t fRunNumber;
//    KVDBTable *runs_table = fDataSet->GetDataBase()->GetTable("Runs");
// 
//    while (fRunlist.good()) {
// 
//       TObjArray *toks = fLine.Tokenize('|');    // split into fields
//       KVString kvs(((TObjString *) toks->At(0))->GetString());
//       fRunNumber = kvs.Atoi();
//       delete toks;
// 
//       KVDBRun *a_run = (KVDBRun *) runs_table->GetRecord(fRunNumber);
// 
//       if (!run_list->Contains(a_run)) {
//          //first time that run appears
//          run_list->Add(a_run);
//       } else {
//          //run appears >1 times
//          multiruns.Add(fRunNumber);
//       }
// 
//       fLine.ReadLine(fRunlist);
//    }
//    delete run_list;
//    CloseAvailableRunsFile();
// 
//    return multiruns;
   ReadFile();
   KVNumberList multiruns;
   TIter next(fAvailableRuns);
   KVNameValueList* run;
   while( (run = (KVNameValueList*)next()) ){
      
      if(run->GetIntValue("Occurs")>1) multiruns.Add(run->GetName());
      
   }
   return multiruns;
}
void KVIonRangeTableMaterial::Print(Option_t*) const
{
   printf("Material : %s (%s)   State : %s\n",
          GetName(), GetSymbol(), fState.Data());
   printf("\tEffective Z=%f, A=%f  ", fZmat, fAmat);
   if (IsGas()) printf(" Molar Weight = %f g.", fMoleWt);
   else printf(" Density = %f g/cm**3", fDens);
   printf("\n");
   if (IsCompound()) printf("\tCompound material:\n");
   else if (IsMixture())  printf("\tMixed material:\n");
   if (IsCompound() || IsMixture()) {
      TIter next(fComposition);
      KVNameValueList* nvl;
      while ((nvl = (KVNameValueList*)next())) {
         KVNucleus n(nvl->GetIntValue("Z"), nvl->GetIntValue("A"));
         printf("\t\tElement: %s   Ar=%f g.   Natoms=%d", n.GetSymbol(), n.GetAtomicMass(), nvl->GetIntValue("Natoms"));
         if (IsMixture()) printf("   Proportion=%f", nvl->GetDoubleValue("Proportion"));
         printf("\n");
      }
   }
   printf("\n\n");
}
示例#7
0
void KV_CCIN2P3_GE::SetBatchSystemParameters(const KVNameValueList& nl)
{
   // Use the parameters in the list to set all relevant parameters for batch system.

   KVBatchSystem::SetBatchSystemParameters(nl);
   SetJobTime(nl.GetStringValue("JobTime"));
   SetJobMemory(nl.GetStringValue("JobMemory"));
   SetJobDisk(nl.GetStringValue("JobDisk"));
   SetMultiJobsMode(nl.GetBoolValue("MultiJobsMode"));
   SetRunsPerJob(nl.GetIntValue("RunsPerJob"));
   if (nl.GetTStringValue("EMailAddress") != "") {
      if (nl.GetBoolValue("EMailOnStart")) SetSendMailOnJobStart();
      if (nl.GetBoolValue("EMailOnEnd")) SetSendMailOnJobEnd();
      SetSendMailAddress(nl.GetStringValue("EMailAddress"));
   }
}
示例#8
0
KVNameValueList* KVAvailableRunsFile::RunHasFileWithDateAndName(Int_t run, const Char_t* filename, TDatime modtime, Int_t& OccNum)
{
   // look in previously read infos (see ReadFile) to see if, for a given run, there is a file with the
   // given name and modification date/time
   // if so, returns the address of the KVNameValueList for the run & sets OccNum to the index number of
   // the corresponding entry (in case of several files for the run)
   // if not, returns NULL
   
   if(!fAvailableRuns) return NULL;
   // is run already in list ?
   KVNameValueList* NVL = (KVNameValueList*)fAvailableRuns->FindObject(Form("%d",run));
   if(!NVL) return NULL;
   Int_t Occurs = NVL->GetIntValue("Occurs");
   for(OccNum=0; OccNum<Occurs; OccNum++){
      if( NVL->IsValue( Form("Filename[%d]",OccNum) , filename ) && NVL->IsValue( Form("Date[%d]",OccNum) , modtime.AsSQLString() ) ) return NVL;
   }
   return NULL;
}
示例#9
0
Bool_t KVAvailableRunsFile::InfosNeedUpdate(Int_t run, const Char_t * filename)
{
   // return kTRUE if the given file for this run is lacking some information
   // e.g. the KV version and username
   // N.B.: if no file is known for this run, we return kFALSE
   
   ReadFile();
   // is run already in list ?
   KVNameValueList* NVL = (KVNameValueList*)fAvailableRuns->FindObject(Form("%d",run));
   if(!NVL) return kFALSE;
   Int_t Occurs = NVL->GetIntValue("Occurs");
   for(Int_t OccNum=0; OccNum<Occurs; OccNum++){
      if( NVL->IsValue( Form("Filename[%d]",OccNum) , filename ) ){
         // infos need update if no KV version has been set
         return ( !NVL->HasParameter(Form("KVVersion[%d]",OccNum)) );
      }
   }
   return kFALSE;   
}
void KVIonRangeTableMaterial::Initialize()
{
   // Correctly initialize material ready for use
   // For compound or mixed materials, calculate normalised weights of components,
   // effective Z and A, and molar weight of substance

   fMoleWt = 0.;
   if (IsCompound() || IsMixture()) {
      // mixture or compound
      // calculate molar weight and effective Z & A
      fZmat = fAmat = 0;
      TIter next(fComposition);
      KVNameValueList* nvl;
      Double_t totW = 0;
      while ((nvl = (KVNameValueList*)next())) {
         Double_t arw = nvl->GetDoubleValue("Ar*Weight");
         Double_t poid = nvl->GetDoubleValue("Weight");
         fMoleWt += arw;
         totW += poid;
         fZmat += poid * nvl->GetIntValue("Z");
         fAmat += poid * nvl->GetIntValue("A");
      }
      fZmat /= totW;
      fAmat /= totW;
      next.Reset();
      while ((nvl = (KVNameValueList*)next())) {
         Double_t prop = nvl->GetDoubleValue("Weight");
         nvl->SetValue("NormWeight", prop / totW);
      }
   }
   else {
      // isotopically-pure elemental material
      // get mass of 1 mole of element
      KVNucleus n(fZmat, fAmat);
      fMoleWt = n.GetAtomicMass();
   }
}
示例#11
0
void KVAvailableRunsFile::ReadFile()
{
   // Read all infos in available runs file and store as KVNameValueList objects in fAvailableRuns.
   // For each run in the file we add a KVNameValueList with the following fields:
   //
   // Name = run number
   // Occurs = number of times run appears in file
   // Filename[0] = name of first file for run
   // Filename[1] =
   //  ...
   // Filename[Occurs-1] = name of last file for run
   // Date[0] = date & time of generation of first file etc.
   // KVVersion[0] = name of KaliVeda version used to generate first file etc. (if known)
   // Username[0] = name of user who generated first file etc. (if known)
   
   //does runlist exist ?
   if (!OpenAvailableRunsFile()) {
      Error("ReadFile", "Cannot open available runs file");
      return;
   }

   if(fAvailableRuns) delete fAvailableRuns;
   fAvailableRuns = new KVHashList;
   fAvailableRuns->SetOwner(kTRUE);
   
   TString fLine;
   Int_t line_number=1;
   fLine.ReadLine(fRunlist);

   KVNumberList duplicate_lines;

   Int_t fRunNumber;

   while (fRunlist.good()) {

      TObjArray *toks = fLine.Tokenize('|');    // split into fields
      
      // number of fields can vary
      // nfields = 2: run number, date
      // nfields = 3: run number, date, filename
      // nfields = 5: run number, date, filename, KaliVeda version, username
      Int_t nfields = toks->GetEntries();
      KVString kvs(((TObjString *) toks->At(0))->GetString());
      fRunNumber = kvs.Atoi();
      if(nfields<2){
            Warning("ReadFile", "Less than 2 fields in entry for run %d (line:%d)???",fRunNumber,line_number);
			toks->ls();
			continue;
		}
      //get date string
      KVString datestring(((TObjString *) toks->At(1))->GetString());
      
      // is run already in list ?
      KVNameValueList* NVL = (KVNameValueList*)fAvailableRuns->FindObject(kvs);
      Int_t Occurs = (NVL ? NVL->GetIntValue("Occurs") : 0);
      if(!NVL) {
         NVL = new KVNameValueList(kvs);
         fAvailableRuns->Add(NVL);
      }
      else
      {
         // check date for run is different to any others
         Bool_t ok = kTRUE;
         for(Int_t ii=0;ii<Occurs;ii++){
            KVString olddate = NVL->GetStringValue(Form("Date[%d]",ii));
            if(olddate==datestring){               
               ok=kFALSE;
               duplicate_lines.Add(line_number);
               break;
            }
         }
         if(!ok){
            delete toks;
             line_number++;
            fLine.ReadLine(fRunlist);
            continue;
         }
      }
      Occurs++;
      NVL->SetValue("Occurs", Occurs);
      
      NVL->SetValue(Form("Date[%d]",Occurs-1), datestring.Data());

      //backwards compatibility
      //an old available_runs file will not have the filename field
      //in this case we assume that the name of the file is given by the
      //dataset's base file name (i.e. with no date/time suffix)
      KVString filename;
      if (nfields > 2) {
         filename = ((TObjString *) toks->At(2))->GetString();
      } else {
         filename = fDataSet->GetBaseFileName(GetDataType(), fRunNumber);
      }
      NVL->SetValue(Form("Filename[%d]",Occurs-1), filename.Data());
      KVString kvversion,username;
      if (nfields > 4) {
         kvversion = ((TObjString *) toks->At(3))->GetString();
         username = ((TObjString *) toks->At(4))->GetString();
         NVL->SetValue(Form("KVVersion[%d]",Occurs-1), kvversion.Data());
         NVL->SetValue(Form("Username[%d]",Occurs-1), username.Data());
      }
      delete toks;

      line_number++;
      fLine.ReadLine(fRunlist);
   }

   CloseAvailableRunsFile();

   if(duplicate_lines.GetNValues()){
       Info("ReadFile", "There were %d duplicate entries in available runs file, they will be removed", duplicate_lines.GetNValues());
       RemoveDuplicateLines(duplicate_lines);
   }

}