CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Configuration/Generator/python/relval_generation_module.py

Go to the documentation of this file.
00001 ######################################################
00002 #                                                    #
00003 #       relval_simulation_module                     #
00004 #                                                    #  
00005 #  This module is a collection of the simulation     # 
00006 #  procedues. The random number service is built     #
00007 #  by the function random_generator_service(energy)  #
00008 #                                                    #
00009 ######################################################
00010 
00011 import FWCore.ParameterSet.Config as cms
00012 import relval_common_module as common
00013 
00014 from math import pi as PI
00015 import os
00016 import sys
00017 
00018 #---------------------------------------------------
00019 # This just simplifies the use of the logger
00020 mod_id="["+os.path.basename(sys._getframe().f_code.co_filename)[:-3]+"]"
00021 
00022 #----------------------------
00023 # Some useful constants:
00024 ETA_MAX=2.5
00025 ETA_MIN=-2.5
00026 
00027 def generate(step, evt_type, energy, evtnumber):
00028     """
00029     This function calls all the other functions specific for
00030     an event evt_type.
00031     """
00032    
00033     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00034     common.log( func_id+" Entering... ")
00035     
00036     # Build the switch cases:
00037     
00038     # Particle Gun
00039     if evt_type in ("MU+","MU-","E","DIE","GAMMA","TAU","PI0","PI+","PI-"):
00040        generator = _generate_PGUN\
00041          (step, evt_type, energy, evtnumber)
00042      
00043     elif evt_type in ("HZZMUMUMUMU", "HZZEEEE", "HZZTTTT", "HZZLLLL","HGG"):
00044        generator = _generate_Higgs\
00045          (step, evt_type, energy, evtnumber)
00046      
00047     elif evt_type in ("B_JETS", "C_JETS"):
00048        generator = _generate_udscb_jets\
00049          (step, evt_type, energy, evtnumber)        
00050     
00051     elif evt_type in ("QCD","TTBAR","ZPJJ","MINBIAS","RS1GG","HpT"):
00052         generator = eval("_generate_"+evt_type+"(step, evt_type, energy, evtnumber)") 
00053     
00054     elif evt_type in ("ZEE","ZTT","ZMUMU"):
00055         generator = _generate_Zll\
00056          (step, evt_type, energy, evtnumber)
00057 
00058     elif evt_type in ("ZPEE","ZPTT","ZPMUMU"):
00059         generator = _generate_ZPll\
00060          (step, evt_type, energy, evtnumber)         
00061              
00062     elif evt_type in ("WE","WM","WT"):
00063         generator = _generate_Wl(step, evt_type, energy, evtnumber)
00064          
00065     else:
00066       raise "Event type","Type not yet implemented."
00067              
00068     common.log( func_id+" Returning Generator")
00069     
00070     return generator
00071 
00072 #------------------------------       
00073 
00074 def _generate_PGUN(step, evt_type, energy, evtnumber):
00075     """
00076     Here the settings for the simple generation of a muon, electron or gamma
00077     are stated.
00078     """
00079     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00080     common.log( func_id+" Entering... ")
00081 
00082    # pythia ID: configure the ID of the particle through a dictionary
00083     py_id_dict = {"MU-":13, 
00084                   "MU+":-13,
00085                   "E" :11,
00086                   "DIE":11,
00087                   "TAU":15,
00088                   "GAMMA":22,
00089                   "PI+":211,
00090                   "PI-":-211,
00091                   "PI0":111}
00092     
00093     # Build the id string of the event name:
00094     id_string = evt_type+" "+energy+" nevts "+ str(evtnumber)    
00095                   
00096     # We have to check if we want to generate a particle with pt=X or Energy=X                  
00097     pt_flag=True
00098     if 'pt' in energy[0:2] or \
00099        'Pt' in energy[0:2] or \
00100        'PT' in energy[0:2]:
00101         energy=energy[2:]
00102     else:
00103         pt_flag=False         
00104                   
00105     # Energy boundaries are now set:      
00106     lower_energy = ""
00107     upper_energy = ""
00108     
00109 
00110 
00111     # Build the partID string
00112     part_id = cms.untracked.vint32 ()
00113 
00114     part_id.append(py_id_dict[evt_type])
00115     upper_energy=''
00116     lower_energy=''
00117     if energy.find('_')!=-1:
00118         upper_energy,lower_energy=energy_split(energy)
00119     else:    
00120         epsilon= 0.001
00121         lower_energy = str ( int(energy) - epsilon) # We want a calculation and
00122         upper_energy = str ( int(energy) + epsilon) # the result as a string   
00123     
00124     # Build the process source
00125     if evt_type in ("TAU","E"):
00126         # Add the corresponding opposite sign particle. Only for taus and es.
00127         part_id.append(-1*part_id[0])
00128     
00129     antip_flag=False
00130     if evt_type=="DIE":
00131         antip_flag=True  
00132     
00133     if pt_flag:        
00134         common.log( func_id+ "This is a pt particle gun ..." )
00135         generator = cms.EDProducer("FlatRandomPtGunProducer",
00136                             psethack = cms.string(id_string),
00137                             firstRun = cms.untracked.uint32(1),
00138                             PGunParameters = cms.PSet(
00139                                 PartID = part_id,
00140                                 MinEta = cms.double(ETA_MAX),
00141                                 MaxEta = cms.double(ETA_MIN),
00142                                 MinPhi = cms.double(-PI),
00143                                 MaxPhi = cms.double(PI),
00144                                 MinPt  = cms.double(lower_energy),
00145                                 MaxPt  = cms.double(upper_energy) 
00146                             ),
00147                             AddAntiParticle=cms.bool(antip_flag),
00148                             Verbosity = cms.untracked.int32(0)
00149                         )
00150     else:
00151         common.log( func_id+ " This is an Energy particle gun ..." )
00152         generator = cms.EDProducer("FlatRandomEGunProducer",
00153                             psethack = cms.string(id_string),
00154                             firstRun = cms.untracked.uint32(1),
00155                             PGunParameters = cms.PSet(
00156                                 PartID = part_id,
00157                                 MinEta = cms.double(ETA_MAX),
00158                                 MaxEta = cms.double(ETA_MIN),
00159                                 MinPhi = cms.double(-PI),
00160                                 MaxPhi = cms.double(PI),
00161                                 MinE = cms.double(lower_energy),
00162                                 MaxE = cms.double(upper_energy) 
00163                             ),
00164                             AddAntiParticle=cms.bool(antip_flag),
00165                             Verbosity = cms.untracked.int32(0)
00166                         )       
00167                         
00168     common.log( func_id+" Returning Generator...")
00169         
00170     return generator 
00171    
00172 #---------------------------
00173     
00174 def _generate_QCD(step, evt_type, energy, evtnumber):
00175     """
00176     Here the settings for the generation of QCD events 
00177     """
00178     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00179     common.log( func_id+" Entering... ")   
00180         
00181     # Recover the energies from the string:
00182     upper_energy, lower_energy = energy_split(energy)
00183     
00184     # Build the process source   
00185     generator = cms.EDFilter("Pythia6GeneratorFilter",
00186                         pythiaPylistVerbosity=cms.untracked.int32(0),
00187                         pythiaHepMCVerbosity=cms.untracked.bool(False),
00188                         maxEventsToPrint = cms.untracked.int32(0), 
00189                         filterEfficiency = cms.untracked.double(1),  
00190                         PythiaParameters = cms.PSet\
00191                         (parameterSets = cms.vstring\
00192                                             ("pythiaUESettings",
00193                                             "processParameters"),
00194                             pythiaUESettings = user_pythia_ue_settings(),
00195                             processParameters = cms.vstring("MSEL=1",
00196                                                 "CKIN(3)="+upper_energy,
00197                                                 "CKIN(4)="+lower_energy))
00198                         )
00199      
00200     common.log( func_id+" Returning Generator...")                 
00201     return generator
00202  
00203 #---------------------------------
00204 
00205 def _generate_MINBIAS(step, evt_type, energy, evtnumber):
00206     """
00207     Settings for MINBIAS events generation
00208     """
00209     
00210     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00211     common.log( func_id+" Entering... ")     
00212     
00213     # Build the process source   
00214     generator = cms.EDFilter("Pythia6GeneratorFilter",
00215                       pythiaPylistVerbosity=cms.untracked.int32(0),
00216                       pythiaHepMCVerbosity=cms.untracked.bool(False),
00217                       maxEventsToPrint = cms.untracked.int32(0), 
00218                       filterEfficiency = cms.untracked.double(1),  
00219                         PythiaParameters = cms.PSet\
00220                         (parameterSets = cms.vstring\
00221                                             ("pythiaUESettings",
00222                                              "processParameters"),
00223                             pythiaUESettings = user_pythia_ue_settings(),
00224                             processParameters = cms.vstring(
00225                                                 "MSEL=0",
00226                                                 "MSUB(11)=1",
00227                                                 "MSUB(12)=1",
00228                                                 "MSUB(13)=1",
00229                                                 "MSUB(28)=1",
00230                                                 "MSUB(53)=1",
00231                                                 "MSUB(68)=1",
00232                                                 "MSUB(92)=1",
00233                                                 "MSUB(93)=1",
00234                                                 "MSUB(94)=1",
00235                                                 "MSUB(95)=1"))
00236                         )
00237     common.log( func_id+" Returning Generator...")                 
00238     
00239     return generator   
00240     
00241 #---------------------------------
00242 
00243 def _generate_Higgs(step, evt_type, energy, evtnumber):
00244     """    
00245     Here the settings for the generation of Higgs->ZZ->ll events 
00246     The energy parameter is not used. According to the evt_type ("HZZMUMUMUMU" 
00247     or "HZZEEEE") the final state is chosen.
00248     """
00249     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00250     common.log( func_id+" Entering... ")      
00251     
00252     # Choose between muon, tau or electron decay of the Z
00253     z_flag="0"
00254     electron_flag = "0"
00255     muon_flag = "0"
00256     tau_flag = "0"
00257     gamma_flag="0"
00258     if evt_type == "HZZEEEE":
00259         electron_flag = "1"
00260         z_flag="1"
00261     elif evt_type == "HZZMUMUMUMU":
00262         muon_flag = "1"    
00263         z_flag="1"
00264     elif evt_type == "HZZTTTT":
00265         tau_flag = "1"
00266         z_flag="1"
00267     elif evt_type == "HZZLLLL":
00268         electron_flag=muon_flag=tau_flag= "1"
00269         z_flag="1"
00270     elif evt_type == "HGG":
00271         gamma_flag="1"    
00272 
00273   
00274     # Prepare The Pythia params  
00275     params = cms.vstring(
00276         "PMAS(25,1)=%s" %energy,      #mass of Higgs",
00277         "MSEL=0",                  
00278         #(D=1) to select between full user control
00279         #(0, then use MSUB) and some preprogrammed alternative: QCD hight pT
00280         #processes (1, then ISUB=11, 12, 13, 28, 53, 68), QCD low pT processes
00281         #(2, then ISUB=11, #12, 13, 28, 53, 68, 91, 92, 94, 95)",
00282         #
00283         #Check on possible errors during program
00284         #execution",
00285         "MSUB(102)=1",             #ggH",
00286         "MSUB(123)=1",             #ZZ fusion to H",
00287         "MSUB(124)=1",             #WW fusion to H",
00288         "CKIN(45)=5.",                       
00289         "CKIN(46)=150.",           
00290         #high mass cut on secondary resonance m1 in
00291         #2->1->2 process Registered by Alexandre.Nikitenko@cern.ch",
00292         "CKIN(47)=5.",             
00293         #low mass cut on secondary resonance m2 in
00294         #2->1->2 process Registered by Alexandre.Nikitenko@cern.ch",
00295         "CKIN(48)=150.",           
00296         #high mass cut on secondary resonance m2 in
00297         #2->1->2 process Registered by Alexandre.Nikitenko@cern.ch",
00298         "MDME(174,1)=0",           #Z decay into d dbar",        
00299         "MDME(175,1)=0",          #Z decay into u ubar",
00300         "MDME(176,1)=0",           #Z decay into s sbar",
00301         "MDME(177,1)=0",           #Z decay into c cbar",
00302         "MDME(178,1)=0",           #Z decay into b bbar",
00303         "MDME(179,1)=0",           #Z decay into t tbar",
00304         "MDME(182,1)=%s" %electron_flag,#Z decay into e- e+",
00305         "MDME(183,1)=0",           #Z decay into nu_e nu_ebar",
00306         "MDME(184,1)=%s" %muon_flag,#Z decay into mu- mu+",
00307         "MDME(185,1)=0",           #Z decay into nu_mu nu_mubar",
00308         "MDME(186,1)=%s" %tau_flag,#Z decay into tau- tau+",
00309         "MDME(187,1)=0",          #Z decay into nu_tau nu_taubar",
00310         "MDME(210,1)=0",           #Higgs decay into dd",
00311         "MDME(211,1)=0",           #Higgs decay into uu",
00312         "MDME(212,1)=0",           #Higgs decay into ss",
00313         "MDME(213,1)=0",           #Higgs decay into cc",
00314         "MDME(214,1)=0",           #Higgs decay into bb",
00315         "MDME(215,1)=0",           #Higgs decay into tt",
00316         "MDME(216,1)=0",           #Higgs decay into",
00317         "MDME(217,1)=0",           #Higgs decay into Higgs decay",
00318         "MDME(218,1)=0",           #Higgs decay into e nu e",
00319         "MDME(219,1)=0",           #Higgs decay into mu nu mu",
00320         "MDME(220,1)=0",           #Higgs decay into tau nu tau",
00321         "MDME(221,1)=0",           #Higgs decay into Higgs decay",
00322         "MDME(222,1)=0",           #Higgs decay into g g",
00323         "MDME(223,1)=%s" %gamma_flag,#Higgs decay into gam gam",
00324         "MDME(224,1)=0",           #Higgs decay into gam Z",
00325         "MDME(225,1)=%s" %z_flag,  #Higgs decay into Z Z",
00326         "MDME(226,1)=0",           #Higgs decay into W W"
00327         ) 
00328 
00329     # Build the process source   
00330     generator = cms.EDFilter('Pythia6GeneratorFilter',
00331                       pythiaPylistVerbosity=cms.untracked.int32(0),
00332                       pythiaHepMCVerbosity=cms.untracked.bool(False),
00333                       maxEventsToPrint = cms.untracked.int32(0), 
00334                       filterEfficiency = cms.untracked.double(1),  
00335                       pythiaVerbosity =cms.untracked.bool(False),
00336                       PythiaParameters = cms.PSet\
00337                        (parameterSets = cms.vstring('PythiaUESettings','processParameters'),
00338                         PythiaUESettings = user_pythia_ue_settings(),
00339                         processParameters=params
00340                        )     
00341                      )
00342 
00343     common.log( func_id+" Returning Generator...")
00344      
00345     return generator      
00346 
00347 #---------------------------------
00348 
00349 def _generate_udscb_jets\
00350         (step, evt_type, energy, evtnumber):
00351     """
00352     Here the settings necessary to udscb jets generation are added. According
00353     to the flavour the Pythia parameters are changed slightly.
00354     For the time being the energy parameter is not used.
00355     """
00356     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00357     common.log( func_id+" Entering... ")
00358     
00359     # Recover the energies from the string:
00360     upper_energy, lower_energy = energy_split(energy)
00361    
00362     # According to the evt_type build the Pythia settings:
00363     pythia_jet_settings=cms.vstring("MSEL=0")  # User defined process
00364     pythia_jet_settings+=cms.vstring("MSUB(81)=1", #qq->QQ massive
00365                                      "MSUB(82)=1") #gg->QQ massive
00366     if evt_type == "C_JETS":
00367             pythia_jet_settings+=cms.vstring("MSTP(7)=4") #ccbar
00368             common.log( func_id+" Including settings for c jets")
00369     else:
00370             pythia_jet_settings+=cms.vstring("MSTP(7)=5") #bbbar
00371             common.log( func_id+" Including settings for b jets")
00372              
00373     # Common part to all cases         
00374     pythia_common=cms.vstring("CKIN(3)="+upper_energy,  # Pt low cut 
00375                               "CKIN(4)="+lower_energy,  # Pt high cut
00376                               "CKIN(13)=0.",            # eta min            
00377                               "CKIN(14)=2.5",           # etamax           
00378                               "CKIN(15)=-2.5",          # -etamin 
00379                               "CKIN(16)=0"              # -etamax
00380                               )
00381     
00382     pythia_jet_settings+=pythia_common
00383     
00384     # Build the process source
00385     generator = cms.EDFilter('Pythia6GeneratorFilter',
00386                       pythiaVerbosity =cms.untracked.bool(True),
00387                       PythiaParameters = cms.PSet\
00388                                (parameterSets = cms.vstring\
00389                                                    ("pythiaUESettings","pythiaJets"),
00390                                 pythiaUESettings = user_pythia_ue_settings(),
00391                                 pythiaJets = pythia_jet_settings
00392                                )
00393                      )                       
00394    
00395     common.log(func_id+" Returning Generator...")
00396      
00397     return generator
00398 
00399 #-----------------------------------
00400     
00401 def _generate_TTBAR(step, evt_type, energy, evtnumber):
00402     """
00403     Here the settings for the ttbar pairs are added to the process.
00404     """
00405       
00406     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00407     common.log(func_id+" Entering... ")      
00408     
00409     # Build the process source    
00410     generator = cms.EDFilter('Pythia6GeneratorFilter',
00411                       pythiaPylistVerbosity=cms.untracked.int32(0),
00412                       pythiaHepMCVerbosity=cms.untracked.bool(False),
00413                       maxEventsToPrint = cms.untracked.int32(0), 
00414                       filterEfficiency = cms.untracked.double(1),                     
00415                       PythiaParameters = cms.PSet\
00416                                 (parameterSets = cms.vstring\
00417                                                    ('pythiaUESettings',
00418                                                     'processParameters'),
00419                                 pythiaUESettings = user_pythia_ue_settings(),
00420                                 # Tau jets (config by A. Nikitenko)
00421                                 # No tau -> electron
00422                                 # No tau -> muon
00423                                 processParameters =cms.vstring\
00424                                     ("MSEL=0",       # userdef process
00425                                      "MSUB(81)=1",   # qqbar->QQbar
00426                                      "MSUB(82)=1",   # gg to QQbar
00427                                      "MSTP(7)=6",    # flavour top
00428                                      "PMAS(6,1)=175" # top mass
00429                                      )
00430                                 ) 
00431                       )  
00432 
00433     common.log(func_id+" Returning Generator...")
00434      
00435     return generator   
00436  
00437 #---------------------------------
00438 
00439 def _generate_Zll(step, evt_type, energy, evtnumber):
00440     """
00441     Here the settings for the Z ee simulation are added to the process.
00442     Energy parameter is not used.
00443     """
00444       
00445     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00446     common.log( func_id+" Entering... ")      
00447 
00448     # Choose between muon or electron decay of the Z
00449     user_param_sets = "pythiaZll"
00450     electron_flag = "0"
00451     muon_flag = "0"
00452     tau_flag = "0"
00453     if evt_type == "ZEE":
00454         electron_flag = "1"
00455     elif evt_type == "ZMUMU":
00456         muon_flag = "1"    
00457     elif evt_type == "ZTT":
00458         tau_flag = "1"
00459     else:
00460         electron_flag=muon_flag=tau_flag= "1"    
00461     
00462     pythia_param_sets = cms.vstring(
00463                  "MSEL = 11 ",           
00464                  "MDME( 174,1) = 0",            #Z decay into d dbar",
00465                  "MDME( 175,1) = 0",            #Z decay into u ubar",
00466                  "MDME( 176,1) = 0",            #Z decay into s sbar",
00467                  "MDME( 177,1) = 0",            #Z decay into c cbar",
00468                  "MDME( 178,1) = 0",            #Z decay into b bbar",
00469                  "MDME( 179,1) = 0",            #Z decay into t tbar",
00470                  "MDME( 182,1) = %s" %electron_flag,#Z decay into e- e+",
00471                  "MDME( 183,1) = 0",            #Z decay into nu_e nu_ebar",
00472                  "MDME( 184,1) = %s" %muon_flag,#Z decay into mu- mu+",
00473                  "MDME( 185,1) = 0",            #Z decay into nu_mu nu_mubar",
00474                  "MDME( 186,1) = %s" %tau_flag, #Z decay into tau- tau+",
00475                  "MDME( 187,1) = 0",            #Z decay into nu_tau nu_taubar",
00476                  "MSTJ( 11) = 3",    #Choice of the fragmentation function",
00477                  "MSTP( 2) = 1",            #which order running alphaS",
00478                  "MSTP( 33) = 0",            #(D=0) ",
00479                  "MSTP( 51) = 7",            #structure function chosen",
00480                  "MSTP( 81) = 1",            #multiple parton interactions 1 is
00481                                              #Pythia default,
00482                  "MSTP( 82) = 4",            #Defines the multi-parton model",
00483                  "PARJ( 71) = 10.",            #for which ctau  10 mm",
00484                  "PARP( 82) = 1.9",   #pt cutoff for multiparton interactions",
00485                  "PARP( 89) = 1000.", #sqrts for which PARP82 is set",
00486                  "PARP( 83) = 0.5", #Multiple interactions: matter distrbn
00487                                     #parameter Registered byChris.Seez@cern.ch
00488                  "PARP( 84) = 0.4",   #Multiple interactions: matterdistribution
00489                                   #parameter Registered by Chris.Seez@cern.ch
00490                  "PARP( 90) = 0.16",  #Multiple interactions:rescaling power
00491                                       #Registered by Chris.Seez@cern.ch
00492                  "CKIN( 1) = 40.",            #(D=2. GeV)
00493                  "CKIN( 2) = -1.",            #(D=-1. GeV)      \
00494                  )     
00495                  
00496     # Build the process source
00497     generator = cms.EDFilter('Pythia6GeneratorFilter', 
00498                       pythiaPylistVerbosity=cms.untracked.int32(0),
00499                       pythiaHepMCVerbosity=cms.untracked.bool(False),
00500                       maxEventsToPrint = cms.untracked.int32(0), 
00501                       filterEfficiency = cms.untracked.double(1),    
00502                       PythiaParameters = cms.PSet\
00503                                (parameterSets = cms.vstring('PythiaUESettings','processParameters'),
00504                                 PythiaUESettings=user_pythia_ue_settings(),
00505                                 processParameters=pythia_param_sets )
00506                      )
00507 
00508     common.log(func_id+" Returning Generator...")
00509      
00510     return generator   
00511 #---------------------------------
00512 
00513 def _generate_Wl(step, evt_type, energy, evtnumber):
00514     """
00515     Here the settings for the Z ee simulation are added to the process.
00516     Energy parameter is not used.
00517     """
00518       
00519     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00520     common.log( func_id+" Entering... ")      
00521 
00522     # Choose between muon or electron decay of the Z
00523     electron_flag = "0"
00524     muon_flag = "0"
00525     tau_flag = "0"
00526     if evt_type == "WE":
00527         electron_flag = "1"
00528     elif evt_type == "WM":
00529         muon_flag = "1"    
00530     elif evt_type == "WT":
00531         tau_flag = "1"    
00532         
00533     # Build the process source
00534     generator = cms.EDFilter('Pythia6GeneratorFilter', 
00535                       pythiaPylistVerbosity=cms.untracked.int32(0),
00536                       pythiaHepMCVerbosity=cms.untracked.bool(False),
00537                       maxEventsToPrint = cms.untracked.int32(0), 
00538                       filterEfficiency = cms.untracked.double(1),
00539                       PythiaParameters = cms.PSet\
00540                                (parameterSets = cms.vstring('PythiaUESettings','processParameters'),
00541                                 PythiaUESettings=user_pythia_ue_settings(),
00542                                 processParameters=cms.vstring('MSEL=0    !User defined processes',
00543                                                               'MSUB(2)     = 1',#    !W production 
00544                                                               'MDME(190,1) = 0',#    !W decay into dbar u 
00545                                                               'MDME(191,1) = 0',#    !W decay into dbar c 
00546                                                               'MDME(192,1) = 0',#    !W decay into dbar t 
00547                                                               'MDME(194,1) = 0',#    !W decay into sbar u 
00548                                                               'MDME(195,1) = 0',#    !W decay into sbar c 
00549                                                               'MDME(196,1) = 0',#    !W decay into sbar t 
00550                                                               'MDME(198,1) = 0',#    !W decay into bbar u 
00551                                                               'MDME(199,1) = 0',#    !W decay into bbar c 
00552                                                               'MDME(200,1) = 0',#    !W decay into bbar t 
00553                                                               'MDME(205,1) = 0',#    !W decay into bbar tp 
00554                                                               'MDME(206,1) = %s' %electron_flag,#   !W decay into e+ nu_e 
00555                                                               'MDME(207,1) = %s' %muon_flag,#   !W decay into mu+ nu_mu 
00556                                                               'MDME(208,1) = %s' %tau_flag,#   !W decay into tau+ nu_tau
00557                                                              )
00558                               )
00559                      )
00560 
00561     common.log(func_id+" Returning Generator...")
00562      
00563     return generator       
00564                                    
00565 #---------------------------------
00566 
00567 def _generate_ZPJJ(step, evt_type, energy, evtnumber):
00568     """
00569     Here the settings for the Zprime to JJ simulation are added to the
00570     process. 
00571     """
00572     
00573     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00574     common.log(func_id+" Entering... ")            
00575     common.log( func_id+" Returning Generator...")
00576     # You might wonder why this time it's not pythonised..Me too: due to the excessive fragmentation of the 
00577     # cfgs it's not worth to do that at the moment. It also obliges to have two functions for the ZP instead of one.
00578     return common.include_files('Configuration/JetMET/data/calorimetry-gen-Zprime_Dijets_700.cff')[0].source                                   
00579 
00580 #---------------------------------
00581 
00582 def _generate_ZPll(step, evt_type, energy, evtnumber):
00583     """
00584     Here the settings for the Z ee simulation are added to the process.
00585     Energy parameter is not used.
00586     """
00587       
00588     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00589     common.log( func_id+" Entering... ")      
00590 
00591     # Choose between muon or electron decay of the Z
00592     electron_flag = "0"
00593     muon_flag = "0"
00594     tau_flag = "0"
00595     if evt_type == "ZPEE":
00596         electron_flag = "1"
00597     elif evt_type == "ZPMUMU":
00598         muon_flag = "1"    
00599     elif evt_type == "ZPTT":
00600         tau_flag = "1"
00601     else:
00602         electron_flag=muon_flag=tau_flag= "1"    
00603     
00604     # Build the process source
00605     generator = cms.EDFilter('Pythia6GeneratorFilter', 
00606                       pythiaPylistVerbosity=cms.untracked.int32(0),
00607                       pythiaHepMCVerbosity=cms.untracked.bool(False),
00608                       maxEventsToPrint = cms.untracked.int32(0), 
00609                       filterEfficiency = cms.untracked.double(1),    
00610                       PythiaParameters = cms.PSet\
00611                                (parameterSets = cms.vstring('PythiaUESettings','processParameters'),
00612                                 PythiaUESettings=user_pythia_ue_settings(),
00613                                 processParameters=\
00614                                     cms.vstring('MSEL       = 0    ', 
00615                                                 'MSUB(141)  = 1    ',#  !ff  gamma z0 Z0', 
00616                                                 'MSTP(44)   = 3    ',#  !only select the Z process', 
00617                                                 'PMAS(32,1) = %s' %energy,#  !mass of Zprime', 
00618                                                 'CKIN(1)    = 400  ',#  !(D=2. GeV)', 
00619                                                 'MDME(289,1)= 0    ',#  !d dbar', 
00620                                                 'MDME(290,1)= 0    ',#  !u ubar', 
00621                                                 'MDME(291,1)= 0    ',#  !s sbar', 
00622                                                 'MDME(292,1)= 0    ',#  !c cbar', 
00623                                                 'MDME(293,1)= 0    ',#  !b bar', 
00624                                                 'MDME(294,1)= 0    ',#  !t tbar', 
00625                                                 'MDME(295,1)= 0    ',#  !4th gen Q Qbar', 
00626                                                 'MDME(296,1)= 0    ',# !4th gen Q Qbar', 
00627                                                 'MDME(297,1)= %s ' %electron_flag,#  !e e', 
00628                                                 'MDME(298,1)= 0    ',#  !neutrino e e', 
00629                                                 'MDME(299,1)= %s ' %muon_flag,#  ! mu mu', 
00630                                                 'MDME(300,1)= 0    ',#  !neutrino mu mu', 
00631                                                 'MDME(301,1)= %s    ' %tau_flag,#  !tau tau', 
00632                                                 'MDME(302,1)= 0    ',#  !neutrino tau tau', 
00633                                                 'MDME(303,1)= 0    ',#  !4th generation lepton', 
00634                                                 'MDME(304,1)= 0    ',#  !4th generation neutrino', 
00635                                                 'MDME(305,1)= 0    ',#  !W W', 
00636                                                 'MDME(306,1)= 0    ',#  !H  charged higgs', 
00637                                                 'MDME(307,1)= 0    ',#  !Z', 
00638                                                 'MDME(308,1)= 0    ',#  !Z', 
00639                                                 'MDME(309,1)= 0    ',#  !sm higgs', 
00640                                                 'MDME(310,1)= 0    ' #  !weird neutral higgs HA')
00641                                                )
00642                                )
00643                      )
00644 
00645     common.log(func_id+" Returning Generator...")
00646      
00647     return generator                   
00648                                       
00649 #-----------------------------------
00650 
00651 def _generate_RS1GG(step, evt_type, energy, evtnumber):
00652     """
00653     Here the settings for the RS1 graviton into gamma gamma.
00654     """
00655       
00656     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00657     common.log( func_id+" Entering... ")         
00658     
00659     # Build the process source
00660     generator = cms.EDFilter('Pythia6GeneratorFilter', 
00661                       pythiaPylistVerbosity=cms.untracked.int32(0),
00662                       pythiaHepMCVerbosity=cms.untracked.bool(False),
00663                       maxEventsToPrint = cms.untracked.int32(0), 
00664                       filterEfficiency = cms.untracked.double(1),    
00665                       PythiaParameters = cms.PSet\
00666                                (parameterSets = cms.vstring('PythiaUESettings','processParameters'),
00667                                 PythiaUESettings=user_pythia_ue_settings(),
00668                                 processParameters=\
00669                                     cms.vstring('MSEL=0   ', 
00670                                                 'MSUB(391)   =1   ', 
00671                                                 'MSUB(392)   =1   ', 
00672                                                 'PMAS(347,1) = %s ' %energy,# ! minv ', 
00673                                                 'PARP(50)    = 0.54 ',# ! 0.54 == c=0.1', 
00674                                                 'MDME(4158,1)=0   ',
00675                                                 'MDME(4159,1)=0   ',
00676                                                 'MDME(4160,1)=0   ',
00677                                                 'MDME(4161,1)=0   ',
00678                                                 'MDME(4162,1)=0   ',
00679                                                 'MDME(4163,1)=0   ',
00680                                                 'MDME(4164,1)=0   ',
00681                                                 'MDME(4165,1)=0   ',
00682                                                 'MDME(4166,1)=0   ',
00683                                                 'MDME(4167,1)=0   ',
00684                                                 'MDME(4168,1)=0   ',
00685                                                 'MDME(4169,1)=0   ',
00686                                                 'MDME(4170,1)=0   ',
00687                                                 'MDME(4170,1)=0   ',
00688                                                 'MDME(4171,1)=0   ',
00689                                                 'MDME(4172,1)=0   ',
00690                                                 'MDME(4173,1)=0   ',
00691                                                 'MDME(4174,1)=0   ',
00692                                                 'MDME(4175,1)=1   ',#! gamma gamma ', 
00693                                                 'MDME(4176,1)=0   ', 
00694                                                 'MDME(4177,1)=0   ', 
00695                                                 'MDME(4178,1)=0   ', 
00696                                                 'CKIN(3)=20.      ',#! minimum pt hat for hard interactions', 
00697                                                 'CKIN(4)=-1.      '#! maximum pt hat for hard interactions'
00698                                                )
00699                                )
00700                      )
00701 
00702     common.log(func_id+" Returning Generator...")
00703      
00704     return generator                     
00705 #-----------------------------------
00706 
00707 def _generate_HpT(step, evt_type, energy, evtnumber):
00708     """
00709     Here the settings for the RS1 graviton into gamma gamma.
00710     """
00711       
00712     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00713     common.log( func_id+" Entering... ")         
00714     
00715     # Build the process source
00716     generator = cms.EDFilter("Pythia6GeneratorFilter",
00717                       pythiaPylistVerbosity = cms.untracked.int32(0),
00718                       pythiaHepMCVerbosity = cms.untracked.bool(False),
00719                       maxEventsToPrint = cms.untracked.int32(0),
00720                       filterEfficiency = cms.untracked.double(1.0),
00721                       PythiaParameters = cms.PSet(\
00722                        parameterSets = cms.vstring('PythiaUESettings', 'processParameters', 'pythiaMSSMmhmax'),
00723                        PythiaUESettings=user_pythia_ue_settings(),
00724                        processParameters=cms.vstring\
00725                                ('MSEL = 0       ',#         ! user control', 
00726                                 'MSUB(401) = 1  ',#         ! gg->tbH+ Registered by Alexandre.Nikitenko@cern.ch', 
00727                                 'MSUB(402) = 1  ',#         ! qq->tbH+ Registered by Alexandre.Nikitenko@cern.ch', 
00728                                 'IMSS(1)= 1     ',#         ! MSSM ', 'RMSS(5) = 30.           ! TANBETA', 
00729                                 'RMSS(19) = 200.',#         ! (D=850.) m_A', 
00730                                 'MDME(503,1)=0  ',#         !Higgs(H+) decay into dbar            u', 
00731                                 'MDME(504,1)=0  ',#         !Higgs(H+) decay into sbar            c', 
00732                                 'MDME(505,1)=0  ',#         !Higgs(H+) decay into bbar            t', 
00733                                 'MDME(506,1)=0  ',#         !Higgs(H+) decay into b bar           t', 
00734                                 'MDME(507,1)=0  ',#         !Higgs(H+) decay into e+              nu_e', 
00735                                 'MDME(508,1)=0  ',#         !Higgs(H+) decay into mu+             nu_mu', 
00736                                 'MDME(509,1)=1  ',#        !Higgs(H+) decay into tau+            nu_tau', 
00737                                 'MDME(510,1)=0  ',#         !Higgs(H+) decay into tau prime+           nu_tau', 
00738                                 'MDME(511,1)=0  ',#         !Higgs(H+) decay into W+              h0', 
00739                                 'MDME(512,1)=0  ',#         !Higgs(H+) decay into ~chi_10         ~chi_1+', 
00740                                 'MDME(513,1)=0  ',#         !Higgs(H+) decay into ~chi_10         ~chi_2+', 
00741                                 'MDME(514,1)=0  ',#         !Higgs(H+) decay into ~chi_20         ~chi_1+', 
00742                                 'MDME(515,1)=0  ',#         !Higgs(H+) decay into ~chi_20         ~chi_2+', 
00743                                 'MDME(516,1)=0  ',#         !Higgs(H+) decay into ~chi_30         ~chi_1+', 
00744                                 'MDME(517,1)=0  ',#         !Higgs(H+) decay into ~chi_30         ~chi_2+', 
00745                                 'MDME(518,1)=0  ',#         !Higgs(H+) decay into ~chi_40         ~chi_1+', 
00746                                 'MDME(519,1)=0  ',#         !Higgs(H+) decay into ~chi_40         ~chi_2+', 
00747                                 'MDME(520,1)=0  ',#         !Higgs(H+) decay into ~t_1            ~b_1bar', 
00748                                 'MDME(521,1)=0  ',#         !Higgs(H+) decay into ~t_2            ~b_1bar', 
00749                                 'MDME(522,1)=0  ',#         !Higgs(H+) decay into ~t_1            ~b_2bar', 
00750                                 'MDME(523,1)=0  ',#         !Higgs(H+) decay into ~t_2            ~b_2bar', 
00751                                 'MDME(524,1)=0  ',#        !Higgs(H+) decay into ~d_Lbar         ~u_L', 
00752                                 'MDME(525,1)=0  ',#        !Higgs(H+) decay into ~s_Lbar         ~c_L', 
00753                                 'MDME(526,1)=0  ',#         !Higgs(H+) decay into ~e_L+           ~nu_eL', 
00754                                 'MDME(527,1)=0  ',#         !Higgs(H+) decay into ~mu_L+          ~nu_muL', 
00755                                 'MDME(528,1)=0  ',#         !Higgs(H+) decay into ~tau_1+         ~nu_tauL', 
00756                                 'MDME(529,1)=0  '#        !Higgs(H+) decay into ~tau_2+         ~nu_tauL'),
00757                                ),          
00758                         pythiaMSSMmhmax = cms.vstring\
00759                               ('RMSS(2)= 200.    ',#       ! SU(2) gaugino mass ', 
00760                                'RMSS(3)= 800.    ',#       ! SU(3) (gluino) mass ', 
00761                                'RMSS(4)= 200.    ',#      ! higgsino mass parameter', 
00762                                'RMSS(6)= 1000.   ',#       ! left slepton mass', 
00763                                'RMSS(7)= 1000.   ',#       ! right slepton mass', 
00764                                'RMSS(8)= 1000.   ',#       ! right slepton mass', 
00765                                'RMSS(9)= 1000.   ',#       ! right squark mass', 
00766                                'RMSS(10)= 1000.  ',#       ! left sq mass for 3th gen/heaviest stop mass', 
00767                                'RMSS(11)= 1000.  ',#       ! right sbottom mass/lightest sbotoom mass', 
00768                                'RMSS(12)= 1000.  ',#       ! right stop mass/lightest stop mass', 
00769                                'RMSS(13)= 1000.  ',#       ! left stau mass', 
00770                                'RMSS(14)= 1000.  ',#       ! right stau mass', 
00771                                'RMSS(15)= 2449.  ',#       ! Ab', 
00772                                'RMSS(16)= 2449.  ',#       ! At', 
00773                                'RMSS(17)= 2449.  '#       ! Atau'
00774                               )
00775                        )
00776                      )
00777 
00778 
00779     common.log(func_id+" Returning Generator...")
00780      
00781     return generator     
00782     
00783 #---------------------------------    
00784 
00785 def energy_split(energy):
00786     """
00787     Extract from a string of the form "lowenergy*highenergy" two 
00788     bounds. It checks on its consistency. If the format is unknown 
00789     the program stops.
00790     """
00791     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00792     common.log( func_id+" Entering... ") 
00793     
00794     separator_list = ["-", #fault tolerance is good
00795                       "_",
00796                       "*",
00797                       "/",
00798                       ";",
00799                       ","]
00800     for separator in separator_list:
00801         if energy.count(separator)==1:
00802             common.log( func_id+" Found separator in energy string...") 
00803             low,high = energy.split(separator)
00804             if float(high) > float(low):
00805                 common.log(func_id+" Returning Energy...")
00806                 return (low,high)
00807     
00808     raise "Energy Format: ","Unrecognised energy format."
00809 
00810 #-----------------------------------
00811 
00812 def user_pythia_ue_settings():
00813     """
00814     The function simply returns a cms.vstring which is a summary of the 
00815     Pythia settings for the event generation
00816     """
00817     
00818     
00819     
00820     func_id=mod_id+"["+sys._getframe().f_code.co_name+"]"
00821     common.log(func_id+" Returning PythiaUE settings...")
00822     
00823     return common.include_files('Configuration/Generator/data/PythiaUESettings.cfi')[0].pythiaUESettings
00824