Skip to content

Commit

Permalink
Merge CMSSW_7_6_X into CMSSW_8_0_X.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsbuild committed Oct 28, 2015
2 parents 9d76187 + 194b285 commit 5fe369f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
19 changes: 10 additions & 9 deletions PhysicsTools/SelectorUtils/interface/VersionedSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,30 +191,31 @@ initialize( const edm::ParameterSet& conf ) {
cend(cutflow.end());
std::vector<edm::ParameterSet>::const_iterator icut = cbegin;
std::map<std::string,unsigned> cut_counter;
for( ; icut != cend; ++icut ) {
const std::string& cname = icut->getParameter<std::string>("cutName");
std::vector<std::string> ignored_cuts;
for( ; icut != cend; ++icut ) {
std::stringstream realname;
const std::string& name = icut->getParameter<std::string>("cutName");
if( !cut_counter.count(name) ) cut_counter[name] = 0;
realname << name << "_" << cut_counter[name];
const bool needsContent =
icut->getParameter<bool>("needsAdditionalProducts");
const bool ignored = icut->getParameter<bool>("isIgnored");
candf::CandidateCut* plugin = nullptr;
CINT_GUARD(plugin = CutApplicatorFactory::get()->create(cname,*icut));
CINT_GUARD(plugin = CutApplicatorFactory::get()->create(name,*icut));
if( plugin != nullptr ) {
cuts_.push_back(SHARED_PTR(candf::CandidateCut)(plugin));
} else {
throw cms::Exception("BadPluginName")
<< "The requested cut: " << cname << " is not available!";
<< "The requested cut: " << name << " is not available!";
}
needs_event_content_.push_back(needsContent);
const std::string& name = plugin->name();
std::stringstream realname;
if( !cut_counter.count(name) ) cut_counter[name] = 0;
realname << name << "_" << cut_counter[name];
const std::string therealname = realname.str();
this->push_back(therealname);
this->set(therealname);
if(ignored) this->ignoreCut(therealname);
if(ignored) ignored_cuts.push_back(therealname);
cut_counter[name]++;
}
this->setIgnoredCuts(ignored_cuts);

//have to loop again to set cut indices after all are filled
icut = cbegin;
Expand Down
21 changes: 11 additions & 10 deletions PhysicsTools/SelectorUtils/python/VIDSelectorBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
ebCutOff = 1.479
%s
%s = %s
"""

def process_pset( builder, pythonpset ):
""" turn a python cms.PSet into a VID ID """
escaped_pset = config_template%(pythonpset)
def process_pset( builder, pythonpset, suffix ):
""" turn a python cms.PSet into a VID ID """
idname = pythonpset.idName.value().replace('-','_') + suffix
escaped_pset = config_template%(idname, pythonpset)

idname = pythonpset.idName.value().replace('-','_')

return builder(escaped_pset,idname)

def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
Expand All @@ -36,7 +35,7 @@ def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
class VIDSelectorBase:
def __init__(self, vidSelectorBuilder, ptrMaker, printer, pythonpset = None):
self.__initialized = False
self.__suffix = id_generator(7)
self.__suffix = id_generator(12)
self.__printer = printer()
self.__ptrMaker = ptrMaker()
self.__selectorBuilder = vidSelectorBuilder()
Expand All @@ -53,7 +52,7 @@ def __init__(self, vidSelectorBuilder, ptrMaker, printer, pythonpset = None):
sys.stderr.write('This ID is not POG approved and likely under development!!!!\n')
sys.stderr.write('Please make sure to report your progress with this ID'\
' at the next relevant POG meeting.\n')
self.__instance = process_pset( self.__selectorBuilder, pythonpset )
self.__instance = process_pset( self.__selectorBuilder, pythonpset, self.__suffix )
expectedmd5 = central_id_registry.getMD5FromName(pythonpset.idName)
if expectedmd5 != self.md5String():
sys.stderr.write("ID: %s\n"%self.name())
Expand All @@ -74,11 +73,13 @@ def __call__(self,*args):
temp = self.__ptrMaker(args[0],args[1])
newargs = [temp]
return self.__instance(*newargs)
if( len(args) == 3 ):
if( len(args) == 3 and type(args[1]) is int and isinstance(args[2], DataFormats.FWLite.Events) ):
temp = self.__ptrMaker(args[0],args[1])
newargs = [temp]
newargs += [args[2].object().event()]
return self.__instance(*newargs)
raise ValueError('VIDSelectorBase __call__ with args: "%s" is not a valid call pattern'%(','.join([repr(arg) for arg in args])))


def initialize(self,pythonpset):
if( self.__initialized ):
Expand All @@ -96,7 +97,7 @@ def initialize(self,pythonpset):
sys.stderr.write('This ID is not POG approved and likely under development!!!!\n')
sys.stderr.write('Please make sure to report your progress with this ID'\
' at the next relevant POG meeting.\n')
self.__instance = process_pset( self.__selectorBuilder, pythonpset )
self.__instance = process_pset( self.__selectorBuilder, pythonpset, self.__suffix )
expectedmd5 = central_id_registry.getMD5FromName(pythonpset.idName)
if expectedmd5 != self.md5String():
sys.stderr.write("ID: %s\n"%self.name())
Expand Down

0 comments on commit 5fe369f

Please sign in to comment.