Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:40

0001 import FWCore.ParameterSet.Config as cms
0002 import FWCore.ParameterSet.VarParsing as VarParsing
0003 
0004 
0005 process = cms.Process("TREE")
0006 process.options = cms.untracked.PSet(wantSummary=cms.untracked.bool(True))
0007 process.options = cms.untracked.PSet(SkipEvent = cms.untracked.vstring('ProductNotFound'))
0008 
0009 ### command-line options
0010 options = VarParsing.VarParsing()
0011 
0012 ### eta ranges steerable
0013 options.register('etaMax1',
0014                  2.4,
0015                  VarParsing.VarParsing.multiplicity.singleton,
0016                  VarParsing.VarParsing.varType.float,
0017                  "eta max (muon1)")
0018 
0019 options.register('etaMin1',
0020                  -2.4,
0021                  VarParsing.VarParsing.multiplicity.singleton,
0022                  VarParsing.VarParsing.varType.float,
0023                  "eta min (muon1)")
0024 
0025 options.register('etaMax2',
0026                  2.4,
0027                  VarParsing.VarParsing.multiplicity.singleton,
0028                  VarParsing.VarParsing.varType.float,
0029                  "eta max (muon2)")
0030 
0031 options.register('etaMin2',
0032                  -2.4,
0033                  VarParsing.VarParsing.multiplicity.singleton,
0034                  VarParsing.VarParsing.varType.float,
0035                  "eta min (muon2)")
0036 
0037 
0038 # next line is not working with CRAB
0039 #options.parseArguments()
0040 ### end of options
0041 
0042 
0043 # Messages
0044 process.load("FWCore.MessageService.MessageLogger_cfi")
0045 process.MessageLogger.cerr.FwkReport.reportEvery = 500
0046 
0047 from CondCore.DBCommon.CondDBSetup_cfi import *
0048 process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
0049 
0050 ############  DATABASE conditions  ###########################
0051 from Configuration.AlCa.GlobalTag import GlobalTag
0052 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_mc', '')   
0053 
0054 ########### FILES  ####################################
0055 process.source = cms.Source(
0056     "PoolSource",
0057 #    fileNames = cms.untracked.vstring('file:test.root')
0058     fileNames = cms.untracked.vstring(
0059 '/store/mc/Phys14DR/DYToMuMu_M-50_Tune4C_13TeV-pythia8/MINIAODSIM/PU40bx25_tsg_castor_PHYS14_25_V1-v2/00000/622CAFBA-BD9A-E411-BE11-002481E14FFC.root'    
0060 )
0061     )
0062 process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(-1))
0063 
0064 ############ Zmumu GoldenSelection sequence ###############################################
0065 # http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/ElectroWeakAnalysis/ZMuMu/python/ZMuMuGolden_cfi.py?revision=1.7&view=markup&sortby=date
0066 
0067 ###########################################################################################
0068 # RUN2 muon selection
0069 ###########################################################################################
0070 process.RunTwoMuons = cms.EDFilter("PATMuonSelector",
0071    src = cms.InputTag("slimmedMuons"),                                 
0072    cut = cms.string(
0073     'pt > 20 & abs(eta)<2.4' + 
0074     '&& (isPFMuon && (isGlobalMuon || isTrackerMuon) )'+
0075     '&& (pfIsolationR04().sumChargedHadronPt+max(0.,pfIsolationR04().sumNeutralHadronEt+pfIsolationR04().sumPhotonEt-0.50*pfIsolationR04().sumPUPt))/pt < 0.20'
0076    )
0077  )
0078 
0079 # for isolation (tight WP)
0080 # https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideMuonId#Muon_Isolation
0081 
0082 #### FILL TREE  #######################
0083 
0084 ### helper class definition ###
0085 #####################
0086 class SetParameters:
0087 #####################
0088     def __init__(self):
0089         self.parResolFix = cms.vint32()
0090         self.parResolOrder = cms.vint32()
0091         self.parResol = cms.vdouble()
0092         self.parResolStep = cms.untracked.vdouble()
0093         self.parResolMin  = cms.untracked.vdouble()
0094         self.parResolMax  = cms.untracked.vdouble()
0095 
0096     def set(self, fix, order, value, step, min, max):
0097         self.parResolFix.append(fix)
0098         self.parResolOrder.append(order)
0099         self.parResol.append(value)
0100         self.parResolStep.append(step)
0101         self.parResolMin.append(min)
0102         self.parResolMax.append(max)
0103 ### end of the  definition ###
0104 
0105         
0106 setter = SetParameters()
0107 #fix, order, value, step, min, max
0108 setter.set( 0 ,0, -0.00113112 , 0.002,      -0.1,  0.1  )
0109 setter.set( 0 ,0, 0.000246547 , 0.00002,    -0.01, 0.01 )
0110 setter.set( 0 ,0, 0.00545563  , 0.000002,   0.,    0.01 )
0111 setter.set( 0 ,0, 0.00501745  , 0.0002,     -0.01, 0.02 )
0112 setter.set( 1 ,0, 0.0091978   , 0.00002,    0.,    0.01 )
0113 setter.set( 0 ,0, 0.0999428   , 0.0002,     0.,    0.2  )
0114 setter.set( 0 ,0, 0.0484629   , 0.0000002,  -0.2,  0.5  )
0115 setter.set( 0 ,0, -1.24738    , 0.0002,     -2.2,  -0.8 )
0116 setter.set( 1 ,0, 0.          , 0.00002,    0.,    0.01 )
0117 setter.set( 0 ,0, -0.0499885  , 0.0002,     -0.2,  0.1  )
0118 setter.set( 0 ,0, 0.252381    , 0.000002,   -0.1,  0.5  )
0119 setter.set( 0 ,0, 1.75024     , 0.0002,     0.,    3.   )
0120 setter.set( 0 ,0, -1.99739    , 0.001,      -2.2,  -1.6 )
0121 setter.set( 0 ,0, 1.59216     , 0.001,      1.,    2.2  )
0122 setter.set( 1 ,0, 0.          , 0.0001,     0.,    0.01 )
0123 
0124 
0125 TREEINPUTNAME=""
0126 TREEOUTPUTNAME="zmumuTree.root"                               
0127 process.looper = cms.Looper(
0128     "MuScleFit",
0129     # Only used when reading events from a root tree
0130     MaxEventsFromRootTree = cms.int32(-1),
0131 
0132     # Specify a file if you want to read events from a root tree in a local file.
0133     # In this case the input source should be an empty source with 0 events.
0134     
0135     InputRootTreeFileName = cms.string(TREEINPUTNAME),
0136     
0137     # Specify the file name where you want to save a root tree with the muon pairs.
0138     # Leave empty if no file should be written.
0139     
0140     OutputRootTreeFileName = cms.string(TREEOUTPUTNAME),
0141     
0142 
0143     # Choose the kind of muons you want to run on
0144     # -------------------------------------------
0145     MuonLabel = cms.InputTag("RunTwoMuons"),
0146     MuonType = cms.int32(11),
0147 
0148     # This line allows to switch to PAT muons. Default is false.
0149     # Note that the onia selection works only with onia patTuples.
0150     PATmuons = cms.untracked.bool(True),
0151 
0152     # ---------------- #
0153     # Select resonance #
0154     # ---------------- #
0155     # The resonances are to be specified in this order:
0156     # Z0, Y(3S), Y(2S), Y(1S), Psi(2S), J/Psi
0157     # -------------------------------------------------
0158     resfind = cms.vint32(1, 0, 0, 0, 0, 0),
0159 
0160     # Likelihood settings
0161     # -------------------
0162     maxLoopNumber = cms.untracked.int32(1),
0163     # Select which fits to do in which loop (0 = do not, 1 = do)
0164     doResolFit =        cms.vint32(0),
0165     doScaleFit =        cms.vint32(0),
0166     doBackgroundFit =   cms.vint32(0),
0167     doCrossSectionFit = cms.vint32(0),
0168 
0169     # Use the probability file or not. If not it will perform a simpler selection taking the muon pair with
0170     # invariant mass closer to the pdf value and will crash if some fit is attempted.
0171     UseProbsFile = cms.untracked.bool(False),
0172 
0173     # False = use also MC information
0174     speedup = cms.bool(False),
0175     GenParticlesName = cms.untracked.string("prunedGenParticles"),
0176 
0177     # Set this to false if you do not want to use simTracks.
0178     # (Note that this is skipped anyway if speedup == True).
0179     compareToSimTracks = cms.bool(False),
0180 
0181     # Output settings
0182     # ---------------
0183     OutputFileName = cms.untracked.string("zmumuHisto.root"),
0184 
0185     # BiasType=0 means no bias to muon momenta
0186     # ----------------------------------------
0187     BiasType = cms.int32(0),
0188     parBias = cms.vdouble(),
0189 
0190     # SmearType=0 means no smearing applied to muon momenta
0191     # -----------------------------------------------------
0192     SmearType = cms.int32(0),
0193     parSmear = cms.vdouble(),
0194 
0195     ### taken from J/Psi #########################
0196     ResolFitType = cms.int32(0),
0197     parResolFix   = setter.parResolFix,
0198     parResolOrder = setter.parResolOrder,
0199     parResol      = setter.parResol,
0200     parResolStep  = setter.parResolStep,
0201     parResolMin   = setter.parResolMin,
0202     parResolMax   = setter.parResolMax,
0203 
0204 
0205     # -------------------- #
0206     # Scale fit parameters #
0207     # -------------------- #
0208 
0209     # -----------------------------------------------------------------------------------
0210     ScaleFitType  = cms.int32(0),
0211     parScaleOrder = cms.vint32( 0, 0, 0, 0, 0),
0212     parScaleFix   = cms.vint32(1, 1, 1, 1, 1),
0213     parScale      = cms.vdouble(-7.3019e-05, 0., 0.00147514, 0.000114635, 0.246663),
0214     
0215     # Scale fit type=11: Linear in pt, sinusoidal in phi with muon sign -->GOOD results in phi
0216     ##  modified for mu+/mu -
0217     # -----------------------------------------------------------------------------------
0218     ##    ScaleFitType = cms.int32(11),
0219     ##     parScaleOrder = cms.vint32(0, 0, 0, 0, 0, 0, 0, 0),
0220     ##     parScaleFix =   cms.vint32(0, 0, 0, 0, 0, 0, 0, 0),
0221     ##     parScale = cms.vdouble(1., 0., 0., 1., 0., 0., 1., 0.),
0222 
0223 
0224     # ---------------------------- #
0225     # Cross section fit parameters #
0226     # ---------------------------- #
0227     # Note that the cross section fit works differently than the others, it
0228     # fits ratios of parameters. Fix and Order should not be used as is, they
0229     # are there mainly for compatibility.
0230     parCrossSectionOrder = cms.vint32(0, 0, 0, 0, 0, 0),
0231     parCrossSectionFix   = cms.vint32(0, 0, 0, 0, 0, 0),
0232     parCrossSection      = cms.vdouble(1.233, 2.07, 6.33, 13.9, 2.169, 127.2),
0233 
0234     # ------------------------- #
0235     # Background fit parameters #
0236     # ------------------------- #
0237 
0238     # Window factors for: Z, Upsilons and (J/Psi,Psi2S) regions
0239     LeftWindowBorder  = cms.vdouble(70., 8., 1.391495),
0240     RightWindowBorder = cms.vdouble(110., 12., 5.391495),
0241 
0242     # The two parameters of BgrFitType=2 are respectively:
0243     # bgr fraction, (negative of) bgr exp. slope, bgr constant
0244     # --------------------------------------------------------
0245     # The function types for resonances in a region must be the same
0246     BgrFitType = cms.vint32(2, 2, 2), # regions
0247     # These empty parameters should be used when there is no background
0248     parBgr = cms.vdouble(0., 0.,   0., 0.,   0., 0.,
0249                          0., 0.,   0., 0.,   0., 0.,   0.,0.,   0.,0.,   0.,0.),
0250     parBgrFix = cms.vint32(0, 0,   0, 0,   0, 0,
0251                            # The rest of the parameters is used for the resonance regions. They are automatically fixed in the code
0252                            # because they are never used to fit the background, but only after the rescaling.
0253                            1, 1,   1, 1,   1, 1,   1, 1,   1, 1,   1, 1),
0254     parBgrOrder = cms.vint32(0, 0,   0, 0,   0, 0,
0255                              0, 0,   0, 0,   0, 0,   0, 0,   0, 0,   0, 0),
0256 
0257 
0258     # ----------------------- #
0259 
0260     # Set Minuit fit strategy
0261     FitStrategy = cms.int32(2),
0262 
0263     # Fit accuracy and debug parameters
0264     StartWithSimplex   = cms.bool(True),
0265     ComputeMinosErrors = cms.bool(False),
0266     MinimumShapePlots  = cms.bool(True),
0267 
0268 
0269     ########## TO BE ENABLED ################################
0270     # Set the cuts on muons to be used in the fit
0271     MinMuonPt = cms.untracked.double(0.),
0272     MaxMuonPt = cms.untracked.double(1000.),
0273     MinMuonEtaFirstRange = cms.untracked.double(options.etaMin1),
0274     MaxMuonEtaFirstRange = cms.untracked.double(options.etaMax1),
0275     MinMuonEtaSecondRange = cms.untracked.double(options.etaMin2),
0276     MaxMuonEtaSecondRange = cms.untracked.double(options.etaMax2),
0277     
0278     #ProbabilitiesFileInPath = cms.untracked.string("MuonAnalysis/MomentumScaleCalibration/test/Probs_merge.root"),
0279     #ProbabilitiesFile = cms.untracked.string("Probs_merge.root"),
0280 
0281     # Pile-Up related info 
0282     PileUpSummaryInfo = cms.untracked.InputTag("addPileupInfo"),
0283     PrimaryVertexCollection = cms.untracked.InputTag("offlineSlimmedPrimaryVertices"),
0284 
0285     # The following parameters can be used to filter events
0286     TriggerResultsLabel = cms.untracked.string("TriggerResults"),
0287     TriggerResultsProcess = cms.untracked.string("HLT"),
0288     TriggerPath = cms.untracked.vstring(""),
0289     # Negate the result of the trigger
0290     NegateTrigger = cms.untracked.bool(False),
0291     debug = cms.untracked.int32(0)
0292 )
0293 
0294 
0295 process.p = cms.Path(
0296     process.RunTwoMuons
0297     )
0298