diff --git a/elena_ShipAna.py b/elena_ShipAna.py index e147c97..5c62bc9 100644 --- a/elena_ShipAna.py +++ b/elena_ShipAna.py @@ -20,7 +20,7 @@ PDG = ROOT.TDatabasePDG.Instance() inputFile = None dy = None -nEvents = 99999 +nEvents = 999999#99999 theHNLcode = 9900015 signal_file = False bg_file = False @@ -376,14 +376,19 @@ elenaTree, IP0 = tools.AddVar(elenaTree, 'IP0', 'float') elenaTree, Mass = tools.AddVar(elenaTree, 'Mass', 'float') elenaTree, Pt = tools.AddVar(elenaTree, 'Pt', 'float') +elenaTree, P = tools.AddVar(elenaTree, 'P', 'float') elenaTree, HNLw = tools.AddVar(elenaTree, 'HNLw', 'float') elenaTree, NuWeight = tools.AddVar(elenaTree, 'NuWeight', 'float') +elenaTree, EventNumber = tools.AddVar(elenaTree, 'EventNumber', 'int') +elenaTree, DaughterMinPt = tools.AddVar(elenaTree, 'DaughterMinPt', 'float') +elenaTree, DaughterMinP = tools.AddVar(elenaTree, 'DaughterMinP', 'float') def elenaEventLoop(N): entries = sTree.GetEntries() nEvents = min(entries,N) for n in range(nEvents): rc = sTree.GetEntry(n) + tools.PutToZero(EventNumber); tools.Push(EventNumber, n) key = -1 # loop over particles, 2-track combinations # From Thomas: @@ -397,15 +402,21 @@ if len(sTree.MCTrack) == 1 and len(sTree.Particles) > 0: print "There is an error somewhere! Particles out of nothing..." sys.exit() - if len(sTree.MCTrack) < 2: continue + if len(sTree.MCTrack) < 2: + print 1, n + continue nu_daughter = sTree.MCTrack[1] - if not isinstance(nu_daughter, ROOT.ShipMCTrack): continue + if not isinstance(nu_daughter, ROOT.ShipMCTrack): + print 2, n + continue nu_x = nu_daughter.GetStartX(); nu_y = nu_daughter.GetStartY(); nu_z = nu_daughter.GetStartZ() nu_energy = nu.GetEnergy() nu_w = tools.calcWeight(nu_x,nu_y,nu_z, nu_energy, nodes, entries, weightHist, file_type) tools.PutToZero(NuWeight); tools.Push(NuWeight, nu_w) for HNL in sTree.Particles: - if signal_file and not (HNL.GetPdgCode() == theHNLcode): continue + if signal_file and not (HNL.GetPdgCode() == theHNLcode): + print 3, n + continue #if bg_file and (HNL.GetPdgCode() == theHNLcode): continue # Fill hit arrays tools.PutToZero(straw_x); tools.PutToZero(straw_y); tools.PutToZero(straw_z) @@ -431,6 +442,7 @@ tools.PutToZero(HNLw); tools.Push(HNLw, w) tools.PutToZero(DaughtersTruthPDG); tools.PutToZero(DaughtersTruthMotherPDG) tools.PutToZero(DaughtersTruthProdX); tools.PutToZero(DaughtersTruthProdY); tools.PutToZero(DaughtersTruthProdZ); + p, pt = [], [] for tr in [t1,t2]: converged = 0 x = sTree.FitTracks[tr] @@ -441,12 +453,15 @@ PosDir[tr] = [xx.getPos(),xx.getDir()] h['CandidateDaughters-Pt'].Fill(xx.getMom().Pt()) tools.Push(DaughtersPt, xx.getMom().Pt()) + p.append(xx.getMom().Mag()); pt.append(xx.getMom().Pt()) h['CandidateDaughters-chi2'].Fill(x.getFitStatus().getChi2() / x.getNumPoints()) tools.Push(DaughtersChi2, x.getFitStatus().getChi2()) tools.Push(DaughtersNPoints, x.getNumPoints()) pdg, mumPdg, truthX, truthY, truthZ = tools.retrieveMCParticleInfo(sTree, tr) tools.Push(DaughtersTruthPDG, pdg); tools.Push(DaughtersTruthMotherPDG, mumPdg) tools.Push(DaughtersTruthProdX, truthX); tools.Push(DaughtersTruthProdY, truthY); tools.Push(DaughtersTruthProdZ, truthZ); + tools.Push(DaughterMinP, min(p)) + tools.Push(DaughterMinPt, min(pt)) xv,yv,zv,doca = myVertex(t1,t2,PosDir) h['Candidate-DOCA'].Fill(doca) tools.PutToZero(DOCA); tools.Push(DOCA, doca) @@ -474,8 +489,11 @@ tools.PutToZero(Mass); tools.Push(Mass, HNLMom.M()) h['Candidate-Pt'].Fill(HNLMom.Pt()) tools.PutToZero(Pt); tools.Push(Pt, HNLMom.Pt()) + tools.PutToZero(P); tools.Push(P, HNLMom.Mag()) elenaTree.SetDirectory(0) elenaTree.Fill() + #if n in [117149, 123463]: + # print doca, dist, Pt, DaughtersTruthPDG[0], DaughtersTruthPDG[1], DaughtersTruthProdZ[0], DaughtersTruthProdZ[1], zv, xv, yv, DaughtersFitConverged[0], DaughtersFitConverged[1] def HNLKinematics():