Exemplo n.º 1
0
 def test_true(self):
     c = ConfigRegistry.loadpys(self.config, MU_SHIELD_ENABLED=True)
     self.assertIn("muShield", c)
     assert len(ConfigRegistry.keys()) == 1, ConfigRegistry.keys()
     assert self.key in ConfigRegistry.keys()
     assert ConfigRegistry[self.key].Bfield.max == 1.5 * u.kilogauss
     assert ConfigRegistry[self.key].muShield.dZ1 == 2.5 * u.m
Exemplo n.º 2
0
    def setUp(self):
        self.key = "basic"
        config = """
import shipunit as u
from ShipGeoConfig import AttrDict, ConfigRegistry

with ConfigRegistry.register_config("basic") as c:
    c.vetoStation = AttrDict(z=-2390.*u.cm)
    c.TrackStation1 = AttrDict(z=1510.*u.cm)
    c.TrackStation2 = AttrDict(z=1710.*u.cm)
    c.TrackStation3 = AttrDict(z=2150.*u.cm)
    c.TrackStation4 = AttrDict(z=2370.*u.cm)

    c.z = c.TrackStation2.z + 0.5 * (c.TrackStation3.z - c.TrackStation2.z)

    c.Bfield = AttrDict(z=c.z)
    c.Bfield.max = 1.5*u.kilogauss  # was 1.15 in EOI

    # target absorber muon shield setup
    c.decayVolume            =  AttrDict(z=0*u.cm)
    c.decayVolume.length     =   50*u.m

    c.muShield               =  AttrDict(z=0*u.cm)
    c.muShield.dZ1 = 2.5*u.m
    c.muShield.dZ2 = 3.5*u.m
    c.muShield.dZ3 = 3.0*u.m
    c.muShield.dZ4 = 3.0*u.m
    c.muShield.dZ5 = 2.5*u.m
    c.muShield.dZ6 = 2.5*u.m
    c.muShield.LE  = 5*u.m
        """
        ConfigRegistry.loadpys(config)
Exemplo n.º 3
0
 def test_true(self):
     c = ConfigRegistry.loadpys(self.config, MU_SHIELD_ENABLED=True)
     self.assertTrue("muShield" in c)
     assert len(ConfigRegistry.keys()) == 1, ConfigRegistry.keys()
     assert self.key in ConfigRegistry.keys()
     assert ConfigRegistry[self.key].Bfield.max  == 1.5*u.kilogauss
     assert ConfigRegistry[self.key].muShield.dZ1 == 2.5*u.m
Exemplo n.º 4
0
    def setUp(self):
        self.key = "basic"
        config = """
import shipunit as u
from ShipGeoConfig import AttrDict, ConfigRegistry

with ConfigRegistry.register_config("basic") as c:
    c.vetoStation = AttrDict(z=-2390.*u.cm)
    c.TrackStation1 = AttrDict(z=1510.*u.cm)
    c.TrackStation2 = AttrDict(z=1710.*u.cm)
    c.TrackStation3 = AttrDict(z=2150.*u.cm)
    c.TrackStation4 = AttrDict(z=2370.*u.cm)

    c.z = c.TrackStation2.z + 0.5 * (c.TrackStation3.z - c.TrackStation2.z)

    c.Bfield = AttrDict(z=c.z)
    c.Bfield.max = 1.5*u.kilogauss  # was 1.15 in EOI

    # target absorber muon shield setup
    c.decayVolume            =  AttrDict(z=0*u.cm)
    c.decayVolume.length     =   50*u.m

    c.muShield               =  AttrDict(z=0*u.cm)
    c.muShield.dZ1 = 2.5*u.m
    c.muShield.dZ2 = 3.5*u.m
    c.muShield.dZ3 = 3.0*u.m
    c.muShield.dZ4 = 3.0*u.m
    c.muShield.dZ5 = 2.5*u.m
    c.muShield.dZ6 = 2.5*u.m
    c.muShield.LE  = 5*u.m
"""
        ConfigRegistry.loadpys(config)
Exemplo n.º 5
0
def main(arguments):
    logger.info("file: %s" % arguments.config_file)
    if arguments.params is not None:
        logger.info("paramters: %s" % arguments.params)
    ConfigRegistry.loadpy(arguments.config_file, **arguments.params)
    # ConfigRegistry.loadpy(arguments.config_file, muShieldDesign=2, targetOpt=5)
    for k, v in ConfigRegistry().items():
        print("%s: %s" % (k, v))
Exemplo n.º 6
0
def main(arguments):
    logger.info("file: %s" % arguments.config_file)
    if arguments.params is not None:
        logger.info("paramters: %s" % arguments.params)
    ConfigRegistry.loadpy(arguments.config_file, **arguments.params)
    # ConfigRegistry.loadpy(arguments.config_file, muShieldDesign=2, targetOpt=5)
    for k, v in ConfigRegistry().iteritems():
        print "%s: %s" % (k, v)
Exemplo n.º 7
0
 def setUp(self):
     with ConfigRegistry.register_config("bb") as c:
         c.length = 10
         c.width = 20
         c.muShield = AttrDict(z=10) 
     with ConfigRegistry.register_config("cc", base="bb") as c:
         c.height = 30
         c.volume = c.length * c.height * c.width
Exemplo n.º 8
0
 def setUp(self):
     with ConfigRegistry.register_config("bb") as c:
         c.length = 10
         c.width = 20
         c.muShield = AttrDict(z=10)
     with ConfigRegistry.register_config("cc", base="bb") as c:
         c.height = 30
         c.volume = c.length * c.height * c.width
Exemplo n.º 9
0
 def InitTask(self):
# prepare container for fitted tracks
  self.comp  = ROOT.TEveCompound('Fitted tracks')
  evmgr.AddElement(self.comp)
  self.trackColors = {13:ROOT.kGreen,211:ROOT.kRed,11:ROOT.kOrange,321:ROOT.kMagenta}
  ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = int(float(dy)))
  self.bfield = ROOT.genfit.BellField(ShipGeo.Bfield.max ,ShipGeo.Bfield.z,2, ShipGeo.Yheight/2.*u.m)
  self.fM = ROOT.genfit.FieldManager.getInstance()
  self.fM.init(self.bfield)
  self.geoMat =  ROOT.genfit.TGeoMaterialInterface()
  ROOT.genfit.MaterialEffects.getInstance().init(self.geoMat)
  dv = top.GetNode('DecayVolume_1')
  ns = dv.GetNodes()
  T1Lid = ns.FindObject("T1Lid_1").GetMatrix()
  self.z_start = T1Lid.GetTranslation()[2]
  mv = top.GetNode('MuonDetector_1').GetMatrix()
  self.z_end = mv.GetTranslation()[2]
  mM = top.GetNode('MCoil_1').GetMatrix()
  self.z_mag = mM.GetTranslation()[2]
  mE = top.GetNode('Ecal_1').GetMatrix()
  self.z_ecal = mE.GetTranslation()[2]
  self.niter = 100
  self.dz = (self.z_end - self.z_start) / float(self.niter)
  self.parallelToZ = ROOT.TVector3(0., 0., 1.) 
  sc    = evmgr.GetScenes()
  self.evscene = sc.FindChild('Event scene')
Exemplo n.º 10
0
def execute(f,ox,name='ShipGeo'):
    if type(ox) == type(''): ox = ConfigRegistry.register_config("basic")
    o = retrieveGitTags(ox)
    if type(f)==type("s"): fg = ROOT.TFile.Open(f,'update')
    else:                  fg = f 
    pkl = Pickler(fg)
    pkl.dump(o,name)    
    if type(f)==type("s"): fg.Close()
Exemplo n.º 11
0
def loadGeometry(geofile, dy):
    # init geometry and mag. field
    ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy )
    # -----Create geometry----------------------------------------------
    import shipDet_conf
    tgeom = ROOT.TGeoManager("Geometry", "Geane geometry")
    gMan  = tgeom.Import(geofile)
    fGeo = ROOT.gGeoManager
    return {'fGeo':fGeo,'gMan':gMan, 'ShipGeo':ShipGeo}
Exemplo n.º 12
0
    def run_ship(self, phiRandom=False, followMuon=True, n_events=10, first_event=0):
        """
        phiRandom = False  # only relevant for muon background generator
        followMuon = True  # only transport muons for a fast muon only background
        """
        r.gErrorIgnoreLevel = r.kWarning
        r.gSystem.Load('libpythia8')

        print ('FairShip setup to produce', n_events, 'events')
        r.gRandom.SetSeed(self.theSeed)
        ship_geo = ConfigRegistry.loadpy(
            '$FAIRSHIP/geometry/geometry_config.py',
            Yheight=self.dy,
            tankDesign=self.vessel_design,
            muShieldDesign=self.shield_design,
            muShieldGeo=self.shield_geo_file)

        run = r.FairRunSim()
        run.SetName(self.mcEngine)  # Transport engine
        run.SetOutputFile(self.output_file)  # Output file
        # user configuration file default g4Config.C
        run.SetUserConfig('g4Config.C')
        modules = shipDet_conf.configure(run, ship_geo)
        primGen = r.FairPrimaryGenerator()
        primGen.SetTarget(ship_geo.target.z0 + 50 * u.m, 0.)
        MuonBackgen = r.MuonBackGenerator()
        MuonBackgen.Init(self.input_file, first_event, phiRandom)
        MuonBackgen.SetSmearBeam(3 * u.cm)  # beam size mimicking spiral
        if self.same_seed:
            MuonBackgen.SetSameSeed(self.same_seed)
        primGen.AddGenerator(MuonBackgen)
        if not n_events:
            n_events = MuonBackgen.GetNevents()
        else:
            n_events = min(n_events, MuonBackgen.GetNevents())
        print ('Process ', n_events, ' from input file, with Phi random=', phiRandom)
        if followMuon:
            modules['Veto'].SetFastMuon()
        run.SetGenerator(primGen)
        run.SetStoreTraj(r.kFALSE)
        run.Init()
        print ('Initialised run.')
        # geomGeant4.setMagnetField()
        if hasattr(ship_geo.Bfield, "fieldMap"):
            fieldMaker = geomGeant4.addVMCFields(ship_geo, '', True)
        print ('Start run of {} events.'.format(n_events))
        run.Run(n_events)
        print ('Finished simulation of {} events.'.format(n_events))

        geofile_output_path = os.path.join(self.output_dir,
                                           "geofile_full.fe_{}_n_events_{}.root" .format(first_event, n_events))
        run.CreateGeometryFile(geofile_output_path)
        # save ShipGeo dictionary in geofile
        saveBasicParameters.execute(geofile_output_path, ship_geo)
        return run
Exemplo n.º 13
0
    def extract_l_and_w(self, magnet_geofile, full_geometry_file, run=None):
        if not run:
            ship_geo = ConfigRegistry.loadpy(
                '$FAIRSHIP/geometry/geometry_config.py',
                Yheight=10,
                tankDesign=6,
                muShieldDesign=8,
                nuTauTargetDesign=3,
                muShieldGeo=os.path.join(self.geometry_dir, magnet_geofile))

            print
            'Config created with ' + os.path.join(self.geometry_dir,
                                                  magnet_geofile)

            outFile = r.TMemFile('output', 'create')
            run = r.FairRunSim()
            run.SetName('TGeant4')
            run.SetOutputFile(outFile)
            run.SetUserConfig('g4Config.C')
            shipDet_conf.configure(run, ship_geo)
            run.Init()
        run.CreateGeometryFile(
            os.path.join(self.geometry_dir, full_geometry_file))
        sGeo = r.gGeoManager
        muonShield = sGeo.GetVolume('MuonShieldArea')
        L = self.get_magnet_length(muonShield)
        W = self.get_magnet_mass(muonShield)
        g = r.TFile.Open(os.path.join(self.geometry_dir, magnet_geofile),
                         'read')
        params = g.Get("params")
        f = r.TFile.Open(os.path.join(self.geometry_dir, full_geometry_file),
                         'update')
        f.cd()
        length = r.TVectorD(1, array('d', [L]))
        length.Write('length')
        weight = r.TVectorD(1, array('d', [W]))
        weight.Write('weight')
        params.Write("params")

        # Extract coordinates of senstive plane
        nav = r.gGeoManager.GetCurrentNavigator()
        nav.cd("sentsitive_tracker_1")
        tmp = nav.GetCurrentNode().GetVolume().GetShape()
        o = [tmp.GetOrigin()[0], tmp.GetOrigin()[1], tmp.GetOrigin()[2]]
        local = array('d', o)
        globOrigin = array('d', [0, 0, 0])
        nav.LocalToMaster(local, globOrigin)

        sensitive_plane = sGeo.GetVolume('sentsitive_tracker')

        left_end, right_end = globOrigin[2] - sensitive_plane.GetShape().GetDZ(),\
                              globOrigin[2] + sensitive_plane.GetShape().GetDZ()
        return L, W, (left_end, right_end)
Exemplo n.º 14
0
def generate(inputFile, paramFile, outFile, seed=1, nEvents=None):

    firstEvent = 0
    dy = 10.
    vessel_design = 5
    shield_design = 8
    mcEngine = 'TGeant4'
    sameSeed = seed
    theSeed = 1
    phiRandom = False  # only relevant for muon background generator
    followMuon = True  # only transport muons for a fast muon only background
    print('FairShip setup to produce', nEvents, 'events')
    r.gRandom.SetSeed(theSeed)
    ship_geo = ConfigRegistry.loadpy('$FAIRSHIP/geometry/geometry_config.py',
                                     Yheight=dy,
                                     tankDesign=vessel_design,
                                     muShieldDesign=shield_design,
                                     muShieldGeo=paramFile)
    run = r.FairRunSim()
    run.SetName(mcEngine)  # Transport engine
    run.SetOutputFile(outFile)  # Output file
    # user configuration file default g4Config.C
    run.SetUserConfig('g4Config.C')
    modules = shipDet_conf.configure(run, ship_geo)
    primGen = r.FairPrimaryGenerator()
    primGen.SetTarget(ship_geo.target.z0 + 50 * u.m, 0.)
    MuonBackgen = r.MuonBackGenerator()
    MuonBackgen.Init(inputFile, firstEvent, phiRandom)
    MuonBackgen.SetSmearBeam(3 * u.cm)  # beam size mimicking spiral
    if sameSeed:
        MuonBackgen.SetSameSeed(sameSeed)
    primGen.AddGenerator(MuonBackgen)
    nEvents = MuonBackgen.GetNevents() - 1
    print('Process ', nEvents, ' from input file, with Phi random=', phiRandom)
    if followMuon:
        modules['Veto'].SetFastMuon()
    run.SetGenerator(primGen)
    run.SetStoreTraj(r.kFALSE)
    run.Init()
    print('Initialised run.')
    geomGeant4.addVMCFields(ship_geo, '', True)
    print('Start run of {} events.'.format(nEvents))
    run.Run(nEvents)
    print('Finished simulation of {} events.'.format(nEvents))
def get_geo(geoFile):
    """Generate the geometry and check its lenght and weight.

    Note: As FairRunSim is a C++ singleton it misbehaves if run
    more than once in a process.

    Parameters
    ----------
    geoFile : str
        File with the muon shield parameters (not with the geometry config!)

    Returns
    -------
    L : float
        Magnet length in [cm].
    W : float
        Magnet mass in [kg].

    """
    ship_geo = ConfigRegistry.loadpy('$FAIRSHIP/geometry/geometry_config.py',
                                     Yheight=10,
                                     tankDesign=5,
                                     muShieldDesign=8,
                                     muShieldGeo=geoFile)

    print 'Config created with ' + geoFile

    outFile = r.TMemFile('output', 'create')
    run = r.FairRunSim()
    run.SetName('TGeant4')
    run.SetOutputFile(outFile)
    run.SetUserConfig('g4Config.C')
    shipDet_conf.configure(run, ship_geo)
    run.Init()
    run.CreateGeometryFile('./geo/' + os.path.basename(geoFile))
    sGeo = r.gGeoManager
    muonShield = sGeo.GetVolume('MuonShieldArea')
    L = magnetLength(muonShield)
    W = magnetMass(muonShield)
    return L, W
Exemplo n.º 16
0
def create_csv_field_map(options):
    r.gErrorIgnoreLevel = r.kWarning
    r.gSystem.Load('libpythia8')

    ship_geo = ConfigRegistry.loadpy(
        '$FAIRSHIP/geometry/geometry_config.py',
        Yheight=globalDesigns["dy"],
        tankDesign=globalDesigns["dv"],
        nuTauTargetDesign=globalDesigns["nud"],
        CaloDesign=globalDesigns["caloDesign"],
        strawDesign=globalDesigns["strawDesign"],
        muShieldDesign=options.ds,
        muShieldStepGeo=options.muShieldStepGeo,
        muShieldWithCobaltMagnet=options.muShieldWithCobaltMagnet,
        muShieldGeo=options.geofile)

    ship_geo.muShield.WithConstField = True

    run = r.FairRunSim()
    run.SetName('TGeant4')  # Transport engine
    run.SetOutputFile("tmp_file")  # Output file
    # user configuration file default g4Config.C
    run.SetUserConfig('g4Config.C')
    modules = shipDet_conf.configure(run, ship_geo)
    primGen = r.FairPrimaryGenerator()
    primGen.SetTarget(ship_geo.target.z0 + 70.845 * u.m, 0.)
    #
    run.SetGenerator(primGen)
    run.SetStoreTraj(r.kFALSE)
    run.Init()
    fieldMaker = geomGeant4.addVMCFields(ship_geo, '', True)

    field_center, shield_half_length = ShieldUtils.find_shield_center(ship_geo)
    print("SHIELD ONLY: CENTER: {}, HALFLENGTH: {}, half_X: {}, half_Y: {}".
          format(field_center, shield_half_length,
                 ship_geo.muShield.half_X_max, ship_geo.muShield.half_Y_max))
    fieldMaker.generateFieldMap(
        os.path.expandvars("$FAIRSHIP/files/fieldMap.csv"), 2.5,
        ship_geo.muShield.half_X_max, ship_geo.muShield.half_Y_max,
        shield_half_length, field_center)
Exemplo n.º 17
0
    def query_params(self, params):
        magnet_geofile = self.generate_magnet_geofile("query_geo.root", params)
        ship_geo = ConfigRegistry.loadpy(
            '$FAIRSHIP/geometry/geometry_config.py',
            Yheight=10,
            tankDesign=5,
            muShieldDesign=8,
            muShieldGeo=os.path.join(self.geometry_dir, magnet_geofile))
        #shipDet_conf.configure(run, ship_geo)

        outFile = r.TMemFile('output', 'create')
        run = r.FairRunSim()
        run.SetName('TGeant4')
        run.SetOutputFile(outFile)
        run.SetUserConfig('g4Config.C')
        shipDet_conf.configure(run, ship_geo)
        run.Init()
        sGeo = r.gGeoManager
        muonShield = sGeo.GetVolume('MuonShieldArea')
        L = self.get_magnet_length(muonShield)
        W = self.get_magnet_mass(muonShield)
        return L, W
Exemplo n.º 18
0
    def create_context(self, f_name='magnet_geo_tmp.root'):
        magnet_geofile = self.generate_magnet_geofile(
            f_name, self.default_magnet_config)
        ship_geo = ConfigRegistry.loadpy(
            '$FAIRSHIP/geometry/geometry_config.py',
            Yheight=10,
            tankDesign=5,
            muShieldDesign=8,
            muShieldGeo=os.path.join(self.geometry_dir, magnet_geofile))

        print
        'Config created with ' + os.path.join(self.geometry_dir,
                                              magnet_geofile)

        outFile = r.TMemFile('output', 'create')
        run = r.FairRunSim()
        run.SetName('TGeant4')
        run.SetOutputFile(outFile)
        run.SetUserConfig('g4Config.C')
        shipDet_conf.configure(run, ship_geo)
        run.Init()
        return run
Exemplo n.º 19
0
def get_geo(geoFile, workDir='/eos/experiment/ship/user/ffedship/EA_V2/Geometry/', outfile=None):
    if workDir[-1] != '/':
        workDir = workDir + '/'
    if not outfile:
        outfile = workDir + os.path.basename(geoFile)
    else:
        outfile = workDir + outfile
    ship_geo = ConfigRegistry.loadpy(
        '$FAIRSHIP/geometry/geometry_config.py',
        Yheight=10,
        tankDesign=5,
        muShieldDesign=8,
        muShieldGeo=geoFile)

    print 'Get_Geo Message: Config created with ' + geoFile
    outFile = r.TMemFile('output', 'create')  # type: Any
    run = r.FairRunSim()
    run.SetName('TGeant4')
    run.SetOutputFile(outFile)
    run.SetUserConfig('g4Config.C')
    shipDet_conf.configure(run, ship_geo)
    run.Init()
    run.CreateGeometryFile(outfile)
    sGeo = r.gGeoManager
    muonShield = sGeo.GetVolume('MuonShieldArea')
    L = magnetLength(muonShield)
    W = magnetMass(muonShield)
    g = r.TFile.Open(geoFile, 'read')
    params = g.Get("params")
    f = r.TFile.Open(outfile, 'update')
    f.cd()
    length = r.TVectorD(1, array('d', [L]))
    length.Write('length')
    weight = r.TVectorD(1, array('d', [W]))
    weight.Write('weight')
    params.Write("params")
    return L, W
Exemplo n.º 20
0
def configure(run, ship_geo):
    latestCharmGeo = ConfigRegistry.loadpy(
        "$FAIRSHIP/geometry/charm-geometry_config.py")
    # -----Create media-------------------------------------------------
    run.SetMaterials("media.geo")  # Materials

    # -----Create geometry----------------------------------------------
    cave = ROOT.ShipCave("CAVE")
    cave.SetGeometryFileName("caveWithAir.geo")
    detectorList.append(cave)

    Box = ROOT.Box("Box", ship_geo.Box.BrX, ship_geo.Box.BrY, ship_geo.Box.BrZ,
                   ship_geo.Box.zBox, ROOT.kTRUE)
    Box.SetEmulsionParam(ship_geo.Box.EmTh, ship_geo.Box.EmX, ship_geo.Box.EmY,
                         ship_geo.Box.PBTh, ship_geo.Box.EPlW,
                         ship_geo.Box.MolybdenumTh, ship_geo.Box.AllPW)
    Box.SetBrickParam(ship_geo.Box.BrX, ship_geo.Box.BrY, ship_geo.Box.BrZ,
                      ship_geo.Box.BrPackX, ship_geo.Box.BrPackY,
                      ship_geo.Box.BrPackZ)
    Box.SetPassiveParam(ship_geo.Box.PX, ship_geo.Box.PY, ship_geo.Box.PZ)
    Box.SetTargetParam(ship_geo.Box.TX, ship_geo.Box.TY, ship_geo.Box.TZ)
    Box.SetCoolingParam(ship_geo.Box.CoolX, ship_geo.Box.CoolY,
                        ship_geo.Box.CoolZ)
    Box.SetCoatingParam(ship_geo.Box.CoatX, ship_geo.Box.CoatY,
                        ship_geo.Box.CoatZ)

    if (ship_geo.MufluxSpectrometer.muflux == False):
        detectorList.append(Box)

    Spectrometer = ROOT.Spectrometer("Spectrometer", ship_geo.Spectrometer.DX,
                                     ship_geo.Spectrometer.DY,
                                     ship_geo.Spectrometer.DZ, ROOT.kTRUE)
    # -----Goliath part by Annarita--------
    Spectrometer.SetGoliathSizes(ship_geo.Spectrometer.H,
                                 ship_geo.Spectrometer.TS,
                                 ship_geo.Spectrometer.LS,
                                 ship_geo.Spectrometer.BasisH)
    Spectrometer.SetCoilParameters(ship_geo.Spectrometer.CoilR,
                                   ship_geo.Spectrometer.UpCoilH,
                                   ship_geo.Spectrometer.LowCoilH,
                                   ship_geo.Spectrometer.CoilD)
    # --------------------------------------
    Spectrometer.SetBoxParam(ship_geo.Spectrometer.SX,
                             ship_geo.Spectrometer.SY,
                             ship_geo.Spectrometer.SZ,
                             ship_geo.Spectrometer.zBox)

    MufluxSpectrometer = ROOT.MufluxSpectrometer("MufluxSpectrometer",
                                                 ship_geo.Spectrometer.DX,
                                                 ship_geo.Spectrometer.DY,
                                                 ship_geo.Spectrometer.DZ,
                                                 ROOT.kTRUE)
    # -----Drift tube part --------

    MufluxSpectrometer.SetGoliathSizes(ship_geo.Spectrometer.H,
                                       ship_geo.Spectrometer.TS,
                                       ship_geo.Spectrometer.LS,
                                       ship_geo.Spectrometer.BasisH)
    MufluxSpectrometer.SetCoilParameters(ship_geo.Spectrometer.CoilR,
                                         ship_geo.Spectrometer.UpCoilH,
                                         ship_geo.Spectrometer.LowCoilH,
                                         ship_geo.Spectrometer.CoilD)
    # --------------------------------------
    MufluxSpectrometer.SetBoxParam(ship_geo.Spectrometer.SX,
                                   ship_geo.Spectrometer.SY,
                                   ship_geo.Spectrometer.SZ,
                                   ship_geo.Spectrometer.zBox)

    MufluxSpectrometer.SetDeltazView(ship_geo.MufluxSpectrometer.DeltazView)
    MufluxSpectrometer.SetInnerTubeDiameter(
        ship_geo.MufluxSpectrometer.InnerTubeDiameter)
    MufluxSpectrometer.SetOuterTubeDiameter(
        ship_geo.MufluxSpectrometer.OuterTubeDiameter)
    MufluxSpectrometer.SetTubePitch(ship_geo.MufluxSpectrometer.TubePitch)
    MufluxSpectrometer.SetDeltazLayer(ship_geo.MufluxSpectrometer.DeltazLayer)
    MufluxSpectrometer.SetDeltazPlane(ship_geo.MufluxSpectrometer.DeltazPlane)
    MufluxSpectrometer.SetTubesPerLayer(
        ship_geo.MufluxSpectrometer.TubesPerLayer)
    MufluxSpectrometer.SetStereoAngle(ship_geo.MufluxSpectrometer.ViewAngle)
    MufluxSpectrometer.SetWireThickness(
        ship_geo.MufluxSpectrometer.WireThickness)
    MufluxSpectrometer.SetTubeLength(ship_geo.MufluxSpectrometer.TubeLength)
    MufluxSpectrometer.SetTubeLength12(
        ship_geo.MufluxSpectrometer.TubeLength12)
    MufluxSpectrometer.SetTr12YDim(ship_geo.MufluxSpectrometer.tr12ydim)
    MufluxSpectrometer.SetTr34YDim(ship_geo.MufluxSpectrometer.tr34ydim)
    MufluxSpectrometer.SetTr12XDim(ship_geo.MufluxSpectrometer.tr12xdim)
    MufluxSpectrometer.SetTr34XDim(ship_geo.MufluxSpectrometer.tr34xdim)
    MufluxSpectrometer.SetDistStereo(ship_geo.MufluxSpectrometer.diststereo)
    MufluxSpectrometer.SetDistT1T2(ship_geo.MufluxSpectrometer.distT1T2)
    MufluxSpectrometer.SetDistT3T4(ship_geo.MufluxSpectrometer.distT3T4)

    # for the digitizing step
    MufluxSpectrometer.SetTubeResolution(
        ship_geo.MufluxSpectrometer.v_drift,
        ship_geo.MufluxSpectrometer.sigma_spatial)

    Scintillator = ROOT.Scintillator("Scintillator", ROOT.kTRUE)
    Scintillator.SetScoring1XY(ship_geo.MufluxSpectrometer.tr12xdim,
                               ship_geo.MufluxSpectrometer.tr12ydim)
    Scintillator.SetDistT1(ship_geo.MufluxSpectrometer.DeltazView / 2 +
                           ship_geo.MufluxSpectrometer.OuterTubeDiameter / 2 -
                           ship_geo.Scintillator.DistT1)
    Scintillator.SetDistT2(ship_geo.Scintillator.DistT2)

    if (ship_geo.MufluxSpectrometer.muflux == False):
        detectorList.append(Spectrometer)
    else:
        TargetStation = ROOT.MufluxTargetStation(
            "MufluxTargetStation", ship_geo.target.length,
            ship_geo.hadronAbsorber.length, ship_geo.target.z,
            ship_geo.hadronAbsorber.z, ship_geo.targetOpt, ship_geo.target.sl)

        if ship_geo.targetOpt > 10:
            slices_length = ROOT.std.vector('float')()
            slices_material = ROOT.std.vector('string')()
            for i in range(1, ship_geo.targetOpt + 1):
                slices_length.push_back(eval("ship_geo.target.L" + str(i)))
                slices_material.push_back(eval("ship_geo.target.M" + str(i)))

            TargetStation.SetLayerPosMat(ship_geo.target.xy, slices_length,
                                         slices_material)
            detectorList.append(TargetStation)

        detectorList.append(Scintillator)
        detectorList.append(MufluxSpectrometer)

    MuonTagger = ROOT.MuonTagger("MuonTagger", ship_geo.MuonTagger.BX,
                                 ship_geo.MuonTagger.BY,
                                 ship_geo.MuonTagger.BZ,
                                 ship_geo.MuonTagger.zBox, ROOT.kTRUE)
    MuonTagger.SetPassiveParameters(ship_geo.MuonTagger.PX,
                                    ship_geo.MuonTagger.PY,
                                    ship_geo.MuonTagger.PTh)
    MuonTagger.SetSensitiveParameters(ship_geo.MuonTagger.SX,
                                      ship_geo.MuonTagger.SY,
                                      ship_geo.MuonTagger.STh)
    detectorList.append(MuonTagger)
    for x in detectorList:
        run.AddModule(x)

    fMagField = ROOT.ShipGoliathField()

    fieldfile = os.environ["FAIRSHIP"] + "/field/GoliathFieldMap.root"
    fMagField.Init(fieldfile)
    run.SetField(fMagField)

    # return list of detector elements
    detElements = {}
    for x in run.GetListOfModules():
        detElements[x.GetName()] = x

    return detElements
Exemplo n.º 21
0
def configure(run, ship_geo):
    # ---- for backward compatibility ----
    if not hasattr(ship_geo, "tankDesign"): ship_geo.tankDesign = 4
    if not hasattr(ship_geo.hcal, "File"): ship_geo.hcal.File = "hcal.geo"
    if not hasattr(ship_geo.Bfield, 'x'): ship_geo.Bfield.x = 3. * u.m
    if not hasattr(ship_geo, 'cave'):
        ship_geo.cave = AttrDict(z=0 * u.cm)
        ship_geo.cave.floorHeightMuonShield = 5 * u.m
        ship_geo.cave.floorHeightTankA = 4.5 * u.m
        ship_geo.cave.floorHeightTankB = 2. * u.m
    latestShipGeo = ConfigRegistry.loadpy(
        "$FAIRSHIP/geometry/geometry_config.py",
        Yheight=ship_geo.Yheight / u.m,
        tankDesign=ship_geo.tankDesign,
        muShieldDesign=ship_geo.muShieldDesign,
        nuTauTargetDesign=ship_geo.nuTauTargetDesign)
    # -----Create media-------------------------------------------------
    run.SetMaterials("media.geo")  # Materials
    # ------------------------------------------------------------------------

    # -----Create geometry----------------------------------------------
    cave = ROOT.ShipCave("CAVE")
    if ship_geo.tankDesign < 5: cave.SetGeometryFileName("cave.geo")
    else: cave.SetGeometryFileName("caveWithAir.geo")
    detectorList.append(cave)

    if ship_geo.muShieldDesign == 6 or ship_geo.muShieldDesign == 7:  # magnetized hadron absorber defined in ShipMuonShield
        TargetStation = ROOT.ShipTargetStation("TargetStation",
                                               ship_geo.target.length,
                                               ship_geo.target.z,
                                               ship_geo.targetOpt,
                                               ship_geo.target.sl)
    else:
        TargetStation = ROOT.ShipTargetStation(
            "TargetStation", ship_geo.target.length,
            ship_geo.hadronAbsorber.length, ship_geo.target.z,
            ship_geo.hadronAbsorber.z, ship_geo.targetOpt, ship_geo.target.sl)

    if ship_geo.targetOpt > 10:
        slices_length = ROOT.std.vector('float')()
        slices_material = ROOT.std.vector('std::string')()
        for i in range(1, ship_geo.targetOpt + 1):
            slices_length.push_back(eval("ship_geo.target.L" + str(i)))
            slices_material.push_back(eval("ship_geo.target.M" + str(i)))
        TargetStation.SetLayerPosMat(ship_geo.target.xy, slices_length,
                                     slices_material)
    detectorList.append(TargetStation)

    if ship_geo.muShieldDesign == 1:
        MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.length,\
                                         ship_geo.muShield.LE)
    elif ship_geo.muShieldDesign == 2:
        MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.dZ1,\
                     ship_geo.muShield.dZ2,ship_geo.muShield.dZ3,ship_geo.muShield.dZ4,ship_geo.muShield.dZ5,ship_geo.muShield.dZ6,ship_geo.muShield.LE)
    elif ship_geo.muShieldDesign == 3 or ship_geo.muShieldDesign == 4 or ship_geo.muShieldDesign == 5 or ship_geo.muShieldDesign == 6 or ship_geo.muShieldDesign == 7:
        if not hasattr(ship_geo.muShield, "Field"):
            MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.dZ1,\
                        ship_geo.muShield.dZ2,ship_geo.muShield.dZ3,ship_geo.muShield.dZ4,ship_geo.muShield.dZ5,ship_geo.muShield.dZ6,\
                        ship_geo.muShield.dZ7,ship_geo.muShield.dZ8,ship_geo.muShield.dXgap,ship_geo.muShield.LE,ship_geo.Yheight*4./10., ship_geo.cave.floorHeightMuonShield)
        else:
            MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.dZ1,\
                        ship_geo.muShield.dZ2,ship_geo.muShield.dZ3,ship_geo.muShield.dZ4,ship_geo.muShield.dZ5,ship_geo.muShield.dZ6,\
                        ship_geo.muShield.dZ7,ship_geo.muShield.dZ8,ship_geo.muShield.dXgap,ship_geo.muShield.LE,ship_geo.Yheight*4./10.,\
                        ship_geo.cave.floorHeightMuonShield,ship_geo.muShield.Field)

    detectorList.append(MuonShield)

    magnet_design = 2
    if ship_geo.tankDesign == 5: magnet_design = 3
    if ship_geo.strawDesign > 1:
        magnet = ROOT.ShipMagnet("Magnet", "SHiP Magnet", ship_geo.Bfield.z,
                                 magnet_design, ship_geo.Bfield.x,
                                 ship_geo.Bfield.y,
                                 ship_geo.cave.floorHeightTankB)
    else:
        magnet = ROOT.ShipMagnet("Magnet", "SHiP Magnet", ship_geo.Bfield.z)
    detectorList.append(magnet)

    Veto = ROOT.veto("Veto", ROOT.kTRUE)  # vacuum tank
    Veto.SetLiquidVeto(1)  # liquid scintillator
    Veto.SetPlasticVeto(1)  # plastic scintillator

    Veto.SetZpositions(ship_geo.vetoStation.z, ship_geo.TrackStation1.z, ship_geo.TrackStation2.z, \
                       ship_geo.TrackStation3.z, ship_geo.TrackStation4.z,ship_geo.tankDesign)
    Veto.SetTubZpositions(ship_geo.Chamber1.z, ship_geo.Chamber2.z,
                          ship_geo.Chamber3.z, ship_geo.Chamber4.z,
                          ship_geo.Chamber5.z, ship_geo.Chamber6.z)
    Veto.SetTublengths(ship_geo.chambers.Tub1length,ship_geo.chambers.Tub2length,ship_geo.chambers.Tub3length, \
                       ship_geo.chambers.Tub4length,ship_geo.chambers.Tub5length,ship_geo.chambers.Tub6length)
    Veto.SetB(ship_geo.Yheight / 2.)
    Veto.SetFloorHeight(ship_geo.cave.floorHeightTankA,
                        ship_geo.cave.floorHeightTankB)
    if ship_geo.tankDesign == 5:
        dzX = ship_geo.zFocusX + ship_geo.target.z0
        x1 = ship_geo.xMax / (ship_geo.Chamber1.z -
                              ship_geo.chambers.Tub1length -
                              dzX) * (ship_geo.TrackStation4.z - dzX)
        dzY = ship_geo.zFocusY + ship_geo.target.z0
        y1 = ship_geo.Yheight / (ship_geo.Chamber1.z -
                                 ship_geo.chambers.Tub1length -
                                 dzY) * (ship_geo.TrackStation4.z - dzY)
        Veto.SetXYstart(x1, dzX, y1, dzY)
        Veto.SetVesselStructure(ship_geo.Veto.innerSupport,ship_geo.Veto.sensitiveThickness,ship_geo.Veto.outerSupport,\
                                ship_geo.Veto.innerSupportMed,ship_geo.Veto.lidThickness,ship_geo.Veto.sensitiveMed,\
                                ship_geo.Veto.outerSupportMed,ship_geo.Veto.decayMed,\
                                ship_geo.Veto.rib,ship_geo.Veto.ribMed)

    detectorList.append(Veto)

    if ship_geo.muShieldDesign not in [2, 3, 4] and hasattr(
            ship_geo.tauMS, 'Xtot'):
        taumagneticspectrometer = ROOT.MagneticSpectrometer(
            "MagneticSpectrometer", ship_geo.tauMS.zMSC, ROOT.kTRUE)
        taumagneticspectrometer.SetTotDimensions(ship_geo.tauMS.Xtot,
                                                 ship_geo.tauMS.Ytot,
                                                 ship_geo.tauMS.Ztot)
        taumagneticspectrometer.SetFeDimensions(ship_geo.tauMS.XFe,
                                                ship_geo.tauMS.YFe,
                                                ship_geo.tauMS.ZFe)
        taumagneticspectrometer.SetRpcDimensions(ship_geo.tauMS.XRpc,
                                                 ship_geo.tauMS.YRpc,
                                                 ship_geo.tauMS.ZRpc)
        taumagneticspectrometer.SetRpcGasDimensions(ship_geo.tauMS.XGas,
                                                    ship_geo.tauMS.YGas,
                                                    ship_geo.tauMS.ZGas)
        taumagneticspectrometer.SetRpcStripDimensions(ship_geo.tauMS.XStrip,
                                                      ship_geo.tauMS.YStrip,
                                                      ship_geo.tauMS.ZStrip)
        taumagneticspectrometer.SetRpcElectrodeDimensions(
            ship_geo.tauMS.XEle, ship_geo.tauMS.YEle, ship_geo.tauMS.ZEle)
        taumagneticspectrometer.SetRpcPETDimensions(ship_geo.tauMS.XPet,
                                                    ship_geo.tauMS.YPet,
                                                    ship_geo.tauMS.ZPet)
        taumagneticspectrometer.SetReturnYokeDimensions(
            ship_geo.tauMS.XRyoke, ship_geo.tauMS.YRyoke,
            ship_geo.tauMS.ZRyoke)
        taumagneticspectrometer.SetSmallerYokeDimensions(
            ship_geo.tauMS.XRyoke_s, ship_geo.tauMS.YRyoke_s,
            ship_geo.tauMS.ZRyoke_s)
        taumagneticspectrometer.SetZDimensionArm(ship_geo.tauMS.ZArm)
        taumagneticspectrometer.SetGapDownstream(ship_geo.tauMS.GapD)
        taumagneticspectrometer.SetGapMiddle(ship_geo.tauMS.GapM)
        taumagneticspectrometer.SetNFeInArm(ship_geo.tauMS.NFe)
        taumagneticspectrometer.SetNRpcInArm(ship_geo.tauMS.NRpc)
        taumagneticspectrometer.SetMagneticField(ship_geo.tauMS.B)
        taumagneticspectrometer.SetCoilParameters(ship_geo.tauMS.CoilH,
                                                  ship_geo.tauMS.CoilW,
                                                  ship_geo.tauMS.N,
                                                  ship_geo.tauMS.CoilG)
        taumagneticspectrometer.SetPillarDimensions(ship_geo.tauMS.PillarX,
                                                    ship_geo.tauMS.PillarY,
                                                    ship_geo.tauMS.PillarZ)
        detectorList.append(taumagneticspectrometer)

        tauHpt = ROOT.Hpt("HighPrecisionTrackers", ship_geo.tauHPT.DX,
                          ship_geo.tauHPT.DY, ship_geo.tauHPT.DZ, ROOT.kTRUE)
        tauHpt.SetZsize(ship_geo.tauMS.Ztot)
        tauHpt.SetConcreteBaseDim(ship_geo.tauHPT.ConcreteX,
                                  ship_geo.tauHPT.ConcreteY,
                                  ship_geo.tauHPT.ConcreteZ)
        detectorList.append(tauHpt)

        if ship_geo.nuTauTargetDesign == 0 or ship_geo.nuTauTargetDesign == 1:
            EmuMagnet = ROOT.EmulsionMagnet("EmuMagnet", ship_geo.EmuMagnet.zC,
                                            "EmulsionMagnet")
            EmuMagnet.SetDesign(ship_geo.EmuMagnet.Design)
            EmuMagnet.SetGaps(ship_geo.EmuMagnet.GapUp,
                              ship_geo.EmuMagnet.GapDown)
            EmuMagnet.SetMagneticField(ship_geo.EmuMagnet.B)
            EmuMagnet.SetMagnetSizes(ship_geo.EmuMagnet.X,
                                     ship_geo.EmuMagnet.Y,
                                     ship_geo.EmuMagnet.Z)
            EmuMagnet.SetCoilParameters(ship_geo.EmuMagnet.Radius,
                                        ship_geo.EmuMagnet.Height1,
                                        ship_geo.EmuMagnet.Height2,
                                        ship_geo.EmuMagnet.Distance)
            EmuMagnet.SetMagnetColumn(ship_geo.EmuMagnet.ColX,
                                      ship_geo.EmuMagnet.ColY,
                                      ship_geo.EmuMagnet.ColZ)
            EmuMagnet.SetBaseDim(ship_geo.EmuMagnet.BaseX,
                                 ship_geo.EmuMagnet.BaseY,
                                 ship_geo.EmuMagnet.BaseZ)
            EmuMagnet.SetPillarDimensions(ship_geo.EmuMagnet.PillarX,
                                          ship_geo.EmuMagnet.PillarY,
                                          ship_geo.EmuMagnet.PillarZ)
            detectorList.append(EmuMagnet)
        if ship_geo.nuTauTargetDesign == 2:
            EmuMagnet = ROOT.EmulsionMagnet()

        NuTauTarget = ROOT.Target("NuTauTarget", ship_geo.NuTauTarget.Ydist,
                                  ROOT.kTRUE)
        NuTauTarget.MakeNuTargetPassive(ship_geo.NuTauTarget.nuTargetPassive)
        NuTauTarget.SetDetectorDesign(ship_geo.NuTauTarget.Design)
        NuTauTarget.SetCenterZ(ship_geo.NuTauTarget.zC)
        NuTauTarget.SetNumberBricks(ship_geo.NuTauTarget.col,
                                    ship_geo.NuTauTarget.row,
                                    ship_geo.NuTauTarget.wall)
        NuTauTarget.SetDetectorDimension(ship_geo.NuTauTarget.xdim,
                                         ship_geo.NuTauTarget.ydim,
                                         ship_geo.NuTauTarget.zdim)
        NuTauTarget.SetEmulsionParam(
            ship_geo.NuTauTarget.EmTh, ship_geo.NuTauTarget.EmX,
            ship_geo.NuTauTarget.EmY, ship_geo.NuTauTarget.PBTh,
            ship_geo.NuTauTarget.EPlW, ship_geo.NuTauTarget.LeadTh,
            ship_geo.NuTauTarget.AllPW)

        NuTauTarget.SetBrickParam(ship_geo.NuTauTarget.BrX,
                                  ship_geo.NuTauTarget.BrY,
                                  ship_geo.NuTauTarget.BrZ,
                                  ship_geo.NuTauTarget.BrPackX,
                                  ship_geo.NuTauTarget.BrPackY,
                                  ship_geo.NuTauTarget.BrPackZ)
        NuTauTarget.SetCESParam(ship_geo.NuTauTarget.RohG,
                                ship_geo.NuTauTarget.LayerCESW,
                                ship_geo.NuTauTarget.CESW,
                                ship_geo.NuTauTarget.CESPack)
        NuTauTarget.SetCellParam(ship_geo.NuTauTarget.CellW)
        if ship_geo.nuTauTargetDesign == 0 or ship_geo.nuTauTargetDesign == 1:
            NuTauTarget.SetMagneticField(ship_geo.EmuMagnet.B)
            NuTauTarget.SetMagnetHeight(ship_geo.EmuMagnet.Y)
            NuTauTarget.SetColumnHeight(ship_geo.EmuMagnet.ColY)
            NuTauTarget.SetBaseHeight(ship_geo.EmuMagnet.BaseY)
            NuTauTarget.SetCoilUpHeight(ship_geo.EmuMagnet.Height1)
            NuTauTarget.SetCoilDownHeight(ship_geo.EmuMagnet.Height2)
        if ship_geo.nuTauTargetDesign == 2:
            NuTauTarget.SetPillarDimension(ship_geo.NuTauTarget.PillarX,
                                           ship_geo.NuTauTarget.PillarY,
                                           ship_geo.NuTauTarget.PillarZ)
            NuTauTarget.SetBaseDimension(ship_geo.NuTauTarget.BaseX,
                                         ship_geo.NuTauTarget.BaseY,
                                         ship_geo.NuTauTarget.BaseZ)

        NuTauTT = ROOT.TargetTracker("TargetTrackers", ROOT.kTRUE)
        NuTauTT.SetNumberTT(ship_geo.NuTauTT.n)
        NuTauTT.SetTargetTrackerParam(ship_geo.NuTauTT.TTX,
                                      ship_geo.NuTauTT.TTY,
                                      ship_geo.NuTauTT.TTZ)
        NuTauTT.SetBrickParam(ship_geo.NuTauTarget.CellW)
        NuTauTT.SetTotZDimension(ship_geo.NuTauTarget.zdim)

        #method of nutau target that must be called after TT parameter definition
        NuTauTarget.SetTTzdimension(ship_geo.NuTauTT.TTZ)

        detectorList.append(NuTauTarget)
        detectorList.append(NuTauTT)

    if ship_geo.strawDesign > 1:
        Strawtubes = ROOT.strawtubes("Strawtubes", ROOT.kTRUE)
        Strawtubes.SetZpositions(ship_geo.vetoStation.z,
                                 ship_geo.TrackStation1.z,
                                 ship_geo.TrackStation2.z,
                                 ship_geo.TrackStation3.z,
                                 ship_geo.TrackStation4.z)
        Strawtubes.SetDeltazView(ship_geo.strawtubes.DeltazView)
        Strawtubes.SetInnerStrawDiameter(
            ship_geo.strawtubes.InnerStrawDiameter)
        Strawtubes.SetOuterStrawDiameter(
            ship_geo.strawtubes.OuterStrawDiameter)
        Strawtubes.SetStrawPitch(ship_geo.strawtubes.StrawPitch)
        Strawtubes.SetDeltazLayer(ship_geo.strawtubes.DeltazLayer)
        Strawtubes.SetDeltazPlane(ship_geo.strawtubes.DeltazPlane)
        Strawtubes.SetStrawsPerLayer(ship_geo.strawtubes.StrawsPerLayer)
        Strawtubes.SetStereoAngle(ship_geo.strawtubes.ViewAngle)
        Strawtubes.SetWireThickness(ship_geo.strawtubes.WireThickness)
        Strawtubes.SetVacBox_x(ship_geo.strawtubes.VacBox_x)
        Strawtubes.SetVacBox_y(ship_geo.strawtubes.VacBox_y)
        Strawtubes.SetStrawLength(ship_geo.strawtubes.StrawLength)

        if hasattr(ship_geo.strawtubes, "StrawLengthVeto"):
            Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLengthVeto)
            Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength12)
            Strawtubes.SetVetoYDim(ship_geo.strawtubes.vetoydim)
            Strawtubes.SetTr12YDim(ship_geo.strawtubes.tr12ydim)
            Strawtubes.SetTr34YDim(ship_geo.strawtubes.tr34ydim)
        else:
            Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLength)
            Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength)
            Strawtubes.SetVetoYDim(ship_geo.Yheight / 2.)
            Strawtubes.SetTr12YDim(ship_geo.Yheight / 2.)
            Strawtubes.SetTr34YDim(ship_geo.Yheight / 2.)
        # for the digitizing step
        Strawtubes.SetStrawResolution(
            getParameter("strawtubes.v_drift", ship_geo, latestShipGeo),
            getParameter("strawtubes.sigma_spatial", ship_geo, latestShipGeo))
        detectorList.append(Strawtubes)

    if ship_geo.preshowerOption > 0:
        Preshower = ROOT.preshower("Preshower", ROOT.kTRUE)
        Preshower.SetZStationPosition2(ship_geo.PreshowerStation0.z,
                                       ship_geo.PreshowerStation1.z)
        Preshower.SetZFilterPosition2(ship_geo.PreshowerFilter0.z,
                                      ship_geo.PreshowerFilter1.z)
        Preshower.SetXMax(ship_geo.Preshower.XMax)
        Preshower.SetYMax(ship_geo.Preshower.YMax)
        Preshower.SetActiveThickness(ship_geo.Preshower.ActiveThickness)
        Preshower.SetFilterThickness2(ship_geo.Preshower.FilterThickness0,
                                      ship_geo.Preshower.FilterThickness1)
        detectorList.append(Preshower)

    ecal, EcalZSize = posEcal(ship_geo.ecal.z, ship_geo.ecal.File)
    detectorList.append(ecal)

    if not ship_geo.HcalOption < 0:
        hcal, HcalZSize = posHcal(ship_geo.hcal.z, ship_geo.hcal.File)
        if abs(ship_geo.hcal.hcalSpace - HcalZSize) > 10 * u.cm:
            print 'mismatch between hcalsize in geo file and python configuration'
            print ship_geo.hcal.hcalSpace - HcalZSize, ship_geo.hcal.hcalSpace, HcalZSize
        detectorList.append(hcal)
    Muon = ROOT.muon("Muon", ROOT.kTRUE)
    Muon.SetZStationPositions(ship_geo.MuonStation0.z, ship_geo.MuonStation1.z,
                              ship_geo.MuonStation2.z, ship_geo.MuonStation3.z)
    Muon.SetZFilterPositions(ship_geo.MuonFilter0.z, ship_geo.MuonFilter1.z,
                             ship_geo.MuonFilter2.z)
    Muon.SetXMax(ship_geo.Muon.XMax)
    Muon.SetYMax(ship_geo.Muon.YMax)
    Muon.SetActiveThickness(ship_geo.Muon.ActiveThickness)
    Muon.SetFilterThickness(ship_geo.Muon.FilterThickness)
    detectorList.append(Muon)

    #-----   Magnetic field   -------------------------------------------
    if ship_geo.strawDesign == 4:
        fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max,
                                       ship_geo.Bfield.z, 2,
                                       ship_geo.Yheight / 2. * u.m)
    else:
        fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max,
                                       ship_geo.Bfield.z, 1,
                                       ship_geo.Yheight / 2. * u.m)
    if ship_geo.muShieldDesign == 6:
        fMagField.IncludeTarget(ship_geo.target.xy, ship_geo.target.z0,
                                ship_geo.target.length)
    run.SetField(fMagField)
    #
    exclusionList = []
    #exclusionList = ["Muon","Ecal","Hcal","Strawtubes","TargetTrackers","NuTauTarget","HighPrecisionTrackers",\
    #                 "Veto","Magnet","MuonShield","TargetStation","MagneticSpectrometer","EmuMagnet"]
    for x in detectorList:
        if x.GetName() in exclusionList: continue
        run.AddModule(x)


# return list of detector elements
    detElements = {}
    for x in run.GetListOfModules():
        detElements[x.GetName()] = x
    return detElements
Exemplo n.º 22
0
def run_track_pattern_recognition(input_file, geo_file, output_file, method):
    """
    Runs all steps of track pattern recognition.
    Parameters
    ----------
    input_file : string
        Path to an input .root file with events.
    geo_file : string
        Path to a file with SHiP geometry.
    output_file : string
        Path to an output .root file with quality plots.
    method : string
        Name of a track pattern recognition method.
    """

    ############################################# Load SHiP geometry ###################################################

    # Check geo file
    try:
        fgeo = ROOT.TFile(geo_file)
    except:
        print "An error with opening the ship geo file."
        raise

    sGeo = fgeo.FAIRGeom

    # Prepare ShipGeo dictionary
    if not fgeo.FindKey('ShipGeo'):

        if sGeo.GetVolume('EcalModule3'):
            ecalGeoFile = "ecal_ellipse6x12m2.geo"
        else:
            ecalGeoFile = "ecal_ellipse5x10m2.geo"

        if dy:
            ShipGeo = ConfigRegistry.loadpy(
                "$FAIRSHIP/geometry/geometry_config.py",
                Yheight=dy,
                EcalGeoFile=ecalGeoFile)
        else:
            ShipGeo = ConfigRegistry.loadpy(
                "$FAIRSHIP/geometry/geometry_config.py",
                EcalGeoFile=ecalGeoFile)

    else:
        upkl = Unpickler(fgeo)
        ShipGeo = upkl.load('ShipGeo')

    # Globals
    builtin.ShipGeo = ShipGeo

    ############################################# Load SHiP modules ####################################################

    run = ROOT.FairRunSim()
    modules = shipDet_conf.configure(run, ShipGeo)

    ############################################# Load inpur data file #################################################

    # Check input file
    try:
        fn = ROOT.TFile(input_file, 'update')
    except:
        print "An error with opening the input data file."
        raise

    sTree = fn.cbmsim
    sTree.Write()

    ############################################# Create hists #########################################################

    h = init_book_hist()

    ########################################## Start Track Pattern Recognition #########################################
    import shipPatRec

    # Init book of hists for the quality measurements
    metrics = {
        'n_hits': [],
        'reconstructible': 0,
        'passed_y12': 0,
        'passed_stereo12': 0,
        'passed_12': 0,
        'passed_y34': 0,
        'passed_stereo34': 0,
        'passed_34': 0,
        'passed_combined': 0,
        'reco_passed': 0,
        'reco_passed_no_clones': 0,
        'frac_y12': [],
        'frac_stereo12': [],
        'frac_12': [],
        'frac_y34': [],
        'frac_stereo34': [],
        'frac_34': [],
        'reco_frac_tot': [],
        'reco_mc_p': [],
        'reco_mc_theta': [],
        'fitted_p': [],
        'fitted_pval': [],
        'fitted_chi': [],
        'fitted_x': [],
        'fitted_y': [],
        'fitted_z': [],
        'fitted_mass': []
    }

    # Start event loop
    nEvents = sTree.GetEntries()

    for iEvent in range(nEvents):

        if iEvent % 1000 == 0:
            print 'Event ', iEvent

        ########################################### Select one event ###################################################

        rc = sTree.GetEvent(iEvent)

        ########################################### Reconstructible tracks #############################################

        reconstructible_tracks = getReconstructibleTracks(
            iEvent, sTree, sGeo, ShipGeo)

        metrics['reconstructible'] += len(reconstructible_tracks)
        for i_reco in reconstructible_tracks:
            h['TracksPassed'].Fill("Reconstructible tracks", 1)
            h['TracksPassedU'].Fill("Reconstructible tracks", 1)

        in_y12 = []
        in_stereo12 = []
        in_12 = []
        in_y34 = []
        in_stereo34 = []
        in_34 = []
        in_combo = []

        ########################################## Recognized tracks ###################################################

        nTracklets = sTree.Tracklets.GetEntriesFast()

        for i_track in range(nTracklets):

            atracklet = sTree.Tracklets[i_track]

            if atracklet.getType() != 1:  # this is a not full track (tracklet)
                continue

            atrack = atracklet.getList()

            if atrack.size() == 0:
                continue

            hits = {
                'X': [],
                'Y': [],
                'Z': [],
                'DetID': [],
                'TrackID': [],
                'Pz': [],
                'Px': [],
                'Py': [],
                'dist2Wire': [],
                'Pdg': []
            }

            for ihit in atrack:
                ahit = sTree.strawtubesPoint[ihit]
                hits['X'] += [ahit.GetX()]
                hits['Y'] += [ahit.GetY()]
                hits['Z'] += [ahit.GetZ()]
                hits['DetID'] += [ahit.GetDetectorID()]
                hits['TrackID'] += [ahit.GetTrackID()]
                hits['Pz'] += [ahit.GetPz()]
                hits['Px'] += [ahit.GetPx()]
                hits['Py'] += [ahit.GetPy()]
                hits['dist2Wire'] += [ahit.dist2Wire()]
                hits['Pdg'] += [ahit.PdgCode()]

            # List to numpy arrays
            for key in hits.keys():
                hits[key] = numpy.array(hits[key])

            # Decoding
            statnb, vnb, pnb, lnb, snb = decodeDetectorID(hits['DetID'])
            is_stereo = ((vnb == 1) + (vnb == 2))
            is_y = ((vnb == 0) + (vnb == 3))
            is_before = ((statnb == 1) + (statnb == 2))
            is_after = ((statnb == 3) + (statnb == 4))

            # Metrics
            metrics['n_hits'] += [get_n_hits(hits['TrackID'])]

            # Tracks passed
            frac_y12, tmax_y12 = fracMCsame(hits['TrackID'][is_before * is_y])
            n_hits_y12 = get_n_hits(hits['TrackID'][is_before * is_y])
            frac_stereo12, tmax_stereo12 = fracMCsame(
                hits['TrackID'][is_before * is_stereo])
            n_hits_stereo12 = get_n_hits(hits['TrackID'][is_before *
                                                         is_stereo])
            frac_12, tmax_12 = fracMCsame(hits['TrackID'][is_before])
            n_hits_12 = get_n_hits(hits['TrackID'][is_before])

            frac_y34, tmax_y34 = fracMCsame(hits['TrackID'][is_after * is_y])
            n_hits_y34 = get_n_hits(hits['TrackID'][is_after * is_y])
            frac_stereo34, tmax_stereo34 = fracMCsame(
                hits['TrackID'][is_after * is_stereo])
            n_hits_stereo34 = get_n_hits(hits['TrackID'][is_after * is_stereo])
            frac_34, tmax_34 = fracMCsame(hits['TrackID'][is_after])
            n_hits_34 = get_n_hits(hits['TrackID'][is_after])
            frac_tot, tmax_tot = fracMCsame(hits['TrackID'])
            n_hits_tot = get_n_hits(hits['TrackID'])

            is_reconstructed = 0
            is_reconstructed_no_clones = 0

            if tmax_y12 in reconstructible_tracks:
                metrics['passed_y12'] += 1
                metrics['frac_y12'] += [frac_y12]
                h['TracksPassed'].Fill("Y view station 1&2", 1)
                if tmax_y12 not in in_y12:
                    h['TracksPassedU'].Fill("Y view station 1&2", 1)
                    in_y12.append(tmax_y12)

                if tmax_stereo12 == tmax_y12:
                    metrics['passed_stereo12'] += 1
                    metrics['frac_stereo12'] += [frac_stereo12]
                    h['TracksPassed'].Fill("Stereo station 1&2", 1)
                    if tmax_stereo12 not in in_stereo12:
                        h['TracksPassedU'].Fill("Stereo station 1&2", 1)
                        in_stereo12.append(tmax_stereo12)

                    if tmax_12 == tmax_y12:
                        metrics['passed_12'] += 1
                        metrics['frac_12'] += [frac_12]
                        h['TracksPassed'].Fill("station 1&2", 1)
                        if tmax_12 not in in_12:
                            h['TracksPassedU'].Fill("station 1&2", 1)
                            in_12.append(tmax_12)

                        if tmax_y34 in reconstructible_tracks:
                            metrics['passed_y34'] += 1
                            metrics['frac_y34'] += [frac_y34]
                            h['TracksPassed'].Fill("Y view station 3&4", 1)
                            if tmax_y34 not in in_y34:
                                h['TracksPassedU'].Fill(
                                    "Y view station 3&4", 1)
                                in_y34.append(tmax_y34)

                            if tmax_stereo34 == tmax_y34:
                                metrics['passed_stereo34'] += 1
                                metrics['frac_stereo34'] += [frac_stereo34]
                                h['TracksPassed'].Fill("Stereo station 3&4", 1)
                                if tmax_stereo34 not in in_stereo34:
                                    h['TracksPassedU'].Fill(
                                        "Stereo station 3&4", 1)
                                    in_stereo34.append(tmax_stereo34)

                                if tmax_34 == tmax_y34:
                                    metrics['passed_34'] += 1
                                    metrics['frac_34'] += [frac_34]
                                    h['TracksPassed'].Fill("station 3&4", 1)
                                    if tmax_34 not in in_34:
                                        h['TracksPassedU'].Fill(
                                            "station 3&4", 1)
                                        in_34.append(tmax_34)

                                if tmax_12 == tmax_34:
                                    metrics['passed_combined'] += 1
                                    h['TracksPassed'].Fill(
                                        "Combined stations 1&2/3&4", 1)
                                    metrics['reco_passed'] += 1
                                    is_reconstructed = 1
                                    if tmax_34 not in in_combo:
                                        h['TracksPassedU'].Fill(
                                            "Combined stations 1&2/3&4", 1)
                                        metrics['reco_passed_no_clones'] += 1
                                        in_combo.append(tmax_34)
                                        is_reconstructed_no_clones = 1

            # For reconstructed tracks
            if is_reconstructed == 0:
                continue

            metrics['reco_frac_tot'] += [frac_tot]

            # Momentum
            Pz = hits['Pz']
            Px = hits['Px']
            Py = hits['Py']
            P = numpy.sqrt(Pz**2 + Px**2 + Py**2)
            P = P[hits['TrackID'] == tmax_tot]
            p = numpy.mean(P)

            metrics['reco_mc_p'] += [p]
            h['TracksPassed_p'].Fill(p, 1)

            # Direction
            Z = hits['Z'][(hits['TrackID'] == tmax_tot) * is_before]
            X = hits['X'][(hits['TrackID'] == tmax_tot) * is_before]
            Y = hits['Y'][(hits['TrackID'] == tmax_tot) * is_before]
            Z = Z - Z[0]
            X = X - X[0]
            Y = Y - Y[0]
            R = numpy.sqrt(X**2 + Y**2 + Z**2)
            Theta = numpy.arccos(Z[1:] / R[1:])
            theta = numpy.mean(Theta)

            metrics['reco_mc_theta'] += [theta]

            h['n_hits_reco_y12'].Fill(n_hits_y12)
            h['n_hits_reco_stereo12'].Fill(n_hits_stereo12)
            h['n_hits_reco_12'].Fill(n_hits_12)
            h['n_hits_reco_y34'].Fill(n_hits_y34)
            h['n_hits_reco_stereo34'].Fill(n_hits_stereo34)
            h['n_hits_reco_34'].Fill(n_hits_34)
            h['n_hits_reco'].Fill(n_hits_tot)

            h['n_hits_y12'].Fill(p, n_hits_y12)
            h['n_hits_stereo12'].Fill(p, n_hits_stereo12)
            h['n_hits_12'].Fill(p, n_hits_12)
            h['n_hits_y34'].Fill(p, n_hits_y34)
            h['n_hits_stereo34'].Fill(p, n_hits_stereo34)
            h['n_hits_34'].Fill(p, n_hits_34)
            h['n_hits_total'].Fill(p, n_hits_tot)

            h['frac_y12'].Fill(p, frac_y12)
            h['frac_stereo12'].Fill(p, frac_stereo12)
            h['frac_12'].Fill(p, frac_12)
            h['frac_y34'].Fill(p, frac_y34)
            h['frac_stereo34'].Fill(p, frac_stereo34)
            h['frac_34'].Fill(p, frac_34)
            h['frac_total'].Fill(p, frac_tot)

            # Fitted track

            thetrack = sTree.FitTracks[i_track]

            fitStatus = thetrack.getFitStatus()
            thetrack.prune(
                "CFL"
            )  # http://sourceforge.net/p/genfit/code/HEAD/tree/trunk/core/include/Track.h#l280

            nmeas = fitStatus.getNdf()
            pval = fitStatus.getPVal()
            chi2 = fitStatus.getChi2() / nmeas

            metrics['fitted_pval'] += [pval]
            metrics['fitted_chi'] += [chi2]

            h['chi2fittedtracks'].Fill(chi2)
            h['pvalfittedtracks'].Fill(pval)

            fittedState = thetrack.getFittedState()
            fittedMom = fittedState.getMomMag()
            fittedMom = fittedMom  #*int(charge)

            metrics['fitted_p'] += [fittedMom]
            perr = (p - fittedMom) / p
            h['ptrue-p/ptrue'].Fill(perr)
            h['perr'].Fill(p, perr)
            h['perr_direction'].Fill(numpy.rad2deg(theta), perr)

            if math.fabs(p) > 0.0:
                h['pvspfitted'].Fill(p, fittedMom)
            fittedtrackDir = fittedState.getDir()
            fittedx = math.degrees(math.acos(fittedtrackDir[0]))
            fittedy = math.degrees(math.acos(fittedtrackDir[1]))
            fittedz = math.degrees(math.acos(fittedtrackDir[2]))
            fittedmass = fittedState.getMass()
            h['momentumfittedtracks'].Fill(fittedMom)
            h['xdirectionfittedtracks'].Fill(fittedx)
            h['ydirectionfittedtracks'].Fill(fittedy)
            h['zdirectionfittedtracks'].Fill(fittedz)
            h['massfittedtracks'].Fill(fittedmass)

            metrics['fitted_x'] += [fittedx]
            metrics['fitted_y'] += [fittedy]
            metrics['fitted_z'] += [fittedz]
            metrics['fitted_mass'] += [fittedmass]

    ############################################# Save hists #########################################################

    save_hists(h, output_file)

    return metrics
Exemplo n.º 23
0
        else:
            logger.warn("...use '-f' option to overwrite it")
    else:
        os.makedirs(work_dir)
    return args


args = init()
os.chdir(work_dir)
# -------------------------------------------------------------------
ROOT.gRandom.SetSeed(
    theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()  # load basic libraries, prepare atexit for python
#this is for the muon flux geometry
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py",
                                 Setup=args.CharmdetSetup,
                                 cTarget=args.CharmTarget)

txt = 'pythia8_Geant4_'
if withEvtGen: txt = 'pythia8_evtgen_Geant4_'
outFile = outputDir + '/' + txt + str(runnr) + '_' + str(ecut) + '.root'
parFile = outputDir + '/ship.params.' + txt + str(runnr) + '_' + str(
    ecut) + '.root'

# -----Timer--------------------------------------------------------
timer = ROOT.TStopwatch()
timer.Start()

# -----Create simulation run----------------------------------------
run = ROOT.FairRunSim()
run.SetName(mcEngine)  # Transport engine
Exemplo n.º 24
0
 def test_readDOS(self):
     c = ConfigRegistry.loadpy(self.filename, Yheight = 1)
     self.assertTrue("vetoStation" in c)
     assert ConfigRegistry[self.key].vetoStation.z == -2390*u.cm
Exemplo n.º 25
0
        if o in ("-f"):
            inputFile = a
        if o in ("-A"):
            inclusive = True
        if o in ("-F"):
            deepCopy = True

print "FairShip setup for",simEngine,"to produce",nEvents,"events"
if (simEngine == "Ntuple" or simEngine == "MuonBack") and not inputFile :
  print 'input file required if simEngine = Ntuple or MuonBack'
ROOT.gRandom.SetSeed(theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()      # load basic libraries, prepare atexit for python
# - muShieldDesign = 2  # 1=passive 2=active
# - targetOpt      = 5  # 0=solid   >0 sliced, 5 pieces of tungsten, 4 air slits
# - strawDesign       = 1  # simplistic tracker design,  3=sophisticated straw tube design, horizontal wires
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py",strawDesign=4,muShieldDesign=5,targetOpt=5)
# Output file name
tag = simEngine+"-"+mcEngine
if eventDisplay: tag = tag+'_D'
outFile ="ship."+tag+".root"  

# rm older files !!! 
os.system("rm *."+tag+".root")
# Parameter file name
parFile="ship.params."+tag+".root"

# In general, the following parts need not be touched
# ========================================================================

# -----Timer--------------------------------------------------------
timer = ROOT.TStopwatch()
Exemplo n.º 26
0
 def test_len(self):
     assert len(ConfigRegistry.keys()) == 1, ConfigRegistry.keys()
Exemplo n.º 27
0
        else:
            logger.warn("...use '-f' option to overwrite it")
    else:
        os.makedirs(work_dir)
    return args


args = init()
os.chdir(work_dir)
# -------------------------------------------------------------------
ROOT.gRandom.SetSeed(
    args.seed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()  # load basic libraries, prepare atexit for python
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py",
                                 Yheight=dy,
                                 tankDesign=dv,
                                 muShieldDesign=ds,
                                 nuTauTargetDesign=nud)

txt = 'pythia8_Geant4_'
if withEvtGen: txt = 'pythia8_evtgen_Geant4_'
outFile = outputDir + '/' + txt + str(runnr) + '_' + str(ecut) + '.root'
parFile = outputDir + '/ship.params.' + txt + str(runnr) + '_' + str(
    ecut) + '.root'

# -----Timer--------------------------------------------------------
timer = ROOT.TStopwatch()
timer.Start()

# -----Create simulation run----------------------------------------
run = ROOT.FairRunSim()
Exemplo n.º 28
0
 def test_true(self):
     c = ConfigRegistry.loadpys(self.config)
     self.assertTrue("vetoStation" in c)
     assert ConfigRegistry[self.key].vetoStation.z == -2390*u.cm
Exemplo n.º 29
0
 def setUp(self):
     self.key = "bb"
     with ConfigRegistry.register_config("bb") as c:
         c.length = 10
         c.width = 20
Exemplo n.º 30
0
 def tearDown(self):
     ConfigRegistry.clean()
Exemplo n.º 31
0
 def test_latest(self):
     c = ConfigRegistry.get_latest_config()
     self.assertTrue(c is not None)
     self.assertEqual(c.height, 30)
Exemplo n.º 32
0
 def test_key(self):
     assert "bb" in ConfigRegistry.keys()
     assert "cc" in ConfigRegistry.keys()
Exemplo n.º 33
0
if "nuTargetDesign" not in globals():
    nuTargetDesign = 1
if "targetOpt" not in globals():
    targetOpt = 17
if "strawDesign" not in globals():
    strawDesign = 4
if "HcalOption" not in globals():
    HcalOption = 1
if "Yheight" not in globals():
    Yheight = 10.
if "EcalGeoFile" not in globals():
    EcalGeoFile = "ecal_ellipse5x10m2.geo" 
if "preshowerOption" not in globals():
    preshowerOption = 0

with ConfigRegistry.register_config("basic") as c:
    # global muShieldDesign, targetOpt, strawDesign, Yheight
    c.Yheight = Yheight*u.m
    # decision by the SP 
    totalLength       = 2.5*c.Yheight + 35*u.m
    extraVesselLength = totalLength - 50*u.m
    windowBulge = 1*u.m
    c.strawDesign = strawDesign
    c.chambers = AttrDict(z=0*u.cm)
    if strawDesign != 4:
     print "this design is not supported, use strawDesign = 4"
     1/0 
    else:
     c.chambers.Length = totalLength
     magnetIncrease    = 100.*u.cm
     c.chambers.Tub1length = 2.5*u.m
Exemplo n.º 34
0
 def test_key(self):
     assert self.key in ConfigRegistry.keys()
Exemplo n.º 35
0
import shipunit as u
from ShipGeoConfig import AttrDict, ConfigRegistry
# the following params should be passed through 'ConfigRegistry.loadpy' method
# none for the moment
with ConfigRegistry.register_config("basic") as c:

    c.MufluxSpectrometer = AttrDict(z=0 * u.cm)
    # False = charm cross-section; True = muon flux measurement
    c.MufluxSpectrometer.muflux = False

    if "targetOpt" not in globals():
        targetOpt = 18  # add extra 20cm of tungsten as per 13/06/2017

    c.target = AttrDict(z0=0 * u.cm)

    c.Bfield = AttrDict(z=0 * u.cm)
    c.Bfield.max = 10. * u.kilogauss  # 1.4361*u.kilogauss for SHiP
    c.Bfield.y = 1.8 * u.m  # dummy value
    c.Bfield.x = 5.0 * u.m  # dummy value
    c.Bfield.z = 3.571 * u.m
    #BOX (Brick!)
    c.Box = AttrDict(z=0 * u.cm)
    c.Box.BX = 13 * u.cm
    c.Box.BY = 11 * u.cm
    c.Box.BZ = 20 * u.cm
    c.Box.zBox = 0 * u.cm
    c.Box.EmTh = 0.0045 * u.cm
    c.Box.EmX = 10 * u.cm  #for the moment, replace the previous values for normal simulations
    c.Box.EmY = 10 * u.cm
    c.Box.PBTh = 0.0205 * u.cm
    c.Box.MolybdenumTh = 0.3 * u.cm
Exemplo n.º 36
0
import shipunit as u
from ShipGeoConfig import AttrDict, ConfigRegistry
# the following params should be passed through 'ConfigRegistry.loadpy' method
# muShieldDesign = 1  # 1=passive 2=active
# targetOpt      = 5  # 0=solid   >0 sliced, 5 pieces of tungsten, 4 air slits

with ConfigRegistry.register_config("basic") as c:
    c.vetoStation = AttrDict(z=-2390.*u.cm)
    c.TrackStation1 = AttrDict(z=1510.*u.cm)
    c.TrackStation2 = AttrDict(z=1710.*u.cm)
    c.TrackStation3 = AttrDict(z=2150.*u.cm)
    c.TrackStation4 = AttrDict(z=2370.*u.cm)

    c.z = c.TrackStation2.z + 0.5 * (c.TrackStation3.z - c.TrackStation2.z)

    c.Bfield = AttrDict(z=c.z)
    c.Bfield.max = 1.5*u.kilogauss  # was 1.15 in EOI

    # target absorber muon shield setup
    c.decayVolume            =  AttrDict(z=0*u.cm)
    c.decayVolume.length     =   50*u.m

    c.muShield               =  AttrDict(z=0*u.cm)
    c.muShield.dZ1 = 2.5*u.m
    c.muShield.dZ2 = 3.5*u.m
    c.muShield.dZ3 = 3.0*u.m
    c.muShield.dZ4 = 3.0*u.m
    c.muShield.dZ5 = 2.5*u.m
    c.muShield.dZ6 = 2.5*u.m
    c.muShield.LE  = 5*u.m
Exemplo n.º 37
0
    sys.exit()
if simEngine == "Nuage" and not inputFile:
    inputFile = 'Numucc.root'

print "FairShip setup for", simEngine, "to produce", nEvents, "events"
if (simEngine == "Ntuple" or simEngine == "MuonBack") and defaultInputFile:
    print 'input file required if simEngine = Ntuple or MuonBack'
    print " for example -f /eos/experiment/ship/data/Mbias/pythia8_Geant4-withCharm_onlyMuons_4magTarget.root"
    sys.exit()
ROOT.gRandom.SetSeed(
    theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure(0)  # load basic libraries, prepare atexit for python
# - muShieldDesign = 2  # 1=passive 5=active (default) 7=short design+magnetized hadron absorber
# - targetOpt      = 5  # 0=solid   >0 sliced, 5: 5 pieces of tungsten, 4 H20 slits, 17: Mo + W +H2O (default)
#   nuTauTargetDesign = 0 # 0 = TP, 1 = NEW with magnet, 2 = NEW without magnet, 3 = 2018 design
if charm == 0:    ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, tankDesign = dv, \
                                     muShieldDesign = ds, nuTauTargetDesign=nud, CaloDesign=caloDesign, strawDesign=strawDesign, muShieldGeo=geofile)
else:
    ship_geo = ConfigRegistry.loadpy(
        "$FAIRSHIP/geometry/charm-geometry_config.py", Setup=CharmdetSetup)
    if CharmdetSetup == 0: print "Setup for muon flux measurement has been set"
    else: print "Setup for charm cross section measurement has been set"
# switch off magnetic field to measure muon flux
#ship_geo.muShield.Field = 0.
#ship_geo.EmuMagnet.B = 0.
#ship_geo.tauMudet.B = 0.

# Output file name, add dy to be able to setup geometry with ambiguities.
if simEngine == "PG": tag = simEngine + "_" + str(pID) + "-" + mcEngine
else: tag = simEngine + "-" + mcEngine
if charmonly: tag = simEngine + "CharmOnly-" + mcEngine
if eventDisplay: tag = tag + '_D'
Exemplo n.º 38
0
 def test_false(self):
     ConfigRegistry.loadpys(self.config, MU_SHIELD_ENABLED=False)
     assert len(ConfigRegistry.keys()) == 1, ConfigRegistry.keys()
     assert self.key in ConfigRegistry.keys()
     assert ConfigRegistry[self.key].Bfield.max  == 1.5*u.kilogauss
     self.assertTrue("muShield" not in ConfigRegistry[self.key])
Exemplo n.º 39
0
def dmetric(input_file, geo_file, dy, reconstructiblerequired, threeprong):

    ############################################# Load SHiP geometry ###################################################

    # Check geo file
    try:
        fgeo = ROOT.TFile(geo_file)
    except:
        print "An error with opening the ship geo file."
        raise

    sGeo = fgeo.FAIRGeom

    # Prepare ShipGeo dictionary
    if not fgeo.FindKey('ShipGeo'):

        if sGeo.GetVolume('EcalModule3') :
            ecalGeoFile = "ecal_ellipse6x12m2.geo"
        else:
            ecalGeoFile = "ecal_ellipse5x10m2.geo"

        if dy:
            ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, EcalGeoFile = ecalGeoFile)
        else:
            ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", EcalGeoFile = ecalGeoFile)

    else:
        upkl    = Unpickler(fgeo)
        ShipGeo = upkl.load('ShipGeo')

    ############################################# Load SHiP modules ####################################################

    run = ROOT.FairRunSim()
    modules = shipDet_conf.configure(run,ShipGeo)

    ############################################# Load input data file #################################################

    # Check input file
    try:
        fn = ROOT.TFile(input_file,'update')
    except:
        print "An error with opening the input data file."
        raise

    sTree = fn.cbmsim

    ############################## Initialize SHiP Spectrometer Tracker geometry #######################################

    zlayer, \
    zlayerv2, \
    z34layer, \
    z34layerv2, \
    TStation1StartZ, \
    TStation4EndZ, \
    VetoStationZ, \
    VetoStationEndZ = initialize(ShipGeo)


    ########################################## Start Checking Geometry #################################################

    all_hits = pandas.DataFrame(columns=['event_id', 'det_id', 'track_id', 'xtop', 'ytop', 'z', 'xbot', 'ybot'])
    all_hits_i = 0
    
    # Start event loop
    nEvents   = sTree.GetEntries()

    for iEvent in range(nEvents):

        if iEvent%100 == 0:
            print 'Event ', iEvent

        ########################################### Select one event ###################################################

        rc = sTree.GetEvent(iEvent)

        ############################################# Get hits #########################################################
        
        reco_mc_tracks = getReconstructibleTracks(iEvent,
                                                  sTree,
                                                  sGeo,
                                                  reconstructiblerequired,
                                                  threeprong,
                                                  TStation1StartZ,
                                                  TStation4EndZ,
                                                  VetoStationZ,
                                                  VetoStationEndZ)
        
        #consider only reconstructible events
        if len(reco_mc_tracks) > 1:

            nHits = sTree.strawtubesPoint.GetEntriesFast()
            key = -1

            for i in range(nHits):

                ahit = sTree.strawtubesPoint[i]

                key+=1
                detID = ahit.GetDetectorID()
                trID = ahit.GetTrackID()
                top = ROOT.TVector3()
                bot = ROOT.TVector3()

                modules["Strawtubes"].StrawEndPoints(detID,bot,top)

                all_hits.loc[all_hits_i] = [iEvent, detID, trID, top.x(), top.y(), top.z(), bot.x(), bot.y()]
                all_hits_i += 1
            
    all_hits['StatNb'] = all_hits['det_id'] // 10000000
    all_hits['ViewNb'] = (all_hits['det_id'] - all_hits['StatNb'] * 10000000) // 1000000
    all_hits['PlaneNb'] = (all_hits['det_id'] - all_hits['StatNb'] * 10000000 - all_hits['ViewNb'] * 1000000) // 100000
    all_hits['LayerNb'] = (all_hits['det_id'] - all_hits['StatNb'] * 10000000 - all_hits['ViewNb'] * 1000000 -\
                           all_hits['PlaneNb'] * 100000) // 10000
    all_hits['StrawNb'] = all_hits['det_id'] - all_hits['StatNb'] * 10000000 - all_hits['ViewNb'] * 1000000 -\
                          all_hits['PlaneNb'] * 100000 - all_hits['LayerNb'] * 10000 - 2000
    
    #return daniel's metric
    df_1_view = all_hits[(all_hits.StatNb==1)&(all_hits.ViewNb==0)]
    counts = df_1_view.groupby(['event_id', 'track_id'])['StatNb'].count()
    all_tracks = len(all_hits.groupby(['event_id', 'track_id'])['StatNb'].count())
    
    return 1. * np.sum(counts>1) / all_tracks
Exemplo n.º 40
0
        for f in files:
          os.unlink(os.path.join(root, f))
        for d in dirs:
          shutil.rmtree(os.path.join(root, d))
    else:
      logger.warn("...use '-f' option to overwrite it")
  else:
    os.makedirs(work_dir)
  return args

args = init()
os.chdir(work_dir)
# -------------------------------------------------------------------
ROOT.gRandom.SetSeed(args.seed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()      # load basic libraries, prepare atexit for python
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, tankDesign = dv, muShieldDesign = ds, nuTauTargetDesign=nud)

txt = 'pythia8_Geant4_'
if withEvtGen: txt = 'pythia8_evtgen_Geant4_'
outFile = outputDir+'/'+txt+str(runnr)+'_'+str(ecut)+'.root'
parFile = outputDir+'/ship.params.'+txt+str(runnr)+'_'+str(ecut)+'.root'

# -----Timer--------------------------------------------------------
timer = ROOT.TStopwatch()
timer.Start()

# -----Create simulation run----------------------------------------
run = ROOT.FairRunSim()
run.SetName(mcEngine)  # Transport engine
run.SetOutputFile(outFile)  # Output file
run.SetUserConfig("g4Config.C") # user configuration file default g4Config.C
Exemplo n.º 41
0
def configure(run,ship_geo,Gfield=''):
 latestCharmGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py")
# -----Create media-------------------------------------------------
 run.SetMaterials("media.geo")  # Materials
 
# -----Create geometry----------------------------------------------
 cave= ROOT.ShipCave("CAVE")
 cave.SetGeometryFileName("caveWithAir.geo")
 detectorList.append(cave)
    

 if (ship_geo.MufluxSpectrometer.muflux==False):
# === Emulsion Target 
    Box = ROOT.Box("Box",ship_geo.Box.BrX, ship_geo.Box.BrY, ship_geo.Box.BrZ, ship_geo.Box.zBox,ROOT.kTRUE)
    Box.SetEmulsionParam(ship_geo.Box.EmTh, ship_geo.Box.EmX, ship_geo.Box.EmY, ship_geo.Box.PBTh,ship_geo.Box.EPlW, ship_geo.Box.PasSlabTh, ship_geo.Box.AllPW);
    Box.SetBrickParam(ship_geo.Box.BrX, ship_geo.Box.BrY, ship_geo.Box.BrZ, ship_geo.Box.BrPackX, ship_geo.Box.BrPackY, ship_geo.Box.BrPackZ);
    Box.SetTargetParam(ship_geo.Box.TX, ship_geo.Box.TY, ship_geo.Box.TZ);
    Box.SetPassiveComposition(ship_geo.Box.Molblock1Z, ship_geo.Box.Molblock2Z, ship_geo.Box.Molblock3Z, ship_geo.Box.Molblock4Z, ship_geo.Box.Wblock1Z, ship_geo.Box.Wblock2Z, ship_geo.Box.Wblock3Z, ship_geo.Box.Wblock3_5Z, ship_geo.Box.Wblock4Z)
    Box.SetPassiveSampling(ship_geo.Box.Passive3mmZ, ship_geo.Box.Passive2mmZ, ship_geo.Box.Passive1mmZ)
    Box.SetCoolingParam(ship_geo.Box.CoolX, ship_geo.Box.CoolY, ship_geo.Box.CoolZ)
    Box.SetCoatingParam(ship_geo.Box.CoatX, ship_geo.Box.CoatY, ship_geo.Box.CoatZ)
    Box.SetGapGeometry(ship_geo.Box.distancePassive2ECC)
    Box.SetTargetDesign(ship_geo.Box.Julytarget)
    Box.SetRunNumber(ship_geo.Box.RunNumber)
    detectorList.append(Box)
# === SciFi modules
    SciFi = ROOT.SciFi("SciFi",ship_geo.SciFi.DX, ship_geo.SciFi.DY, ship_geo.SciFi.DZ,ROOT.kTRUE)
    SciFi.SetBoxParam(ship_geo.SciFi.DX,ship_geo.SciFi.DY,ship_geo.SciFi.DZ, ship_geo.SciFi.zBox)
    SciFi.SetStationNumber(ship_geo.SciFi.nstations)
    SciFi.SetStationDimensions(ship_geo.SciFi.StationDimX, ship_geo.SciFi.StationDimY, ship_geo.SciFi.StationDimZ)
    for i, (x, y, z) in enumerate(zip(ship_geo.SciFi.xSi,ship_geo.SciFi.ySi,ship_geo.SciFi.zSi)):
    	SciFi.SetStationPositions(i, x, y, z)
# === Pixel modules
    PixelModules = ROOT.PixelModules("PixelModules",ship_geo.PixelModules.DX, ship_geo.PixelModules.DY, ship_geo.PixelModules.DZ,ROOT.kTRUE)
    PixelModules.SetBoxParam(ship_geo.PixelModules.DX,ship_geo.PixelModules.DY,ship_geo.PixelModules.DZ, ship_geo.PixelModules.zBox, ship_geo.PixelModules.DimZpixelbox, ship_geo.PixelModules.D1short, ship_geo.PixelModules.D1long)
    PixelModules.SetSiliconDZ(ship_geo.PixelModules.DimZSi)
# === SciFi modules
    detectorList.append(SciFi)
# === Pixel modules
    detectorList.append(PixelModules)
    for i, (x, y, z) in enumerate(zip(ship_geo.PixelModules.xSi,ship_geo.PixelModules.ySi,ship_geo.PixelModules.zSi)):
    	PixelModules.SetSiliconStationPositions(i, x, y, z)

 Spectrometer = ROOT.Spectrometer("Spectrometer",ship_geo.Spectrometer.DX, ship_geo.Spectrometer.DY, ship_geo.Spectrometer.DZ,ROOT.kTRUE)
 Spectrometer.SetTransverseSizes(ship_geo.Spectrometer.D1Short, ship_geo.Spectrometer.D1Long)
# -----Goliath part by Annarita--------
 Spectrometer.SetGoliathSizes(ship_geo.Spectrometer.H, ship_geo.Spectrometer.TS, ship_geo.Spectrometer.LS, ship_geo.Spectrometer.BasisH);
 Spectrometer.SetCoilParameters(ship_geo.Spectrometer.CoilR, ship_geo.Spectrometer.UpCoilH, ship_geo.Spectrometer.LowCoilH,  ship_geo.Spectrometer.CoilD);
# --------------------------------------
 Spectrometer.SetBoxParam(ship_geo.Spectrometer.SX,ship_geo.Spectrometer.SY,ship_geo.Spectrometer.SZ,ship_geo.Spectrometer.zBox)
 if (ship_geo.MufluxSpectrometer.muflux==False):
  MufluxSpectrometer = ROOT.MufluxSpectrometer("MufluxSpectrometer",ship_geo.MufluxSpectrometer.DX, ship_geo.MufluxSpectrometer.DY,   ship_geo.MufluxSpectrometer.DZ,ROOT.kTRUE)
 else:
  MufluxSpectrometer = ROOT.MufluxSpectrometer("MufluxSpectrometer",ship_geo.Spectrometer.DX, ship_geo.Spectrometer.DY, ship_geo.Spectrometer.DZ,ROOT.kTRUE)
 # -----Drift tube part --------
 
 MufluxSpectrometer.SetGoliathSizes(ship_geo.Spectrometer.H, ship_geo.Spectrometer.TS, ship_geo.Spectrometer.LS, ship_geo.Spectrometer.BasisH);
 MufluxSpectrometer.SetCoilParameters(ship_geo.Spectrometer.CoilR, ship_geo.Spectrometer.UpCoilH, ship_geo.Spectrometer.LowCoilH,  ship_geo.Spectrometer.CoilD);
# --------------------------------------
 
 MufluxSpectrometer.ChooseDetector(ship_geo.MufluxSpectrometer.muflux)
 MufluxSpectrometer.SetDeltazView(ship_geo.MufluxSpectrometer.DeltazView)
 MufluxSpectrometer.SetInnerTubeDiameter(ship_geo.MufluxSpectrometer.InnerTubeDiameter)
 MufluxSpectrometer.SetOuterTubeDiameter(ship_geo.MufluxSpectrometer.OuterTubeDiameter)
 MufluxSpectrometer.SetTubePitch(ship_geo.MufluxSpectrometer.TubePitch)
 MufluxSpectrometer.SetTubePitch_T1u(ship_geo.MufluxSpectrometer.TubePitch_T1u,ship_geo.MufluxSpectrometer.T1u_const,ship_geo.MufluxSpectrometer.T1u_const_2,ship_geo.MufluxSpectrometer.T1u_const_3,ship_geo.MufluxSpectrometer.T1u_const_4)
 MufluxSpectrometer.SetTubePitch_T2v(ship_geo.MufluxSpectrometer.TubePitch_T2v,ship_geo.MufluxSpectrometer.T2v_const,ship_geo.MufluxSpectrometer.T2v_const_2,ship_geo.MufluxSpectrometer.T2v_const_3,ship_geo.MufluxSpectrometer.T2v_const_4) 
 MufluxSpectrometer.SetDeltazLayer(ship_geo.MufluxSpectrometer.DeltazLayer)
 MufluxSpectrometer.SetDeltazPlane(ship_geo.MufluxSpectrometer.DeltazPlane)
 MufluxSpectrometer.SetTubesPerLayer(ship_geo.MufluxSpectrometer.TubesPerLayer)
 MufluxSpectrometer.SetStereoAngle(ship_geo.MufluxSpectrometer.ViewAngle, ship_geo.MufluxSpectrometer.ViewvAngle)
 MufluxSpectrometer.SetWireThickness(ship_geo.MufluxSpectrometer.WireThickness)
 MufluxSpectrometer.SetTubeLength(ship_geo.MufluxSpectrometer.TubeLength)
 MufluxSpectrometer.SetTubeLength12(ship_geo.MufluxSpectrometer.TubeLength12) 
 MufluxSpectrometer.SetTr12YDim(ship_geo.MufluxSpectrometer.tr12ydim)
 MufluxSpectrometer.SetTr34YDim(ship_geo.MufluxSpectrometer.tr34ydim)
 MufluxSpectrometer.SetTr12XDim(ship_geo.MufluxSpectrometer.tr12xdim)
 MufluxSpectrometer.SetTr34XDim(ship_geo.MufluxSpectrometer.tr34xdim) 
 MufluxSpectrometer.SetDistStereo(ship_geo.MufluxSpectrometer.diststereoT1,ship_geo.MufluxSpectrometer.diststereoT2)
 MufluxSpectrometer.SetDistT1T2(ship_geo.MufluxSpectrometer.distT1T2)
 MufluxSpectrometer.SetDistT3T4(ship_geo.MufluxSpectrometer.distT3T4)    
 MufluxSpectrometer.SetGoliathCentre(ship_geo.MufluxSpectrometer.goliathcentre_to_beam)
 MufluxSpectrometer.SetGoliathCentreZ(ship_geo.MufluxSpectrometer.goliathcentre)
 MufluxSpectrometer.SetT3StationsZcorr(ship_geo.MufluxSpectrometer.T3z_1,ship_geo.MufluxSpectrometer.T3z_2,ship_geo.MufluxSpectrometer.T3z_3,ship_geo.MufluxSpectrometer.T3z_4) 
 MufluxSpectrometer.SetT4StationsZcorr(ship_geo.MufluxSpectrometer.T4z_1,ship_geo.MufluxSpectrometer.T4z_2,ship_geo.MufluxSpectrometer.T4z_3,ship_geo.MufluxSpectrometer.T4z_4) 
 MufluxSpectrometer.SetT3StationsXcorr(ship_geo.MufluxSpectrometer.T3x_1,ship_geo.MufluxSpectrometer.T3x_2,ship_geo.MufluxSpectrometer.T3x_3,ship_geo.MufluxSpectrometer.T3x_4) 
 MufluxSpectrometer.SetT4StationsXcorr(ship_geo.MufluxSpectrometer.T4x_1,ship_geo.MufluxSpectrometer.T4x_2,ship_geo.MufluxSpectrometer.T4x_3,ship_geo.MufluxSpectrometer.T4x_4)
 MufluxSpectrometer.SetTStationsZ(ship_geo.MufluxSpectrometer.T1z,ship_geo.MufluxSpectrometer.T1x_z,ship_geo.MufluxSpectrometer.T1u_z,ship_geo.MufluxSpectrometer.T2z,ship_geo.MufluxSpectrometer.T2v_z,ship_geo.MufluxSpectrometer.T2x_z,ship_geo.MufluxSpectrometer.T3z,ship_geo.MufluxSpectrometer.T4z) 
 MufluxSpectrometer.SetTStationsX(ship_geo.MufluxSpectrometer.T1x_x,ship_geo.MufluxSpectrometer.T1u_x,ship_geo.MufluxSpectrometer.T2x_x,ship_geo.MufluxSpectrometer.T2v_x,ship_geo.MufluxSpectrometer.T3x,ship_geo.MufluxSpectrometer.T4x) 
 MufluxSpectrometer.SetTStationsY(ship_geo.MufluxSpectrometer.T1x_y,ship_geo.MufluxSpectrometer.T1u_y,ship_geo.MufluxSpectrometer.T2x_y,ship_geo.MufluxSpectrometer.T2v_y,ship_geo.MufluxSpectrometer.T3y,ship_geo.MufluxSpectrometer.T4y) 

 if (ship_geo.MufluxSpectrometer.muflux==False):
 ##Survey Results from charm by daniel
  MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3ax,ship_geo.MufluxSpectrometer.SurveyCharm_T3ay,ship_geo.MufluxSpectrometer.SurveyCharm_T3az,0)
  MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3bx,ship_geo.MufluxSpectrometer.SurveyCharm_T3by,ship_geo.MufluxSpectrometer.SurveyCharm_T3bz,1)
  MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3cx,ship_geo.MufluxSpectrometer.SurveyCharm_T3cy,ship_geo.MufluxSpectrometer.SurveyCharm_T3cz,2)
  MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3dx,ship_geo.MufluxSpectrometer.SurveyCharm_T3dy,ship_geo.MufluxSpectrometer.SurveyCharm_T3dz,3)
  MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3tx,ship_geo.MufluxSpectrometer.SurveyCharm_T3ty,ship_geo.MufluxSpectrometer.SurveyCharm_T3tz,4)

  MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4ax,ship_geo.MufluxSpectrometer.SurveyCharm_T4ay,ship_geo.MufluxSpectrometer.SurveyCharm_T4az,0)
  MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4bx,ship_geo.MufluxSpectrometer.SurveyCharm_T4by,ship_geo.MufluxSpectrometer.SurveyCharm_T4bz,1)
  MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4cx,ship_geo.MufluxSpectrometer.SurveyCharm_T4cy,ship_geo.MufluxSpectrometer.SurveyCharm_T4cz,2)
  MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4dx,ship_geo.MufluxSpectrometer.SurveyCharm_T4dy,ship_geo.MufluxSpectrometer.SurveyCharm_T4dz,3)
  MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4tx,ship_geo.MufluxSpectrometer.SurveyCharm_T4ty,ship_geo.MufluxSpectrometer.SurveyCharm_T4tz,4)

 
 # for the digitizing step
 MufluxSpectrometer.SetTubeResolution(ship_geo.MufluxSpectrometer.v_drift,ship_geo.MufluxSpectrometer.sigma_spatial) 
  
 if (ship_geo.MufluxSpectrometer.muflux==False): 
    detectorList.append(MufluxSpectrometer)
 else:
 # Scintillator and Target Station classes for muflux configuration
    Scintillator = ROOT.Scintillator("Scintillator",ROOT.kTRUE)
    Scintillator.SetScoring1XY(ship_geo.MufluxSpectrometer.tr12xdim,ship_geo.MufluxSpectrometer.tr12ydim)
    Scintillator.SetDistT1(ship_geo.Scintillator.DistT1)
    Scintillator.SetDistT2(ship_geo.Scintillator.DistT2) 
    Scintillator.SetS_T1coords(ship_geo.MufluxSpectrometer.T1x_x,ship_geo.MufluxSpectrometer.T1x_y) 
    Scintillator.SetS_T2coords(ship_geo.MufluxSpectrometer.T2x_x,ship_geo.MufluxSpectrometer.T2x_y)  

    TargetStation = ROOT.MufluxTargetStation("MufluxTargetStation",ship_geo.target.length,ship_geo.hadronAbsorber.length, ship_geo.target.z,ship_geo.hadronAbsorber.z,ship_geo.targetOpt,ship_geo.target.sl)
    
    TargetStation.SetIronAbsorber(ship_geo.MufluxTargetStation.absorber_x,ship_geo.MufluxTargetStation.absorber_y)
    TargetStation.SetAbsorberCutout(ship_geo.MufluxTargetStation.absorbercutout_x, ship_geo.MufluxTargetStation.absorbercutout_y)
    TargetStation.SetIronShield(ship_geo.MufluxTargetStation.ironshield_x, ship_geo.MufluxTargetStation.ironshield_y, ship_geo.MufluxTargetStation.ironshield_z)
    TargetStation.SetConcreteShield(ship_geo.MufluxTargetStation.concreteshield_x, ship_geo.MufluxTargetStation.concreteshield_y, ship_geo.MufluxTargetStation.concreteshield_z)
    TargetStation.SetAboveTargetShield(ship_geo.MufluxTargetStation.abovetargetshield_x, ship_geo.MufluxTargetStation.abovetargetshield_y,ship_geo.MufluxTargetStation.abovetargetshield_z)
    TargetStation.SetAboveAbsorberShield(ship_geo.MufluxTargetStation.aboveabsorbershield_x, ship_geo.MufluxTargetStation.aboveabsorbershield_y,ship_geo.MufluxTargetStation.aboveabsorbershield_z)
    TargetStation.SetAboveAboveTargetShield(ship_geo.MufluxTargetStation.aboveabovetargetshield_y)
    TargetStation.SetFloor(ship_geo.MufluxTargetStation.floor_x,ship_geo.MufluxTargetStation.floor_y,ship_geo.MufluxTargetStation.floor_z)
    TargetStation.SetFloorT34(ship_geo.MufluxTargetStation.floorT34_x,ship_geo.MufluxTargetStation.floorT34_y,ship_geo.MufluxTargetStation.floorT34_z)
    TargetStation.SetFloorRPC(ship_geo.MufluxTargetStation.floorRPC_x, ship_geo.MufluxTargetStation.floorRPC_y,ship_geo.MufluxTargetStation.floorRPC_z)

    if ship_geo.targetOpt>10:
     slices_length=ROOT.std.vector('float')()     
     slices_material=ROOT.std.vector('string')()
     for i in range(1,ship_geo.targetOpt+1):
      slices_length.push_back(eval("ship_geo.target.L"+str(i)))
      slices_material.push_back(eval("ship_geo.target.M"+str(i)))

     TargetStation.SetLayerPosMat(ship_geo.target.xy,slices_length,slices_material)
     detectorList.append(TargetStation)
     
    detectorList.append(Scintillator)
    detectorList.append(MufluxSpectrometer)
   
 MuonTagger = ROOT.MuonTagger("MuonTagger", ship_geo.MuonTagger.BX, ship_geo.MuonTagger.BY, ship_geo.MuonTagger.BZ, ship_geo.MuonTagger.zBox, ROOT.kTRUE)
 MuonTagger.SetPassiveParameters(ship_geo.MuonTagger.PX, ship_geo.MuonTagger.PY, ship_geo.MuonTagger.PTh, ship_geo.MuonTagger.PTh1)
 MuonTagger.SetSensitiveParameters(ship_geo.MuonTagger.SX, ship_geo.MuonTagger.SY, ship_geo.MuonTagger.STh)
 MuonTagger.SetHoleDimensions(ship_geo.MuonTagger.HX, ship_geo.MuonTagger.HY)
 MuonTagger.SetRPCz(ship_geo.MuonTagger.RPC1z, ship_geo.MuonTagger.RPC2z, ship_geo.MuonTagger.RPC3z, ship_geo.MuonTagger.RPC4z, ship_geo.MuonTagger.RPC5z)
 MuonTagger.SetRPCThickness(ship_geo.MuonTagger.RPCthickness)
 MuonTagger.SetGapThickness(ship_geo.MuonTagger.Gapthickness)
 MuonTagger.SetElectrodeThickness(ship_geo.MuonTagger.Electrodethickness)
 MuonTagger.SetStripz(ship_geo.MuonTagger.Stripz, ship_geo.MuonTagger.Stripfoamz)
 MuonTagger.SetVStrip(ship_geo.MuonTagger.VStripx,ship_geo.MuonTagger.VStripx_L,ship_geo.MuonTagger.VStripx_R,ship_geo.MuonTagger.VStripoffset) 
 MuonTagger.SetHStrip(ship_geo.MuonTagger.HStripy,ship_geo.MuonTagger.HStripy_ext,ship_geo.MuonTagger.HStripoffset)  
 MuonTagger.SetNStrips(ship_geo.MuonTagger.NVstrips,ship_geo.MuonTagger.NHstrips) 
  
 detectorList.append(MuonTagger)
 for x in detectorList:
  run.AddModule(x)
  
 fMagField = ROOT.ShipGoliathField()
 if Gfield == '':  
  #default field map
  fieldfile = os.environ["FAIRSHIP"]+"/field/GoliathFieldMap.root"
 elif Gfield == 'inter': 
  fieldfile = os.environ["FAIRSHIP"]+"/field/GoliathFieldMap_2400A_1167A.root" 
 elif Gfield == 'noDavid':
  fieldfile = os.environ["FAIRSHIP"]+"/field/GoliathFieldMap_3600A_0A.root"  
 fMagField.Init(fieldfile)
 run.SetField(fMagField)
 
# return list of detector elements
 detElements = {}
 for x in run.GetListOfModules(): detElements[x.GetName()]=x 
 
 return detElements
Exemplo n.º 42
0
    f = ROOT.TFile(fname, 'update')
    sTree = f.Get('cbmsim')
    if not sTree:
        print("Problem with updateFile: ", f)
        exit(-1)
else:
    sTree = ROOT.TChain('cbmsim')
    for f in fnames:
        print("add ", f)
        if options.onEOS: sTree.Add(os.environ['EOSSHIP'] + f)
        else: sTree.Add(f)

#-------------------------------geometry initialization
from ShipGeoConfig import ConfigRegistry
ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py",
                                Setup=1,
                                cTarget=1)
builtin.ShipGeo = ShipGeo
import charmDet_conf
run = ROOT.FairRunSim()
run.SetName("TGeant4")  # Transport engine
run.SetOutputFile(ROOT.TMemFile('output', 'recreate'))  # Output file
run.SetUserConfig(
    "g4Config_basic.C"
)  # geant4 transport not used, only needed for creating VMC field
rtdb = run.GetRuntimeDb()
modules = charmDet_conf.configure(run, ShipGeo)
# -----Create geometry and draw display----------------------------------------------
run.Init()
sGeo = ROOT.gGeoManager
nav = sGeo.GetCurrentNavigator()
Exemplo n.º 43
0
          os.unlink(os.path.join(root, f))
        for d in dirs:
          shutil.rmtree(os.path.join(root, d))
    else:
      logger.warn("...use '-f' option to overwrite it")
  else:
    os.makedirs(work_dir)
  return args

args = init()
os.chdir(work_dir)
# -------------------------------------------------------------------
ROOT.gRandom.SetSeed(theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()      # load basic libraries, prepare atexit for python
#this is for the muon flux geometry
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py", Setup = args.CharmdetSetup)

txt = 'pythia8_Geant4_'
if withEvtGen: txt = 'pythia8_evtgen_Geant4_'
outFile = outputDir+'/'+txt+str(runnr)+'_'+str(ecut)+'.root'
parFile = outputDir+'/ship.params.'+txt+str(runnr)+'_'+str(ecut)+'.root'

# -----Timer--------------------------------------------------------
timer = ROOT.TStopwatch()
timer.Start()

# -----Create simulation run----------------------------------------
run = ROOT.FairRunSim()
run.SetName(mcEngine)  # Transport engine
run.SetOutputFile(outFile)  # Output file
run.SetUserConfig("g4Config.C") # user configuration file default g4Config.C
Exemplo n.º 44
0
if (simEngine == "Ntuple" or simEngine == "MuonBack") and defaultInputFile:
    print 'input file required if simEngine = Ntuple or MuonBack'
    print " for example -f /eos/ship/data/Mbias/pythia8_Geant4-withCharm_onlyMuons_4magTarget.root"
    sys.exit()
ROOT.gRandom.SetSeed(
    theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure(
    DarkPhoton)  # load basic libraries, prepare atexit for python
# - muShieldDesign = 2  # 1=passive 5=active (default) 7=short design+magnetized hadron absorber
# - targetOpt      = 5  # 0=solid   >0 sliced, 5: 5 pieces of tungsten, 4 H20 slits, 17: Mo + W +H2O (default)
# - strawDesign    = 4  # simplistic tracker design,  4=sophisticated straw tube design, horizontal wires (default)
# - HcalOption     = -1 # no hcal,  0=hcal after muon,  1=hcal between ecal and muon (default)
# - preshowerOption = 0 # no preshower, default. 1= simple preshower
if charm == 0:
    ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py",
                                     Yheight=dy,
                                     tankDesign=dv,
                                     muShieldDesign=ds)
else:
    ship_geo = ConfigRegistry.loadpy(
        "$FAIRSHIP/geometry/charm-geometry_config.py")

# Output file name, add dy to be able to setup geometry with ambiguities.
tag = simEngine + "-" + mcEngine
if charmonly: tag = simEngine + "CharmOnly-" + mcEngine
if eventDisplay: tag = tag + '_D'
if dv == 5: tag = 'conical.' + tag
elif dy: tag = str(dy) + '.' + tag
if not os.path.exists(outputDir):
    os.makedirs(outputDir)
outFile = "%s/ship.%s.root" % (outputDir, tag)
Exemplo n.º 45
0
if options.updateFile:
 f=ROOT.TFile(fname,'update')
 sTree=f.Get('cbmsim')
 if not sTree: 
   print "Problem with updateFile",f
   exit(-1)
else:
 sTree = ROOT.TChain('cbmsim')
 for f in fnames: 
  print "add ",f
  if options.onEOS: sTree.Add(os.environ['EOSSHIP']+f)
  else:             sTree.Add(f)

#-------------------------------geometry initialization
from ShipGeoConfig import ConfigRegistry
ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py", Setup = 1, cTarget = 3)
builtin.ShipGeo = ShipGeo
import charmDet_conf
run = ROOT.FairRunSim()
run.SetName("TGeant4")  # Transport engine
run.SetOutputFile(ROOT.TMemFile('output', 'recreate'))  # Output file
run.SetUserConfig("g4Config_basic.C") # geant4 transport not used, only needed for creating VMC field
rtdb = run.GetRuntimeDb()
modules = charmDet_conf.configure(run,ShipGeo)
# -----Create geometry and draw display----------------------------------------------
run.Init()
sGeo = ROOT.gGeoManager
nav = sGeo.GetCurrentNavigator()
top = sGeo.GetTopVolume()
top.SetVisibility(0)
if options.withDisplay: 
Exemplo n.º 46
0
s = sys.argv[1]
thickness = setup[s]['thickness']
material = setup[s]['material']
momentum = setup[s]['momentum']

checkOverlap = True

outFile = "gconv"+s+".root"
theSeed      = int(10000 * time.time() % 10000000)
ecut      = 0.0
                 
# -------------------------------------------------------------------
ROOT.gRandom.SetSeed(theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()      # load basic libraries, prepare atexit for python
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = 10, tankDesign = 5, muShieldDesign = 7, nuTauTargetDesign=1)

# -----Timer--------------------------------------------------------
timer = ROOT.TStopwatch()
timer.Start()

# -----Create simulation run----------------------------------------
run = ROOT.FairRunSim()
run.SetName(mcEngine)  # Transport engine
run.SetOutputFile(outFile)  # Output file
run.SetUserConfig("g4Config.C") # user configuration file default g4Config.C
rtdb = run.GetRuntimeDb() 

# -----Materials----------------------------------------------
run.SetMaterials("media.geo")  
# -----Create geometry----------------------------------------------
Exemplo n.º 47
0
def configure(run,ship_geo):
 latestCharmGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py")
# -----Create media-------------------------------------------------
 run.SetMaterials("media.geo")  # Materials
 
# -----Create geometry----------------------------------------------
 cave= ROOT.ShipCave("CAVE")
 cave.SetGeometryFileName("caveWithAir.geo")
 detectorList.append(cave)
    
 Box = ROOT.Box("Box",ship_geo.Box.BrX, ship_geo.Box.BrY, ship_geo.Box.BrZ, ship_geo.Box.zBox,ROOT.kTRUE)
 Box.SetEmulsionParam(ship_geo.Box.EmTh, ship_geo.Box.EmX, ship_geo.Box.EmY, ship_geo.Box.PBTh,ship_geo.Box.EPlW, ship_geo.Box.PasSlabTh, ship_geo.Box.AllPW);
 Box.SetBrickParam(ship_geo.Box.BrX, ship_geo.Box.BrY, ship_geo.Box.BrZ, ship_geo.Box.BrPackX, ship_geo.Box.BrPackY, ship_geo.Box.BrPackZ);
 Box.SetTargetParam(ship_geo.Box.TX, ship_geo.Box.TY, ship_geo.Box.TZ);
 Box.SetPassiveComposition(ship_geo.Box.Molblock1Z, ship_geo.Box.Molblock2Z, ship_geo.Box.Molblock3Z, ship_geo.Box.Molblock4Z, ship_geo.Box.Wblock1Z, ship_geo.Box.Wblock2Z, ship_geo.Box.Wblock3Z, ship_geo.Box.Wblock3_5Z, ship_geo.Box.Wblock4Z)
 Box.SetPassiveSampling(ship_geo.Box.Passive3mmZ, ship_geo.Box.Passive2mmZ, ship_geo.Box.Passive1mmZ)
 Box.SetCoolingParam(ship_geo.Box.CoolX, ship_geo.Box.CoolY, ship_geo.Box.CoolZ)
 Box.SetCoatingParam(ship_geo.Box.CoatX, ship_geo.Box.CoatY, ship_geo.Box.CoatZ)
 Box.SetGapGeometry(ship_geo.Box.distancePassive2ECC)
 Box.SetTargetDesign(ship_geo.Box.Julytarget)
 Box.SetTargetNumber(ship_geo.Box.CharmTargetNumber)

 if (ship_geo.MufluxSpectrometer.muflux==False): 
# === SciFi modules
    SciFi = ROOT.SciFi("SciFi",ship_geo.SciFi.DX, ship_geo.SciFi.DY, ship_geo.SciFi.DZ,ROOT.kTRUE)
    SciFi.SetBoxParam(ship_geo.SciFi.DX,ship_geo.SciFi.DY,ship_geo.SciFi.DZ, ship_geo.SciFi.zBox)
    SciFi.SetStationNumber(ship_geo.SciFi.nstations)
    SciFi.SetStationDimensions(ship_geo.SciFi.StationDimX, ship_geo.SciFi.StationDimY, ship_geo.SciFi.StationDimZ)
    for i, (x, y, z) in enumerate(zip(ship_geo.SciFi.xSi,ship_geo.SciFi.ySi,ship_geo.SciFi.zSi)):
    	SciFi.SetStationPositions(i, x, y, z)
# === Pixel modules
    PixelModules = ROOT.PixelModules("PixelModules",ship_geo.PixelModules.DX, ship_geo.PixelModules.DY, ship_geo.PixelModules.DZ,ROOT.kTRUE)
    PixelModules.SetBoxParam(ship_geo.PixelModules.DX,ship_geo.PixelModules.DY,ship_geo.PixelModules.DZ, ship_geo.PixelModules.zBox, ship_geo.PixelModules.DimZpixelbox, ship_geo.PixelModules.D1short, ship_geo.PixelModules.D1long)
    PixelModules.SetSiliconDZ(ship_geo.PixelModules.DimZSi)
# === Box
    detectorList.append(Box)
# === SciFi modules
    detectorList.append(SciFi)
# === Pixel modules
    detectorList.append(PixelModules)
    for i, (x, y, z) in enumerate(zip(ship_geo.PixelModules.xSi,ship_geo.PixelModules.ySi,ship_geo.PixelModules.zSi)):
    	PixelModules.SetSiliconStationPositions(i, x, y, z)

 Spectrometer = ROOT.Spectrometer("Spectrometer",ship_geo.Spectrometer.DX, ship_geo.Spectrometer.DY, ship_geo.Spectrometer.DZ,ROOT.kTRUE)
 Spectrometer.SetTransverseSizes(ship_geo.Spectrometer.D1Short, ship_geo.Spectrometer.D1Long)
# -----Goliath part by Annarita--------
 Spectrometer.SetGoliathSizes(ship_geo.Spectrometer.H, ship_geo.Spectrometer.TS, ship_geo.Spectrometer.LS, ship_geo.Spectrometer.BasisH);
 Spectrometer.SetCoilParameters(ship_geo.Spectrometer.CoilR, ship_geo.Spectrometer.UpCoilH, ship_geo.Spectrometer.LowCoilH,  ship_geo.Spectrometer.CoilD);
# --------------------------------------
 Spectrometer.SetBoxParam(ship_geo.Spectrometer.SX,ship_geo.Spectrometer.SY,ship_geo.Spectrometer.SZ,ship_geo.Spectrometer.zBox)
 if (ship_geo.MufluxSpectrometer.muflux==False):
  MufluxSpectrometer = ROOT.MufluxSpectrometer("MufluxSpectrometer",ship_geo.MufluxSpectrometer.DX, ship_geo.MufluxSpectrometer.DY,   ship_geo.MufluxSpectrometer.DZ,ROOT.kTRUE)
 else:
  MufluxSpectrometer = ROOT.MufluxSpectrometer("MufluxSpectrometer",ship_geo.Spectrometer.DX, ship_geo.Spectrometer.DY, ship_geo.Spectrometer.DZ,ROOT.kTRUE)
 # -----Drift tube part --------
 
 MufluxSpectrometer.SetGoliathSizes(ship_geo.Spectrometer.H, ship_geo.Spectrometer.TS, ship_geo.Spectrometer.LS, ship_geo.Spectrometer.BasisH);
 MufluxSpectrometer.SetCoilParameters(ship_geo.Spectrometer.CoilR, ship_geo.Spectrometer.UpCoilH, ship_geo.Spectrometer.LowCoilH,  ship_geo.Spectrometer.CoilD);
# --------------------------------------
 
 MufluxSpectrometer.ChooseDetector(ship_geo.MufluxSpectrometer.muflux)
 MufluxSpectrometer.SetDeltazView(ship_geo.MufluxSpectrometer.DeltazView)
 MufluxSpectrometer.SetInnerTubeDiameter(ship_geo.MufluxSpectrometer.InnerTubeDiameter)
 MufluxSpectrometer.SetOuterTubeDiameter(ship_geo.MufluxSpectrometer.OuterTubeDiameter)
 MufluxSpectrometer.SetTubePitch(ship_geo.MufluxSpectrometer.TubePitch)
 MufluxSpectrometer.SetTubePitch_T1u(ship_geo.MufluxSpectrometer.TubePitch_T1u,ship_geo.MufluxSpectrometer.T1u_const,ship_geo.MufluxSpectrometer.T1u_const_2,ship_geo.MufluxSpectrometer.T1u_const_3,ship_geo.MufluxSpectrometer.T1u_const_4)
 MufluxSpectrometer.SetTubePitch_T2v(ship_geo.MufluxSpectrometer.TubePitch_T2v,ship_geo.MufluxSpectrometer.T2v_const,ship_geo.MufluxSpectrometer.T2v_const_2,ship_geo.MufluxSpectrometer.T2v_const_3,ship_geo.MufluxSpectrometer.T2v_const_4) 
 MufluxSpectrometer.SetDeltazLayer(ship_geo.MufluxSpectrometer.DeltazLayer)
 MufluxSpectrometer.SetDeltazPlane(ship_geo.MufluxSpectrometer.DeltazPlane)
 MufluxSpectrometer.SetTubesPerLayer(ship_geo.MufluxSpectrometer.TubesPerLayer)
 MufluxSpectrometer.SetStereoAngle(ship_geo.MufluxSpectrometer.ViewAngle, ship_geo.MufluxSpectrometer.ViewvAngle)
 MufluxSpectrometer.SetWireThickness(ship_geo.MufluxSpectrometer.WireThickness)
 MufluxSpectrometer.SetTubeLength(ship_geo.MufluxSpectrometer.TubeLength)
 MufluxSpectrometer.SetTubeLength12(ship_geo.MufluxSpectrometer.TubeLength12) 
 MufluxSpectrometer.SetTr12YDim(ship_geo.MufluxSpectrometer.tr12ydim)
 MufluxSpectrometer.SetTr34YDim(ship_geo.MufluxSpectrometer.tr34ydim)
 MufluxSpectrometer.SetTr12XDim(ship_geo.MufluxSpectrometer.tr12xdim)
 MufluxSpectrometer.SetTr34XDim(ship_geo.MufluxSpectrometer.tr34xdim) 
 MufluxSpectrometer.SetDistStereo(ship_geo.MufluxSpectrometer.diststereoT1,ship_geo.MufluxSpectrometer.diststereoT2)
 MufluxSpectrometer.SetDistT1T2(ship_geo.MufluxSpectrometer.distT1T2)
 MufluxSpectrometer.SetDistT3T4(ship_geo.MufluxSpectrometer.distT3T4)    
 MufluxSpectrometer.SetGoliathCentre(ship_geo.MufluxSpectrometer.goliathcentre_to_beam)
 MufluxSpectrometer.SetGoliathCentreZ(ship_geo.MufluxSpectrometer.goliathcentre)
 MufluxSpectrometer.SetT3StationsZcorr(ship_geo.MufluxSpectrometer.T3z_1,ship_geo.MufluxSpectrometer.T3z_2,ship_geo.MufluxSpectrometer.T3z_3,ship_geo.MufluxSpectrometer.T3z_4) 
 MufluxSpectrometer.SetT4StationsZcorr(ship_geo.MufluxSpectrometer.T4z_1,ship_geo.MufluxSpectrometer.T4z_2,ship_geo.MufluxSpectrometer.T4z_3,ship_geo.MufluxSpectrometer.T4z_4) 
 MufluxSpectrometer.SetT3StationsXcorr(ship_geo.MufluxSpectrometer.T3x_1,ship_geo.MufluxSpectrometer.T3x_2,ship_geo.MufluxSpectrometer.T3x_3,ship_geo.MufluxSpectrometer.T3x_4) 
 MufluxSpectrometer.SetT4StationsXcorr(ship_geo.MufluxSpectrometer.T4x_1,ship_geo.MufluxSpectrometer.T4x_2,ship_geo.MufluxSpectrometer.T4x_3,ship_geo.MufluxSpectrometer.T4x_4)
 MufluxSpectrometer.SetTStationsZ(ship_geo.MufluxSpectrometer.T1z,ship_geo.MufluxSpectrometer.T1x_z,ship_geo.MufluxSpectrometer.T1u_z,ship_geo.MufluxSpectrometer.T2z,ship_geo.MufluxSpectrometer.T2v_z,ship_geo.MufluxSpectrometer.T2x_z,ship_geo.MufluxSpectrometer.T3z,ship_geo.MufluxSpectrometer.T4z) 
 MufluxSpectrometer.SetTStationsX(ship_geo.MufluxSpectrometer.T1x_x,ship_geo.MufluxSpectrometer.T1u_x,ship_geo.MufluxSpectrometer.T2x_x,ship_geo.MufluxSpectrometer.T2v_x,ship_geo.MufluxSpectrometer.T3x,ship_geo.MufluxSpectrometer.T4x) 
 MufluxSpectrometer.SetTStationsY(ship_geo.MufluxSpectrometer.T1x_y,ship_geo.MufluxSpectrometer.T1u_y,ship_geo.MufluxSpectrometer.T2x_y,ship_geo.MufluxSpectrometer.T2v_y,ship_geo.MufluxSpectrometer.T3y,ship_geo.MufluxSpectrometer.T4y) 

 ##Survey Results from charm by daniel
 MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3ax,ship_geo.MufluxSpectrometer.SurveyCharm_T3ay,ship_geo.MufluxSpectrometer.SurveyCharm_T3az,0)
 MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3bx,ship_geo.MufluxSpectrometer.SurveyCharm_T3by,ship_geo.MufluxSpectrometer.SurveyCharm_T3bz,1)
 MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3cx,ship_geo.MufluxSpectrometer.SurveyCharm_T3cy,ship_geo.MufluxSpectrometer.SurveyCharm_T3cz,2)
 MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3dx,ship_geo.MufluxSpectrometer.SurveyCharm_T3dy,ship_geo.MufluxSpectrometer.SurveyCharm_T3dz,3)
 MufluxSpectrometer.SetT3(ship_geo.MufluxSpectrometer.SurveyCharm_T3tx,ship_geo.MufluxSpectrometer.SurveyCharm_T3ty,ship_geo.MufluxSpectrometer.SurveyCharm_T3tz,4)

 MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4ax,ship_geo.MufluxSpectrometer.SurveyCharm_T4ay,ship_geo.MufluxSpectrometer.SurveyCharm_T4az,0)
 MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4bx,ship_geo.MufluxSpectrometer.SurveyCharm_T4by,ship_geo.MufluxSpectrometer.SurveyCharm_T4bz,1)
 MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4cx,ship_geo.MufluxSpectrometer.SurveyCharm_T4cy,ship_geo.MufluxSpectrometer.SurveyCharm_T4cz,2)
 MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4dx,ship_geo.MufluxSpectrometer.SurveyCharm_T4dy,ship_geo.MufluxSpectrometer.SurveyCharm_T4dz,3)
 MufluxSpectrometer.SetT4(ship_geo.MufluxSpectrometer.SurveyCharm_T4tx,ship_geo.MufluxSpectrometer.SurveyCharm_T4ty,ship_geo.MufluxSpectrometer.SurveyCharm_T4tz,4)

 
 # for the digitizing step
 MufluxSpectrometer.SetTubeResolution(ship_geo.MufluxSpectrometer.v_drift,ship_geo.MufluxSpectrometer.sigma_spatial) 

 Scintillator = ROOT.Scintillator("Scintillator",ROOT.kTRUE)
 Scintillator.SetScoring1XY(ship_geo.MufluxSpectrometer.tr12xdim,ship_geo.MufluxSpectrometer.tr12ydim)
 Scintillator.SetDistT1(ship_geo.Scintillator.DistT1)
 Scintillator.SetDistT2(ship_geo.Scintillator.DistT2) 
 Scintillator.SetS_T1coords(ship_geo.MufluxSpectrometer.T1x_x,ship_geo.MufluxSpectrometer.T1x_y) 
 Scintillator.SetS_T2coords(ship_geo.MufluxSpectrometer.T2x_x,ship_geo.MufluxSpectrometer.T2x_y)  
  
 if (ship_geo.MufluxSpectrometer.muflux==False): 
    detectorList.append(MufluxSpectrometer)
 else:
    TargetStation = ROOT.MufluxTargetStation("MufluxTargetStation",ship_geo.target.length,ship_geo.hadronAbsorber.length, ship_geo.target.z,ship_geo.hadronAbsorber.z,ship_geo.targetOpt,ship_geo.target.sl)
    
    TargetStation.SetIronAbsorber(ship_geo.MufluxTargetStation.absorber_x,ship_geo.MufluxTargetStation.absorber_y)
    TargetStation.SetAbsorberCutout(ship_geo.MufluxTargetStation.absorbercutout_x, ship_geo.MufluxTargetStation.absorbercutout_y)
    TargetStation.SetIronShield(ship_geo.MufluxTargetStation.ironshield_x, ship_geo.MufluxTargetStation.ironshield_y, ship_geo.MufluxTargetStation.ironshield_z)
    TargetStation.SetConcreteShield(ship_geo.MufluxTargetStation.concreteshield_x, ship_geo.MufluxTargetStation.concreteshield_y, ship_geo.MufluxTargetStation.concreteshield_z)
    TargetStation.SetAboveTargetShield(ship_geo.MufluxTargetStation.abovetargetshield_x, ship_geo.MufluxTargetStation.abovetargetshield_y,ship_geo.MufluxTargetStation.abovetargetshield_z)
    TargetStation.SetAboveAbsorberShield(ship_geo.MufluxTargetStation.aboveabsorbershield_x, ship_geo.MufluxTargetStation.aboveabsorbershield_y,ship_geo.MufluxTargetStation.aboveabsorbershield_z)
    TargetStation.SetAboveAboveTargetShield(ship_geo.MufluxTargetStation.aboveabovetargetshield_y)
    TargetStation.SetFloor(ship_geo.MufluxTargetStation.floor_x,ship_geo.MufluxTargetStation.floor_y,ship_geo.MufluxTargetStation.floor_z)
    TargetStation.SetFloorT34(ship_geo.MufluxTargetStation.floorT34_x,ship_geo.MufluxTargetStation.floorT34_y,ship_geo.MufluxTargetStation.floorT34_z)
    TargetStation.SetFloorRPC(ship_geo.MufluxTargetStation.floorRPC_x, ship_geo.MufluxTargetStation.floorRPC_y,ship_geo.MufluxTargetStation.floorRPC_z)

    if ship_geo.targetOpt>10:
     slices_length=ROOT.std.vector('float')()     
     slices_material=ROOT.std.vector('string')()
     for i in range(1,ship_geo.targetOpt+1):
      slices_length.push_back(eval("ship_geo.target.L"+str(i)))
      slices_material.push_back(eval("ship_geo.target.M"+str(i)))

     TargetStation.SetLayerPosMat(ship_geo.target.xy,slices_length,slices_material)
     detectorList.append(TargetStation)
     
    detectorList.append(Scintillator)
    detectorList.append(MufluxSpectrometer)
   
 MuonTagger = ROOT.MuonTagger("MuonTagger", ship_geo.MuonTagger.BX, ship_geo.MuonTagger.BY, ship_geo.MuonTagger.BZ, ship_geo.MuonTagger.zBox, ROOT.kTRUE)
 MuonTagger.SetPassiveParameters(ship_geo.MuonTagger.PX, ship_geo.MuonTagger.PY, ship_geo.MuonTagger.PTh, ship_geo.MuonTagger.PTh1)
 MuonTagger.SetSensitiveParameters(ship_geo.MuonTagger.SX, ship_geo.MuonTagger.SY, ship_geo.MuonTagger.STh)
 MuonTagger.SetHoleDimensions(ship_geo.MuonTagger.HX, ship_geo.MuonTagger.HY)
 MuonTagger.SetRPCz(ship_geo.MuonTagger.RPC1z, ship_geo.MuonTagger.RPC2z, ship_geo.MuonTagger.RPC3z, ship_geo.MuonTagger.RPC4z, ship_geo.MuonTagger.RPC5z)
 MuonTagger.SetRPCThickness(ship_geo.MuonTagger.RPCthickness)
 MuonTagger.SetGapThickness(ship_geo.MuonTagger.Gapthickness)
 MuonTagger.SetElectrodeThickness(ship_geo.MuonTagger.Electrodethickness)
 MuonTagger.SetStripz(ship_geo.MuonTagger.Stripz, ship_geo.MuonTagger.Stripfoamz)
 MuonTagger.SetVStrip(ship_geo.MuonTagger.VStripx,ship_geo.MuonTagger.VStripx_L,ship_geo.MuonTagger.VStripx_R,ship_geo.MuonTagger.VStripoffset) 
 MuonTagger.SetHStrip(ship_geo.MuonTagger.HStripy,ship_geo.MuonTagger.HStripy_ext,ship_geo.MuonTagger.HStripoffset)  
 MuonTagger.SetNStrips(ship_geo.MuonTagger.NVstrips,ship_geo.MuonTagger.NHstrips) 
  
 detectorList.append(MuonTagger)
 for x in detectorList:
  run.AddModule(x)
  
 fMagField = ROOT.ShipGoliathField()
 
 #fieldfile = os.environ["FAIRSHIP"]+"/field/GoliathFieldMap_3600A_0A.root"  
 #fieldfile = os.environ["FAIRSHIP"]+"/field/GoliathFieldMap_2400A_1167A.root" 
 #default field map
 fieldfile = os.environ["FAIRSHIP"]+"/field/GoliathFieldMap.root"
 fMagField.Init(fieldfile)
 run.SetField(fMagField)   
 
# return list of detector elements
 detElements = {}
 for x in run.GetListOfModules(): detElements[x.GetName()]=x 
 
 return detElements
Exemplo n.º 48
0
        "crossing angle up:        /eos/experiment/sndlhc/MonteCarlo/FLUKA/muons_up/version1/unit30_Nm.root  (unit30_Pm.root)"
    )
    print(
        "crossing angle down: /eos/experiment/sndlhc/MonteCarlo/FLUKA/muons_down/muons_VCdown_IR1-LHC.root"
    )
    sys.exit()

print("SND@LHC setup for", simEngine, "to produce", options.nEvents, "events")

ROOT.gRandom.SetSeed(
    options.theSeed
)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure(0)  # load basic libraries, prepare atexit for python

if options.testbeam:
    snd_geo = ConfigRegistry.loadpy(
        "$SNDSW_ROOT/geometry/sndLHC_H6geom_config.py")
else:
    snd_geo = ConfigRegistry.loadpy(
        "$SNDSW_ROOT/geometry/sndLHC_geom_config.py")

if simEngine == "PG": tag = simEngine + "_" + str(options.pID) + "-" + mcEngine
else: tag = simEngine + "-" + mcEngine

if not os.path.exists(options.outputDir):
    os.makedirs(options.outputDir)
if options.boostFactor > 1:
    tag += '_boost' + str(options.boostFactor)
outFile = "%s/sndLHC.%s.root" % (options.outputDir, tag)

# rm older files !!!
for x in os.listdir(options.outputDir):
Exemplo n.º 49
0
def configure(run, ship_geo):
    # ---- for backward compatibility ----
    if not hasattr(ship_geo, "tankDesign"): ship_geo.tankDesign = 5
    if not hasattr(ship_geo, "muShieldGeo"): ship_geo.muShieldGeo = None
    if not hasattr(ship_geo.hcal, "File"): ship_geo.hcal.File = "hcal.geo"
    if not hasattr(ship_geo.Bfield, 'x'): ship_geo.Bfield.x = 3. * u.m
    if not hasattr(ship_geo, 'cave'):
        ship_geo.cave = AttrDict(z=0 * u.cm)
        ship_geo.cave.floorHeightMuonShield = 5 * u.m
        ship_geo.cave.floorHeightTankA = 4.5 * u.m
        ship_geo.cave.floorHeightTankB = 2. * u.m
    if not hasattr(ship_geo, 'NuTauTT'):
        ship_geo.NuTauTT = AttrDict(z=0 * u.cm)
    if not hasattr(ship_geo.NuTauTT, 'design'): ship_geo.NuTauTT.design = 0
    if not hasattr(ship_geo, 'EcalOption'): ship_geo.EcalOption = 1
    latestShipGeo = ConfigRegistry.loadpy(
        "$FAIRSHIP/geometry/geometry_config.py",
        Yheight=ship_geo.Yheight / u.m,
        tankDesign=ship_geo.tankDesign,
        muShieldDesign=ship_geo.muShieldDesign,
        nuTauTargetDesign=ship_geo.nuTauTargetDesign,
        muShieldGeo=ship_geo.muShieldGeo)
    # -----Create media-------------------------------------------------
    run.SetMaterials("media.geo")  # Materials
    # ------------------------------------------------------------------------

    # -----Create geometry----------------------------------------------
    cave = ROOT.ShipCave("CAVE")
    if ship_geo.tankDesign < 5: cave.SetGeometryFileName("cave.geo")
    else: cave.SetGeometryFileName("caveWithAir.geo")
    detectorList.append(cave)

    if ship_geo.muShieldDesign in [
            6, 7, 8, 9
    ]:  # magnetized hadron absorber defined in ShipMuonShield
        TargetStation = ROOT.ShipTargetStation("TargetStation",
                                               ship_geo.target.length,
                                               ship_geo.target.z,
                                               ship_geo.targetOpt,
                                               ship_geo.target.sl)
    else:
        TargetStation = ROOT.ShipTargetStation(
            "TargetStation", ship_geo.target.length,
            ship_geo.hadronAbsorber.length, ship_geo.target.z,
            ship_geo.hadronAbsorber.z, ship_geo.targetOpt, ship_geo.target.sl)

    if ship_geo.targetOpt > 10:
        slices_length = ROOT.std.vector('float')()
        slices_material = ROOT.std.vector('std::string')()
        for i in range(1, ship_geo.targetOpt + 1):
            slices_length.push_back(eval("ship_geo.target.L" + str(i)))
            slices_material.push_back(eval("ship_geo.target.M" + str(i)))
        TargetStation.SetLayerPosMat(ship_geo.target.xy, slices_length,
                                     slices_material)
    detectorList.append(TargetStation)

    if ship_geo.muShieldDesign == 1:
        MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.length,\
                                         ship_geo.muShield.LE)
    elif ship_geo.muShieldDesign == 2:
        MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.dZ1,\
                     ship_geo.muShield.dZ2,ship_geo.muShield.dZ3,ship_geo.muShield.dZ4,ship_geo.muShield.dZ5,ship_geo.muShield.dZ6,ship_geo.muShield.LE)
    elif ship_geo.muShieldDesign in [3, 4, 5, 6, 7, 9]:
        if not hasattr(ship_geo.muShield, "Field"):
            MuonShield = ROOT.ShipMuonShield(
                "MuonShield", ship_geo.muShieldDesign, "ShipMuonShield",
                ship_geo.muShield.z, ship_geo.muShield.dZ0,
                ship_geo.muShield.dZ1, ship_geo.muShield.dZ2,
                ship_geo.muShield.dZ3, ship_geo.muShield.dZ4,
                ship_geo.muShield.dZ5, ship_geo.muShield.dZ6,
                ship_geo.muShield.dZ7, ship_geo.muShield.dZ8,
                ship_geo.muShield.dXgap, ship_geo.muShield.LE,
                ship_geo.Yheight * 4. / 10.,
                ship_geo.cave.floorHeightMuonShield)
        else:
            MuonShield = ROOT.ShipMuonShield(
                "MuonShield", ship_geo.muShieldDesign, "ShipMuonShield",
                ship_geo.muShield.z, ship_geo.muShield.dZ0,
                ship_geo.muShield.dZ1, ship_geo.muShield.dZ2,
                ship_geo.muShield.dZ3, ship_geo.muShield.dZ4,
                ship_geo.muShield.dZ5, ship_geo.muShield.dZ6,
                ship_geo.muShield.dZ7, ship_geo.muShield.dZ8,
                ship_geo.muShield.dXgap, ship_geo.muShield.LE,
                ship_geo.Yheight * 4. / 10.,
                ship_geo.cave.floorHeightMuonShield, ship_geo.muShield.Field)
    elif ship_geo.muShieldDesign == 8:
        MuonShield = ROOT.ShipMuonShield(ship_geo.muShieldGeo)

    detectorList.append(MuonShield)

    if not hasattr(ship_geo, "magnetDesign"):
        # backward compatibility
        magnet_design = 2
        if ship_geo.tankDesign == 5: magnet_design = 3
        if ship_geo.tankDesign == 6: magnet_design = 4
        ship_geo.magnetDesign = magnet_design
        ship_geo.Bfield.YokeWidth = 200. * u.cm
        ship_geo.Bfield.YokeDepth = 200. * u.cm
        ship_geo.Bfield.CoilThick = 25. * u.cm
# sanity check, 2018 layout ship_geo.tankDesign == 6 has to be together with ship_geo.nuTauTargetDesign == 3
    if (ship_geo.tankDesign == 6 and ship_geo.nuTauTargetDesign != 3) or (
            ship_geo.tankDesign != 6 and ship_geo.nuTauTargetDesign == 3):
        print "version of tankDesign and nuTauTargetDesign are not compatible, should be 6 and 3, it is ", ship_geo.tankDesign, ship_geo.nuTauTargetDesign
        exit()
    if ship_geo.strawDesign > 1:
        if ship_geo.magnetDesign > 3:
            B = ship_geo.Bfield
            magnet = ROOT.ShipMagnet("Magnet", "SHiP Magnet", B.z,
                                     ship_geo.magnetDesign, B.x, B.y,
                                     ship_geo.cave.floorHeightTankB,
                                     B.YokeWidth, B.YokeDepth, B.CoilThick)
#                                                               xaperture,  yaperture
        else:
            magnet = ROOT.ShipMagnet("Magnet", "SHiP Magnet",
                                     ship_geo.Bfield.z, ship_geo.magnetDesign,
                                     ship_geo.Bfield.x, ship_geo.Bfield.y,
                                     ship_geo.cave.floorHeightTankB)
    else:
        magnet = ROOT.ShipMagnet("Magnet", "SHiP Magnet", ship_geo.Bfield.z)
    detectorList.append(magnet)

    Veto = ROOT.veto("Veto", ROOT.kTRUE)  # vacuum tank
    Veto.SetLiquidVeto(1)  # liquid scintillator
    Veto.SetPlasticVeto(1)  # plastic scintillator

    Veto.SetZpositions(ship_geo.vetoStation.z, ship_geo.TrackStation1.z, ship_geo.TrackStation2.z, \
                       ship_geo.TrackStation3.z, ship_geo.TrackStation4.z,ship_geo.tankDesign)
    Veto.SetTubZpositions(ship_geo.Chamber1.z, ship_geo.Chamber2.z,
                          ship_geo.Chamber3.z, ship_geo.Chamber4.z,
                          ship_geo.Chamber5.z, ship_geo.Chamber6.z)
    Veto.SetTublengths(ship_geo.chambers.Tub1length,ship_geo.chambers.Tub2length,ship_geo.chambers.Tub3length, \
                       ship_geo.chambers.Tub4length,ship_geo.chambers.Tub5length,ship_geo.chambers.Tub6length)
    Veto.SetB(ship_geo.Yheight / 2.)
    Veto.SetFloorHeight(ship_geo.cave.floorHeightTankA,
                        ship_geo.cave.floorHeightTankB)
    if ship_geo.tankDesign > 4:
        dzX = ship_geo.zFocusX + ship_geo.target.z0
        x1 = ship_geo.xMax / (ship_geo.Chamber1.z -
                              ship_geo.chambers.Tub1length -
                              dzX) * (ship_geo.TrackStation4.z - dzX)
        dzY = ship_geo.zFocusY + ship_geo.target.z0
        y1 = ship_geo.Yheight / (ship_geo.Chamber1.z -
                                 ship_geo.chambers.Tub1length -
                                 dzY) * (ship_geo.TrackStation4.z - dzY)
        Veto.SetXYstart(x1, dzX, y1, dzY)
        Veto.SetVesselStructure(ship_geo.Veto.innerSupport,ship_geo.Veto.sensitiveThickness,ship_geo.Veto.outerSupport,\
                                ship_geo.Veto.innerSupportMed,ship_geo.Veto.lidThickness,ship_geo.Veto.sensitiveMed,\
                                ship_geo.Veto.outerSupportMed,ship_geo.Veto.decayMed,\
                                ship_geo.Veto.rib,ship_geo.Veto.ribMed)

    detectorList.append(Veto)
    if hasattr(ship_geo, 'tauMudet'):  # don't support old designs

        if ship_geo.muShieldDesign not in [2, 3, 4] and hasattr(
                ship_geo.tauMudet, 'Xtot'):
            taumuondetector = ROOT.NuTauMudet("NuTauMudet",
                                              ship_geo.tauMudet.zMudetC,
                                              ROOT.kTRUE)
            taumuondetector.SetDesign(ship_geo.nuTauTargetDesign)
            taumuondetector.SetTotDimensions(ship_geo.tauMudet.Xtot,
                                             ship_geo.tauMudet.Ytot,
                                             ship_geo.tauMudet.Ztot)
            taumuondetector.SetFeDimensions(ship_geo.tauMudet.XFe,
                                            ship_geo.tauMudet.YFe,
                                            ship_geo.tauMudet.ZFe)
            taumuondetector.SetRpcDimensions(ship_geo.tauMudet.XRpc,
                                             ship_geo.tauMudet.YRpc,
                                             ship_geo.tauMudet.ZRpc)
            taumuondetector.SetRpcGasDimensions(ship_geo.tauMudet.XGas,
                                                ship_geo.tauMudet.YGas,
                                                ship_geo.tauMudet.ZGas)
            taumuondetector.SetRpcStripDimensions(ship_geo.tauMudet.XStrip,
                                                  ship_geo.tauMudet.YStrip,
                                                  ship_geo.tauMudet.ZStrip)
            taumuondetector.SetRpcElectrodeDimensions(ship_geo.tauMudet.XEle,
                                                      ship_geo.tauMudet.YEle,
                                                      ship_geo.tauMudet.ZEle)
            taumuondetector.SetRpcPETDimensions(ship_geo.tauMudet.XPet,
                                                ship_geo.tauMudet.YPet,
                                                ship_geo.tauMudet.ZPet)
            taumuondetector.SetNFeInArm(ship_geo.tauMudet.NFe)
            taumuondetector.SetNRpcInArm(ship_geo.tauMudet.NRpc)
            taumuondetector.SetPillarDimensions(ship_geo.tauMudet.PillarX,
                                                ship_geo.tauMudet.PillarY,
                                                ship_geo.tauMudet.PillarZ)
            detectorList.append(taumuondetector)
            if ship_geo.nuTauTargetDesign == 3:
                taumuondetector.SetRpcDimDifferences(ship_geo.tauMudet.deltax,
                                                     ship_geo.tauMudet.deltay)
            if ship_geo.nuTauTargetDesign < 3:
                taumuondetector.SetReturnYokeDimensions(
                    ship_geo.tauMudet.XRyoke, ship_geo.tauMudet.YRyoke,
                    ship_geo.tauMudet.ZRyoke)
                taumuondetector.SetSmallerYokeDimensions(
                    ship_geo.tauMudet.XRyoke_s, ship_geo.tauMudet.YRyoke_s,
                    ship_geo.tauMudet.ZRyoke_s)
                taumuondetector.SetZDimensionArm(ship_geo.tauMudet.ZArm)
                taumuondetector.SetGapDownstream(ship_geo.tauMudet.GapD)
                taumuondetector.SetGapMiddle(ship_geo.tauMudet.GapM)
                taumuondetector.SetMagneticField(ship_geo.tauMudet.B)
                taumuondetector.SetCoilParameters(ship_geo.tauMudet.CoilH,
                                                  ship_geo.tauMudet.CoilW,
                                                  ship_geo.tauMudet.N,
                                                  ship_geo.tauMudet.CoilG)

            if ship_geo.nuTauTargetDesign == 0 or ship_geo.nuTauTargetDesign == 1 or ship_geo.nuTauTargetDesign == 3:
                EmuMagnet = ROOT.EmulsionMagnet("EmuMagnet",
                                                ship_geo.EmuMagnet.zC,
                                                "EmulsionMagnet")
                EmuMagnet.SetDesign(ship_geo.EmuMagnet.Design)
                EmuMagnet.SetGaps(ship_geo.EmuMagnet.GapUp,
                                  ship_geo.EmuMagnet.GapDown)
                EmuMagnet.SetMagneticField(ship_geo.EmuMagnet.B)
                EmuMagnet.SetMagnetSizes(ship_geo.EmuMagnet.X,
                                         ship_geo.EmuMagnet.Y,
                                         ship_geo.EmuMagnet.Z)
                if ship_geo.nuTauTargetDesign == 0 or ship_geo.nuTauTargetDesign == 1:
                    EmuMagnet.SetCoilParameters(ship_geo.EmuMagnet.Radius,
                                                ship_geo.EmuMagnet.Height1,
                                                ship_geo.EmuMagnet.Height2,
                                                ship_geo.EmuMagnet.Distance)
                if ship_geo.nuTauTargetDesign == 3:
                    EmuMagnet.SetCoilParameters(ship_geo.EmuMagnet.CoilX,
                                                ship_geo.EmuMagnet.CoilY,
                                                ship_geo.EmuMagnet.Height1,
                                                ship_geo.EmuMagnet.Height2,
                                                ship_geo.EmuMagnet.Thickness)
                    EmuMagnet.SetCutDimensions(ship_geo.EmuMagnet.CutLength,
                                               ship_geo.EmuMagnet.CutHeight)
                EmuMagnet.SetMagnetColumn(ship_geo.EmuMagnet.ColX,
                                          ship_geo.EmuMagnet.ColY,
                                          ship_geo.EmuMagnet.ColZ)
                EmuMagnet.SetBaseDim(ship_geo.EmuMagnet.BaseX,
                                     ship_geo.EmuMagnet.BaseY,
                                     ship_geo.EmuMagnet.BaseZ)
                EmuMagnet.SetPillarDimensions(ship_geo.EmuMagnet.PillarX,
                                              ship_geo.EmuMagnet.PillarY,
                                              ship_geo.EmuMagnet.PillarZ)
                detectorList.append(EmuMagnet)
            if ship_geo.nuTauTargetDesign == 2:
                EmuMagnet = ROOT.EmulsionMagnet()

            NuTauTarget = ROOT.Target("NuTauTarget",
                                      ship_geo.NuTauTarget.Ydist, ROOT.kTRUE)
            NuTauTarget.MakeNuTargetPassive(
                ship_geo.NuTauTarget.nuTargetPassive)
            NuTauTarget.MergeTopBot(ship_geo.NuTauTarget.SingleEmFilm)
            NuTauTarget.SetDetectorDesign(ship_geo.NuTauTarget.Design)
            if ship_geo.nuTauTargetDesign != 3:
                NuTauTarget.SetCenterZ(ship_geo.NuTauTarget.zC)
            if ship_geo.nuTauTargetDesign == 3:
                NuTauTarget.SetCenterZ(
                    ship_geo.EmuMagnet.zC
                )  #now the centers of emumagnet and nutautarget are different (target does not include HPT)
                NuTauTarget.SetNumberTargets(ship_geo.NuTauTarget.target)
                NuTauTarget.SetHpTParam(ship_geo.tauHPT.nHPT,
                                        ship_geo.tauHPT.distHPT,
                                        ship_geo.tauHPT.DZ)
            NuTauTarget.SetNumberBricks(ship_geo.NuTauTarget.col,
                                        ship_geo.NuTauTarget.row,
                                        ship_geo.NuTauTarget.wall)
            NuTauTarget.SetDetectorDimension(ship_geo.NuTauTarget.xdim,
                                             ship_geo.NuTauTarget.ydim,
                                             ship_geo.NuTauTarget.zdim)
            NuTauTarget.SetEmulsionParam(
                ship_geo.NuTauTarget.EmTh, ship_geo.NuTauTarget.EmX,
                ship_geo.NuTauTarget.EmY, ship_geo.NuTauTarget.PBTh,
                ship_geo.NuTauTarget.EPlW, ship_geo.NuTauTarget.LeadTh,
                ship_geo.NuTauTarget.AllPW)
            NuTauTarget.SetBrickParam(ship_geo.NuTauTarget.BrX,
                                      ship_geo.NuTauTarget.BrY,
                                      ship_geo.NuTauTarget.BrZ,
                                      ship_geo.NuTauTarget.BrPackX,
                                      ship_geo.NuTauTarget.BrPackY,
                                      ship_geo.NuTauTarget.BrPackZ)
            NuTauTarget.SetCESParam(ship_geo.NuTauTarget.RohG,
                                    ship_geo.NuTauTarget.LayerCESW,
                                    ship_geo.NuTauTarget.CESW,
                                    ship_geo.NuTauTarget.CESPack)
            NuTauTarget.SetCellParam(ship_geo.NuTauTarget.CellW)
            if ship_geo.nuTauTargetDesign == 0 or ship_geo.nuTauTargetDesign == 1:
                NuTauTarget.SetMagnetHeight(ship_geo.EmuMagnet.Y)
                NuTauTarget.SetColumnHeight(ship_geo.EmuMagnet.ColY)
                NuTauTarget.SetBaseHeight(ship_geo.EmuMagnet.BaseY)
                NuTauTarget.SetCoilUpHeight(ship_geo.EmuMagnet.Height1)
                NuTauTarget.SetCoilDownHeight(ship_geo.EmuMagnet.Height2)
            if ship_geo.nuTauTargetDesign != 2:
                NuTauTarget.SetMagneticField(ship_geo.EmuMagnet.B)
            if ship_geo.nuTauTargetDesign == 2:
                NuTauTarget.SetPillarDimension(ship_geo.NuTauTarget.PillarX,
                                               ship_geo.NuTauTarget.PillarY,
                                               ship_geo.NuTauTarget.PillarZ)
                NuTauTarget.SetBaseDimension(ship_geo.NuTauTarget.BaseX,
                                             ship_geo.NuTauTarget.BaseY,
                                             ship_geo.NuTauTarget.BaseZ)

            NuTauTT = ROOT.TargetTracker("TargetTrackers", ROOT.kTRUE)
            NuTauTT.SetDesign(ship_geo.NuTauTT.design)
            NuTauTT.SetTargetTrackerParam(ship_geo.NuTauTT.TTX,
                                          ship_geo.NuTauTT.TTY,
                                          ship_geo.NuTauTT.TTZ)
            NuTauTT.SetBrickParam(ship_geo.NuTauTarget.CellW)
            NuTauTT.SetTotZDimension(ship_geo.NuTauTarget.zdim)
            NuTauTT.SetNumberTT(ship_geo.NuTauTT.n)

            #method of nutau target that must be called after TT parameter definition
            NuTauTarget.SetTTzdimension(ship_geo.NuTauTT.TTZ)

            detectorList.append(NuTauTarget)
            detectorList.append(NuTauTT)

            tauHpt = ROOT.Hpt("HighPrecisionTrackers", ship_geo.tauHPT.DX,
                              ship_geo.tauHPT.DY, ship_geo.tauHPT.DZ,
                              ROOT.kTRUE)
            tauHpt.SetZsize(ship_geo.tauMudet.Ztot)
            tauHpt.SetDesign(ship_geo.NuTauTarget.Design)
            if ship_geo.nuTauTargetDesign < 3:
                tauHpt.SetConcreteBaseDim(ship_geo.tauHPT.ConcreteX,
                                          ship_geo.tauHPT.ConcreteY,
                                          ship_geo.tauHPT.ConcreteZ)
            if ship_geo.nuTauTargetDesign == 3:
                tauHpt.SetHPTNumber(ship_geo.tauHPT.nHPT)
                tauHpt.SetDistanceHPTs(ship_geo.tauHPT.distHPT)
                tauHpt.SetSurroundingDetHeight(ship_geo.tauHPT.SRDY)
                tauHpt.GetMagnetGeometry(ship_geo.EmuMagnet.zC,
                                         ship_geo.EmuMagnet.Y)
                tauHpt.GetNumberofTargets(ship_geo.NuTauTarget.target)
            detectorList.append(tauHpt)

    # for backward compatibility
    if not hasattr(ship_geo.strawtubes, "YPlaneOffset"):
        ship_geo.strawtubes.YLayerOffset = ship_geo.strawtubes.StrawPitch / 2.
        ship_geo.strawtubes.YPlaneOffset = ship_geo.strawtubes.StrawPitch / 4.
    if ship_geo.strawDesign > 1:
        # for backward compatibility
        if ship_geo.strawDesign == 10 and not hasattr(ship_geo.strawtubes,
                                                      "DeltazFrame"):
            ship_geo.strawtubes.DeltazFrame = 2.5 * u.cm
            ship_geo.strawtubes.FrameLateralWidth = 1.2 * u.m
            ship_geo.strawtubes.FrameMaterial = "steel"
        elif not hasattr(ship_geo.strawtubes, "DeltazFrame"):
            ship_geo.strawtubes.DeltazFrame = 10. * u.cm
            ship_geo.strawtubes.FrameLateralWidth = 1. * u.cm
            ship_geo.strawtubes.FrameMaterial = "aluminium"

        Strawtubes = ROOT.strawtubes("Strawtubes", ROOT.kTRUE)
        Strawtubes.SetZpositions(ship_geo.vetoStation.z,
                                 ship_geo.TrackStation1.z,
                                 ship_geo.TrackStation2.z,
                                 ship_geo.TrackStation3.z,
                                 ship_geo.TrackStation4.z)
        Strawtubes.SetDeltazFrame(ship_geo.strawtubes.DeltazFrame)
        Strawtubes.SetFrameLateralWidth(ship_geo.strawtubes.FrameLateralWidth)
        Strawtubes.SetFrameMaterial(ship_geo.strawtubes.FrameMaterial)
        Strawtubes.SetDeltazView(ship_geo.strawtubes.DeltazView)
        Strawtubes.SetInnerStrawDiameter(
            ship_geo.strawtubes.InnerStrawDiameter)
        Strawtubes.SetOuterStrawDiameter(
            ship_geo.strawtubes.OuterStrawDiameter)
        Strawtubes.SetStrawPitch(ship_geo.strawtubes.StrawPitch,
                                 ship_geo.strawtubes.YLayerOffset,
                                 ship_geo.strawtubes.YPlaneOffset)
        Strawtubes.SetDeltazLayer(ship_geo.strawtubes.DeltazLayer)
        Strawtubes.SetDeltazPlane(ship_geo.strawtubes.DeltazPlane)
        Strawtubes.SetStrawsPerLayer(ship_geo.strawtubes.StrawsPerLayer)
        Strawtubes.SetStereoAngle(ship_geo.strawtubes.ViewAngle)
        Strawtubes.SetWireThickness(ship_geo.strawtubes.WireThickness)
        Strawtubes.SetVacBox_x(ship_geo.strawtubes.VacBox_x)
        Strawtubes.SetVacBox_y(ship_geo.strawtubes.VacBox_y)
        Strawtubes.SetStrawLength(ship_geo.strawtubes.StrawLength)

        if hasattr(ship_geo.strawtubes, "StrawLengthVeto"):
            Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLengthVeto)
            Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength12)
            Strawtubes.SetVetoYDim(ship_geo.strawtubes.vetoydim)
            Strawtubes.SetTr12YDim(ship_geo.strawtubes.tr12ydim)
            Strawtubes.SetTr34YDim(ship_geo.strawtubes.tr34ydim)
        else:
            Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLength)
            Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength)
            Strawtubes.SetVetoYDim(ship_geo.Yheight / 2.)
            Strawtubes.SetTr12YDim(ship_geo.Yheight / 2.)
            Strawtubes.SetTr34YDim(ship_geo.Yheight / 2.)
        # for the digitizing step
        Strawtubes.SetStrawResolution(
            getParameter("strawtubes.v_drift", ship_geo, latestShipGeo),
            getParameter("strawtubes.sigma_spatial", ship_geo, latestShipGeo))
        detectorList.append(Strawtubes)

    if ship_geo.EcalOption == 1:  # shashlik design TP
        if ship_geo.preshowerOption > 0:
            Preshower = ROOT.preshower("Preshower", ROOT.kTRUE)
            Preshower.SetZStationPosition2(ship_geo.PreshowerStation0.z,
                                           ship_geo.PreshowerStation1.z)
            Preshower.SetZFilterPosition2(ship_geo.PreshowerFilter0.z,
                                          ship_geo.PreshowerFilter1.z)
            Preshower.SetXMax(ship_geo.Preshower.XMax)
            Preshower.SetYMax(ship_geo.Preshower.YMax)
            Preshower.SetActiveThickness(ship_geo.Preshower.ActiveThickness)
            Preshower.SetFilterThickness2(ship_geo.Preshower.FilterThickness0,
                                          ship_geo.Preshower.FilterThickness1)
            detectorList.append(Preshower)

        ecal, EcalZSize = posEcal(ship_geo.ecal.z, ship_geo.ecal.File)
        detectorList.append(ecal)

    if ship_geo.EcalOption == 2:  # splitCal with pointing information
        SplitCal = ROOT.splitcal("SplitCal", ROOT.kTRUE)
        x = ship_geo.SplitCal
        SplitCal.SetThickness(x.ActiveECALThickness, x.ActiveHCALThickness,
                              x.FilterECALThickness,
                              x.FilterECALThickness_first,
                              x.FilterHCALThickness,
                              x.ActiveECAL_gas_Thickness)
        SplitCal.SetMaterial(x.ActiveECALMaterial, x.ActiveHCALMaterial,
                             x.FilterECALMaterial, x.FilterHCALMaterial)
        SplitCal.SetNSamplings(x.nECALSamplings, x.nHCALSamplings,
                               x.ActiveHCAL)
        SplitCal.SetZStart(x.ZStart)
        SplitCal.SetXMax(x.XMax)
        SplitCal.SetYMax(x.YMax)
        SplitCal.SetEmpty(x.Empty, x.BigGap, x.ActiveECAL_gas_gap,
                          x.first_precision_layer, x.second_precision_layer,
                          x.third_precision_layer, x.num_precision_layers)
        SplitCal.SetNModules(x.NModulesInX, x.NModulesInY)
        SplitCal.SetNStrips(x.NStripsPerModule)
        SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength)
        detectorList.append(SplitCal)

    if not ship_geo.HcalOption < 0:
        hcal, HcalZSize = posHcal(ship_geo.hcal.z, ship_geo.hcal.File,
                                  ship_geo.HcalOption)
        if ship_geo.HcalOption != 2 and abs(ship_geo.hcal.hcalSpace -
                                            HcalZSize) > 10 * u.cm:
            print 'mismatch between hcalsize in geo file and python configuration'
            print ship_geo.hcal.hcalSpace - HcalZSize, ship_geo.hcal.hcalSpace, HcalZSize
        detectorList.append(hcal)
    Muon = ROOT.muon("Muon", ROOT.kTRUE)
    Muon.SetZStationPositions(ship_geo.MuonStation0.z, ship_geo.MuonStation1.z,
                              ship_geo.MuonStation2.z, ship_geo.MuonStation3.z)
    Muon.SetZFilterPositions(ship_geo.MuonFilter0.z, ship_geo.MuonFilter1.z,
                             ship_geo.MuonFilter2.z)
    Muon.SetXMax(ship_geo.Muon.XMax)
    Muon.SetYMax(ship_geo.Muon.YMax)
    Muon.SetActiveThickness(ship_geo.Muon.ActiveThickness)
    Muon.SetFilterThickness(ship_geo.Muon.FilterThickness)
    detectorList.append(Muon)

    timeDet = ROOT.TimeDet("TimeDet", ROOT.kTRUE)
    timeDet.SetZposition(ship_geo.TimeDet.z)
    timeDet.SetBarZspacing(ship_geo.TimeDet.dzBarRow,
                           ship_geo.TimeDet.dzBarCol)
    timeDet.SetBarZ(ship_geo.TimeDet.zBar)
    timeDet.SetSizeX(2 * ship_geo.TimeDet.DX)
    timeDet.SetSizeY(2 * ship_geo.TimeDet.DY)
    detectorList.append(timeDet)

    #-----   Magnetic field   -------------------------------------------
    if not hasattr(ship_geo.Bfield, "fieldMap"):
        if ship_geo.strawDesign == 4 or ship_geo.strawDesign == 10:
            fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max,
                                           ship_geo.Bfield.z, 2,
                                           ship_geo.Yheight / 2. * u.m)
        else:
            fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max,
                                           ship_geo.Bfield.z, 1,
                                           ship_geo.Yheight / 2. * u.m)
        if ship_geo.muShieldDesign == 6:
            fMagField.IncludeTarget(ship_geo.target.xy, ship_geo.target.z0,
                                    ship_geo.target.length)
        run.SetField(fMagField)
#
    exclusionList = []
    #exclusionList = ["Muon","Ecal","Hcal","Strawtubes","TargetTrackers","NuTauTarget","HighPrecisionTrackers",\
    #                 "Veto","Magnet","MuonShield","TargetStation","NuTauMudet","EmuMagnet", "TimeDet"]
    for x in detectorList:
        if x.GetName() in exclusionList: continue
        run.AddModule(x)


# return list of detector elements
    detElements = {}
    for x in run.GetListOfModules():
        detElements[x.GetName()] = x
    return detElements
Exemplo n.º 50
0
def run_track_pattern_recognition(input_file, geo_file, output_file, method):
    """
    Runs all steps of track pattern recognition.
    Parameters
    ----------
    input_file : string
        Path to an input .root file with events.
    geo_file : string
        Path to a file with SHiP geometry.
    output_file : string
        Path to an output .root file with quality plots.
    method : string
        Name of a track pattern recognition method.
    """

    ############################################# Load SHiP geometry ###################################################

    # Check geo file
    try:
        fgeo = ROOT.TFile(geo_file)
    except:
        print("An error with opening the ship geo file.")
        raise

    sGeo = fgeo.FAIRGeom

    # Prepare ShipGeo dictionary
    if not fgeo.FindKey('ShipGeo'):

        if sGeo.GetVolume('EcalModule3'):
            ecalGeoFile = "ecal_ellipse6x12m2.geo"
        else:
            ecalGeoFile = "ecal_ellipse5x10m2.geo"

        if dy:
            ShipGeo = ConfigRegistry.loadpy(
                "$FAIRSHIP/geometry/geometry_config.py",
                Yheight=dy,
                EcalGeoFile=ecalGeoFile)
        else:
            ShipGeo = ConfigRegistry.loadpy(
                "$FAIRSHIP/geometry/geometry_config.py",
                EcalGeoFile=ecalGeoFile)

    else:
        upkl = Unpickler(fgeo)
        ShipGeo = upkl.load('ShipGeo')

    # Globals
    builtin.ShipGeo = ShipGeo

    ############################################# Load SHiP modules ####################################################

    import shipDet_conf
    run = ROOT.FairRunSim()
    run.SetName("TGeant4")  # Transport engine
    run.SetOutputFile("dummy")  # Output file
    run.SetUserConfig(
        "g4Config_basic.C"
    )  # geant4 transport not used, only needed for the mag field
    rtdb = run.GetRuntimeDb()

    modules = shipDet_conf.configure(run, ShipGeo)
    run.Init()

    #run = ROOT.FairRunSim()
    #modules = shipDet_conf.configure(run,ShipGeo)

    ######################################### Load SHiP magnetic field #################################################

    import geomGeant4
    if hasattr(ShipGeo.Bfield, "fieldMap"):
        fieldMaker = geomGeant4.addVMCFields(ShipGeo,
                                             '',
                                             True,
                                             withVirtualMC=False)
    else:
        print("no fieldmap given, geofile too old, not anymore support")
        exit(-1)
    sGeo = fgeo.FAIRGeom
    geoMat = ROOT.genfit.TGeoMaterialInterface()
    ROOT.genfit.MaterialEffects.getInstance().init(geoMat)
    bfield = ROOT.genfit.FairShipFields()
    bfield.setField(fieldMaker.getGlobalField())
    fM = ROOT.genfit.FieldManager.getInstance()
    fM.init(bfield)

    ############################################# Load inpur data file #################################################

    # Check input file
    try:
        fn = ROOT.TFile(input_file, 'update')
    except:
        print("An error with opening the input data file.")
        raise

    sTree = fn.cbmsim
    sTree.Write()

    ############################################# Create hists #########################################################

    h = init_book_hist()

    ########################################## Start Track Pattern Recognition #########################################
    import shipPatRec

    # Init book of hists for the quality measurements
    metrics = {
        'n_hits': [],
        'reconstructible': 0,
        'passed_y12': 0,
        'passed_stereo12': 0,
        'passed_12': 0,
        'passed_y34': 0,
        'passed_stereo34': 0,
        'passed_34': 0,
        'passed_combined': 0,
        'reco_passed': 0,
        'reco_passed_no_clones': 0,
        'frac_y12': [],
        'frac_stereo12': [],
        'frac_12': [],
        'frac_y34': [],
        'frac_stereo34': [],
        'frac_34': [],
        'reco_frac_tot': [],
        'reco_mc_p': [],
        'reco_mc_theta': [],
        'fitted_p': [],
        'fitted_pval': [],
        'fitted_chi': [],
        'fitted_x': [],
        'fitted_y': [],
        'fitted_z': [],
        'fitted_mass': []
    }

    # Start event loop
    nEvents = sTree.GetEntries()

    for iEvent in range(nEvents):

        if iEvent % 1000 == 0:
            print('Event ', iEvent)

        ########################################### Select one event ###################################################

        rc = sTree.GetEvent(iEvent)

        ########################################### Reconstructible tracks #############################################

        reconstructible_tracks = getReconstructibleTracks(
            iEvent, sTree, sGeo, ShipGeo)

        metrics['reconstructible'] += len(reconstructible_tracks)
        for i_reco in reconstructible_tracks:
            h['TracksPassed'].Fill("Reconstructible tracks", 1)
            h['TracksPassedU'].Fill("Reconstructible tracks", 1)

        in_y12 = []
        in_stereo12 = []
        in_12 = []
        in_y34 = []
        in_stereo34 = []
        in_34 = []
        in_combo = []

        found_track_ids = []
        n_tracks = len(reconstructible_tracks)
        n_recognized = 0
        n_clones = 0
        n_ghosts = 0
        n_others = 0

        min_eff = 0.

        ########################################## Recognized tracks ###################################################

        nTracklets = sTree.Tracklets.GetEntriesFast()

        for i_track in range(nTracklets):

            atracklet = sTree.Tracklets[i_track]

            if atracklet.getType() != 1:  # this is a not full track (tracklet)
                continue

            atrack = atracklet.getList()

            if atrack.size() == 0:
                continue

            hits = {
                'X': [],
                'Y': [],
                'Z': [],
                'DetID': [],
                'TrackID': [],
                'Pz': [],
                'Px': [],
                'Py': [],
                'dist2Wire': [],
                'Pdg': []
            }

            for ihit in atrack:
                ahit = sTree.strawtubesPoint[ihit]
                hits['X'] += [ahit.GetX()]
                hits['Y'] += [ahit.GetY()]
                hits['Z'] += [ahit.GetZ()]
                hits['DetID'] += [ahit.GetDetectorID()]
                hits['TrackID'] += [ahit.GetTrackID()]
                hits['Pz'] += [ahit.GetPz()]
                hits['Px'] += [ahit.GetPx()]
                hits['Py'] += [ahit.GetPy()]
                hits['dist2Wire'] += [ahit.dist2Wire()]
                hits['Pdg'] += [ahit.PdgCode()]

            # List to numpy arrays
            for key in hits.keys():
                hits[key] = numpy.array(hits[key])

            # Decoding
            statnb, vnb, pnb, lnb, snb = decodeDetectorID(hits['DetID'])
            is_stereo = ((vnb == 1) + (vnb == 2))
            is_y = ((vnb == 0) + (vnb == 3))
            is_before = ((statnb == 1) + (statnb == 2))
            is_after = ((statnb == 3) + (statnb == 4))

            # Metrics
            metrics['n_hits'] += [get_n_hits(hits['TrackID'])]

            # Tracks passed
            frac_y12, tmax_y12 = fracMCsame(hits['TrackID'][is_before * is_y])
            n_hits_y12 = get_n_hits(hits['TrackID'][is_before * is_y])
            frac_stereo12, tmax_stereo12 = fracMCsame(
                hits['TrackID'][is_before * is_stereo])
            n_hits_stereo12 = get_n_hits(hits['TrackID'][is_before *
                                                         is_stereo])
            frac_12, tmax_12 = fracMCsame(hits['TrackID'][is_before])
            n_hits_12 = get_n_hits(hits['TrackID'][is_before])

            frac_y34, tmax_y34 = fracMCsame(hits['TrackID'][is_after * is_y])
            n_hits_y34 = get_n_hits(hits['TrackID'][is_after * is_y])
            frac_stereo34, tmax_stereo34 = fracMCsame(
                hits['TrackID'][is_after * is_stereo])
            n_hits_stereo34 = get_n_hits(hits['TrackID'][is_after * is_stereo])
            frac_34, tmax_34 = fracMCsame(hits['TrackID'][is_after])
            n_hits_34 = get_n_hits(hits['TrackID'][is_after])
            frac_tot, tmax_tot = fracMCsame(hits['TrackID'])
            n_hits_tot = get_n_hits(hits['TrackID'])

            if tmax_y12 == tmax_stereo12 and tmax_y12 == tmax_y34 and tmax_y12 == tmax_stereo34:
                if frac_y12 >= min_eff and frac_stereo12 >= min_eff and frac_y34 >= min_eff and frac_stereo34 >= min_eff:

                    if tmax_y12 in reconstructible_tracks and tmax_y12 not in found_track_ids:
                        n_recognized += 1
                        found_track_ids.append(tmax_y12)
                    elif tmax_y12 in reconstructible_tracks and tmax_y12 in found_track_ids:
                        n_clones += 1
                    elif tmax_y12 not in reconstructible_tracks:
                        n_others += 1

                else:
                    n_ghosts += 1
            else:
                n_ghosts += 1

            is_reconstructed = 0
            is_reconstructed_no_clones = 0

            if tmax_y12 in reconstructible_tracks:
                metrics['passed_y12'] += 1
                metrics['frac_y12'] += [frac_y12]
                h['TracksPassed'].Fill("Y view station 1&2", 1)
                if tmax_y12 not in in_y12:
                    h['TracksPassedU'].Fill("Y view station 1&2", 1)
                    in_y12.append(tmax_y12)

                if tmax_stereo12 == tmax_y12:
                    metrics['passed_stereo12'] += 1
                    metrics['frac_stereo12'] += [frac_stereo12]
                    h['TracksPassed'].Fill("Stereo station 1&2", 1)
                    if tmax_stereo12 not in in_stereo12:
                        h['TracksPassedU'].Fill("Stereo station 1&2", 1)
                        in_stereo12.append(tmax_stereo12)

                    if tmax_12 == tmax_y12:
                        metrics['passed_12'] += 1
                        metrics['frac_12'] += [frac_12]
                        h['TracksPassed'].Fill("station 1&2", 1)
                        if tmax_12 not in in_12:
                            h['TracksPassedU'].Fill("station 1&2", 1)
                            in_12.append(tmax_12)

                        if tmax_y34 in reconstructible_tracks:
                            metrics['passed_y34'] += 1
                            metrics['frac_y34'] += [frac_y34]
                            h['TracksPassed'].Fill("Y view station 3&4", 1)
                            if tmax_y34 not in in_y34:
                                h['TracksPassedU'].Fill(
                                    "Y view station 3&4", 1)
                                in_y34.append(tmax_y34)

                            if tmax_stereo34 == tmax_y34:
                                metrics['passed_stereo34'] += 1
                                metrics['frac_stereo34'] += [frac_stereo34]
                                h['TracksPassed'].Fill("Stereo station 3&4", 1)
                                if tmax_stereo34 not in in_stereo34:
                                    h['TracksPassedU'].Fill(
                                        "Stereo station 3&4", 1)
                                    in_stereo34.append(tmax_stereo34)

                                if tmax_34 == tmax_y34:
                                    metrics['passed_34'] += 1
                                    metrics['frac_34'] += [frac_34]
                                    h['TracksPassed'].Fill("station 3&4", 1)
                                    if tmax_34 not in in_34:
                                        h['TracksPassedU'].Fill(
                                            "station 3&4", 1)
                                        in_34.append(tmax_34)

                                    if tmax_12 == tmax_34:
                                        metrics['passed_combined'] += 1
                                        h['TracksPassed'].Fill(
                                            "Combined stations 1&2/3&4", 1)
                                        metrics['reco_passed'] += 1
                                        is_reconstructed = 1
                                        if tmax_34 not in in_combo:
                                            h['TracksPassedU'].Fill(
                                                "Combined stations 1&2/3&4", 1)
                                            metrics[
                                                'reco_passed_no_clones'] += 1
                                            in_combo.append(tmax_34)
                                            is_reconstructed_no_clones = 1

            # For reconstructed tracks
            if is_reconstructed == 0:
                continue

            metrics['reco_frac_tot'] += [frac_tot]

            # Momentum
            Pz = hits['Pz']
            Px = hits['Px']
            Py = hits['Py']

            p, px, py, pz = getPtruthFirst(sTree, tmax_tot)
            pt = math.sqrt(px**2 + py**2)

            Z_true = []
            X_true = []
            Y_true = []
            for ahit in sTree.strawtubesPoint:
                if ahit.GetTrackID() == tmax_tot:
                    az, ax, ay = ahit.GetZ(), ahit.GetX(), ahit.GetY()
                    Z_true.append(az)
                    X_true.append(ax)
                    Y_true.append(ay)

            metrics['reco_mc_p'] += [p]
            h['TracksPassed_p'].Fill(p, 1)

            # Direction
            Z = hits['Z'][(hits['TrackID'] == tmax_tot) * is_before]
            X = hits['X'][(hits['TrackID'] == tmax_tot) * is_before]
            Y = hits['Y'][(hits['TrackID'] == tmax_tot) * is_before]
            Z = Z - Z[0]
            X = X - X[0]
            Y = Y - Y[0]
            R = numpy.sqrt(X**2 + Y**2 + Z**2)
            Theta = numpy.arccos(Z[1:] / R[1:])
            theta = numpy.mean(Theta)

            metrics['reco_mc_theta'] += [theta]

            h['n_hits_reco_y12'].Fill(n_hits_y12)
            h['n_hits_reco_stereo12'].Fill(n_hits_stereo12)
            h['n_hits_reco_12'].Fill(n_hits_12)
            h['n_hits_reco_y34'].Fill(n_hits_y34)
            h['n_hits_reco_stereo34'].Fill(n_hits_stereo34)
            h['n_hits_reco_34'].Fill(n_hits_34)
            h['n_hits_reco'].Fill(n_hits_tot)

            h['n_hits_y12'].Fill(p, n_hits_y12)
            h['n_hits_stereo12'].Fill(p, n_hits_stereo12)
            h['n_hits_12'].Fill(p, n_hits_12)
            h['n_hits_y34'].Fill(p, n_hits_y34)
            h['n_hits_stereo34'].Fill(p, n_hits_stereo34)
            h['n_hits_34'].Fill(p, n_hits_34)
            h['n_hits_total'].Fill(p, n_hits_tot)

            h['frac_y12'].Fill(p, frac_y12)
            h['frac_stereo12'].Fill(p, frac_stereo12)
            h['frac_12'].Fill(p, frac_12)
            h['frac_y34'].Fill(p, frac_y34)
            h['frac_stereo34'].Fill(p, frac_stereo34)
            h['frac_34'].Fill(p, frac_34)
            h['frac_total'].Fill(p, frac_tot)

            h['frac_y12_dist'].Fill(frac_y12)
            h['frac_stereo12_dist'].Fill(frac_stereo12)
            h['frac_12_dist'].Fill(frac_12)
            h['frac_y34_dist'].Fill(frac_y34)
            h['frac_stereo34_dist'].Fill(frac_stereo34)
            h['frac_34_dist'].Fill(frac_34)
            h['frac_total_dist'].Fill(frac_tot)

            # Fitted track

            thetrack = sTree.FitTracks[i_track]

            fitStatus = thetrack.getFitStatus()
            thetrack.prune(
                "CFL"
            )  # http://sourceforge.net/p/genfit/code/HEAD/tree/trunk/core/include/Track.h#l280

            nmeas = fitStatus.getNdf()
            pval = fitStatus.getPVal()
            chi2 = fitStatus.getChi2() / nmeas

            metrics['fitted_pval'] += [pval]
            metrics['fitted_chi'] += [chi2]

            h['chi2fittedtracks'].Fill(chi2)
            h['pvalfittedtracks'].Fill(pval)

            try:

                fittedState = thetrack.getFittedState()
                fittedMom = fittedState.getMomMag()
                fittedMom = fittedMom  #*int(charge)

                px_fit, py_fit, pz_fit = fittedState.getMom().x(
                ), fittedState.getMom().y(), fittedState.getMom().z()
                p_fit = fittedMom
                pt_fit = math.sqrt(px_fit**2 + py_fit**2)

                metrics['fitted_p'] += [p_fit]
                perr = (p - p_fit) / p
                h['ptrue-p/ptrue'].Fill(perr)
                h['perr'].Fill(p, perr)
                h['perr_direction'].Fill(numpy.rad2deg(theta), perr)

                pterr = (pt - pt_fit) / pt
                h['pttrue-pt/pttrue'].Fill(pterr)

                pxerr = (px - px_fit) / px
                h['pxtrue-px/pxtrue'].Fill(pxerr)

                pyerr = (py - py_fit) / py
                h['pytrue-py/pytrue'].Fill(pyerr)

                pzerr = (pz - pz_fit) / pz
                h['pztrue-pz/pztrue'].Fill(pzerr)

                if math.fabs(p) > 0.0:
                    h['pvspfitted'].Fill(p, fittedMom)
                fittedtrackDir = fittedState.getDir()
                fittedx = math.degrees(math.acos(fittedtrackDir[0]))
                fittedy = math.degrees(math.acos(fittedtrackDir[1]))
                fittedz = math.degrees(math.acos(fittedtrackDir[2]))
                fittedmass = fittedState.getMass()
                h['momentumfittedtracks'].Fill(fittedMom)
                h['xdirectionfittedtracks'].Fill(fittedx)
                h['ydirectionfittedtracks'].Fill(fittedy)
                h['zdirectionfittedtracks'].Fill(fittedz)
                h['massfittedtracks'].Fill(fittedmass)

                metrics['fitted_x'] += [fittedx]
                metrics['fitted_y'] += [fittedy]
                metrics['fitted_z'] += [fittedz]
                metrics['fitted_mass'] += [fittedmass]

                Z_fit = []
                X_fit = []
                Y_fit = []
                for az in Z_true:
                    rc, pos, mom = extrapolateToPlane(thetrack, az)
                    Z_fit.append(pos.Z())
                    X_fit.append(pos.X())
                    Y_fit.append(pos.Y())

                for i in range(len(Z_true)):
                    xerr = abs(X_fit[i] - X_true[i])
                    yerr = abs(Y_fit[i] - Y_true[i])
                    h['abs(x - x-true)'].Fill(xerr)
                    h['abs(y - y-true)'].Fill(yerr)

                rmse_x = numpy.sqrt(
                    numpy.mean((numpy.array(X_fit) - numpy.array(X_true))**2))
                rmse_y = numpy.sqrt(
                    numpy.mean((numpy.array(Y_fit) - numpy.array(Y_true))**2))
                h['rmse_x'].Fill(rmse_x)
                h['rmse_y'].Fill(rmse_y)

            except:
                print("Problem with fitted state.")

        h['Reco_tracks'].Fill("N total", n_tracks)
        h['Reco_tracks'].Fill("N recognized tracks", n_recognized)
        h['Reco_tracks'].Fill("N clones", n_clones)
        h['Reco_tracks'].Fill("N ghosts", n_ghosts)
        h['Reco_tracks'].Fill("N others", n_others)

    ############################################# Save hists #########################################################

    save_hists(h, output_file)

    return metrics
Exemplo n.º 51
0
    geoFile = inputFile.replace('ship.', 'geofile_full.').replace('_rec.', '.')
if geoFile[0:4] == "/eos":
    eospath = "root://eoslhcb.cern.ch/" + geoFile
    fgeo = ROOT.TFile.Open(eospath)
else:
    fgeo = ROOT.TFile(geoFile)
sGeo = fgeo.FAIRGeom

if not fgeo.FindKey('ShipGeo'):
    # old geofile, missing Shipgeo dictionary
    if sGeo.GetVolume('EcalModule3'): ecalGeoFile = "ecal_ellipse6x12m2.geo"
    else: ecalGeoFile = "ecal_ellipse5x10m2.geo"
    print 'found ecal geo for ', ecalGeoFile
    # re-create geometry and mag. field
    ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py",
                                    Yheight=dy,
                                    EcalGeoFile=ecalGeoFile)
else:
    # new geofile, load Shipgeo dictionary written by run_simScript.py
    upkl = Unpickler(fgeo)
    ShipGeo = upkl.load('ShipGeo')
    ecalGeoFile = ShipGeo.ecal.File

# -----Create geometry----------------------------------------------
import shipDet_conf

run = ROOT.FairRunSim()
modules = shipDet_conf.configure(run, ShipGeo)

gMan = ROOT.gGeoManager
geoMat = ROOT.genfit.TGeoMaterialInterface()
Exemplo n.º 52
0
def configure(run,ship_geo):
# ---- for backward compatibility ----
 if not hasattr(ship_geo,"tankDesign"): ship_geo.tankDesign = 5
 if not hasattr(ship_geo,"muShieldGeo"): ship_geo.muShieldGeo = None
 if not hasattr(ship_geo.hcal,"File"):  ship_geo.hcal.File = "hcal.geo"
 if not hasattr(ship_geo.Bfield,'x') :  ship_geo.Bfield.x   = 3.*u.m
 if not hasattr(ship_geo,'cave') :       
   ship_geo.cave = AttrDict(z=0*u.cm)
   ship_geo.cave.floorHeightMuonShield = 5*u.m
   ship_geo.cave.floorHeightTankA   = 4.5*u.m
   ship_geo.cave.floorHeightTankB   = 2.*u.m
 if not hasattr(ship_geo,'NuTauTT') : ship_geo.NuTauTT= AttrDict(z=0*u.cm)
 if not hasattr(ship_geo.NuTauTT,'design') : ship_geo.NuTauTT.design = 0
 if not hasattr(ship_geo,'EcalOption'):     ship_geo.EcalOption = 1      
 latestShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py",Yheight = ship_geo.Yheight/u.m, tankDesign = ship_geo.tankDesign, muShieldDesign = ship_geo.muShieldDesign, nuTauTargetDesign = ship_geo.nuTauTargetDesign, muShieldGeo = ship_geo.muShieldGeo)
# -----Create media-------------------------------------------------
 run.SetMaterials("media.geo")  # Materials
# ------------------------------------------------------------------------
  
# -----Create geometry----------------------------------------------
 cave= ROOT.ShipCave("CAVE")
 if ship_geo.tankDesign < 5: cave.SetGeometryFileName("cave.geo")
 else: cave.SetGeometryFileName("caveWithAir.geo")
 detectorList.append(cave)

 if ship_geo.muShieldDesign in [6, 7, 8, 9]:  # magnetized hadron absorber defined in ShipMuonShield 
  TargetStation = ROOT.ShipTargetStation("TargetStation",ship_geo.target.length,
                                                        ship_geo.target.z,ship_geo.targetOpt,ship_geo.target.sl)
 else:
  TargetStation = ROOT.ShipTargetStation("TargetStation",ship_geo.target.length,ship_geo.hadronAbsorber.length,
                                                        ship_geo.target.z,ship_geo.hadronAbsorber.z,ship_geo.targetOpt,ship_geo.target.sl)
   
 if ship_geo.targetOpt>10:
  slices_length   = ROOT.std.vector('float')()
  slices_material = ROOT.std.vector('std::string')()
  for i in range(1,ship_geo.targetOpt+1):
   slices_length.push_back(  eval("ship_geo.target.L"+str(i)))
   slices_material.push_back(eval("ship_geo.target.M"+str(i)))
  TargetStation.SetLayerPosMat(ship_geo.target.xy,slices_length,slices_material)
 detectorList.append(TargetStation)

 if ship_geo.muShieldDesign==1:
  MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.length,\
                                   ship_geo.muShield.LE) 
 elif ship_geo.muShieldDesign==2:
  MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.dZ1,\
               ship_geo.muShield.dZ2,ship_geo.muShield.dZ3,ship_geo.muShield.dZ4,ship_geo.muShield.dZ5,ship_geo.muShield.dZ6,ship_geo.muShield.LE) 
 elif ship_geo.muShieldDesign in [3, 4, 5, 6, 7, 9]:
  if not hasattr(ship_geo.muShield,"Field"):
        MuonShield = ROOT.ShipMuonShield(
            "MuonShield", ship_geo.muShieldDesign, "ShipMuonShield",
            ship_geo.muShield.z, ship_geo.muShield.dZ0, ship_geo.muShield.dZ1,
            ship_geo.muShield.dZ2, ship_geo.muShield.dZ3,
            ship_geo.muShield.dZ4, ship_geo.muShield.dZ5,
            ship_geo.muShield.dZ6, ship_geo.muShield.dZ7,
            ship_geo.muShield.dZ8, ship_geo.muShield.dXgap,
            ship_geo.muShield.LE, ship_geo.Yheight * 4. / 10.,
            ship_geo.cave.floorHeightMuonShield)
  else:
        MuonShield = ROOT.ShipMuonShield(
            "MuonShield", ship_geo.muShieldDesign, "ShipMuonShield",
            ship_geo.muShield.z, ship_geo.muShield.dZ0, ship_geo.muShield.dZ1,
            ship_geo.muShield.dZ2, ship_geo.muShield.dZ3,
            ship_geo.muShield.dZ4, ship_geo.muShield.dZ5,
            ship_geo.muShield.dZ6, ship_geo.muShield.dZ7,
            ship_geo.muShield.dZ8, ship_geo.muShield.dXgap,
            ship_geo.muShield.LE, ship_geo.Yheight * 4. / 10.,
               ship_geo.cave.floorHeightMuonShield,ship_geo.muShield.Field) 
 elif ship_geo.muShieldDesign == 8:
  MuonShield = ROOT.ShipMuonShield(ship_geo.muShieldGeo)
 
 detectorList.append(MuonShield)

 if not hasattr(ship_geo,"magnetDesign"):
 # backward compatibility
  magnet_design = 2
  if ship_geo.tankDesign == 5: magnet_design = 3
  if ship_geo.tankDesign == 6: magnet_design = 4
  ship_geo.magnetDesign = magnet_design
  ship_geo.Bfield.YokeWidth = 200.*u.cm 
  ship_geo.Bfield.YokeDepth = 200.*u.cm
  ship_geo.Bfield.CoilThick = 25.*u.cm
# sanity check, 2018 layout ship_geo.tankDesign == 6 has to be together with ship_geo.nuTauTargetDesign == 3
 if (ship_geo.tankDesign == 6 and ship_geo.nuTauTargetDesign != 3) or (ship_geo.tankDesign != 6 and ship_geo.nuTauTargetDesign == 3):
   print "version of tankDesign and nuTauTargetDesign are not compatible, should be 6 and 3, it is ",ship_geo.tankDesign, ship_geo.nuTauTargetDesign 
   exit()
 if ship_geo.strawDesign > 1 : 
  if ship_geo.magnetDesign>3:
   B = ship_geo.Bfield
   magnet = ROOT.ShipMagnet("Magnet","SHiP Magnet",B.z, ship_geo.magnetDesign, B.x, B.y, ship_geo.cave.floorHeightTankB, B.YokeWidth, B.YokeDepth, B.CoilThick)
#                                                               xaperture,  yaperture 
  else: 
   magnet = ROOT.ShipMagnet("Magnet","SHiP Magnet",ship_geo.Bfield.z, ship_geo.magnetDesign, ship_geo.Bfield.x, ship_geo.Bfield.y, ship_geo.cave.floorHeightTankB)
 else: magnet = ROOT.ShipMagnet("Magnet","SHiP Magnet",ship_geo.Bfield.z)
 detectorList.append(magnet)
  
 Veto = ROOT.veto("Veto", ROOT.kTRUE)   # vacuum tank
 Veto.SetLiquidVeto(1)  # liquid scintillator
 Veto.SetPlasticVeto(1) # plastic scintillator

 Veto.SetZpositions(ship_geo.vetoStation.z, ship_geo.TrackStation1.z, ship_geo.TrackStation2.z, \
                    ship_geo.TrackStation3.z, ship_geo.TrackStation4.z,ship_geo.tankDesign)
 Veto.SetTubZpositions(ship_geo.Chamber1.z,ship_geo.Chamber2.z,ship_geo.Chamber3.z,ship_geo.Chamber4.z,ship_geo.Chamber5.z,ship_geo.Chamber6.z)
 Veto.SetTublengths(ship_geo.chambers.Tub1length,ship_geo.chambers.Tub2length,ship_geo.chambers.Tub3length, \
                    ship_geo.chambers.Tub4length,ship_geo.chambers.Tub5length,ship_geo.chambers.Tub6length)
 Veto.SetB(ship_geo.Yheight/2.)
 Veto.SetFloorHeight(ship_geo.cave.floorHeightTankA,ship_geo.cave.floorHeightTankB)
 if ship_geo.tankDesign > 4: 
    dzX = ship_geo.zFocusX+ship_geo.target.z0    
    x1  = ship_geo.xMax/(ship_geo.Chamber1.z -ship_geo.chambers.Tub1length-dzX)*(ship_geo.TrackStation4.z-dzX)
    dzY = ship_geo.zFocusY+ship_geo.target.z0    
    y1  = ship_geo.Yheight/(ship_geo.Chamber1.z -ship_geo.chambers.Tub1length-dzY)*(ship_geo.TrackStation4.z-dzY)
    Veto.SetXYstart(x1,dzX,y1,dzY)
    Veto.SetVesselStructure(ship_geo.Veto.innerSupport,ship_geo.Veto.sensitiveThickness,ship_geo.Veto.outerSupport,\
                            ship_geo.Veto.innerSupportMed,ship_geo.Veto.lidThickness,ship_geo.Veto.sensitiveMed,\
                            ship_geo.Veto.outerSupportMed,ship_geo.Veto.decayMed,\
                            ship_geo.Veto.rib,ship_geo.Veto.ribMed)

 detectorList.append(Veto)
 if hasattr(ship_geo,'tauMudet'): # don't support old designs

  if ship_geo.muShieldDesign not in [2,3,4] and hasattr(ship_geo.tauMudet,'Xtot'):
   taumuondetector = ROOT.NuTauMudet("NuTauMudet", ship_geo.tauMudet.zMudetC,  ROOT.kTRUE)
   taumuondetector.SetDesign(ship_geo.nuTauTargetDesign)
   taumuondetector.SetTotDimensions(ship_geo.tauMudet.Xtot,ship_geo.tauMudet.Ytot, ship_geo.tauMudet.Ztot )
   taumuondetector.SetFeDimensions(ship_geo.tauMudet.XFe,ship_geo.tauMudet.YFe, ship_geo.tauMudet.ZFe)
   taumuondetector.SetRpcDimensions(ship_geo.tauMudet.XRpc,ship_geo.tauMudet.YRpc, ship_geo.tauMudet.ZRpc)
   taumuondetector.SetRpcGasDimensions(ship_geo.tauMudet.XGas,ship_geo.tauMudet.YGas, ship_geo.tauMudet.ZGas)
   taumuondetector.SetRpcStripDimensions(ship_geo.tauMudet.XStrip,ship_geo.tauMudet.YStrip, ship_geo.tauMudet.ZStrip)
   taumuondetector.SetRpcElectrodeDimensions(ship_geo.tauMudet.XEle,ship_geo.tauMudet.YEle, ship_geo.tauMudet.ZEle)
   taumuondetector.SetRpcPETDimensions(ship_geo.tauMudet.XPet,ship_geo.tauMudet.YPet, ship_geo.tauMudet.ZPet)
   taumuondetector.SetNFeInArm(ship_geo.tauMudet.NFe)
   taumuondetector.SetNRpcInArm(ship_geo.tauMudet.NRpc)
   taumuondetector.SetPillarDimensions(ship_geo.tauMudet.PillarX,ship_geo.tauMudet.PillarY, ship_geo.tauMudet.PillarZ)
   detectorList.append(taumuondetector)
   if ship_geo.nuTauTargetDesign==3: 
    taumuondetector.SetRpcDimDifferences(ship_geo.tauMudet.deltax, ship_geo.tauMudet.deltay)
   if ship_geo.nuTauTargetDesign<3:
    taumuondetector.SetReturnYokeDimensions(ship_geo.tauMudet.XRyoke,ship_geo.tauMudet.YRyoke, ship_geo.tauMudet.ZRyoke)
    taumuondetector.SetSmallerYokeDimensions(ship_geo.tauMudet.XRyoke_s,ship_geo.tauMudet.YRyoke_s, ship_geo.tauMudet.ZRyoke_s)
    taumuondetector.SetZDimensionArm(ship_geo.tauMudet.ZArm)
    taumuondetector.SetGapDownstream(ship_geo.tauMudet.GapD)
    taumuondetector.SetGapMiddle(ship_geo.tauMudet.GapM)
    taumuondetector.SetMagneticField(ship_geo.tauMudet.B)
    taumuondetector.SetCoilParameters(ship_geo.tauMudet.CoilH, ship_geo.tauMudet.CoilW, ship_geo.tauMudet.N, ship_geo.tauMudet.CoilG)

   if ship_geo.nuTauTargetDesign==0 or ship_geo.nuTauTargetDesign==1 or ship_geo.nuTauTargetDesign==3:
    EmuMagnet = ROOT.EmulsionMagnet("EmuMagnet",ship_geo.EmuMagnet.zC,"EmulsionMagnet")
    EmuMagnet.SetDesign(ship_geo.EmuMagnet.Design)
    EmuMagnet.SetGaps(ship_geo.EmuMagnet.GapUp, ship_geo.EmuMagnet.GapDown)
    EmuMagnet.SetMagneticField(ship_geo.EmuMagnet.B)
    EmuMagnet.SetConstantField(ship_geo.EmuMagnet.WithConstField)
    EmuMagnet.SetMagnetSizes(ship_geo.EmuMagnet.X, ship_geo.EmuMagnet.Y, ship_geo.EmuMagnet.Z)
    if ship_geo.nuTauTargetDesign==0 or ship_geo.nuTauTargetDesign==1:
      EmuMagnet.SetCoilParameters(ship_geo.EmuMagnet.Radius, ship_geo.EmuMagnet.Height1, ship_geo.EmuMagnet.Height2, ship_geo.EmuMagnet.Distance)
    if ship_geo.nuTauTargetDesign==3:
      EmuMagnet.SetCoilParameters(ship_geo.EmuMagnet.CoilX,ship_geo.EmuMagnet.CoilY,ship_geo.EmuMagnet.Height1, ship_geo.EmuMagnet.Height2, ship_geo.EmuMagnet.Thickness) 
      EmuMagnet.SetCutDimensions(ship_geo.EmuMagnet.CutLength, ship_geo.EmuMagnet.CutHeight)
    EmuMagnet.SetMagnetColumn(ship_geo.EmuMagnet.ColX, ship_geo.EmuMagnet.ColY, ship_geo.EmuMagnet.ColZ)
    EmuMagnet.SetBaseDim(ship_geo.EmuMagnet.BaseX, ship_geo.EmuMagnet.BaseY, ship_geo.EmuMagnet.BaseZ)
    EmuMagnet.SetPillarDimensions(ship_geo.EmuMagnet.PillarX, ship_geo.EmuMagnet.PillarY, ship_geo.EmuMagnet.PillarZ)
    detectorList.append(EmuMagnet)
   if ship_geo.nuTauTargetDesign==2:
     EmuMagnet = ROOT.EmulsionMagnet()

   NuTauTarget = ROOT.Target("NuTauTarget",ship_geo.NuTauTarget.Ydist,ROOT.kTRUE)
   NuTauTarget.MakeNuTargetPassive(ship_geo.NuTauTarget.nuTargetPassive)
   if hasattr(ship_geo.NuTauTarget,"SingleEmFilm"): #for backward compatibility
    NuTauTarget.MergeTopBot(ship_geo.NuTauTarget.SingleEmFilm)
   NuTauTarget.SetDetectorDesign(ship_geo.NuTauTarget.Design)
   if ship_geo.nuTauTargetDesign!=3:
    NuTauTarget.SetCenterZ(ship_geo.NuTauTarget.zC)
   if ship_geo.nuTauTargetDesign==3:
    NuTauTarget.SetCenterZ(ship_geo.EmuMagnet.zC) #now the centers of emumagnet and nutautarget are different (target does not include HPT)
    NuTauTarget.SetNumberTargets(ship_geo.NuTauTarget.target)
    NuTauTarget.SetHpTParam(ship_geo.tauHPT.nHPT, ship_geo.tauHPT.distHPT, ship_geo.tauHPT.DZ) 
   NuTauTarget.SetNumberBricks(ship_geo.NuTauTarget.col,ship_geo.NuTauTarget.row,ship_geo.NuTauTarget.wall)
   NuTauTarget.SetDetectorDimension(ship_geo.NuTauTarget.xdim, ship_geo.NuTauTarget.ydim, ship_geo.NuTauTarget.zdim)
   NuTauTarget.SetEmulsionParam(ship_geo.NuTauTarget.EmTh, ship_geo.NuTauTarget.EmX, ship_geo.NuTauTarget.EmY, ship_geo.NuTauTarget.PBTh,ship_geo.NuTauTarget.EPlW, ship_geo.NuTauTarget.LeadTh, ship_geo.NuTauTarget.AllPW)
   NuTauTarget.SetBrickParam(ship_geo.NuTauTarget.BrX, ship_geo.NuTauTarget.BrY, ship_geo.NuTauTarget.BrZ, ship_geo.NuTauTarget.BrPackX, ship_geo.NuTauTarget.BrPackY, ship_geo.NuTauTarget.BrPackZ)
   NuTauTarget.SetCESParam(ship_geo.NuTauTarget.RohG, ship_geo.NuTauTarget.LayerCESW, ship_geo.NuTauTarget.CESW, ship_geo.NuTauTarget.CESPack)
   NuTauTarget.SetCellParam(ship_geo.NuTauTarget.CellW)
   if ship_geo.nuTauTargetDesign==0 or ship_geo.nuTauTargetDesign==1:
    NuTauTarget.SetMagnetHeight(ship_geo.EmuMagnet.Y)
    NuTauTarget.SetColumnHeight(ship_geo.EmuMagnet.ColY)
    NuTauTarget.SetBaseHeight(ship_geo.EmuMagnet.BaseY)
    NuTauTarget.SetCoilUpHeight(ship_geo.EmuMagnet.Height1)
    NuTauTarget.SetCoilDownHeight(ship_geo.EmuMagnet.Height2)
   if ship_geo.nuTauTargetDesign!=2:
    NuTauTarget.SetMagneticField(ship_geo.EmuMagnet.B)
   if ship_geo.nuTauTargetDesign==2:
    NuTauTarget.SetPillarDimension(ship_geo.NuTauTarget.PillarX,ship_geo.NuTauTarget.PillarY,ship_geo.NuTauTarget.PillarZ)
    NuTauTarget.SetBaseDimension(ship_geo.NuTauTarget.BaseX, ship_geo.NuTauTarget.BaseY, ship_geo.NuTauTarget.BaseZ)
  
   NuTauTT = ROOT.TargetTracker("TargetTrackers",ROOT.kTRUE)
   NuTauTT.SetDesign(ship_geo.NuTauTT.design)
   NuTauTT.SetTargetTrackerParam(ship_geo.NuTauTT.TTX, ship_geo.NuTauTT.TTY, ship_geo.NuTauTT.TTZ)
   NuTauTT.SetBrickParam(ship_geo.NuTauTarget.CellW)
   NuTauTT.SetTotZDimension(ship_geo.NuTauTarget.zdim)
   NuTauTT.SetNumberTT(ship_geo.NuTauTT.n)

  #method of nutau target that must be called after TT parameter definition
   NuTauTarget.SetTTzdimension(ship_geo.NuTauTT.TTZ)
 
   detectorList.append(NuTauTarget)
   detectorList.append(NuTauTT)

   tauHpt = ROOT.Hpt("HighPrecisionTrackers",ship_geo.tauHPT.DX, ship_geo.tauHPT.DY, ship_geo.tauHPT.DZ, ROOT.kTRUE)
   tauHpt.SetZsize(ship_geo.tauMudet.Ztot)
   tauHpt.SetDesign(ship_geo.NuTauTarget.Design)
   if ship_geo.nuTauTargetDesign<3:
    tauHpt.SetConcreteBaseDim(ship_geo.tauHPT.ConcreteX,ship_geo.tauHPT.ConcreteY,ship_geo.tauHPT.ConcreteZ)
   if ship_geo.nuTauTargetDesign==3:
    tauHpt.SetHPTNumber(ship_geo.tauHPT.nHPT)
    tauHpt.SetDistanceHPTs(ship_geo.tauHPT.distHPT)
    tauHpt.SetSurroundingDetHeight(ship_geo.tauHPT.SRDY)
    tauHpt.GetMagnetGeometry(ship_geo.EmuMagnet.zC, ship_geo.EmuMagnet.Y)
    tauHpt.GetNumberofTargets(ship_geo.NuTauTarget.target)
   detectorList.append(tauHpt)

 # for backward compatibility
 if not hasattr(ship_geo.strawtubes, "YPlaneOffset"):
   ship_geo.strawtubes.YLayerOffset = ship_geo.strawtubes.StrawPitch  / 2.
   ship_geo.strawtubes.YPlaneOffset = ship_geo.strawtubes.StrawPitch  / 4.
 if ship_geo.strawDesign > 1 :
  # for backward compatibility
  if ship_geo.strawDesign == 10 and not hasattr(ship_geo.strawtubes, "DeltazFrame"):
   ship_geo.strawtubes.DeltazFrame = 2.5*u.cm
   ship_geo.strawtubes.FrameLateralWidth = 1.2*u.m
   ship_geo.strawtubes.FrameMaterial = "steel"
  elif not hasattr(ship_geo.strawtubes, "DeltazFrame"):
   ship_geo.strawtubes.DeltazFrame = 10.*u.cm
   ship_geo.strawtubes.FrameLateralWidth = 1.*u.cm
   ship_geo.strawtubes.FrameMaterial = "aluminium"

  Strawtubes = ROOT.strawtubes("Strawtubes", ROOT.kTRUE)    
  Strawtubes.SetZpositions(ship_geo.vetoStation.z, ship_geo.TrackStation1.z, ship_geo.TrackStation2.z, ship_geo.TrackStation3.z, ship_geo.TrackStation4.z)
  Strawtubes.SetDeltazFrame(ship_geo.strawtubes.DeltazFrame)
  Strawtubes.SetFrameLateralWidth(ship_geo.strawtubes.FrameLateralWidth)
  Strawtubes.SetFrameMaterial(ship_geo.strawtubes.FrameMaterial)
  Strawtubes.SetDeltazView(ship_geo.strawtubes.DeltazView)
  Strawtubes.SetInnerStrawDiameter(ship_geo.strawtubes.InnerStrawDiameter)
  Strawtubes.SetOuterStrawDiameter(ship_geo.strawtubes.OuterStrawDiameter)
  Strawtubes.SetStrawPitch(ship_geo.strawtubes.StrawPitch,ship_geo.strawtubes.YLayerOffset,ship_geo.strawtubes.YPlaneOffset)
  Strawtubes.SetDeltazLayer(ship_geo.strawtubes.DeltazLayer)
  Strawtubes.SetDeltazPlane(ship_geo.strawtubes.DeltazPlane)
  Strawtubes.SetStrawsPerLayer(ship_geo.strawtubes.StrawsPerLayer)
  Strawtubes.SetStereoAngle(ship_geo.strawtubes.ViewAngle)
  Strawtubes.SetWireThickness(ship_geo.strawtubes.WireThickness)
  Strawtubes.SetVacBox_x(ship_geo.strawtubes.VacBox_x)
  Strawtubes.SetVacBox_y(ship_geo.strawtubes.VacBox_y)
  Strawtubes.SetStrawLength(ship_geo.strawtubes.StrawLength)
 
  if hasattr(ship_geo.strawtubes,"StrawLengthVeto"):
   Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLengthVeto) 
   Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength12)
   Strawtubes.SetVetoYDim(ship_geo.strawtubes.vetoydim)  
   Strawtubes.SetTr12YDim(ship_geo.strawtubes.tr12ydim)
   Strawtubes.SetTr34YDim(ship_geo.strawtubes.tr34ydim)    
  else:
   Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLength) 
   Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength)
   Strawtubes.SetVetoYDim(ship_geo.Yheight/2.)  
   Strawtubes.SetTr12YDim(ship_geo.Yheight/2.)
   Strawtubes.SetTr34YDim(ship_geo.Yheight/2.)    
  # for the digitizing step
  Strawtubes.SetStrawResolution(getParameter("strawtubes.v_drift",ship_geo,latestShipGeo),getParameter("strawtubes.sigma_spatial",ship_geo,latestShipGeo) )
  detectorList.append(Strawtubes)

 if ship_geo.EcalOption == 1:  # shashlik design TP 
  if ship_geo.preshowerOption > 0 :
   Preshower = ROOT.preshower("Preshower", ROOT.kTRUE)
   Preshower.SetZStationPosition2(ship_geo.PreshowerStation0.z,ship_geo.PreshowerStation1.z)
   Preshower.SetZFilterPosition2(ship_geo.PreshowerFilter0.z,ship_geo.PreshowerFilter1.z)
   Preshower.SetXMax(ship_geo.Preshower.XMax)
   Preshower.SetYMax(ship_geo.Preshower.YMax)
   Preshower.SetActiveThickness(ship_geo.Preshower.ActiveThickness)
   Preshower.SetFilterThickness2(ship_geo.Preshower.FilterThickness0,ship_geo.Preshower.FilterThickness1)
   detectorList.append(Preshower)

  ecal,EcalZSize = posEcal(ship_geo.ecal.z,ship_geo.ecal.File)
  detectorList.append(ecal)

 if ship_geo.EcalOption == 2:  # splitCal with pointing information
  SplitCal = ROOT.splitcal("SplitCal", ROOT.kTRUE)
  x = ship_geo.SplitCal 
  SplitCal.SetThickness(x.ActiveECALThickness,x.ActiveHCALThickness,x.FilterECALThickness,x.FilterECALThickness_first,x.FilterHCALThickness,x.ActiveECAL_gas_Thickness)
  SplitCal.SetMaterial(x.ActiveECALMaterial,x.ActiveHCALMaterial,x.FilterECALMaterial ,x.FilterHCALMaterial)
  SplitCal.SetNSamplings(x.nECALSamplings,x.nHCALSamplings,x.ActiveHCAL)
  SplitCal.SetZStart(x.ZStart)
  SplitCal.SetXMax(x.XMax)
  SplitCal.SetYMax(x.YMax)
  SplitCal.SetEmpty(x.Empty,x.BigGap,x.ActiveECAL_gas_gap,x.first_precision_layer,x.second_precision_layer,x.third_precision_layer,x.num_precision_layers)
  SplitCal.SetNModules(x.NModulesInX, x.NModulesInY)
  SplitCal.SetNStrips(x.NStripsPerModule)
  SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength)
  detectorList.append(SplitCal)

 if not ship_geo.HcalOption < 0:
  hcal,HcalZSize = posHcal(ship_geo.hcal.z,ship_geo.hcal.File,ship_geo.HcalOption)
  if ship_geo.HcalOption!=2 and abs(ship_geo.hcal.hcalSpace -  HcalZSize) > 10*u.cm:
    print 'mismatch between hcalsize in geo file and python configuration'
    print ship_geo.hcal.hcalSpace -  HcalZSize, ship_geo.hcal.hcalSpace , HcalZSize
  detectorList.append(hcal)
 Muon = ROOT.muon("Muon", ROOT.kTRUE)
 Muon.SetZStationPositions(ship_geo.MuonStation0.z, ship_geo.MuonStation1.z,ship_geo.MuonStation2.z,ship_geo.MuonStation3.z)
 Muon.SetZFilterPositions(ship_geo.MuonFilter0.z, ship_geo.MuonFilter1.z,ship_geo.MuonFilter2.z)
 Muon.SetXMax(ship_geo.Muon.XMax)
 Muon.SetYMax(ship_geo.Muon.YMax)
 Muon.SetActiveThickness(ship_geo.Muon.ActiveThickness)
 Muon.SetFilterThickness(ship_geo.Muon.FilterThickness)
 detectorList.append(Muon)

 timeDet = ROOT.TimeDet("TimeDet", ROOT.kTRUE)
 timeDet.SetZposition(ship_geo.TimeDet.z)
 timeDet.SetBarZspacing(ship_geo.TimeDet.dzBarRow, ship_geo.TimeDet.dzBarCol)
 timeDet.SetBarZ(ship_geo.TimeDet.zBar)
 timeDet.SetSizeX(2 * ship_geo.TimeDet.DX)
 timeDet.SetSizeY(2 * ship_geo.TimeDet.DY)
 detectorList.append(timeDet)

#-----   Magnetic field   -------------------------------------------
 if not hasattr(ship_geo.Bfield,"fieldMap"):
  if ship_geo.strawDesign == 4 or ship_geo.strawDesign == 10 : fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max ,ship_geo.Bfield.z,2,ship_geo.Yheight/2.*u.m )  
  else :                                                      fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max ,ship_geo.Bfield.z,1,ship_geo.Yheight/2.*u.m )  
  if ship_geo.muShieldDesign==6: fMagField.IncludeTarget(ship_geo.target.xy, ship_geo.target.z0, ship_geo.target.length)
  run.SetField(fMagField)
#
 exclusionList = []
 #exclusionList = ["Muon","Ecal","Hcal","Strawtubes","TargetTrackers","NuTauTarget","HighPrecisionTrackers",\
 #                 "Veto","Magnet","MuonShield","TargetStation","NuTauMudet","EmuMagnet", "TimeDet"]
 for x in detectorList:
   if x.GetName() in exclusionList: continue
   run.AddModule(x)
# return list of detector elements
 detElements = {}
 for x in run.GetListOfModules(): detElements[x.GetName()]=x
 return detElements
Exemplo n.º 53
0
if not geoFile:
 geoFile = inputFile.replace('ship.','geofile_full.').replace('_rec.','.')
if geoFile[0:4] == "/eos":
  eospath = "root://eoslhcb.cern.ch/"+geoFile
  fgeo = ROOT.TFile.Open(eospath)
else:  
  fgeo = ROOT.TFile(geoFile)
sGeo = fgeo.FAIRGeom

if not fgeo.FindKey('ShipGeo'):
 # old geofile, missing Shipgeo dictionary
 if sGeo.GetVolume('EcalModule3') :  ecalGeoFile = "ecal_ellipse6x12m2.geo"
 else: ecalGeoFile = "ecal_ellipse5x10m2.geo" 
 print 'found ecal geo for ',ecalGeoFile
 # re-create geometry and mag. field
 ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, EcalGeoFile = ecalGeoFile )
else: 
 # new geofile, load Shipgeo dictionary written by run_simScript.py
  upkl    = Unpickler(fgeo)
  ShipGeo = upkl.load('ShipGeo')
  ecalGeoFile = ShipGeo.ecal.File

# -----Create geometry----------------------------------------------
import shipDet_conf
run = ROOT.FairRunSim()
modules = shipDet_conf.configure(run,ShipGeo)

gMan  = ROOT.gGeoManager
geoMat =  ROOT.genfit.TGeoMaterialInterface()
ROOT.genfit.MaterialEffects.getInstance().init(geoMat)
volDict = {}
Exemplo n.º 54
0
  print " for example -f  /eos/experiment/ship/data/muonDIS/muonDis_1.root"
  sys.exit()
if simEngine == "Nuage" and not inputFile:
 inputFile = 'Numucc.root'

print "FairShip setup for",simEngine,"to produce",nEvents,"events"
if (simEngine == "Ntuple" or simEngine == "MuonBack") and defaultInputFile :
  print 'input file required if simEngine = Ntuple or MuonBack'
  print " for example -f /eos/experiment/ship/data/Mbias/pythia8_Geant4-withCharm_onlyMuons_4magTarget.root"
  sys.exit()
ROOT.gRandom.SetSeed(theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure(DarkPhoton)      # load basic libraries, prepare atexit for python
# - muShieldDesign = 2  # 1=passive 5=active (default) 7=short design+magnetized hadron absorber
# - targetOpt      = 5  # 0=solid   >0 sliced, 5: 5 pieces of tungsten, 4 H20 slits, 17: Mo + W +H2O (default)
#   nuTauTargetDesign = 0 # 0 = TP, 1 = NEW with magnet, 2 = NEW without magnet, 3 = 2018 design
if charm == 0: ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, tankDesign = dv, \
                                                muShieldDesign = ds, nuTauTargetDesign=nud, CaloDesign=caloDesign, strawDesign=strawDesign, muShieldGeo=geofile)
else: ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py")

# switch off magnetic field to measure muon flux
#ship_geo.muShield.Field = 0.
#ship_geo.EmuMagnet.B = 0.
#ship_geo.tauMudet.B = 0.


# Output file name, add dy to be able to setup geometry with ambiguities.
tag = simEngine+"-"+mcEngine
if charmonly: tag = simEngine+"CharmOnly-"+mcEngine
if eventDisplay: tag = tag+'_D'
if dv > 4 : tag = 'conical.'+tag
elif dy: tag = str(dy)+'.'+tag 
if not os.path.exists(outputDir):
Exemplo n.º 55
0
# analyze muon background /media/Data/HNL/PythiaGeant4Production/pythia8_Geant4_total.root 
import os,ROOT
import rootUtils as ut
import shipunit as u
PDG = ROOT.TDatabasePDG.Instance()
from ShipGeoConfig import ConfigRegistry
# init geometry and mag. field
ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py")
tgeom   = ROOT.TGeoManager("Geometry", "Geane geometry")

rz_inter = -1.,0.
def origin(it):
 at = sTree.MCTrack[it]
 im = at.GetMotherId()
 if im>0: origin(im)
 if im<0: 
   print 'does not come from muon'
   rz_inter = -1.,0.
 if im==0: 
   #print 'origin z',at.GetStartZ()
   rz_inter = ROOT.TMath.Sqrt(at.GetStartX()**2+at.GetStartY()**2),at.GetStartZ()

inputFile = 'ship.MuonBack-TGeant4.root'

withChain =  9  # 9  # 1

if withChain == 1:
 inputFile = 'ship.MuonBack-TGeant4_D.root'

# 11-19 with QGSP_BERT_EMV instead of QGSP_BERT_HP_PEN
# 51-59 passive shielding
Exemplo n.º 56
0
def pyExit():
    global fitter
    del fitter
    print "finishing pyExit"


import atexit

atexit.register(pyExit)

from array import array
import shipunit as u
import rootUtils as ut
from ShipGeoConfig import ConfigRegistry
if dy:
    ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py",
                                    Yheight=dy)
else:
    ShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py")
# -----Create geometry----------------------------------------------
import shipDet_conf

run = ROOT.FairRunSim()
modules = shipDet_conf.configure(run, ShipGeo)

addHNLtoROOT()

fout = ROOT.TFile(outFile, 'update')


def myVertex(t1, t2, PosDir):
    # closest distance between two tracks
Exemplo n.º 57
0
# nu_mu: inputFile = os.environ['SHIPSOFT']+'/data/Genie-mu+_nu_mu-gntp.113.gst.root'
if simEngine == "muonDIS" and not inputFile:
 inputFile = os.environ['SHIPSOFT']+'/data/muonDis.root' 
if simEngine == "Nuage" and not inputFile:
 inputFile = 'Numucc.root'

print "FairShip setup for",simEngine,"to produce",nEvents,"events"
if (simEngine == "Ntuple" or simEngine == "MuonBack") and not inputFile :
  print 'input file required if simEngine = Ntuple or MuonBack'
ROOT.gRandom.SetSeed(theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()      # load basic libraries, prepare atexit for python
# - muShieldDesign = 2  # 1=passive 2=active (default)
# - targetOpt      = 5  # 0=solid   >0 sliced, 5: 5 pieces of tungsten, 4 H20 slits, 17: Mo + W +H2O (default)
# - strawDesign    = 4  # simplistic tracker design,  4=sophisticated straw tube design, horizontal wires (default)
# - HcalOption     = -1 # no hcal,  0=hcal after muon,  1=hcal between ecal and muon (default)
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy)
# Output file name, add dy to be able to setup geometry with ambiguities.
tag = simEngine+"-"+mcEngine
if eventDisplay: tag = tag+'_D'
if dy: tag = str(dy)+'.'+tag 
if not os.path.exists(outputDir):
  os.makedirs(outputDir)
outFile = "%s/ship.%s.root" % (outputDir, tag)


# rm older files !!! 
os.system("rm %s/*.%s.root" % (outputDir, tag))
# Parameter file name
parFile="%s/ship.params.%s.root" % (outputDir, tag)

# In general, the following parts need not be touched
Exemplo n.º 58
0
 def tearDown(self):
     ConfigRegistry.clean()
     os.remove(self.filename)