Esempio n. 1
0
//___________________________________________________________________________________________
void KVValues::init_val_base()
{
//protected method
//Mise en correspondance du noms des differentes valeurs a calculees
//et de leur position dans le tableau values
// Ex:
// nom_valeurs -> id_valeurs -> values[id_valeurs]

   KVString lname = "MIN MAX";
   lname.Begin(" ");
   kval_base = 0;    //variables de base disponibles

   kval_tot = 0; //nombre de variables totales disponibles
   while (!lname.End()) {
      KVString tamp = lname.Next();
      SetValue(tamp.Data(), kval_tot++);
   }
   kdeb = kval_tot;  //ici pos_deb=2 (par defaut)

   KVString smoment;
   for (Int_t mm = 0; mm <= kordre_mom_max; mm += 1) { //Ex: moment_max = 3
      smoment.Form("SUM%d", mm);
      SetValue(smoment.Data(), kval_tot++);
   }
   kval_base = kval_tot;   //ici nbase=6 (par defaut)

   values = new Double_t[knbre_val_max];
   init_val();


}
Esempio n. 2
0
KVINDRATelescope* KVINDRA::BuildTelescope(const Char_t* prefix, Int_t module)
{
   // Build telescope from infos in file "$KVROOT/KVFiles/data/indra-struct.[dataset].env"

   //Info("BuildTelescope", "Building telescope %s",name);
   KVINDRATelescope* kvt = new KVINDRATelescope;
   KVString telescopes = fStrucInfos.GetValue(Form("%s.Telescope", prefix), "");
   telescopes.Begin(" ");
   KVString name;
   while (!telescopes.End()) {
      name = telescopes.Next();
      KVNumberList mods = fStrucInfos.GetValue(Form("%s.Telescope.%s.Modules", prefix, name.Data()), "1-100");
      if (mods.Contains(module)) break;
   }

   KVString detectors = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.Detectors", name.Data()), "");
   Double_t aziwidth = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.AziWidth", name.Data()), 1.0);
   Double_t dist = fStrucInfos.GetValue(Form("%s.Dist", prefix), 0.0);
   kvt->SetDistance(dist);
   detectors.Begin(" ");
   Int_t idet = 1;
   while (!detectors.End()) {
      KVString detector = detectors.Next();
      detector.Begin("()");
      KVString dettype = detector.Next();
      Double_t detthick = detector.Next().Atof();
      KVDetector* det = KVDetector::MakeDetector(Form("%s.%s", fDataSet.Data(), dettype.Data()), detthick);
      kvt->Add(det);
      Double_t depth = fStrucInfos.GetValue(Form("INDRA.Telescope.%s.Depth.%s", name.Data(), dettype.Data()), 0.);
      kvt->SetDepth(idet, depth);
      idet++;
   }
   kvt->SetAzimuthalWidth(aziwidth);
   return kvt;
}
Esempio n. 3
0
//________________________________________________________________
Double_t KVCaloBase::GetIngValue(KVString name)
{ 
	//return the value of a name given ingredient
	//if it is not defined return 0
	if (!nvl_ing->HasParameter(name.Data())) return 0;
	return nvl_ing->GetDoubleValue(name.Data());
}
Esempio n. 4
0
//___________________________________________________________________________________________
void KVValues::DefineAdditionalValue(KVString name, KVString expr)
{

   if (HasParameter(name.Data())) {
      Warning("DefineAdditionalValue", "le nom de variable %s est deja utilise", name.Data());
      return;
   }

   KVString expr2 = expr;
   KVNumberList* nl = TransformExpression(expr2);

   if (nl) {
      if (nl->IsEmpty()) {
         Warning("DefineAdditionalValue", "la KVNumberList est vide #%s#", nl->GetList());
      }
      else {
         if (AddFormula(name, expr2)) {
            LinkParameters(nl);
            ComputeAdditionalValues(kval_add - 1, kval_add);
         }
      }
   }
   else {
      Error("DefineAdditionalValue", "La traduction de l'expression %s a echouee", expr.Data());
   }
}
void KVDP2toCsIGridConvertor::ReadGammaFile(const Char_t* gammafile)
{
   ifstream gamfile;
   gamfile.open(gammafile);

   if (!gamfile.good()) {
      Error(KV__ERROR(ReadGammaFile),
            "Problem reading file %s", gammafile);
      return;
   }
   KVString s;

   s.ReadLine(gamfile);

   while (gamfile.good()) {

      if (s == "") {
         s.ReadLine(gamfile);
         continue;
      }

      if (!s.BeginsWith('#')) { //'#' sign signals comments
         int ring, modu, frun, lrun;
         if (sscanf(s.Data(), "%d %d %d %d", &ring, &modu, &frun, &lrun) !=
               4) {
            Error(KV__ERROR(ReadGammaFile), "Problem reading file %s\nLast line read: %s",
                  gammafile, s.Data());
            return;
         };
         //get grid for this ring,mod
         TString name;
         name.
         Form
         ("CsI R-L Grid First run=%d Last run=%d Ring min=%d Ring max=%d Mod min=%d Mod max=%d",
          frun, lrun, ring, ring, modu, modu);
         KVIDGrid* grid = (KVIDGrid*)fGrids->FindObject(name.Data());
         if (!grid) {
            Error(KV__ERROR(ReadGammaFile), "Can't find grid %s", name.Data());
         }
         int npoints;
         gamfile >> npoints;
         //found gamma line
         KVIDLine* line = 0;
         if (grid) {
            line = grid->NewLine("ok");
            line->SetName("gamma_line");
            line->Set(npoints);
            grid->Add("ok", line);
         }
         //read in points
         for (int i = 0; i < npoints; i++) {
            Double_t x, y;
            gamfile >> x >> y;
            if (grid)
               line->SetPoint(i, x, y);
         }
      }
      s.ReadLine(gamfile);
   }
Esempio n. 6
0
//________________________________________________________________
Bool_t KVFAZIADetector::SetProperties()
{
	// detector name are assumed to be defined as
   // SI2-T2-Q2-B001
	//	CSI-T2-Q2-B001
	// SI1-T1-Q1-B001
	//
   
   KVString tmp;
   KVString sname(GetName());
   sname.Begin("-");
   SetLabel(sname.Next());
	gFazia->AddDetectorLabel(GetLabel());
   
	tmp = sname.Next(); tmp.ReplaceAll("T",""); fTelescope = tmp.Atoi();
	tmp = sname.Next(); tmp.ReplaceAll("Q",""); fQuartet = tmp.Atoi();
	tmp = sname.Next(); tmp.ReplaceAll("B",""); fBlock = tmp.Atoi();
	KVSignal* sig=0;
   //"QH1", "I1", "QL1", "Q2", "I2", "Q3
	if (fSignals)
   	delete fSignals;
   fSignals = new KVList(kTRUE);
	KVString lsignals="";
   if ( !strcmp(GetLabel(),"SI1") ) {	lsignals="QH1,I1,QL1";	}
   else if ( !strcmp(GetLabel(),"SI2" ) ) {	lsignals="Q2,I2";	}
	else if ( !strcmp(GetLabel(),"CSI" ) ) {	lsignals="Q3";	}
   else{
   	Warning("SetProperties","Unknown label \"%s\" for this detector : %s\n",GetLabel(),GetName());
		lsignals="";
	}
   
	lsignals.Begin(",");
	while ( !lsignals.End() )
	{
		KVString ssig = lsignals.Next();
		if (ssig.BeginsWith("Q")){
			sig = new KVChargeSignal(ssig.Data());
		}
		else if (ssig.BeginsWith("I")){
			sig = new KVCurrentSignal(ssig.Data());
		}
		else{
			Warning("unknown format signal detectorlabel=%s, signal=%s\n",GetLabel(),ssig.Data());
			sig = new KVSignal(ssig.Data(),"unknown");
		}
		
		sig->LoadPSAParameters(GetLabel());
		sig->SetDetectorName(GetName());
		fSignals->Add(sig);
	}
	
	return kTRUE;
}
Esempio n. 7
0
//___________________________________________________________________________________________
Bool_t KVValues::AddFormula(KVString name, KVString expr)
{

   TFormula* fm = new TFormula(name.Data(), expr.Data());
   if (fm->GetExpFormula().IsNull()) {
      Warning("AddFormula", "%s considere comme nulle", expr.Data());
      return kFALSE;
      delete fm;
   }
   kform_add->Add(fm);
   SetValue(name.Data(), kval_tot++);
   kval_add += 1;
   return kTRUE;
}
Esempio n. 8
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. 9
0
void KVEventSelector::ParseOptions()
{
   // Analyse comma-separated list of options given to TTree::Process
   // and store all "option=value" pairs in fOptionList.
   // Options can then be accessed using IsOptGiven(), GetOptString(), etc.
   //
   //     BranchName=xxxx  :  change name of branch in TTree containing data
   //     EventsReadInterval=N: print "+++ 12345 events processed +++" every N events
   //
   // This method is called by SlaveBegin
   //

	fOptionList.Clear(); // clear list
   KVString option = GetOption();
   option.Begin(",");
   while (!option.End()) {

      KVString opt = option.Next();
      opt.Begin("=");
      KVString param = opt.Next();
      KVString val=opt.Next();
      while(!opt.End()){
          val+="=";
          val+=opt.Next();
      }

      SetOpt(param.Data(), val.Data());
   }
	
	fOptionList.Print();
	// check for branch name
	if(IsOptGiven("BranchName")) SetBranchName(GetOpt("BranchName"));
	// check for events read interval
	if(IsOptGiven("EventsReadInterval")) SetEventsReadInterval(GetOpt("EventsReadInterval").Atoi());
}
Esempio n. 10
0
void KVINDRAUpDater_e475s::SetPedestals(KVDBRun* kvrun)
{
   
	KVRList *param_list = kvrun->GetLinks("Pedestals");

   if (!param_list)
      return;
   if (!param_list->GetSize())
      return;

   KVDetector *det;
   KVDBParameterSet *kvps;
   TIter next_ps(param_list);
   KVString str;
	Double_t pied_value;
	
   // Setting all pedestal values available
   while ((kvps = (KVDBParameterSet *) next_ps())) {    // boucle sur les parametres
      str = kvps->GetName();
		if ( (det = gIndra->GetDetector(str.Data())) ){
		   pied_value = kvps->GetParameter(1);
			det->SetPedestal(kvps->GetTitle(),pied_value);
		}                      //detector found
   }   	                     //boucle sur les parameters

}
Esempio n. 11
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);

}
Esempio n. 12
0
void KVFAZIA::SetNameOfDetectors(KVEnv& env)
{
   for (Int_t bb = fStartingBlockNumber; bb < fNblocks; bb += 1) {
      for (Int_t qq = 1; qq <= 4; qq += 1) {
         for (Int_t tt = 1; tt <= 4; tt += 1) {
            fDetectorLabels.Begin(",");
            while (!fDetectorLabels.End()) {
               KVString sdet = fDetectorLabels.Next();
               env.SetValue(
                  Form("BLOCK_%d_QUARTET_%d_%s-T%d", bb, qq, sdet.Data(), tt),
                  Form("%s-T%d-Q%d-B%03d", sdet.Data(), tt, qq, bb)
               );
            }
         }
      }
   }
}
Esempio n. 13
0
void KVINDRA::BuildGeometry()
{
   // Construction of INDRA detector array.
   // Uses infos in file $KVROOT/KVFiles/data/indra_struct.[dataset].env
   //                 or $KVROOT/KVFiles/data/indra_struct.env
   // if no dataset-specific file found


   TString path = Form("indra-struct.%s.env", fDataSet.Data());
   TString path2;
   SearchKVFile(path.Data(), path2, "data");
   if (path2 == "") {
      path = "indra-struct.env";
      SearchKVFile(path.Data(), path2, "data");
   }
   fStrucInfos.ReadFile(path2, kEnvAll);

   KVString lruns = fStrucInfos.GetValue("AddOnForRuns", "");
   //test if additional geometrical specification exists
   if (lruns != "") {
      lruns.Begin(",");
      while (!lruns.End()) {
         KVString sruns = lruns.Next();
         KVNumberList nlr(sruns.Data());
         //the current run needs specific geometry
         if (nlr.Contains(fCurrentRun)) {
            path = fStrucInfos.GetValue(sruns.Data(), "");
            Info("BuildGeometry", "Additional geometry for run=%d in file #%s#", fCurrentRun, path.Data());
            SearchKVFile(path.Data(), path2, "data");
            if (path2 == "") {
               Warning("BuildGeometry", "fichier %s inconnu", path.Data());
            }
            else {
               fStrucInfos.ReadFile(path2, kEnvChange);
            }
         }
      }
   }

   SetName(fStrucInfos.GetValue("INDRA.Name", ""));
   SetTitle(fStrucInfos.GetValue("INDRA.Title", ""));

   KVString layers = fStrucInfos.GetValue("INDRA.Layers", "");
   layers.Begin(" ");
   while (!layers.End()) BuildLayer(layers.Next());
}
Esempio n. 14
0
void KV_CCIN2P3_GE::ChooseJobDisk()
{
   KVString tmp = "";
   cout << "Enter max scratch disk per job (xKB/xMB/xGB) ["
        << fDefJobDisk.Data() << "] : ";
   cout.flush();
   tmp.ReadToDelim(cin);
   SetJobDisk(tmp.Data());
}
Esempio n. 15
0
void KV_CCIN2P3_GE::ChooseJobMemory()
{
   KVString tmp = "";
   cout << "Enter max memory per job (xKB/xMB/xGB) ["
        << fDefJobMem.Data() << "] : ";
   cout.flush();
   tmp.ReadToDelim(cin);
   SetJobMemory(tmp.Data());
}
Esempio n. 16
0
//________________________________________________________________________________________
TGraph* KVINDRA::GetPedestals(const Char_t* det_signal, const Char_t* det_type, Int_t ring_number, Int_t
                              run_number)
{

   //Renvoie sous forme de TGraph (en fonction du numero de module)
   //les piedestaux du signal (det_signal) asssocies aux detecteurs de type (det_type)
   //qui sont presents dans la couronne ring_number pour un numero de run donne (si run_number==-1)
   //on suppose que gIndra->SetParameters(xxx) a ete fait en amont
   //L'utilisateur doit effacer ce TGraph tout seul comme un grand apres usage
   //Une recherche sur l existence ou non du graph permet d eviter des boucles inutiles
   //Si l appel est reitere

   if (run_number != -1 || run_number != Int_t(GetCurrentRunNumber()))
      SetParameters(run_number);

   KVSeqCollection* sltype = 0;
   KVSeqCollection* slring = 0;
   TGraph* gr_ped = 0;

   KVString sgraph;
   sgraph.Form("KVPed_%s_%s_%d_%d", det_signal, det_type, ring_number, GetCurrentRunNumber());
   if ((gr_ped = (TGraph*)gROOT->FindObject(sgraph.Data()))) return gr_ped;

   if ((sltype = GetDetectors()->GetSubListWithMethod(det_type, "GetType"))) {
      KVString sring;
      sring.Form("%d", ring_number);
      if ((slring = sltype->GetSubListWithMethod(sring, "GetRingNumber"))) {
         gr_ped = new TGraph();
         gr_ped->SetName(sgraph.Data());
         for (Int_t mm = 0; mm < slring->GetEntries(); mm += 1) {
            gr_ped->SetPoint(gr_ped->GetN(),
                             ((KVINDRADetector*)slring->At(mm))->GetModuleNumber(),
                             ((KVDetector*)slring->At(mm))->GetPedestal(det_signal));

         }
         delete slring;
         return gr_ped;
      }
      delete sltype;
   }
   return 0;

}
Esempio n. 17
0
void KVINDRA::SetPinLasersForCsI()
{
   // Sets the KVCsI::fPinLaser member of each CsI detector with the number of the
   // pin laser associated for the stability control of these detectors.
   //
   // We look for a file with the following format:
   //
   // CSI_0101     1
   // CSI_0102     1
   // CSI_0103     1
   // CSI_0104     1
   // etc.
   //
   // i.e. 'name of CsI detector'   'number of pin laser (1-8)'
   // Comment lines must begin with '#'
   //
   // The default name of this file is defined in .kvrootrc by
   //
   // INDRADB.CsIPinCorr:          CsI_PILA.dat
   //
   // Dataset-specific version can be specified:
   //
   // INDRA_e999.INDRADB.CsIPinCorr:    CorrCsIPin_2054.dat
   //
   // This file should be in the directory corresponding to the current dataset,
   // i.e. in $KVROOT/KVFiles/name_of_dataset

   ifstream pila_file;
   if (gDataSet->OpenDataSetFile(gDataSet->GetDataSetEnv("INDRADB.CsIPinCorr", ""), pila_file)) {

      Info("SetPinLasersForCsI", "Setting correspondance CsI-PinLaser using file %s.",
           gDataSet->GetDataSetEnv("INDRADB.CsIPinCorr", ""));
      // read file, set correspondance
      KVString line;
      line.ReadLine(pila_file);
      while (pila_file.good()) {
         if (!line.BeginsWith("#")) {
            line.Begin(" ");
            KVString detname = line.Next(kTRUE);
            KVCsI* det = (KVCsI*)GetDetector(detname.Data());
            Int_t pila = line.Next(kTRUE).Atoi();
            if (det) {
               det->SetPinLaser(pila);
            }
         }
         line.ReadLine(pila_file);
      }
      pila_file.close();
   }
   else {
      Info("SetPinLasersForCsI", "File %s not found. Correspondance Csi-PinLaser is unknown.",
           gDataSet->GetDataSetEnv("CsIPinCorr", ""));
   }
}
Esempio n. 18
0
void KVGeoNavigator::FormatStructureName(const Char_t* type, Int_t number, KVString& name)
{
   // If a format for naming structures of given type has been defined by a call
   // to SetStructureNameFormat(const Char_t *, const Char_t *), we use it to
   // format the name in the TString.
   // If no format was given, we use by default "[type]_[number]"
   // If SetNameCorrespondanceList(const Char_t *) was used, we use it to translate
   // any names resulting from this formatting to their final value.

   name = "";
   if (fStrucNameFmt.HasParameter(type)) {
      KVString fmt = fStrucNameFmt.GetStringValue(type);
      fmt.Begin("$");
      while (!fmt.End()) {
         KVString bit = fmt.Next();
         if (bit.BeginsWith("type")) {
            Ssiz_t ind = bit.Index("%");
            if (ind > -1) {
               bit.Remove(0, ind);
               name += Form(bit.Data(), type);
            } else
               name += type;
         } else if (bit.BeginsWith("number")) {
            Ssiz_t ind = bit.Index("%");
            if (ind > -1) {
               bit.Remove(0, ind);
               name += Form(bit.Data(), number);
            } else
               name += number;
         } else
            name += bit;
      }
   } else
      name.Form("%s_%d", type, number);
   TString tmp;
   GetNameCorrespondance(name.Data(), tmp);
   name = tmp;
}
Esempio n. 19
0
const Char_t* KVINDRAReconDataAnalyser::ExpandAutoBatchName(const Char_t* format)
{
   //Replace any 'special' symbols in "format" with their current values
   //
   //  $Date   : current date and time
   //  $System  :  name of system to be analysed
   //  $User  :  name of user
   //  $UserClass or $Selector :  name of user's analysis class (KVSelector)
   //  $DataSelector  :  name of user's data selector (KVDataSelector)
   
   static KVString tmp;
   tmp = KVDataAnalyser::ExpandAutoBatchName(format);
   tmp.ReplaceAll("$Selector", GetUserClass());
   tmp.ReplaceAll("$DataSelector", GetKVDataSelector());
   return tmp.Data();
}
Esempio n. 20
0
KVNumberList KVINDRAReconDataAnalyser::PrintAvailableRuns(KVString & datatype)
{
   //Prints list of available runs, sorted according to multiplicity
   //trigger, for selected dataset, data type/analysis task, and system
   //Returns list containing all run numbers

   KVNumberList all_runs=
       fDataSet->GetRunList(datatype.Data(), fSystem);
   KVINDRADBRun *dbrun;
   
   //first read list and find what triggers are available
   int triggers[10], n_trigs = 0;
   all_runs.Begin();
   while ( !all_runs.End() ) {
      dbrun = (KVINDRADBRun *)fDataSet->GetDataBase()->GetTable("Runs")->GetRecord(all_runs.Next());
      if (!KVBase::
          ArrContainsValue(n_trigs, triggers, dbrun->GetTrigger())) {
         triggers[n_trigs++] = dbrun->GetTrigger();
      }
   }
   //sort triggers in ascending order
   int ord_trig[10];
   TMath::Sort(n_trigs, triggers, ord_trig, kFALSE);

   int trig = 0;
   while (trig < n_trigs) {
      cout << " ---> Trigger M>" << triggers[ord_trig[trig]] << endl;
      all_runs.Begin();
      while ( !all_runs.End() ) {
         dbrun = (KVINDRADBRun *)fDataSet->GetDataBase()->GetTable("Runs")->GetRecord(all_runs.Next());
         if (dbrun->GetTrigger() == triggers[ord_trig[trig]]) {
            cout << "    " << Form("%4d", dbrun->GetNumber());
            cout << Form("\t(%7d events)", dbrun->GetEvents());
            cout << "\t[File written: " << dbrun->GetDatime().
                AsString() << "]";
            if (dbrun->GetComments())
               cout << "\t" << dbrun->GetComments();
            cout << endl;
         }
      }
      trig++;
      cout << endl;
   }
   return all_runs;
}
void KVFAZIARawDataReconstructor::ExtraProcessing()
{
   KVString label = "";

   KVFAZIADetector* det = 0;
   KVSignal* sig = 0;
   KVReconstructedNucleus* recnuc = 0;
   while ((recnuc = recev->GetNextParticle())) {
      TIter next_d(recnuc->GetDetectorList());
      while ((det = (KVFAZIADetector*)next_d())) {
         TIter next_s(det->GetListOfSignals());
         while ((sig = (KVSignal*)next_s())) {
            if (sig->HasFPGA()) {
               for (Int_t ii = 0; ii < sig->GetNFPGAValues(); ii += 1) {
                  //SI2-T3-Q1-B003.Q2.RawAmplitude=14
                  if (ii == 0) label = "FPGAEnergy";
                  if (ii == 1) label = "FPGAFastEnergy"; //only for CsI Q3
                  TString ene = GetEvent()->GetFPGAEnergy(
                                   det->GetBlockNumber(),
                                   det->GetQuartetNumber(),
                                   det->GetTelescopeNumber(),
                                   sig->GetType(),
                                   ii
                                );

                  recnuc->GetParameters()->SetValue(
                     Form("%s.%s.%s", det->GetName(), sig->GetName(), label.Data()),
                     ene.Data()
                  );
               }
            }
            if (!sig->PSAHasBeenComputed()) {
               sig->TreateSignal();
            }

            KVNameValueList* psa = sig->GetPSAResult();
            if (psa) {
               *(recnuc->GetParameters()) += *psa;
               delete psa;
            }
         }
      }
   }
}
KVNumberList KVINDRARawDataAnalyser::PrintAvailableRuns(KVString& datatype)
{
   //Prints list of available runs, sorted according to multiplicity
   //trigger, for selected dataset, data type/analysis task, and system
   //Returns list containing all run numbers

   KVNumberList all_runs =
      GetDataSet()->GetRunList(datatype.Data(), GetSystem());
   KVINDRADBRun* dbrun;

   //first read list and find what triggers are available
   vector<int> triggers;
   all_runs.Begin();
   while (!all_runs.End()) {
      dbrun = (KVINDRADBRun*)GetDataSet()->GetDataBase()->GetDBRun(all_runs.Next());
      if (triggers.size() == 0
            || std::find(triggers.begin(), triggers.end(), dbrun->GetTrigger()) != triggers.end()) {
         triggers.push_back(dbrun->GetTrigger());
      }
   }
   //sort triggers in ascending order
   std::sort(triggers.begin(), triggers.end());

   for (std::vector<int>::iterator it = triggers.begin(); it != triggers.end(); ++it) {
      cout << " ---> Trigger M>" << *it << endl;
      all_runs.Begin();
      while (!all_runs.End()) {
         dbrun = (KVINDRADBRun*)GetDataSet()->GetDataBase()->GetDBRun(all_runs.Next());
         if (dbrun->GetTrigger() == *it) {
            cout << "    " << Form("%4d", dbrun->GetNumber());
            cout << Form("\t(%7d events)", dbrun->GetEvents());
            cout << "\t[File written: " << dbrun->GetDatime().
                 AsString() << "]";
            if (dbrun->GetComments())
               cout << "\t" << dbrun->GetComments();
            cout << endl;
         }
      }
      cout << endl;
   }
   return all_runs;
}
Esempio n. 23
0
//________________________________________________________________
Double_t KVCaloBase::GetParValue(KVString name)
{
	//return the value of a name given parameter
	return nvl_par->GetDoubleValue(name.Data());
}
Esempio n. 24
0
//________________________________________________________________
void KVCaloBase::SetIngValue(KVString name,Double_t value)
{
	// protected method,
	//set the value a name given ingredient
	nvl_ing->SetValue(name.Data(),value);
}
Esempio n. 25
0
//________________________________________________________________
Bool_t KVCaloBase::HasParameter(KVString name)
{
	// protected method,
	//Check if a given parameter is defined
	return nvl_par->HasParameter(name.Data());
}
Esempio n. 26
0
//___________________________________________________
void KVClassFactory::WriteClassDec(ofstream & file)
{
   // Write the class declaration in the header file
   // This will include a default (public) constructor & destructor and
   // any methods added using AddMethod, sorted according to
   // their access type.

   file << "class " << fClassName.Data();
   if (fHasBaseClass) {
		file << " : ";
		if(WithMultipleBaseClasses()){
			fBaseClassName.Begin(",");
			file << "public " << fBaseClassName.Next(kTRUE);
			while( !fBaseClassName.End() ) file << ", public " << fBaseClassName.Next(kTRUE);
		}
		else
	file << "public " << fBaseClassName.Data();
   }
   file << "\n{" << endl;

   // protected members
   KVList* prem = (KVList*)fMembers.GetSubListWithMethod("protected", "GetAccess");
   if( prem->GetEntries() ){
      file << "\n   protected:" << endl;
      KVString line;
      TIter next( prem ); KVClassMember* meth;
      while( (meth = (KVClassMember*)next()) ){
         meth->WriteDeclaration(line);
         file << "   " << line.Data() << endl;
      }
   }
   delete prem;

   // private methods
   KVList* priv = (KVList*)fMethods.GetSubListWithMethod("private", "GetAccess");
   if( priv->GetEntries() ){
      file << "   private:" << endl;
      KVString line;
      TIter next( priv ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
         meth->WriteDeclaration(line);
         file << "   " << line.Data() << endl;
      }
   }
   delete priv;

   // protected methods
   KVList* prot = (KVList*)fMethods.GetSubListWithMethod("protected", "GetAccess");
   if( prot->GetEntries() ){
      file << "\n   protected:" << endl;
      KVString line;
      TIter next( prot ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
         meth->WriteDeclaration(line);
         file << "   " << line.Data() << endl;
      }
   }
   delete prot;

   //public methods
   file << "\n   public:" << endl;
   //default ctor
   file << "   " << fClassName.Data() << "();" << endl;
	//any other ctors ?
   KVList* ctor = (KVList*)fMethods.GetSubListWithMethod("1", "IsConstructor");
	if( ctor->GetEntries() ){
      KVString line;
      TIter next( ctor ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
         meth->WriteDeclaration(line);
         file << "   " << line.Data() << endl;
      }
	}
	delete ctor;
	// default dtor
   file << "   virtual ~" << fClassName.Data() << "();" << endl;

   // public methods
   KVList* pub = (KVList*)fMethods.GetSubListWithMethod("public", "GetAccess");
   if( pub->GetEntries() ){
      KVString line;
      TIter next( pub ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
			if(!meth->IsConstructor() ){
         	meth->WriteDeclaration(line);
         	file << "   " << line.Data() << endl;
			}
      }
   }
   delete pub;

   file << "\n   ClassDef(" << fClassName.Data() << ",1)//";
   file << fClassDesc.Data() << endl;
   file << "};\n\n#endif" << endl;      //don't forget to close the preprocessor #if !!!
}
Esempio n. 27
0
//___________________________________________________
void KVClassFactory::WriteClassImp()
{
   //Write the class implementation file
   //This includes a class description in pure HTML

   ofstream file_cpp;

   file_cpp.open( GetImpFileName() );

   WriteWhoWhen(file_cpp);

   file_cpp << "#include \"" << fClassName.Data() << ".h\"" << endl;
   if( fImpInc.GetSize() ){
      TIter next(&fImpInc); TObjString* str;
      while( (str = (TObjString*)next()) ){
         file_cpp << "#include \"" << str->String().Data() << "\"" << endl;
      }
   }
   file_cpp << endl << "ClassImp(" << fClassName.Data() << ")\n" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////"
       << endl;
   file_cpp << "// BEGIN_HTML <!--" << endl;
   file_cpp << "/* -->" << endl;
   file_cpp << "<h2>" << fClassName.Data() << "</h2>" << endl;
   file_cpp << "<h4>" << fClassDesc.Data() << "</h4>" << endl;
   file_cpp << "<!-- */" << endl;
   file_cpp << "// --> END_HTML" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////\n"
       << endl;
   file_cpp << fClassName.Data() << "::" << fClassName.
       Data() << "()" << endl;
   file_cpp << "{\n   // Default constructor\n}\n" << endl;
	// any other ctors ?
   KVList* ctor = (KVList*)fMethods.GetSubListWithMethod("1", "IsConstructor");
	if( ctor->GetEntries() ){
      KVString line;
      TIter next( ctor ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
         meth->WriteImplementation(line);
         line.Prepend("//________________________________________________________________\n\n");
         file_cpp << line.Data() << endl;
      }
	}
	delete ctor;

   file_cpp << fClassName.Data() << "::~" << fClassName.
       Data() << "()" << endl;
   file_cpp << "{\n   // Destructor\n}\n" << endl;

   //write implementations of added methods
   if( fMethods.GetSize() ){
      KVString line;
      TIter next( &fMethods ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
			if( !meth->IsConstructor() ){
         	meth->WriteImplementation(line);
         	line.Prepend("//________________________________________________________________\n\n");
         	file_cpp << line.Data() << endl;
			}
      }
   }

   file_cpp.close();

   cout << "<KVClassFactory::WriteClassImp> : File " << GetImpFileName() << " generated." << endl;
}
Esempio n. 28
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. 29
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;

}
Esempio n. 30
0
//___________________________________________________
void KVClassFactory::WriteClassWithTemplateImp()
{
   // Writes the implementation file for the class

   ofstream file_cpp;

   file_cpp.open( GetImpFileName() );

   WriteWhoWhen(file_cpp);

   file_cpp << "#include \"" << fClassName.Data() << ".h\"" << endl;
   if( fImpInc.GetSize() ){
      TIter next(&fImpInc); TObjString* str;
      while( (str = (TObjString*)next()) ){
         file_cpp << "#include \"" << str->String().Data() << "\"" << endl;
      }
   }
   file_cpp << endl << "ClassImp(" << fClassName.Data() << ")\n" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////"
       << endl;
   file_cpp << "// BEGIN_HTML <!--" << endl;
   file_cpp << "/* -->" << endl;
   file_cpp << "<h2>" << fClassName.Data() << "</h2>" << endl;
   file_cpp << "<h4>" << fClassDesc.Data() << "</h4>" << endl;
   file_cpp << "<!-- */" << endl;
   file_cpp << "// --> END_HTML" << endl;
   file_cpp <<
       "////////////////////////////////////////////////////////////////////////////////\n"
       << endl;

   TString cppFile;
   ifstream file_cpp_template;

   //open file whose full path was stored in fTemplateCPP
   if (!KVBase::
       SearchAndOpenKVFile(fTemplateCPP.Data(), file_cpp_template)) {
      //this should never happen!
      cout << "<KVClassFactory::WriteClassWithTemplateImp>: cannot open "
          << fTemplateCPP.Data() << endl;
      return;
   }

   cppFile.ReadFile(file_cpp_template);
   file_cpp_template.close();
   file_cpp << cppFile.ReplaceAll(fTemplateClassName.Data(),
                                  fClassName.Data());

   //write implementations of added methods
   if( fMethods.GetSize() ){
      KVString line;
      TIter next( &fMethods ); KVClassMethod* meth;
      while( (meth = (KVClassMethod*)next()) ){
         meth->WriteImplementation(line);
         line.Prepend("\n//________________________________________________________________\n");
         file_cpp << line.Data();
      }
   }
   file_cpp.close();

   cout << "<KVClassFactory::WriteClassWithTemplateImp> : File " << GetImpFileName() << " generated." << endl;
}