Skip to content

Commit

Permalink
Merge pull request cms-sw#119 from mbluj/CMSSW_10_5_X_recoOnMiniAOD
Browse files Browse the repository at this point in the history
Sync with 10_5_0_pre2
Only one trivial conflict solved
  • Loading branch information
mbluj authored Feb 26, 2019
2 parents a52e3b6 + d67e5db commit 4468872
Show file tree
Hide file tree
Showing 280 changed files with 8,100 additions and 2,854 deletions.
4 changes: 2 additions & 2 deletions Alignment/CommonAlignment/scripts/tkal_create_file_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def _validate_input(self):
self._args.events = float("inf")
print_msg("Using all tracks for alignment")
elif (self._args.tracks is None) and (self._args.rate is None):
msg = ("either -n/--events-for-alignment or both of "
msg = ("either -n/--events-for-alignment, --all-events, or both of "
"--tracks-for-alignment and --track-rate are required")
self._parser.error(msg)
elif (((self._args.tracks is not None) and (self._args.rate is None)) or
Expand Down Expand Up @@ -461,7 +461,7 @@ def _split_hippy_jobs(self):
eventsinthisjob = float("inf")
for fileinfo in self._files_alignment:
if fileinfo.dataset != dataset: continue
miniiovs = self._get_iovs(fileinfo.runs, useminiiovs=True)
miniiovs = set(self._get_iovs(fileinfo.runs, useminiiovs=True))
if miniiov not in miniiovs: continue
if len(miniiovs) > 1:
hippyjobs[dataset,miniiov] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def interpretOptions(self):
self.uniformetaformula=val
## Options for mMin. bias
# Apply vertex constraint
elif (key=="primaryvertextpye" or key=="pvtype"):
elif (key=="primaryvertextype" or key=="pvtype"):
val=val.lower()
if (val=="nobs" or val=="withbs"):
self.PVtype=val
Expand Down
25 changes: 10 additions & 15 deletions Alignment/HIPAlignmentAlgorithm/python/align_tpl_py.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,16 @@ if "generic" in optpy.CPEtype: # CPE type is defaulted to "template" in HipPyOpt
sourceFileList=[
<FILE>
]
if strflaglower == "cosmics":
process.source = cms.Source("PoolSource",
#useCSA08Kludge = cms.untracked.bool(True),
fileNames = cms.untracked.vstring(sourceFileList)
)
elif strflaglower == "cdcs":
process.source = cms.Source("PoolSource",
#useCSA08Kludge = cms.untracked.bool(True),
fileNames = cms.untracked.vstring(sourceFileList)
)
else:
process.source = cms.Source("PoolSource",
#useCSA08Kludge = cms.untracked.bool(True),
fileNames = cms.untracked.vstring(sourceFileList)
)
import os, sys
if sys.argv[0] == "cmsRun": __file__ = sys.argv[1]
try:
sourceFileList = [_ for _ in sourceFileList if _ not in open(os.path.join(os.path.dirname(__file__), "../../../run/DataFiles/baddatafiles.txt")).read()]
except IOError:
pass

process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(sourceFileList)
)

if hasattr(optpy, "LumiJSON"):
import FWCore.PythonUtilities.LumiList as LumiList
Expand Down
127 changes: 127 additions & 0 deletions Alignment/HIPAlignmentAlgorithm/scripts/hippyaddtobaddatafiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#!/usr/bin/env python

from __future__ import print_function

import argparse, contextlib, os, re, shutil, subprocess, tempfile, time

if __name__ == "__main__":
def abspath(path):
if not os.path.exists(path): raise ValueError(path+" does not exist")
return os.path.abspath(path)

p = argparse.ArgumentParser()
p.add_argument("cfgfile", type=abspath)
p.add_argument("baddatafileslist", nargs="?", default=None)
args = p.parse_args()

def runcfg(cfgfile, badfilelist):
try:
subprocess.check_output(["cmsRun", cfgfile], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
if "FallbackFileOpenError" in e.output:
output = e.output.split("An exception of category 'FallbackFileOpenError' occurred while")[1]
filename = re.search("Failed to open the file '[^']*(/store/.*[.]root)", output).group(1)
with OneAtATime(badfilelist+".tmp", 2) as f:
with open(badfilelist) as f:
contents = set(f.read().split())
if filename in contents:
raise RuntimeError(filename+"\nis already in\n"+badfilelist+"\n\nExiting to avoid an infinite loop. Maybe you have this running on the same cfg file multiple times?")
contents.add(filename)
contents = sorted(contents)
with open(badfilelist, "w") as f:
f.write("\n".join(contents)+"\n")
print("found and added a bad file:\n"+filename)
else:
raise
return runcfg(cfgfile, badfilelist)
print("all files left are good")

@contextlib.contextmanager
def cd(newdir):
"""http://stackoverflow.com/a/24176022/5228524"""
prevdir = os.getcwd()
os.chdir(os.path.expanduser(newdir))
try:
yield
finally:
os.chdir(prevdir)

def cdtemp(): return cd(tempfile.mkdtemp())

class KeepWhileOpenFile(object):
def __init__(self, name, message=None):
self.filename = name
self.__message = message
self.pwd = os.getcwd()
self.fd = self.f = None
self.bool = False

@property
def wouldbevalid(self):
if self: return True
with self:
return bool(self)

def __open(self):
self.fd = os.open(self.filename, os.O_CREAT | os.O_EXCL | os.O_WRONLY)

def __enter__(self):
with cd(self.pwd):
try:
self.__open()
except OSError:
return None

self.f = os.fdopen(self.fd, 'w')

try:
if self.__message is not None:
self.f.write(self.__message+"\n")
except IOError:
pass
try:
self.f.close()
except IOError:
pass
self.bool = True
return True

def __exit__(self, *args):
if self:
try:
with cd(self.pwd):
os.remove(self.filename)
except OSError:
pass #ignore it
self.fd = self.f = None
self.bool = False

def __nonzero__(self):
return self.bool

class OneAtATime(KeepWhileOpenFile):
def __init__(self, name, delay, message=None, printmessage=None, task="doing this"):
super(OneAtATime, self).__init__(name, message=message)
self.delay = delay
if printmessage is None:
printmessage = "Another process is already {task}! Waiting {delay} seconds."
printmessage = printmessage.format(delay=delay, task=task)
self.__printmessage = printmessage

def __enter__(self):
while True:
result = super(OneAtATime, self).__enter__()
if result:
return result
print(self.__printmessage)
time.sleep(self.delay)

if __name__ == "__main__":
with cdtemp():
shutil.copy(args.cfgfile, ".")

badfilelist = args.badfilelist
if badfilelist is None:
badfilelist = os.path.join(os.path.dirname(cfgfile, "../../../run/DataFiles/baddatafiles.txt"))

runcfg(os.path.basename(args.cfgfile), args.badfilelist)
10 changes: 9 additions & 1 deletion Alignment/HIPAlignmentAlgorithm/scripts/makeHippyCampaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():
parser.add_argument("--cmssw", default=os.environ["CMSSW_VERSION"])
parser.add_argument("--scram-arch", default=os.environ["SCRAM_ARCH"])
parser.add_argument("--subfolder", default="", help="subfolder within "+basedir+" to make 'foldername' in.")
parser.add_argument("--merge-topic", action="append", help="things to cms-merge-topic within the CMSSW release created")
parser.add_argument("--merge-topic", action="append", help="things to cms-merge-topic within the CMSSW release created", default=[])
parser.add_argument("--print-sys-path", action="store_true", help=argparse.SUPPRESS) #internal, don't use this
args = parser.parse_args()

Expand Down Expand Up @@ -80,6 +80,14 @@ def main():
f.write(os.path.join(os.getcwd(), "cosmics.txt") + ",,COSMICS,Datatype:1 APVMode:deco Bfield:3.8T\n")
f.write(os.path.join(os.getcwd(), "CDCs.txt") + ",,CDCS,Datatype:1 APVMode:deco Bfield:3.8T\n")
subprocess.check_call(["git", "add", "data_example.lst"])
if not os.path.exists("baddatafiles.txt"):
with open("baddatafiles.txt", "w") as f:
f.write("If any data files are bad (e.g. not at CERN), put them here,\n")
f.write("separated by newlines or spaces or nothing or whatever you like.\n")
f.write("Anything else in this file, like these lines, will be ignored.\n")
f.write("You can also run hippyaddtobaddatafiles.py .../align_cfg.py to automatically\n")
f.write("find bad data files.\n")
f.write("Running jobs will automatically pick up changes here next time they resubmit.")

mkdir_p("IOV")
with cd("IOV"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extraopts="--redirectproxy"
#alignmentname=pick a name
#niterations=pick a number

[ -e $lstfile ] || echo "$lstfile does not exist!"
[ -e $common ] || echo "$common does not exist!"
[ -e $IOVfile ] || echo "$IOVfile does not exist!"
[ -e $lstfile ] || (echo "$lstfile does not exist!"; exit 1)
[ -e $common ] || (echo "$common does not exist!"; exit 1)
[ -e $IOVfile ] || (echo "$IOVfile does not exist!"; exit 1)

commitid=$(git rev-parse HEAD)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ void EcalTrivialObjectAnalyzer::analyze(const edm::Event& e, const edm::EventSet

// laser timestamps
EcalLaserAPDPNRatios::EcalLaserTimeStamp ltimestamp;
EcalLaserAPDPNRatios::EcalLaserTimeStampMap::const_iterator ltimeit;
for (int i=1; i<=92; i++) {
ltimestamp = lratio->getTimeMap()[i];
std::cout << "i = " << std::setprecision(6) << i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ class SiPixelQualityESProducer : public edm::ESProducer, public edm::EventSetupR


/* virtual*/ std::unique_ptr<SiPixelQuality> produce(const SiPixelQualityRcd & iRecord) ;
/* virtual*/ std::unique_ptr<SiPixelQuality> produceWithLabel(const SiPixelQualityRcd & iRecord);

protected:
protected:

void setIntervalFor( const edm::eventsetup::EventSetupRecordKey&,
const edm::IOVSyncValue&,
Expand All @@ -54,10 +55,11 @@ class SiPixelQualityESProducer : public edm::ESProducer, public edm::EventSetupR

private:

std::string label;
edm::FileInPath fp_;
typedef std::vector< edm::ParameterSet > Parameters;
Parameters toGet;


std::unique_ptr<SiPixelQuality> get_pointer(const SiPixelQualityRcd & iRecord, std::string label);
};
#endif
46 changes: 29 additions & 17 deletions CalibTracker/SiPixelESProducers/plugins/SiPixelQualityESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@ using namespace edm;

SiPixelQualityESProducer::SiPixelQualityESProducer(const edm::ParameterSet& conf_)
: //fp_(conf_.getParameter<edm::FileInPath>("file")),
toGet(conf_.getParameter<Parameters>("ListOfRecordToMerge"))
label(conf_.exists("siPixelQualityLabel")?conf_.getParameter<std::string>("siPixelQualityLabel"):""),
toGet(conf_.getParameter<Parameters>("ListOfRecordToMerge"))
{
edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
edm::LogInfo("SiPixelQualityESProducer::SiPixelQualityESProducer");
//the following line is needed to tell the framework what
// data is being produced
setWhatProduced(this);
findingRecord<SiPixelQualityRcd>();
if (label == "forDigitizer"){
setWhatProduced(this, &SiPixelQualityESProducer::produceWithLabel, edm::es::Label(label));
}
findingRecord<SiPixelQualityRcd>();
}


SiPixelQualityESProducer::~SiPixelQualityESProducer()
{

Expand All @@ -55,8 +58,8 @@ SiPixelQualityESProducer::~SiPixelQualityESProducer()

}

std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd & iRecord)
{
std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::get_pointer(const SiPixelQualityRcd & iRecord, std::string label){

std::string recordName;

Expand All @@ -72,32 +75,41 @@ std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQ
//SiPixelQuality::disabledModuleType BadModule;
//BadModule.DetID = 1; BadModule.errorType = 0; BadModule.BadRocs = 65535; obj->addDisabledModule(BadModule);

//start with the record thta existed already to decouple the debugging
//start with the record thta existed already to decouple the debugging
//here i can do whatever i need with the detVoff

edm::ESHandle<SiStripDetVOff> Voff;
edm::ESHandle<SiPixelQuality> dbobject;

for( Parameters::iterator itToGet = toGet.begin(); itToGet != toGet.end(); ++itToGet ) {

recordName = itToGet->getParameter<std::string>("record");

if (recordName=="SiPixelDetVOffRcd")
iRecord.getRecord<SiPixelDetVOffRcd>().get(Voff);
if (recordName=="SiPixelQualityFromDbRcd")
iRecord.getRecord<SiPixelQualityFromDbRcd>().get(dbobject);
iRecord.getRecord<SiPixelDetVOffRcd>().get(Voff);
if (recordName=="SiPixelQualityFromDbRcd"){
iRecord.getRecord<SiPixelQualityFromDbRcd>().get(label, dbobject);
}
} //end getting the records from the parameters

//now the dbobject is the one copied from the db
//here make a copy of dbobject, but now the label has to be empty not to interfeare with the Reco
auto dbptr = std::make_unique<SiPixelQuality>(*(dbobject));

//here is the magic line in which it switches off Bad Modules
dbptr->add(Voff.product());

return dbptr;
}


std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produce(const SiPixelQualityRcd & iRecord)
{
return get_pointer(iRecord, "");
}
std::unique_ptr<SiPixelQuality> SiPixelQualityESProducer::produceWithLabel(const SiPixelQualityRcd & iRecord)
{
return get_pointer(iRecord, label);
}

void SiPixelQualityESProducer::setIntervalFor( const edm::eventsetup::EventSetupRecordKey&,
const edm::IOVSyncValue& iosv,
edm::ValidityInterval& oValidity ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import FWCore.ParameterSet.Config as cms

siPixelQualityESProducer = cms.ESProducer("SiPixelQualityESProducer",
ListOfRecordToMerge = cms.VPSet(
cms.PSet( record = cms.string( "SiPixelQualityFromDbRcd" ),
tag = cms.string( "" )
),
cms.PSet( record = cms.string( "SiPixelDetVOffRcd" ),
tag = cms.string( "" )
)
)
)
siPixelQualityESProducer = cms.ESProducer(
"SiPixelQualityESProducer",
ListOfRecordToMerge = cms.VPSet(
cms.PSet( record = cms.string( "SiPixelQualityFromDbRcd" ),
tag = cms.string( "" )
),
cms.PSet( record = cms.string( "SiPixelDetVOffRcd" ),
tag = cms.string( "" )
)
),
siPixelQualityLabel = cms.string(""),
)
1 change: 1 addition & 0 deletions CondCore/Utilities/plugins/Module_2XML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ PAYLOAD_2XML_MODULE( pluginUtilities_payload2xml ){
PAYLOAD_2XML_CLASS( EcalSRSettings );
PAYLOAD_2XML_CLASS( EcalSampleMask );
PAYLOAD_2XML_CLASS( EcalSamplesCorrelation );
PAYLOAD_2XML_CLASS( EcalSimPulseShape );
PAYLOAD_2XML_CLASS( EcalTBWeights );
PAYLOAD_2XML_CLASS( EcalTPGFineGrainEBGroup );
PAYLOAD_2XML_CLASS( EcalTPGFineGrainEBIdMap );
Expand Down
1 change: 1 addition & 0 deletions CondCore/Utilities/src/CondFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
#include "CondFormats/EcalObjects/interface/EcalTPGWeightGroup.h"
#include "CondFormats/EcalObjects/interface/EcalTPGWeightIdMap.h"
#include "CondFormats/EcalObjects/interface/EcalWeightXtalGroups.h"
#include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h"
#include "CondFormats/Common/interface/FileBlob.h"
//#include "CondFormats/GeometryObjects/interface/GeometryFile.h"
#include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
Expand Down
1 change: 1 addition & 0 deletions CondTools/Ecal/interface/XMLTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace xuti{
const std::string rms1_tag("rms_x1");

const std::string PulseShapes_tag("EcalPulseShapes");
const std::string SimPulseShape_tag("EcalSimPulseShape");
const std::string sample0_tag("sample_0");
const std::string sample1_tag("sample_1");
const std::string sample2_tag("sample_2");
Expand Down
Loading

0 comments on commit 4468872

Please sign in to comment.