def originOfMuon(t, fl=None):
    leaves = t.GetListOfLeaves()
    nmax = t.GetEntries()
    evnrs = []
    leaves = h["T"].GetListOfLeaves()
    names = u.setAttributes(pyl, leaves)
    for n in range(nmax):
        rc = t.GetEntry(n)
        if not pyl.id:
            names = u.setAttributes(pyl, leaves)
        if abs(pyl.id.GetValue()) != 13:
            continue
        z = pyl.z.GetValue()
        y = pyl.y.GetValue()
        x = pyl.x.GetValue()
        pz = pyl.pz.GetValue()
        py = pyl.py.GetValue()
        px = pyl.px.GetValue()
        E = pyl.Ezero.GetValue()
        if z > 39.9 and z < 40.1 and abs(pz) > 0.1 and abs(x) < 2 and abs(y) < 2:
            evnrs.append(pyl.iev.GetValue())
            print "strange muon, original direction:", pyl.iev.GetValue(), n, px, py, pz, E, TMath.sqrt(
                px * px + py * py
            ) / pz
            print "             ", x, y, z
    if fl != None:
        for n in range(nmax):
            rc = t.GetEntry(n)
            ie = pyl.iev.GetValue()
            if ie in evnrs:
                z = pyl.z.GetValue()
                y = pyl.y.GetValue()
                x = pyl.x.GetValue()
                pz = pyl.pz.GetValue()
                py = pyl.py.GetValue()
                px = pyl.px.GetValue()
                E = pyl.Ezero.GetValue()
                if z < -50:
                    er, ex, ey, ep = extrap(-50 + 3.5, pyl)
                    print "pos at 3.5m", ex, ey, er
                    er, ex, ey, ep = extrap(-50 + 40, pyl)
                    print "pos at 40m", ex, ey, er
                else:
                    print "                                  ", pyl.iev.GetValue(), pyl.id.GetValue(), px, py, pz, E, TMath.sqrt(
                        px * px + py * py
                    ) / pz
                    print "             ", x, y, z
                    er, ex, ey, ep = extrap(10.5, pyl)
                    print "pos at 60m", ex, ey, er
    return evnrs
def dumpEvent(t,iev):
 t.SetEventList(0) 
 t.Draw(">>anEvent",'iev=='+str(int(iev)))
 h["anEvent"]=gROOT.FindObjectAny("anEvent")
 t.SetEventList(h["anEvent"])
 leaves = t.GetListOfLeaves()
 names  = u.setAttributes(pyl,leaves)
 for i in range( h["anEvent"].GetN() ):  
  t.GetEntry(h["anEvent"].GetEntry(i)) 
  if abs(leaves[0].GetValue())!=int(iev):
      print 'this should not happen' 
  z  = pyl.z.GetValue()
  y  = pyl.y.GetValue()
  x  = pyl.x.GetValue()
  pz = pyl.pz.GetValue()
  py = pyl.py.GetValue()
  px = pyl.px.GetValue()
  E  = pyl.Ezero.GetValue()
  pid= pyl.id.GetValue()
  volid  = pyl.volid.GetValue()
  procid = pyl.procid.GetValue()
  vname = ''
  pname = ''
  if dictVol.has_key(volid):    vname = dictVol[volid]
  if dictProc.has_key(procid):  pname = dictProc[procid]
  if z<-50. : vname = 'Pgun'
  theta = TMath.ATan(TMath.Sqrt(px*px+py*py)/(pz+0.0001))
  print 'id=%3i x=%5.3F y=%5.3F z=%5.3F r=%5.3F E=%5.3F  theta=%5.3F %s %s'%(pid,x,y,z,TMath.Sqrt(x*x+y*y),E,theta,vname,pname)
  if pz>0 : 
    r,xdet,ydet,E = extrap(40.,pyl)
    print '           extrap to z=40m: x=%5.3F y=%5.3F r=%5.3F  '%(xdet,ydet,r)
def energyLoss():
    t = h["T"]
    u.bookHist(h, "elossW", "energy loss as function of distance in W", 100, 0.0, 50.0, 100, 0.0, 300.0)
    u.bookHist(h, "elossPb", "energy loss as function of distance in Pb", 100, 0.0, 50.0, 100, 0.0, 200.0)
    u.bookHist(h, "elossFe", "energy loss as function of distance in Fe", 100, 0.0, 50.0, 100, 0.0, 200.0)
    nmax = t.GetEntries()
    leaves = t.GetListOfLeaves()
    names = u.setAttributes(pyl, leaves)
    for n in range(nmax):
        rc = t.GetEntry(n)
        nmeas = int(pyl.Nmeas.GetValue())
        measW = {}
        measPb = {}
        measFe = {}
        w = pyl.w.GetValue()
        for j in range(nmeas):
            volid = int(pyl.volid.GetValue(j))
            procid = int(pyl.procid.GetValue(j))
            z = pyl.z.GetValue(j)
            px = pyl.px.GetValue(j)
            py = pyl.py.GetValue(j)
            pz = pyl.pz.GetValue(j)
            E = math.sqrt(px * px + py * py + pz * pz + Mmu2)
            if volid == 0 and procid < 0:
                # attention, there are entry and exit points !
                if not measW.has_key(0):
                    measW[0] = [z, E]
            elif (volid > 3 and volid < 7) and procid < 0:  # enter Pbshield1
                if not measW.has_key(1):
                    measW[1] = [z, E]
            if volid == 4 and procid < 0:
                if not measPb.has_key(0):
                    measPb[0] = [z, E]
            elif volid == 6 and procid < 0:
                if not measPb.has_key(1):
                    measPb[1] = [z, E]
                if not measFe.has_key(0):
                    measFe[0] = [z, E]
            elif volid != 6 and measFe.has_key(0) and procid < 0:
                if not measFe.has_key(1):
                    measFe[1] = [z, E]
        if len(measW) == 2:
            dist = measW[1][0] - measW[0][0]
            Eloss = measW[0][1] - measW[1][1]
            h["elossW"].Fill(dist, Eloss, w)
        if len(measPb) == 2:
            dist = measPb[1][0] - measPb[0][0]
            Eloss = measPb[0][1] - measPb[1][1]
            h["elossPb"].Fill(dist, Eloss, w)
        if len(measFe) == 2:
            dist = measFe[1][0] - measFe[0][0]
            Eloss = measFe[0][1] - measFe[1][1]
            h["elossFe"].Fill(dist, Eloss, w)
    h["mean_elossW"] = h["elossW"].ProfileX()
    h["mean_elossW"].SetTitle("mean energy loss as function of distance in W")
    h["mean_elossPb"] = h["elossPb"].ProfileX()
    h["mean_elossPb"].SetTitle("mean energy loss as function of distance in Pb")
    h["mean_elossFe"] = h["elossFe"].ProfileX()
    h["mean_elossFe"].SetTitle("mean energy loss as function of distance in Fe")
Beispiel #4
0
run = ROOT.FairRunSim()
modules = shipDet_conf.configure(run,ShipGeo)

tgeom = ROOT.TGeoManager("Geometry", "Geane geometry")
geofile = inputFile.replace('ship.','geofile_full.').replace('_rec.','.')
gMan  = tgeom.Import(geofile)
geoMat =  ROOT.genfit.TGeoMaterialInterface()
ROOT.genfit.MaterialEffects.getInstance().init(geoMat)

bfield = ROOT.genfit.BellField(ShipGeo.Bfield.max, ShipGeo.Bfield.z,2)
fM = ROOT.genfit.FieldManager.getInstance()
fM.init(bfield)

ev     = ut.PyListOfLeaves()
leaves = sTree.GetListOfLeaves()
names  = ut.setAttributes(ev, leaves)

h = {}
ut.bookHist(h,'delPOverP','delP / P',100,0.,50.,100,-0.5,0.5)
ut.bookHist(h,'delPOverP2','delP / P chi2/nmeas<25',100,0.,50.,100,-0.5,0.5)
ut.bookHist(h,'chi2','chi2/nmeas after trackfit',100,0.,100.)
ut.bookHist(h,'IP','Impact Parameter',100,0.,10.)
ut.bookHist(h,'Doca','Doca between two tracks',100,0.,10.)
ut.bookHist(h,'IP0','Impact Parameter to target',100,0.,100.)
ut.bookHist(h,'IP0/mass','Impact Parameter to target vs mass',100,0.,2.,100,0.,100.)
ut.bookHist(h,'HNL','reconstructed Mass',100,0.,2.)
ut.bookHist(h,'meas','number of measurements',40,-0.5,39.5)
ut.bookHist(h,'measVSchi2','number of measurements vs chi2/meas',40,-0.5,39.5,100,0.,100.)
ut.bookHist(h,'distu','distance to wire',100,0.,1.)
ut.bookHist(h,'distv','distance to wire',100,0.,1.)
ut.bookHist(h,'disty','distance to wire',100,0.,1.)
if not found :
 for x in os.listdir('.'):
  if not x.find('flux_')<0 and not x.find('.root')<0:
# make the new ntuple format
   os.system('python $HNL/G4NewNtuple.py')
   fname = x.replace('.root','_br.root')
   found = True
   break  

print 'start analyzing file ',fname
h['f']  = TFile(fname)
h['T']  = h['f'].FindObjectAny('ntuple')
gROOT.cd()
pyl    = u.PyListOfLeaves()                           
leaves = h['T'].GetListOfLeaves()
names  = u.setAttributes(pyl,leaves)
Ntot         = nEvents() * 10 #(for phi symmetry)
extrapFactor = 1./10.         # weight made for 5E13 pot in g4Ex.py, each event used 11times (phi symmetry)
                              # corrected 19.3.2014, had assumed 10x    
                              # however, 10 jobs are running now in parallel 24.4., what does it mean for the number of events and extrapFactor ?  
                              # change from 11 to 10,  25.4. TR 
                              # since 19 June, also running without additional factor 10. How to check automatically ? multiplicity of event number ?

u.bookHist(h,'x','p',1000,300,350)
h['T'].Draw('Ezero>>x')
h['x'].Fit('pol0')
fx  = h['x'].GetFunction('pol0')
extrapFactor = 1./ int(fx.GetParameter(0))
print 'IMPORTANT: extrapolation factor used =',extrapFactor

eX = str(extrapFactor)
Beispiel #6
0
run = ROOT.FairRunSim()
modules = shipDet_conf.configure(run, ShipGeo)

tgeom = ROOT.TGeoManager("Geometry", "Geane geometry")
geofile = inputFile.replace('ship.', 'geofile_full.').replace('_rec.', '.')
gMan = tgeom.Import(geofile)
geoMat = ROOT.genfit.TGeoMaterialInterface()
ROOT.genfit.MaterialEffects.getInstance().init(geoMat)

bfield = ROOT.genfit.BellField(ShipGeo.Bfield.max, ShipGeo.Bfield.z, 2)
fM = ROOT.genfit.FieldManager.getInstance()
fM.init(bfield)

ev = ut.PyListOfLeaves()
leaves = sTree.GetListOfLeaves()
names = ut.setAttributes(ev, leaves)

h = {}
ut.bookHist(h, 'delPOverP', 'delP / P', 100, 0., 50., 100, -0.5, 0.5)
ut.bookHist(h, 'delPOverP2', 'delP / P chi2/nmeas<25', 100, 0., 50., 100, -0.5,
            0.5)
ut.bookHist(h, 'chi2', 'chi2/nmeas after trackfit', 100, 0., 100.)
ut.bookHist(h, 'IP', 'Impact Parameter', 100, 0., 10.)
ut.bookHist(h, 'Doca', 'Doca between two tracks', 100, 0., 10.)
ut.bookHist(h, 'IP0', 'Impact Parameter to target', 100, 0., 100.)
ut.bookHist(h, 'IP0/mass', 'Impact Parameter to target vs mass', 100, 0., 2.,
            100, 0., 100.)
ut.bookHist(h, 'HNL', 'reconstructed Mass', 100, 0., 2.)
ut.bookHist(h, 'meas', 'number of measurements', 40, -0.5, 39.5)
ut.bookHist(h, 'measVSchi2', 'number of measurements vs chi2/meas', 40, -0.5,
            39.5, 100, 0., 100.)