Esempio n. 1
0
//___________________________________________________________________________________________
void KVIntegerList::SetPartition(const Char_t* par)
{
//protected method, utilisée par le Streamer qui utilise le champ fName de la classe TNamed
//voir également KVIntegerList::DeducePartitionFromTNamed
   KVString st(par);
   st.Begin(" ");
   TObjArray* toks = 0;
   while (!st.End()) {
      KVString tamp = st.Next();
      Int_t val;
      Int_t freq;
      if (tamp.Contains("(")) {
         if (!tamp.Contains(")")) {
            Warning("SetPartition", "%s ->pb de coherence dans les parentheses", tamp.Data());
            return;
         } else {
            toks = tamp.Tokenize("(");
            val = ((TObjString*)toks->At(0))->GetString().Atoi();
            freq = ((TObjString*)toks->At(1))->GetString().Atoi();
            delete toks;
         }
      } else {
         val = tamp.Atoi();
         freq = 1;
      }
      Add(val, freq);
   }

}
Esempio n. 2
0
void KVGeoNavigator::FormatDetectorName(const Char_t* basename, KVString& name)
{
   // If a format for naming detectors has been defined by a call
   // to SetDetectorNameFormat(const Char_t *), we use it to
   // format the name in the TString.
   // If no format was given 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]
   // If SetNameCorrespondanceList(const Char_t *) was used, we use it to translate
   // any names resulting from this formatting to their final value.

   name = "";
   if (!fCurStrucNumber) {
      // no parent structures
      name = basename;
   } else {
      if (fDetNameFmt == "") {
         for (int i = 0; i < fCurStrucNumber; i++) {
            KVGeoStrucElement* el = (KVGeoStrucElement*)fCurrentStructures[i];
            name += Form("%s_", el->GetName());
         }
         name += basename;
      } else {
         //    $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
         fDetNameFmt.Begin("$");
         while (!fDetNameFmt.End()) {
            KVString bit = fDetNameFmt.Next();
            if (bit.Contains(":")) {
               bit.Begin(":");
               KVString itbit = bit.Next();
               if (itbit == "det") {
                  itbit = bit.Next();
                  if (itbit.BeginsWith("name")) {
                     Ssiz_t ind = itbit.Index("%");
                     if (ind > -1) {
                        itbit.Remove(0, ind);
                        name += Form(itbit.Data(), basename);
                     } else
                        name += basename;
                  }
               } else if (itbit == "struc") {
                  KVString struc_typ = bit.Next();
                  KVGeoStrucElement* el = 0;
                  for (int i = 0; i < fCurStrucNumber; i++) {
                     el = (KVGeoStrucElement*)fCurrentStructures[i];
                     if (el->IsType(struc_typ)) break;
                  }
                  if (el) {
                     itbit = bit.Next();
                     if (itbit.BeginsWith("name")) {
                        Ssiz_t ind = itbit.Index("%");
                        if (ind > -1) {
                           itbit.Remove(0, ind);
                           name += Form(itbit.Data(), el->GetName());
                        } else
                           name += el->GetName();
                     } else if (itbit.BeginsWith("type")) {
                        Ssiz_t ind = itbit.Index("%");
                        if (ind > -1) {
                           itbit.Remove(0, ind);
                           name += Form(itbit.Data(), el->GetType());
                        } else
                           name += el->GetType();
                     } else if (itbit.BeginsWith("number")) {
                        Ssiz_t ind = itbit.Index("%");
                        if (ind > -1) {
                           itbit.Remove(0, ind);
                           name += Form(itbit.Data(), el->GetNumber());
                        } else
                           name += el->GetNumber();
                     }
                  }
               }
            } else
               name += bit;
         }
      }
   }
   TString tmp;
   GetNameCorrespondance(name.Data(), tmp);
   name = tmp;
}
Esempio n. 3
0
Bool_t KVRemoteDataSetManager::OpenAvailableDatasetsFile()
{
   //Transfers file $KVROOT/KVFiles/[repository name].available.datasets
   //from remote machine containing info on available datasets and
   //associated subdirectories in remote data repository.
   //Copies to local working directory and opens for reading, if all goes
   //well (returns kTRUE).
   //Returns kFALSE in case of problems.
   //
   //N.B. If 'curl' is used to transfer the file, we check for HTML code in the file
   //It can happen that 'curl' itself does not give an error when the web server
   //is down, but transfers a file which looks like this:
// <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
// <html><head>
// <title>403 Forbidden</title>
// </head><body>
// <h1>Forbidden</h1>
// <p>You don't have permission to access /KaliVedaDoc/ccali.available.datasets
// on this server.</p>
// <p>Additionally, a 403 Forbidden
// error was encountered while trying to use an ErrorDocument to handle the request.</p>
// <hr>
// <address>Apache/2.0.53 (Unix) mod_ssl/2.0.53 OpenSSL/0.9.7a DAV/2 PHP/5.1.6 mod_python/3.2.8 Python/2.4.2 mod_jk/1.2.15 mod_perl/2.0.2 Perl/v5.8.7 Server at indra.in2p3.fr Port 80</address>
// </body></html>
   

   TString http =
       gEnv->GetValue(Form("%s.DataRepository.RemoteAvailableRuns.url",
                           fRepository->GetName()), "");
   if (http == "") {
      Warning("OpenAvailableDatasetsFile()",
              "%s.DataRepository.RemoteAvailableRuns.url is not defined. See $KVROOT/KVFiles/.kvrootrc",
              fRepository->GetName());
      return kFALSE;
   }
   TString url;
   url.Form("%s/%s", http.Data(), fCacheFileName.Data());
   
   //Find executable 'curl' or programme indicated by
   //value of DataRepository.RemoteAvailableRuns.protocol
   fCurl = gEnv->GetValue(Form
                          ("%s.DataRepository.RemoteAvailableRuns.protocol",
                           fRepository->GetName()), "curl");
   if(!KVBase::FindExecutable(fCurl)){
      Error("OpenAvailableDatasetsFile",
            "Executable for file transfer \"%s\" not found. You cannot use remote data repository.",
            fCurl.Data());
      return kFALSE;
   }
   TString cmd;
   cmd.Form("%s -oremote.available.datasets %s", fCurl.Data(), url.Data());
   if (gSystem->Exec(cmd.Data()))
      return kFALSE;            // problem with curl
   fDatasets.open("remote.available.datasets");
   if( fCurl.Contains("curl") ){
      //check contents of file for HTML code
      KVString line; line.ReadLine( fDatasets );
      if( line.Contains("<") ){
         Error("OpenAvailableDatasetsFile",
               "Remote available datasets file transferred by curl contains HTML code :");
         //print contents of file
         cout << line.Data() << endl;
         line.ReadLine( fDatasets );
         while( fDatasets.good() ){
            cout << line.Data() << endl;
            line.ReadLine( fDatasets );
         }
         Error("OpenAvailableDatasetsFile",
               "You cannot use this remote data repository");
         return kFALSE;
      }
      else   // no HTML in file : OK
      {
         //reset stream to beginning of file
         fDatasets.clear();         // clear any error flags (EOF etc.)
         fDatasets.seekg(0, ios::beg);      // set file buffer pointer to beginning of file
      }
   }
   return kTRUE;
}