228228// / not exactly the same, then a warning output message will be prompted.
229229// / - **last**: It will simply register the value of the metadata member
230230// / from the last file in the list of selected files.
231+ // / - **append**: It will append the metadata member value to the previous
232+ // / value. The user can specify the appender string after the `append`
233+ // / keyword. If no appender is given, then an empty string will be used.
234+ // / It will check if the value is already in the string and not append it
235+ // / if it is. Use _extend_ if you want to force the append.
236+ // / - **extend**: same as _append_ but it will not check if the value is
237+ // / already in the string.
231238// /
232239// / ### Adding a new column based on relevant quantities
233240// /
@@ -352,29 +359,14 @@ void TRestDataSet::GenerateDataSet() {
352359
353360 // /// Disentangling process observables --> producing finalList
354361 TRestRun run (fFileSelection .front ());
355- std::vector <std::string> finalList;
356- finalList.push_back (" runOrigin" );
357- finalList.push_back (" eventID" );
358- finalList.push_back (" timeStamp" );
362+ std::set <std::string> finalList;
363+ finalList.insert (" runOrigin" );
364+ finalList.insert (" eventID" );
365+ finalList.insert (" timeStamp" );
359366
360367 auto obsNames = run.GetAnalysisTree ()->GetObservableNames ();
361- for (const auto & obs : fObservablesList ) {
362- if (std::find (obsNames.begin (), obsNames.end (), obs) != obsNames.end ()) {
363- finalList.push_back (obs);
364- } else {
365- RESTWarning << " Observable " << obs << " not found in observable list, skipping..." << RESTendl;
366- }
367- }
368-
369- for (const auto & name : obsNames) {
370- for (const auto & pcs : fProcessObservablesList ) {
371- if (name.find (pcs) == 0 ) finalList.push_back (name);
372- }
373- }
374-
375- // Remove duplicated observables if any
376- std::sort (finalList.begin (), finalList.end ());
377- finalList.erase (std::unique (finalList.begin (), finalList.end ()), finalList.end ());
368+ auto obsFromList = TRestTools::GetMatchingStrings (obsNames, fObservablesList );
369+ finalList.insert (obsFromList.begin (), obsFromList.end ());
378370
379371 if (fMT )
380372 ROOT::EnableImplicitMT ();
@@ -390,11 +382,11 @@ void TRestDataSet::GenerateDataSet() {
390382 // Adding new user columns added to the dataset
391383 for (const auto & [cName, cExpression] : fColumnNameExpressions ) {
392384 RESTInfo << " Adding column to dataset: " << cName << RESTendl;
393- finalList.emplace_back (cName);
385+ finalList.emplace (cName);
394386 fDataFrame = DefineColumn (cName, cExpression);
395387 }
396388
397- RegenerateTree (finalList);
389+ RegenerateTree (std::vector<std::string>( finalList. begin (), finalList. end ()) );
398390
399391 RESTInfo << " - Dataset generated!" << RESTendl;
400392}
@@ -513,6 +505,26 @@ std::vector<std::string> TRestDataSet::FileSelection() {
513505 }
514506
515507 if (properties.strategy == " last" ) properties.value = value;
508+
509+ if (properties.strategy .find (" append" ) != std::string::npos) {
510+ // Get appender from "append" til the end of string. E.g. "append," -> "," or "append" -> ""
511+ std::string appender = properties.strategy .substr (properties.strategy .find (" append" ) + 6 );
512+ if (properties.value .empty ())
513+ properties.value = value;
514+ else
515+ // do not append if value already contains the value to append
516+ if (properties.value .find (value) == std::string::npos)
517+ properties.value += appender + value;
518+ }
519+
520+ if (properties.strategy .find (" extend" ) != std::string::npos) {
521+ // Get appender from "extend" til the end of string. E.g. "extend," -> "," or "extend" -> ""
522+ std::string appender = properties.strategy .substr (properties.strategy .find (" extend" ) + 6 );
523+ if (properties.value .empty ())
524+ properties.value = value;
525+ else
526+ properties.value += appender + value;
527+ }
516528 }
517529
518530 if (run.GetStartTimestamp () < fStartTime ) fStartTime = run.GetStartTimestamp ();
@@ -645,21 +657,13 @@ void TRestDataSet::PrintMetadata() {
645657 RESTMetadata << " " << RESTendl;
646658
647659 if (!fObservablesList .empty ()) {
648- RESTMetadata << " Single observables added:" << RESTendl;
660+ RESTMetadata << " Observables added:" << RESTendl;
649661 RESTMetadata << " -------------------------" << RESTendl;
650662 for (const auto & l : fObservablesList ) RESTMetadata << " - " << l << RESTendl;
651663
652664 RESTMetadata << " " << RESTendl;
653665 }
654666
655- if (!fProcessObservablesList .empty ()) {
656- RESTMetadata << " Process observables added: " << RESTendl;
657- RESTMetadata << " -------------------------- " << RESTendl;
658- for (const auto & l : fProcessObservablesList ) RESTMetadata << " - " << l << RESTendl;
659-
660- RESTMetadata << " " << RESTendl;
661- }
662-
663667 if (!fFilterMetadata .empty ()) {
664668 RESTMetadata << " Metadata filters: " << RESTendl;
665669 RESTMetadata << " ----------------- " << RESTendl;
@@ -784,7 +788,10 @@ void TRestDataSet::InitFromConfigFile() {
784788
785789 std::vector<std::string> obsList = REST_StringHelper::Split (observables, " ," );
786790
787- for (const auto & l : obsList) fProcessObservablesList .push_back (l);
791+ for (const auto & l : obsList) {
792+ std::string processObsPattern = l + " _*" ;
793+ fObservablesList .push_back (processObsPattern);
794+ }
788795
789796 obsProcessDefinition = GetNextElement (obsProcessDefinition);
790797 }
@@ -1006,7 +1013,6 @@ TRestDataSet& TRestDataSet::operator=(TRestDataSet& dS) {
10061013 fFilePattern = dS.GetFilePattern ();
10071014 fObservablesList = dS.GetObservablesList ();
10081015 fFileSelection = dS.GetFileSelection ();
1009- fProcessObservablesList = dS.GetProcessObservablesList ();
10101016 fFilterMetadata = dS.GetFilterMetadata ();
10111017 fFilterContains = dS.GetFilterContains ();
10121018 fFilterGreaterThan = dS.GetFilterGreaterThan ();
0 commit comments