Пример #1
0
//___________________________________________________________________________________________
void KVIntegerList::Update()
{
//protected method, Mise a jour du nom de la partition (via SetName()), de sa longueur (fLength)
//Le bit kHastobeComputed es mis à 0 pour indiquer que la mise à jour a été faite
//
   KVString snom = "", stamp = "";
   for (Int_t ii = fLimiteRegle; ii >= 0; ii -= 1) {
      Int_t contenu = fRegle->At(ii);
      if (contenu > 0) {
         //Formattage du nom de la partition
         stamp.Form("%d", ii);
         snom += stamp;
         if (contenu > 1) {
            stamp.Form("(%d)", contenu);
            snom += stamp;
         }
         snom += " ";
      }
   }
   if (snom != "") snom.Remove(snom.Length() - 1);
   SetName(snom.Data());
   fLength = snom.Length();

   SetBit(kHastobeComputed, kFALSE);

}
Пример #2
0
void KV_CCIN2P3_GE::ChooseJobTime()
{
   KVString tmp = "";
   cout << "Enter max CPU time per job (ss/mn:ss/hh:mn:ss) ["
        << fDefJobTime << "] : ";
   cout.flush();
   tmp.ReadToDelim(cin);
   if (!tmp.Length()) {
      SetJobTime();
      return;
   }
   else
      SetJobTime(tmp);
}
Пример #3
0
void KVGeoNavigator::ExtractDetectorNameFromPath(KVString& detname)
{
   // We analyse the current path in order to construct the full (unique) name
   // of the detector, i.e. if the current path is
   //
   // /TOP_1/STRUCT_BLOCK_2/CHIO_WALL_1/DET_CHIO_2/WINDOW_1
   //
   // then the default name of the detector will be "BLOCK_2_CHIO_2"
   // (see below to override this)
   //
   // This method also fills the fCurrentStructures array with elements
   // deduced from the path, e.g. if the path is
   //
   // /TOP_1/STRUCT_BLOCK_2/STRUCT_QUARTET_1/DET_SI1-T1
   //
   // then by default
   //  fCurrentStructures[0] = KVGeoStrucElement(name = "BLOCK_2", type = "BLOCK", number = 2)
   //  fCurrentStructures[1] = KVGeoStrucElement(name = "QUARTET_1", type = "QUARTET", number = 1)
   //
   // and the default name of the detector will be "BLOCK_2_QUARTET_1_SI1-T1"
   //
   // STRUCTURE & DETECTOR NAME FORMATTING
   // ====================================
   //    -- STRUCTURES --
   // The default names for structures are taken from the node name by stripping off
   // the "STRUCT_" prefix. It is assumed that the remaining string is of the form
   //    "[structure type]_[structure number]"
   // (the structure number is always taken after the last occurence of '_' in the
   // node name). This is the name that will be used by default for the structure.
   // However, this format can be change by calling method
   //    SetStructureNameFormat("[structure type]", "[format]")
   // where format can contain any of the following tokens:
   //    $type$         - will be replaced by the structure type name
   //    $type%[fmt]$   - will be replaced by the structure type name using given format
   //    $number$       - will be replaced by the structure number
   //    $number%[fmt]$ - will be replaced by the structure number using given format
   //
   // Example: to change the name of the block in the previous example to "B-02",
   //   SetStructureNameFormat("BLOCK", "$type%.1s$-$number%02d$")
   //
   //    -- DETECTORS --
   // The default base names for detectors are taken from the node name by stripping off
   // the "DET_" prefix. In order to ensure that all detectors have unique names,
   // by default we prefix the names of the parent structures to the basename in
   // order to generate the full name of the detector:
   //    [struc1-name]_[struc2-name]_..._[detector-basename]
   // However, this format can be changed by calling method
   //    SetDetectorNameFormat("[format]")
   // where format can contain any of the following tokens:
   //    $det:name$             - will be replaced by the detector basename
   //    $struc:[type]:name$    - will be replaced by the name of the parent structure of given type
   //    $struc:[type]:type$    - will be replaced by the type of the parent structure of given type
   //    $struc:[type]:number$  - will be replaced by the number of the parent structure of given type
   // plus additional formatting information as for SetStructureNameFormat (see above).
   //
   // Example: to change the name of the "SI1-T1" detector in the previous example to
   //  "SI1-T1-Q1-B2":
   //   SetDetectorNameFormat("$det:name$-Q$struc:QUARTET:number$-B$struc:BLOCK:number$")
   // Or if you also change the format of the structure names:
   //   SetStructureNameFormat("BLOCK", "$type%.1s$$number$")
   //   SetStructureNameFormat("QUARTET", "$type%.1s$$number$")
   //   SetDetectorNameFormat("$det:name$-$struc:QUARTET:name$-$struc:BLOCK:name$")


   KVString path = GetCurrentPath();
   path.Begin("/");
   detname = "";
   fCurrentStructures.Clear("C");
   fCurStrucNumber = 0;
   while (!path.End()) {
      KVString elem = path.Next();
      if (elem.BeginsWith("STRUCT_")) {
         // structure element. strip off "STRUCT_" and extract type and number of structure.
         KVString struc_name(elem(7, elem.Length() - 7));
         KVGeoStrucElement* gel = (KVGeoStrucElement*)fCurrentStructures.ConstructedAt(fCurStrucNumber++);
         Ssiz_t last_ = struc_name.Last('_'); // find last '_' in structure name
         TString type = struc_name(0, last_);
         TString nums = struc_name(last_ + 1, struc_name.Length() - last_ - 1);
         Int_t number = nums.Atoi();
         KVString name;
         FormatStructureName(type, number, name);
         gel->SetNameTitle(name, type);
         gel->SetNumber(number);
      } else if (elem.BeginsWith("DET_")) {
         // detector name. strip off "DET_" and use rest as basename
         KVString basename(elem(4, elem.Length() - 4));
         FormatDetectorName(basename, detname);
      }
   }
}
Пример #4
0
//___________________________________________________________________________________________
KVNumberList* KVValues::TransformExpression(KVString& expr)
{

   KVNumberList* nl = new KVNumberList();

   const char* O = "[";
   const char* F = "]";

   KVString clone;
   clone.Form("%s", expr.Data());
   const char* expression = clone.Data();

   Int_t nouvert = 0, nferme = 0;
   Int_t posouvert = 0, posferme = 0;
   Int_t nvar = 0;

   Int_t nsize = clone.Length();
   for (Int_t ii = 0; ii <= nsize; ii += 1) {
      if (expression[ii] == O[0]) {
         nouvert += 1;
         posouvert = ii;
      }
      else if (expression[ii] == F[0]) {
         nferme += 1;
         posferme = ii;
         KVString st(clone(posouvert + 1, posferme - posouvert - 1));
         if (st.IsDigit()) {
            Int_t idx = st.Atoi();
            if (0 <= idx && idx < kval_tot) {
               nl->Add(idx);
               nvar += 1;
            }
            else {
               delete nl;
               return 0;
            }
         }
         else {

            Int_t idx = GetValuePosition(st.Data());
            if (idx == -1) {
               delete nl;
               return 0;
            }
            nl->Add(idx);
            nvar += 1;
            KVString s1;
            s1.Form("[%s]", st.Data());
            KVString s2;
            s2.Form("[%d]", idx);
            expr.ReplaceAll(s1, s2);
         }
      }
      else {}
   }

   if (nouvert != nferme || nvar != nouvert) {
      Error("TransformExpr", "nombre [ : %d - nombre de ] : %d - nombre de variables %d", nouvert, nferme, nvar);
   }

   return nl;

}