Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions analysis/python_cfg_example/jamfile.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# jamfile for the python_cfg_example
# -------------------------------------------------------------------- #

exe python_cfg_example
: # sources
./source/main.cc
# dependent packages
/ROOT
#/CMSSW/<link>shared # if you want all of CMSSW (see PAC/externals/build/cmssw/jamfile.jam)
/CMSSW//libFWCoreParameterSet/<link>shared
/CMSSW//libFWCorePythonParameterSet/<link>shared
: # requirements
<include>./include
<include>./source
: # default-build
: # usage-requirements
;

# install libs/exes
# -------------------------------------------------------------- #

default-install python_cfg_example ;
43 changes: 43 additions & 0 deletions analysis/python_cfg_example/pset/pset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import FWCore.ParameterSet.Config as cms
import os
import sys

## path the analysis (THIS SHOULD NOT CHANGE)
analysis_path = os.getenv("PAC") + "/analysis/python_cfg_example"
sys.path.append(analysis_path + "/pset")

## process to parse (THIS SHOULD NOT CHANGE)
process = cms.PSet()

## ------------------------------------------------------------- #
## Parameters for the selection, plot making, and fitting
## ------------------------------------------------------------- #

process.pset = cms.PSet(

## path to the analysis
analysis_path = cms.string(analysis_path),

## the sample name (from Sample.h/cc)
sample_name = cms.string("sample"),

## integrated luminosity
lumi = cms.double(19.5),

## output label to give it a unique name
output_label = cms.string("v0"),

## search regions
search_regions = cms.vuint32(0, 1, 2, 3, 4, 5, 6),

## select a specific sparm parameter
mass_stop = cms.double(-1),
mass_lsp = cms.double(-1),

## max number of events to run on
max_events = cms.int64(-1),

## verbosity (for trouble shooting)
verbose = cms.bool(False),
)

94 changes: 94 additions & 0 deletions analysis/python_cfg_example/source/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// C++ includes
#include <iostream>
#include <string>
#include <stdexcept>

// ROOT includes
#include "TString.h"

// CMSSW includes
// #include "FWCore/FWLite/interface/AutoLibraryLoader.h" // needed for FWLite if you want to run edm files
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"

// ------------------------------------------------------------------------------------ //
// The main program
// ------------------------------------------------------------------------------------ //

int main(int argc, char **argv)
try
{
using namespace std;

// needed for FWLite if you want to run edm files
// gSystem->Load("libFWCoreFWLite");
// AutoLibraryLoader::enable();

// parse the inputs
// -------------------------------------------------------------------------------------------------//

// check that the python is passed
if (argc < 2)
{
throw std::invalid_argument(Form("Usage : %s [parameters.py]", argv[0]));
}

// check that pset contains "process"
const std::string pset_filename = argv[1];
if (!edm::readPSetsFrom(argv[1])->existsAs<edm::ParameterSet>("process"))
{
throw std::invalid_argument(Form("[python_cfg_example] Error: ParametersSet 'process' is missing in your configuration file"));
}

// get the python configuration
const edm::ParameterSet& process = edm::readPSetsFrom(pset_filename)->getParameter<edm::ParameterSet>("process");
const edm::ParameterSet& pset = process.getParameter<edm::ParameterSet>("pset");

// get the inputs
const long long max_events = pset.getParameter<long long> ("max_events" ) ;
const bool verbose = pset.getParameter<bool> ("verbose" ) ;
const std::string analysis_path = pset.getParameter<std::string> ("analysis_path" ) ;
const std::string output_label = pset.getParameter<std::string> ("output_label" ) ;
const std::string sample_name = pset.getParameter<std::string> ("sample_name" ) ;
const double lumi = pset.getParameter<double> ("lumi" ) ;
const double mass_stop = pset.getParameter<double> ("mass_stop" ) ;
const double mass_lsp = pset.getParameter<double> ("mass_lsp" ) ;
const std::vector<unsigned int> search_regions = pset.getParameter<std::vector<unsigned int> > ("search_regions") ;

// print out the parameters
// -------------------------------------------------------------------------------------------------//

cout << "\n[python_cfg_example] running with the following inputs:" << endl;
printf("%-25s = %lld\n" , "max_events" , max_events );
printf("%-25s = %1.1f\n" , "lumi" , lumi );
printf("%-25s = %s\n" , "sample_name" , sample_name.c_str() );
printf("%-25s = %s\n" , "output_label" , output_label.c_str() );
printf("%-25s = %d\n" , "verbose" , verbose );
printf("%-25s = %1.0f\n" , "mass_stop" , mass_stop );
printf("%-25s = %1.0f\n" , "mass_lsp" , mass_lsp );

// print the search regions
printf("%-25s = ", "SR(s)");
for (size_t i = 0; i != search_regions.size(); i++)
{
if (search_regions.at(i) != search_regions.back()) {cout << search_regions.at(i) << ", ";}
else {cout << search_regions.at(i) << endl;}
}

// do stuff
// -------------------------------------------------------------------------------------------------//

//...

// done
// -------------------------------------------------------------------------------------------------//

return 0;
}
catch (std::exception& e)
{
std::cerr << "[stop_interp_plots] Error: failed..." << std::endl;
std::cerr << e.what() << std::endl;
return 1;
}

78 changes: 78 additions & 0 deletions externals/build/cmssw/jamfile.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# jamfile for CMSSW including FWLite

# need to import some files
import os ;

# env variables and other derived paths
# ------------------------------------------------------------------------------------------------- #

# CMSSW variables (4.2 ish)
local CMS_PATH = [ os.environ CMS_PATH ] ;
local CMSSW_RELEASE_BASE = [ os.environ CMSSW_RELEASE_BASE ] ;
local CMSSW_BASE = [ os.environ CMSSW_BASE ] ;
local CMSSW_VERSION = [ os.environ CMSSW_VERSION ] ;
local CMSSW_SEARCH_PATH = [ os.environ CMSSW_SEARCH_PATH ] ;
local CMSSW_DATA_PATH = [ os.environ CMSSW_DATA_PATH ] ;
local SCRAM_ARCH = [ os.environ SCRAM_ARCH ] ;

# derived variables paths
# NOT robust -- might need more logic if the release name is more complicated
# (e.g. CMSSW_5_3_14_LHAPDF590)
local CMSSW_EXTERNAL_BASE = $(CMS_PATH)/$(SCRAM_ARCH)/external ;
local CMSSW_RELEASE_NOPATCH_BASE = [ SHELL "echo -ne $CMSSW_RELEASE_BASE | sed 's/-patch//g' | sed 's/_patch4//g'" ] ;
#ECHO "CMSSW_RELEASE_NOPATCH_BASE is set: " $(CMSSW_RELEASE_NOPATCH_BASE) "\n" ;

# library paths
local LIBS_LOCAL = $(CMSSW_BASE)/lib/$(SCRAM_ARCH) ;
local LIBS_BASE = $(CMSSW_RELEASE_BASE)/lib/$(SCRAM_ARCH) ;
local LIBS_NOPATCH_BASE = $(CMSSW_RELEASE_NOPATCH_BASE)/lib/$(SCRAM_ARCH) ;

# External to CMSSW
# needed by FWLite and are CMSSW version dependent
# (see env var $CMSSW_FWLITE_INCLUDE_PATH)
local SHERPA = $(CMSSW_EXTERNAL_BASE)/sherpa/1.3.1-cms2 ;
local HEPMC = $(CMSSW_EXTERNAL_BASE)/hepmc/2.06.07 ;
local CLHEP = $(CMSSW_EXTERNAL_BASE)/clhep/2.0.4.6 ;

# CMSSW search paths
# ------------------------------------------------------------------------------------------------- #
project CMSSW
: usage-requirements
# CMSSW Local
<include>$(CMSSW_SEARCH_PATH)
<include>$(CMSSW_BASE)/src
<include>$(CMSSW_BASE)/external/$(SCRAM_ARCH)/data
# CMSSW Release
<include>$(CMSSW_RELEASE_BASE)/src
<include>$(CMSSW_RELEASE_BASE)/external/$(SCRAM_ARCH)/data
# CMSSW Nopatch Release
<include>$(CMSSW_RELEASE_NOPATCH_BASE)/src
<include>$(CMSSW_RELEASE_NOPATCH_BASE)/external/$(SCRAM_ARCH)/data
# CMSSW Externals
<include>$(SHERPA)/include
<include>$(HEPMC)/include
<include>$(CLHEP)/include
;

# CMSSW libs
# ------------------------------------------------------------------------------------------------- #
lib libFWCoreFWLite : : <name>FWCoreFWLite <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
lib libFWCoreFramework : : <name>FWCoreFramework <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
lib libFWCoreParameterSet : : <name>FWCoreParameterSet <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
lib libFWCorePythonParameterSet : : <name>FWCorePythonParameterSet <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;

# these are out of date -- add as need from LIBS_LOCAL, LIBS_BASE, or LIBS_NOPATCH_BASE
#lib libFWCoreVersion : : <name>FWCoreVersion <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libDQMServicesClientConfig : : <name>DQMServicesClientConfig <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libCommonToolsCandAlgos : : <name>CommonToolsCandAlgos <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libDataFormatsFWLite : : <name>DataFormatsFWLite <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libDataFormatsMath : : <name>DataFormatsMath <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libPhysicsToolsFWLite : : <name>PhysicsToolsFWLite <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libDataFormatsTrackReco : : <name>DataFormatsTrackReco <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libDataFormatsCLHEP : : <name>DataFormatsCLHEP <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libSimDataFormatsTrackingAnalysis : : <name>SimDataFormatsTrackingAnalysis <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libCommonToolsUtilAlgos : : <name>CommonToolsUtilAlgos <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libCalibCalorimetryEcalTPGTools : : <name>CalibCalorimetryEcalTPGTools <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libPhysicsToolsPFCandProducer : : <name>PhysicsToolsPFCandProducer <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;
#lib libRecoEgammaElectronIdentification : : <name>RecoEgammaElectronIdentification <search>$(LIBS_LOCAL) <search>$(LIBS_BASE) <search>$(LIBS_NOPATCH_BASE) <link>shared ;

3 changes: 1 addition & 2 deletions jamroot.jam
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ set-install-dir $(install-dir) ;
# ----------------------------------------------------------------------#

# CMSSW
#path-constant CMSSW_SRC : /usr/local/cmssw/osx107_amd64_gcc462/cms/cmssw/CMSSW_5_3_4/src ;
#use-project /CMSSW : ./externals/build/CMSSW ;
use-project /CMSSW : ./externals/build/cmssw ;

# BOOST
local boost_current = [ os.environ BOOST_CURRENT ] ;
Expand Down