ATLAS Offline Software
Loading...
Searching...
No Matches
dqi::HanConfig::AssessmentVisitor Class Reference

#include <HanConfig.h>

Inheritance diagram for dqi::HanConfig::AssessmentVisitor:
Collaboration diagram for dqi::HanConfig::AssessmentVisitor:

Public Member Functions

 AssessmentVisitor (HanConfigGroup *root_, const MiniConfig &algConfig_, const MiniConfig &thrConfig_, const MiniConfig &refConfig_, TFile *outfile_, HanConfig::DirMap_t &directories_, TMap *refsourcedata_)
virtual void Visit (const MiniConfigTreeNode *node)

Protected Member Functions

void GetAlgorithmConfiguration (HanConfigAssessor *dqpar, const std::string &algID, const std::string &assessorName="")
std::shared_ptr< TFile > GetROOTFile (std::string &fname)
void PopulateKeyCache (const std::string &fname, std::shared_ptr< TFile > &file)
void EnsureKeyCache (std::string &fname)

Protected Attributes

HanConfigGroupm_root {}
const MiniConfigm_algConfig
const MiniConfigm_thrConfig
const MiniConfigm_refConfig
TFile * m_outfile {}
HanConfig::DirMap_tm_directories
TMap * m_refsourcedata {}
std::map< std::string, std::shared_ptr< TFile > > m_filecache
std::unordered_set< std::string > m_badPaths
std::map< std::string, std::vector< std::string > > m_keycache

Detailed Description

Definition at line 136 of file HanConfig.h.

Constructor & Destructor Documentation

◆ AssessmentVisitor()

dqi::HanConfig::AssessmentVisitor::AssessmentVisitor ( HanConfigGroup * root_,
const MiniConfig & algConfig_,
const MiniConfig & thrConfig_,
const MiniConfig & refConfig_,
TFile * outfile_,
HanConfig::DirMap_t & directories_,
TMap * refsourcedata_ )

Definition at line 903 of file HanConfig.cxx.

908 : AssessmentVisitorBase( root_, algConfig_, thrConfig_, refConfig_, outfile_, directories_, refsourcedata_ )
909{
910}
AssessmentVisitorBase(HanConfigGroup *root_, const MiniConfig &algConfig_, const MiniConfig &thrConfig_, const MiniConfig &refConfig_, TFile *outfile_, HanConfig::DirMap_t &directories_, TMap *refsourcedata_)

Member Function Documentation

◆ EnsureKeyCache()

void dqi::HanConfig::AssessmentVisitorBase::EnsureKeyCache ( std::string & fname)
protectedinherited

Definition at line 491 of file HanConfig.cxx.

492 {
493 DisableMustClean dmc;
494 auto file = GetROOTFile(fname);
495 if (file) {
496 if (m_keycache.find(fname) != m_keycache.end()) {
497 return;
498 } else {
499 m_keycache[fname].reserve(100000);
500 PopulateKeyCache(fname, file);
501 }
502 }
503}
std::shared_ptr< TFile > GetROOTFile(std::string &fname)
void PopulateKeyCache(const std::string &fname, std::shared_ptr< TFile > &file)
std::map< std::string, std::vector< std::string > > m_keycache
Definition HanConfig.h:120
TFile * file

◆ GetAlgorithmConfiguration()

void dqi::HanConfig::AssessmentVisitorBase::GetAlgorithmConfiguration ( HanConfigAssessor * dqpar,
const std::string & algID,
const std::string & assessorName = "" )
protectedinherited

Definition at line 525 of file HanConfig.cxx.

528{
529 // bool hasName(false);
530 std::set<std::string> algAtt;
531 m_algConfig.GetAttributeNames( algID, algAtt );
532 std::set<std::string>::const_iterator algAttEnd = algAtt.end();
533 for( std::set<std::string>::const_iterator i = algAtt.begin(); i != algAttEnd; ++i ) {
534 std::string trail("");
535 std::string::size_type pos = (*i).find('|');
536 if (pos != std::string::npos) {
537 trail = (*i).substr(pos + 1, std::string::npos);
538 }
539 if( *i == "name" ) {
540 // hasName = true;
541 std::string algName( m_algConfig.GetStringAttribute(algID,"name") );
542 dqpar->SetAlgName( std::move(algName) );
543 }
544 else if( *i == "libname" ) {
545 std::string algLibName( m_algConfig.GetStringAttribute(algID,"libname") );
546 dqpar->SetAlgLibName( std::move(algLibName) );
547 }
548 else if( *i == "thresholds" || trail == "thresholds" ) {
549 std::string thrID( m_algConfig.GetStringAttribute(algID,*i) );
550 std::set<std::string> thrAtt;
551 m_thrConfig.GetAttributeNames( thrID, thrAtt );
552 std::set<std::string>::const_iterator thrAttEnd = thrAtt.end();
553 for( std::set<std::string>::const_iterator t = thrAtt.begin(); t != thrAttEnd; ++t ) {
554 std::string thrAttName = *t;
555 std::string thrAttVal = m_thrConfig.GetStringAttribute( thrID, thrAttName );
556 std::string limName = thrAttVal + std::string("/") + thrAttName;
557 HanConfigAlgLimit algLim;
558 if (pos != std::string::npos) {
559 algLim.SetName( (*i).substr(0, pos) + std::string("|") + *t );
560 } else {
561 algLim.SetName( *t );
562 }
563 algLim.SetGreen( m_thrConfig.GetFloatAttribute(limName,"warning") );
564 algLim.SetRed( m_thrConfig.GetFloatAttribute(std::move(limName),"error") );
565 dqpar->AddAlgLimit( algLim );
566 }
567 }
568 else if( *i == "reference" ) {
569 // structure: if regex, store TMap of matching hist name -> names of reference objects
570 // if not regex, just store names of reference objects
571 // reference objects are TObjArrays if multiple references, else some kind of TObject
572 std::string tmpRefID=m_algConfig.GetStringAttribute(algID,"reference");
573 //std::cout<<"Got tmpRefID=\""<<tmpRefID<<"\""<<std::endl;
574 dqi::ConditionsSingleton &CS=dqi::ConditionsSingleton::getInstance();
575 //parses
576 std::vector<std::pair<std::string,std::string> > condPairs=CS.getConditionReferencePairs(std::move(tmpRefID));
577 std::stringstream newRefString;
578 // for each condition ...
579 for(size_t t=0;t<condPairs.size();t++){
580 bool refsuccess(false);
581 std::string refID=condPairs.at(t).second;
582 std::string cond=condPairs.at(t).first;
583 std::vector<std::string> refIDVec;
584 // the following allows us to accumulate objects as necessary
585 std::vector<std::vector<std::pair<std::string, std::shared_ptr<TObject>>>> objects;
586 std::string newRefId("");
587 bool isMultiRef(false);
588 std::vector<std::string> sourceMatches;
589 if (refID[0] == '[') {
590 std::string cleanedRefID = refID;
591 boost::algorithm::trim_if(cleanedRefID, boost::is_any_of("[] "));
592 isMultiRef = true;
593 boost::split(refIDVec, cleanedRefID, boost::is_any_of(","));
594 // toarray = new TObjArray();
595 // toarray->SetOwner(kTRUE);
596 } else {
597 refIDVec.push_back(refID);
598 }
599
600 // special case: not same_name, and is not a multiple reference
601 // in these cases, things have been copied into file already
602 std::string algRefName( m_refConfig.GetStringAttribute(refID,"name") );
603 std::string algRefInfo( m_refConfig.GetStringAttribute(refID,"info") );
604 std::string algRefFile( m_refConfig.GetStringAttribute(refID,"file") );
605 if (algRefName != "same_name" && !isMultiRef) {
606 newRefId=CS.getNewReferenceName(algRefFile+":/"+algRefName,true);
607
608 if(newRefId.empty()){
609 std::string algRefPath( m_refConfig.GetStringAttribute(refID,"path") );
610 std::cerr<<"Warning New reference id is empty for refId=\""
611 <<refID<<"\", cond=\""<<cond<<"\", assessorName=\""
612 <<assessorName<<"\", algRefName=\""
613 <<algRefName<<"\""<<std::endl;
614 std::cerr << "AlgRefPath=" << algRefPath << " AlgRefInfo=" << algRefInfo << std::endl;
615 } else {
616 refsuccess = true;
617 }
618 } else {
619 // is same_name, or a regex multiple reference
620 objects.resize(refIDVec.size());
621 std::string absAlgRefName, algRefPath, algRefInfo;
622 for (size_t iRefID = 0; iRefID < refIDVec.size(); ++iRefID) {
623 const auto& thisRefID = refIDVec[iRefID];
624 algRefName = m_refConfig.GetStringAttribute(thisRefID,"name");
625 algRefPath = m_refConfig.GetStringAttribute(thisRefID,"path");
626 algRefInfo = m_refConfig.GetStringAttribute(thisRefID,"info");
627 algRefFile = m_refConfig.GetStringAttribute(thisRefID,"file");
628 if (algRefInfo == "") {
629 std::cerr << "INFO: Reference " << thisRefID << " is defined without an \"info\" attribute. Consider adding one"
630 << std::endl;
631 }
632 absAlgRefName = "";
633 if( algRefPath != "" ) {
634 absAlgRefName += algRefPath;
635 absAlgRefName += "/";
636 }
637 if( algRefName == "same_name" ) {//sameName reference
638 algRefName = assessorName;
639 absAlgRefName += algRefName;
640 algRefFile = SplitReference( m_refConfig.GetStringAttribute(thisRefID,"location"), algRefFile);
641
642 if( algRefFile != "" ) {
643 std::shared_ptr<TFile> infile = GetROOTFile(algRefFile);
644 if ( ! infile.get() ) {
645 std::cerr << "HanConfig::AssessmentVistorBase::GetAlgorithmConfiguration: Reference file " << algRefFile << " not found" << std::endl;
646 continue;
647 }
648 std::vector<std::string> localMatches;
649 if (dqpar->GetIsRegex()) {
650 if (! sourceMatches.empty()) {
651 std::cerr << "same_name appears twice in a reference request???" << std::endl;
652 } else {
653 // change Python to Boost syntax for named captures
654 std::string regexPattern = boost::regex_replace(absAlgRefName, boost::regex("\\(\\?P=([^)]*)\\)"), "\\\\k<\\1>", boost::format_all);
655 boost::regex re(boost::replace_all_copy(regexPattern, "(?P", "(?"));
656 EnsureKeyCache(algRefFile);
657 for (const auto& iKey: m_keycache[algRefFile]) {
658 if (boost::regex_match(iKey, re)) {
659 sourceMatches.push_back(iKey);
660 TKey* key = getObjKey(infile.get(), iKey);
661 m_outfile->cd(); //we are writing to the / folder of file
662 objects[iRefID].emplace_back(iKey, key->ReadObj());
663 }
664 }
665 }
666 } else {
667 TKey* key = getObjKey( infile.get(), absAlgRefName );
668 if( key == 0 ) {
669 // no reference
670 continue;
671 }
672 m_outfile->cd(); //we are writing to the / folder of file
673 std::shared_ptr<TObject> q(key->ReadObj());
674 objects[iRefID].emplace_back(absAlgRefName, q);
675 }
676 }
677 } else {
678 absAlgRefName += algRefName;
679 algRefFile = SplitReference( m_refConfig.GetStringAttribute(thisRefID,"location"), algRefFile);
680
681 if( algRefFile != "" ) {
682 std::shared_ptr<TFile> infile = GetROOTFile(algRefFile);
683 if ( ! infile.get() ) {
684 std::cerr << "HanConfig::AssessmentVistorBase::GetAlgorithmConfiguration: Reference file " << algRefFile << " not found" << std::endl;
685 continue;
686 }
687
688 TKey* key = getObjKey( infile.get(), absAlgRefName );
689 if( key == 0 ) {
690 // no reference
691 std::cerr << "Couldn't find reference " << absAlgRefName << std::endl;
692 continue;
693 }
694 m_outfile->cd(); //we are writing to the / folder of file
695 std::shared_ptr<TObject> q(key->ReadObj());
696 TNamed* qn = dynamic_cast<TNamed*>(q.get());
697 if (isMultiRef && qn) {
698 std::string multirefname = thisRefID; // fallback
699 if (algRefInfo != "") {
700 multirefname = algRefInfo;
701 } else if (algRefFile != "") {
702 multirefname = algRefFile;
703 }
704 qn->SetName(multirefname.c_str());
705 }
706 objects[iRefID].emplace_back(absAlgRefName, q);
707 } else {
708 std::cerr << "No file specified for " << absAlgRefName << " ?" << std::endl;
709 }
710 }
711 }
712
713 std::shared_ptr<TObject> toWriteOut;
714 std::string algRefUniqueName;
715 std::string algRefSourceInfo = (algRefInfo != "" ? algRefInfo.c_str() : "Reference");
716
717 if (!isMultiRef) {
718 // is this a regex?
719 if (dqpar->GetIsRegex() && !objects[0].empty()) {
720 refsuccess = true;
721 TMap* tmapobj = new TMap();
722 tmapobj->SetOwnerKeyValue();
723 for (const auto& thisPair: objects[0]) {
724 std::unique_ptr<TObject> cobj(thisPair.second->Clone());
725 TNamed* hobj = dynamic_cast<TNamed*>(cobj.get());
726 if (hobj) {
727 hobj->SetName(refID.c_str());
728 }
729 algRefUniqueName = algRefFile+":/"+thisPair.first;
730 newRefId=CS.getNewReferenceName(algRefUniqueName,true);
731 if(newRefId.empty()){
732 newRefId=CS.getNewRefHistoName();
733 CS.setNewReferenceName(algRefUniqueName,newRefId);
734 m_refsourcedata->Add(new TObjString(newRefId.c_str()),
735 new TObjString(algRefFile.c_str()));
736 cobj->Write(newRefId.c_str(), 1);
737 }
738 m_outfile->cd();
739 std::string maprefstring(thisPair.first);
740 if (algRefPath != "") {
741 boost::replace_first(maprefstring, algRefPath + "/", "");
742 }
743 tmapobj->Add(new TObjString(maprefstring.c_str()),
744 new TObjString(newRefId.c_str()));
745 }
746 toWriteOut.reset(tmapobj);
747 algRefUniqueName = algRefFile+"_regex:/"+dqpar->GetUniqueName();
748 }
749 else {
750 algRefUniqueName = algRefFile+":/"+absAlgRefName;
751 if (! objects[0].empty()) {
752 refsuccess = true;
753 toWriteOut = objects[0][0].second;
754 }
755 }
756 } else { // is multiref
757 algRefUniqueName=cond+"_multiple:/"+absAlgRefName;
758 algRefSourceInfo="Multiple references";
759 // is this a regex?
760 if (dqpar->GetIsRegex()) {
761 // not implemented for now
762 } else {
763 TObjArray* toarray = new TObjArray();
764 toarray->SetOwner(true);
765 for (size_t iRef = 0; iRef < objects.size(); ++iRef) {
766 // check that object is actually valid (might be missing a reference)
767 if (! objects[iRef].empty()) {
768 toarray->Add(objects[iRef][0].second->Clone());
769 }
770 }
771 toWriteOut.reset(toarray);
772 refsuccess = true;
773 }
774 }
775
776 if (refsuccess && toWriteOut) {
777 // register top level object
778 newRefId=CS.getNewReferenceName(algRefUniqueName,true);
779 if(newRefId.empty()){
780 newRefId=CS.getNewRefHistoName();
781 CS.setNewReferenceName(algRefUniqueName,newRefId);
782 if (! isMultiRef) {
783 // ref to file
784 m_refsourcedata->Add(new TObjString(newRefId.c_str()),
785 new TObjString(algRefFile.c_str()));
786 // file to further info
787 if (! m_refsourcedata->FindObject(algRefFile.c_str())) {
788 m_refsourcedata->Add(new TObjString(algRefFile.c_str()),
789 new TObjString(algRefSourceInfo.c_str()));
790 }
791 } else {
792 // ref to "Multiple references"
793 m_refsourcedata->Add(new TObjString(newRefId.c_str()),
794 new TObjString(algRefSourceInfo.c_str()));
795 }
796 }
797 m_outfile->cd();
798 toWriteOut->Write(newRefId.c_str(), 1);
799 }
800 }
801
802 if (!newRefId.empty()) {
803 if(!cond.empty()){
804 newRefString<<cond<<":"<<newRefId<<";";
805 }else{
806 newRefString<<newRefId;
807 }
808 }
809 }
810 dqpar->SetAlgRefName((newRefString.str()));
811
812 }else {
813 std::string stringValue = m_algConfig.GetStringAttribute( algID, *i );
814 float numberValue;
815 std::istringstream parser( stringValue );
816 parser >> numberValue;
817 if ( ! parser ) {
818 HanConfigParMap algPar;
819 algPar.SetName( *i );
820 algPar.SetValue( stringValue );
821 dqpar->AddAlgStrPar( algPar );
822 } else {
823 HanConfigAlgPar algPar;
824 algPar.SetName( *i );
825 algPar.SetValue( numberValue );
826 dqpar->AddAlgPar( algPar );
827 }
828 }
829 }
830}
const boost::regex re(r_e)
static const Attributes_t empty
static ConditionsSingleton & getInstance()
void setNewReferenceName(const std::string &, const std::string &)
std::vector< std::pair< std::string, std::string > > getConditionReferencePairs(std::string inp) const
std::string getNewReferenceName(const std::string &, bool quiet=false) const
void EnsureKeyCache(std::string &fname)
std::string SplitReference(std::string refPath, const std::string &refName)
TKey * getObjKey(TDirectory *dir, const std::string &path)
Definition HanUtils.cxx:36
const std::string & algName(ID id)
Converts a JetAlgorithmType::ID into a string.

◆ GetROOTFile()

std::shared_ptr< TFile > dqi::HanConfig::AssessmentVisitorBase::GetROOTFile ( std::string & fname)
protectedinherited

Definition at line 463 of file HanConfig.cxx.

465{
466 auto it = m_filecache.find(fname);
467 if (it != end(m_filecache)) {
468 return it->second;
469 } else {
470 if (m_badPaths.find(fname) != m_badPaths.end()) {
471 return std::shared_ptr<TFile>(nullptr);
472 }
473 std::shared_ptr<TFile> thisptr(TFile::Open(fname.c_str()));
474 if (thisptr.get()) {
475 return ( m_filecache[fname] = std::move(thisptr) );
476 } else {
477 m_badPaths.insert(fname);
478 return thisptr;
479 }
480 }
481}
std::map< std::string, std::shared_ptr< TFile > > m_filecache
Definition HanConfig.h:115
std::unordered_set< std::string > m_badPaths
Definition HanConfig.h:117

◆ PopulateKeyCache()

void dqi::HanConfig::AssessmentVisitorBase::PopulateKeyCache ( const std::string & fname,
std::shared_ptr< TFile > & file )
protectedinherited

Definition at line 484 of file HanConfig.cxx.

485 {
486 auto& vec = m_keycache[fname];
487 dolsr(file.get(), vec);
488}
std::vector< size_t > vec
void dolsr(const TDirectory *dir, std::vector< std::string > &hists, const TDirectory *topdir=nullptr)
Definition HanUtils.cxx:80

◆ Visit()

void dqi::HanConfig::AssessmentVisitor::Visit ( const MiniConfigTreeNode * node)
virtual

Implements dqi::MiniConfigTreeNode::Visitor.

Definition at line 913 of file HanConfig.cxx.

915{
916 std::set<std::string> histAtt;
917 node->GetAttributeNames( histAtt );
918 std::set<std::string> defined;
919 std::string regID("");
920 std::string algID("");
921 std::set<std::string>::const_iterator histAttEnd = histAtt.end();
922 for( std::set<std::string>::const_iterator h = histAtt.begin(); h != histAttEnd; ++h ) {
923 const MiniConfigTreeNode* histNode = node->GetDaughter( *h );
924 if( histNode == 0 )
925 continue;
926
927 algID = histNode->GetAttribute("algorithm");
928 regID = histNode->GetAttribute("output");
929
930 if( algID == "" ) {
931 std::cerr << "No \"algorithm\" defined for " << histNode->GetPathName() << "\n";
932 continue;
933 }
934
935 if( regID == "" )
936 regID = "top_level";
937
938 std::string strNodeName(histNode->GetName());
939 std::string strHistName, strFullHistName;
940 std::string::size_type atsign = strNodeName.find('@');
941 if (atsign == std::string::npos) {
942 strHistName = std::move(strNodeName);
943 strFullHistName = histNode->GetPathName();
944 } else {
945 strHistName = strNodeName.substr(0, atsign);
946 strFullHistName = histNode->GetPathName();
947 strFullHistName.resize(strFullHistName.find('@'));
948 }
949
950 if( strHistName == "all_in_dir" )
951 continue;
952
953 if( defined.find(histNode->GetPathName()) != defined.end() )
954 continue;
955
956 HanConfigAssessor dqpar;
957 dqpar.SetName( histNode->GetPathName() );
958
959 dqpar.SetIsRegex(TestMiniNodeIsRegex(histNode));
960
961 if (histNode->GetAttribute("weight") != "") {
962 std::ostringstream err;
963 err << "Weight attribute not a floating point type for " << histNode->GetPathName() << "; setting to zero";
964 dqpar.SetWeight(AttribToFloat(histNode, "weight",
965 err.str()));
966 }
967
968 GetAlgorithmConfiguration( &dqpar, algID, strFullHistName );
969
970 std::set<std::string> histAtt2;
971 histNode->GetAttributeNames( histAtt2 );
972 std::set<std::string>::const_iterator histAttEnd2 = histAtt2.end();
973 for( std::set<std::string>::const_iterator h2 = histAtt2.begin(); h2 != histAttEnd2; ++h2 ) {
974 if (node->GetDaughter( *h2 )
975 || *h2 == "algorithm" || *h2 == "output" || *h2 == "reference"
976 || *h2 == "weight" || *h2 == "regex") {
977 continue;
978 }
979 HanConfigParMap parMap;
980 parMap.SetName(*h2); parMap.SetValue(histNode->GetAttribute(*h2));
981 dqpar.AddAnnotation(parMap);
982 }
983
984 // Add the histogram name
985 HanConfigParMap parMap;
986 parMap.SetName(inputNameStr); parMap.SetValue( strFullHistName );
987 dqpar.AddAnnotation(parMap);
988
989 HanConfigGroup* dqreg = m_root->GetNode( regID );
990 dqreg = (dqreg==0) ? m_root : dqreg;
991 if( dqreg != 0 ) {
992 dqreg->AddAssessor( dqpar );
993 }
994 defined.insert( std::move(strFullHistName) );
995 }
996
997 for( std::set<std::string>::const_iterator h = histAtt.begin(); h != histAttEnd; ++h ) {
998 const MiniConfigTreeNode* histNode = node->GetDaughter( *h );
999 if( histNode == 0 )
1000 continue;
1001
1002 algID = histNode->GetAttribute("algorithm");
1003 regID = histNode->GetAttribute("output");
1004
1005 if( algID == "" ) {
1006 std::cerr << "No \"algorithm\" defined for " << histNode->GetPathName() << "\n";
1007 continue;
1008 }
1009
1010 if( regID == "" )
1011 regID = "top_level";
1012
1013 std::string strNodeName(histNode->GetName());
1014 std::string strHistName, strFullHistName, extension;
1015 std::string::size_type atsign = strNodeName.find('@');
1016 if (atsign == std::string::npos) {
1017 strHistName = std::move(strNodeName);
1018 strFullHistName = histNode->GetPathName();
1019 extension = "";
1020 } else {
1021 strHistName = strNodeName.substr(0, atsign);
1022 extension = strNodeName.substr(atsign, std::string::npos);
1023 strFullHistName = histNode->GetPathName();
1024 strFullHistName.resize(strFullHistName.find('@'));
1025 }
1026
1027 if( strHistName == "all_in_dir" ) {
1028
1029 std::string regexflag(histNode->GetAttribute("regex"));
1030 if (histNode->GetAttribute("regex") != "") {
1031 std::cerr << "WARNING: all_in_dir and regex are incompatible; ignoring regex flag for " << histNode->GetPathName()
1032 << "/all_in_dir" << std::endl;
1033 }
1034
1035 std::string refID( histNode->GetAttribute("reference") );
1036 if( refID == "" ) {
1037 std::cerr << "WARNING: No \"reference\" defined for " << histNode->GetPathName() << "\n";
1038 continue;
1039 }
1040 std::string refFile( m_refConfig.GetStringAttribute(refID,"file") );
1041 if( refFile == "" ) {
1042 std::cerr << "WARNING: No \"file\" defined for " << histNode->GetPathName() << "\n";
1043 continue;
1044 }
1045
1046 std::string refPath( m_refConfig.GetStringAttribute(refID,"path") );
1047
1048 std::string objPath("");
1049 std::string absObjPath("");
1050
1051 refFile = SplitReference( m_refConfig.GetStringAttribute(std::move(refID),"location"), refFile);
1052 std::shared_ptr<TFile> infile( GetROOTFile(refFile) );
1053 TDirectory* basedir(0);
1054 TDirectory* dir(0);
1055 TKey* key;
1056
1057 if( refPath != "" ) {
1058 //std::cout << "Searching under path \"" << refPath << "\" for " << "\"" << histNode->GetPathName() << "\"\n";
1059 absObjPath += refPath;
1060 absObjPath += "/";
1061 std::string refPathForSearch = refPath;
1062 refPathForSearch += "/dummyName";
1063 basedir = ChangeInputDir( infile.get(), refPathForSearch );
1064 if( basedir == 0 ) {
1065 std::cerr << "INFO: Cannot find path \"" << refPath << "\" in reference file\n";
1066 continue;
1067 }
1068 }
1069
1070 if( basedir == 0 )
1071 basedir = infile.get();
1072
1073 std::string allPathName( histNode->GetPathName() );
1074 std::string::size_type i = allPathName.find_last_of('/');
1075 if( i != std::string::npos ) {
1076 objPath = std::string( allPathName, 0, i );
1077 objPath += "/";
1078 absObjPath += std::string( allPathName, 0, i );
1079 absObjPath += "/";
1080 }
1081
1082 dir = ChangeInputDir( basedir, histNode->GetPathName() );
1083 if( dir == 0 ) {
1084 std::cerr << "INFO: Cannot find path \"" << absObjPath << "\" in reference file\n";
1085 continue;
1086 }
1087
1088 TIter next( dir->GetListOfKeys() );
1089 std::string objName;
1090 std::string absObjName;
1091 // we might have multiple loops through 'all_in_dir', but each should
1092 // have unique objects
1093 std::set<std::string> localdefined;
1094 while( (key = dynamic_cast<TKey*>(next())) != 0 ) {
1095 TObject* tmpobj = key->ReadObj();
1096 TH1* tmph = dynamic_cast<TH1*>(tmpobj);
1097 TGraph* tmpg = dynamic_cast<TGraph*>(tmpobj);
1098 TEfficiency* tmpe = dynamic_cast<TEfficiency*>(tmpobj);
1099 if( tmph == 0 && tmpg == 0 && tmpe == 0 )
1100 continue;
1101
1102 objName = objPath;
1103 objName += std::string( tmpobj->GetName() );
1104 absObjName = absObjPath;
1105 absObjName += std::string( tmpobj->GetName() );
1106 delete tmpobj;
1107
1108 if( defined.find(objName) != defined.end() ||
1109 localdefined.find(objName) != localdefined.end() )
1110 continue;
1111
1112 TKey* test = getObjKey( infile.get(), absObjName );
1113 if( test == 0 )
1114 continue;
1115
1116 HanConfigAssessor dqpar;
1117 dqpar.SetName( objName + extension );
1118 GetAlgorithmConfiguration( &dqpar, algID, objName );
1119
1120 if (histNode->GetAttribute("weight") != "") {
1121 std::ostringstream err;
1122 err << "Weight attribute not a floating point type for " << objName << "; setting to zero";
1123 dqpar.SetWeight(AttribToFloat(histNode, "weight",
1124 err.str()));
1125 }
1126
1127 std::set<std::string> histAtt2;
1128 histNode->GetAttributeNames( histAtt2 );
1129 std::set<std::string>::const_iterator histAttEnd2 = histAtt2.end();
1130 for( std::set<std::string>::const_iterator h2 = histAtt2.begin(); h2 != histAttEnd2; ++h2 ) {
1131 if (node->GetDaughter( *h2 )
1132 || *h2 == "algorithm" || *h2 == "output" || *h2 == "reference"
1133 || *h2 == "weight" || *h2 == "regex") {
1134 continue;
1135 }
1136 HanConfigParMap parMap;
1137 parMap.SetName(*h2); parMap.SetValue(histNode->GetAttribute(*h2));
1138 dqpar.AddAnnotation(parMap);
1139 }
1140
1141 // Add the histogram name
1142 HanConfigParMap parMap;
1143 parMap.SetName(inputNameStr); parMap.SetValue( objName );
1144 dqpar.AddAnnotation(parMap);
1145
1146 HanConfigGroup* dqreg = m_root->GetNode( regID );
1147 dqreg = (dqreg==0) ? m_root : dqreg;
1148 if( dqreg != 0 ) {
1149 dqreg->AddAssessor( dqpar );
1150 }
1151 localdefined.insert( objName );
1152 }
1153
1154 continue;
1155 }
1156 }
1157}
void GetAlgorithmConfiguration(HanConfigAssessor *dqpar, const std::string &algID, const std::string &assessorName="")
static TDirectory * ChangeInputDir(TDirectory *dir, const std::string &path)
float AttribToFloat(const MiniConfigTreeNode *node, const std::string &attrib, const std::string &warningString, bool local=false)

Member Data Documentation

◆ m_algConfig

const MiniConfig& dqi::HanConfig::AssessmentVisitorBase::m_algConfig
protectedinherited

Definition at line 108 of file HanConfig.h.

◆ m_badPaths

std::unordered_set<std::string> dqi::HanConfig::AssessmentVisitorBase::m_badPaths
protectedinherited

Definition at line 117 of file HanConfig.h.

◆ m_directories

HanConfig::DirMap_t& dqi::HanConfig::AssessmentVisitorBase::m_directories
protectedinherited

Definition at line 112 of file HanConfig.h.

◆ m_filecache

std::map<std::string, std::shared_ptr<TFile> > dqi::HanConfig::AssessmentVisitorBase::m_filecache
protectedinherited

Definition at line 115 of file HanConfig.h.

◆ m_keycache

std::map<std::string, std::vector<std::string> > dqi::HanConfig::AssessmentVisitorBase::m_keycache
protectedinherited

Definition at line 120 of file HanConfig.h.

◆ m_outfile

TFile* dqi::HanConfig::AssessmentVisitorBase::m_outfile {}
protectedinherited

Definition at line 111 of file HanConfig.h.

111{};

◆ m_refConfig

const MiniConfig& dqi::HanConfig::AssessmentVisitorBase::m_refConfig
protectedinherited

Definition at line 110 of file HanConfig.h.

◆ m_refsourcedata

TMap* dqi::HanConfig::AssessmentVisitorBase::m_refsourcedata {}
protectedinherited

Definition at line 113 of file HanConfig.h.

113{};

◆ m_root

HanConfigGroup* dqi::HanConfig::AssessmentVisitorBase::m_root {}
protectedinherited

Definition at line 107 of file HanConfig.h.

107{};

◆ m_thrConfig

const MiniConfig& dqi::HanConfig::AssessmentVisitorBase::m_thrConfig
protectedinherited

Definition at line 109 of file HanConfig.h.


The documentation for this class was generated from the following files: