Skip to content

Commit

Permalink
Merge pull request #16 from cms-sw/CMSSW_7_6_X
Browse files Browse the repository at this point in the history
PR_ToBringUpToDateMyBranch_ME0Segment_PR_v3
  • Loading branch information
pietverwilligen committed Aug 17, 2015
2 parents a099ac5 + 7795d16 commit c22418c
Show file tree
Hide file tree
Showing 415 changed files with 62,352 additions and 13,440 deletions.
2 changes: 1 addition & 1 deletion CalibCalorimetry/HcalPlugins/src/HcalTextCalibrations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ HcalTextCalibrations::HcalTextCalibrations ( const edm::ParameterSet& iConfig )
findingRecord <HcalQIEDataRcd> ();
}
else if (objectName == "ChannelQuality") {
setWhatProduced (this, &HcalTextCalibrations::produceChannelQuality);
setWhatProduced (this, &HcalTextCalibrations::produceChannelQuality, edm::es::Label("withTopo"));
findingRecord <HcalChannelQualityRcd> ();
}
else if (objectName == "ZSThresholds") {
Expand Down
5 changes: 3 additions & 2 deletions CalibMuon/DTCalibration/interface/DTCalibMuonSelection.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/EDGetToken.h"

#include "DataFormats/MuonReco/interface/MuonFwd.h"

#include <vector>
#include <string>
Expand All @@ -26,7 +27,7 @@ class DTCalibMuonSelection : public edm::EDFilter {

virtual void endJob() ;

edm::InputTag muonList;
edm::EDGetTokenT<reco::MuonCollection> muonList;

double etaMin;
double etaMax;
Expand Down
6 changes: 3 additions & 3 deletions CalibMuon/DTCalibration/src/DTCalibMuonSelection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "DataFormats/MuonReco/interface/Muon.h"
#include "DataFormats/MuonReco/interface/MuonFwd.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
Expand All @@ -21,7 +21,7 @@ using namespace reco;

DTCalibMuonSelection::DTCalibMuonSelection(const edm::ParameterSet& iConfig)
{
muonList = iConfig.getParameter<edm::InputTag>("src");
muonList = consumes<MuonCollection>(iConfig.getParameter<edm::InputTag>("src"));
etaMin = iConfig.getParameter<double>("etaMin");
etaMax = iConfig.getParameter<double>("etaMax");
ptMin = iConfig.getParameter<double>("ptMin");
Expand All @@ -37,7 +37,7 @@ bool DTCalibMuonSelection::filter(edm::Event& iEvent, const edm::EventSetup& iSe

//Retrieve the muons list
Handle<MuonCollection> MuHandle;
iEvent.getByLabel(muonList,MuHandle);
iEvent.getByToken(muonList,MuHandle);

for (MuonCollection::const_iterator nmuon = MuHandle->begin(); nmuon != MuHandle->end(); ++nmuon) {

Expand Down
2 changes: 2 additions & 0 deletions CommonTools/Utils/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<use name="FWCore/Utilities"/>
<use name="FWCore/MessageLogger"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/EgammaObjects"/>
<use name="boost"/>
<use name="roothistmatrix"/>
<use name="roottmva"/>
Expand Down
26 changes: 21 additions & 5 deletions CommonTools/Utils/interface/TMVAEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
#include <string>
#include <vector>
#include <map>
#include <mutex>

#include "TMVA/Reader.h"
#include "TMVA/IMethod.h"
#include "CondFormats/EgammaObjects/interface/GBRForest.h"
#include "FWCore/Framework/interface/EventSetup.h"


class TMVAEvaluator {
Expand All @@ -16,17 +20,29 @@ class TMVAEvaluator {
~TMVAEvaluator();

void initialize(const std::string & options, const std::string & method, const std::string & weightFile,
const std::vector<std::string> & variables, const std::vector<std::string> & spectators);
float evaluate(const std::map<std::string,float> & inputs, const bool useSpectators=false);
const std::vector<std::string> & variables, const std::vector<std::string> & spectators, bool useGBRForest=false, bool useAdaBoost=false);
void initializeGBRForest(const GBRForest* gbrForest, const std::vector<std::string> & variables,
const std::vector<std::string> & spectators, bool useAdaBoost=false);
void initializeGBRForest(const edm::EventSetup &iSetup, const std::string & label,
const std::vector<std::string> & variables, const std::vector<std::string> & spectators, bool useAdaBoost=false);
float evaluateTMVA(const std::map<std::string,float> & inputs, bool useSpectators) const;
float evaluateGBRForest(const std::map<std::string,float> & inputs) const;
float evaluate(const std::map<std::string,float> & inputs, bool useSpectators=false) const;

private:
bool mIsInitialized;
bool mUsingGBRForest;
bool mUseAdaBoost;
bool mReleaseAtEnd;

std::string mMethod;
std::unique_ptr<TMVA::Reader> mReader;
mutable std::mutex m_mutex;
[[cms::thread_guard("m_mutex")]] std::unique_ptr<TMVA::Reader> mReader;
std::unique_ptr<TMVA::IMethod> mIMethod;
std::unique_ptr<const GBRForest> mGBRForest;

std::map<std::string,float> mVariables;
std::map<std::string,float> mSpectators;
[[cms::thread_guard("m_mutex")]] mutable std::map<std::string,std::pair<size_t,float>> mVariables;
[[cms::thread_guard("m_mutex")]] mutable std::map<std::string,std::pair<size_t,float>> mSpectators;
};

#endif // CommonTools_Utils_TMVAEvaluator_h
Expand Down
3 changes: 2 additions & 1 deletion CommonTools/Utils/interface/TMVAZipReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define TMVAZIPREADER_7RXIGO70

#include "TMVA/Reader.h"
#include "TMVA/IMethod.h"
#include <string>

namespace reco {
Expand All @@ -32,7 +33,7 @@ namespace reco {
bool hasEnding(std::string const &fullString, std::string const &ending);
char* readGzipFile(const std::string& weightFile);

void loadTMVAWeights(TMVA::Reader* reader, const std::string& method,
TMVA::IMethod* loadTMVAWeights(TMVA::Reader* reader, const std::string& method,
const std::string& weightFile, bool verbose=false);


Expand Down
8 changes: 8 additions & 0 deletions CommonTools/Utils/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
<use name="CondCore/DBOutputService"/>
<use name="CondFormats/EgammaObjects"/>
<use name="root"/>
<use name="roottmva"/>
<flags EDM_PLUGIN="1"/>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "RecoMET/METPUSubtraction/plugins/GBRForestWriter.h"
#include "CommonTools/Utils/plugins/GBRForestWriter.h"

#include "FWCore/Utilities/interface/Exception.h"

Expand Down Expand Up @@ -59,11 +59,11 @@ void GBRForestWriter::analyze(const edm::Event&, const edm::EventSetup&)
dummyVariables.push_back(0.);
mvaReader->AddSpectator(spectatorVariable->data(), &dummyVariables.back());
}
mvaReader->BookMVA((*category)->gbrForestName_.data(), (*category)->inputFileName_.data());
TMVA::MethodBDT* bdt = dynamic_cast<TMVA::MethodBDT*>(mvaReader->FindMVA((*category)->gbrForestName_.data()));
mvaReader->BookMVA((*category)->methodName_.data(), (*category)->inputFileName_.data());
TMVA::MethodBDT* bdt = dynamic_cast<TMVA::MethodBDT*>(mvaReader->FindMVA((*category)->methodName_.data()));
if ( !bdt )
throw cms::Exception("GBRForestWriter")
<< "Failed to load MVA = " << (*category)->gbrForestName_.data() << " from file = " << (*category)->inputFileName_ << " !!\n";
<< "Failed to load MVA = " << (*category)->methodName_.data() << " from file = " << (*category)->inputFileName_ << " !!\n";
gbrForest = new GBRForest(bdt);
delete mvaReader;
TMVA::Tools::DestroyInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ class GBRForestWriter : public edm::EDAnalyzer
if ( inputFileType_ == kXML ) {
inputVariables_ = cfg.getParameter<vstring>("inputVariables");
spectatorVariables_ = cfg.getParameter<vstring>("spectatorVariables");
methodName_ = cfg.getParameter<std::string>("methodName");
gbrForestName_ = ( cfg.existsAs<std::string>("gbrForestName") ? cfg.getParameter<std::string>("gbrForestName") : methodName_ );
}
gbrForestName_ = cfg.getParameter<std::string>("gbrForestName");
else
gbrForestName_ = cfg.getParameter<std::string>("gbrForestName");
}
~categoryEntryType() {}
std::string inputFileName_;
Expand All @@ -65,6 +68,7 @@ class GBRForestWriter : public edm::EDAnalyzer
vstring inputVariables_;
vstring spectatorVariables_;
std::string gbrForestName_;
std::string methodName_;
};
struct jobEntryType
{
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/Utils/src/ComparisonStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace reco {
namespace parser {
class ComparisonBase;
struct ComparisonBase;
typedef std::vector<boost::shared_ptr<ComparisonBase> > ComparisonStack;
}
}
Expand Down
2 changes: 1 addition & 1 deletion CommonTools/Utils/src/ExpressionSetter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef CommonTools_Utils_ExpressionSetter_h
#define CommoTools_Utils_ExpressionSetter_h
#define CommonTools_Utils_ExpressionSetter_h
/* \class reco::parser::ExpressionSetter
*
* Expression setter
Expand Down
Loading

0 comments on commit c22418c

Please sign in to comment.