From 1e5b548d953130f64f98ad4298b8425a7017b3bf Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Thu, 7 Feb 2019 15:29:38 -0800 Subject: [PATCH 01/16] migrate helperclass infoswitch back over to header for python parsing --- Root/HelperClasses.cxx | 406 +-------------------------------- xAODAnaHelpers/HelperClasses.h | 402 ++++++++++++++++++++++++++++++-- 2 files changed, 387 insertions(+), 421 deletions(-) diff --git a/Root/HelperClasses.cxx b/Root/HelperClasses.cxx index 4f7833c253..bf3d6dee30 100644 --- a/Root/HelperClasses.cxx +++ b/Root/HelperClasses.cxx @@ -60,7 +60,7 @@ namespace HelperClasses{ /* parser for Tau BDT ID enum */ /* Apparently this won't be useful for non-Athena users... */ - + template <> EnumParser::EnumParser() { @@ -110,408 +110,4 @@ namespace HelperClasses{ return wps; } - /* - !!!!!!!!!!!!!WARNING!!!!!!!!!!!!! - If you change the string here, - please update the relevant - documentation in the header file. - !!!!!!!!!!!!!WARNING!!!!!!!!!!!!! - */ - - void EventInfoSwitch::initialize(){ - m_pileup = has_exact("pileup"); - m_pileupsys = has_exact("pileupsys"); - m_eventCleaning = has_exact("eventCleaning"); - m_bcidInfo = has_exact("bcidInfo"); - m_shapeEM = has_exact("shapeEM"); - m_shapeEMPFLOW = has_exact("shapeEMPFLOW"); - m_shapeLC = has_exact("shapeLC"); - m_truth = has_exact("truth"); - m_caloClus = has_exact("caloClusters"); - m_weightsSys = has_exact("weightsSys"); - } - - void TriggerInfoSwitch::initialize(){ - m_basic = has_exact("basic"); - m_menuKeys = has_exact("menuKeys"); - m_passTriggers = has_exact("passTriggers"); - m_passTrigBits = has_exact("passTrigBits"); - m_prescales = has_exact("prescales"); - m_prescalesLumi = has_exact("prescalesLumi"); - } - - void IParticleInfoSwitch::initialize(){ - m_kinematic = has_exact("kinematic"); - - m_numLeading = 0; - for(auto configDetail : m_configDetails) - { - if( configDetail.compare(0,8,"NLeading")==0) - { - m_numLeading = std::atoi( configDetail.substr(8, std::string::npos).c_str() ); - break; - } - } - - m_useTheS = has_exact("useTheS"); - } - - void MuonInfoSwitch::initialize(){ - m_trigger = has_exact("trigger"); - m_isolation = has_exact("isolation"); - m_isolationKinematics = has_exact("isolationKinematics"); - m_quality = has_exact("quality"); - m_trackparams = has_exact("trackparams"); - m_trackhitcont = has_exact("trackhitcont"); - m_effSF = has_exact("effSF"); - m_energyLoss = has_exact("energyLoss"); - m_promptlepton = has_exact("promptlepton"); - - // working points combinations for trigger corrections - std::string token; - std::string reco_keyword = "RECO_"; - std::string isol_keyword = "ISOL_"; - std::string trig_keyword = "TRIG_"; - - std::istringstream ss(m_configStr); - while ( std::getline(ss, token, ' ') ) { - auto reco_substr = token.find(reco_keyword); - auto isol_substr = token.find(isol_keyword); - auto trig_substr = token.find(trig_keyword); - if( reco_substr != std::string::npos ){ - m_recoWPs.push_back(token.substr(5)); - } else if(isol_substr != std::string::npos){ - if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); - else m_isolWPs.push_back(token.substr(5)); - } else if(trig_substr != std::string::npos){ - m_trigWPs.push_back(token.substr(5)); - } - } - - m_recoEff_sysNames = has_exact("recoEff_sysNames"); - m_isoEff_sysNames = has_exact("isoEff_sysNames"); - m_trigEff_sysNames = has_exact("trigEff_sysNames"); - m_ttvaEff_sysNames = has_exact("ttvaEff_sysNames"); - - } - - void ElectronInfoSwitch::initialize(){ - m_trigger = has_exact("trigger"); - m_isolation = has_exact("isolation"); - m_isolationKinematics = has_exact("isolationKinematics"); - m_quality = has_exact("quality"); - if (m_quality) { - std::cerr << "WARNING! The 'quality' option is deprecated in ElectronInfoSwitch. Use 'PID' instead." << std::endl; - } - m_PID = has_exact("PID"); - m_recoparams = has_exact("recoparams"); - m_trackparams = has_exact("trackparams"); - m_trackhitcont = has_exact("trackhitcont"); - m_effSF = has_exact("effSF"); - m_promptlepton = has_exact("promptlepton"); - // working points for scale-factors - - // working points combinations for trigger corrections - std::string token; - std::string pid_keyword = "PID_"; - std::string pidsf_keyword = "PIDSF_"; - std::string isol_keyword = "ISOL_"; - std::string trig_keyword = "TRIG_"; - - std::istringstream ss(m_configStr); - while ( std::getline(ss, token, ' ') ) { - auto pid_substr = token.find(pid_keyword); - auto pidsf_substr = token.find(pidsf_keyword); - auto isol_substr = token.find(isol_keyword); - auto trig_substr = token.find(trig_keyword); - if( pid_substr != std::string::npos ){ - m_PIDWPs.push_back(token.substr(4)); - } else if( pidsf_substr != std::string::npos ){ - m_PIDSFWPs.push_back(token.substr(6)); - } else if(isol_substr != std::string::npos){ - if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); - else m_isolWPs.push_back(token.substr(5)); - } else if(trig_substr != std::string::npos){ - m_trigWPs.push_back(token.substr(5)); - } - } - } - - void PhotonInfoSwitch::initialize(){ - m_isolation = has_exact("isolation"); - m_PID = has_exact("PID"); - m_purity = has_exact("purity"); - m_effSF = has_exact("effSF"); - m_trigger = has_exact("trigger"); - } - - void ClusterInfoSwitch::initialize(){ - } - - void JetInfoSwitch::initialize(){ - std::string tmpConfigStr; // temporary config string used to extract multiple values - - m_trigger = has_exact("trigger"); - m_substructure = has_exact("substructure"); - m_bosonCount = has_exact("bosonCount"); - m_VTags = has_exact("VTags"); - m_rapidity = has_exact("rapidity"); - m_clean = has_exact("clean"); - m_cleanLight = has_exact("cleanLight"); - m_cleanNoSumm = has_exact("cleanNoSumm"); - m_energy = has_exact("energy"); - m_energyLight = has_exact("energyLight"); - m_scales = has_exact("scales"); - m_constscaleEta = has_exact("constscaleEta"); - m_detectorEta = has_exact("detectorEta"); - m_resolution = has_exact("resolution"); - m_truth = has_exact("truth"); - m_truthDetails = has_exact("truth_details"); - m_layer = has_exact("layer"); - m_trackPV = has_exact("trackPV"); - m_trackAll = has_exact("trackAll"); - m_jvt = has_exact("JVT"); - m_allTrack = has_exact("allTrack"); - m_allTrackPVSel = has_exact("allTrackPVSel"); - m_allTrackDetail= has_exact("allTrackDetail"); - if( m_allTrackDetail ) { - m_allTrackPVSel = m_allTrackPVSel || has_exact("allTrackDetailPVSel") ; - } - m_constituent = has_exact("constituent"); - m_constituentAll = has_exact("constituentAll"); - m_flavorTag = has_exact("flavorTag"); - m_flavorTagHLT = has_exact("flavorTagHLT"); - m_btag_jettrk = has_exact("btag_jettrk"); - m_jetFitterDetails = has_exact("jetFitterDetails"); - m_svDetails = has_exact("svDetails"); - m_ipDetails = has_exact("ipDetails"); - - if(has_match("tracksInJet")){ - m_tracksInJet = true; - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("tracksInJet_") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove tracksInJet_ to just leave the tack name - input.erase(0,12); - - m_trackName = input; - }else{ - m_tracksInJet = false; - m_trackName = ""; - } - - - m_trackJetNames.clear(); - if(has_match("trackJetName")){ - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("trackJetName") ); - if(input.find(" ")!=std::string::npos) input.erase( input.find(" "), std::string::npos ); - input.erase( 0, 13 ); - - std::stringstream ss(input); - std::string s; - while(std::getline(ss, s, '_')) - m_trackJetNames.push_back(s); - } - - - m_hltVtxComp = has_exact("hltVtxComp"); - m_onlineBS = has_exact("onlineBS"); - m_onlineBSTool = has_exact("onlineBSTool"); - - - m_charge = has_exact("charge"); - m_etaPhiMap = has_exact("etaPhiMap"); - m_byAverageMu = has_exact("byAverageMu"); - m_byEta = has_exact("byEta"); - m_vsLumiBlock = has_exact("vsLumiBlock"); - m_vsActualMu = has_exact("vsActualMu"); - m_lumiB_runN = has_exact("lumiB_runN"); - - m_sfJVTName = get_working_point("sfJVT"); - m_sffJVTName = get_working_point("sffJVT"); - - m_sfFTagFix.clear(); - if( has_match( "sfFTagFix" ) ) { - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("sfFTagFix") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove fTagSFFix to just leave the numbers - input.erase(0,9); - // two by two take the characters and push back an int into this vector - std::vector values; - int size( input.size()/2 ); - int count(0); - while( count < size ) { - std::string number = input.substr(0,2); - m_sfFTagFix.push_back( atoi( number.c_str() ) ); - input.erase(0,2); - count++; - } - } // sfFTagFix - m_sfFTagFlt.clear(); - if( has_match( "sfFTagFlt" ) ) { - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("sfFTagFlt") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove fTagSFFlt to just leave the numbers - input.erase(0,9); - // two by two take the characters and push back an int into this vector - std::vector values; - int size( input.size()/2 ); - int count(0); - while( count < size ) { - std::string number = input.substr(0,2); - m_sfFTagFlt.push_back( atoi( number.c_str() ) ); - input.erase(0,2); - count++; - } - } // sfFTagFlt - m_sfFTagHyb.clear(); - if( has_match( "sfFTagHyb" ) ) { - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("sfFTagHyb") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove fTagSFHyb to just leave the numbers - input.erase(0,9); - // two by two take the characters and push back an int into this vector - std::vector values; - int size( input.size()/2 ); - int count(0); - while( count < size ) { - std::string number = input.substr(0,2); - m_sfFTagHyb.push_back( atoi( number.c_str() ) ); - input.erase(0,2); - count++; - } - } // sfFTagHyb - - m_jetBTag.clear(); - tmpConfigStr=std::string(m_configStr); - while( tmpConfigStr.find("jetBTag") != std::string::npos ) { // jetBTag - // erase everything before the interesting string - tmpConfigStr.erase( 0, tmpConfigStr.find("jetBTag") ); - // extract interesting string - std::size_t pos =tmpConfigStr.find(" "); - std::string input=tmpConfigStr.substr(0,pos); - // remove interesting string from configStr being processed - tmpConfigStr.erase(0,pos); - // extracted the tagger and numbers - std::stringstream ss(input); - std::string s; - uint idx=0; - std::string tagger; - std::string type; - std::vector wps; - while(std::getline(ss, s, '_')) { - switch(idx) - { - case 0: // jetBTag - break; - case 1: // tagger - tagger=s; - break; - case 2: // efficiency type - type=s; - break; - case 3: // list of efficiency working points - uint size( s.size()/2 ); - for(uint i=0;i>(); - for(auto wp : wps) - m_jetBTag[tagger].push_back(std::make_pair(type,wp)); - } // jetBTag - - m_area = has_exact("area"); - m_JVC = has_exact("JVC"); - } - - void TruthInfoSwitch::initialize(){ - m_type = has_exact("type"); - m_bVtx = has_exact("bVtx"); - m_parents = has_exact("parents"); - m_children = has_exact("children"); - } - - void TrackInfoSwitch::initialize(){ - m_kinematic = has_exact("kinematic"); - m_fitpars = has_exact("fitpars"); - m_numbers = has_exact("numbers"); - m_vertex = has_exact("vertex"); - m_useTheS = has_exact("useTheS"); - } - - void TauInfoSwitch::initialize(){ - m_trigger = has_exact("trigger"); - m_JetID = has_exact("JetID"); - m_EleVeto = has_exact("EleVeto"); - m_trackAll = has_exact("trackAll"); - m_xahTauJetMatching = has_exact("xahTauJetMatching"); - m_effSF = has_exact("effSF"); - m_trackparams = has_exact("trackparams"); - m_trackhitcont = has_exact("trackhitcont"); - - // working points combinations for trigger corrections - std::string token; - std::string taueff_keyword = "TAUEFF_"; - std::string trig_keyword = "TRIG_"; - - std::istringstream ss(m_configStr); - while ( std::getline(ss, token, ' ') ) { - auto taueff_substr = token.find(taueff_keyword); - auto trig_substr = token.find(trig_keyword); - if( taueff_substr != std::string::npos ){ - m_tauEffWPs.push_back(token.substr(7)); - } else if(trig_substr != std::string::npos){ - m_trigWPs.push_back(token.substr(5)); - } - } - - } - - void METInfoSwitch::initialize(){ - m_metClus = has_exact("metClus"); - m_metTrk = has_exact("metTrk"); - m_sigClus = has_exact("sigClus") || has_exact("all"); - m_sigTrk = has_exact("sigTrk") || has_exact("all"); - m_sigResolutionClus = has_exact("sigResolutionClus") || has_exact("all"); - m_sigResolutionTrk = has_exact("sigResolutionTrk") || has_exact("all"); - m_refEle = has_exact("refEle") || has_exact("all"); - m_refGamma = has_exact("refGamma") || has_exact("all"); - m_refTau = has_exact("refTau") || has_exact("all"); - m_refMuons = has_exact("refMuons") || has_exact("all"); - m_refJet = has_exact("refJet") || has_exact("all"); - m_refJetTrk = has_exact("refJetTrk"); // take this one *only* if requested by user explicitly - m_softClus = has_exact("softClus") || has_exact("all"); - m_softTrk = has_exact("softTrk") || has_exact("all"); - } - } // close namespace HelperClasses diff --git a/xAODAnaHelpers/HelperClasses.h b/xAODAnaHelpers/HelperClasses.h index 09770289a5..726a162761 100644 --- a/xAODAnaHelpers/HelperClasses.h +++ b/xAODAnaHelpers/HelperClasses.h @@ -163,7 +163,18 @@ namespace HelperClasses { bool m_weightsSys; EventInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(); + void initialize(){ + m_pileup = has_exact("pileup"); + m_pileupsys = has_exact("pileupsys"); + m_eventCleaning = has_exact("eventCleaning"); + m_bcidInfo = has_exact("bcidInfo"); + m_shapeEM = has_exact("shapeEM"); + m_shapeEMPFLOW = has_exact("shapeEMPFLOW"); + m_shapeLC = has_exact("shapeLC"); + m_truth = has_exact("truth"); + m_caloClus = has_exact("caloClusters"); + m_weightsSys = has_exact("weightsSys"); + }; }; /** @@ -196,7 +207,14 @@ namespace HelperClasses { bool m_prescalesLumi; TriggerInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(); + void initialize(){ + m_basic = has_exact("basic"); + m_menuKeys = has_exact("menuKeys"); + m_passTriggers = has_exact("passTriggers"); + m_passTrigBits = has_exact("passTrigBits"); + m_prescales = has_exact("prescales"); + m_prescalesLumi = has_exact("prescalesLumi"); + }; }; /** @@ -231,7 +249,21 @@ namespace HelperClasses { IParticleInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); } virtual ~IParticleInfoSwitch() {} protected: - virtual void initialize(); + virtual void initialize(){ + m_kinematic = has_exact("kinematic"); + + m_numLeading = 0; + for(auto configDetail : m_configDetails) + { + if( configDetail.compare(0,8,"NLeading")==0) + { + m_numLeading = std::atoi( configDetail.substr(8, std::string::npos).c_str() ); + break; + } + } + + m_useTheS = has_exact("useTheS"); + }; }; /** @@ -298,7 +330,43 @@ namespace HelperClasses { MuonInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~MuonInfoSwitch() {} protected: - virtual void initialize(); + void initialize(){ + m_trigger = has_exact("trigger"); + m_isolation = has_exact("isolation"); + m_isolationKinematics = has_exact("isolationKinematics"); + m_quality = has_exact("quality"); + m_trackparams = has_exact("trackparams"); + m_trackhitcont = has_exact("trackhitcont"); + m_effSF = has_exact("effSF"); + m_energyLoss = has_exact("energyLoss"); + m_promptlepton = has_exact("promptlepton"); + + // working points combinations for trigger corrections + std::string token; + std::string reco_keyword = "RECO_"; + std::string isol_keyword = "ISOL_"; + std::string trig_keyword = "TRIG_"; + + std::istringstream ss(m_configStr); + while ( std::getline(ss, token, ' ') ) { + auto reco_substr = token.find(reco_keyword); + auto isol_substr = token.find(isol_keyword); + auto trig_substr = token.find(trig_keyword); + if( reco_substr != std::string::npos ){ + m_recoWPs.push_back(token.substr(5)); + } else if(isol_substr != std::string::npos){ + if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); + else m_isolWPs.push_back(token.substr(5)); + } else if(trig_substr != std::string::npos){ + m_trigWPs.push_back(token.substr(5)); + } + } + + m_recoEff_sysNames = has_exact("recoEff_sysNames"); + m_isoEff_sysNames = has_exact("isoEff_sysNames"); + m_trigEff_sysNames = has_exact("trigEff_sysNames"); + m_ttvaEff_sysNames = has_exact("ttvaEff_sysNames"); + }; }; /** @@ -358,7 +426,47 @@ namespace HelperClasses { ElectronInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~ElectronInfoSwitch() {} protected: - virtual void initialize(); + void initialize(){ + m_trigger = has_exact("trigger"); + m_isolation = has_exact("isolation"); + m_isolationKinematics = has_exact("isolationKinematics"); + m_quality = has_exact("quality"); + if (m_quality) { + std::cerr << "WARNING! The 'quality' option is deprecated in ElectronInfoSwitch. Use 'PID' instead." << std::endl; + } + m_PID = has_exact("PID"); + m_recoparams = has_exact("recoparams"); + m_trackparams = has_exact("trackparams"); + m_trackhitcont = has_exact("trackhitcont"); + m_effSF = has_exact("effSF"); + m_promptlepton = has_exact("promptlepton"); + // working points for scale-factors + + // working points combinations for trigger corrections + std::string token; + std::string pid_keyword = "PID_"; + std::string pidsf_keyword = "PIDSF_"; + std::string isol_keyword = "ISOL_"; + std::string trig_keyword = "TRIG_"; + + std::istringstream ss(m_configStr); + while ( std::getline(ss, token, ' ') ) { + auto pid_substr = token.find(pid_keyword); + auto pidsf_substr = token.find(pidsf_keyword); + auto isol_substr = token.find(isol_keyword); + auto trig_substr = token.find(trig_keyword); + if( pid_substr != std::string::npos ){ + m_PIDWPs.push_back(token.substr(4)); + } else if( pidsf_substr != std::string::npos ){ + m_PIDSFWPs.push_back(token.substr(6)); + } else if(isol_substr != std::string::npos){ + if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); + else m_isolWPs.push_back(token.substr(5)); + } else if(trig_substr != std::string::npos){ + m_trigWPs.push_back(token.substr(5)); + } + } + }; }; /** @@ -387,7 +495,13 @@ namespace HelperClasses { PhotonInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); } virtual ~PhotonInfoSwitch() {} protected: - virtual void initialize(); + void initialize(){ + m_isolation = has_exact("isolation"); + m_PID = has_exact("PID"); + m_purity = has_exact("purity"); + m_effSF = has_exact("effSF"); + m_trigger = has_exact("trigger"); + }; }; class ClusterInfoSwitch : public IParticleInfoSwitch { @@ -395,7 +509,7 @@ namespace HelperClasses { ClusterInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); } virtual ~ClusterInfoSwitch() {} protected: - virtual void initialize(); + void initialize(){}; }; /** @@ -534,7 +648,211 @@ namespace HelperClasses { JetInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~JetInfoSwitch() {} protected: - virtual void initialize(); + void initialize(){ + std::string tmpConfigStr; // temporary config string used to extract multiple values + + m_trigger = has_exact("trigger"); + m_substructure = has_exact("substructure"); + m_bosonCount = has_exact("bosonCount"); + m_VTags = has_exact("VTags"); + m_rapidity = has_exact("rapidity"); + m_clean = has_exact("clean"); + m_cleanLight = has_exact("cleanLight"); + m_cleanNoSumm = has_exact("cleanNoSumm"); + m_energy = has_exact("energy"); + m_energyLight = has_exact("energyLight"); + m_scales = has_exact("scales"); + m_constscaleEta = has_exact("constscaleEta"); + m_detectorEta = has_exact("detectorEta"); + m_resolution = has_exact("resolution"); + m_truth = has_exact("truth"); + m_truthDetails = has_exact("truth_details"); + m_layer = has_exact("layer"); + m_trackPV = has_exact("trackPV"); + m_trackAll = has_exact("trackAll"); + m_jvt = has_exact("JVT"); + m_allTrack = has_exact("allTrack"); + m_allTrackPVSel = has_exact("allTrackPVSel"); + m_allTrackDetail= has_exact("allTrackDetail"); + if( m_allTrackDetail ) { + m_allTrackPVSel = m_allTrackPVSel || has_exact("allTrackDetailPVSel") ; + } + m_constituent = has_exact("constituent"); + m_constituentAll = has_exact("constituentAll"); + m_flavorTag = has_exact("flavorTag"); + m_flavorTagHLT = has_exact("flavorTagHLT"); + m_btag_jettrk = has_exact("btag_jettrk"); + m_jetFitterDetails = has_exact("jetFitterDetails"); + m_svDetails = has_exact("svDetails"); + m_ipDetails = has_exact("ipDetails"); + + if(has_match("tracksInJet")){ + m_tracksInJet = true; + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("tracksInJet_") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove tracksInJet_ to just leave the tack name + input.erase(0,12); + + m_trackName = input; + }else{ + m_tracksInJet = false; + m_trackName = ""; + } + + + m_trackJetNames.clear(); + if(has_match("trackJetName")){ + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("trackJetName") ); + if(input.find(" ")!=std::string::npos) input.erase( input.find(" "), std::string::npos ); + input.erase( 0, 13 ); + + std::stringstream ss(input); + std::string s; + while(std::getline(ss, s, '_')) + m_trackJetNames.push_back(s); + } + + + m_hltVtxComp = has_exact("hltVtxComp"); + m_onlineBS = has_exact("onlineBS"); + m_onlineBSTool = has_exact("onlineBSTool"); + + + m_charge = has_exact("charge"); + m_etaPhiMap = has_exact("etaPhiMap"); + m_byAverageMu = has_exact("byAverageMu"); + m_byEta = has_exact("byEta"); + m_vsLumiBlock = has_exact("vsLumiBlock"); + m_vsActualMu = has_exact("vsActualMu"); + m_lumiB_runN = has_exact("lumiB_runN"); + + m_sfJVTName = get_working_point("sfJVT"); + m_sffJVTName = get_working_point("sffJVT"); + + m_sfFTagFix.clear(); + if( has_match( "sfFTagFix" ) ) { + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("sfFTagFix") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove fTagSFFix to just leave the numbers + input.erase(0,9); + // two by two take the characters and push back an int into this vector + std::vector values; + int size( input.size()/2 ); + int count(0); + while( count < size ) { + std::string number = input.substr(0,2); + m_sfFTagFix.push_back( atoi( number.c_str() ) ); + input.erase(0,2); + count++; + } + } // sfFTagFix + m_sfFTagFlt.clear(); + if( has_match( "sfFTagFlt" ) ) { + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("sfFTagFlt") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove fTagSFFlt to just leave the numbers + input.erase(0,9); + // two by two take the characters and push back an int into this vector + std::vector values; + int size( input.size()/2 ); + int count(0); + while( count < size ) { + std::string number = input.substr(0,2); + m_sfFTagFlt.push_back( atoi( number.c_str() ) ); + input.erase(0,2); + count++; + } + } // sfFTagFlt + m_sfFTagHyb.clear(); + if( has_match( "sfFTagHyb" ) ) { + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("sfFTagHyb") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove fTagSFHyb to just leave the numbers + input.erase(0,9); + // two by two take the characters and push back an int into this vector + std::vector values; + int size( input.size()/2 ); + int count(0); + while( count < size ) { + std::string number = input.substr(0,2); + m_sfFTagHyb.push_back( atoi( number.c_str() ) ); + input.erase(0,2); + count++; + } + } // sfFTagHyb + + m_jetBTag.clear(); + tmpConfigStr=std::string(m_configStr); + while( tmpConfigStr.find("jetBTag") != std::string::npos ) { // jetBTag + // erase everything before the interesting string + tmpConfigStr.erase( 0, tmpConfigStr.find("jetBTag") ); + // extract interesting string + std::size_t pos =tmpConfigStr.find(" "); + std::string input=tmpConfigStr.substr(0,pos); + // remove interesting string from configStr being processed + tmpConfigStr.erase(0,pos); + // extracted the tagger and numbers + std::stringstream ss(input); + std::string s; + uint idx=0; + std::string tagger; + std::string type; + std::vector wps; + while(std::getline(ss, s, '_')) { + switch(idx) + { + case 0: // jetBTag + break; + case 1: // tagger + tagger=s; + break; + case 2: // efficiency type + type=s; + break; + case 3: // list of efficiency working points + uint size( s.size()/2 ); + for(uint i=0;i>(); + for(auto wp : wps) + m_jetBTag[tagger].push_back(std::make_pair(type,wp)); + } // jetBTag + + m_area = has_exact("area"); + m_JVC = has_exact("JVC"); + }; }; /** @@ -562,7 +880,12 @@ namespace HelperClasses { bool m_children; TruthInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; protected: - void initialize(); + void initialize(){ + m_type = has_exact("type"); + m_bVtx = has_exact("bVtx"); + m_parents = has_exact("parents"); + m_children = has_exact("children"); + }; }; /** @@ -591,7 +914,13 @@ namespace HelperClasses { bool m_useTheS; TrackInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(); + void initialize(){ + m_kinematic = has_exact("kinematic"); + m_fitpars = has_exact("fitpars"); + m_numbers = has_exact("numbers"); + m_vertex = has_exact("vertex"); + m_useTheS = has_exact("useTheS"); + }; }; /** @@ -615,8 +944,8 @@ namespace HelperClasses { .. note:: - ``identification`` and ``effSF`` switches do not enable any additional output by themselves. - They require additional working point pattern using ``TAUEFF_XYZ`` for combined scale factors, and ``TRIG_XYZ`` + ``identification`` and ``effSF`` switches do not enable any additional output by themselves. + They require additional working point pattern using ``TAUEFF_XYZ`` for combined scale factors, and ``TRIG_XYZ`` for trigger scale factors. ``XYZ`` in the pattern should be replaced using the working point name, for example:: m_configStr = "... TAUEFF_EleOLRElectronEleBDTLoose_TauIDMedium ... TRIG_EleOLRElectronEleBDTMedium_TauIDLoose_TrigMyTriggerMenu" @@ -632,18 +961,44 @@ namespace HelperClasses { bool m_JetID; bool m_EleVeto; bool m_xahTauJetMatching; - bool m_trackAll; + bool m_trackAll; bool m_trackparams; bool m_trackhitcont; bool m_effSF; - + std::vector< std::string > m_tauEffWPs; std::vector< std::string > m_trigWPs; TauInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~TauInfoSwitch() { } protected: - virtual void initialize(); + void initialize(){ + m_trigger = has_exact("trigger"); + m_JetID = has_exact("JetID"); + m_EleVeto = has_exact("EleVeto"); + m_trackAll = has_exact("trackAll"); + m_xahTauJetMatching = has_exact("xahTauJetMatching"); + m_effSF = has_exact("effSF"); + m_trackparams = has_exact("trackparams"); + m_trackhitcont = has_exact("trackhitcont"); + + // working points combinations for trigger corrections + std::string token; + std::string taueff_keyword = "TAUEFF_"; + std::string trig_keyword = "TRIG_"; + + std::istringstream ss(m_configStr); + while ( std::getline(ss, token, ' ') ) { + auto taueff_substr = token.find(taueff_keyword); + auto trig_substr = token.find(trig_keyword); + if( taueff_substr != std::string::npos ){ + m_tauEffWPs.push_back(token.substr(7)); + } else if(trig_substr != std::string::npos){ + m_trigWPs.push_back(token.substr(5)); + } + } + + }; }; /** @@ -692,7 +1047,22 @@ namespace HelperClasses { bool m_softTrk; METInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(); + void initialize(){ + m_metClus = has_exact("metClus"); + m_metTrk = has_exact("metTrk"); + m_sigClus = has_exact("sigClus") || has_exact("all"); + m_sigTrk = has_exact("sigTrk") || has_exact("all"); + m_sigResolutionClus = has_exact("sigResolutionClus") || has_exact("all"); + m_sigResolutionTrk = has_exact("sigResolutionTrk") || has_exact("all"); + m_refEle = has_exact("refEle") || has_exact("all"); + m_refGamma = has_exact("refGamma") || has_exact("all"); + m_refTau = has_exact("refTau") || has_exact("all"); + m_refMuons = has_exact("refMuons") || has_exact("all"); + m_refJet = has_exact("refJet") || has_exact("all"); + m_refJetTrk = has_exact("refJetTrk"); // take this one *only* if requested by user explicitly + m_softClus = has_exact("softClus") || has_exact("all"); + m_softTrk = has_exact("softTrk") || has_exact("all"); + }; }; } // close namespace HelperClasses From f67a7a8d04dbc36b60bf8efc70da54be6c696938 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Thu, 7 Feb 2019 16:33:26 -0800 Subject: [PATCH 02/16] add first commit of a script that will dump the infoswitch information for us --- test.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 test.py diff --git a/test.py b/test.py new file mode 100644 index 0000000000..82715a56a0 --- /dev/null +++ b/test.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +""" Usage: call with +""" + +import sys +import clang.cindex +from itertools import izip +import json + +def infoswitch_parser(node, index=0): + tokens = [] + for token in node.get_tokens(): + if token.spelling == node.spelling: continue + if token.kind in [clang.cindex.TokenKind.COMMENT, clang.cindex.TokenKind.KEYWORD]: continue + if token.spelling in ['(', ')', '=', '{', '}']: continue + # what's the token? + spelling = token.spelling + # chunks of 3 (variable, matcing type, string to match) + if token.kind == clang.cindex.TokenKind.PUNCTUATION: + if token.spelling not in ';': continue + else: + match_type = None + if 'has_exact' in tokens: + match_type = 'has_exact' + elif 'get_working_point' in tokens: + match_type = 'get_working_point' + if match_type: + match_index = tokens.index(match_type) + identifier = tokens[match_index-1] + rest = iter(tokens[match_index:]) + for match_type, match_string in izip(rest,rest): + yield [identifier, match_type, match_string] + tokens = [] + else: + # strip quotes + if token.kind == clang.cindex.TokenKind.LITERAL: spelling = spelling.replace('"','').replace("'",'') + tokens.append(spelling) + yield [] + +def find_inheritance(node): + if node.kind != clang.cindex.CursorKind.CLASS_DECL: return + for c in node.get_children(): + if c.kind != clang.cindex.CursorKind.CXX_BASE_SPECIFIER: continue + children = list(c.get_children()) + if children[0].get_definition(): + return children[0].get_definition().spelling + +def find_infoswitches(infoswitches, node): + if node.spelling == 'initialize' and node.kind == clang.cindex.CursorKind.CXX_METHOD: + infoswitches[node.semantic_parent.spelling] = [token for token in infoswitch_parser(node) if token] + for child in node.get_children(): + find_infoswitches(infoswitches, child) + +clang.cindex.Config.set_library_path('/usr/local/opt/llvm/lib') +index = clang.cindex.Index.create() +tu = index.parse(sys.argv[1], args=['-x', 'c++']) +print 'Translation unit:', tu.spelling + +infoswitches = {} +find_infoswitches(infoswitches, tu.cursor) + +for infoswitch, tokens in infoswitches.iteritems(): + print 'Tokens for {}'.format(infoswitch) + for var, match_type, match_string in tokens: + print ' -',var, match_type, match_string + +print json.dumps(infoswitches, sort_keys=True, indent=4) From e5909eb0547f4e12e5b1ab79b561a25cc13ba65e Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 07:44:38 -0800 Subject: [PATCH 03/16] update test.py to python3 --- test.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test.py b/test.py index 82715a56a0..1dc9a67c3d 100644 --- a/test.py +++ b/test.py @@ -1,10 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Usage: call with """ import sys import clang.cindex -from itertools import izip import json def infoswitch_parser(node, index=0): @@ -28,7 +27,7 @@ def infoswitch_parser(node, index=0): match_index = tokens.index(match_type) identifier = tokens[match_index-1] rest = iter(tokens[match_index:]) - for match_type, match_string in izip(rest,rest): + for match_type, match_string in zip(rest,rest): yield [identifier, match_type, match_string] tokens = [] else: @@ -51,17 +50,17 @@ def find_infoswitches(infoswitches, node): for child in node.get_children(): find_infoswitches(infoswitches, child) -clang.cindex.Config.set_library_path('/usr/local/opt/llvm/lib') +clang.cindex.Config.set_library_path('/usr/lib') index = clang.cindex.Index.create() tu = index.parse(sys.argv[1], args=['-x', 'c++']) -print 'Translation unit:', tu.spelling +print('Translation unit:', tu.spelling) infoswitches = {} find_infoswitches(infoswitches, tu.cursor) -for infoswitch, tokens in infoswitches.iteritems(): - print 'Tokens for {}'.format(infoswitch) +for infoswitch, tokens in infoswitches.items(): + print('Tokens for {}'.format(infoswitch)) for var, match_type, match_string in tokens: - print ' -',var, match_type, match_string + print(' -',var, match_type, match_string) -print json.dumps(infoswitches, sort_keys=True, indent=4) +json.dump(infoswitches, file('data/xAH_infoswitches.json', 'w+'), sort_keys=True, indent=4) From d6178020254d0e26fd33af88b15f50f0e52a8ffb Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 07:48:54 -0800 Subject: [PATCH 04/16] add infoswitches json --- data/xAH_infoswitches.json | 695 +++++++++++++++++++++++++++++++++++++ 1 file changed, 695 insertions(+) create mode 100644 data/xAH_infoswitches.json diff --git a/data/xAH_infoswitches.json b/data/xAH_infoswitches.json new file mode 100644 index 0000000000..16991a8e87 --- /dev/null +++ b/data/xAH_infoswitches.json @@ -0,0 +1,695 @@ +{ + "ClusterInfoSwitch": [], + "ElectronInfoSwitch": [ + [ + "m_trigger", + "has_exact", + "trigger" + ], + [ + "m_isolation", + "has_exact", + "isolation" + ], + [ + "m_isolationKinematics", + "has_exact", + "isolationKinematics" + ], + [ + "m_quality", + "has_exact", + "quality" + ], + [ + "m_PID", + "has_exact", + "PID" + ], + [ + "m_recoparams", + "has_exact", + "recoparams" + ], + [ + "m_trackparams", + "has_exact", + "trackparams" + ], + [ + "m_trackhitcont", + "has_exact", + "trackhitcont" + ], + [ + "m_effSF", + "has_exact", + "effSF" + ], + [ + "m_promptlepton", + "has_exact", + "promptlepton" + ] + ], + "EventInfoSwitch": [ + [ + "m_pileup", + "has_exact", + "pileup" + ], + [ + "m_pileupsys", + "has_exact", + "pileupsys" + ], + [ + "m_eventCleaning", + "has_exact", + "eventCleaning" + ], + [ + "m_bcidInfo", + "has_exact", + "bcidInfo" + ], + [ + "m_shapeEM", + "has_exact", + "shapeEM" + ], + [ + "m_shapeEMPFLOW", + "has_exact", + "shapeEMPFLOW" + ], + [ + "m_shapeLC", + "has_exact", + "shapeLC" + ], + [ + "m_truth", + "has_exact", + "truth" + ], + [ + "m_caloClus", + "has_exact", + "caloClusters" + ], + [ + "m_weightsSys", + "has_exact", + "weightsSys" + ] + ], + "IParticleInfoSwitch": [ + [ + "m_kinematic", + "has_exact", + "kinematic" + ], + [ + "m_useTheS", + "has_exact", + "useTheS" + ] + ], + "JetInfoSwitch": [ + [ + "m_trigger", + "has_exact", + "trigger" + ], + [ + "m_substructure", + "has_exact", + "substructure" + ], + [ + "m_bosonCount", + "has_exact", + "bosonCount" + ], + [ + "m_VTags", + "has_exact", + "VTags" + ], + [ + "m_rapidity", + "has_exact", + "rapidity" + ], + [ + "m_clean", + "has_exact", + "clean" + ], + [ + "m_cleanLight", + "has_exact", + "cleanLight" + ], + [ + "m_cleanNoSumm", + "has_exact", + "cleanNoSumm" + ], + [ + "m_energy", + "has_exact", + "energy" + ], + [ + "m_energyLight", + "has_exact", + "energyLight" + ], + [ + "m_scales", + "has_exact", + "scales" + ], + [ + "m_constscaleEta", + "has_exact", + "constscaleEta" + ], + [ + "m_detectorEta", + "has_exact", + "detectorEta" + ], + [ + "m_resolution", + "has_exact", + "resolution" + ], + [ + "m_truth", + "has_exact", + "truth" + ], + [ + "m_truthDetails", + "has_exact", + "truth_details" + ], + [ + "m_layer", + "has_exact", + "layer" + ], + [ + "m_trackPV", + "has_exact", + "trackPV" + ], + [ + "m_trackAll", + "has_exact", + "trackAll" + ], + [ + "m_jvt", + "has_exact", + "JVT" + ], + [ + "m_allTrack", + "has_exact", + "allTrack" + ], + [ + "m_allTrackPVSel", + "has_exact", + "allTrackPVSel" + ], + [ + "m_allTrackDetail", + "has_exact", + "allTrackDetail" + ], + [ + "m_allTrackPVSel", + "has_exact", + "allTrackDetailPVSel" + ], + [ + "m_constituent", + "has_exact", + "constituent" + ], + [ + "m_constituentAll", + "has_exact", + "constituentAll" + ], + [ + "m_flavorTag", + "has_exact", + "flavorTag" + ], + [ + "m_flavorTagHLT", + "has_exact", + "flavorTagHLT" + ], + [ + "m_btag_jettrk", + "has_exact", + "btag_jettrk" + ], + [ + "m_jetFitterDetails", + "has_exact", + "jetFitterDetails" + ], + [ + "m_svDetails", + "has_exact", + "svDetails" + ], + [ + "m_ipDetails", + "has_exact", + "ipDetails" + ], + [ + "m_hltVtxComp", + "has_exact", + "hltVtxComp" + ], + [ + "m_onlineBS", + "has_exact", + "onlineBS" + ], + [ + "m_onlineBSTool", + "has_exact", + "onlineBSTool" + ], + [ + "m_charge", + "has_exact", + "charge" + ], + [ + "m_etaPhiMap", + "has_exact", + "etaPhiMap" + ], + [ + "m_byAverageMu", + "has_exact", + "byAverageMu" + ], + [ + "m_byEta", + "has_exact", + "byEta" + ], + [ + "m_vsLumiBlock", + "has_exact", + "vsLumiBlock" + ], + [ + "m_vsActualMu", + "has_exact", + "vsActualMu" + ], + [ + "m_lumiB_runN", + "has_exact", + "lumiB_runN" + ], + [ + "m_sfJVTName", + "get_working_point", + "sfJVT" + ], + [ + "m_sffJVTName", + "get_working_point", + "sffJVT" + ], + [ + "m_area", + "has_exact", + "area" + ], + [ + "m_JVC", + "has_exact", + "JVC" + ] + ], + "METInfoSwitch": [ + [ + "m_metClus", + "has_exact", + "metClus" + ], + [ + "m_metTrk", + "has_exact", + "metTrk" + ], + [ + "m_sigClus", + "has_exact", + "sigClus" + ], + [ + "m_sigClus", + "has_exact", + "all" + ], + [ + "m_sigTrk", + "has_exact", + "sigTrk" + ], + [ + "m_sigTrk", + "has_exact", + "all" + ], + [ + "m_sigResolutionClus", + "has_exact", + "sigResolutionClus" + ], + [ + "m_sigResolutionClus", + "has_exact", + "all" + ], + [ + "m_sigResolutionTrk", + "has_exact", + "sigResolutionTrk" + ], + [ + "m_sigResolutionTrk", + "has_exact", + "all" + ], + [ + "m_refEle", + "has_exact", + "refEle" + ], + [ + "m_refEle", + "has_exact", + "all" + ], + [ + "m_refGamma", + "has_exact", + "refGamma" + ], + [ + "m_refGamma", + "has_exact", + "all" + ], + [ + "m_refTau", + "has_exact", + "refTau" + ], + [ + "m_refTau", + "has_exact", + "all" + ], + [ + "m_refMuons", + "has_exact", + "refMuons" + ], + [ + "m_refMuons", + "has_exact", + "all" + ], + [ + "m_refJet", + "has_exact", + "refJet" + ], + [ + "m_refJet", + "has_exact", + "all" + ], + [ + "m_refJetTrk", + "has_exact", + "refJetTrk" + ], + [ + "m_softClus", + "has_exact", + "softClus" + ], + [ + "m_softClus", + "has_exact", + "all" + ], + [ + "m_softTrk", + "has_exact", + "softTrk" + ], + [ + "m_softTrk", + "has_exact", + "all" + ] + ], + "MuonInfoSwitch": [ + [ + "m_trigger", + "has_exact", + "trigger" + ], + [ + "m_isolation", + "has_exact", + "isolation" + ], + [ + "m_isolationKinematics", + "has_exact", + "isolationKinematics" + ], + [ + "m_quality", + "has_exact", + "quality" + ], + [ + "m_trackparams", + "has_exact", + "trackparams" + ], + [ + "m_trackhitcont", + "has_exact", + "trackhitcont" + ], + [ + "m_effSF", + "has_exact", + "effSF" + ], + [ + "m_energyLoss", + "has_exact", + "energyLoss" + ], + [ + "m_promptlepton", + "has_exact", + "promptlepton" + ], + [ + "m_recoEff_sysNames", + "has_exact", + "recoEff_sysNames" + ], + [ + "m_isoEff_sysNames", + "has_exact", + "isoEff_sysNames" + ], + [ + "m_trigEff_sysNames", + "has_exact", + "trigEff_sysNames" + ], + [ + "m_ttvaEff_sysNames", + "has_exact", + "ttvaEff_sysNames" + ] + ], + "PhotonInfoSwitch": [ + [ + "m_isolation", + "has_exact", + "isolation" + ], + [ + "m_PID", + "has_exact", + "PID" + ], + [ + "m_purity", + "has_exact", + "purity" + ], + [ + "m_effSF", + "has_exact", + "effSF" + ], + [ + "m_trigger", + "has_exact", + "trigger" + ] + ], + "TauInfoSwitch": [ + [ + "m_trigger", + "has_exact", + "trigger" + ], + [ + "m_JetID", + "has_exact", + "JetID" + ], + [ + "m_EleVeto", + "has_exact", + "EleVeto" + ], + [ + "m_trackAll", + "has_exact", + "trackAll" + ], + [ + "m_xahTauJetMatching", + "has_exact", + "xahTauJetMatching" + ], + [ + "m_effSF", + "has_exact", + "effSF" + ], + [ + "m_trackparams", + "has_exact", + "trackparams" + ], + [ + "m_trackhitcont", + "has_exact", + "trackhitcont" + ] + ], + "TrackInfoSwitch": [ + [ + "m_kinematic", + "has_exact", + "kinematic" + ], + [ + "m_fitpars", + "has_exact", + "fitpars" + ], + [ + "m_numbers", + "has_exact", + "numbers" + ], + [ + "m_vertex", + "has_exact", + "vertex" + ], + [ + "m_useTheS", + "has_exact", + "useTheS" + ] + ], + "TriggerInfoSwitch": [ + [ + "m_basic", + "has_exact", + "basic" + ], + [ + "m_menuKeys", + "has_exact", + "menuKeys" + ], + [ + "m_passTriggers", + "has_exact", + "passTriggers" + ], + [ + "m_passTrigBits", + "has_exact", + "passTrigBits" + ], + [ + "m_prescales", + "has_exact", + "prescales" + ], + [ + "m_prescalesLumi", + "has_exact", + "prescalesLumi" + ] + ], + "TruthInfoSwitch": [ + [ + "m_type", + "has_exact", + "type" + ], + [ + "m_bVtx", + "has_exact", + "bVtx" + ], + [ + "m_parents", + "has_exact", + "parents" + ], + [ + "m_children", + "has_exact", + "children" + ] + ] +} \ No newline at end of file From 7f0ac00acdea2b5578bcb43d35e6e484f488f351 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 07:59:11 -0800 Subject: [PATCH 05/16] document the code more and add .travis.yml --- .travis.yml | 13 +++++++++++ test.py => ci/parse_infoswitches.py | 34 +++++++++++++++++++---------- 2 files changed, 36 insertions(+), 11 deletions(-) rename test.py => ci/parse_infoswitches.py (79%) diff --git a/.travis.yml b/.travis.yml index d10501ef77..2238ea5392 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,6 +78,19 @@ matrix: script: - docker run -it -v "$(pwd)":/workdir -w /workdir unibeautify/uncrustify -c ci/uncrustify.cfg --check **/**.cxx || exit 0 + - language: python + python: "3.7" + addons: + apt: + packages: libclang-dev + before_script: + - sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-6.0.so /usr/lib/libclang.so + install: + - pip install clang + script: + - python3 ci/parse_infoswitches.py + - git diff --exit-code --name-only -- data/xAH_infoswitches.json + notifications: email: on_success: never diff --git a/test.py b/ci/parse_infoswitches.py similarity index 79% rename from test.py rename to ci/parse_infoswitches.py index 1dc9a67c3d..af923a0ebd 100644 --- a/test.py +++ b/ci/parse_infoswitches.py @@ -1,12 +1,27 @@ #!/usr/bin/env python3 -""" Usage: call with -""" import sys import clang.cindex import json +def find_inheritance(node): + """ + If given a class declaration, will grab the inheritance of the class if one exists. + Returns None if no class inheritance. + """ + if node.kind != clang.cindex.CursorKind.CLASS_DECL: return + for c in node.get_children(): + if c.kind != clang.cindex.CursorKind.CXX_BASE_SPECIFIER: continue + children = list(c.get_children()) + if children[0].get_definition(): + return children[0].get_definition().spelling + def infoswitch_parser(node, index=0): + """ + Given a node that is believed to be the initialize() of an InfoSwitch struct, + parse all the tokens, and extract the relevant information for pattern + matching, and yield it back. + """ tokens = [] for token in node.get_tokens(): if token.spelling == node.spelling: continue @@ -36,15 +51,12 @@ def infoswitch_parser(node, index=0): tokens.append(spelling) yield [] -def find_inheritance(node): - if node.kind != clang.cindex.CursorKind.CLASS_DECL: return - for c in node.get_children(): - if c.kind != clang.cindex.CursorKind.CXX_BASE_SPECIFIER: continue - children = list(c.get_children()) - if children[0].get_definition(): - return children[0].get_definition().spelling - def find_infoswitches(infoswitches, node): + """ + This top-level entry recursive function goes through all children provided to + identify nodes which are to contain an InfoSwitch struct and then parse out + the appropriate tokens from that node. + """ if node.spelling == 'initialize' and node.kind == clang.cindex.CursorKind.CXX_METHOD: infoswitches[node.semantic_parent.spelling] = [token for token in infoswitch_parser(node) if token] for child in node.get_children(): @@ -52,7 +64,7 @@ def find_infoswitches(infoswitches, node): clang.cindex.Config.set_library_path('/usr/lib') index = clang.cindex.Index.create() -tu = index.parse(sys.argv[1], args=['-x', 'c++']) +tu = index.parse("xAODAnaHelpers/HelperClasses.h", args=['-x', 'c++']) print('Translation unit:', tu.spelling) infoswitches = {} From 43c1a1fe2ffe916e721c9f742374293a57e802e4 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:13:21 -0800 Subject: [PATCH 06/16] print out a git diff to make it easier to patch --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2238ea5392..5c3a31e83d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,6 +89,7 @@ matrix: - pip install clang script: - python3 ci/parse_infoswitches.py + - git diff --no-prefix -- data/xAH_infoswitches.json - git diff --exit-code --name-only -- data/xAH_infoswitches.json notifications: From 85e8fde59673392a3f44cb4350597e1ae7d6ccc8 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:16:08 -0800 Subject: [PATCH 07/16] add job env --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5c3a31e83d..2b7c0f6cb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,6 +80,7 @@ matrix: - language: python python: "3.7" + env: JOB="Parsing xAODAnaHelpers/HelperClasses.h for InfoSwitches" addons: apt: packages: libclang-dev From 5ae6924955bb3a0cad6b45500bcbb8c85ca6d39d Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:18:19 -0800 Subject: [PATCH 08/16] to use py3.7 workaround, see travis-ci/travis-ci#9815 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2b7c0f6cb3..35654162e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,6 +81,8 @@ matrix: - language: python python: "3.7" env: JOB="Parsing xAODAnaHelpers/HelperClasses.h for InfoSwitches" + dist: xenial + sudo: true addons: apt: packages: libclang-dev From 92e7192641912bd8e698677f11f051bea9d3ad26 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:25:24 -0800 Subject: [PATCH 09/16] looking for libclang --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 35654162e9..1c332f11b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,6 +87,7 @@ matrix: apt: packages: libclang-dev before_script: + - sudo find /usr/lib -name "libclang*.so" - sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-6.0.so /usr/lib/libclang.so install: - pip install clang From 7ca3bc348100ddd9408b667e2cf37c0260b612ef Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:33:48 -0800 Subject: [PATCH 10/16] symlink clang version correctly --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1c332f11b9..8aed49f84b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,8 +87,7 @@ matrix: apt: packages: libclang-dev before_script: - - sudo find /usr/lib -name "libclang*.so" - - sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-6.0.so /usr/lib/libclang.so + - sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-3.8.so /usr/lib/libclang.so install: - pip install clang script: From c37d8a0647c76b0c10ee3a1ab4fddff372025e09 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:38:39 -0800 Subject: [PATCH 11/16] specific libclang --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8aed49f84b..f8c556d5ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,7 +85,7 @@ matrix: sudo: true addons: apt: - packages: libclang-dev + packages: libclang-6.0-dev before_script: - sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-3.8.so /usr/lib/libclang.so install: From 239ed57dbc3de469de0628a4b599b2a38ab048f1 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:44:35 -0800 Subject: [PATCH 12/16] fix symlinking --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f8c556d5ec..e7352c76a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,7 +87,7 @@ matrix: apt: packages: libclang-6.0-dev before_script: - - sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-3.8.so /usr/lib/libclang.so + - sudo ln -s /usr/lib/x86_64-linux-gnu/libclang-6.0.so /usr/lib/libclang.so install: - pip install clang script: From df27b475728ddf033bbac3726be3c1277137b60d Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:48:07 -0800 Subject: [PATCH 13/16] file -> open --- ci/parse_infoswitches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/parse_infoswitches.py b/ci/parse_infoswitches.py index af923a0ebd..f70078c74b 100644 --- a/ci/parse_infoswitches.py +++ b/ci/parse_infoswitches.py @@ -75,4 +75,4 @@ def find_infoswitches(infoswitches, node): for var, match_type, match_string in tokens: print(' -',var, match_type, match_string) -json.dump(infoswitches, file('data/xAH_infoswitches.json', 'w+'), sort_keys=True, indent=4) +json.dump(infoswitches, open('data/xAH_infoswitches.json', 'w+'), sort_keys=True, indent=4) From febcbc0ba8cb1f5fc806572c515855711d6769a2 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:50:24 -0800 Subject: [PATCH 14/16] no need for sys --- ci/parse_infoswitches.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/parse_infoswitches.py b/ci/parse_infoswitches.py index f70078c74b..de934e6b8d 100644 --- a/ci/parse_infoswitches.py +++ b/ci/parse_infoswitches.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -import sys import clang.cindex import json From 517a28c758e2961d2529f89f7df9253a746a95b4 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 08:56:36 -0800 Subject: [PATCH 15/16] remove whitespace from end of lines --- data/xAH_infoswitches.json | 804 ++++++++++++++++++------------------- 1 file changed, 402 insertions(+), 402 deletions(-) diff --git a/data/xAH_infoswitches.json b/data/xAH_infoswitches.json index 16991a8e87..a3c7df4aa1 100644 --- a/data/xAH_infoswitches.json +++ b/data/xAH_infoswitches.json @@ -1,694 +1,694 @@ { - "ClusterInfoSwitch": [], + "ClusterInfoSwitch": [], "ElectronInfoSwitch": [ [ - "m_trigger", - "has_exact", + "m_trigger", + "has_exact", "trigger" - ], + ], [ - "m_isolation", - "has_exact", + "m_isolation", + "has_exact", "isolation" - ], + ], [ - "m_isolationKinematics", - "has_exact", + "m_isolationKinematics", + "has_exact", "isolationKinematics" - ], + ], [ - "m_quality", - "has_exact", + "m_quality", + "has_exact", "quality" - ], + ], [ - "m_PID", - "has_exact", + "m_PID", + "has_exact", "PID" - ], + ], [ - "m_recoparams", - "has_exact", + "m_recoparams", + "has_exact", "recoparams" - ], + ], [ - "m_trackparams", - "has_exact", + "m_trackparams", + "has_exact", "trackparams" - ], + ], [ - "m_trackhitcont", - "has_exact", + "m_trackhitcont", + "has_exact", "trackhitcont" - ], + ], [ - "m_effSF", - "has_exact", + "m_effSF", + "has_exact", "effSF" - ], + ], [ - "m_promptlepton", - "has_exact", + "m_promptlepton", + "has_exact", "promptlepton" ] - ], + ], "EventInfoSwitch": [ [ - "m_pileup", - "has_exact", + "m_pileup", + "has_exact", "pileup" - ], + ], [ - "m_pileupsys", - "has_exact", + "m_pileupsys", + "has_exact", "pileupsys" - ], + ], [ - "m_eventCleaning", - "has_exact", + "m_eventCleaning", + "has_exact", "eventCleaning" - ], + ], [ - "m_bcidInfo", - "has_exact", + "m_bcidInfo", + "has_exact", "bcidInfo" - ], + ], [ - "m_shapeEM", - "has_exact", + "m_shapeEM", + "has_exact", "shapeEM" - ], + ], [ - "m_shapeEMPFLOW", - "has_exact", + "m_shapeEMPFLOW", + "has_exact", "shapeEMPFLOW" - ], + ], [ - "m_shapeLC", - "has_exact", + "m_shapeLC", + "has_exact", "shapeLC" - ], + ], [ - "m_truth", - "has_exact", + "m_truth", + "has_exact", "truth" - ], + ], [ - "m_caloClus", - "has_exact", + "m_caloClus", + "has_exact", "caloClusters" - ], + ], [ - "m_weightsSys", - "has_exact", + "m_weightsSys", + "has_exact", "weightsSys" ] - ], + ], "IParticleInfoSwitch": [ [ - "m_kinematic", - "has_exact", + "m_kinematic", + "has_exact", "kinematic" - ], + ], [ - "m_useTheS", - "has_exact", + "m_useTheS", + "has_exact", "useTheS" ] - ], + ], "JetInfoSwitch": [ [ - "m_trigger", - "has_exact", + "m_trigger", + "has_exact", "trigger" - ], + ], [ - "m_substructure", - "has_exact", + "m_substructure", + "has_exact", "substructure" - ], + ], [ - "m_bosonCount", - "has_exact", + "m_bosonCount", + "has_exact", "bosonCount" - ], + ], [ - "m_VTags", - "has_exact", + "m_VTags", + "has_exact", "VTags" - ], + ], [ - "m_rapidity", - "has_exact", + "m_rapidity", + "has_exact", "rapidity" - ], + ], [ - "m_clean", - "has_exact", + "m_clean", + "has_exact", "clean" - ], + ], [ - "m_cleanLight", - "has_exact", + "m_cleanLight", + "has_exact", "cleanLight" - ], + ], [ - "m_cleanNoSumm", - "has_exact", + "m_cleanNoSumm", + "has_exact", "cleanNoSumm" - ], + ], [ - "m_energy", - "has_exact", + "m_energy", + "has_exact", "energy" - ], + ], [ - "m_energyLight", - "has_exact", + "m_energyLight", + "has_exact", "energyLight" - ], + ], [ - "m_scales", - "has_exact", + "m_scales", + "has_exact", "scales" - ], + ], [ - "m_constscaleEta", - "has_exact", + "m_constscaleEta", + "has_exact", "constscaleEta" - ], + ], [ - "m_detectorEta", - "has_exact", + "m_detectorEta", + "has_exact", "detectorEta" - ], + ], [ - "m_resolution", - "has_exact", + "m_resolution", + "has_exact", "resolution" - ], + ], [ - "m_truth", - "has_exact", + "m_truth", + "has_exact", "truth" - ], + ], [ - "m_truthDetails", - "has_exact", + "m_truthDetails", + "has_exact", "truth_details" - ], + ], [ - "m_layer", - "has_exact", + "m_layer", + "has_exact", "layer" - ], + ], [ - "m_trackPV", - "has_exact", + "m_trackPV", + "has_exact", "trackPV" - ], + ], [ - "m_trackAll", - "has_exact", + "m_trackAll", + "has_exact", "trackAll" - ], + ], [ - "m_jvt", - "has_exact", + "m_jvt", + "has_exact", "JVT" - ], + ], [ - "m_allTrack", - "has_exact", + "m_allTrack", + "has_exact", "allTrack" - ], + ], [ - "m_allTrackPVSel", - "has_exact", + "m_allTrackPVSel", + "has_exact", "allTrackPVSel" - ], + ], [ - "m_allTrackDetail", - "has_exact", + "m_allTrackDetail", + "has_exact", "allTrackDetail" - ], + ], [ - "m_allTrackPVSel", - "has_exact", + "m_allTrackPVSel", + "has_exact", "allTrackDetailPVSel" - ], + ], [ - "m_constituent", - "has_exact", + "m_constituent", + "has_exact", "constituent" - ], + ], [ - "m_constituentAll", - "has_exact", + "m_constituentAll", + "has_exact", "constituentAll" - ], + ], [ - "m_flavorTag", - "has_exact", + "m_flavorTag", + "has_exact", "flavorTag" - ], + ], [ - "m_flavorTagHLT", - "has_exact", + "m_flavorTagHLT", + "has_exact", "flavorTagHLT" - ], + ], [ - "m_btag_jettrk", - "has_exact", + "m_btag_jettrk", + "has_exact", "btag_jettrk" - ], + ], [ - "m_jetFitterDetails", - "has_exact", + "m_jetFitterDetails", + "has_exact", "jetFitterDetails" - ], + ], [ - "m_svDetails", - "has_exact", + "m_svDetails", + "has_exact", "svDetails" - ], + ], [ - "m_ipDetails", - "has_exact", + "m_ipDetails", + "has_exact", "ipDetails" - ], + ], [ - "m_hltVtxComp", - "has_exact", + "m_hltVtxComp", + "has_exact", "hltVtxComp" - ], + ], [ - "m_onlineBS", - "has_exact", + "m_onlineBS", + "has_exact", "onlineBS" - ], + ], [ - "m_onlineBSTool", - "has_exact", + "m_onlineBSTool", + "has_exact", "onlineBSTool" - ], + ], [ - "m_charge", - "has_exact", + "m_charge", + "has_exact", "charge" - ], + ], [ - "m_etaPhiMap", - "has_exact", + "m_etaPhiMap", + "has_exact", "etaPhiMap" - ], + ], [ - "m_byAverageMu", - "has_exact", + "m_byAverageMu", + "has_exact", "byAverageMu" - ], + ], [ - "m_byEta", - "has_exact", + "m_byEta", + "has_exact", "byEta" - ], + ], [ - "m_vsLumiBlock", - "has_exact", + "m_vsLumiBlock", + "has_exact", "vsLumiBlock" - ], + ], [ - "m_vsActualMu", - "has_exact", + "m_vsActualMu", + "has_exact", "vsActualMu" - ], + ], [ - "m_lumiB_runN", - "has_exact", + "m_lumiB_runN", + "has_exact", "lumiB_runN" - ], + ], [ - "m_sfJVTName", - "get_working_point", + "m_sfJVTName", + "get_working_point", "sfJVT" - ], + ], [ - "m_sffJVTName", - "get_working_point", + "m_sffJVTName", + "get_working_point", "sffJVT" - ], + ], [ - "m_area", - "has_exact", + "m_area", + "has_exact", "area" - ], + ], [ - "m_JVC", - "has_exact", + "m_JVC", + "has_exact", "JVC" ] - ], + ], "METInfoSwitch": [ [ - "m_metClus", - "has_exact", + "m_metClus", + "has_exact", "metClus" - ], + ], [ - "m_metTrk", - "has_exact", + "m_metTrk", + "has_exact", "metTrk" - ], + ], [ - "m_sigClus", - "has_exact", + "m_sigClus", + "has_exact", "sigClus" - ], + ], [ - "m_sigClus", - "has_exact", + "m_sigClus", + "has_exact", "all" - ], + ], [ - "m_sigTrk", - "has_exact", + "m_sigTrk", + "has_exact", "sigTrk" - ], + ], [ - "m_sigTrk", - "has_exact", + "m_sigTrk", + "has_exact", "all" - ], + ], [ - "m_sigResolutionClus", - "has_exact", + "m_sigResolutionClus", + "has_exact", "sigResolutionClus" - ], + ], [ - "m_sigResolutionClus", - "has_exact", + "m_sigResolutionClus", + "has_exact", "all" - ], + ], [ - "m_sigResolutionTrk", - "has_exact", + "m_sigResolutionTrk", + "has_exact", "sigResolutionTrk" - ], + ], [ - "m_sigResolutionTrk", - "has_exact", + "m_sigResolutionTrk", + "has_exact", "all" - ], + ], [ - "m_refEle", - "has_exact", + "m_refEle", + "has_exact", "refEle" - ], + ], [ - "m_refEle", - "has_exact", + "m_refEle", + "has_exact", "all" - ], + ], [ - "m_refGamma", - "has_exact", + "m_refGamma", + "has_exact", "refGamma" - ], + ], [ - "m_refGamma", - "has_exact", + "m_refGamma", + "has_exact", "all" - ], + ], [ - "m_refTau", - "has_exact", + "m_refTau", + "has_exact", "refTau" - ], + ], [ - "m_refTau", - "has_exact", + "m_refTau", + "has_exact", "all" - ], + ], [ - "m_refMuons", - "has_exact", + "m_refMuons", + "has_exact", "refMuons" - ], + ], [ - "m_refMuons", - "has_exact", + "m_refMuons", + "has_exact", "all" - ], + ], [ - "m_refJet", - "has_exact", + "m_refJet", + "has_exact", "refJet" - ], + ], [ - "m_refJet", - "has_exact", + "m_refJet", + "has_exact", "all" - ], + ], [ - "m_refJetTrk", - "has_exact", + "m_refJetTrk", + "has_exact", "refJetTrk" - ], + ], [ - "m_softClus", - "has_exact", + "m_softClus", + "has_exact", "softClus" - ], + ], [ - "m_softClus", - "has_exact", + "m_softClus", + "has_exact", "all" - ], + ], [ - "m_softTrk", - "has_exact", + "m_softTrk", + "has_exact", "softTrk" - ], + ], [ - "m_softTrk", - "has_exact", + "m_softTrk", + "has_exact", "all" ] - ], + ], "MuonInfoSwitch": [ [ - "m_trigger", - "has_exact", + "m_trigger", + "has_exact", "trigger" - ], + ], [ - "m_isolation", - "has_exact", + "m_isolation", + "has_exact", "isolation" - ], + ], [ - "m_isolationKinematics", - "has_exact", + "m_isolationKinematics", + "has_exact", "isolationKinematics" - ], + ], [ - "m_quality", - "has_exact", + "m_quality", + "has_exact", "quality" - ], + ], [ - "m_trackparams", - "has_exact", + "m_trackparams", + "has_exact", "trackparams" - ], + ], [ - "m_trackhitcont", - "has_exact", + "m_trackhitcont", + "has_exact", "trackhitcont" - ], + ], [ - "m_effSF", - "has_exact", + "m_effSF", + "has_exact", "effSF" - ], + ], [ - "m_energyLoss", - "has_exact", + "m_energyLoss", + "has_exact", "energyLoss" - ], + ], [ - "m_promptlepton", - "has_exact", + "m_promptlepton", + "has_exact", "promptlepton" - ], + ], [ - "m_recoEff_sysNames", - "has_exact", + "m_recoEff_sysNames", + "has_exact", "recoEff_sysNames" - ], + ], [ - "m_isoEff_sysNames", - "has_exact", + "m_isoEff_sysNames", + "has_exact", "isoEff_sysNames" - ], + ], [ - "m_trigEff_sysNames", - "has_exact", + "m_trigEff_sysNames", + "has_exact", "trigEff_sysNames" - ], + ], [ - "m_ttvaEff_sysNames", - "has_exact", + "m_ttvaEff_sysNames", + "has_exact", "ttvaEff_sysNames" ] - ], + ], "PhotonInfoSwitch": [ [ - "m_isolation", - "has_exact", + "m_isolation", + "has_exact", "isolation" - ], + ], [ - "m_PID", - "has_exact", + "m_PID", + "has_exact", "PID" - ], + ], [ - "m_purity", - "has_exact", + "m_purity", + "has_exact", "purity" - ], + ], [ - "m_effSF", - "has_exact", + "m_effSF", + "has_exact", "effSF" - ], + ], [ - "m_trigger", - "has_exact", + "m_trigger", + "has_exact", "trigger" ] - ], + ], "TauInfoSwitch": [ [ - "m_trigger", - "has_exact", + "m_trigger", + "has_exact", "trigger" - ], + ], [ - "m_JetID", - "has_exact", + "m_JetID", + "has_exact", "JetID" - ], + ], [ - "m_EleVeto", - "has_exact", + "m_EleVeto", + "has_exact", "EleVeto" - ], + ], [ - "m_trackAll", - "has_exact", + "m_trackAll", + "has_exact", "trackAll" - ], + ], [ - "m_xahTauJetMatching", - "has_exact", + "m_xahTauJetMatching", + "has_exact", "xahTauJetMatching" - ], + ], [ - "m_effSF", - "has_exact", + "m_effSF", + "has_exact", "effSF" - ], + ], [ - "m_trackparams", - "has_exact", + "m_trackparams", + "has_exact", "trackparams" - ], + ], [ - "m_trackhitcont", - "has_exact", + "m_trackhitcont", + "has_exact", "trackhitcont" ] - ], + ], "TrackInfoSwitch": [ [ - "m_kinematic", - "has_exact", + "m_kinematic", + "has_exact", "kinematic" - ], + ], [ - "m_fitpars", - "has_exact", + "m_fitpars", + "has_exact", "fitpars" - ], + ], [ - "m_numbers", - "has_exact", + "m_numbers", + "has_exact", "numbers" - ], + ], [ - "m_vertex", - "has_exact", + "m_vertex", + "has_exact", "vertex" - ], + ], [ - "m_useTheS", - "has_exact", + "m_useTheS", + "has_exact", "useTheS" ] - ], + ], "TriggerInfoSwitch": [ [ - "m_basic", - "has_exact", + "m_basic", + "has_exact", "basic" - ], + ], [ - "m_menuKeys", - "has_exact", + "m_menuKeys", + "has_exact", "menuKeys" - ], + ], [ - "m_passTriggers", - "has_exact", + "m_passTriggers", + "has_exact", "passTriggers" - ], + ], [ - "m_passTrigBits", - "has_exact", + "m_passTrigBits", + "has_exact", "passTrigBits" - ], + ], [ - "m_prescales", - "has_exact", + "m_prescales", + "has_exact", "prescales" - ], + ], [ - "m_prescalesLumi", - "has_exact", + "m_prescalesLumi", + "has_exact", "prescalesLumi" ] - ], + ], "TruthInfoSwitch": [ [ - "m_type", - "has_exact", + "m_type", + "has_exact", "type" - ], + ], [ - "m_bVtx", - "has_exact", + "m_bVtx", + "has_exact", "bVtx" - ], + ], [ - "m_parents", - "has_exact", + "m_parents", + "has_exact", "parents" - ], + ], [ - "m_children", - "has_exact", + "m_children", + "has_exact", "children" ] ] From 13a7bfaef3becd906ac350db50decdc299df7a71 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Fri, 8 Feb 2019 09:26:25 -0800 Subject: [PATCH 16/16] this reverts the changes to HelperClasses and concatenates inputs --- Root/HelperClasses.cxx | 406 ++++++++++++++++++++++++++++++++- ci/parse_infoswitches.py | 8 +- xAODAnaHelpers/HelperClasses.h | 402 ++------------------------------ 3 files changed, 428 insertions(+), 388 deletions(-) diff --git a/Root/HelperClasses.cxx b/Root/HelperClasses.cxx index bf3d6dee30..4f7833c253 100644 --- a/Root/HelperClasses.cxx +++ b/Root/HelperClasses.cxx @@ -60,7 +60,7 @@ namespace HelperClasses{ /* parser for Tau BDT ID enum */ /* Apparently this won't be useful for non-Athena users... */ - + template <> EnumParser::EnumParser() { @@ -110,4 +110,408 @@ namespace HelperClasses{ return wps; } + /* + !!!!!!!!!!!!!WARNING!!!!!!!!!!!!! + If you change the string here, + please update the relevant + documentation in the header file. + !!!!!!!!!!!!!WARNING!!!!!!!!!!!!! + */ + + void EventInfoSwitch::initialize(){ + m_pileup = has_exact("pileup"); + m_pileupsys = has_exact("pileupsys"); + m_eventCleaning = has_exact("eventCleaning"); + m_bcidInfo = has_exact("bcidInfo"); + m_shapeEM = has_exact("shapeEM"); + m_shapeEMPFLOW = has_exact("shapeEMPFLOW"); + m_shapeLC = has_exact("shapeLC"); + m_truth = has_exact("truth"); + m_caloClus = has_exact("caloClusters"); + m_weightsSys = has_exact("weightsSys"); + } + + void TriggerInfoSwitch::initialize(){ + m_basic = has_exact("basic"); + m_menuKeys = has_exact("menuKeys"); + m_passTriggers = has_exact("passTriggers"); + m_passTrigBits = has_exact("passTrigBits"); + m_prescales = has_exact("prescales"); + m_prescalesLumi = has_exact("prescalesLumi"); + } + + void IParticleInfoSwitch::initialize(){ + m_kinematic = has_exact("kinematic"); + + m_numLeading = 0; + for(auto configDetail : m_configDetails) + { + if( configDetail.compare(0,8,"NLeading")==0) + { + m_numLeading = std::atoi( configDetail.substr(8, std::string::npos).c_str() ); + break; + } + } + + m_useTheS = has_exact("useTheS"); + } + + void MuonInfoSwitch::initialize(){ + m_trigger = has_exact("trigger"); + m_isolation = has_exact("isolation"); + m_isolationKinematics = has_exact("isolationKinematics"); + m_quality = has_exact("quality"); + m_trackparams = has_exact("trackparams"); + m_trackhitcont = has_exact("trackhitcont"); + m_effSF = has_exact("effSF"); + m_energyLoss = has_exact("energyLoss"); + m_promptlepton = has_exact("promptlepton"); + + // working points combinations for trigger corrections + std::string token; + std::string reco_keyword = "RECO_"; + std::string isol_keyword = "ISOL_"; + std::string trig_keyword = "TRIG_"; + + std::istringstream ss(m_configStr); + while ( std::getline(ss, token, ' ') ) { + auto reco_substr = token.find(reco_keyword); + auto isol_substr = token.find(isol_keyword); + auto trig_substr = token.find(trig_keyword); + if( reco_substr != std::string::npos ){ + m_recoWPs.push_back(token.substr(5)); + } else if(isol_substr != std::string::npos){ + if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); + else m_isolWPs.push_back(token.substr(5)); + } else if(trig_substr != std::string::npos){ + m_trigWPs.push_back(token.substr(5)); + } + } + + m_recoEff_sysNames = has_exact("recoEff_sysNames"); + m_isoEff_sysNames = has_exact("isoEff_sysNames"); + m_trigEff_sysNames = has_exact("trigEff_sysNames"); + m_ttvaEff_sysNames = has_exact("ttvaEff_sysNames"); + + } + + void ElectronInfoSwitch::initialize(){ + m_trigger = has_exact("trigger"); + m_isolation = has_exact("isolation"); + m_isolationKinematics = has_exact("isolationKinematics"); + m_quality = has_exact("quality"); + if (m_quality) { + std::cerr << "WARNING! The 'quality' option is deprecated in ElectronInfoSwitch. Use 'PID' instead." << std::endl; + } + m_PID = has_exact("PID"); + m_recoparams = has_exact("recoparams"); + m_trackparams = has_exact("trackparams"); + m_trackhitcont = has_exact("trackhitcont"); + m_effSF = has_exact("effSF"); + m_promptlepton = has_exact("promptlepton"); + // working points for scale-factors + + // working points combinations for trigger corrections + std::string token; + std::string pid_keyword = "PID_"; + std::string pidsf_keyword = "PIDSF_"; + std::string isol_keyword = "ISOL_"; + std::string trig_keyword = "TRIG_"; + + std::istringstream ss(m_configStr); + while ( std::getline(ss, token, ' ') ) { + auto pid_substr = token.find(pid_keyword); + auto pidsf_substr = token.find(pidsf_keyword); + auto isol_substr = token.find(isol_keyword); + auto trig_substr = token.find(trig_keyword); + if( pid_substr != std::string::npos ){ + m_PIDWPs.push_back(token.substr(4)); + } else if( pidsf_substr != std::string::npos ){ + m_PIDSFWPs.push_back(token.substr(6)); + } else if(isol_substr != std::string::npos){ + if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); + else m_isolWPs.push_back(token.substr(5)); + } else if(trig_substr != std::string::npos){ + m_trigWPs.push_back(token.substr(5)); + } + } + } + + void PhotonInfoSwitch::initialize(){ + m_isolation = has_exact("isolation"); + m_PID = has_exact("PID"); + m_purity = has_exact("purity"); + m_effSF = has_exact("effSF"); + m_trigger = has_exact("trigger"); + } + + void ClusterInfoSwitch::initialize(){ + } + + void JetInfoSwitch::initialize(){ + std::string tmpConfigStr; // temporary config string used to extract multiple values + + m_trigger = has_exact("trigger"); + m_substructure = has_exact("substructure"); + m_bosonCount = has_exact("bosonCount"); + m_VTags = has_exact("VTags"); + m_rapidity = has_exact("rapidity"); + m_clean = has_exact("clean"); + m_cleanLight = has_exact("cleanLight"); + m_cleanNoSumm = has_exact("cleanNoSumm"); + m_energy = has_exact("energy"); + m_energyLight = has_exact("energyLight"); + m_scales = has_exact("scales"); + m_constscaleEta = has_exact("constscaleEta"); + m_detectorEta = has_exact("detectorEta"); + m_resolution = has_exact("resolution"); + m_truth = has_exact("truth"); + m_truthDetails = has_exact("truth_details"); + m_layer = has_exact("layer"); + m_trackPV = has_exact("trackPV"); + m_trackAll = has_exact("trackAll"); + m_jvt = has_exact("JVT"); + m_allTrack = has_exact("allTrack"); + m_allTrackPVSel = has_exact("allTrackPVSel"); + m_allTrackDetail= has_exact("allTrackDetail"); + if( m_allTrackDetail ) { + m_allTrackPVSel = m_allTrackPVSel || has_exact("allTrackDetailPVSel") ; + } + m_constituent = has_exact("constituent"); + m_constituentAll = has_exact("constituentAll"); + m_flavorTag = has_exact("flavorTag"); + m_flavorTagHLT = has_exact("flavorTagHLT"); + m_btag_jettrk = has_exact("btag_jettrk"); + m_jetFitterDetails = has_exact("jetFitterDetails"); + m_svDetails = has_exact("svDetails"); + m_ipDetails = has_exact("ipDetails"); + + if(has_match("tracksInJet")){ + m_tracksInJet = true; + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("tracksInJet_") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove tracksInJet_ to just leave the tack name + input.erase(0,12); + + m_trackName = input; + }else{ + m_tracksInJet = false; + m_trackName = ""; + } + + + m_trackJetNames.clear(); + if(has_match("trackJetName")){ + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("trackJetName") ); + if(input.find(" ")!=std::string::npos) input.erase( input.find(" "), std::string::npos ); + input.erase( 0, 13 ); + + std::stringstream ss(input); + std::string s; + while(std::getline(ss, s, '_')) + m_trackJetNames.push_back(s); + } + + + m_hltVtxComp = has_exact("hltVtxComp"); + m_onlineBS = has_exact("onlineBS"); + m_onlineBSTool = has_exact("onlineBSTool"); + + + m_charge = has_exact("charge"); + m_etaPhiMap = has_exact("etaPhiMap"); + m_byAverageMu = has_exact("byAverageMu"); + m_byEta = has_exact("byEta"); + m_vsLumiBlock = has_exact("vsLumiBlock"); + m_vsActualMu = has_exact("vsActualMu"); + m_lumiB_runN = has_exact("lumiB_runN"); + + m_sfJVTName = get_working_point("sfJVT"); + m_sffJVTName = get_working_point("sffJVT"); + + m_sfFTagFix.clear(); + if( has_match( "sfFTagFix" ) ) { + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("sfFTagFix") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove fTagSFFix to just leave the numbers + input.erase(0,9); + // two by two take the characters and push back an int into this vector + std::vector values; + int size( input.size()/2 ); + int count(0); + while( count < size ) { + std::string number = input.substr(0,2); + m_sfFTagFix.push_back( atoi( number.c_str() ) ); + input.erase(0,2); + count++; + } + } // sfFTagFix + m_sfFTagFlt.clear(); + if( has_match( "sfFTagFlt" ) ) { + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("sfFTagFlt") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove fTagSFFlt to just leave the numbers + input.erase(0,9); + // two by two take the characters and push back an int into this vector + std::vector values; + int size( input.size()/2 ); + int count(0); + while( count < size ) { + std::string number = input.substr(0,2); + m_sfFTagFlt.push_back( atoi( number.c_str() ) ); + input.erase(0,2); + count++; + } + } // sfFTagFlt + m_sfFTagHyb.clear(); + if( has_match( "sfFTagHyb" ) ) { + std::string input(m_configStr); + // erase everything before the interesting string + input.erase( 0, input.find("sfFTagHyb") ); + // erase everything after the interesting string + // only if there is something after the string + if( input.find(" ") != std::string::npos ) { + input.erase( input.find_first_of(" "), input.size() ); + } + // remove fTagSFHyb to just leave the numbers + input.erase(0,9); + // two by two take the characters and push back an int into this vector + std::vector values; + int size( input.size()/2 ); + int count(0); + while( count < size ) { + std::string number = input.substr(0,2); + m_sfFTagHyb.push_back( atoi( number.c_str() ) ); + input.erase(0,2); + count++; + } + } // sfFTagHyb + + m_jetBTag.clear(); + tmpConfigStr=std::string(m_configStr); + while( tmpConfigStr.find("jetBTag") != std::string::npos ) { // jetBTag + // erase everything before the interesting string + tmpConfigStr.erase( 0, tmpConfigStr.find("jetBTag") ); + // extract interesting string + std::size_t pos =tmpConfigStr.find(" "); + std::string input=tmpConfigStr.substr(0,pos); + // remove interesting string from configStr being processed + tmpConfigStr.erase(0,pos); + // extracted the tagger and numbers + std::stringstream ss(input); + std::string s; + uint idx=0; + std::string tagger; + std::string type; + std::vector wps; + while(std::getline(ss, s, '_')) { + switch(idx) + { + case 0: // jetBTag + break; + case 1: // tagger + tagger=s; + break; + case 2: // efficiency type + type=s; + break; + case 3: // list of efficiency working points + uint size( s.size()/2 ); + for(uint i=0;i>(); + for(auto wp : wps) + m_jetBTag[tagger].push_back(std::make_pair(type,wp)); + } // jetBTag + + m_area = has_exact("area"); + m_JVC = has_exact("JVC"); + } + + void TruthInfoSwitch::initialize(){ + m_type = has_exact("type"); + m_bVtx = has_exact("bVtx"); + m_parents = has_exact("parents"); + m_children = has_exact("children"); + } + + void TrackInfoSwitch::initialize(){ + m_kinematic = has_exact("kinematic"); + m_fitpars = has_exact("fitpars"); + m_numbers = has_exact("numbers"); + m_vertex = has_exact("vertex"); + m_useTheS = has_exact("useTheS"); + } + + void TauInfoSwitch::initialize(){ + m_trigger = has_exact("trigger"); + m_JetID = has_exact("JetID"); + m_EleVeto = has_exact("EleVeto"); + m_trackAll = has_exact("trackAll"); + m_xahTauJetMatching = has_exact("xahTauJetMatching"); + m_effSF = has_exact("effSF"); + m_trackparams = has_exact("trackparams"); + m_trackhitcont = has_exact("trackhitcont"); + + // working points combinations for trigger corrections + std::string token; + std::string taueff_keyword = "TAUEFF_"; + std::string trig_keyword = "TRIG_"; + + std::istringstream ss(m_configStr); + while ( std::getline(ss, token, ' ') ) { + auto taueff_substr = token.find(taueff_keyword); + auto trig_substr = token.find(trig_keyword); + if( taueff_substr != std::string::npos ){ + m_tauEffWPs.push_back(token.substr(7)); + } else if(trig_substr != std::string::npos){ + m_trigWPs.push_back(token.substr(5)); + } + } + + } + + void METInfoSwitch::initialize(){ + m_metClus = has_exact("metClus"); + m_metTrk = has_exact("metTrk"); + m_sigClus = has_exact("sigClus") || has_exact("all"); + m_sigTrk = has_exact("sigTrk") || has_exact("all"); + m_sigResolutionClus = has_exact("sigResolutionClus") || has_exact("all"); + m_sigResolutionTrk = has_exact("sigResolutionTrk") || has_exact("all"); + m_refEle = has_exact("refEle") || has_exact("all"); + m_refGamma = has_exact("refGamma") || has_exact("all"); + m_refTau = has_exact("refTau") || has_exact("all"); + m_refMuons = has_exact("refMuons") || has_exact("all"); + m_refJet = has_exact("refJet") || has_exact("all"); + m_refJetTrk = has_exact("refJetTrk"); // take this one *only* if requested by user explicitly + m_softClus = has_exact("softClus") || has_exact("all"); + m_softTrk = has_exact("softTrk") || has_exact("all"); + } + } // close namespace HelperClasses diff --git a/ci/parse_infoswitches.py b/ci/parse_infoswitches.py index de934e6b8d..be83c27936 100644 --- a/ci/parse_infoswitches.py +++ b/ci/parse_infoswitches.py @@ -2,6 +2,7 @@ import clang.cindex import json +import tempfile def find_inheritance(node): """ @@ -63,7 +64,12 @@ def find_infoswitches(infoswitches, node): clang.cindex.Config.set_library_path('/usr/lib') index = clang.cindex.Index.create() -tu = index.parse("xAODAnaHelpers/HelperClasses.h", args=['-x', 'c++']) + +f = tempfile.NamedTemporaryFile(mode='w+', delete=False) +for fname in ['xAODAnaHelpers/HelperClasses.h', 'Root/HelperClasses.cxx']: + with open(fname) as infile: + f.write(infile.read()) +tu = index.parse(f.name, args=['-x', 'c++']) print('Translation unit:', tu.spelling) infoswitches = {} diff --git a/xAODAnaHelpers/HelperClasses.h b/xAODAnaHelpers/HelperClasses.h index 726a162761..09770289a5 100644 --- a/xAODAnaHelpers/HelperClasses.h +++ b/xAODAnaHelpers/HelperClasses.h @@ -163,18 +163,7 @@ namespace HelperClasses { bool m_weightsSys; EventInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(){ - m_pileup = has_exact("pileup"); - m_pileupsys = has_exact("pileupsys"); - m_eventCleaning = has_exact("eventCleaning"); - m_bcidInfo = has_exact("bcidInfo"); - m_shapeEM = has_exact("shapeEM"); - m_shapeEMPFLOW = has_exact("shapeEMPFLOW"); - m_shapeLC = has_exact("shapeLC"); - m_truth = has_exact("truth"); - m_caloClus = has_exact("caloClusters"); - m_weightsSys = has_exact("weightsSys"); - }; + void initialize(); }; /** @@ -207,14 +196,7 @@ namespace HelperClasses { bool m_prescalesLumi; TriggerInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(){ - m_basic = has_exact("basic"); - m_menuKeys = has_exact("menuKeys"); - m_passTriggers = has_exact("passTriggers"); - m_passTrigBits = has_exact("passTrigBits"); - m_prescales = has_exact("prescales"); - m_prescalesLumi = has_exact("prescalesLumi"); - }; + void initialize(); }; /** @@ -249,21 +231,7 @@ namespace HelperClasses { IParticleInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); } virtual ~IParticleInfoSwitch() {} protected: - virtual void initialize(){ - m_kinematic = has_exact("kinematic"); - - m_numLeading = 0; - for(auto configDetail : m_configDetails) - { - if( configDetail.compare(0,8,"NLeading")==0) - { - m_numLeading = std::atoi( configDetail.substr(8, std::string::npos).c_str() ); - break; - } - } - - m_useTheS = has_exact("useTheS"); - }; + virtual void initialize(); }; /** @@ -330,43 +298,7 @@ namespace HelperClasses { MuonInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~MuonInfoSwitch() {} protected: - void initialize(){ - m_trigger = has_exact("trigger"); - m_isolation = has_exact("isolation"); - m_isolationKinematics = has_exact("isolationKinematics"); - m_quality = has_exact("quality"); - m_trackparams = has_exact("trackparams"); - m_trackhitcont = has_exact("trackhitcont"); - m_effSF = has_exact("effSF"); - m_energyLoss = has_exact("energyLoss"); - m_promptlepton = has_exact("promptlepton"); - - // working points combinations for trigger corrections - std::string token; - std::string reco_keyword = "RECO_"; - std::string isol_keyword = "ISOL_"; - std::string trig_keyword = "TRIG_"; - - std::istringstream ss(m_configStr); - while ( std::getline(ss, token, ' ') ) { - auto reco_substr = token.find(reco_keyword); - auto isol_substr = token.find(isol_keyword); - auto trig_substr = token.find(trig_keyword); - if( reco_substr != std::string::npos ){ - m_recoWPs.push_back(token.substr(5)); - } else if(isol_substr != std::string::npos){ - if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); - else m_isolWPs.push_back(token.substr(5)); - } else if(trig_substr != std::string::npos){ - m_trigWPs.push_back(token.substr(5)); - } - } - - m_recoEff_sysNames = has_exact("recoEff_sysNames"); - m_isoEff_sysNames = has_exact("isoEff_sysNames"); - m_trigEff_sysNames = has_exact("trigEff_sysNames"); - m_ttvaEff_sysNames = has_exact("ttvaEff_sysNames"); - }; + virtual void initialize(); }; /** @@ -426,47 +358,7 @@ namespace HelperClasses { ElectronInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~ElectronInfoSwitch() {} protected: - void initialize(){ - m_trigger = has_exact("trigger"); - m_isolation = has_exact("isolation"); - m_isolationKinematics = has_exact("isolationKinematics"); - m_quality = has_exact("quality"); - if (m_quality) { - std::cerr << "WARNING! The 'quality' option is deprecated in ElectronInfoSwitch. Use 'PID' instead." << std::endl; - } - m_PID = has_exact("PID"); - m_recoparams = has_exact("recoparams"); - m_trackparams = has_exact("trackparams"); - m_trackhitcont = has_exact("trackhitcont"); - m_effSF = has_exact("effSF"); - m_promptlepton = has_exact("promptlepton"); - // working points for scale-factors - - // working points combinations for trigger corrections - std::string token; - std::string pid_keyword = "PID_"; - std::string pidsf_keyword = "PIDSF_"; - std::string isol_keyword = "ISOL_"; - std::string trig_keyword = "TRIG_"; - - std::istringstream ss(m_configStr); - while ( std::getline(ss, token, ' ') ) { - auto pid_substr = token.find(pid_keyword); - auto pidsf_substr = token.find(pidsf_keyword); - auto isol_substr = token.find(isol_keyword); - auto trig_substr = token.find(trig_keyword); - if( pid_substr != std::string::npos ){ - m_PIDWPs.push_back(token.substr(4)); - } else if( pidsf_substr != std::string::npos ){ - m_PIDSFWPs.push_back(token.substr(6)); - } else if(isol_substr != std::string::npos){ - if(token.substr(5) == "NONE" || token == isol_keyword) m_isolWPs.push_back(""); - else m_isolWPs.push_back(token.substr(5)); - } else if(trig_substr != std::string::npos){ - m_trigWPs.push_back(token.substr(5)); - } - } - }; + virtual void initialize(); }; /** @@ -495,13 +387,7 @@ namespace HelperClasses { PhotonInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); } virtual ~PhotonInfoSwitch() {} protected: - void initialize(){ - m_isolation = has_exact("isolation"); - m_PID = has_exact("PID"); - m_purity = has_exact("purity"); - m_effSF = has_exact("effSF"); - m_trigger = has_exact("trigger"); - }; + virtual void initialize(); }; class ClusterInfoSwitch : public IParticleInfoSwitch { @@ -509,7 +395,7 @@ namespace HelperClasses { ClusterInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); } virtual ~ClusterInfoSwitch() {} protected: - void initialize(){}; + virtual void initialize(); }; /** @@ -648,211 +534,7 @@ namespace HelperClasses { JetInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~JetInfoSwitch() {} protected: - void initialize(){ - std::string tmpConfigStr; // temporary config string used to extract multiple values - - m_trigger = has_exact("trigger"); - m_substructure = has_exact("substructure"); - m_bosonCount = has_exact("bosonCount"); - m_VTags = has_exact("VTags"); - m_rapidity = has_exact("rapidity"); - m_clean = has_exact("clean"); - m_cleanLight = has_exact("cleanLight"); - m_cleanNoSumm = has_exact("cleanNoSumm"); - m_energy = has_exact("energy"); - m_energyLight = has_exact("energyLight"); - m_scales = has_exact("scales"); - m_constscaleEta = has_exact("constscaleEta"); - m_detectorEta = has_exact("detectorEta"); - m_resolution = has_exact("resolution"); - m_truth = has_exact("truth"); - m_truthDetails = has_exact("truth_details"); - m_layer = has_exact("layer"); - m_trackPV = has_exact("trackPV"); - m_trackAll = has_exact("trackAll"); - m_jvt = has_exact("JVT"); - m_allTrack = has_exact("allTrack"); - m_allTrackPVSel = has_exact("allTrackPVSel"); - m_allTrackDetail= has_exact("allTrackDetail"); - if( m_allTrackDetail ) { - m_allTrackPVSel = m_allTrackPVSel || has_exact("allTrackDetailPVSel") ; - } - m_constituent = has_exact("constituent"); - m_constituentAll = has_exact("constituentAll"); - m_flavorTag = has_exact("flavorTag"); - m_flavorTagHLT = has_exact("flavorTagHLT"); - m_btag_jettrk = has_exact("btag_jettrk"); - m_jetFitterDetails = has_exact("jetFitterDetails"); - m_svDetails = has_exact("svDetails"); - m_ipDetails = has_exact("ipDetails"); - - if(has_match("tracksInJet")){ - m_tracksInJet = true; - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("tracksInJet_") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove tracksInJet_ to just leave the tack name - input.erase(0,12); - - m_trackName = input; - }else{ - m_tracksInJet = false; - m_trackName = ""; - } - - - m_trackJetNames.clear(); - if(has_match("trackJetName")){ - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("trackJetName") ); - if(input.find(" ")!=std::string::npos) input.erase( input.find(" "), std::string::npos ); - input.erase( 0, 13 ); - - std::stringstream ss(input); - std::string s; - while(std::getline(ss, s, '_')) - m_trackJetNames.push_back(s); - } - - - m_hltVtxComp = has_exact("hltVtxComp"); - m_onlineBS = has_exact("onlineBS"); - m_onlineBSTool = has_exact("onlineBSTool"); - - - m_charge = has_exact("charge"); - m_etaPhiMap = has_exact("etaPhiMap"); - m_byAverageMu = has_exact("byAverageMu"); - m_byEta = has_exact("byEta"); - m_vsLumiBlock = has_exact("vsLumiBlock"); - m_vsActualMu = has_exact("vsActualMu"); - m_lumiB_runN = has_exact("lumiB_runN"); - - m_sfJVTName = get_working_point("sfJVT"); - m_sffJVTName = get_working_point("sffJVT"); - - m_sfFTagFix.clear(); - if( has_match( "sfFTagFix" ) ) { - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("sfFTagFix") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove fTagSFFix to just leave the numbers - input.erase(0,9); - // two by two take the characters and push back an int into this vector - std::vector values; - int size( input.size()/2 ); - int count(0); - while( count < size ) { - std::string number = input.substr(0,2); - m_sfFTagFix.push_back( atoi( number.c_str() ) ); - input.erase(0,2); - count++; - } - } // sfFTagFix - m_sfFTagFlt.clear(); - if( has_match( "sfFTagFlt" ) ) { - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("sfFTagFlt") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove fTagSFFlt to just leave the numbers - input.erase(0,9); - // two by two take the characters and push back an int into this vector - std::vector values; - int size( input.size()/2 ); - int count(0); - while( count < size ) { - std::string number = input.substr(0,2); - m_sfFTagFlt.push_back( atoi( number.c_str() ) ); - input.erase(0,2); - count++; - } - } // sfFTagFlt - m_sfFTagHyb.clear(); - if( has_match( "sfFTagHyb" ) ) { - std::string input(m_configStr); - // erase everything before the interesting string - input.erase( 0, input.find("sfFTagHyb") ); - // erase everything after the interesting string - // only if there is something after the string - if( input.find(" ") != std::string::npos ) { - input.erase( input.find_first_of(" "), input.size() ); - } - // remove fTagSFHyb to just leave the numbers - input.erase(0,9); - // two by two take the characters and push back an int into this vector - std::vector values; - int size( input.size()/2 ); - int count(0); - while( count < size ) { - std::string number = input.substr(0,2); - m_sfFTagHyb.push_back( atoi( number.c_str() ) ); - input.erase(0,2); - count++; - } - } // sfFTagHyb - - m_jetBTag.clear(); - tmpConfigStr=std::string(m_configStr); - while( tmpConfigStr.find("jetBTag") != std::string::npos ) { // jetBTag - // erase everything before the interesting string - tmpConfigStr.erase( 0, tmpConfigStr.find("jetBTag") ); - // extract interesting string - std::size_t pos =tmpConfigStr.find(" "); - std::string input=tmpConfigStr.substr(0,pos); - // remove interesting string from configStr being processed - tmpConfigStr.erase(0,pos); - // extracted the tagger and numbers - std::stringstream ss(input); - std::string s; - uint idx=0; - std::string tagger; - std::string type; - std::vector wps; - while(std::getline(ss, s, '_')) { - switch(idx) - { - case 0: // jetBTag - break; - case 1: // tagger - tagger=s; - break; - case 2: // efficiency type - type=s; - break; - case 3: // list of efficiency working points - uint size( s.size()/2 ); - for(uint i=0;i>(); - for(auto wp : wps) - m_jetBTag[tagger].push_back(std::make_pair(type,wp)); - } // jetBTag - - m_area = has_exact("area"); - m_JVC = has_exact("JVC"); - }; + virtual void initialize(); }; /** @@ -880,12 +562,7 @@ namespace HelperClasses { bool m_children; TruthInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; protected: - void initialize(){ - m_type = has_exact("type"); - m_bVtx = has_exact("bVtx"); - m_parents = has_exact("parents"); - m_children = has_exact("children"); - }; + void initialize(); }; /** @@ -914,13 +591,7 @@ namespace HelperClasses { bool m_useTheS; TrackInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(){ - m_kinematic = has_exact("kinematic"); - m_fitpars = has_exact("fitpars"); - m_numbers = has_exact("numbers"); - m_vertex = has_exact("vertex"); - m_useTheS = has_exact("useTheS"); - }; + void initialize(); }; /** @@ -944,8 +615,8 @@ namespace HelperClasses { .. note:: - ``identification`` and ``effSF`` switches do not enable any additional output by themselves. - They require additional working point pattern using ``TAUEFF_XYZ`` for combined scale factors, and ``TRIG_XYZ`` + ``identification`` and ``effSF`` switches do not enable any additional output by themselves. + They require additional working point pattern using ``TAUEFF_XYZ`` for combined scale factors, and ``TRIG_XYZ`` for trigger scale factors. ``XYZ`` in the pattern should be replaced using the working point name, for example:: m_configStr = "... TAUEFF_EleOLRElectronEleBDTLoose_TauIDMedium ... TRIG_EleOLRElectronEleBDTMedium_TauIDLoose_TrigMyTriggerMenu" @@ -961,44 +632,18 @@ namespace HelperClasses { bool m_JetID; bool m_EleVeto; bool m_xahTauJetMatching; - bool m_trackAll; + bool m_trackAll; bool m_trackparams; bool m_trackhitcont; bool m_effSF; - + std::vector< std::string > m_tauEffWPs; std::vector< std::string > m_trigWPs; TauInfoSwitch(const std::string configStr) : IParticleInfoSwitch(configStr) { initialize(); }; virtual ~TauInfoSwitch() { } protected: - void initialize(){ - m_trigger = has_exact("trigger"); - m_JetID = has_exact("JetID"); - m_EleVeto = has_exact("EleVeto"); - m_trackAll = has_exact("trackAll"); - m_xahTauJetMatching = has_exact("xahTauJetMatching"); - m_effSF = has_exact("effSF"); - m_trackparams = has_exact("trackparams"); - m_trackhitcont = has_exact("trackhitcont"); - - // working points combinations for trigger corrections - std::string token; - std::string taueff_keyword = "TAUEFF_"; - std::string trig_keyword = "TRIG_"; - - std::istringstream ss(m_configStr); - while ( std::getline(ss, token, ' ') ) { - auto taueff_substr = token.find(taueff_keyword); - auto trig_substr = token.find(trig_keyword); - if( taueff_substr != std::string::npos ){ - m_tauEffWPs.push_back(token.substr(7)); - } else if(trig_substr != std::string::npos){ - m_trigWPs.push_back(token.substr(5)); - } - } - - }; + virtual void initialize(); }; /** @@ -1047,22 +692,7 @@ namespace HelperClasses { bool m_softTrk; METInfoSwitch(const std::string configStr) : InfoSwitch(configStr) { initialize(); }; protected: - void initialize(){ - m_metClus = has_exact("metClus"); - m_metTrk = has_exact("metTrk"); - m_sigClus = has_exact("sigClus") || has_exact("all"); - m_sigTrk = has_exact("sigTrk") || has_exact("all"); - m_sigResolutionClus = has_exact("sigResolutionClus") || has_exact("all"); - m_sigResolutionTrk = has_exact("sigResolutionTrk") || has_exact("all"); - m_refEle = has_exact("refEle") || has_exact("all"); - m_refGamma = has_exact("refGamma") || has_exact("all"); - m_refTau = has_exact("refTau") || has_exact("all"); - m_refMuons = has_exact("refMuons") || has_exact("all"); - m_refJet = has_exact("refJet") || has_exact("all"); - m_refJetTrk = has_exact("refJetTrk"); // take this one *only* if requested by user explicitly - m_softClus = has_exact("softClus") || has_exact("all"); - m_softTrk = has_exact("softTrk") || has_exact("all"); - }; + void initialize(); }; } // close namespace HelperClasses