From 83ac7825ebe4771326a5a3427a76429d918c2d43 Mon Sep 17 00:00:00 2001 From: Bruno Date: Fri, 13 Mar 2015 19:45:31 +0100 Subject: [PATCH 1/9] use expandvars in case the path contains an environmental variable --- PhysicsTools/Heppy/python/analyzers/core/JSONAnalyzer.py | 3 ++- PhysicsTools/Heppy/python/analyzers/core/PileUpAnalyzer.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/PhysicsTools/Heppy/python/analyzers/core/JSONAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/core/JSONAnalyzer.py index db3d9a9980c6..f767f536c400 100644 --- a/PhysicsTools/Heppy/python/analyzers/core/JSONAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/core/JSONAnalyzer.py @@ -1,4 +1,5 @@ import json +import os from PhysicsTools.Heppy.analyzers.core.Analyzer import Analyzer from FWCore.PythonUtilities.LumiList import LumiList @@ -31,7 +32,7 @@ def __init__(self, cfg_ana, cfg_comp, looperName): if not cfg_comp.isMC: if self.cfg_comp.json is None: raise ValueError('component {cname} is not MC, and contains no JSON file. Either remove the JSONAnalyzer for your path or set the "json" attribute of this component'.format(cname=cfg_comp.name)) - self.lumiList = LumiList(self.cfg_comp.json) + self.lumiList = LumiList(os.path.expandvars(self.cfg_comp.json)) else: self.lumiList = None diff --git a/PhysicsTools/Heppy/python/analyzers/core/PileUpAnalyzer.py b/PhysicsTools/Heppy/python/analyzers/core/PileUpAnalyzer.py index d09dbb62e7eb..96d65c0492a4 100644 --- a/PhysicsTools/Heppy/python/analyzers/core/PileUpAnalyzer.py +++ b/PhysicsTools/Heppy/python/analyzers/core/PileUpAnalyzer.py @@ -62,8 +62,8 @@ def __init__(self, cfg_ana, cfg_comp, looperName): if not hasattr(self.cfg_comp,"puFileMC") or (self.cfg_comp.puFileMC is None and self.cfg_comp.puFileData is None): self.enable = False else: - assert( os.path.isfile(self.cfg_comp.puFileMC) ) - assert( os.path.isfile(self.cfg_comp.puFileData) ) + assert( os.path.isfile(os.path.expandvars(self.cfg_comp.puFileMC)) ) + assert( os.path.isfile(os.path.expandvars(self.cfg_comp.puFileData)) ) self.mcfile = TFile( self.cfg_comp.puFileMC ) self.mchist = self.mcfile.Get('pileup') From a5480134593b8f9048284b3ae58a588fdf597533 Mon Sep 17 00:00:00 2001 From: Bruno Date: Fri, 13 Mar 2015 19:49:16 +0100 Subject: [PATCH 2/9] use $CMSSW_BASE to define dataDir path --- CMGTools/TTHAnalysis/python/samples/samples_13TeV_PHYS14.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMGTools/TTHAnalysis/python/samples/samples_13TeV_PHYS14.py b/CMGTools/TTHAnalysis/python/samples/samples_13TeV_PHYS14.py index c336b00605a4..49fa4ae8caef 100644 --- a/CMGTools/TTHAnalysis/python/samples/samples_13TeV_PHYS14.py +++ b/CMGTools/TTHAnalysis/python/samples/samples_13TeV_PHYS14.py @@ -361,7 +361,8 @@ #-----------DATA--------------- -dataDir = os.environ['CMSSW_BASE']+"/src/CMGTools/TTHAnalysis/data" +#dataDir = os.environ['CMSSW_BASE']+"/src/CMGTools/TTHAnalysis/data" +dataDir = "$CMSSW_BASE/src/CMGTools/TTHAnalysis/data" # use environmental variable, useful for instance to run on CRAB #lumi: 12.21+7.27+0.134 = 19.62 /fb @ 8TeV json=dataDir+'/json/Cert_Run2012ABCD_22Jan2013ReReco.json' From ac7eff8dce7ea0e8a449a33887a52bfc3a2b37be Mon Sep 17 00:00:00 2001 From: Bruno Date: Fri, 13 Mar 2015 20:04:07 +0100 Subject: [PATCH 3/9] crab tools --- .../cfg/crab/FrameworkJobReport.xml | 17 +++ CMGTools/TTHAnalysis/cfg/crab/heppy_config.py | 1 + .../TTHAnalysis/cfg/crab/heppy_crab_config.py | 30 ++++++ .../cfg/crab/heppy_crab_config_env.py | 45 ++++++++ .../cfg/crab/heppy_crab_fake_pset.py | 6 ++ .../TTHAnalysis/cfg/crab/heppy_crab_script.py | 101 ++++++++++++++++++ .../TTHAnalysis/cfg/crab/heppy_crab_script.sh | 32 ++++++ CMGTools/TTHAnalysis/cfg/crab/launchall.py | 29 +++++ 8 files changed, 261 insertions(+) create mode 100644 CMGTools/TTHAnalysis/cfg/crab/FrameworkJobReport.xml create mode 120000 CMGTools/TTHAnalysis/cfg/crab/heppy_config.py create mode 100644 CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config.py create mode 100644 CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py create mode 100644 CMGTools/TTHAnalysis/cfg/crab/heppy_crab_fake_pset.py create mode 100644 CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.py create mode 100755 CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.sh create mode 100755 CMGTools/TTHAnalysis/cfg/crab/launchall.py diff --git a/CMGTools/TTHAnalysis/cfg/crab/FrameworkJobReport.xml b/CMGTools/TTHAnalysis/cfg/crab/FrameworkJobReport.xml new file mode 100644 index 000000000000..fd947d385b92 --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/FrameworkJobReport.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_config.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_config.py new file mode 120000 index 000000000000..f3fa79017c6a --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_config.py @@ -0,0 +1 @@ +../run_susyMT2_cfg.py \ No newline at end of file diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config.py new file mode 100644 index 000000000000..27327eab575e --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config.py @@ -0,0 +1,30 @@ +from WMCore.Configuration import Configuration +config = Configuration() + +config.section_("General") +config.General.transferLogs = True + +config.section_("JobType") +config.JobType.pluginName = 'PrivateMC' +config.JobType.psetName = 'heppy_crab_fake_pset.py' +config.JobType.scriptExe = 'heppy_crab_script.sh' +# config.JobType.sendPythonFolder = True #doesn't work, not supported yet? do it by hand +import os +os.system("tar czf python.tar.gz --dereference --directory $CMSSW_BASE python") +os.system("tar czf cmgdataset.tar.gz --directory $HOME .cmgdataset") +os.system("tar czf cafpython.tar.gz --directory /afs/cern.ch/cms/caf/ python") +config.JobType.inputFiles = ['FrameworkJobReport.xml','heppy_config.py','heppy_crab_script.py','cmgdataset.tar.gz', 'python.tar.gz', 'cafpython.tar.gz'] +config.JobType.outputFiles = ['output.log.tgz'] # mt2.root is automatically send because of the pset file + +config.section_("Data") +config.Data.inputDBS = 'global' +config.Data.splitting = 'EventBased' +config.Data.outLFN = '/store/user/' + os.environ["USER"] +config.Data.publication = False + +config.section_("Site") +#config.Site.whitelist = ["T2_CH_CSCS"] +config.Site.whitelist = ["T2_CH_CSCS", "T2_IT_Legnaro", "T2_UK_London_IC", "T2_UK_SGrid_Bristol", "T2_DE_DESY", "T2_ES_CIEMAT", "T2_IT_Rome", "T2_UK_London_Brunel", "T2_AT_Vienna","T2_DE_RWTH","T2_FR_GRIF_IRFU", "T2_HU_Budapest"] #, "T2_FR_IPHC", "T2_BE_IIHE", "T2_IT_Pisa", "T2_ES_IFCA"] , "T2_PK_NCP", "T2_US_Purdue", "T2_UA_KIPT", "T2_KR_KNU", "T2_RU_IHEP", "T2_RU_INR", "T2_RU_JINR", "T2_US_MIT", "T2_US_Wisconsin", "T2_US_UCSD", "T2_US_Vanderbilt", "T2_US_Caltech"] +config.Site.storageSite = "T3_CH_PSI" +#config.Data.ignoreLocality = True + diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py new file mode 100644 index 000000000000..06413045047d --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py @@ -0,0 +1,45 @@ +# here we set all crab options that are not fixed +# values we'll be taken from environment variables set in launchall.py +# fixed options will be taken from heppy_crab_config.py + +import imp +file = open( "heppy_crab_config.py", 'r' ) +cfg = imp.load_source( 'cfg', "heppy_crab_config.py", file) +config = cfg.config +import os +import re +dataset=os.environ["DATASET"] +NJOBS=int(os.environ["NJOBS"]) +production_label = os.environ["PROD_LABEL"] +cmg_version = os.environ["CMG_VERSION"] + +print dataset, NJOBS + +config.General.requestName = dataset + "_" + cmg_version # task name +config.General.workArea = 'crab_' + production_label # crab dir name + +# this will divide task in *exactly* NJOBS jobs (for this we need JobType.pluginName = 'PrivateMC' and Data.splitting = 'EventBased') +config.Data.unitsPerJob = 10 +config.Data.totalUnits = config.Data.unitsPerJob * NJOBS + +# arguments to pass to scriptExe. They have to be like "arg=value". +config.JobType.scriptArgs = ["dataset="+dataset, "total="+str(NJOBS)] + +# output will be .../$outLFN/$PRIMARY_DS/$PUBLISH_NAME/$TIMESTAMP/$COUNTER/$FILENAME +# https://twiki.cern.ch/twiki/bin/view/CMSPublic/Crab3DataHandling +config.Data.outLFN += '/babies/' + cmg_version +config.Data.primaryDataset = production_label +config.Data.publishDataName = dataset +#final output: /store/user/$USER/babies/cmg_version/production_label/dataset/150313_114158/0000/foo.bar + +# uncomment for test purposes +# NJOBS = 2 +# NEVENTS = 200 + +# if NEVENTS variable is set then only nevents will be run +try: + NEVENTS +except NameError: + pass +else: + config.JobType.scriptArgs += ["nevents="+str(NEVENTS)] diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_fake_pset.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_fake_pset.py new file mode 100644 index 000000000000..42455cf27abd --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_fake_pset.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms +process = cms.Process('FAKE') +process.source = cms.Source("PoolSource", fileNames = cms.untracked.vstring()) +process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(10)) +process.output = cms.OutputModule("PoolOutputModule", fileName = cms.untracked.string('mt2.root')) +process.out = cms.EndPath(process.output) diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.py new file mode 100644 index 000000000000..91e5239d7c00 --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python +import os +import PhysicsTools.HeppyCore.framework.config as cfg +#cfg.Analyzer.nosubdir=True + +import ROOT +from DataFormats.FWLite import * +import sys +import re +#import PSet + +ROOT.gSystem.Load("libCMGToolsTTHAnalysis") +ROOT.gSystem.Load("libFWCoreFWLite.so") +ROOT.gSystem.Load("libDataFormatsFWLite.so") +ROOT.gSystem.Load("libPhysicsToolsHeppy") +ROOT.gSystem.Load("libCMGToolsRootTools") +ROOT.AutoLibraryLoader.enable() + +dataset = "" +total = 0 # total number of jobs for given dataset, not used at the moment +nevents = None # this means run all events +nprint = 0 # quiet printout, change if you want to print the first nprint events + +# arguments of scriptExe +print "ARGV:",sys.argv +JobNumber=sys.argv[1] # 1st crab argument is jobID +job = int(JobNumber) +# if one wants to include more options to be passed to the crab scriptExe add a corresponding argument below +# crab only allows arguments of the type 'arg=value' +for arg in sys.argv[2:]: + if arg.split("=")[0] == "dataset": # this argument is strictly necessary + dataset = arg.split("=")[1] + elif arg.split("=")[0] == "total": + total = int(arg.split("=")[1]) + elif arg.split("=")[0] == "nevents": + nevents = int(arg.split("=")[1]) + print "selected to run over", nevents, "events" + +print "dataset:", dataset +print "job", job , " out of", total + +# fetch config file +import imp +handle = open("heppy_config.py", 'r') +cfo = imp.load_source("heppy_config", "heppy_config.py", handle) +config = cfo.config +handle.close() + +# pick right component from dataset and file from jobID +selectedComponents = [] +for comp in config.components: + if comp.name == dataset: + comp.files = comp.files[job-1: job] # first job number is 1 + comp.name = comp.name+"_Chunk"+str(job) + selectedComponents.append(comp) + +# check selectedComponents +if len(selectedComponents) == 0: + print "No selected components found!!" + print " - dataset:", dataset + print " - components:", config.components +if len(selectedComponents)>1: + print "More than one selected component:" + cfg.printComps(selectedComponents) +else: + print "Selected component:" + print selectedComponents[0] + print "files: ", selectedComponents[0].files + +# set component to run +config.components = selectedComponents + +# run!!! +from PhysicsTools.HeppyCore.framework.looper import Looper +looper = Looper( 'Output', config, nPrint = nprint, nEvents = nevents) +looper.loop() +looper.write() + +#os.system("ls -lR") # for debugging + +# assign the right name +os.rename("Output/mt2.root", "mt2.root") + +# print in crab log file the content of the job log files, so one can see it from 'crab getlog' +print "-"*25 +print "printing output txt files" +os.system('for i in Output/*.txt; do echo $i; cat $i; echo "---------"; done') + +# pack job log files to be sent to output site +os.system("tar czf output.log.tgz Output/") +#os.system("mkdir log") +#os.rename("output.log.tgz log/output.log.tgz") + + +import ROOT +f=ROOT.TFile.Open('mt2.root') +entries=f.Get('tree').GetEntries() +f.Close() + +print entries, "events processed" +print "job succesful" diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.sh b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.sh new file mode 100755 index 000000000000..63383b624fa3 --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_script.sh @@ -0,0 +1,32 @@ +# extract exported necessary stuff +tar xzf cmgdataset.tar.gz --directory $HOME +tar xzf python.tar.gz --directory $CMSSW_BASE +tar xzf cafpython.tar.gz --directory $CMSSW_BASE + +# uncomment for debuging purposes + +#ls -lR . +#echo "ARGS:" +#echo $@ +#echo "ENV..................................." +#env +#echo "VOMS" +#voms-proxy-info -all +#echo "CMSSW BASE, python path, pwd, home" +#echo $CMSSW_BASE +#echo $PYTHONPATH +#echo $PWD +#echo $HOME + +# copy auxiliarity data to the right place (json, pu, lep eff, jet corr, ...) +cp lib/slc*/* $CMSSW_BASE/lib/slc* +for i in `find src/ -name data -type d` +do + echo $i + mkdir -p $CMSSW_BASE/$i + cp -r $i/* $CMSSW_BASE/$i +done + +#ls -lR + +python heppy_crab_script.py $@ diff --git a/CMGTools/TTHAnalysis/cfg/crab/launchall.py b/CMGTools/TTHAnalysis/cfg/crab/launchall.py new file mode 100755 index 000000000000..3ae467781423 --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/launchall.py @@ -0,0 +1,29 @@ +import imp, os + +# datasets to run as defined from run_susyMT2.cfg +# right now configured for maximal job splitting +# in principle one only needs to modify the following two lines: +production_label = "fullProd_test3" +cmg_version = 'MT2_CMGTools-from-CMSSW_7_2_3' + +handle = open("heppy_config.py", 'r') +cfo = imp.load_source("heppy_config", "heppy_config.py", handle) +conf = cfo.config +handle.close() + +os.system("scramv1 runtime -sh") +os.system("source /cvmfs/cms.cern.ch/crab3/crab.sh") + +os.environ["PROD_LABEL"] = production_label +os.environ["CMG_VERSION"] = cmg_version + +for comp in conf.components: + #set maximal splitting + NJOBS = len(comp.files) + os.environ["NJOBS"] = str(NJOBS) + os.environ["DATASET"] = str(comp.name) + os.system("crab submit -c heppy_crab_config_env.py") + +os.system("rm -f python.tar.gz") +os.system("rm -f cmgdataset.tar.gz") +os.system("rm -f cafpython.tar.gz") From be1270c5633dc83d03d45168d7a2f7afd0614413 Mon Sep 17 00:00:00 2001 From: Bruno Date: Fri, 13 Mar 2015 20:38:46 +0100 Subject: [PATCH 4/9] fix in debugging option --- CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py index 06413045047d..00c0fade870b 100644 --- a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py @@ -2,6 +2,8 @@ # values we'll be taken from environment variables set in launchall.py # fixed options will be taken from heppy_crab_config.py +debug = False + import imp file = open( "heppy_crab_config.py", 'r' ) cfg = imp.load_source( 'cfg', "heppy_crab_config.py", file) @@ -22,6 +24,10 @@ config.Data.unitsPerJob = 10 config.Data.totalUnits = config.Data.unitsPerJob * NJOBS +if debug: + NJOBS = 2 + NEVENTS = 200 + # arguments to pass to scriptExe. They have to be like "arg=value". config.JobType.scriptArgs = ["dataset="+dataset, "total="+str(NJOBS)] @@ -32,10 +38,6 @@ config.Data.publishDataName = dataset #final output: /store/user/$USER/babies/cmg_version/production_label/dataset/150313_114158/0000/foo.bar -# uncomment for test purposes -# NJOBS = 2 -# NEVENTS = 200 - # if NEVENTS variable is set then only nevents will be run try: NEVENTS From 37f3410849e3daf537e46421a726564bb452c006 Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 14 Mar 2015 00:01:51 +0100 Subject: [PATCH 5/9] yet again another fix for debugging option --- CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py index 00c0fade870b..9f5c56ee2ea2 100644 --- a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py @@ -2,7 +2,7 @@ # values we'll be taken from environment variables set in launchall.py # fixed options will be taken from heppy_crab_config.py -debug = False +debug = True import imp file = open( "heppy_crab_config.py", 'r' ) @@ -17,6 +17,10 @@ print dataset, NJOBS +if debug: + NJOBS = 2 + NEVENTS = 200 + config.General.requestName = dataset + "_" + cmg_version # task name config.General.workArea = 'crab_' + production_label # crab dir name @@ -24,10 +28,6 @@ config.Data.unitsPerJob = 10 config.Data.totalUnits = config.Data.unitsPerJob * NJOBS -if debug: - NJOBS = 2 - NEVENTS = 200 - # arguments to pass to scriptExe. They have to be like "arg=value". config.JobType.scriptArgs = ["dataset="+dataset, "total="+str(NJOBS)] From 377edace35795fc962c734ef9fb7052aeccdcae2 Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 14 Mar 2015 01:39:07 +0100 Subject: [PATCH 6/9] MagneticField/ParametrizedEngine package from CMSSW_7_3_X --- .../ParametrizedEngine/BuildFile.xml | 9 ++ .../ParametrizedMagneticFieldFactory.h | 45 ++++++ .../ParametrizedEngine/plugins/BuildFile.xml | 1 + .../OAE85lParametrizedMagneticField.cc | 135 ---------------- .../plugins/OAE85lParametrizedMagneticField.h | 56 ------- .../ParametrizedMagneticFieldProducer.cc | 35 +---- .../{plugins => src}/BCyl.h | 0 .../{plugins => src}/BFit.cc | 0 .../{plugins => src}/BFit.h | 0 .../{plugins => src}/BFit3D.cc | 0 .../{plugins => src}/BFit3D.h | 0 .../{plugins => src}/BFit3D_data.h | 0 .../{plugins => src}/HarmBasis3DCyl.cc | 0 .../{plugins => src}/HarmBasis3DCyl.h | 0 .../OAEParametrizedMagneticField.cc | 3 + .../OAEParametrizedMagneticField.h | 9 +- .../ParabolicParametrizedMagneticField.cc | 21 ++- .../ParabolicParametrizedMagneticField.h | 16 +- .../src/ParametrizedMagneticFieldFactory.cc | 78 ++++++++++ .../PolyFit2DParametrizedMagneticField.cc | 0 .../PolyFit2DParametrizedMagneticField.h | 0 .../{plugins => src}/TkBfield.cc | 15 +- .../{plugins => src}/TkBfield.h | 5 +- .../{plugins => src}/poly2d_base.cc | 0 .../{plugins => src}/poly2d_base.h | 0 .../{plugins => src}/rz_harm_poly.cc | 0 .../{plugins => src}/rz_harm_poly.h | 0 .../{plugins => src}/rz_poly.cc | 0 .../{plugins => src}/rz_poly.h | 0 .../ParametrizedEngine/test/BuildFile.xml | 12 -- .../test/MagneticFieldPlotter.cc | 146 ------------------ .../test/MagneticFieldPlotter.h | 65 -------- .../ParametrizedEngine/test/TKBfield_t.cpp | 18 --- .../ParametrizedEngine/test/res60.out | 81 ---------- .../ParametrizedEngine/test/res61.out | 81 ---------- 35 files changed, 188 insertions(+), 643 deletions(-) create mode 100644 MagneticField/ParametrizedEngine/BuildFile.xml create mode 100644 MagneticField/ParametrizedEngine/interface/ParametrizedMagneticFieldFactory.h delete mode 100644 MagneticField/ParametrizedEngine/plugins/OAE85lParametrizedMagneticField.cc delete mode 100644 MagneticField/ParametrizedEngine/plugins/OAE85lParametrizedMagneticField.h rename MagneticField/ParametrizedEngine/{plugins => src}/BCyl.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/BFit.cc (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/BFit.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/BFit3D.cc (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/BFit3D.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/BFit3D_data.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/HarmBasis3DCyl.cc (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/HarmBasis3DCyl.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/OAEParametrizedMagneticField.cc (93%) rename MagneticField/ParametrizedEngine/{plugins => src}/OAEParametrizedMagneticField.h (80%) rename MagneticField/ParametrizedEngine/{plugins => src}/ParabolicParametrizedMagneticField.cc (72%) rename MagneticField/ParametrizedEngine/{plugins => src}/ParabolicParametrizedMagneticField.h (73%) create mode 100644 MagneticField/ParametrizedEngine/src/ParametrizedMagneticFieldFactory.cc rename MagneticField/ParametrizedEngine/{plugins => src}/PolyFit2DParametrizedMagneticField.cc (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/PolyFit2DParametrizedMagneticField.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/TkBfield.cc (83%) rename MagneticField/ParametrizedEngine/{plugins => src}/TkBfield.h (84%) rename MagneticField/ParametrizedEngine/{plugins => src}/poly2d_base.cc (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/poly2d_base.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/rz_harm_poly.cc (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/rz_harm_poly.h (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/rz_poly.cc (100%) rename MagneticField/ParametrizedEngine/{plugins => src}/rz_poly.h (100%) delete mode 100644 MagneticField/ParametrizedEngine/test/BuildFile.xml delete mode 100644 MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.cc delete mode 100644 MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.h delete mode 100644 MagneticField/ParametrizedEngine/test/TKBfield_t.cpp delete mode 100644 MagneticField/ParametrizedEngine/test/res60.out delete mode 100644 MagneticField/ParametrizedEngine/test/res61.out diff --git a/MagneticField/ParametrizedEngine/BuildFile.xml b/MagneticField/ParametrizedEngine/BuildFile.xml new file mode 100644 index 000000000000..ab054d245fea --- /dev/null +++ b/MagneticField/ParametrizedEngine/BuildFile.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/MagneticField/ParametrizedEngine/interface/ParametrizedMagneticFieldFactory.h b/MagneticField/ParametrizedEngine/interface/ParametrizedMagneticFieldFactory.h new file mode 100644 index 000000000000..97e91df3c967 --- /dev/null +++ b/MagneticField/ParametrizedEngine/interface/ParametrizedMagneticFieldFactory.h @@ -0,0 +1,45 @@ +#ifndef ParametrizedMagneticFieldFactory_h +#define ParametrizedMagneticFieldFactory_h + +/** \class ParametrizedMagneticFieldFactory + * + * Create a parametrized field map with the specified configuration. + * + * \author N. Amapane - Torino + */ + + +#include +#include +#include +#include + +namespace edm{ + class ParameterSet; +} + +namespace magneticfield{ + class ParametrizedMagneticFieldProducer; + class VolumeBasedMagneticFieldESProducerFromDB; +} + +class ParametrizedMagneticFieldFactory { + public: + /// Constructor + ParametrizedMagneticFieldFactory(); + + private: + friend class magneticfield::ParametrizedMagneticFieldProducer; + friend class magneticfield::VolumeBasedMagneticFieldESProducerFromDB; + + // Get map configured from pset (deprecated) + std::auto_ptr + static get(std::string version, const edm::ParameterSet& parameters); + + // Get map configured from type name and numerical parameters + std::auto_ptr + static get(std::string version, std::vector parameters); + +}; +#endif + diff --git a/MagneticField/ParametrizedEngine/plugins/BuildFile.xml b/MagneticField/ParametrizedEngine/plugins/BuildFile.xml index 2c90d517ede2..94644847e5ff 100644 --- a/MagneticField/ParametrizedEngine/plugins/BuildFile.xml +++ b/MagneticField/ParametrizedEngine/plugins/BuildFile.xml @@ -3,6 +3,7 @@ + diff --git a/MagneticField/ParametrizedEngine/plugins/OAE85lParametrizedMagneticField.cc b/MagneticField/ParametrizedEngine/plugins/OAE85lParametrizedMagneticField.cc deleted file mode 100644 index 9e606e7aec7a..000000000000 --- a/MagneticField/ParametrizedEngine/plugins/OAE85lParametrizedMagneticField.cc +++ /dev/null @@ -1,135 +0,0 @@ -/** \file - * - * \author N. Amapane - CERN - */ - -#include "OAE85lParametrizedMagneticField.h" -#include -#include - -#include "TkBfield.h" - -using namespace std; -using namespace magfieldparam; - - -OAE85lParametrizedMagneticField::OAE85lParametrizedMagneticField(float b0_, - float a_, - float l_) - : b0(b0_), - l(l_), - a(a_) -{ - init(); -} - - -OAE85lParametrizedMagneticField::OAE85lParametrizedMagneticField(const edm::ParameterSet& parameters) { - b0 = parameters.getParameter("b0"); - l = parameters.getParameter("l"); - a = parameters.getParameter("a"); - init(); -} - -void OAE85lParametrizedMagneticField::init() { - ap2=4.0*a*a/(l*l); - hb0=0.5*b0*sqrt(1.0+ap2); - hlova=1.0/sqrt(ap2); - ainv=2.0*hlova/l; -} - - - -OAE85lParametrizedMagneticField::~OAE85lParametrizedMagneticField() {} - - -GlobalVector -OAE85lParametrizedMagneticField::inTesla(const GlobalPoint& gp) const { - - if (isDefined(gp)) { - return inTeslaUnchecked(gp); - } else { - edm::LogWarning("MagneticField|FieldOutsideValidity") << " Point " << gp << " is outside the validity region of OAE85lParametrizedMagneticField"; - return GlobalVector(); - } -} - - -GlobalVector -OAE85lParametrizedMagneticField::inTeslaUnchecked(const GlobalPoint& gp) const { - -// Method formerly named "trackerField" - -// -// B-field in Tracker volume -// -// In: xyz[3]: coordinates (m) -// Out: bxyz[3]: Bx,By,Bz (kG) -// -// Valid for r<1.2 and |z|<3.0 V.Karimäki 040301 -// Updated for CMSSW field 070424 -// - -// b0=field at centre, l=solenoid length, a=radius (m) (phenomen. parameters) - - // FIXME: beware of statics... -// static float ap2=4.0*a*a/(l*l); -// static float hb0=0.5*b0*sqrt(1.0+ap2); -// static float hlova=1.0/sqrt(ap2); -// static float ainv=2.0*hlova/l; - float xyz[3];//, bxyz[3]; - // convert to m (CMSSW) - xyz[0]=0.01*gp.x(); - xyz[1]=0.01*gp.y(); - xyz[2]=0.01*gp.z(); - - float r=sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); - float z=xyz[2]; - float az = fabs(z); - // if (r<1.2&&az<3.0) // NOTE: check omitted, is done already by inTesla (NA) - { - float zainv=z*ainv; - float rinv=(r>0.0) ? 1.0/r : 0.0; - float u=hlova-zainv; - float v=hlova+zainv; - float fu[5],gv[5]; - ffunkti(u,fu); - ffunkti(v,gv); - float rat=r*ainv; - float corrr=0.00894*r*z*(az-2.2221)*(az-2.2221); - float corrz=-0.02996*exp(-0.5*(az-1.9820)*(az-1.9820)/(0.78915*0.78915)); - float br=hb0*0.5*rat*(fu[1]-gv[1]-0.125*(fu[3]-gv[3])*rat*rat)+corrr; - float bz=hb0*(fu[0]+gv[0]-(fu[2]+gv[2])*0.25*rat*rat)+corrz; - //bxyz[0]=br*xyz[0]*rinv; - //bxyz[1]=br*xyz[1]*rinv; - //bxyz[2]=bz; - /// GlobalVector bresult(br*xyz[0]*rinv, br*xyz[1]*rinv, bz); - // bvec.x()=0.1*br*xyz[0]*rinv; - //bvec.y()=0.1*br*xyz[1]*rinv; - //bvec.z()=0.1*bz; - return 0.1*GlobalVector(br*xyz[0]*rinv, br*xyz[1]*rinv, bz); - } - // else { - // cout <<"The point is outside the region r<1.2m && |z|<3.0m"< #include @@ -27,9 +25,7 @@ ParametrizedMagneticFieldProducer::ParametrizedMagneticFieldProducer(const edm:: } -ParametrizedMagneticFieldProducer::~ParametrizedMagneticFieldProducer() -{ -} +ParametrizedMagneticFieldProducer::~ParametrizedMagneticFieldProducer(){} std::auto_ptr @@ -38,28 +34,7 @@ ParametrizedMagneticFieldProducer::produce(const IdealMagneticFieldRecord& iReco string version = pset.getParameter("version"); ParameterSet parameters = pset.getParameter("parameters"); - if (version=="OAE_85l_030919") { - // V. Karimaki's off-axis expansion fitted to v85l TOSCA computation - std::auto_ptr result(new OAE85lParametrizedMagneticField(parameters)); - return result; - } else if (version=="OAE_1103l_071212") { - // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation - std::auto_ptr result( new OAEParametrizedMagneticField(parameters)); - return result; - } else if (version=="PolyFit2D") { - // V. Maroussov polynomial fit to mapping data - std::auto_ptr result( new PolyFit2DParametrizedMagneticField(parameters)); - return result; - } else if (version=="PolyFit3D") { - // V. Maroussov polynomial fit to mapping data - throw cms::Exception("InvalidParameter")<<"PolyFit3D is not supported anymore"; - } else if (version=="Parabolic"){ - std::auto_ptr result( new ParabolicParametrizedMagneticField()); - return result; - } else { - throw cms::Exception("InvalidParameter")<<"Invalid parametrization version " << version; - } - return std::auto_ptr(0); //make compiler happy + return ParametrizedMagneticFieldFactory::get(version, parameters); } #include "FWCore/Framework/interface/ModuleFactory.h" diff --git a/MagneticField/ParametrizedEngine/plugins/BCyl.h b/MagneticField/ParametrizedEngine/src/BCyl.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/BCyl.h rename to MagneticField/ParametrizedEngine/src/BCyl.h diff --git a/MagneticField/ParametrizedEngine/plugins/BFit.cc b/MagneticField/ParametrizedEngine/src/BFit.cc similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/BFit.cc rename to MagneticField/ParametrizedEngine/src/BFit.cc diff --git a/MagneticField/ParametrizedEngine/plugins/BFit.h b/MagneticField/ParametrizedEngine/src/BFit.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/BFit.h rename to MagneticField/ParametrizedEngine/src/BFit.h diff --git a/MagneticField/ParametrizedEngine/plugins/BFit3D.cc b/MagneticField/ParametrizedEngine/src/BFit3D.cc similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/BFit3D.cc rename to MagneticField/ParametrizedEngine/src/BFit3D.cc diff --git a/MagneticField/ParametrizedEngine/plugins/BFit3D.h b/MagneticField/ParametrizedEngine/src/BFit3D.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/BFit3D.h rename to MagneticField/ParametrizedEngine/src/BFit3D.h diff --git a/MagneticField/ParametrizedEngine/plugins/BFit3D_data.h b/MagneticField/ParametrizedEngine/src/BFit3D_data.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/BFit3D_data.h rename to MagneticField/ParametrizedEngine/src/BFit3D_data.h diff --git a/MagneticField/ParametrizedEngine/plugins/HarmBasis3DCyl.cc b/MagneticField/ParametrizedEngine/src/HarmBasis3DCyl.cc similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/HarmBasis3DCyl.cc rename to MagneticField/ParametrizedEngine/src/HarmBasis3DCyl.cc diff --git a/MagneticField/ParametrizedEngine/plugins/HarmBasis3DCyl.h b/MagneticField/ParametrizedEngine/src/HarmBasis3DCyl.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/HarmBasis3DCyl.h rename to MagneticField/ParametrizedEngine/src/HarmBasis3DCyl.h diff --git a/MagneticField/ParametrizedEngine/plugins/OAEParametrizedMagneticField.cc b/MagneticField/ParametrizedEngine/src/OAEParametrizedMagneticField.cc similarity index 93% rename from MagneticField/ParametrizedEngine/plugins/OAEParametrizedMagneticField.cc rename to MagneticField/ParametrizedEngine/src/OAEParametrizedMagneticField.cc index 143d0bdb1092..ee11ab88046b 100644 --- a/MagneticField/ParametrizedEngine/plugins/OAEParametrizedMagneticField.cc +++ b/MagneticField/ParametrizedEngine/src/OAEParametrizedMagneticField.cc @@ -12,6 +12,9 @@ using namespace std; using namespace magfieldparam; +OAEParametrizedMagneticField::OAEParametrizedMagneticField(float B) : + theParam(B){} + OAEParametrizedMagneticField::OAEParametrizedMagneticField(string T) : theParam(T){} diff --git a/MagneticField/ParametrizedEngine/plugins/OAEParametrizedMagneticField.h b/MagneticField/ParametrizedEngine/src/OAEParametrizedMagneticField.h similarity index 80% rename from MagneticField/ParametrizedEngine/plugins/OAEParametrizedMagneticField.h rename to MagneticField/ParametrizedEngine/src/OAEParametrizedMagneticField.h index b99ac55796c8..63acb1eac823 100644 --- a/MagneticField/ParametrizedEngine/plugins/OAEParametrizedMagneticField.h +++ b/MagneticField/ParametrizedEngine/src/OAEParametrizedMagneticField.h @@ -9,7 +9,7 @@ * For details, cf TkBfield.h * * - * \author N. Amapane - CERN + * \author N. Amapane - Torino */ #include "MagneticField/Engine/interface/MagneticField.h" @@ -20,10 +20,13 @@ namespace magfieldparam { class TkBfield; } class OAEParametrizedMagneticField : public MagneticField { public: - /// Constructor + /// Constructor, pass value for nominal field + explicit OAEParametrizedMagneticField(float B); + + /// Constructor, pass string for nominal field [deprecated] explicit OAEParametrizedMagneticField(std::string T="3_8T"); - /// Constructor. Parameters taken from a PSet + /// Constructor. Parameters taken from a PSet [deprecated] explicit OAEParametrizedMagneticField(const edm::ParameterSet& parameters); /// Destructor diff --git a/MagneticField/ParametrizedEngine/plugins/ParabolicParametrizedMagneticField.cc b/MagneticField/ParametrizedEngine/src/ParabolicParametrizedMagneticField.cc similarity index 72% rename from MagneticField/ParametrizedEngine/plugins/ParabolicParametrizedMagneticField.cc rename to MagneticField/ParametrizedEngine/src/ParabolicParametrizedMagneticField.cc index 243e5a86a549..7ce7638e9ebd 100644 --- a/MagneticField/ParametrizedEngine/plugins/ParabolicParametrizedMagneticField.cc +++ b/MagneticField/ParametrizedEngine/src/ParabolicParametrizedMagneticField.cc @@ -8,13 +8,23 @@ #include using namespace std; -using namespace magfieldparam; -ParabolicParametrizedMagneticField::ParabolicParametrizedMagneticField() {} +// Default parameters are the best fit of 3.8T to the OAEParametrizedMagneticField parametrization. +ParabolicParametrizedMagneticField::ParabolicParametrizedMagneticField() : + c1(3.8114), + b0(-3.94991e-06), + b1(7.53701e-06), + a (2.43878e-11) +{} -//ParabolicParametrizedMagneticField::ParabolicParametrizedMagneticField(const edm::ParameterSet& parameters) {} -// theParam(parameters.getParameter("BValue")) {} + +ParabolicParametrizedMagneticField::ParabolicParametrizedMagneticField(const vector& parameters) : + c1(parameters[0]), + b0(parameters[1]), + b1(parameters[2]), + a (parameters[3]) +{} ParabolicParametrizedMagneticField::~ParabolicParametrizedMagneticField() {} @@ -31,8 +41,7 @@ ParabolicParametrizedMagneticField::inTesla(const GlobalPoint& gp) const { } GlobalVector ParabolicParametrizedMagneticField::inTeslaUnchecked(const GlobalPoint& gp) const { - float B=B0Z(gp.z())*Kr(gp.perp2()); - return GlobalVector(0, 0, B); + return GlobalVector(0, 0, B0Z(gp.z())*Kr(gp.perp2())); } inline float ParabolicParametrizedMagneticField::B0Z(const float z) const { diff --git a/MagneticField/ParametrizedEngine/plugins/ParabolicParametrizedMagneticField.h b/MagneticField/ParametrizedEngine/src/ParabolicParametrizedMagneticField.h similarity index 73% rename from MagneticField/ParametrizedEngine/plugins/ParabolicParametrizedMagneticField.h rename to MagneticField/ParametrizedEngine/src/ParabolicParametrizedMagneticField.h index 9ea5e64bbc82..de4514283fe3 100644 --- a/MagneticField/ParametrizedEngine/plugins/ParabolicParametrizedMagneticField.h +++ b/MagneticField/ParametrizedEngine/src/ParabolicParametrizedMagneticField.h @@ -10,17 +10,17 @@ */ #include "MagneticField/Engine/interface/MagneticField.h" +#include namespace edm { class ParameterSet; } -namespace magfieldparam { class TkBfield; } class ParabolicParametrizedMagneticField : public MagneticField { public: - /// Constructor + /// Default constructor, use default values for 3.8T map explicit ParabolicParametrizedMagneticField(); - /// Constructor. Parameters taken from a PSet - //explicit ParabolicParametrizedMagneticField(const edm::ParameterSet& parameters); + /// Constructor with explicit parameter list (b0, b1, c1, a) + explicit ParabolicParametrizedMagneticField(const std::vector& parameters); /// Destructor virtual ~ParabolicParametrizedMagneticField(); @@ -36,9 +36,9 @@ class ParabolicParametrizedMagneticField : public MagneticField { inline bool isDefined(const GlobalPoint& gp) const; private: - const float b0 = -3.94991e-06; - const float b1 = 7.53701e-06; - const float c1 = 3.8114; - const float a = 2.43878e-11; + float c1; + float b0; + float b1; + float a; }; #endif diff --git a/MagneticField/ParametrizedEngine/src/ParametrizedMagneticFieldFactory.cc b/MagneticField/ParametrizedEngine/src/ParametrizedMagneticFieldFactory.cc new file mode 100644 index 000000000000..c35c98deb070 --- /dev/null +++ b/MagneticField/ParametrizedEngine/src/ParametrizedMagneticFieldFactory.cc @@ -0,0 +1,78 @@ +/** \file + * + * \author N. Amapane - Torino + */ + +#include +#include + +#include "MagneticField/UniformEngine/src/UniformMagneticField.h" +#include "OAEParametrizedMagneticField.h" +#include "ParabolicParametrizedMagneticField.h" +#include "PolyFit2DParametrizedMagneticField.h" + +#include "FWCore/Utilities/interface/Exception.h" + +using namespace std; +using namespace edm; + +ParametrizedMagneticFieldFactory::ParametrizedMagneticFieldFactory(){} + +// Legacy interface, deprecated +std::auto_ptr +ParametrizedMagneticFieldFactory::get(string version, const ParameterSet& parameters) { + + if (version=="OAE_1103l_071212") { + // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation + std::auto_ptr result( new OAEParametrizedMagneticField(parameters)); + return result; + } else if (version=="PolyFit2D") { + // V. Maroussov polynomial fit to mapping data + std::auto_ptr result( new PolyFit2DParametrizedMagneticField(parameters)); + return result; + } else if (version=="PolyFit3D") { + // V. Maroussov polynomial fit to mapping data + throw cms::Exception("InvalidParameter")<<"PolyFit3D is not supported anymore"; + } else if (version=="Parabolic"){ + // FIXME implement configurable parameters to be passed to ctor +// vector params = parameters.getParameter("parameters"); +// std::auto_ptr result( new ParabolicParametrizedMagneticField(params)); + std::auto_ptr result( new ParabolicParametrizedMagneticField()); + return result; + } else { + throw cms::Exception("InvalidParameter")<<"Invalid parametrization version " << version; + } + return std::auto_ptr(0); //make compiler happy +} + + +// New interface +std::auto_ptr +ParametrizedMagneticFieldFactory::get(string version, vector parameters) { + + if (version=="Uniform") { + if (parameters.size()!=1) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ; + std::auto_ptr result(new UniformMagneticField(parameters[0])); + return result; + } else if (version=="OAE_1103l_071212") { + // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation + if (parameters.size()!=1) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ; + std::auto_ptr result( new OAEParametrizedMagneticField(parameters[0])); + return result; + } else if (version=="PolyFit2D") { + // V. Maroussov polynomial fit to mapping data + if (parameters.size()!=1) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ; + std::auto_ptr result( new PolyFit2DParametrizedMagneticField(parameters[0])); + return result; + } else if (version=="PolyFit3D") { + // V. Maroussov polynomial fit to mapping data + throw cms::Exception("InvalidParameter")<<"PolyFit3D is not supported anymore"; + } else if (version=="Parabolic"){ + if (parameters.size()!=4) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ; + std::auto_ptr result( new ParabolicParametrizedMagneticField(parameters)); + return result; + } else { + throw cms::Exception("InvalidParameter")<<"Invalid parametrization version " << version; + } + return std::auto_ptr(0); //make compiler happy +} diff --git a/MagneticField/ParametrizedEngine/plugins/PolyFit2DParametrizedMagneticField.cc b/MagneticField/ParametrizedEngine/src/PolyFit2DParametrizedMagneticField.cc similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/PolyFit2DParametrizedMagneticField.cc rename to MagneticField/ParametrizedEngine/src/PolyFit2DParametrizedMagneticField.cc diff --git a/MagneticField/ParametrizedEngine/plugins/PolyFit2DParametrizedMagneticField.h b/MagneticField/ParametrizedEngine/src/PolyFit2DParametrizedMagneticField.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/PolyFit2DParametrizedMagneticField.h rename to MagneticField/ParametrizedEngine/src/PolyFit2DParametrizedMagneticField.h diff --git a/MagneticField/ParametrizedEngine/plugins/TkBfield.cc b/MagneticField/ParametrizedEngine/src/TkBfield.cc similarity index 83% rename from MagneticField/ParametrizedEngine/plugins/TkBfield.cc rename to MagneticField/ParametrizedEngine/src/TkBfield.cc index 91cf8fd02e51..9f67af59800b 100644 --- a/MagneticField/ParametrizedEngine/plugins/TkBfield.cc +++ b/MagneticField/ParametrizedEngine/src/TkBfield.cc @@ -18,8 +18,19 @@ namespace { BCylParam fpar4{4.24326f,15.0201f,3.81492f,0.0178712f,0.000656527f,2.45818f,0.00778695f,2.12500f,1.77436f}; // 3.8T-2G BCylParam fpar5{4.21136f,14.8824f,4.01683f,0.0175932f,0.000695541f,2.45311f,0.00813447f,2.11688f,1.76076f}; // 4.0T-2G std::string const flds[] = {"2_0T","3_0T","3_5T","3_8T","4_0T"}; + float flds_f[] = {2.0, 3.0, 3.5, 3.8, 4.0}; BCylParam const fpars[]{fpar1,fpar2,fpar3,fpar4,fpar5}; + BCylParam const & findPar(float fld) { + for (int i=0; i<5; ++i){ + if (fabs(fld-flds_f[i])<0.001) { + return fpars[i]; + } + } + throw cms::Exception("BadParameters") << "Undefined field value " << fld; + } + + BCylParam const & findPar(std::string fld) { auto f = std::find(flds,flds+5,fld); if (f-flds>4) throw cms::Exception("BadParameters") @@ -31,8 +42,10 @@ namespace { } -TkBfield::TkBfield(std::string fld) : bcyl(findPar(fld)) { +TkBfield::TkBfield(float fld) : bcyl(findPar(fld)) { +} +TkBfield::TkBfield(std::string fld) : bcyl(findPar(fld)) { } diff --git a/MagneticField/ParametrizedEngine/plugins/TkBfield.h b/MagneticField/ParametrizedEngine/src/TkBfield.h similarity index 84% rename from MagneticField/ParametrizedEngine/plugins/TkBfield.h rename to MagneticField/ParametrizedEngine/src/TkBfield.h index 8c710e34e267..784c300b5a71 100644 --- a/MagneticField/ParametrizedEngine/plugins/TkBfield.h +++ b/MagneticField/ParametrizedEngine/src/TkBfield.h @@ -26,8 +26,11 @@ namespace magfieldparam { class TkBfield { public: - TkBfield (std::string T="3_8T"); + // Deprecated ctor, nominal field value specified with a string, eg. "3_8T" + TkBfield (std::string T); + // Ctor + TkBfield (float fld=3.8); /// B out in cartesian void getBxyz(float const * __restrict__ x, float * __restrict__ Bxyz) const; diff --git a/MagneticField/ParametrizedEngine/plugins/poly2d_base.cc b/MagneticField/ParametrizedEngine/src/poly2d_base.cc similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/poly2d_base.cc rename to MagneticField/ParametrizedEngine/src/poly2d_base.cc diff --git a/MagneticField/ParametrizedEngine/plugins/poly2d_base.h b/MagneticField/ParametrizedEngine/src/poly2d_base.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/poly2d_base.h rename to MagneticField/ParametrizedEngine/src/poly2d_base.h diff --git a/MagneticField/ParametrizedEngine/plugins/rz_harm_poly.cc b/MagneticField/ParametrizedEngine/src/rz_harm_poly.cc similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/rz_harm_poly.cc rename to MagneticField/ParametrizedEngine/src/rz_harm_poly.cc diff --git a/MagneticField/ParametrizedEngine/plugins/rz_harm_poly.h b/MagneticField/ParametrizedEngine/src/rz_harm_poly.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/rz_harm_poly.h rename to MagneticField/ParametrizedEngine/src/rz_harm_poly.h diff --git a/MagneticField/ParametrizedEngine/plugins/rz_poly.cc b/MagneticField/ParametrizedEngine/src/rz_poly.cc similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/rz_poly.cc rename to MagneticField/ParametrizedEngine/src/rz_poly.cc diff --git a/MagneticField/ParametrizedEngine/plugins/rz_poly.h b/MagneticField/ParametrizedEngine/src/rz_poly.h similarity index 100% rename from MagneticField/ParametrizedEngine/plugins/rz_poly.h rename to MagneticField/ParametrizedEngine/src/rz_poly.h diff --git a/MagneticField/ParametrizedEngine/test/BuildFile.xml b/MagneticField/ParametrizedEngine/test/BuildFile.xml deleted file mode 100644 index db160c09b608..000000000000 --- a/MagneticField/ParametrizedEngine/test/BuildFile.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.cc b/MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.cc deleted file mode 100644 index 219e08a5774f..000000000000 --- a/MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.cc +++ /dev/null @@ -1,146 +0,0 @@ -// -*- C++ -*- -// -// Package: MagneticFieldPlotter -// Class: MagneticFieldPlotter -// -/**\class MagneticFieldPlotter MagneticFieldPlotter.cc MyAnalyzers/MagneticFieldPlotter/src/MagneticFieldPlotter.cc - - Description: Plots Magnetic Field Components in the Tracker Volume - - Implementation: - This Analyzer fills some histograms with the Magnetic Field components in the tracker volume. It's mainly aimed to look - at differences between the Veikko parametrized field and the VolumeBased one. -*/ -// -// Original Author: Massimiliano Chiorboli -// Created: Mon Jun 11 17:20:15 CEST 2007 -// -// - - -// system include files -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - - - -#include "MagneticField/Engine/interface/MagneticField.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" -#include "MagneticFieldPlotter.h" -#include "DataFormats/GeometryVector/interface/Pi.h" -#include "FWCore/Framework/interface/ESHandle.h" - -#include -#include - -using namespace edm; -using namespace std; - - -MagneticFieldPlotter::MagneticFieldPlotter(const edm::ParameterSet& iConfig): - HistoFileName(iConfig.getUntrackedParameter("histoFileName", - std::string("magneticFieldPlotterHistos.root"))) -{ - theHistoFile = 0; - - nZstep = 1; - nPhistep = 1; - zHalfLength = 280; - -} - - -MagneticFieldPlotter::~MagneticFieldPlotter() -{ - -} - - -void -MagneticFieldPlotter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - ESHandle ESMGField; - iSetup.get().get(ESMGField); - theMGField = &(*ESMGField); - - - // float radius[5] = {10, 20, 30, 50, 100}; - float radius[1] = {100}; - // for(int iR=0; iR<5; iR++) { - for(int iR=0; iR<1; iR++) { - for(int iPhi=0; iPhiinTesla(gp); - float Br = myFieldVector.x()*cos(gp.phi()) + myFieldVector.y()*sin(gp.phi()); - float Bphi = - myFieldVector.x()*sin(gp.phi()) + myFieldVector.y()*cos(gp.phi()); - std::cout << "Radius = " << rCoordinate ; - std::cout << ", Z = " << zCoordinate ; - std::cout << ", Phi = " << phiCoordinate <> iS; - string gBzName = "gBz" + iS; - string gBzTitle = "B_{z}" + iS; - string gBphiName = "gBphi" + iS; - string gBphiTitle = "B_{#phi}" + iS; - string gBrName = "gBr" + iS; - string gBrTitle = "B_{r}" + iS; - gBz[i] = new TH2D(gBzName.c_str() , gBzTitle.c_str() , - nPhistep , -Geom::pi()-phiStepWidth/2 , Geom::pi()-phiStepWidth/2, - nZstep , -zHalfLength-zStepWidth/2 , zHalfLength-zStepWidth/2 ); - gBphi[i] = new TH2D(gBphiName.c_str() , gBphiTitle.c_str() , - nPhistep , -Geom::pi()-phiStepWidth/2 , Geom::pi()-phiStepWidth/2, - nZstep , -zHalfLength-zStepWidth/2 , zHalfLength-zStepWidth/2 ); - gBr[i] = new TH2D(gBrName.c_str() , gBrTitle.c_str() , - nPhistep , -Geom::pi()-phiStepWidth/2 , Geom::pi()-phiStepWidth/2, - nZstep , -zHalfLength-zStepWidth/2 , zHalfLength-zStepWidth/2 ); - - } - -} - -void -MagneticFieldPlotter::endJob() { - theHistoFile->Write(); - theHistoFile->Close() ; -} - -DEFINE_FWK_MODULE(MagneticFieldPlotter); diff --git a/MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.h b/MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.h deleted file mode 100644 index ceeee4f1d524..000000000000 --- a/MagneticField/ParametrizedEngine/test/MagneticFieldPlotter.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*- C++ -*- -// -// Package: MagneticFieldPlotter -// Class: MagneticFieldPlotter -// -/**\class MagneticFieldPlotter MagneticFieldPlotter.cc MyAnalyzers/MagneticFieldPlotter/src/MagneticFieldPlotter.cc - - Description: Plots Magnetic Field Components in the Tracker Volume - - Implementation: - This Analyzer fills some histograms with the Magnetic Field components in the tracker volume. It's mainly aimed to look - at differences between the Veikko parametrized field and the VolumeBased one. -*/ -// -// Original Author: Massimiliano Chiorboli -// Created: Mon Jun 11 17:20:15 CEST 2007 -// -// -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "TGraph2D.h" -#include "TGraph.h" -#include "TH1.h" -#include "TFile.h" - - -class MagneticFieldPlotter : public edm::EDAnalyzer { -public: - explicit MagneticFieldPlotter(const edm::ParameterSet&); - ~MagneticFieldPlotter(); - - -private: - virtual void beginJob() ; - virtual void analyze(const edm::Event&, const edm::EventSetup&); - virtual void endJob() ; - - - TH2D* gBz[5]; - TH2D* gBphi[5]; - TH2D* gBr[5]; - - int nZstep; - int nPhistep; - float zHalfLength; - - const MagneticField* theMGField; - std::string HistoFileName; - TFile* theHistoFile; - -}; - - - diff --git a/MagneticField/ParametrizedEngine/test/TKBfield_t.cpp b/MagneticField/ParametrizedEngine/test/TKBfield_t.cpp deleted file mode 100644 index 9597bbe950bd..000000000000 --- a/MagneticField/ParametrizedEngine/test/TKBfield_t.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - - - -int main() { - magfieldparam::TkBfield field; - for (float x=-0.5; x<0.6; x+=0.5) - for (float y=- 0.5; y<0.6; y+=0.5) - for (float z=-2.; z<2.1; z+=0.5) { - float loc[] = {x,y,z}; - float b[3]; - field.getBxyz(loc,b); - std::cout << b[0] << ", " << b[1] << ", " << b[2] << std::endl; - } - return 0; -} - diff --git a/MagneticField/ParametrizedEngine/test/res60.out b/MagneticField/ParametrizedEngine/test/res60.out deleted file mode 100644 index 1e236dc0cd8a..000000000000 --- a/MagneticField/ParametrizedEngine/test/res60.out +++ /dev/null @@ -1,81 +0,0 @@ -0.0207383, 0.0207383, 3.73348 -0.0152751, 0.0152751, 3.76922 -0.0103261, 0.0103261, 3.7948 -0.0054454, 0.0054454, 3.81039 -0.000199622, 0.000199622, 3.81586 --0.00508761, -0.00508761, 3.81111 --0.00998011, -0.00998011, 3.79624 --0.0149097, -0.0149097, 3.77138 --0.020321, -0.020321, 3.73638 -0.0208369, -0, 3.73038 -0.0153471, -0, 3.76646 -0.0103731, -0, 3.79228 -0.00546889, -0, 3.80801 -0.000200428, -0, 3.81353 --0.00510946, 0, 3.80875 --0.0100254, 0, 3.79374 --0.0149798, 0, 3.76864 --0.0204176, 0, 3.73332 -0.0207383, -0.0207383, 3.73348 -0.0152751, -0.0152751, 3.76922 -0.0103261, -0.0103261, 3.7948 -0.0054454, -0.0054454, 3.81039 -0.000199622, -0.000199622, 3.81586 --0.00508761, 0.00508761, 3.81111 --0.00998011, 0.00998011, 3.79624 --0.0149097, 0.0149097, 3.77138 --0.020321, 0.020321, 3.73638 --0, 0.0208369, 3.73038 --0, 0.0153471, 3.76646 --0, 0.0103731, 3.79228 --0, 0.00546889, 3.80801 --0, 0.000200428, 3.81353 -0, -0.00510946, 3.80875 -0, -0.0100254, 3.79374 -0, -0.0149798, 3.76864 -0, -0.0204176, 3.73332 --0, -0, 3.72729 --0, -0, 3.76371 --0, -0, 3.78977 --0, -0, 3.80564 --0, -0, 3.8112 -0, 0, 3.80638 -0, 0, 3.79124 -0, 0, 3.76591 -0, 0, 3.73025 --0, -0.0208369, 3.73038 --0, -0.0153471, 3.76646 --0, -0.0103731, 3.79228 --0, -0.00546889, 3.80801 --0, -0.000200428, 3.81353 -0, 0.00510946, 3.80875 -0, 0.0100254, 3.79374 -0, 0.0149798, 3.76864 -0, 0.0204176, 3.73332 --0.0207383, 0.0207383, 3.73348 --0.0152751, 0.0152751, 3.76922 --0.0103261, 0.0103261, 3.7948 --0.0054454, 0.0054454, 3.81039 --0.000199622, 0.000199622, 3.81586 -0.00508761, -0.00508761, 3.81111 -0.00998011, -0.00998011, 3.79624 -0.0149097, -0.0149097, 3.77138 -0.020321, -0.020321, 3.73638 --0.0208369, -0, 3.73038 --0.0153471, -0, 3.76646 --0.0103731, -0, 3.79228 --0.00546889, -0, 3.80801 --0.000200428, -0, 3.81353 -0.00510946, 0, 3.80875 -0.0100254, 0, 3.79374 -0.0149798, 0, 3.76864 -0.0204176, 0, 3.73332 --0.0207383, -0.0207383, 3.73348 --0.0152751, -0.0152751, 3.76922 --0.0103261, -0.0103261, 3.7948 --0.0054454, -0.0054454, 3.81039 --0.000199622, -0.000199622, 3.81586 -0.00508761, 0.00508761, 3.81111 -0.00998011, 0.00998011, 3.79624 -0.0149097, 0.0149097, 3.77138 -0.020321, 0.020321, 3.73638 diff --git a/MagneticField/ParametrizedEngine/test/res61.out b/MagneticField/ParametrizedEngine/test/res61.out deleted file mode 100644 index 710f75332ec0..000000000000 --- a/MagneticField/ParametrizedEngine/test/res61.out +++ /dev/null @@ -1,81 +0,0 @@ -0.0207383, 0.0207383, 3.73348 -0.0152751, 0.0152751, 3.76922 -0.0103261, 0.0103261, 3.7948 -0.00544541, 0.00544541, 3.81039 -0.000199624, 0.000199624, 3.81586 --0.00508761, -0.00508761, 3.81111 --0.00998011, -0.00998011, 3.79624 --0.0149097, -0.0149097, 3.77138 --0.020321, -0.020321, 3.73638 -0.0208369, -0, 3.73038 -0.0153471, -0, 3.76646 -0.0103731, -0, 3.79228 -0.0054689, -0, 3.80801 -0.000200429, -0, 3.81353 --0.00510946, 0, 3.80875 --0.0100254, 0, 3.79374 --0.0149798, 0, 3.76864 --0.0204176, 0, 3.73332 -0.0207383, -0.0207383, 3.73348 -0.0152751, -0.0152751, 3.76922 -0.0103261, -0.0103261, 3.7948 -0.00544541, -0.00544541, 3.81039 -0.000199624, -0.000199624, 3.81586 --0.00508761, 0.00508761, 3.81111 --0.00998011, 0.00998011, 3.79624 --0.0149097, 0.0149097, 3.77138 --0.020321, 0.020321, 3.73638 --0, 0.0208369, 3.73038 --0, 0.0153471, 3.76646 --0, 0.0103731, 3.79228 --0, 0.0054689, 3.80801 --0, 0.000200429, 3.81353 -0, -0.00510946, 3.80875 -0, -0.0100254, 3.79374 -0, -0.0149798, 3.76864 -0, -0.0204176, 3.73332 --0, -0, 3.72729 --0, -0, 3.76371 --0, -0, 3.78977 --0, -0, 3.80564 --0, -0, 3.8112 -0, 0, 3.80638 -0, 0, 3.79124 -0, 0, 3.76591 -0, 0, 3.73025 --0, -0.0208369, 3.73038 --0, -0.0153471, 3.76646 --0, -0.0103731, 3.79228 --0, -0.0054689, 3.80801 --0, -0.000200429, 3.81353 -0, 0.00510946, 3.80875 -0, 0.0100254, 3.79374 -0, 0.0149798, 3.76864 -0, 0.0204176, 3.73332 --0.0207383, 0.0207383, 3.73348 --0.0152751, 0.0152751, 3.76922 --0.0103261, 0.0103261, 3.7948 --0.00544541, 0.00544541, 3.81039 --0.000199624, 0.000199624, 3.81586 -0.00508761, -0.00508761, 3.81111 -0.00998011, -0.00998011, 3.79624 -0.0149097, -0.0149097, 3.77138 -0.020321, -0.020321, 3.73638 --0.0208369, -0, 3.73038 --0.0153471, -0, 3.76646 --0.0103731, -0, 3.79228 --0.0054689, -0, 3.80801 --0.000200429, -0, 3.81353 -0.00510946, 0, 3.80875 -0.0100254, 0, 3.79374 -0.0149798, 0, 3.76864 -0.0204176, 0, 3.73332 --0.0207383, -0.0207383, 3.73348 --0.0152751, -0.0152751, 3.76922 --0.0103261, -0.0103261, 3.7948 --0.00544541, -0.00544541, 3.81039 --0.000199624, -0.000199624, 3.81586 -0.00508761, 0.00508761, 3.81111 -0.00998011, 0.00998011, 3.79624 -0.0149097, 0.0149097, 3.77138 -0.020321, 0.020321, 3.73638 From 24d35d984dbdbee152690e6076703cca17797724 Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 14 Mar 2015 01:40:06 +0100 Subject: [PATCH 7/9] adapted to MagneticField/ParametrizedEngine from 73X --- CMGTools/TTHAnalysis/BuildFile.xml | 2 +- CMGTools/TTHAnalysis/src/SignedImpactParameter.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMGTools/TTHAnalysis/BuildFile.xml b/CMGTools/TTHAnalysis/BuildFile.xml index 16f4abdf86c0..c70a0cd9b4e4 100644 --- a/CMGTools/TTHAnalysis/BuildFile.xml +++ b/CMGTools/TTHAnalysis/BuildFile.xml @@ -1,6 +1,7 @@ + @@ -8,7 +9,6 @@ - diff --git a/CMGTools/TTHAnalysis/src/SignedImpactParameter.cc b/CMGTools/TTHAnalysis/src/SignedImpactParameter.cc index 8f56b51aa838..30daa683cab7 100644 --- a/CMGTools/TTHAnalysis/src/SignedImpactParameter.cc +++ b/CMGTools/TTHAnalysis/src/SignedImpactParameter.cc @@ -1,6 +1,6 @@ #include "CMGTools/TTHAnalysis/interface/SignedImpactParameter.h" #include "MagneticField/UniformEngine/src/UniformMagneticField.h" -#include "MagneticField/ParametrizedEngine/plugins/OAEParametrizedMagneticField.h" +#include "MagneticField/ParametrizedEngine/src/OAEParametrizedMagneticField.h" #include "TrackingTools/PatternTools/interface/TwoTrackMinimumDistance.h" #include "TrackingTools/TransientTrack/interface/TransientTrack.h" #include "TrackingTools/IPTools/interface/IPTools.h" From 54da8416f4f21e555af24688a4f87e2e71779c9c Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 14 Mar 2015 01:42:37 +0100 Subject: [PATCH 8/9] default for debug = False --- CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py index 9f5c56ee2ea2..2c5bbe18abe6 100644 --- a/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py +++ b/CMGTools/TTHAnalysis/cfg/crab/heppy_crab_config_env.py @@ -2,7 +2,7 @@ # values we'll be taken from environment variables set in launchall.py # fixed options will be taken from heppy_crab_config.py -debug = True +debug = False import imp file = open( "heppy_crab_config.py", 'r' ) From 90a4c2bfaeb6463484c6f95e13b87988182c3e2c Mon Sep 17 00:00:00 2001 From: Bruno Date: Sat, 14 Mar 2015 01:54:51 +0100 Subject: [PATCH 9/9] instructions in README.txt file --- CMGTools/TTHAnalysis/cfg/crab/README.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CMGTools/TTHAnalysis/cfg/crab/README.txt diff --git a/CMGTools/TTHAnalysis/cfg/crab/README.txt b/CMGTools/TTHAnalysis/cfg/crab/README.txt new file mode 100644 index 000000000000..034baea434ea --- /dev/null +++ b/CMGTools/TTHAnalysis/cfg/crab/README.txt @@ -0,0 +1,14 @@ +1) edit ../run_susyMT2.cfg to run over your favorite components + +2) edit launchall.py to change the CMG-version/tag and the production name + +3) run!!! +> voms-proxy-init -voms cms --valid=50:00 +Enter GRID pass phrase for this identity: pandolfiniGay +> python launchall.py + + +Notes: +- debugging: choose a single component and set debug=True in heppy_crab_config_env.py + +- modify heppy_crab_config.py to run only on your favorite sites