#!/usr/local/bin/python -i import sys, itertools, aa from ROOT import * # This example does a simple analysis of a DU-2 run. It plots # the number of hits, number of trigger hits, and number of # unique doms in an event. # Open the event file. Irods pattern is recognized and file is # automatically staged to EventFile.stagedir f = EventFile("/in2p3/km3net/data/raw/sea/KM3NeT_00000007/1/KM3NeT_00000007_00001921.root") # declare the histograms (this is just ROOT) h_nhits = TH1D("h_nhits","h_nhits",50,0,100); h_ntrighits = TH1D("h_ntrighits","h_ntrighits",50,0,50); h_ndoms = TH1D("h_ndoms","h_ndoms",19,-0.5,18.5); h_nbigtotdoms = TH1D("h_nbigtotdoms","h_nbigtotdoms",19,-0.5,18.5); # Loop over the events in the file and file the histograms for evt in f: if f.index ==0 : print "time of first event:", evt.t.AsString() # print all hits in first event for h in evt.hits : print h # number of hits - simply vector::size() h_nhits.Fill( evt.hits.size() ) # compute number of triggered hits - the ntrighits = 0 for h in evt.hits : if h.trig : ntrighits+=1 # compute nhtrighits again, now with the equivalent python generator expression ntrighits = sum( h.trig for h in evt.hits ) h_ntrighits.Fill( ntrighits ) # number of unique doms that have a hit... = size of the set of dom_id's h_ndoms.Fill( len( { h.dom_id for h in evt.hits } ) ) # python set comprehension # same as above but only if one of the hits has TOT>30. h_nbigtotdoms.Fill( len( { h.dom_id for h in evt.hits if h.tot > 30 } ) ) c = TCanvas("c","c",800,800); c.Divide(2,2); c.cd(1); h_nhits.Draw() c.cd(2); h_ntrighits.Draw(); c.cd(3); h_ndoms.Draw(); c.cd(4); h_nbigtotdoms.Draw();