File: 03-tools.py

package info (click to toggle)
fastjet 3.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,552 kB
  • sloc: cpp: 78,628; python: 6,112; sh: 1,038; fortran: 673; makefile: 636; ansic: 161
file content (81 lines) | stat: -rwxr-xr-x 2,497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python
"""Simple example to illustrate use of various FastJet tools in python.

For this script to work, make sure that the installation location for
the fastjet python module (cf. fastjet-config --pythonpath) is
included in your PYTHONPATH environment variable.

"""

from __future__ import print_function
from fastjet import *
import re
import copy

def main():
    event = read_event("../data/single-event.dat")
    print("Event has {} particles and is of type {}".format(len(event), type(event)))
    
    jet_def = JetDefinition(antikt_algorithm, 0.4)
    jets = SelectorPtMin(5.0)(jet_def(event))
    print(jets)
    print(len(jets))
    for jet in jets:
        print(jet.pt(), jet.rap())

    # select the hardest jet to play with
    print("---------- Selecting hardest jet ----------")
    hard_jet = SelectorNHardest(1)(jets)[0]
    print("Hard jet: ", hard_jet)
    print()
    
    # try boosting wrt the 2nd jet
    print("---------- testing (Un)boost ----------")
    prest = jets[1]
    boost=Unboost(prest)
    boosted_hard = boost(hard_jet)
    print("After (un)boosting ", boosted_hard)

    # try boosting all jets
    boosted_all = boost(jets)
    print("After (un)boosting all: ", boosted_all)
    print("Hardest became ", boosted_all[0])
    print("Prest became ", boosted_all[1])
    print()

    # try reclustering and run MDT
    print("---------- testing Recluster + MDT ----------")
    
    recluster = Recluster(cambridge_algorithm)
    print("Using recluster: ",recluster)
    rec_hard= recluster(hard_jet)
    print("reclustered hard jet: ", rec_hard)
    rec_all = recluster(jets)
    print("reclustered jets: ", rec_all)
    print("reclustered hard jet: ", rec_all[0])
    print()

    mdt = MassDropTagger(1.0, 0.09)
    print("Using MDT: ", mdt)
    mdt_hard = mdt.result(rec_hard)
    print("MDT'd hard jet (after recluster): ", mdt_hard)
    mdt_all = mdt(rec_all)
    print("MDT'd jets (after recluster): ", mdt_all)
    print("MDT'd hard jet (after recluster): ", mdt_all[0])
    mdt_hard_norec = mdt.result(hard_jet)
    print("MDT'd hard jet (no recluster --- warning expected): ", mdt_hard_norec)
    print()

#----------------------------------------------------------------------
def read_event(filename):
    f = open(filename, 'r')
    event = []
    for line in f:
        p = line.split()
        event.append(PseudoJet(float(p[0]),float(p[1]),float(p[2]),float(p[3])));

    return event
    
if __name__ == '__main__':
    main()